Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TreeTest_CTFmod.C
Go to the documentation of this file.
1 #define XIFO 4
2 
3 #pragma GCC system_header
4 
5 #include "cwb.hh"
6 #include "config.hh"
7 #include "network.hh"
8 #include "wavearray.hh"
9 #include "TString.h"
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TPaletteAxis.h"
13 #include "TMultiLayerPerceptron.h"
14 #include "TMLPAnalyzer.h"
15 #include "TRandom.h"
16 #include "TComplex.h"
17 #include "TMath.h"
18 #include "mdc.hh"
19 #include "watplot.hh"
20 #include <vector>
21 
22 
23 /*
24  nn_otree->Branch("dt_corepixels",&dt,NPIX,0);
25  //char deltat_l[1024];
26  //sprintf(deltat_l,"dt_corepixels[%i]",NPIX);
27  //nn_otree->Branch("dt_corepixels",&deltat,deltat_l);
28  nn_otree->Branch("index",&ind,"ind/I");
29  nn_otree->Branch("t_duration",&dT,"duration/D");
30  nn_otree->Branch("f_duration",&dF,"f_duration/D");
31  nn_otree->Branch("central_f",&Fc,"central_f/D");
32 
33 */
34 
35 
36 
37 //#define differentW
38 
39 //#define SIG_FILE "/home/serena.vinciguerra/test0/S6D_R11_SIM_EOBNRv2_advL1H1V1_2G_run1_2/merge/NN_wave_S6D_R11_SIM_EOBNRv2_advL1H1V1_2G_run1_2.M1.root"
40 //#define BG_FILE "/home/serena.vinciguerra/test0/S6D_R11_BKG_L1H1V1_2G_MP_run1/merge/NN_wave_S6D_R11_BKG_L1H1V1_2G_MP_run1.M1.root"
41 #define nIFO 3
42 #define NPIX 20
43 using namespace std;
44 
45 void TreeTest_CTFmod(TString ifileS,TString ifileB,TString ofile,int const y=1, int const NDIM=8,int const nINP=64){
46 
47 
48 /*if(ifileS!=0)
49 //{
50  // SIGNAL
51  TChain TreeS("waveburst");//cerca il Tree "waveburst nei file
52  TreeS.Add(ifileS.Data());//determina i file
53  netevent entryS(&TreeS,nIFO);
54  int entriesS = entryS.GetEntries();
55  cout << "Sig entries : " << entriesS << endl;
56  std::vector<double>* frameS = new vector<double>;
57  entryS.fChain->SetBranchAddress("nnframe", &frameS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
58 //}
59 
60 //if(ifileB!=0)
61 //{
62 
63  TChain TreeB("waveburst");//cerca il Tree "waveburst nei file
64  TreeB.Add(ifileB.Data());//determina i file
65  netevent entryB(&TreeB,nIFO);
66  int entriesB = entryB.GetEntries();
67  cout << "Bg entries : " << entriesB << endl;
68  std::vector<double>* frameB = new vector<double>;
69  entryB.fChain->SetBranchAddress("nnframe", &frameB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
70 // }
71 */
72 
73  //cout<<"frame "<<(*frame)[0]<<endl;
74  TTree* nnTree2 = new TTree ("nnTree","nnTree");
75 // netevent nn(Tree,nIFO);
76  nnTree2->SetDirectory(0);
77 
78  // add leaf
79  Int_t type;
80  float s[nINP];
81  Float_t x[nINP];
82  for (int jj=0; jj<nINP;jj++) x[jj]=0.;
83  char ilabel[nINP][16];
84  double dt[NPIX];
85  for (int jj=0; jj<NPIX;jj++) dt[jj]=0.;
86  char ilabeldt[NPIX][16];
87  double dT=0.;
88  double Fc=0.;
89  double dF=0.;
90 
91  //costruzione una foglia per ogni input
92  for(int i=0;i<nINP;i++) {
93  sprintf(ilabel[i],"x%i",i+1);
94  char tlabel[16]; sprintf(tlabel,"x%i/F",i+1);
95  nnTree2->Branch(ilabel[i], &x[i], tlabel);
96  }
97 
98 //costruzione una foglia per ogni dt
99  for(int i=0;i<NPIX;i++) {
100  sprintf(ilabeldt[i],"dt%i",i+1);
101  char tlabeldt[16]; sprintf(tlabeldt,"dt%i/D",i+1);
102  nnTree2->Branch(ilabeldt[i], &dt[i], tlabeldt);
103  }
104 //add info time-frequncy plane
105  nnTree2->Branch("duration", &dT, "duration/D");
106  nnTree2->Branch("frequency_width", &dF, "frequency_width/D");
107  nnTree2->Branch("central_frequency", &Fc, "central_frequency/D");
108 
109 
110  //costruzione foglie peso e tipo
111  nnTree2->Branch("type",&type,"type/I");
112  int yi=0;
113  yi=y;
114  int nDim=0;
115  nDim=NDIM;
116  int nInp=0;
117  nInp=nINP;
118 int index=0;
119 int entriesTot=0;
120  nnTree2->Branch("amplitude_mode",&yi,"amplitude_mode/I");
121  nnTree2->Branch("Matrix_dim",&nDim,"Matrix_dim/I");
122  nnTree2->Branch("#inputs",&nInp,"#inputs/I");
123  nnTree2->Branch("index",&index,"index/I");
124  nnTree2->Branch("#Entries_type",&entriesTot,"#Entries_type/I");
125 char fname[516];
126  nnTree2->Branch("Files_name",&fname,"Files_name/C");
127 
128 #ifdef differentW
129  char wlabel[nINP][16];
130  float w[nINP];
131  for(int i=0;i<nINP;i++) {
132  sprintf(wlabel[i],"w%d",i+1);
133  char llabel[16]; sprintf(llabel,"w%d/F",i+1);
134  nnTree2->Branch(ilabel[i], &w[i], tlabel);
135  w[i]=1;
136  }
137 
138 #else
139  float w;
140  nnTree2->Branch("w",&w,"w/F");
141  w=1;
142 #endif
143 
144 cout<<"fine definizione foglie"<<endl;
145 if(ifileS!=0)
146 {
147  TChain TreeS("waveburst");//cerca il Tree "waveburst nei file
148  TreeS.Add(ifileS.Data());//determina i file
149  netevent entryS(&TreeS,nIFO);
150  entriesTot = entryS.GetEntries();
151  cout << "Sig entries : " << entriesTot << endl;
152  std::vector<double>* frameS = new vector<double>;
153  entryS.fChain->SetBranchAddress("nnframe", &frameS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
154  std::vector<double>* dtvS = new vector<double>;
155  entryS.fChain->SetBranchAddress("dt_corepixels", &dtvS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
156 
157  double dTS;
158  double dFS;
159  double FcS;
160 
161  entryS.fChain->SetBranchAddress("t_duration", &dTS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
162  entryS.fChain->SetBranchAddress("f_duration", &dFS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
163  entryS.fChain->SetBranchAddress("central_f", &FcS);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
164 
165  type = 1;
166  sprintf(fname,"%s",ifileS.Data());
167  cout<<fname<<endl;
168  for(int n=0;n<entryS.GetEntries();n++) {
169  TreeS.GetEntry(n);
170  dT=dTS;
171  dF=dFS;
172  Fc=FcS;
173  for (int j=0;j<NPIX;j++) dt[j]=(*dtvS)[j];
174  for (int j=0;j<nINP;j++)
175  //for (int j=0;j<nINP;j++)
176  { if(yi==0){
177  if((*frameS)[j]>0.001) x[j]=1;
178  else x[j]=0;
179  }
180  //else x[j]=frameS->at(j);
181  else x[j]=(*frameS)[j];
182  }
183  index=index+1;
184  nnTree2->Fill();
185  }
186 }
187 cout<<"Fine ciclo sul segnale"<<endl;
188 if(ifileB!=0)
189  {
190  TChain TreeB("waveburst");//cerca il Tree "waveburst nei file
191  TreeB.Add(ifileB.Data());//determina i file
192  netevent entryB(&TreeB,nIFO);
193  entriesTot = entryB.GetEntries();
194  cout << "Bg entries : " << entriesTot << endl;
195  std::vector<double>* frameB = new vector<double>;
196  entryB.fChain->SetBranchAddress("nnframe", &frameB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
197  std::vector<double>* dtvB = new vector<double>;
198  entryB.fChain->SetBranchAddress("dt_corepixels", &dtvB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
199 
200  double dTB;
201  double dFB;
202  double FcB;
203 
204  entryB.fChain->SetBranchAddress("t_duration", &dTB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
205  entryB.fChain->SetBranchAddress("f_duration", &dFB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
206  entryB.fChain->SetBranchAddress("central_f", &FcB);//fa esattamente come ha fatto per le altre variabili nella macro netevent.cc
207 
208  type = 0;
209  sprintf(fname,"%s",ifileB.Data());
210  cout<<fname<<endl;
211  for(int n=0;n<entryB.GetEntries();n++) {
212  TreeB.GetEntry(n);
213  dT=dTB;
214  dF=dFB;
215  Fc=FcB;
216  for (int j=0;j<NPIX;j++) dt[j]=(*dtvB)[j];
217  for (int j=0;j<nINP;j++)
218  //for (int j=0;j<nINP;j++)
219  { if(yi==0){
220  if((*frameB)[j]>0.001) x[j]=1;
221  else x[j]=0;
222  }
223  //else x[j]=frameB->at(j);
224  else x[j]=(*frameB)[j];
225  }
226  index=index+1;
227  nnTree2->Fill();
228  }
229 }
230 cout<<"fine ciclo sul Bg"<<endl;
231 //SAVE THE TREE
232 /*
233 TString ofileS(ifileS.Data());
234 ofileS.ReplaceAll(".root","_nnTree");
235 TString ofileB(ifileB.Data());
236 ofileB.ReplaceAll(".root","_nnTree");
237 */
238 char nomefile[516];
239 sprintf(nomefile,"nnTREE/nnTree_%s.root",ofile.Data());
240 //char nomefile[516]="nnTREE/nnTree_S6D_and_SIM0run3.root";
241 TFile* f=new TFile(nomefile,"RECREATE");
242 nnTree2->Write();
243 f->Close();
244 
245 }
tuple f
Definition: cwb_online.py:91
int n
Definition: cwb_net.C:10
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
STL namespace.
void TreeTest_CTFmod(TString ifileS, TString ifileB, TString ofile, int const y=1, int const NDIM=8, int const nINP=64)
TTree * fChain
root input file cointainig the analyzed TTree
Definition: netevent.hh:45
char ofile[512]
int j
Definition: cwb_net.C:10
i drho i
wavearray< double > w
Definition: Test1.C:27
char fname[1024]
double dt
s s
Definition: cwb_net.C:137
#define nIFO
wavearray< int > index
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double dT
Definition: testWDM_5.C:12
Int_t GetEntries()
Definition: netevent.cc:381
#define NPIX
wavearray< double > y
Definition: Test10.C:31