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);
00079 bool SetTriggerSamples(ReadTriggers *aTriggerSample0, ReadTriggers *aTriggerSample1, const double aTimeOffset0=0.0, const double aTimeOffset1=0.0, Segments *aValidSegments=NULL);
00080
00091 int MakeCoinc(void);
00092
00101 int MakeCoincWithSmartShift(void);
00102
00106 void PrintCoinc(void);
00107
00116 bool WriteCoinc(const string aOutDir, const string aOutFileName);
00117
00122 inline void SetCoincDt(const double aDt){ coinc_dt=aDt; return; };
00123
00128 inline void SetCoincDf(const double aDf){ coinc_df=aDf; return; };
00129
00134 inline void SetCoincAf(const double aAf){ coinc_af=aAf; return; };
00135
00139 inline int GetNCoinc(void){ return (int)CoC[0].size(); };
00140
00147 inline int GetClusterIndex(const int aSampleIndex, const int aCoincIndex){
00148 if(aCoincIndex < 0 || aCoincIndex >= GetNCoinc()) return -1;
00149 if(aSampleIndex < 0 || aSampleIndex >= 2) return -1;
00150 return CoC[aSampleIndex][aCoincIndex];
00151 };
00152
00158 inline void SetCoincTag(const int aCoincIndex, const bool aNewTag){
00159 if(aCoincIndex>=0&&aCoincIndex<GetNCoinc()) CoTag[aCoincIndex]=aNewTag;
00160 };
00161
00166 inline void SetCoincTag(const bool aNewTag){
00167 for(int c=0; c<(int)CoC[0].size(); c++) CoTag[c]=aNewTag;
00168 };
00169
00175 inline bool GetCoincTag(const int aCoincIndex){
00176 if(aCoincIndex>=0&&aCoincIndex<GetNCoinc()) return CoTag[aCoincIndex];
00177 return false;
00178 };
00179
00185 inline int GetNActiveClusters(const int aSampleIndex){
00186 if(aSampleIndex < 0 || aSampleIndex > 1) return -1;
00187 return nactive[aSampleIndex];
00188 };
00189
00193 inline double GetCoincLiveTime(void){ return CoSeg->GetLiveTime(); };
00194
00205
00206
00212
00213
00214 bool MakeComparators(const string aTriggerId0, const string aTriggerId1);
00215 bool PrintComparator(const string aComparatorName);
00216
00217 protected:
00218
00219
00220 int verbosity;
00221
00222
00223 ReadTriggers *triggers[2];
00224 double toffset[2];
00225 int nactive[2];
00226
00227
00228 vector <int> CoC[2];
00229 bool *CoTag;
00230 Segments *CoSeg;
00231 bool smartshift;
00232 TTree *CoTree;
00233
00234
00235 double coinc_dt;
00236 double coinc_df;
00237 double coinc_af;
00238
00239
00240 TH2D *h_ct[2];
00241 TH2D *h_ctcum[2];
00242 TH2D *h_ct_coinc[2];
00243 TH2D *h_ctcum_coinc[2];
00244
00245
00246 TH2D *hc_asnr;
00247 TH2D *hc_snrsnr;
00248 TH2D *hc_af;
00249 TH2D *hc_ff;
00250
00251
00252 private:
00253
00254 void SelectClusters(const int aSampleIndex);
00255
00256 inline double GetSmartShiftStart(const int aSampleIndex, const int aClIndex){
00257 return triggers[aSampleIndex]->GetClusterTimeEnd(aClIndex)+toffset[aSampleIndex]+triggers[aSampleIndex]->GetClusterizeDt()/2.0;
00258 };
00259
00260 inline double GetSmartShiftEnd(const int aSampleIndex, const int aClIndex){
00261 double te=triggers[aSampleIndex]->GetClusterTimeEnd(aClIndex)+toffset[aSampleIndex]+triggers[aSampleIndex]->GetClusterizeDt()/2.0+triggers[aSampleIndex]->GetClusterDuration(aClIndex);
00262 if(aClIndex==triggers[aSampleIndex]->GetNClusters()-1) return te;
00263 double temax=triggers[aSampleIndex]->GetClusterTimeStart(aClIndex+1)+toffset[aSampleIndex]-triggers[aSampleIndex]->GetClusterizeDt()/2.0;
00264 if(te<temax) return te;
00265 return temax;
00266 };
00267
00268 ClassDef(Coinc2,0)
00269 };
00270
00271 #endif
00272
00273