00001
00002
00004 #ifndef __Triggers__
00005 #define __Triggers__
00006
00007 #include "Chain.h"
00008 #include "TTreeIndex.h"
00009 #include "Segments.h"
00010
00011 using namespace std;
00012
00026 class Triggers {
00027
00028 public:
00029
00044 Triggers(const int aVerbose=0);
00045
00049 virtual ~Triggers(void);
00070 bool AddTrigger(const double aTime, const double aFrequency,
00071 const double aSNR, const double aQ,
00072 const double aTstart, const double aTend,
00073 const double aFstart, const double aFend,
00074 const double aAmplitude, const double aPhase);
00075
00079 bool SortTriggers(void);
00080
00090 bool SetTriggerBranchStatus(const string aBname, const bool aStatus = true);
00091
00095 inline int GetNTrig(void){ return Ttree->GetEntries(); };
00096
00100 inline int GetNtrig(void){ return Ttree->GetEntries(); };
00101
00105 inline int GetNTriggers(void){ return Ttree->GetEntries(); };
00106
00110 inline int GetNtriggers(void){ return Ttree->GetEntries(); };
00111
00117 string GetTriggerFile(const int aTr);
00118
00124 inline double GetTriggerTime(const int aTr){
00125 if(Ttree->GetEntry(aTr)>0) return Ttime;
00126 return 0.0;
00127 };
00128
00134 inline double GetTriggerFrequency(const int aTr){
00135 if(Ttree->GetEntry(aTr)>0) return Tfreq;
00136 return 0.0;
00137 };
00138
00144 double GetTriggerSNR(const int aTr){
00145 if(Ttree->GetEntry(aTr)>0) return Tsnr;
00146 return 0.0;
00147 };
00148
00154 double GetTriggerAmplitude(const int aTr){
00155 if(Ttree->GetEntry(aTr)>0) return Tamp;
00156 return 0.0;
00157 };
00158
00164 double GetTriggerQ(const int aTr){
00165 if(Ttree->GetEntry(aTr)>0) return Tq;
00166 return 0.0;
00167 };
00168
00174 double GetTriggerPhase(const int aTr){
00175 if(Ttree->GetEntry(aTr)>0) return Tph;
00176 return 0.0;
00177 };
00178
00184 double GetTriggerTimeStart(const int aTr){
00185 if(Ttree->GetEntry(aTr)>0) return Ttstart;
00186 return 0.0;
00187 };
00188
00194 double GetTriggerTimeEnd(const int aTr){
00195 if(Ttree->GetEntry(aTr)>0) return Ttend;
00196 return 0.0;
00197 };
00198
00204 inline double GetTriggerDuration(const int aTr){
00205 return GetTriggerTimeEnd(aTr)-GetTriggerTimeStart(aTr);
00206 };
00207
00213 double GetTriggerFrequencyStart(const int aTr){
00214 if(Ttree->GetEntry(aTr)>0) return Tfstart;
00215 return 0.0;
00216 };
00217
00223 double GetTriggerFrequencyEnd(const int aTr){
00224 if(Ttree->GetEntry(aTr)>0) return Tfend;
00225 return 0.0;
00226 };
00227
00233 double GetTriggerBandWidth(const int aTr){
00234 return GetTriggerFrequencyEnd(aTr)-GetTriggerFrequencyStart(aTr);
00235 };
00236
00242 int GetTriggerIndex(const double aTime);
00243
00254 Segments* GetTriggerSegments(TH1D *aThr=NULL, const double aInfValue=1e20);
00255
00260 void ResetClusters(void);
00261
00273 bool Clusterize(const int aTag=-1);
00274
00280 inline void SetClusterizeDt(const double aDt){Cdelta_t=aDt; return;};
00281
00287 inline void SetClusterizeSizeMin(const double aSizeMin){Csizemin=aSizeMin; return;};
00288
00294 inline void SetClusterizeSNRthr(const double aSNRthr){cl_snr_thr=aSNRthr; return;};
00295
00302 bool SetClusterTag(const int aCl, const int aNewTag);
00303
00309 inline void SetClusterTag(const int aNewTag){
00310 for(int c=0; c<Ctree->GetEntries(); c++) cl_tag[c]=aNewTag;
00311 };
00312
00322 bool SetClusterBranchStatus(const string aBname, const bool aStatus = true);
00323
00327 inline int GetNClust(void){return Ctree->GetEntries();};
00331 inline int GetNclust(void){return Ctree->GetEntries();};
00332
00336 inline int GetNClusters(void){return Ctree->GetEntries();};
00340 inline int GetNclusters(void){return Ctree->GetEntries();};
00341
00345 inline double GetClusterizeDt(void){return Cdelta_t;};
00346
00352 inline double GetClusterTime(const int aCl){
00353 if(Ctree->GetEntry(aCl)>0) return Ctime;
00354 return 0.0;
00355 };
00356
00362 inline double GetClusterFrequency(const int aCl){
00363 if(Ctree->GetEntry(aCl)>0) return Cfreq;
00364 return 0.0;
00365 };
00366
00372 inline double GetClusterSNR(const int aCl){
00373 if(Ctree->GetEntry(aCl)>0) return Csnr;
00374 return 0.0;
00375 };
00376
00382 inline double GetClusterAmplitude(const int aCl){
00383 if(Ctree->GetEntry(aCl)>0) return Camp;
00384 return 0.0;
00385 };
00386
00392 inline double GetClusterQ(const int aCl){
00393 if(Ctree->GetEntry(aCl)>0) return Cq;
00394 return 0.0;
00395 };
00396
00402 inline double GetClusterPhase(const int aCl){
00403 if(Ctree->GetEntry(aCl)>0) return Cph;
00404 return -100.0;
00405 };
00406
00412 inline double GetClusterTimeStart(const int aCl){
00413 if(Ctree->GetEntry(aCl)>0) return Ctstart;
00414 return 0.0;
00415 };
00416
00422 inline double GetClusterTimeEnd(const int aCl){
00423 if(Ctree->GetEntry(aCl)>0) return Ctend;
00424 return 0.0;
00425 };
00426
00432 inline double GetClusterDuration(const int aCl){
00433 return GetClusterTimeEnd(aCl)-GetClusterTimeStart(aCl);
00434 };
00435
00441 inline double GetClusterFrequencyStart(const int aCl){
00442 if(Ctree->GetEntry(aCl)>0) return Cfstart;
00443 return 0.0;
00444 };
00445
00451 inline double GetClusterFrequencyEnd(const int aCl){
00452 if(Ctree->GetEntry(aCl)>0) return Cfend;
00453 return 0.0;
00454 };
00455
00461 inline double GetClusterBandWidth(const int aCl){
00462 return GetClusterFrequencyEnd(aCl)-GetClusterFrequencyStart(aCl);
00463 };
00464
00470 inline int GetClusterSize(const int aCl){
00471 if(Ctree->GetEntry(aCl)>0) return (int)Csize;
00472 return 0;
00473 };
00474
00480 inline int GetClusterFirstTrigger(const int aCl){
00481 if(Ctree->GetEntry(aCl)>0) return (int)Cfirstentry;
00482 return -1;
00483 };
00484
00490 int GetClusterIndex(const double aTime);
00491
00497 inline int GetClusterTag(const int aCl){
00498 if(Ctree->GetEntry(aCl)>0) return cl_tag[aCl];
00499 return -100;
00500 }
00501
00505 inline double GetClusterMeanDuration(void){ return Cmeandur; };
00506
00510 inline double GetClusterMaxDuration(void){ return Cmaxdur; };
00511
00516 void ResetTriggers(void);
00517
00525 bool ReadTriggerFiles(const string aPattern, const string aDirectory);
00526
00527 protected:
00528
00529
00530 int Verbose;
00531
00532
00533 TTree *Ttree;
00534 Chain *Ttree_read;
00535 TTree *Ttree_make;
00536 double Ttime,
00537 Tfreq,
00538 Tq,
00539 Tsnr,
00540 Ttstart,
00541 Ttend,
00542 Tfstart,
00543 Tfend,
00544 Tamp,
00545 Tph;
00546
00547
00548 TTree *Ctree;
00549 double Ctime,
00550 Ctstart,
00551 Ctend,
00552 Cfreq,
00553 Cfstart,
00554 Cfend,
00555 Csnr,
00556 Camp,
00557 Cq,
00558 Cph;
00559 Long64_t Cfirstentry,
00560 Csize;
00561 int *cl_tag;
00562 double Cmeandur;
00563 double Cmaxdur;
00564
00565
00566 Long64_t *Toffsets;
00567
00568
00569 int Ttstart_ms;
00570
00571 private:
00572
00573
00574 bool readmode;
00575 int randid;
00576 string srandid;
00577
00578
00579 double Cdelta_t;
00580 int Csizemin;
00581 double cl_snr_thr;
00582 bool Clusterize_t(void);
00583
00584 ClassDef(Triggers,0)
00585 };
00586
00587 #endif
00588
00589