21 TFile *
out = TFile::Open(
"benchmark.root",
"RECREATE");
30 double t0Dist_plus = 10;
31 double t0Dist_minus = 4;
34 FairRunAna *
fRun =
new FairRunAna();
35 fRun->SetInputFile(recoFile);
36 fRun->AddFriend(digiFile);
37 fRun->AddFriend(simFile);
38 fRun->SetOutputFile(outFile);
39 fRun->SetUseFairLinks(kTRUE);
43 allDigiFile +=
"/macro/params/all.par";
45 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
46 FairParRootFileIo*
parInput1 =
new FairParRootFileIo();
47 parInput1->open(parFile.Data());
49 FairParAsciiFileIo*
parIo1 =
new FairParAsciiFileIo();
50 parIo1->open(allDigiFile.Data(),
"in");
51 rtdb->setFirstInput(parInput1);
52 rtdb->setSecondInput(parIo1);
61 int t0_candidates = 0, t0_ghosts = 0, t0_good = 0, t0_missed = 0, t0_double = 0, t0_MCs = 0;
63 std::multiset<double> set_t0MC, set_t0Candidates;
64 std::multiset<double>::iterator it_t0Can, it_t0Can2, it_t0CanOld, it_t0MC;
69 int binN = 1000, binStart = 0, binEnd = 5000;
71 TH1D *h_t0_MC =
new TH1D(
"h_t0_MC",
"t0 ;time [ns]", binN, binStart,binEnd);
72 TH1D *h_t0Candidates =
new TH1D(
"h_t0Candidates",
"t0 ;time [ns]", binN,binStart, binEnd);
73 THStack *hs_timeline =
new THStack(
"hs_timeline",
"event time and T0 candidates ;time [ns]");
75 TH1D *h_t0Resolution =
new TH1D(
"h_t0Resolution",
"t0 Resolution ;time [ns]", 10*(t0Dist_plus+t0Dist_minus), -t0Dist_minus, t0Dist_plus);
76 TH1D *h_results =
new TH1D(
"h_results",
"results",6,0,5);
79 FairRootManager* ioman = FairRootManager::Instance();
81 TClonesArray* t0CandidateArray = (TClonesArray*) ioman->GetObject(
"T0Candidates");
83 FairTimeStamp *t0Candidate;
86 FairEventHeader* evtHeader = NULL;
87 TFile* digFile = TFile::Open(digiFile);
88 TTree* digTree = (TTree*) digFile->Get(
"pndsim");
89 digTree->SetBranchAddress(
"EventHeader.", &evtHeader);
93 Ev_end = Int_t((ioman->GetInChain())->
GetEntries());
94 cout <<
" EndEvent = " << Ev_end << endl;
99 for (
int i_Event = Ev_start; i_Event < Ev_end; i_Event++) {
101 digTree->GetEntry(i_Event);
102 ioman->ReadEvent(i_Event);
103 cout <<
"event: " << i_Event <<
" time: " << evtHeader->GetEventTime()
106 if (i_Event < Ev_end - 2) {
107 t0_MC = evtHeader->GetEventTime();
109 h_t0_MC->Fill(t0_MC, -0.5);
111 set_t0MC.insert(t0_MC);
114 for (Int_t i_Array = 0; i_Array < t0CandidateArray->GetEntries();
117 t0Candidate = (FairTimeStamp*) t0CandidateArray->At(i_Array);
118 timeStamp = t0Candidate->GetTimeStamp();
119 if (timeStamp < binEnd)
120 h_t0Candidates->Fill(timeStamp);
122 set_t0Candidates.insert(timeStamp);
131 t0_candidates = set_t0Candidates.size();
132 t0_MCs = set_t0MC.size();
134 for (it_t0MC = set_t0MC.begin(); it_t0MC != set_t0MC.end();it_t0MC++){
136 it_t0Can = set_t0Candidates.lower_bound(*it_t0MC-t0Dist_minus);
138 if(it_t0Can == set_t0Candidates.end()){
143 dist1 = *it_t0Can - *it_t0MC;
144 if (dist1 > t0Dist_plus){
148 it_t0Can2 = it_t0Can;
150 if(it_t0Can2 != set_t0Candidates.end()){
151 dist2 = *it_t0Can2 - *it_t0MC;
152 if(abs(dist2) < abs(dist1)){
153 it_t0Can = it_t0Can2;
159 h_t0Resolution->Fill(dist1);
160 if(it_t0CanOld == it_t0Can) t0_double++;
161 it_t0CanOld = it_t0Can;
164 t0_ghosts = t0_candidates - t0_good;
166 h_results->Fill(
"t0_MCs",t0_MCs);
167 h_results->Fill(
"t0_candidates",t0_candidates);
168 h_results->Fill(
"t0_good",t0_good);
169 h_results->Fill(
"t0_double",t0_double);
170 h_results->Fill(
"t0_missed",t0_missed);
171 h_results->Fill(
"t0_ghosts",t0_ghosts);
174 h_t0_MC->SetLineColor(6);
175 h_t0_MC->SetFillColor(6);
177 h_t0Candidates->SetLineColor(1);
178 h_t0Candidates->SetFillColor(1);
180 hs_timeline->Add(h_t0Candidates);
181 hs_timeline->Add(h_t0_MC);
183 TCanvas *
c =
new TCanvas;
185 c->SaveAs(
"results.pdf");
189 h_t0_MC->Write(
"", TObject::kOverwrite);
190 h_t0Candidates->Write(
"", TObject::kOverwrite);
192 hs_timeline->Write(
"", TObject::kOverwrite);
194 h_results->Write(
"", TObject::kOverwrite);
199 cout << endl << endl;
200 cout <<
"Macro finished succesfully." << endl;
201 cout <<
"Output file is " << outFile << endl;
202 cout <<
"Parameter file is " << parFile << endl;
203 cout <<
"Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
206 cout <<
" Test passed" << endl;
207 cout <<
" All ok " << endl;
FairParRootFileIo * parInput1
FairParAsciiFileIo * parIo1
cout<<"will loop over "<< t-> GetEntries()