Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_job_obj.C
Go to the documentation of this file.
1 // Coherent WaveBurst production script for GW network (obsolete)
2 
3 {
4 
5  #include <vector>
6 
7 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 // declarations
9 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 
11  TFile* jfile;
12  TDirectory* cdsim;
13  TDirectory* cdprod;
14 
15  char tdf00[1024];
16  char tdf90[1024];
17  char end_CED[1024];
18 
23  WSeries<double> wM; // mdc WSeries
24 
25  jfile = gROOT->GetFile();
26  jfile->ReOpen("UPDATE");
27  if(jfile==NULL) {cout << "Error opening input root file " << endl;exit(1);}
28  jfile->ls();
29 
30  // read network object
31  network NET = *(network*)jfile->Get("net");
32  // read config object
33  CWB::config config = *(CWB::config*)jfile->Get("config");
34  // restore config parameters in CINT
35  config.Export();
36 
37  if(simulation) cdsim = (TDirectory*)jfile->Get("sim");
38  else cdprod = (TDirectory*)jfile->Get("prod");
39 
40  nSky=1000;
41  NET.nSky=nSky;
42 
43  cedDump=true;
44  TObjArray* token = TString(jfile->GetName()).Tokenize(TString("/"));
45  TObjString* path_tok = (TObjString*)token->At(token->GetEntries()-1);
46  TString jname = path_tok->GetString().Data();
47  cout << jname.Data() << endl;
48 
49  // print ifo infos
50  cout << "nIFO : " << nIFO << endl;
51  for(int n=0; n<nIFO; n++) pD[n] = NET.getifo(n);
52  for(int n=0; n<nIFO; n++) pD[n]->print();
53 
54  // restore skymaps
55  NET.setSkyMaps(angle);
56  NET.setAntenna();
57  NET.setDelay(pD[0]->Name);
58 
59 /* not needed with fixed network copy constructor !!!
60  // restore network NDM & ifoName lists
61  vectorD v; v.clear();
62  for(int n=0; n<nIFO; n++) {
63  NET.NDM.push_back(v);
64  for(int m=0; m<nIFO; m++) NET.NDM[n].push_back(0);
65  NET.ifoName.push_back(pD[n]->Name);
66  }
67  cout << "NDM size " << NET.NDM.size() << endl;
68 */
69  // there is a issue in network class (no TClass for char*)
70  NET.ifoName.clear();
71  for(int n=0; n<nIFO; n++) NET.ifoName.push_back(pD[n]->Name);
72 
73  // declare netevent
74  netevent netburst(nIFO,Psave);
75 
76  // print network infos
77  double mTau=NET.getDelay("MAX"); // maximum time delay
78  double dTau=NET.getDelay(); // time delay difference
79  cout<<"maximum time delay between detectors: "<<mTau<<endl;
80  cout<<" maximum time delay difference: "<<dTau<<endl;
81  cout<<" netRHO and netCC: "<<NET.netRHO<<", "<<NET.netCC<<endl;
82  cout<<" regulator delta, gamma: "<<NET.delta <<" " <<NET.gamma<<endl<<endl;
83 
84  gSystem->Exec("/bin/date");
85  gSystem->Exec("/bin/hostname");
86 
87 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88 // data conditioning
89 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90 
91  if(!simulation) nfactor = 1;
92  for(int iii=0; iii<nfactor; iii++) {
93  double factor=factors[iii];
94  cout<<"factor="<<factor<<endl;
95  char sfactor[32];
96  sprintf(sfactor,"factor_%g",factor);
97  // build end_CED file name
98  sprintf(end_CED,"%s/ced_%s_%g",ced_dir,jname.ReplaceAll(".root","").Data(),factor);
99 
100  for(int i=0; i<nIFO; i++) {
101  pTF[i] = (WSeries<double>*)jfile->Get(TString("proc/")+pD[i]->Name);
102  if(pTF[i]==NULL || simulation) { // process raw data
103  pTF[i] = (WSeries<double>*)jfile->Get(TString("raw/")+pD[i]->Name);
104  if(pTF[i]==NULL) {cout << "Error : data not present, job terminated!!!" << endl;return;}
105  pTF[i] = pD[i]->getTFmap();
106  *pTF[i] = *(WSeries<double>*)jfile->Get(TString("raw/")+pD[i]->Name);
107  if(simulation) {
108  wM = *(WSeries<double>*)jfile->Get(TString("raw/")+ifo[i]+TString(":mdc"));
109  wM*=factor;
110  pTF[i]->add(wM);
111  wM*=1./factor;
112  }
113  pTF[i]->lprFilter(2,0,Tlpr,4.);
114  pTF[i]->setlow(fLow);
115  pD[i]->white(60.,1,8.,20.);
116  if(simulation) pD[i]->setsim(wM,NET.getmdcTime(),10.,8.,true);
117  pTF[i]->Inverse(levelD-levelF);
118  pTF[i]->lprFilter(2,0,Tlpr,4.);
119  pTF[i]->Forward(levelD-levelF);
120  pTF[i]->sethigh(fHigh);
121  pD[i]->bandPass();
122  cout<<"After "<<pD[i]->Name<<" data conditioning"<<endl;
123  gSystem->Exec("/bin/date"); GetProcInfo();
124  } else { // process proc data
125  pTF[i] = pD[i]->getTFmap();
126  *pTF[i] = *(WSeries<double>*)jfile->Get(TString("proc/")+pD[i]->Name);
127  }
128  }
129 
130  // set the decomposition level
131  for(int i=0; i<nIFO; i++) pTF[i]->Inverse(levelD-l_low);
132  NET.setTimeShifts();
133 
134 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
135 // supercluster analysis
136 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
137 
138  int lags=1;
139  for(int j=0; j<lags; j++){
140  wc.clear();
141  TString wcdir = simulation ? TString("sim/")+sfactor : TString("prod/lag_")+j;
142  TIter nextkey(((TDirectory*)jfile->Get(wcdir))->GetListOfKeys());
143  TKey *key;while(key=(TKey*)nextkey()) wc.append(*(netcluster*)key->ReadObj());
144  int m = wc.supercluster('L',NET.e2or,true);
145  pwc = NET.getwc(j); pwc->cpf(wc,true);
146  cout<<m<<"|"<<pwc->size()<<" ";
147  }
148 
149 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
150 // likelihood
151 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
152 
153  TDirectory* cdced = NULL;
154  if(cedDump) {cdced = simulation ? cdsim->mkdir("ced") : cdprod->mkdir("ced"); }
155 
156  for(int i=l_low; i<=l_high; i++) {
157  sprintf(tdf00,"%s/Meyer1024wat482_00%s_L%1d.dat",filter_dir,filter,i);
158  sprintf(tdf90,"%s/Meyer1024wat482_90%s_L%1d.dat",filter_dir,filter,i);
159  NET.setDelayFilters(tdf00,tdf90);
160 
161  if(i==l_low) {
162  //NET.pOUT=true;
163  NET.setDelayIndex();
164  NET.setIndexMode(mode);
165  }
166 
167  cout<<endl;
168  cout<<"selected core pixels: "<<NET.likelihood(SEARCH(),Acore)<<" for level "<<i<<"\n";
169  cout<<"rejected weak pixels: "<<NET.netcut(NET.netRHO,'r',0,1)<<"\n"; // remove weak glitches
170  cout<<"rejected loud pixels: "<<NET.netcut(NET.netCC,'c',0,1)<<"\n"; // remove loud glitches
171  cout<<"events in the buffer: "<<NET.events()<<"\n";
172 
173  if(cedDump) {
174  if(cdced==NULL) {
175  cout<<"dump ced into "<<end_CED<<"\n";
176  CWB::ced ced(&NET,&netburst,end_CED);
177  } else {
178  //gBenchmark->Start("ced");
179  CWB::ced ced(&NET,&netburst,cdced);
180  //gBenchmark->Show("ced");
181  //gBenchmark->Reset();
182  }
183  ced.SetOptions(cedRHO);
184  ced.Write(factor);
185  }
186 
187  if(i<l_high) NET.Forward(1);
188  }
189 
190  gSystem->Exec("/bin/date"); GetProcInfo();
191  cout<<"\nSearch done\n";
192  cout<<"reconstructed events: "<<NET.events()<<"\n";
193 
194 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
195 // save data in root file
196 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
197 
198  if(simulation) cdsim->cd(); else cdprod->cd();
199 
200  TTree* net_tree = netburst.setTree();
201 
202  // build output data txt name (in the /dev/shm directory)
203  char ofile[256];
204  gRandom->SetSeed(0);
205  int rnID = int(gRandom->Rndm(13)*1.e9);
206  UserGroup_t* uinfo = gSystem->GetUserInfo();
207  TString uname = uinfo->fUser;
208  gSystem->Exec(TString("mkdir -p /dev/shm/")+uname);
209  sprintf(ofile,"/dev/shm/%s/waveburst-%d.txt",uname.Data(),rnID);
210 
211  dump=true;
212 
213  if(dump) netburst.dopen(ofile,"w");
214  netburst.output(net_tree,&NET);
215  jfile->Write();
216  if(dump) netburst.dclose();
217 
218  TMacro macro(ofile);
219  macro.Write("output.txt");
220  gSystem->Exec(TString("rm ")+ofile);
221  }
222 
223  jfile->ReOpen("READ");
224  gROOT->RefreshBrowsers();
225  gROOT->ForceStyle(0);
226 }
227 
228 
std::vector< char * > ifoName
Definition: network.hh:591
void sethigh(double f)
Definition: wseries.hh:114
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
WSeries< double > * pTF[NIFO_MAX]
Definition: cwb_job_obj.C:22
double netCC
Definition: network.hh:578
void white(double dT=0, int wtype=1, double offset=0., double stride=0.)
what it does: see algorithm description in wseries.hh
Definition: detector.hh:240
void Export(TString fname="")
Definition: config.cc:388
char filter_dir[1024]
void setAntenna(detector *)
param: detector (use theta, phi index array)
Definition: network.cc:2815
std::vector< double > * getmdcTime()
Definition: network.hh:404
double fHigh
network NET
Definition: cwb_job_obj.C:31
int n
Definition: cwb_net.C:10
double angle
TDirectory * cdprod
Definition: cwb_job_obj.C:13
TString("c")
size_t setIndexMode(size_t=0)
Definition: network.cc:8072
TDirectory * cdsim
Definition: cwb_job_obj.C:3
void add(const wavearray< DataType_t > &, int=0, int=0, int=0)
Definition: wavearray.cc:728
netcluster * pwc
Definition: cwb_job_obj.C:20
void setlow(double f)
Definition: wseries.hh:107
virtual size_t supercluster(char atype, double S, bool core)
param: statistic: E - excess power, L - likelihood param: selection threshold T for likelihood cluste...
Definition: netcluster.cc:789
int m
Definition: cwb_net.C:10
char ofile[512]
int j
Definition: cwb_net.C:10
detector * pD[NIFO_MAX]
Definition: cwb_job_obj.C:21
i drho i
int l_low
Definition: test_config1.C:40
char ifo[NIFO_MAX][8]
char ced_dir[512]
Definition: test_config1.C:154
int Psave
Definition: test_config1.C:75
double Acore
Definition: test_config1.C:28
size_t mode
#define nIFO
char tdf90[1024]
Definition: cwb_job_obj.C:16
double factor
TString uname
jfile
Definition: cwb_job_obj.C:25
char end_CED[1024]
Definition: cwb_job_obj.C:17
void Forward(size_t k)
param: number of steps
Definition: network.hh:71
int levelD
TTree * net_tree
char tdf00[1024]
Definition: cwb_job_obj.C:15
i() int(T_cor *100))
void setDelayIndex(double rate)
param: MDC log file
Definition: network.cc:2865
const int NIFO_MAX
Definition: wat.hh:4
double getDelay(const char *c="")
Definition: network.cc:2787
virtual size_t append(netcluster &wc)
param: input netcluster return size of appended pixel list
Definition: netcluster.cc:750
double cedRHO
UserGroup_t * uinfo
Definition: cwb_frdisplay.C:73
size_t cpf(const netcluster &, bool=false, int=0)
Definition: netcluster.cc:99
TObjArray * token
ss Inverse()
void setDelay(const char *="L1")
Definition: network.cc:2736
void bandPass(double f1, double f2, double a=0.)
Definition: detector.hh:265
double e2or
Definition: network.hh:566
WSeries< double > wM
Definition: cwb_job_obj.C:23
long likelihood(char='E', double=sqrt(2.), int=0, size_t=0, int=-1, bool=false)
Definition: network.cc:4415
size_t size()
Definition: netcluster.hh:129
double factors[100]
Definition: test_config1.C:84
size_t events()
Definition: network.hh:311
char filter[1024]
double fLow
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:161
char Name[16]
Definition: detector.hh:309
iD print()
double gamma
Definition: network.hh:574
double mTau
virtual void lprFilter(double, int=0, double=0., double=0.)
Definition: wseries.cc:1108
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
netcluster wc
Definition: cwb_job_obj.C:19
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:421
CWB::config config
Definition: cwb_job_obj.C:33
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
nfactor[0]
Definition: cwb_eced.C:10
bool dump
void setDelayFilters(detector *=NULL)
Definition: network.cc:7706
int l_high
Definition: test_config1.C:41
long nSky
Definition: network.hh:556
TString jname
Definition: ced.hh:26
size_t netcut(double, char='L', size_t=0, int=1)
param: threshold param: minimum cluster size processed by the corrcut param: cluster type return: num...
Definition: network.cc:2967
long nSky
int rnID
simulation
Definition: cwb_eced.C:9
double Tlpr
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
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:273
double delta
Definition: network.hh:573
size_t setsim(WSeries< double > &, std::vector< double > *, double=5., double=8., bool saveWF=false)
Definition: detector.cc:1348
double netRHO
Definition: network.hh:579
void GetProcInfo(TString str="")
Definition: Toolfun.hh:219
#define SEARCH(TYPE)
Definition: xroot.hh:4
bool cedDump
int levelF
void setSkyMaps(double, double=0., double=180., double=0., double=360.)
param: sky map granularity step, degrees param: theta begin, degrees param: theta end...
Definition: network.cc:2656
exit(0)
void clear()
Definition: netcluster.hh:409