1 #define AncillaryFilter_cxx
30 #include "TEventList.h"
31 #include "TEntryList.h"
34 #include <TDatabasePDG.h>
48 TEventList *evlist; TEntryList *enlist;
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);
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);
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);
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);
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);
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);
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);
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);
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);
133 GlobalExitChannelDistrib =
new TH1F(
"ExitChannelDistrib",
"ExitChannelDistrib",50,0,50);
135 for(
int i=0 ; i<=5 ; i++)
137 for(
int j=0 ; j<=5 ; j++)
139 for(
int k=0 ; k<=1 ; k++)
141 TString Name = Form(
"ECDist_%dn%dp%da",i,j,k);
142 ExitChannelDistrib[i][j][k] =
new TH1F(Name,Name,50,0,50);
150 gPDG = TDatabasePDG::Instance()->GetParticle(
"gamma")->PdgCode();
151 nPDG = TDatabasePDG::Instance()->GetParticle(
"neutron")->PdgCode();
152 pPDG = TDatabasePDG::Instance()->GetParticle(
"proton")->PdgCode();
159 if ( gDirectory->GetList()->FindObject(
"SToGS_entrylist") ) {
160 delete gDirectory->GetList()->FindObject(
"SToGS_entrylist");
165 enlist =
new TEntryList(
"SToGS_entrylist",
"selection from TSelector");
166 enlist->SetDirectory(0);
168 enlist->SetTreeName(
fChain->GetName());
169 enlist->SetFileName(gSystem->BaseName(
fChain->GetDirectory()->GetName()));
172 cout<<
"Starting to process events : "<<
endl;
182 TString option = GetOption();
208 if(
fChain->GetChainEntryNumber(entry+1)%
Fact==0)
210 cout<<
"\r"<<
"Analysis progress : "<<setw(3)<<(double)
fChain->GetChainEntryNumber(entry+1)/(double)
NEntries*100<<
" %"<<
" ("<<
fChain->GetChainEntryNumber(entry+1)<<
"/"<<
NEntries<<
")"<<flush;
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;
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;
246 if(PlotEfficiencies == 2 && (nb_AGATA >= fN_Agata[0] && nb_AGATA <= fN_Agata[1]))
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);
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);
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);
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",
"");
265 GlobalExitChannelDistrib->GetXaxis()->FindBin(ExitChannel);
266 GlobalExitChannelDistrib->Fill(ExitChannel,1);
269 TString HistName = Form(
"ECDist_%dn%dp%da",nb_NW,nb_DIAM_proton,nb_DIAM_alpha);
270 TH1 *h = (TH1*)gROOT->FindObject(HistName);
273 h->GetXaxis()->FindBin(ExitChannel);
274 h->Fill(ExitChannel,1);
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]))
294 enlist->Enter(
fChain->GetChainEntryNumber(entry));
296 if(PlotEfficiencies == 1)
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);
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);
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);
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",
"");
315 GlobalExitChannelDistrib->GetXaxis()->FindBin(ExitChannel);
316 GlobalExitChannelDistrib->Fill(ExitChannel,1);
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;
345 TFile *FileOut =
new TFile(fFileName,
"UPDATE");
351 if(PlotEfficiencies != 0)
353 for(
int i=1 ; i<=50 ; i++)
355 TH1 *h = AGATACountsPrNorm->ProjectionX();
356 Int_t EntriesAGATA = h->GetBinContent(i);
359 h = DiamantCountsPrNorm->ProjectionX();
360 Int_t EntriesDiam = h->GetBinContent(i);
363 h = NWCountsPrNorm->ProjectionX();
364 Int_t EntriesNW = h->GetBinContent(i);
367 for(
int j=1 ; j<=50 ; j++)
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));
375 for(
int j=1 ; j<=50 ; j++)
377 TH1 *h = AGATACountsEvNorm->ProjectionY();
378 Int_t EntriesAGATA = h->GetBinContent(j);
381 h = DiamantCountsEvNorm->ProjectionY();
382 Int_t EntriesDiam = h->GetBinContent(j);
385 h = NWCountsEvNorm->ProjectionY();
386 Int_t EntriesNW = h->GetBinContent(j);
389 for(
int i=1 ; i<=50 ; i++)
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));
397 Int_t Entries = AGATACountsGlobNorm->GetEntries();
399 for(
int i=1 ; i<=50 ; i++)
401 for(
int j=1 ; j<=50 ; j++)
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));
409 TFile *fHists =
new TFile(EfficiencyPlotFileName,
"recreate");
411 TString Name = GlobalExitChannelDistrib->GetName();
412 TString Title = GlobalExitChannelDistrib->GetName();
413 Int_t NBins = GlobalExitChannelDistrib->FindLastBinAbove(0);
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);
423 for(
int i=0 ; i<NBins ; i++)
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);
434 if(PlotEfficiencies == 2)
436 fHists->mkdir(
"ExitChannelsDist");
437 fHists->cd(
"ExitChannelsDist");
439 for(
int i=0 ; i<=5 ; i++)
441 for(
int j=0 ; j<=5 ; j++)
443 for(
int k=0 ; k<=1 ; k++)
445 TH1 *h = ExitChannelDistrib[i][j][k];
446 h->Scale(1./((
double)h->GetEntries()));
447 TString Name = h->GetName();
448 TString Title = h->GetName();
450 TH1F *htemp = (TH1F*)h->Clone(
"htemp");
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);
459 for(
int i=0 ; i<NBins ; i++)
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));
472 GlobalExitChannelDistrib->Write();
474 fHists->mkdir(
"GlobNorm");
475 fHists->cd(
"GlobNorm");
476 AGATACountsGlobNorm->Write();
477 DiamantCountsGlobNorm->Write();
478 NWCountsGlobNorm->Write();
480 fHists->mkdir(
"PrNorm");
481 fHists->cd(
"PrNorm");
482 AGATACountsPrNorm->Write();
483 DiamantCountsPrNorm->Write();
484 NWCountsPrNorm->Write();
486 fHists->mkdir(
"EvNorm");
487 fHists->cd(
"EvNorm");
488 AGATACountsEvNorm->Write();
489 DiamantCountsEvNorm->Write();
490 NWCountsEvNorm->Write();
499 cout<<
"******************************"<<
endl;
500 cout<<
"* Reading Configuration File *"<<
endl;
501 cout<<
"******************************"<<
endl;
504 std::ifstream FileIn;
505 FileIn.open(
"AncillaryFilter.conf", std::ifstream::in);
514 fN_Diamant_proton[0] = 0;
515 fN_Diamant_alpha[0] = 0;
529 PlotEfficiencies = 0;
530 EfficiencyPlotFileName =
"";
532 fFileName = Form(
"%s_%sEntryList.root",
fChain->GetName(),GetOption());
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");
544 Int_t *CurrentParameter;
548 getline(FileIn,line);
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;
565 Buffer.ReplaceAll(
"\t",
" ");
566 TObjArray *loa=Buffer.Tokenize(
" ");
567 Int_t NValues = loa->GetEntries();
569 if(CurrentParameter == 0x0)
571 if(Buffer.BeginsWith(
"FilterName"))
575 cout<<
"Wrong Filter name definition, default one is taken"<<
endl;
579 fFileName = (TString)
fChain->GetName() +
"_" + (TString)loa->Last()->GetName() +
"_EntryList.root";
581 cout<<
"EntryList will be stored in "<<fFileName<<
endl;
584 else if(Buffer.BeginsWith(
"EffPlot"))
588 cout<<
"Wrong Efficiencies plot definition, no plot will be stored"<<
endl;
592 PlotEfficiencies = ((TString)loa->Last()->GetName()).Atoi();
593 if(PlotEfficiencies<0) PlotEfficiencies = 0;
594 if(PlotEfficiencies>2) PlotEfficiencies = 2;
596 if(PlotEfficiencies == 0)
598 cout<<
"Efficiencies will not be plotted"<<
endl;
601 if(PlotEfficiencies == 1)
603 EfficiencyPlotFileName = fFileName.Copy().ReplaceAll(
"EntryList",
"Efficiencies");
604 cout<<
"Efficiencies will be plotted for filtered events in "<<EfficiencyPlotFileName<<
endl;
608 EfficiencyPlotFileName = (TString)
fChain->GetName() +
"_Global_Efficiencies.root";
609 cout<<
"Global Efficiencies will be plotted in "<<EfficiencyPlotFileName<<
endl;
620 CurrentParameter[0] = ((TString)loa->Last()->GetName()).Atoi();
621 CurrentParameter[1] = CurrentParameter[0];
623 else if(NValues == 3)
625 CurrentParameter[0] = ((TString)loa->At(1)->GetName()).Atoi();
626 if((TString)loa->Last()->GetName() !=
"Max") CurrentParameter[1] = ((TString)loa->Last()->GetName()).Atoi();
630 cout<<setw(13)<<loa->First()->GetName()<<
" : Wrong number of entries in the configuration file"<<
endl;
632 cout<<left<<setw(13)<<loa->First()->GetName()<<
" restricted to [ "<<setw(4)<<CurrentParameter[0]<<
" ; "<<setw(4)<<CurrentParameter[1]<<
"]"<<
endl;
virtual void SlaveTerminate()
virtual void Init(TTree *tree)
virtual void Begin(TTree *tree)
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Int_t Pr_fHits_fPDG[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)