3 |
|
#include "MitAna/TreeMod/interface/AnaFwkMod.h" |
4 |
|
#include "MitAna/DataUtil/interface/Debug.h" |
5 |
|
#include "MitAna/DataTree/interface/Names.h" |
6 |
+ |
#include "MitAna/DataTree/interface/PileupInfo.h" |
7 |
|
#include <TFile.h> |
8 |
|
#include <TH1D.h> |
9 |
+ |
#include <TH3D.h> |
10 |
|
#include <TStopwatch.h> |
11 |
|
#include <TTree.h> |
12 |
|
|
20 |
|
fAllHeadTreeName(Names::gkAllEvtTreeName), |
21 |
|
fAllHeadBrName(Names::gkAllEvtHeaderBrn), |
22 |
|
fSkipNEvents(0), |
23 |
+ |
fPrintScale(1), |
24 |
|
fSWtotal(0), |
25 |
|
fSWevent(0), |
26 |
|
fAllHeaders(0,Names::gkSkimmedHeaders), |
29 |
|
fReload(kFALSE), |
30 |
|
fCurEnt(-2), |
31 |
|
fNEventsSkimmed(0), |
32 |
< |
fNEventsSkipped(0) |
32 |
> |
fNEventsSkipped(0), |
33 |
> |
fPileupInfoName("PileupInfo"), |
34 |
> |
fDoPUInfo(kFALSE), |
35 |
> |
hNPU(0), |
36 |
> |
hNPU50ns(0), |
37 |
> |
hNPUTrue(0) |
38 |
|
{ |
39 |
|
// Constructor. |
40 |
|
} |
57 |
|
if (!file) |
58 |
|
return; |
59 |
|
|
60 |
< |
// get HLT tree |
60 |
> |
// get all event header tree |
61 |
|
fAllHeadTree = dynamic_cast<TTree*>(file->Get(fAllHeadTreeName)); |
62 |
|
if (!fAllHeadTree) { |
63 |
|
SendError(kWarning, "BeginRun", |
64 |
< |
"Can not find tree '%s' in file '%s'", |
64 |
> |
"Cannot find tree '%s' in file '%s'", |
65 |
|
fAllHeadTreeName.Data(),file->GetName()); |
66 |
|
return; |
67 |
|
} |
60 |
– |
} |
68 |
|
|
69 |
< |
// get HLT trigger name branch |
70 |
< |
if (fAllHeadTree->GetBranch(fAllHeadBrName)) { |
71 |
< |
fAllHeadTree->SetBranchAddress(fAllHeadBrName, &fAllEventHeader); |
72 |
< |
} else { |
73 |
< |
SendError(kWarning, "BeginRun", |
74 |
< |
"Can not find branch '%s' in tree '%s'", |
75 |
< |
fAllHeadBrName.Data(), fAllHeadTreeName.Data()); |
76 |
< |
return; |
69 |
> |
// get all event header branch |
70 |
> |
if (fAllHeadTree->GetBranch(fAllHeadBrName)) { |
71 |
> |
fAllHeadTree->SetBranchAddress(fAllHeadBrName, &fAllEventHeader); |
72 |
> |
} else { |
73 |
> |
SendError(kWarning, "BeginRun", |
74 |
> |
"Cannot find branch '%s' in tree '%s'", |
75 |
> |
fAllHeadBrName.Data(), fAllHeadTreeName.Data()); |
76 |
> |
return; |
77 |
> |
} |
78 |
|
} |
79 |
|
} |
80 |
|
|
87 |
|
|
88 |
|
const EventHeader *curev = GetEventHeader(); |
89 |
|
if (!curev) { |
90 |
< |
SendError(kWarning, "CopyAllEventHeaders", "Can not obtain current event"); |
90 |
> |
SendError(kWarning, "CopyAllEventHeaders", "Cannot obtain current event"); |
91 |
|
return; |
92 |
|
} |
93 |
|
|
99 |
|
return; |
100 |
|
} |
101 |
|
fAllHeadTree->GetEntry(fCurEnt++); |
102 |
< |
while(fCurEnt<=nemax && fAllEventHeader->Skimmed()) { |
102 |
> |
while (fCurEnt <= nemax && fAllEventHeader->Skimmed()) { |
103 |
|
EventHeader *eh = fAllHeaders.AddNew(); |
104 |
< |
eh->SetRunNum(fAllEventHeader->RunNum()); |
105 |
< |
eh->SetEvtNum(fAllEventHeader->EvtNum()); |
106 |
< |
eh->SetLumiSec(fAllEventHeader->LumiSec()); |
104 |
> |
eh->SetRunNum (fAllEventHeader->RunNum()); |
105 |
> |
eh->SetEvtNum (fAllEventHeader->EvtNum()); |
106 |
> |
eh->SetLumiSec (fAllEventHeader->LumiSec()); |
107 |
|
eh->SetRunEntry(fAllEventHeader->RunEntry()); |
108 |
< |
eh->SetSkimmed(fAllEventHeader->Skimmed()); |
108 |
> |
eh->SetSkimmed (fAllEventHeader->Skimmed()); |
109 |
|
fAllHeadTree->GetEntry(fCurEnt++); |
110 |
|
} |
111 |
< |
if ((fAllEventHeader->RunNum()!=curev->RunNum()) || |
112 |
< |
(fAllEventHeader->EvtNum()!=curev->EvtNum()) || |
113 |
< |
(fAllEventHeader->LumiSec()!=curev->LumiSec()) || |
114 |
< |
(fAllEventHeader->RunEntry()!=curev->RunEntry())) { |
111 |
> |
if ((fAllEventHeader->RunNum() != curev->RunNum()) || |
112 |
> |
(fAllEventHeader->EvtNum() != curev->EvtNum()) || |
113 |
> |
(fAllEventHeader->LumiSec() != curev->LumiSec()) || |
114 |
> |
(fAllEventHeader->RunEntry() != curev->RunEntry())) { |
115 |
|
SendError(kWarning, "CopyAllEventHeaders", |
116 |
|
"Event header information for entry %d inconsistent: " |
117 |
|
"%d==%d, %d==%d, %d==%d, %d==%d", |
127 |
|
if (fCurEnt<nemax) { |
128 |
|
Int_t testEnt = fCurEnt; |
129 |
|
fAllHeadTree->GetEntry(testEnt++); |
130 |
< |
while(testEnt<=nemax && fAllEventHeader->Skimmed()) |
130 |
> |
while (testEnt<=nemax && fAllEventHeader->Skimmed()) |
131 |
|
fAllHeadTree->GetEntry(testEnt++); |
132 |
|
if (testEnt==nemax+1) { // need to add remaining skimmed events |
133 |
|
fAllHeadTree->GetEntry(fCurEnt++); |
134 |
|
while(fCurEnt<=nemax) { |
135 |
|
EventHeader *eh = fAllHeaders.AddNew(); |
136 |
< |
eh->SetRunNum(fAllEventHeader->RunNum()); |
137 |
< |
eh->SetEvtNum(fAllEventHeader->EvtNum()); |
138 |
< |
eh->SetLumiSec(fAllEventHeader->LumiSec()); |
136 |
> |
eh->SetRunNum (fAllEventHeader->RunNum()); |
137 |
> |
eh->SetEvtNum (fAllEventHeader->EvtNum()); |
138 |
> |
eh->SetLumiSec (fAllEventHeader->LumiSec()); |
139 |
|
eh->SetRunEntry(fAllEventHeader->RunEntry()); |
140 |
< |
eh->SetSkimmed(fAllEventHeader->Skimmed()); |
140 |
> |
eh->SetSkimmed (fAllEventHeader->Skimmed()); |
141 |
|
fAllHeadTree->GetEntry(fCurEnt++); |
142 |
|
} |
143 |
|
if (fCurEnt != nemax+1) { |
175 |
|
if (fNEventsSkipped<fSkipNEvents) { |
176 |
|
++fNEventsSkipped; |
177 |
|
MDB(kAnalysis, 3) { |
178 |
< |
SendError(kWarning, "Process", "Skipping (aborting) %d out of %d first events.", |
179 |
< |
fNEventsSkipped, fSkipNEvents); |
178 |
> |
Info("Process", "Skipping (aborting) %d out of %lld first events.", |
179 |
> |
fNEventsSkipped, fSkipNEvents); |
180 |
|
} |
181 |
|
AbortEvent(); |
182 |
|
return; |
183 |
|
} |
184 |
|
|
185 |
|
// check if printout should be done |
186 |
< |
Bool_t doPrint = 0; |
186 |
> |
Bool_t doPrint = 0; |
187 |
> |
UInt_t nProcessed = fPrintScale; |
188 |
|
|
189 |
|
MDB(kAnalysis, 4) { |
190 |
< |
if (GetNEventsProcessed() % 250 == 0) |
190 |
> |
if (GetNEventsProcessed() % (fPrintScale) == 0) |
191 |
|
doPrint = 1; |
192 |
|
} else { |
193 |
|
MDB(kAnalysis, 3) { |
194 |
< |
if (GetNEventsProcessed() % 2500 == 0) |
194 |
> |
if (GetNEventsProcessed() % (fPrintScale*10) == 0) |
195 |
|
doPrint = 1; |
196 |
+ |
nProcessed = fPrintScale*10; |
197 |
|
} else { |
198 |
|
MDB(kAnalysis, 2) { |
199 |
< |
if (GetNEventsProcessed() % 10000 == 0) |
199 |
> |
if (GetNEventsProcessed() % (fPrintScale*100) == 0) |
200 |
|
doPrint = 1; |
201 |
+ |
nProcessed = fPrintScale*100; |
202 |
|
} else { |
203 |
|
MDB(kAnalysis, 1) { |
204 |
< |
if (GetNEventsProcessed() % 50000 == 0) |
204 |
> |
if (GetNEventsProcessed() % (fPrintScale*1000) == 0) |
205 |
|
doPrint = 1; |
206 |
+ |
nProcessed = fPrintScale*1000; |
207 |
|
} |
208 |
|
} |
209 |
|
} |
210 |
|
} |
211 |
|
|
212 |
+ |
if (GetEventHeader()->IsMC()) { |
213 |
+ |
LoadBranch(fPileupInfoName); |
214 |
+ |
Double_t npu[4] = {0.,0.,0.,0.}; |
215 |
+ |
for (UInt_t i=0; i<fPileupInfo->GetEntries(); ++i) { |
216 |
+ |
const PileupInfo *puinfo = fPileupInfo->At(i); |
217 |
+ |
if (puinfo->GetBunchCrossing()==0) npu[0]= puinfo->GetPU_NumInteractions(); |
218 |
+ |
else if (puinfo->GetBunchCrossing()==-1) npu[1] = puinfo->GetPU_NumInteractions(); |
219 |
+ |
else if (puinfo->GetBunchCrossing()==1) npu[2] = puinfo->GetPU_NumInteractions(); |
220 |
+ |
if (puinfo->GetBunchCrossing()==0) npu[3]= puinfo->GetPU_NumMean(); |
221 |
+ |
} |
222 |
+ |
hNPU->Fill(npu[0]); |
223 |
+ |
hNPU50ns->Fill(npu[0],npu[1],npu[2]); |
224 |
+ |
hNPUTrue->Fill(npu[3]); |
225 |
+ |
} |
226 |
+ |
|
227 |
+ |
|
228 |
|
if (doPrint) { |
229 |
|
fSWevent->Stop(); |
230 |
< |
SendError(kWarning, "Process", |
231 |
< |
"Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)", |
232 |
< |
GetNEventsProcessed(), fSWevent->RealTime(), fSWevent->CpuTime(), |
233 |
< |
fSWevent->RealTime()/GetNEventsProcessed(), |
234 |
< |
fSWevent->CpuTime()/GetNEventsProcessed()); |
230 |
> |
Info("Process", |
231 |
> |
"Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)", |
232 |
> |
GetNEventsProcessed(), fSWevent->RealTime(), fSWevent->CpuTime(), |
233 |
> |
fSWevent->RealTime()/nProcessed, |
234 |
> |
fSWevent->CpuTime()/nProcessed); |
235 |
|
fSWevent->Start(); |
236 |
< |
} |
236 |
> |
} |
237 |
> |
|
238 |
> |
|
239 |
|
} |
240 |
|
|
241 |
|
//-------------------------------------------------------------------------------------------------- |
251 |
|
"Could not publish all event headers with name %s.", fAllHeaders.GetName()); |
252 |
|
return; |
253 |
|
} |
254 |
+ |
|
255 |
+ |
ReqBranch(fPileupInfoName, fPileupInfo); |
256 |
+ |
|
257 |
+ |
hNPU = new TH1D("hNPU", "hNPU", 201, -0.5, 200.5); |
258 |
+ |
AddOutput(hNPU); |
259 |
+ |
|
260 |
+ |
hNPU50ns = new TH3D("hNPU50ns", "hNPU50ns", 201, -0.5, 200.5, 201, -0.5, 200.5, 201, -0.5, 200.5); |
261 |
+ |
AddOutput(hNPU50ns); |
262 |
+ |
|
263 |
+ |
hNPUTrue = new TH1D("hNPUTrue", "hNPUTrue", 2000, 0.0, 200.0); |
264 |
+ |
AddOutput(hNPUTrue); |
265 |
+ |
|
266 |
|
} |
267 |
|
|
268 |
|
//-------------------------------------------------------------------------------------------------- |
287 |
|
fSWevent->Stop(); |
288 |
|
|
289 |
|
MDB(kAnalysis, 1) |
290 |
< |
SendError(kWarning, "SlaveTerminate", |
291 |
< |
"Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)", |
292 |
< |
GetNEventsProcessed(), fSWtotal->RealTime(), fSWtotal->CpuTime(), |
293 |
< |
fSWtotal->RealTime()/GetNEventsProcessed(), |
294 |
< |
fSWtotal->CpuTime()/GetNEventsProcessed()); |
290 |
> |
Info("SlaveTerminate", |
291 |
> |
"Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)", |
292 |
> |
GetNEventsProcessed(), fSWtotal->RealTime(), fSWtotal->CpuTime(), |
293 |
> |
fSWtotal->RealTime()/GetNEventsProcessed(), |
294 |
> |
fSWtotal->CpuTime()/GetNEventsProcessed()); |
295 |
|
|
296 |
|
delete fSWtotal; |
297 |
|
delete fSWevent; |