GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AncillaryFilter.C
Go to the documentation of this file.
1 #define AncillaryFilter_cxx
2 // The class definition in AncillaryFilter.h has been generated automatically
3 // by the ROOT utility TTree::MakeSelector(). This class is derived
4 // from the ROOT class TSelector. For more information on the TSelector
5 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
6 
7 // The following methods are defined in this file:
8 // Begin(): called every time a loop on the tree starts,
9 // a convenient place to create your histograms.
10 // SlaveBegin(): called after Begin(), when on PROOF called only on the
11 // slave servers.
12 // Process(): called for each event, in this function you decide what
13 // to read and fill your histograms.
14 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
15 // called only on the slave servers.
16 // Terminate(): called at the end of the loop on the tree,
17 // a convenient place to draw/fit your histograms.
18 //
19 // To use this file, try the following session on your Tree T:
20 //
21 // Root > T->Process("AncillaryFilter.C")
22 // Root > T->Process("AncillaryFilter.C","some options")
23 // Root > T->Process("AncillaryFilter.C+")
24 //
25 
26 #include "AncillaryFilter.h"
27 #include <TH2.h>
28 #include <TStyle.h>
29 #include "TSystem.h"
30 #include "TEventList.h"
31 #include "TEntryList.h"
32 #include "TH1.h"
33 #include "TH2.h"
34 #include <TDatabasePDG.h>
35 
36 #include <iostream>
37 #include <iomanip>
38 #include <fstream>
39 
40 
41 namespace {
42 Int_t gPDG;
43 Int_t nPDG;
44 Int_t pPDG;
45 Int_t aPDG;
46 
47 // event or entry list
48 TEventList *evlist; TEntryList *enlist;
49 }
50 
51 void AncillaryFilter::Begin(TTree * tree)
52 {
53  // The Begin() function is called at the start of the query.
54  // When running with PROOF Begin() is only called on the client.
55  // The tree argument is deprecated (on PROOF 0 is passed).
56 
57  Init(tree);
58 
59  ReadConfFile();
60 
61  AGATACountsGlobNorm = new TH2F("AGATACountsGlobNorm","AGATACountsGlobNorm",50,0,50,50,0,50);
62  AGATACountsGlobNorm->GetXaxis()->SetTitle("Number of emited gammas");
63  AGATACountsGlobNorm->GetYaxis()->SetTitle("Number of hits in AGATA");
64  AGATACountsGlobNorm->GetXaxis()->SetTitleOffset(0.9);
65  AGATACountsGlobNorm->GetXaxis()->SetTitleSize(0.05);
66  AGATACountsGlobNorm->GetYaxis()->SetTitleOffset(0.8);
67  AGATACountsGlobNorm->GetYaxis()->SetTitleSize(0.05);
68 
69  DiamantCountsGlobNorm = new TH2F("DiamantCountsGlobNorm","DiamantCountsGlobNorm",10,0,10,20,0,20);
70  DiamantCountsGlobNorm->GetXaxis()->SetTitle("Number of emited charged particles");
71  DiamantCountsGlobNorm->GetYaxis()->SetTitle("Number of hits in DIAMANT");
72  DiamantCountsGlobNorm->GetXaxis()->SetTitleOffset(0.9);
73  DiamantCountsGlobNorm->GetXaxis()->SetTitleSize(0.05);
74  DiamantCountsGlobNorm->GetYaxis()->SetTitleOffset(0.8);
75  DiamantCountsGlobNorm->GetYaxis()->SetTitleSize(0.05);
76 
77  NWCountsGlobNorm = new TH2F("NWCountsGlobNorm","NWCountsGlobNorm",10,0,10,20,0,20);
78  NWCountsGlobNorm->GetXaxis()->SetTitle("Number of emited neutrons");
79  NWCountsGlobNorm->GetYaxis()->SetTitle("Number of hits in NW");
80  NWCountsGlobNorm->GetXaxis()->SetTitleOffset(0.9);
81  NWCountsGlobNorm->GetXaxis()->SetTitleSize(0.05);
82  NWCountsGlobNorm->GetYaxis()->SetTitleOffset(0.8);
83  NWCountsGlobNorm->GetYaxis()->SetTitleSize(0.05);
84 
85  AGATACountsPrNorm = new TH2F("AGATACountsPrNorm","AGATACountsPrNorm",50,0,50,50,0,50);
86  AGATACountsPrNorm->GetXaxis()->SetTitle("Number of emited gammas");
87  AGATACountsPrNorm->GetYaxis()->SetTitle("Number of hits in AGATA");
88  AGATACountsPrNorm->GetXaxis()->SetTitleOffset(0.9);
89  AGATACountsPrNorm->GetXaxis()->SetTitleSize(0.05);
90  AGATACountsPrNorm->GetYaxis()->SetTitleOffset(0.8);
91  AGATACountsPrNorm->GetYaxis()->SetTitleSize(0.05);
92 
93  DiamantCountsPrNorm = new TH2F("DiamantCountsPrNorm","DiamantCountsPrNorm",10,0,10,20,0,20);
94  DiamantCountsPrNorm->GetXaxis()->SetTitle("Number of emited charged particles");
95  DiamantCountsPrNorm->GetYaxis()->SetTitle("Number of hits in DIAMANT");
96  DiamantCountsPrNorm->GetXaxis()->SetTitleOffset(0.9);
97  DiamantCountsPrNorm->GetXaxis()->SetTitleSize(0.05);
98  DiamantCountsPrNorm->GetYaxis()->SetTitleOffset(0.8);
99  DiamantCountsPrNorm->GetYaxis()->SetTitleSize(0.05);
100 
101  NWCountsPrNorm = new TH2F("NWCountsPrNorm","NWCountsPrNorm",10,0,10,20,0,20);
102  NWCountsPrNorm->GetXaxis()->SetTitle("Number of emited neutrons");
103  NWCountsPrNorm->GetYaxis()->SetTitle("Number of hits in NW");
104  NWCountsPrNorm->GetXaxis()->SetTitleOffset(0.9);
105  NWCountsPrNorm->GetXaxis()->SetTitleSize(0.05);
106  NWCountsPrNorm->GetYaxis()->SetTitleOffset(0.8);
107  NWCountsPrNorm->GetYaxis()->SetTitleSize(0.05);
108 
109  AGATACountsEvNorm = new TH2F("AGATACountsEvNorm","AGATACountsEvNorm",50,0,50,50,0,50);
110  AGATACountsEvNorm->GetXaxis()->SetTitle("Number of emited gammas");
111  AGATACountsEvNorm->GetYaxis()->SetTitle("Number of hits in AGATA");
112  AGATACountsEvNorm->GetXaxis()->SetTitleOffset(0.9);
113  AGATACountsEvNorm->GetXaxis()->SetTitleSize(0.05);
114  AGATACountsEvNorm->GetYaxis()->SetTitleOffset(0.8);
115  AGATACountsEvNorm->GetYaxis()->SetTitleSize(0.05);
116 
117  DiamantCountsEvNorm = new TH2F("DiamantCountsEvNorm","DiamantCountsEvNorm",10,0,10,20,0,20);
118  DiamantCountsEvNorm->GetXaxis()->SetTitle("Number of emited charged particles");
119  DiamantCountsEvNorm->GetYaxis()->SetTitle("Number of hits in DIAMANT");
120  DiamantCountsEvNorm->GetXaxis()->SetTitleOffset(0.9);
121  DiamantCountsEvNorm->GetXaxis()->SetTitleSize(0.05);
122  DiamantCountsEvNorm->GetYaxis()->SetTitleOffset(0.8);
123  DiamantCountsEvNorm->GetYaxis()->SetTitleSize(0.05);
124 
125  NWCountsEvNorm = new TH2F("NWCountsEvNorm","NWCountsEvNorm",10,0,10,20,0,20);
126  NWCountsEvNorm->GetXaxis()->SetTitle("Number of emited neutrons");
127  NWCountsEvNorm->GetYaxis()->SetTitle("Number of hits in NW");
128  NWCountsEvNorm->GetXaxis()->SetTitleOffset(0.9);
129  NWCountsEvNorm->GetXaxis()->SetTitleSize(0.05);
130  NWCountsEvNorm->GetYaxis()->SetTitleOffset(0.8);
131  NWCountsEvNorm->GetYaxis()->SetTitleSize(0.05);
132 
133  GlobalExitChannelDistrib = new TH1F("ExitChannelDistrib","ExitChannelDistrib",50,0,50);
134 
135  for(int i=0 ; i<=5 ; i++)
136  {
137  for(int j=0 ; j<=5 ; j++)
138  {
139  for(int k=0 ; k<=1 ; k++)
140  {
141  TString Name = Form("ECDist_%dn%dp%da",i,j,k);
142  ExitChannelDistrib[i][j][k] = new TH1F(Name,Name,50,0,50);
143  }
144  }
145  }
146 
147  NEntries = tree->GetEntries();
148  Fact = NEntries/100;
149 
150  gPDG = TDatabasePDG::Instance()->GetParticle("gamma")->PdgCode();
151  nPDG = TDatabasePDG::Instance()->GetParticle("neutron")->PdgCode();
152  pPDG = TDatabasePDG::Instance()->GetParticle("proton")->PdgCode();
153  aPDG = 1000020040;
154 
155  //ELIST
156  evlist = 0x0;
157  enlist = 0x0;
158 
159  if ( gDirectory->GetList()->FindObject("SToGS_entrylist") ) {
160  delete gDirectory->GetList()->FindObject("SToGS_entrylist");
161  }
162  fChain->SetEntryList(0);
163 
164  // case when one creates/fills the event list
165  enlist = new TEntryList("SToGS_entrylist","selection from TSelector");
166  enlist->SetDirectory(0);
167 
168  enlist->SetTreeName(fChain->GetName());
169  enlist->SetFileName(gSystem->BaseName(fChain->GetDirectory()->GetName()));
170 
171  cout<<endl;
172  cout<<"Starting to process events : "<<endl;
173  cout<<endl;
174 }
175 
176 void AncillaryFilter::SlaveBegin(TTree * /*tree*/)
177 {
178  // The SlaveBegin() function is called after the Begin() function.
179  // When running with PROOF SlaveBegin() is called on each slave server.
180  // The tree argument is deprecated (on PROOF 0 is passed).
181 
182  TString option = GetOption();
183 
184 }
185 
186 Bool_t AncillaryFilter::Process(Long64_t entry)
187 {
188  // The Process() function is called for each entry in the tree (or possibly
189  // keyed object in the case of PROOF) to be processed. The entry argument
190  // specifies which entry in the currently loaded tree is to be processed.
191  // It can be passed to either AncillaryFilter::GetEntry() or TBranch::GetEntry()
192  // to read either all or the required parts of the data. When processing
193  // keyed objects with PROOF, the object is already loaded and is available
194  // via the fObject pointer.
195  //
196  // This function should contain the "body" of the analysis. It can contain
197  // simple or elaborate selection criteria, run algorithms on the data
198  // of the event and typically fill histograms.
199  //
200  // The processing can be stopped by calling Abort().
201  //
202  // Use fStatus to set the return value of TTree::Process().
203  //
204  // The return value is currently not used.
205 
206  GetEntry(entry);
207 
208  if(fChain->GetChainEntryNumber(entry+1)%Fact==0)
209  {
210  cout<<"\r"<<"Analysis progress : "<<setw(3)<<(double)fChain->GetChainEntryNumber(entry+1)/(double)NEntries*100<<" %"<<" ("<<fChain->GetChainEntryNumber(entry+1)<<"/"<<NEntries<<")"<<flush;
211  }
212 
213  Int_t g_pr_hits, n_pr_hits, p_pr_hits, a_pr_hits, nb_AGATA, nb_NW, nb_DIAM, nb_DIAM_proton, nb_DIAM_alpha;
214 
215  g_pr_hits=0;n_pr_hits=0;p_pr_hits=0;a_pr_hits=0;nb_AGATA=0;nb_NW=0;nb_DIAM=0;nb_DIAM_proton=0;nb_DIAM_alpha=0;
216 
217 
218  for (int i=0; i< Pr_fHits_; i++)
219  {
220  if (Pr_fHits_fPDG[i] == gPDG)
221  g_pr_hits++;
222  else if (Pr_fHits_fPDG[i] == nPDG)
223  {
224  n_pr_hits++;
225  }
226  else if (Pr_fHits_fPDG[i] == pPDG)
227  p_pr_hits++;
228 
229  else if (Pr_fHits_fPDG[i] == aPDG)
230  a_pr_hits++;
231  }
232  for (int i=0; i< Ev_fHits_; i++)
233  {
234  if ( Ev_fHits_fUID[i] >=0 && Ev_fHits_fUID[i] <=180 ) // AGATA, compute number of hits in the array [tracking mode]
235  nb_AGATA++;
236  else if (Ev_fHits_fUID[i]>=1000 && Ev_fHits_fUID[i] <2000)
237  {
238  nb_DIAM++;
239  if(Pr_fHits_fPDG[Ev_fHits_fFlag[i]] == pPDG) nb_DIAM_proton++;
240  else if(Pr_fHits_fPDG[Ev_fHits_fFlag[i]] == aPDG) nb_DIAM_alpha++;
241  }
242  else if (Ev_fHits_fUID[i]>=2000 && Ev_fHits_fUID[i] <3000)
243  nb_NW++;
244  }
245 
246  if(PlotEfficiencies == 2 && (nb_AGATA >= fN_Agata[0] && nb_AGATA <= fN_Agata[1]))
247  {
248  AGATACountsPrNorm->Fill(g_pr_hits,nb_AGATA);
249  DiamantCountsPrNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
250  NWCountsPrNorm->Fill(n_pr_hits,nb_NW);
251 
252  AGATACountsEvNorm->Fill(g_pr_hits,nb_AGATA);
253  DiamantCountsEvNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
254  NWCountsEvNorm->Fill(n_pr_hits,nb_NW);
255 
256  AGATACountsGlobNorm->Fill(g_pr_hits,nb_AGATA);
257  DiamantCountsGlobNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
258  NWCountsGlobNorm->Fill(n_pr_hits,nb_NW);
259 
260  TString ExitChannel = Form("%dn%dp%da",n_pr_hits,p_pr_hits,a_pr_hits);
261  ExitChannel.ReplaceAll("0n","");
262  ExitChannel.ReplaceAll("0p","");
263  ExitChannel.ReplaceAll("0a","");
264 
265  GlobalExitChannelDistrib->GetXaxis()->FindBin(ExitChannel);
266  GlobalExitChannelDistrib->Fill(ExitChannel,1);
267 
268 
269  TString HistName = Form("ECDist_%dn%dp%da",nb_NW,nb_DIAM_proton,nb_DIAM_alpha);
270  TH1 *h = (TH1*)gROOT->FindObject(HistName);
271  if(h != 0x0)
272  {
273  h->GetXaxis()->FindBin(ExitChannel);
274  h->Fill(ExitChannel,1);
275  }
276  }
277 
278  // if(entry>10000)
279  // {
280  // Terminate();
281  // gROOT->ProcessLine(".QQQQQQQQQQQQQQQQQQQQ");
282  // }
283 
284  if( (g_pr_hits >= fN_Gamma[0] && g_pr_hits <= fN_Gamma[1]) &&
285  (n_pr_hits >= fN_Neutron[0] && n_pr_hits <= fN_Neutron[1]) &&
286  (p_pr_hits >= fN_Proton[0] && p_pr_hits <= fN_Proton[1]) &&
287  (a_pr_hits >= fN_Alpha[0] && a_pr_hits <= fN_Alpha[1]) &&
288  (nb_AGATA >= fN_Agata[0] && nb_AGATA <= fN_Agata[1]) &&
289  (nb_DIAM >= fN_Diamant[0] && nb_DIAM <= fN_Diamant[1]) &&
290  (nb_DIAM_proton >= fN_Diamant_proton[0] && nb_DIAM_proton <= fN_Diamant_proton[1]) &&
291  (nb_DIAM_alpha >= fN_Diamant_alpha[0] && nb_DIAM_alpha <= fN_Diamant_alpha[1]) &&
292  (nb_NW >= fN_NW[0] && nb_NW <= fN_NW[1]))
293  {
294  enlist->Enter(fChain->GetChainEntryNumber(entry));
295 
296  if(PlotEfficiencies == 1)
297  {
298  AGATACountsPrNorm->Fill(g_pr_hits,nb_AGATA);
299  DiamantCountsPrNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
300  NWCountsPrNorm->Fill(n_pr_hits,nb_NW);
301 
302  AGATACountsEvNorm->Fill(g_pr_hits,nb_AGATA);
303  DiamantCountsEvNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
304  NWCountsEvNorm->Fill(n_pr_hits,nb_NW);
305 
306  AGATACountsGlobNorm->Fill(g_pr_hits,nb_AGATA);
307  DiamantCountsGlobNorm->Fill(p_pr_hits+a_pr_hits,nb_DIAM);
308  NWCountsGlobNorm->Fill(n_pr_hits,nb_NW);
309 
310  TString ExitChannel = Form("%dn%dp%da",n_pr_hits,p_pr_hits,a_pr_hits);
311  ExitChannel.ReplaceAll("0n","");
312  ExitChannel.ReplaceAll("0p","");
313  ExitChannel.ReplaceAll("0a","");
314 
315  GlobalExitChannelDistrib->GetXaxis()->FindBin(ExitChannel);
316  GlobalExitChannelDistrib->Fill(ExitChannel,1);
317  }
318 
319  return kTRUE;
320  }
321  else
322  {
323  return kFALSE;
324  }
325 }
326 
328 {
329  // The SlaveTerminate() function is called after all entries or objects
330  // have been processed. When running with PROOF SlaveTerminate() is called
331  // on each slave server.
332 
333 }
334 
336 {
337  // The Terminate() function is the last function to be called during
338  // a query. It always runs on the client, it can be used to present
339  // the results graphically or save the results to file.
340 
341  cout<<endl;
342  cout<<"Entry list completed ! "<<endl;
343  cout<<"Number of events in the list : "<<enlist->GetN()<<" ("<<(double)enlist->GetN()/(double)NEntries*100<<" % of input events)"<<endl;
344 
345  TFile *FileOut = new TFile(fFileName,"UPDATE");
346 
347  enlist->Write();
348  FileOut->Close();
349  delete FileOut;
350 
351  if(PlotEfficiencies != 0)
352  {
353  for(int i=1 ; i<=50 ; i++)
354  {
355  TH1 *h = AGATACountsPrNorm->ProjectionX();
356  Int_t EntriesAGATA = h->GetBinContent(i);
357  delete h;
358 
359  h = DiamantCountsPrNorm->ProjectionX();
360  Int_t EntriesDiam = h->GetBinContent(i);
361  delete h;
362 
363  h = NWCountsPrNorm->ProjectionX();
364  Int_t EntriesNW = h->GetBinContent(i);
365  delete h;
366 
367  for(int j=1 ; j<=50 ; j++)
368  {
369  if(EntriesAGATA!=0) AGATACountsPrNorm->SetBinContent(i,j,(double)AGATACountsPrNorm->GetBinContent(i,j)/((double)EntriesAGATA));
370  if(EntriesDiam!=0) DiamantCountsPrNorm->SetBinContent(i,j,(double)DiamantCountsPrNorm->GetBinContent(i,j)/((double)EntriesDiam));
371  if(EntriesNW!=0) NWCountsPrNorm->SetBinContent(i,j,(double)NWCountsPrNorm->GetBinContent(i,j)/((double)EntriesNW));
372  }
373  }
374 
375  for(int j=1 ; j<=50 ; j++)
376  {
377  TH1 *h = AGATACountsEvNorm->ProjectionY();
378  Int_t EntriesAGATA = h->GetBinContent(j);
379  delete h;
380 
381  h = DiamantCountsEvNorm->ProjectionY();
382  Int_t EntriesDiam = h->GetBinContent(j);
383  delete h;
384 
385  h = NWCountsEvNorm->ProjectionY();
386  Int_t EntriesNW = h->GetBinContent(j);
387  delete h;
388 
389  for(int i=1 ; i<=50 ; i++)
390  {
391  if(EntriesAGATA!=0) AGATACountsEvNorm->SetBinContent(i,j,(double)AGATACountsEvNorm->GetBinContent(i,j)/((double)EntriesAGATA));
392  if(EntriesDiam!=0) DiamantCountsEvNorm->SetBinContent(i,j,(double)DiamantCountsEvNorm->GetBinContent(i,j)/((double)EntriesDiam));
393  if(EntriesNW!=0) NWCountsEvNorm->SetBinContent(i,j,(double)NWCountsEvNorm->GetBinContent(i,j)/((double)EntriesNW));
394  }
395  }
396 
397  Int_t Entries = AGATACountsGlobNorm->GetEntries();
398 
399  for(int i=1 ; i<=50 ; i++)
400  {
401  for(int j=1 ; j<=50 ; j++)
402  {
403  AGATACountsGlobNorm->SetBinContent(i,j,(double)AGATACountsGlobNorm->GetBinContent(i,j)/((double)Entries));
404  DiamantCountsGlobNorm->SetBinContent(i,j,(double)DiamantCountsGlobNorm->GetBinContent(i,j)/((double)Entries));
405  NWCountsGlobNorm->SetBinContent(i,j,(double)NWCountsGlobNorm->GetBinContent(i,j)/((double)Entries));
406  }
407  }
408 
409  TFile *fHists = new TFile(EfficiencyPlotFileName,"recreate");
410 
411  TString Name = GlobalExitChannelDistrib->GetName();
412  TString Title = GlobalExitChannelDistrib->GetName();
413  Int_t NBins = GlobalExitChannelDistrib->FindLastBinAbove(0);
414 
415  TH1F *htemp = (TH1F*)GlobalExitChannelDistrib->Clone("htemp");
416  delete GlobalExitChannelDistrib;
417  GlobalExitChannelDistrib = new TH1F(Name,Title,NBins,0,NBins);
418  GlobalExitChannelDistrib->GetXaxis()->SetLabelSize(0.1);
419  GlobalExitChannelDistrib->GetYaxis()->SetTitle("Rates");
420  GlobalExitChannelDistrib->GetYaxis()->SetTitleOffset(0.8);
421  GlobalExitChannelDistrib->GetYaxis()->SetTitleSize(0.05);
422 
423  for(int i=0 ; i<NBins ; i++)
424  {
425  int bin = htemp->GetMaximumBin();
426  Double_t Value = (double)htemp->GetBinContent(bin)/((double)Entries);
427  TString Label = htemp->GetXaxis()->GetBinLabel(bin);
428  htemp->SetBinContent(bin,0);
429  GlobalExitChannelDistrib->SetBinContent(i+1,Value);
430  GlobalExitChannelDistrib->GetXaxis()->SetBinLabel(i+1,Label);
431  }
432  delete htemp;
433 
434  if(PlotEfficiencies == 2)
435  {
436  fHists->mkdir("ExitChannelsDist");
437  fHists->cd("ExitChannelsDist");
438 
439  for(int i=0 ; i<=5 ; i++)
440  {
441  for(int j=0 ; j<=5 ; j++)
442  {
443  for(int k=0 ; k<=1 ; k++)
444  {
445  TH1 *h = ExitChannelDistrib[i][j][k];
446  h->Scale(1./((double)h->GetEntries()));
447  TString Name = h->GetName();
448  TString Title = h->GetName();
449 
450  TH1F *htemp = (TH1F*)h->Clone("htemp");
451  delete h;
452  ExitChannelDistrib[i][j][k] = new TH1F(Name,Title,NBins,0,NBins);
453  h = ExitChannelDistrib[i][j][k];
454  h->GetXaxis()->SetLabelSize(0.1);
455  h->GetYaxis()->SetTitle("Rates");
456  h->GetYaxis()->SetTitleOffset(0.8);
457  h->GetYaxis()->SetTitleSize(0.05);
458 
459  for(int i=0 ; i<NBins ; i++)
460  {
461  int bin = htemp->GetXaxis()->FindBin(GlobalExitChannelDistrib->GetXaxis()->GetBinLabel(i+1));
462  h->SetBinContent(i+1,htemp->GetBinContent(bin));
463  h->GetXaxis()->SetBinLabel(i+1,GlobalExitChannelDistrib->GetXaxis()->GetBinLabel(i+1));
464  }
465  delete htemp;
466  h->Write();
467  }
468  }
469  }
470  }
471 
472  GlobalExitChannelDistrib->Write();
473 
474  fHists->mkdir("GlobNorm");
475  fHists->cd("GlobNorm");
476  AGATACountsGlobNorm->Write();
477  DiamantCountsGlobNorm->Write();
478  NWCountsGlobNorm->Write();
479 
480  fHists->mkdir("PrNorm");
481  fHists->cd("PrNorm");
482  AGATACountsPrNorm->Write();
483  DiamantCountsPrNorm->Write();
484  NWCountsPrNorm->Write();
485 
486  fHists->mkdir("EvNorm");
487  fHists->cd("EvNorm");
488  AGATACountsEvNorm->Write();
489  DiamantCountsEvNorm->Write();
490  NWCountsEvNorm->Write();
491 
492  fHists->Close();
493  }
494 }
495 
497 {
498  cout<<endl;
499  cout<<"******************************"<<endl;
500  cout<<"* Reading Configuration File *"<<endl;
501  cout<<"******************************"<<endl;
502  cout<<endl;
503 
504  std::ifstream FileIn;
505  FileIn.open("AncillaryFilter.conf", std::ifstream::in);
506 
507  fN_Gamma[0] = 0;
508  fN_Neutron[0] = 0;
509  fN_Proton[0] = 0;
510  fN_Alpha[0] = 0;
511 
512  fN_Agata[0] = 0;
513  fN_Diamant[0] = 0;
514  fN_Diamant_proton[0] = 0;
515  fN_Diamant_alpha[0] = 0;
516  fN_NW[0] = 0;
517 
518  fN_Gamma[1] = kMaxPr_fHits;
519  fN_Neutron[1] = kMaxPr_fHits;
520  fN_Proton[1] = kMaxPr_fHits;
521  fN_Alpha[1] = kMaxPr_fHits;
522 
523  fN_Agata[1] = kMaxEv_fHits;
524  fN_Diamant[1] = kMaxEv_fHits;
525  fN_Diamant_proton[1] = kMaxEv_fHits;
526  fN_Diamant_alpha[1] = kMaxEv_fHits;
527  fN_NW[1] = kMaxEv_fHits;
528 
529  PlotEfficiencies = 0;
530  EfficiencyPlotFileName = "";
531 
532  fFileName = Form("%s_%sEntryList.root",fChain->GetName(),GetOption());
533 
534  if(!FileIn)
535  {
536  cout<<"No Configuration file ==> Exit"<<endl;
537  cout<<"An example of configuration file is available in the Conf folder"<<endl;
538  gROOT->ProcessLine(".qqqqqqqqqqqqqqqqq");
539  }
540 
541  string line;
542  TString Buffer;
543 
544  Int_t *CurrentParameter;
545 
546  while(FileIn)
547  {
548  getline(FileIn,line);
549  Buffer = line;
550 
551  if(Buffer.BeginsWith("#")) continue;
552  if(Buffer.BeginsWith("N_Gamma")) CurrentParameter = fN_Gamma;
553  else if(Buffer.BeginsWith("N_Neutron")) CurrentParameter = fN_Neutron;
554  else if(Buffer.BeginsWith("N_Proton")) CurrentParameter = fN_Proton;
555  else if(Buffer.BeginsWith("N_Alpha")) CurrentParameter = fN_Alpha;
556  else if(Buffer.BeginsWith("Hits_Agata")) CurrentParameter = fN_Agata;
557  else if(Buffer.BeginsWith("Hits_Diamant")) CurrentParameter = fN_Diamant;
558  else if(Buffer.BeginsWith("Hits_Proton")) CurrentParameter = fN_Diamant_proton;
559  else if(Buffer.BeginsWith("Hits_Alpha")) CurrentParameter = fN_Diamant_alpha;
560  else if(Buffer.BeginsWith("Hits_NW")) CurrentParameter = fN_NW;
561  else if(Buffer.BeginsWith("FilterName")) CurrentParameter = 0x0;
562  else if(Buffer.BeginsWith("EffPlot")) CurrentParameter = 0x0;
563  else continue;
564 
565  Buffer.ReplaceAll("\t"," ");
566  TObjArray *loa=Buffer.Tokenize(" ");
567  Int_t NValues = loa->GetEntries();
568 
569  if(CurrentParameter == 0x0)
570  {
571  if(Buffer.BeginsWith("FilterName"))
572  {
573  if(NValues != 2)
574  {
575  cout<<"Wrong Filter name definition, default one is taken"<<endl;
576  }
577  else
578  {
579  fFileName = (TString)fChain->GetName() + "_" + (TString)loa->Last()->GetName() + "_EntryList.root";
580  }
581  cout<<"EntryList will be stored in "<<fFileName<<endl;
582  continue;
583  }
584  else if(Buffer.BeginsWith("EffPlot"))
585  {
586  if(NValues != 2)
587  {
588  cout<<"Wrong Efficiencies plot definition, no plot will be stored"<<endl;
589  }
590  else
591  {
592  PlotEfficiencies = ((TString)loa->Last()->GetName()).Atoi();
593  if(PlotEfficiencies<0) PlotEfficiencies = 0;
594  if(PlotEfficiencies>2) PlotEfficiencies = 2;
595  }
596  if(PlotEfficiencies == 0)
597  {
598  cout<<"Efficiencies will not be plotted"<<endl;
599  continue;
600  }
601  if(PlotEfficiencies == 1)
602  {
603  EfficiencyPlotFileName = fFileName.Copy().ReplaceAll("EntryList","Efficiencies");
604  cout<<"Efficiencies will be plotted for filtered events in "<<EfficiencyPlotFileName<<endl;
605  }
606  else
607  {
608  EfficiencyPlotFileName = (TString)fChain->GetName() + "_Global_Efficiencies.root";
609  cout<<"Global Efficiencies will be plotted in "<<EfficiencyPlotFileName<<endl;
610  }
611 
612  continue;
613  }
614 
615  }
616  else
617  {
618  if(NValues == 2)
619  {
620  CurrentParameter[0] = ((TString)loa->Last()->GetName()).Atoi();
621  CurrentParameter[1] = CurrentParameter[0];
622  }
623  else if(NValues == 3)
624  {
625  CurrentParameter[0] = ((TString)loa->At(1)->GetName()).Atoi();
626  if((TString)loa->Last()->GetName() != "Max") CurrentParameter[1] = ((TString)loa->Last()->GetName()).Atoi();
627  }
628  else
629  {
630  cout<<setw(13)<<loa->First()->GetName()<<" : Wrong number of entries in the configuration file"<<endl;
631  }
632  cout<<left<<setw(13)<<loa->First()->GetName()<<" restricted to [ "<<setw(4)<<CurrentParameter[0]<<" ; "<<setw(4)<<CurrentParameter[1]<<"]"<<endl;
633 
634  }
635 
636  delete loa;
637  }
638  FileIn.close();
639 }
virtual void SlaveTerminate()
virtual void Init(TTree *tree)
virtual void Begin(TTree *tree)
virtual void Terminate()
const Int_t kMaxEv_fHits
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Int_t Pr_fHits_fPDG[kMaxPr_fHits]
const Int_t kMaxPr_fHits
unsigned long NEntries
pointer to the analyzed TTree or TChain
virtual void SlaveBegin(TTree *tree)
ADF::LogMessage & endl(ADF::LogMessage &log)
Int_t Ev_fHits_fUID[kMaxEv_fHits]
Int_t Ev_fHits_fFlag[kMaxEv_fHits]
virtual Bool_t Process(Long64_t entry)