Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GetLiveTime.C
Go to the documentation of this file.
1 // This macro computes the livetime for each lag using the CWB::Toolbox::getLiveTime method
2 // NOTE : this macro works only for standard lags !!!
3 //
4 // The livetime obtained with this method is not exactly equals to the one computed
5 // in the CWB pipeline (network::getNetworkPixels).
6 //
7 // In the network::getNetworkPixels the livetime takes into account the time discretization
8 // used in the TF level with the maximum dt, while in the CWB::Toolbox::getLiveTime method
9 // the time is not discretized.
10 // NOTE : in the CWB pipeline only DQ CAT2 are used
11 //
12 // usage : root -n -l -b $CWB_PARMS_FILES GetLiveTime.C
13 //
14 // the DQ lists must be declared in the config/user_parameters.C
15 // To get the livetime after the CAT1+CAT2 -> #define DQ_LIVETIME CWB_CAT2
16 // To get the livetime after the CAT1+CAT2+CAT3 -> #define DQ_LIVETIME CWB_CAT3
17 // To get the livetime after the CAT1+CAT2+CAT3+HVETO -> #define DQ_LIVETIME CWB_HVETO
18 // livetimes are saved in the OUTPUT_LIVETIME_FILE_NAME
19 // NOTE : remember that the DQ files defined in the user_parameters.C have the boolean parameter "inverse"
20 // defined with the opposite value respect to the one defined in user_pparameters.C
21 //
22 // Author : Gabriele Vedovato
23 
24 
25 #define DQ_LIVETIME CWB_CAT2 // livetime after the CAT1+CAT2
26 //#define DQ_LIVETIME CWB_CAT3 // livetime after the CAT1+CAT2+CAT3
27 //#define DQ_LIVETIME CWB_HVETO // livetime after the CAT1+CAT2+CAT3+HVETO
28 
29 #define OUTPUT_LIVETIME_FILE_NAME "livetime.txt"
30 
31 void GetLiveTime() {
32 
34 
35  // check if parameter files exist
36  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
37  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
38  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
39 
40  if(simulation) {
41  cout << "GetLiveTime : simulation is !=0 -> only zero lag is defined!!!" << endl << endl;
42  gSystem->Exit(1);
43  }
44 
45  // check input user configuration
47  cfg.Import();
48  cfg.Check();
49 
50  // define network
51  detector* pD[NIFO_MAX]; // pointers to detectors
52  for(int i=0; i<nIFO; i++) {
53  if(strlen(ifo[i])>0) pD[i] = new detector(ifo[i]); // built in detector
54  else pD[i] = new detector(detParms[i]); // user define detector
55  }
56 
57  network NET; // network
58  for(int i=0; i<nIFO; i++) NET.add(pD[i]); // add deetctors to network object
59 
60  wavearray<double> x(segLen*16384); // dummy array used by setTimeShifts
61  pD[0]->TFmap=x;
62 
63  // get lags from network class
65  cout<<"lag step: "<<lagStep<<endl;
66  cout<<"number of time lags: "<<lags<<endl;
67 
68  // compute cat1List
69  // CAT1 list must be defined in user_parameters.C as CWB_CAT1
70  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
71  // compute cat2List after CAT1+CAT2
72  // CAT2 list must be defined in user_parameters.C as CWB_CAT2
73  vector<waveSegment> cat2List=TB.readSegList(nDQF, DQF, CWB_CAT2);
74  // compute cat3List after CAT1+CAT2+CAT3
75  // CAT3 list must be defined in user_parameters.C as CWB_CAT3
76  vector<waveSegment> cat3List=TB.readSegList(nDQF, DQF, CWB_CAT3);
77  // compute havetoList after CAT1+CAT2+CAT3+HVETO
78  // HVETO list must be defined in user_parameters.C as CWB_HVETO
79  vector<waveSegment> hvetoList=TB.readSegList(nDQF, DQF, CWB_HVETO);
80  // compute jobList
81  vector<waveSegment> jobList=TB.getJobList(cat1List, cat2List, segLen, segMLS, segTHR, segEdge);
82  cout<<"Number of standard jobs : " << jobList.size() <<endl<<endl;
83 
85  FILE* fP=NULL;
86  if((fP = fopen(fName.Data(), "w")) == NULL) {
87  cout << "cannot open output file " << fName.Data() <<". \n";
88  gSystem->Exit(1);
89  };
90  cout << "Write output file : " << fName.Data() << endl;
91  fprintf(fP,"# lagID\t live\t\t\n");
92 
93  // compute the approximate value of the livetime obtained with CWB::Toolbox::getLiveTime
94  printf("%8s ","lag");
95  for(int n=0; n<nIFO; n++) printf("%12.12s%2s","ifo",NET.getifo(n)->Name);
96  printf("\n");
97  vector<double> shiftList(nIFO);
98  for(int m=0;m<lags;m++) {
99 
100  printf("%8d ",(int)NET.wc_List[m].shift);
101  for(int n=0; n<nIFO; n++) printf("%14.5f",NET.getifo(n)->lagShift.data[m]);
102  printf("\n");
103 
104  for(int n=0;n<nIFO;n++) shiftList[n]=NET.getifo(n)->lagShift.data[m];
105 
106  double live = 0;
107 #if ( DQ_LIVETIME == CWB_CAT2 )
108  live = TB.getLiveTime(jobList, cat2List, shiftList);
109 #endif
110 #if ( DQ_LIVETIME == CWB_CAT3 )
111  live = TB.getLiveTime(jobList, cat3List, shiftList);
112 #endif
113 #if ( DQ_LIVETIME == CWB_HVETO )
114  live = TB.getLiveTime(jobList, hvetoList, shiftList);
115 #endif
116 
117  cout << endl;
118  cout << "-> livetime : " << int(live) << " sec "
119  << live/3600. << " h " << live/86400. << " day" << endl;
120  cout << endl;
121 
122  fprintf(fP,"%8d %10d\n",(int)NET.wc_List[m].shift,int(live));
123  }
124  if(fP!=NULL) fclose(fP);
125 
126  gSystem->Exit(0);
127 }
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
#define OUTPUT_LIVETIME_FILE_NAME
Definition: GetLiveTime.C:29
double segMLS
Definition: test_config1.C:47
double lagStep
Definition: test_config1.C:53
std::vector< netcluster > wc_List
Definition: network.hh:592
size_t add(detector *)
param: detector structure return number of detectors in the network
Definition: network.cc:2528
printf("total live time: non-zero lags = %10.1f \n", liveTot)
TString live
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
size_t * lagSite
Definition: test_config1.C:58
int n
Definition: cwb_net.C:10
void GetLiveTime()
Definition: GetLiveTime.C:31
TString("c")
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
void Check()
Definition: config.cc:1393
size_t lagOff
Definition: test_config1.C:54
static double getLiveTime(vector< waveSegment > &jobList, vector< waveSegment > &dqList)
Definition: Toolbox.cc:2074
int m
Definition: cwb_net.C:10
double segEdge
Definition: test_config1.C:49
i drho i
void Import(TString umacro="")
Definition: config.cc:334
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
CWB::Toolbox TB
Definition: ComputeSNR.C:5
char ifo[NIFO_MAX][8]
nDQF
Definition: cwb_eced.C:92
double segTHR
Definition: test_config1.C:48
#define nIFO
char lagMode[2]
Definition: test_config1.C:57
vector< int > jobList
i() int(T_cor *100))
network NET
Definition: cwb_dump_inj.C:12
const int NIFO_MAX
Definition: wat.hh:4
dqfile DQF[12]
Definition: test_config1.C:171
segLen
Definition: cwb_eced.C:7
vector< waveSegment > cat1List
wavearray< double > lagShift
Definition: detector.hh:351
static vector< waveSegment > getJobList(vector< waveSegment > ilist, double segLen=600., double segMLS=300., double segEdge=8.)
Definition: Toolbox.cc:627
FILE * fP
WSeries< double > TFmap
Definition: detector.hh:336
static vector< waveSegment > readSegList(dqfile DQF)
Definition: Toolbox.cc:391
char Name[16]
Definition: detector.hh:309
char * lagFile
Definition: test_config1.C:56
cout<< "total cat1 livetime : "<< int(cat1_time)<< " sec "<< cat1_time/3600.<< " h "<< cat1_time/86400.<< " day"<< endl;cout<< endl;vector< waveSegment > cat2List
Definition: cwb_dump_job.C:22
DataType_t * data
Definition: wavearray.hh:301
simulation
Definition: cwb_eced.C:9
fclose(ftrig)
detectorParams detParms[4]
char fName[256]
int setTimeShifts(size_t=1, double=1., size_t=0, size_t=0, const char *=NULL, const char *="w", size_t *=NULL)
param number of time lags param time shift step in seconds param first lag ID param maximum lag ID pa...
Definition: network.cc:7290
detector ** pD
size_t lagMax
Definition: test_config1.C:55
size_t lagSize
Definition: test_config1.C:52