00001
00002
00004 #ifndef __Triggers__
00005 #define __Triggers__
00006
00007 #include "CUtils.h"
00008 #include "Segments.h"
00009 #include "Streams.h"
00010 #include "TFile.h"
00011 #include "TTree.h"
00012 #include "TTreeIndex.h"
00013
00014 using namespace std;
00015
00021 class Triggers {
00022
00023 public:
00024
00046 Triggers(const string aoutdir,
00047 const string aoutfile,
00048 const string afileformat="root",
00049 const int averbose=0);
00050
00054 virtual ~Triggers(void);
00075 bool AddTrigger(const double atime, const double afrequency,
00076 const double asnr, const double aq,
00077 const double atstart, const double atend,
00078 const double afstart, const double afend,
00079 const double aamp);
00080
00081
00090 bool AddSegment(const double gps_start, const double gps_end, const int tag=-1);
00091
00098 bool AddSegments(Segments *aSeg);
00099
00108 bool SetSegments(Segments *aSeg);
00109
00125 Segments* GetTriggerSegments(TH1D *aThr, const double aPadding=0.0, const double aInfValue=1e20);
00126
00127
00134 inline void SetMprocessname(const string aMprocessname){ Mprocessname=aMprocessname; };
00135
00142 inline void SetMstreamname(const string aMstreamname){ Mstreamname=aMstreamname; };
00143
00150 inline void SetMdetindex(const int aMdetindex){ Mdetindex=aMdetindex; };
00151
00159 bool InitUserMetaData(vector<string> aMusername, vector<string> aMusertype);
00160
00167 bool SetUserMetaData(const string aMusername, const double aMuservalue);
00168
00175 bool SetUserMetaData(const string aMusername, const int aMuservalue);
00176
00183 bool SetUserMetaData(const string aMusername, const string aMuservalue);
00184
00189 bool Reset(void);
00190
00212 string Write(const string mode="PROC", const string filename="default", const bool sorttriggers=true, const bool writemetadata=true);
00213
00258 bool SetClustering(const string Algo="TIME");
00259
00265 bool SetClusterDeltaT(const double DeltaT);
00266
00271 inline void SetVerbose(const int averbose){ fverbose=averbose; };
00272
00279 inline void SetNtriggerMax(const int aNmax){ NtriggerMax=aNmax; };
00280
00285 inline bool GetMaxFlag(void){ return Maxflag; };
00286
00290 inline bool GetNTrig(void){ return Ttree->GetEntries(); };
00291
00295 inline bool GetNtrig(void){ return Ttree->GetEntries(); };
00296
00302 inline bool SetOutputDirectory(const string aoutdir){
00303 if(!IsDirectory(aoutdir)){
00304 cerr<<"Triggers::SetOutputDirectory: output directory "<<aoutdir<<" does not exist"<<endl;
00305 return false;
00306 }
00307 foutdir=aoutdir;
00308 return true;
00309 };
00310
00311 protected:
00312
00313
00314 int fverbose;
00315 string foutdir;
00316 string foutfile;
00317 vector <string> ffileformat;
00318
00319
00320 bool status_OK;
00321 bool cluster_OK;
00322
00323
00324 TTree *Ttree;
00325 double Ttime,
00326 Tfreq,
00327 Tq,
00328 Tsnr,
00329 Ttstart,
00330 Ttend,
00331 Tfstart,
00332 Tfend,
00333 Tamp;
00334 int Ttstart_ms;
00335
00336
00337 Segments *Seg;
00338
00339
00340 Streams *Tstream;
00341
00342
00343 TTree *Mtree;
00344 double Mstart,
00345 Mend;
00346 string Mprocessname;
00347 string Mstreamname;
00348 int Mdetindex;
00349 double Mfmin,
00350 Mfmax,
00351 Mqmin,
00352 Mqmax,
00353 Msnrmin,
00354 Msnrmax;
00355 vector <string> Musername;
00356 vector <string> Musertype;
00357 double *Mdvar;
00358 int *Mivar;
00359 string *Msvar;
00360
00361
00362 TTree *Ctree;
00363 double Ctime,
00364 Cfreq,
00365 Cq,
00366 Csnr,
00367 Ctstart,
00368 Ctend,
00369 Cfstart,
00370 Cfend,
00371 Camp;
00372 string fAlgo;
00373 double Cdelta_t;
00374
00375
00376 int NtriggerMax;
00377 bool Maxflag;
00378
00379 private:
00380
00381 bool Clusterize(TTree *intree);
00382 bool Clusterize_t(TTree *intree);
00383 bool Clusterize_q(TTree *intree);
00384 bool WriteTXT(const string txtfilename, TTree *intree=NULL);
00385 bool WriteXML(const string xmlfilename, TTree *intree=NULL);
00386
00387
00388 ClassDef(Triggers,0)
00389 };
00390
00391 #endif
00392
00393