00001
00002
00004 #ifndef __Coinc2__
00005 #define __Coinc2__
00006
00007 #include "GwollumPlot.h"
00008 #include "ReadTriggers.h"
00009 #include "MakeTriggers.h"
00010 #include "TriggerSelect.h"
00011
00012 using namespace std;
00013
00019 class Coinc2 : public GwollumPlot {
00020
00021 public:
00022
00038 Coinc2(const int aVerbose=0);
00039
00053 Coinc2(ReadTriggers *aTriggerSample0, ReadTriggers *aTriggerSample1, const int aVerbose=0);
00054
00058 virtual ~Coinc2(void);
00078 bool SetTriggerSamples(ReadTriggers *aTriggerSample0, ReadTriggers *aTriggerSample1, const double aTimeOffset0=0.0, const double aTimeOffset1=0.0, Segments *aValidSegments=NULL);
00079
00090 int MakeCoinc(void);
00091
00100 int MakeCoincWithSmartShift(void);
00101
00105 void PrintCoinc(void);
00106
00115 bool WriteCoinc(const string aOutDir, const string aOutFileName);
00116
00121 inline void SetCoincDt(const double aDt){ coinc_dt=aDt; return; };
00122
00127 inline void SetCoincDf(const double aDf){ coinc_df=aDf; return; };
00128
00133 inline void SetCoincAf(const double aAf){ coinc_af=aAf; return; };
00134
00138 inline int GetNCoinc(void){ return (int)CoC[0].size(); };
00139
00146 inline int GetClusterIndex(const int aSampleIndex, const int aCoincIndex){
00147 if(aCoincIndex < 0 || aCoincIndex >= GetNCoinc()) return -1;
00148 if(aSampleIndex < 0 || aSampleIndex >= 2) return -1;
00149 return CoC[aSampleIndex][aCoincIndex];
00150 };
00151
00157 inline void SetCoincTag(const int aCoincIndex, const bool aNewTag){
00158 if(aCoincIndex>=0&&aCoincIndex<GetNCoinc()) CoTag[aCoincIndex]=aNewTag;
00159 };
00160
00165 inline void SetCoincTag(const bool aNewTag){
00166 for(int c=0; c<(int)CoC[0].size(); c++) CoTag[c]=aNewTag;
00167 };
00168
00174 inline bool GetCoincTag(const int aCoincIndex){
00175 if(aCoincIndex>=0&&aCoincIndex<GetNCoinc()) return CoTag[aCoincIndex];
00176 return false;
00177 };
00178
00189 bool MakeMonitors(const bool aWeighted = false);
00190
00196 bool WriteMonitors(const string aOutDir, const string aOutFileName);
00197
00198 bool MakeComparators(const string aTriggerId0, const string aTriggerId1);
00199 bool PrintComparator(const string aComparatorName);
00200
00201 protected:
00202
00203
00204 int verbosity;
00205
00206
00207 ReadTriggers *triggers[2];
00208 double toffset[2];
00209
00210
00211 vector <int> CoC[2];
00212 bool *CoTag;
00213 Segments *CoSeg;
00214 bool smartshift;
00215 TTree *CoTree;
00216
00217
00218 double coinc_dt;
00219 double coinc_df;
00220 double coinc_af;
00221
00222
00223 TH2D *h_n[2];
00224 TH2D *h_ncum[2];
00225 TH2D *h_ct[2];
00226 TH2D *h_ctcum[2];
00227 TH2D *h_n_coinc[2];
00228 TH2D *h_ncum_coinc[2];
00229 TH2D *h_n_nocoinc[2];
00230 TH2D *h_ncum_nocoinc[2];
00231
00232
00233 TH2D *hc_asnr;
00234 TH2D *hc_snrsnr;
00235 TH2D *hc_af;
00236 TH2D *hc_ff;
00237
00238
00239 private:
00240
00241 void SelectClusters(const int aSampleIndex);
00242
00243 inline double GetSmartShiftStart(const int aSampleIndex, const int aClIndex){
00244 return triggers[aSampleIndex]->GetClusterTimeEnd(aClIndex)+toffset[aSampleIndex]+triggers[aSampleIndex]->GetClusterizeDt()/2.0;
00245 };
00246
00247 inline double GetSmartShiftEnd(const int aSampleIndex, const int aClIndex){
00248 double te=triggers[aSampleIndex]->GetClusterTimeEnd(aClIndex)+toffset[aSampleIndex]+triggers[aSampleIndex]->GetClusterizeDt()/2.0+triggers[aSampleIndex]->GetClusterDuration(aClIndex);
00249 if(aClIndex==triggers[aSampleIndex]->GetNClusters()-1) return te;
00250 double temax=triggers[aSampleIndex]->GetClusterTimeStart(aClIndex+1)+toffset[aSampleIndex]-triggers[aSampleIndex]->GetClusterizeDt()/2.0;
00251 if(te<temax) return te;
00252 return temax;
00253 };
00254
00255 ClassDef(Coinc2,0)
00256 };
00257
00258 #endif
00259
00260