4 |
|
#include <vector> // STL vector class |
5 |
|
#include <iostream> // standard I/O |
6 |
|
#include <iomanip> // functions to format standard I/O |
7 |
< |
#include <fstream> // functions for file I/O |
8 |
< |
#include <string> // C++ string class |
9 |
< |
#include <sstream> // class for parsing strings |
10 |
< |
#include <assert.h> |
11 |
< |
#include <stdlib.h> |
12 |
< |
#include <getopt.h> |
7 |
> |
#include <bitset> |
8 |
> |
#include <map> |
9 |
|
using namespace std; |
10 |
|
|
11 |
|
// |
12 |
< |
// ROOT headers |
12 |
> |
// root headers |
13 |
|
// |
14 |
< |
#include <TROOT.h> // access to gROOT, entry point to ROOT system |
15 |
< |
#include <TSystem.h> // interface to OS |
16 |
< |
#include <TFile.h> // file handle class |
17 |
< |
#include <TNtuple.h> |
18 |
< |
#include <TTree.h> // class to access ntuples |
19 |
< |
#include <TChain.h> // |
20 |
< |
#include <TBranch.h> // class to access branches in TTree |
21 |
< |
#include <TClonesArray.h> // ROOT array class |
22 |
< |
#include <TCanvas.h> // class for drawing |
23 |
< |
#include <TH1F.h> // 1D histograms |
24 |
< |
#include <TBenchmark.h> // class to track macro running statistics |
25 |
< |
#include <TLorentzVector.h> // 4-vector class |
26 |
< |
#include <TVector3.h> // 3D vector class |
14 |
> |
#include <TFile.h> |
15 |
> |
#include <TTree.h> |
16 |
> |
#include <TChain.h> |
17 |
> |
#include <TBranch.h> |
18 |
> |
#include <TClonesArray.h> |
19 |
> |
|
20 |
> |
|
21 |
> |
// |
22 |
> |
// TMVA |
23 |
> |
// |
24 |
> |
#include "TMVA/Reader.h" |
25 |
> |
#include "TMVA/Tools.h" |
26 |
> |
#include "TMVA/Config.h" |
27 |
> |
#include "TMVA/MethodBDT.h" |
28 |
|
|
29 |
|
// |
30 |
|
// ntuple format headers |
31 |
|
// |
32 |
< |
#include "EWKAnaDefs.hh" |
33 |
< |
#include "TEventInfo.hh" |
34 |
< |
#include "TElectron.hh" |
35 |
< |
#include "TMuon.hh" |
36 |
< |
#include "TJet.hh" |
37 |
< |
#include "RunLumiRangeMap.h" |
32 |
> |
#include "EventHeader.h" |
33 |
> |
#include "Electron.h" |
34 |
> |
#include "Muon.h" |
35 |
> |
#include "Vertex.h" |
36 |
> |
#include "PFCandidate.h" |
37 |
> |
#include "PFCandidateCol.h" |
38 |
> |
#include "PileupInfoCol.h" |
39 |
> |
#include "PileupEnergyDensity.h" |
40 |
> |
#include "MCParticle.h" |
41 |
> |
#include "TriggerMask.h" |
42 |
> |
#include "TriggerTable.h" |
43 |
> |
#include "Names.h" |
44 |
> |
#include "BaseMod.h" |
45 |
|
|
46 |
|
// |
47 |
< |
// utility headers |
47 |
> |
// our headers |
48 |
|
// |
49 |
|
#include "ParseArgs.h" |
50 |
< |
#include "Selection.h" |
51 |
< |
#include "HZZCiCElectronSelection.h" |
50 |
> |
#include "MuonSelection.h" |
51 |
> |
#include "ElectronSelection.h" |
52 |
> |
#include "IsolationSelection.h" |
53 |
> |
|
54 |
> |
//#include "Selection.h" |
55 |
> |
//#include "ReferenceSelection.h" |
56 |
> |
#include "ReferenceSelection2.h" |
57 |
> |
|
58 |
> |
#include "TriggerUtils.h" |
59 |
> |
#include "PassHLT.h" |
60 |
> |
#include "Angles.h" |
61 |
> |
#include "KinematicsStruct.h" |
62 |
> |
#include "InfoStruct.h" |
63 |
> |
//#include "GenInfoStruct.h" |
64 |
> |
#include "WeightStruct.h" |
65 |
> |
//#include "GlobalDataAndFuncs.h" |
66 |
> |
#include "RunLumiRangeMap.h" |
67 |
> |
|
68 |
> |
#include "AngleTuple.h" |
69 |
> |
#include "FOTuple.h" |
70 |
> |
|
71 |
> |
#include "SampleWeight.h" |
72 |
> |
#include "EfficiencyWeightsInterface.h" |
73 |
> |
|
74 |
> |
#include "SimpleLepton.h" |
75 |
> |
|
76 |
> |
#ifndef CMSSW_BASE |
77 |
> |
#define CMSSW_BASE "../" |
78 |
> |
#endif |
79 |
|
|
80 |
< |
//#define THEIR_EVENTS |
80 |
> |
using namespace mithep; |
81 |
|
|
82 |
< |
//=== MAIN ================================================================================================= |
82 |
> |
// |
83 |
> |
// globals |
84 |
> |
//---------------------------------------------------------------------------- |
85 |
> |
TH1D * hpu; |
86 |
> |
RunLumiRangeMap rlrm; |
87 |
> |
vector<SimpleLepton> failingLeptons ; // for fake estimation |
88 |
> |
vector<SimpleLepton> passingLeptons; // for fake estimation |
89 |
> |
vector<unsigned> cutvec; |
90 |
> |
vector<vector<unsigned> > zcutvec; |
91 |
> |
vector<vector<unsigned> > zzcutvec; |
92 |
> |
map<unsigned,float> evtrhoMap; |
93 |
> |
vector<string> cutstrs; |
94 |
> |
bool passes_HLT_MC; |
95 |
> |
vector<bool> PFnoPUflag;; |
96 |
> |
|
97 |
> |
// |
98 |
> |
// prototypes |
99 |
> |
//---------------------------------------------------------------------------- |
100 |
> |
bool setPV(ControlFlags,const mithep::Array<mithep::Vertex>*, mithep::Vertex& ); |
101 |
> |
void initPUWeights(); |
102 |
> |
double getPUWeight(unsigned npu); |
103 |
> |
void setEffiencyWeights(EventData&, WeightStruct& ); |
104 |
> |
void initRunLumiRangeMap(); |
105 |
> |
void initEvtRhoMap(map<unsigned,float> &); |
106 |
> |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
107 |
> |
vector<bool> &pfNoPileUpFlag, |
108 |
> |
mithep::Array<Vertex> * vtxArr ); |
109 |
> |
//---------------------------------------------------------------------------- |
110 |
> |
|
111 |
> |
|
112 |
> |
// |
113 |
> |
// MAIN |
114 |
> |
//---------------------------------------------------------------------------- |
115 |
|
int main(int argc, char** argv) |
116 |
+ |
//---------------------------------------------------------------------------- |
117 |
|
{ |
118 |
< |
|
118 |
> |
cutstrs.push_back(string("skim0")); //0 |
119 |
> |
cutstrs.push_back(string("skim1")); //1 |
120 |
> |
cutstrs.push_back(string("trigger")); //2 |
121 |
> |
// ------------------------------------------------- |
122 |
> |
cutstrs.push_back(string("Z candidate")); //3 |
123 |
> |
cutstrs.push_back(string("good Z1")); //4 |
124 |
> |
// ------------------------------------------------- |
125 |
> |
cutstrs.push_back(string("4l")); //5 |
126 |
> |
cutstrs.push_back(string("ZZ candidate")); //6 |
127 |
> |
cutstrs.push_back(string("good Z2")); //7 |
128 |
> |
cutstrs.push_back(string("ZZ 20/10")); //8 |
129 |
> |
cutstrs.push_back(string("resonance")); //9 |
130 |
> |
cutstrs.push_back(string("m4l>70")); //10 |
131 |
> |
cutstrs.push_back(string("m4l>100")); //11 |
132 |
> |
|
133 |
> |
|
134 |
> |
|
135 |
> |
|
136 |
> |
string cmsswpath(CMSSW_BASE); |
137 |
> |
cmsswpath.append("/src"); |
138 |
> |
std::bitset<1024> triggerBits; |
139 |
|
vector<vector<string> > inputFiles; |
140 |
|
inputFiles.push_back(vector<string>()); |
141 |
+ |
map<string,unsigned> entrymap; // number of unskimmed entries in each file |
142 |
+ |
for( int i=0; i<cutstrs.size(); i++ ) cutvec.push_back(0); |
143 |
+ |
for( int i=0; i<2; i++ ) { |
144 |
+ |
zcutvec.push_back(vector<unsigned>()); |
145 |
+ |
for( int j=0; j<cutstrs.size(); j++ ) zcutvec[i].push_back(0); |
146 |
+ |
} |
147 |
+ |
for( int i=0; i<3; i++ ) { |
148 |
+ |
zzcutvec.push_back(vector<unsigned>()); |
149 |
+ |
for( int j=0; j<cutstrs.size(); j++ ) zzcutvec[i].push_back(0); |
150 |
+ |
} |
151 |
+ |
|
152 |
|
|
153 |
|
// |
154 |
|
// args |
155 |
|
//-------------------------------------------------------------------------------------------------------------- |
156 |
|
ControlFlags ctrl; |
157 |
|
parse_args( argc, argv, ctrl ); |
158 |
< |
if( ctrl.inputfile.empty() || |
159 |
< |
ctrl.inputfile.empty() ) { |
160 |
< |
cerr << "usage: applySelection.exe <flags> " << endl; |
161 |
< |
cerr << "\tmandoatory flags : " << endl; |
162 |
< |
cerr << "\t--inputfile | file containing a list of ntuples to run over" << endl; |
163 |
< |
cerr << "\t--outputfile | file to store selected evet" << endl; |
164 |
< |
return 1; |
165 |
< |
} |
158 |
> |
if( ctrl.inputfiles.empty() &&ctrl.inputfile.empty() ) |
159 |
> |
{ |
160 |
> |
cerr << "usage: applySelection.exe <flags> " << endl; |
161 |
> |
cerr << "\tmandoatory flags : " << endl; |
162 |
> |
cerr << "\t--inputfiles | file containing a list of ntuples to run over" << endl; |
163 |
> |
cerr << "\t--inputfile | a file to run over" << endl; |
164 |
> |
cerr << "\t--outputfile | file to store selected evet" << endl; |
165 |
> |
return 1; |
166 |
> |
} |
167 |
|
ctrl.dump(); |
168 |
|
|
169 |
+ |
|
170 |
+ |
|
171 |
|
// |
172 |
|
// File I/O |
173 |
|
//-------------------------------------------------------------------------------------------------------------- |
174 |
|
TChain * chain = new TChain("Events"); |
175 |
< |
ifstream f(ctrl.inputfile.c_str()); |
175 |
> |
TChain * hltchain = new TChain("HLT"); |
176 |
> |
|
177 |
|
string fname; |
178 |
< |
while (f >> fname) { |
179 |
< |
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines |
180 |
< |
cout << "adding inputfile : " << fname.c_str() << endl; |
181 |
< |
chain->AddFile(fname.c_str()); |
178 |
> |
if( !ctrl.inputfiles.empty() ) { |
179 |
> |
ifstream f(ctrl.inputfiles.c_str()); |
180 |
> |
while (f >> fname) { |
181 |
> |
if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines |
182 |
> |
cout << "adding inputfile : " << fname.c_str() << endl; |
183 |
> |
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
184 |
> |
cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl; |
185 |
> |
chain->AddFile(fname.c_str()); |
186 |
> |
hltchain->AddFile(fname.c_str()); |
187 |
> |
} |
188 |
> |
} else { |
189 |
> |
cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl; |
190 |
> |
unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str()); |
191 |
> |
cout << "tmpent: " << tmpent << endl; |
192 |
> |
entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str()); |
193 |
> |
cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl; |
194 |
> |
chain->AddFile(ctrl.inputfile.c_str()); |
195 |
> |
hltchain->AddFile(ctrl.inputfile.c_str()); |
196 |
> |
} |
197 |
> |
|
198 |
> |
const char * ofname; |
199 |
> |
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
200 |
> |
ofname = ctrl.outputfile.c_str(); |
201 |
> |
} else { |
202 |
> |
ofname = "tmp.root"; |
203 |
|
} |
204 |
+ |
// table of cross section values |
205 |
+ |
string xspath = (cmsswpath+string("/MitPhysics/data/xs.dat")); |
206 |
+ |
cout << "xspath: " << xspath.c_str() << endl; |
207 |
+ |
SimpleTable xstab(xspath.c_str()); |
208 |
+ |
|
209 |
|
|
210 |
|
// |
211 |
|
// Setup |
212 |
|
//-------------------------------------------------------------------------------------------------------------- |
213 |
< |
TH1F * h_evt = new TH1F("hevt", "hevt", 2, 0, 2 ); |
214 |
< |
TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 100, 0, 100 ); |
215 |
< |
TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" ); |
216 |
< |
initCiCSelection(); |
217 |
< |
initRunLumiRangeMap(); |
213 |
> |
Angles angles; |
214 |
> |
KinematicsStruct kinematics; |
215 |
> |
InfoStruct evtinfo; |
216 |
> |
WeightStruct weights; |
217 |
> |
// GenInfoStruct geninfo; |
218 |
> |
|
219 |
> |
AngleTuple nt( (const char*)ofname, (const char*)"zznt"); |
220 |
> |
nt.makeAngleBranch(angles); |
221 |
> |
nt.makeKinematicsBranch(kinematics); |
222 |
> |
nt.makeInfoBranch(evtinfo); |
223 |
> |
|
224 |
> |
FOTuple foTree( nt.getFile(), (const char*)"FOtree"); |
225 |
> |
foTree.makeFailedLeptonBranch(failingLeptons); |
226 |
> |
foTree.makeZLeptonBranch(passingLeptons); |
227 |
> |
|
228 |
> |
TH1F * h_w_hpt; |
229 |
> |
if(ctrl.mc) { |
230 |
> |
nt.makeWeightBranch(weights); |
231 |
> |
// nt.makeGenInfoBranch(geninfo); |
232 |
> |
initEfficiencyWeights(); |
233 |
> |
initPUWeights(); |
234 |
> |
/* |
235 |
> |
// Higgs only, pt reweighting |
236 |
> |
if( ctrl.mH <= 140 ) { |
237 |
> |
char wptname[256]; |
238 |
> |
sprintf( wptname, "/data/blue/pharris/Flat/ntupler/root/weight_ptH_%i.root", ctrl.mH ); |
239 |
> |
TFile * f_hpt = new TFile(wptname); |
240 |
> |
f_hpt->Print(); |
241 |
> |
sprintf(wptname, "weight_hqt_fehipro_fit_%i", ctrl.mH); |
242 |
> |
h_w_hpt = (TH1F*)(f_hpt->FindObjectAny(wptname)); |
243 |
> |
h_w_hpt->Print(); |
244 |
> |
} |
245 |
> |
*/ |
246 |
> |
} else { |
247 |
> |
initRunLumiRangeMap(); |
248 |
> |
} |
249 |
|
|
250 |
+ |
// initMuonIDMVA(); |
251 |
+ |
initMuonIsoMVA(); |
252 |
+ |
initElectronIDMVA(); |
253 |
+ |
initElectronIsoMVA(); |
254 |
+ |
initTrigger(); |
255 |
+ |
|
256 |
+ |
// hack |
257 |
+ |
initEvtRhoMap(evtrhoMap); |
258 |
|
|
95 |
– |
// |
96 |
– |
// Loop |
97 |
– |
//-------------------------------------------------------------------------------------------------------------- |
259 |
|
|
260 |
|
// |
261 |
< |
// Access samples and fill histograms |
261 |
> |
// Setup tree I/O |
262 |
> |
//-------------------------------------------------------------------------------------------------------------- |
263 |
|
TFile *inputFile=0; |
264 |
|
TTree *eventTree=0; |
265 |
< |
|
266 |
< |
// Data structures to store info from TTrees |
267 |
< |
mithep::TEventInfo *info = new mithep::TEventInfo(); |
268 |
< |
TClonesArray *electronArr = new TClonesArray("mithep::TElectron"); |
269 |
< |
TClonesArray *muonArr = new TClonesArray("mithep::TMuon"); |
265 |
> |
string currentFile(""); |
266 |
> |
|
267 |
> |
mithep::EventHeader *info = new mithep::EventHeader(); |
268 |
> |
// mithep::TGenInfo *ginfo = new mithep::TGenInfo(); |
269 |
> |
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
270 |
> |
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
271 |
> |
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
272 |
> |
mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>(); |
273 |
> |
mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>(); |
274 |
> |
mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>(); |
275 |
> |
mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>(); |
276 |
> |
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
277 |
> |
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
278 |
> |
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
279 |
> |
vector<string> *hltTableStrings = new vector<string>(); |
280 |
> |
|
281 |
> |
TString fElectronName(Names::gkElectronBrn); |
282 |
> |
TString fMuonName(Names::gkMuonBrn); |
283 |
> |
TString fInfoName(Names::gkEvtHeaderBrn); |
284 |
> |
TString fPrimVtxName(Names::gkPVBrn); |
285 |
> |
TString fPFCandidateName(Names::gkPFCandidatesBrn); |
286 |
> |
TString fPileupInfoName(Names::gkPileupInfoBrn); |
287 |
> |
TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn); |
288 |
> |
TString fTrackName(Names::gkTrackBrn); |
289 |
> |
TString fMCParticleName(Names::gkMCPartBrn); |
290 |
> |
TString fTriggerMaskName(Names::gkHltBitBrn); |
291 |
> |
TString fTriggerTableName(Names::gkHltTableBrn); |
292 |
|
|
293 |
+ |
chain->SetBranchAddress(fInfoName, &info); |
294 |
+ |
chain->SetBranchAddress(fElectronName, &electronArr); |
295 |
+ |
chain->SetBranchAddress(fMuonName, &muonArr); |
296 |
+ |
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
297 |
+ |
chain->SetBranchAddress(fPFCandidateName, &pfArr); |
298 |
+ |
if( ctrl.mc ) { |
299 |
+ |
chain->SetBranchAddress(fPileupInfoName, &puArr); |
300 |
+ |
chain->SetBranchAddress(fMCParticleName, &mcArr); |
301 |
+ |
} |
302 |
+ |
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
303 |
+ |
chain->SetBranchAddress(fTrackName, &trkArr); |
304 |
+ |
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
305 |
+ |
cout << "hlttable: " << fTriggerTableName << endl; |
306 |
+ |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
307 |
+ |
|
308 |
+ |
mithep::Vertex vtx; // best primary vertex in the event |
309 |
+ |
|
310 |
+ |
// ginfo = NULL; |
311 |
+ |
// if( ctrl.mc ) { chain->SetBranchAddress("Gen", &ginfo);} |
312 |
+ |
|
313 |
+ |
int count=0, pass=0; |
314 |
+ |
float passcorr=0., passcorr_errup=0., passcorr_errdown=0.; |
315 |
+ |
float denom[3]={0.,0.,0.}; |
316 |
+ |
float numer[3]={0.,0.,0.}; |
317 |
+ |
float numercorr[3]={0.,0.,0.}; |
318 |
+ |
|
319 |
+ |
// only 1 HLT table / file ??? |
320 |
+ |
hltchain->GetEntry(0); |
321 |
+ |
cerr << "here... " << endl; |
322 |
+ |
|
323 |
+ |
int imax = chain->GetEntries(); |
324 |
+ |
cout << "nEntries: " << imax << endl; |
325 |
+ |
|
326 |
|
|
327 |
< |
TBranch *infoBr; |
328 |
< |
TBranch *electronBr; |
329 |
< |
TBranch *muonBr; |
327 |
> |
// |
328 |
> |
// Loop !!!!!!!!! |
329 |
> |
//-------------------------------------------------------------------------------------------------------------- |
330 |
> |
for(UInt_t ientry=0; ientry<imax; ientry++) |
331 |
> |
{ |
332 |
> |
chain->GetEntry(ientry); |
333 |
> |
|
334 |
> |
/* |
335 |
> |
bool found_tau=false; |
336 |
> |
if( ctrl.mc) { // && ctrl.debug |
337 |
> |
cout << "nparticles: " << mcArr->GetEntries() << endl; |
338 |
> |
cout << "-----------------------------------" << endl; |
339 |
> |
for( int i=0; i<mcArr->GetEntries(); i++ ) { |
340 |
> |
const mithep::MCParticle *mc = mcArr->At(i); |
341 |
> |
cout << "i: " << i << "\t" |
342 |
> |
<< "id: " << mc->AbsPdgId() |
343 |
> |
<< endl; |
344 |
> |
if( mc->Is(MCParticle::kTau) ) { |
345 |
> |
found_tau=true; |
346 |
> |
} |
347 |
> |
} |
348 |
> |
} |
349 |
> |
cout << "-----------------------------------" << endl; |
350 |
> |
cout << "found tau: " << found_tau << endl; |
351 |
> |
*/ |
352 |
> |
|
353 |
> |
// events that fail bc ele overlaps w/ reco mu |
354 |
> |
/* |
355 |
> |
if( info->EvtNum() != 67315 && |
356 |
> |
info->EvtNum() != 288693 ) continue; |
357 |
> |
*/ |
358 |
> |
|
359 |
> |
// events where they apparently don't veto electrons ... |
360 |
> |
/* |
361 |
> |
if( info->EvtNum() != 141713 && |
362 |
> |
info->EvtNum() != 178019 && |
363 |
> |
info->EvtNum() != 60823 && |
364 |
> |
info->EvtNum() != 192795 ) continue; |
365 |
> |
*/ |
366 |
> |
|
367 |
> |
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
368 |
> |
setPV( ctrl, vtxArr, vtx); |
369 |
> |
//if (!(setPV( ctrl, vtxArr, vtx)) ) continue; |
370 |
> |
|
371 |
> |
float rho = evtrhoMap[info->EvtNum()]; |
372 |
> |
|
373 |
> |
// |
374 |
> |
// pfNoPU |
375 |
> |
// |
376 |
> |
//mithep::Array<PFCandidate> pfNoPileUp; |
377 |
> |
PFnoPUflag.clear(); |
378 |
> |
int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr ); |
379 |
> |
assert(pfnopu_size == pfArr->GetEntries()); |
380 |
> |
|
381 |
> |
// |
382 |
> |
// data/MC |
383 |
> |
// |
384 |
> |
if(ctrl.mc) { |
385 |
> |
// |
386 |
> |
// xsec & PU weights |
387 |
> |
// |
388 |
> |
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
389 |
> |
cout << "xsec weight: " << weights.w << endl; |
390 |
> |
int npu = -1; |
391 |
> |
for(int i=0;i<puArr->GetEntries();i++) { |
392 |
> |
if(puArr->At(i)->GetBunchCrossing() == 0) |
393 |
> |
npu = puArr->At(i)->GetPU_NumInteractions(); |
394 |
> |
} |
395 |
> |
assert(npu>=0); |
396 |
> |
evtinfo.npu; |
397 |
> |
weights.npuw = getPUWeight(evtinfo.npu); |
398 |
> |
// cout << "weight: " << weights.w << endl; |
399 |
> |
// |
400 |
> |
// trigger |
401 |
> |
// |
402 |
> |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
403 |
> |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
404 |
> |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
405 |
> |
hltchain->GetEntry(0); |
406 |
> |
hltTable->Clear(); |
407 |
> |
fillTriggerBits(hltTable, hltTableStrings ); |
408 |
> |
} |
409 |
> |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
410 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
411 |
> |
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
412 |
> |
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
413 |
> |
passes_HLT_MC = false; |
414 |
> |
} |
415 |
> |
} else { |
416 |
> |
// |
417 |
> |
// JSON |
418 |
> |
// |
419 |
> |
/* |
420 |
> |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
421 |
> |
if( !(rlrm.HasRunLumi(rl)) ) { |
422 |
> |
if( ctrl.debug ) cout << "\tfails JSON" << endl; |
423 |
> |
continue; |
424 |
> |
} |
425 |
> |
*/ |
426 |
> |
// |
427 |
> |
// trigger |
428 |
> |
// |
429 |
> |
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
430 |
> |
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
431 |
> |
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
432 |
> |
hltchain->GetEntry(0); |
433 |
> |
hltTable->Clear(); |
434 |
> |
fillTriggerBits(hltTable, hltTableStrings ); |
435 |
> |
} |
436 |
> |
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
437 |
> |
/* |
438 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
439 |
> |
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
440 |
> |
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
441 |
> |
continue; |
442 |
> |
} |
443 |
> |
*/ |
444 |
> |
} |
445 |
> |
|
446 |
> |
// |
447 |
> |
// lepton/kinematic selection ... |
448 |
> |
// |
449 |
> |
failingLeptons.clear(); |
450 |
> |
passingLeptons.clear(); |
451 |
> |
EventData ret4l = |
452 |
> |
|
453 |
> |
|
454 |
> |
// reference |
455 |
> |
/* |
456 |
> |
apply_HZZ4L_reference2_selection(ctrl, info, |
457 |
> |
vtx, |
458 |
> |
pfArr, |
459 |
> |
//rho, |
460 |
> |
puDArr, |
461 |
> |
electronArr, |
462 |
> |
&electronReferencePreSelection, |
463 |
> |
&electronReferenceIDMVASelection, |
464 |
> |
&electronReferenceIsoSelection, |
465 |
> |
muonArr, |
466 |
> |
&muonReferencePreSelection, |
467 |
> |
&muonIDPFSelection, |
468 |
> |
&muonReferenceIsoSelection); |
469 |
> |
*/ |
470 |
> |
|
471 |
> |
// evolved |
472 |
> |
apply_HZZ4L_reference2_selection(ctrl, info, |
473 |
> |
vtx, |
474 |
> |
pfArr, |
475 |
> |
//rho, |
476 |
> |
puDArr, |
477 |
> |
electronArr, |
478 |
> |
&electronReferencePreSelection, |
479 |
> |
//&electronPreSelection, |
480 |
> |
&electronReferenceIDMVASelection, |
481 |
> |
&electronIsoMVASelection, |
482 |
> |
muonArr, |
483 |
> |
&muonReferencePreSelection, |
484 |
> |
//&muonPreSelection, |
485 |
> |
&muonIDPFSelection, |
486 |
> |
&muonIsoMVASelection); |
487 |
> |
|
488 |
> |
|
489 |
> |
if( ctrl.debug ) cout << endl; |
490 |
> |
|
491 |
> |
|
492 |
> |
int Z1type=0, Z2type=0; |
493 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZCANDIDATE ) { |
494 |
> |
if( abs(ret4l.Z1leptons[0].type) == 11 ) Z1type = 11; |
495 |
> |
if( abs(ret4l.Z1leptons[0].type) == 13 ) Z1type = 13; |
496 |
> |
} |
497 |
> |
if( ret4l.status.selectionBits.to_ulong() >= PASS_ZZCANDIDATE ) { |
498 |
> |
if( abs(ret4l.Z2leptons[0].type) == 11 ) Z2type = 11; |
499 |
> |
if( abs(ret4l.Z2leptons[0].type) == 13 ) Z2type = 13; |
500 |
> |
} |
501 |
> |
|
502 |
> |
#ifdef SYNC |
503 |
> |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
504 |
> |
<< "Z1: " << Z1type << "\t" |
505 |
> |
<< "Z2: " << Z2type << endl; |
506 |
> |
cout << endl; |
507 |
> |
#endif |
508 |
> |
|
509 |
> |
if( ret4l.status.pass() ) { |
510 |
> |
fillAngles(ret4l,angles); |
511 |
> |
fillKinematics(ret4l,kinematics); |
512 |
> |
fillEventInfo(info,evtinfo); |
513 |
> |
if( ctrl.mc) { |
514 |
> |
// fillGenInfo(ginfo,geninfo); |
515 |
> |
setEffiencyWeights(ret4l, weights); |
516 |
> |
if(ctrl.debug) |
517 |
> |
cout << "w: " << weights.w << "\t" |
518 |
> |
<< "won: " << weights.won << "\t" |
519 |
> |
<< "woff: " << weights.woff << endl; |
520 |
> |
} |
521 |
> |
|
522 |
> |
/* |
523 |
> |
// only for Higgs < 140 |
524 |
> |
geninfo.weight *= h_w_hpt->GetBinContent(h_w_hpt->FindBin(geninfo.pt_zz)); |
525 |
> |
angles.bdt = reader->EvaluateMVA("BDTG"); |
526 |
> |
*/ |
527 |
> |
nt.Fill(); |
528 |
> |
|
529 |
> |
cerr << "PASS:: " |
530 |
> |
<< "\trun: " << evtinfo.run |
531 |
> |
<< "\tevt: " << evtinfo.evt |
532 |
> |
<< "\tlumi: " << evtinfo.lumi |
533 |
> |
<< "\tcostheta1: " << angles.costheta1 |
534 |
> |
<< "\tcostheta2: " << angles.costheta2 |
535 |
> |
<< "\tcostheta*: " << angles.costhetastar |
536 |
> |
<< "\tbdt: " << angles.bdt |
537 |
> |
<< endl; |
538 |
> |
pass++; |
539 |
> |
// if( pass > 3 ) break; |
540 |
> |
|
541 |
> |
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) ) { // save for fakes ... |
542 |
> |
// if(ctrl.debug) { |
543 |
> |
cout << "failingLeptons : " << failingLeptons.size() << endl; |
544 |
> |
for( int f=0; f<failingLeptons.size(); f++ ) { |
545 |
> |
SimpleLepton l = failingLeptons[f]; |
546 |
> |
cout << "f: " << f << "\t" |
547 |
> |
<< "type: " << l.type << "\t" |
548 |
> |
<< "pT: " << l.vec.Pt() << "\t" |
549 |
> |
<< "eta: " << l.vec.Eta() |
550 |
> |
<< endl; |
551 |
> |
// } |
552 |
> |
} |
553 |
> |
foTree.Fill(); |
554 |
> |
} |
555 |
> |
} |
556 |
|
|
557 |
< |
// chain->SetBranchStatus("*",0); //disable all branches |
558 |
< |
// chain->SetBranchStatus("Info", 1); |
559 |
< |
// chain->SetBranchStatus("Muon", 1); |
560 |
< |
// chain->SetBranchStatus("Electron", 1); |
557 |
> |
|
558 |
> |
foTree.getFile()->cd(); |
559 |
> |
foTree.getTree()->Write(); |
560 |
> |
nt.WriteClose(); |
561 |
> |
|
562 |
> |
cout << endl; |
563 |
> |
cout << endl; |
564 |
> |
for( int i=0; i<cutvec.size(); i++ ) { |
565 |
> |
cout << "cut: " << i << "\t" |
566 |
> |
<< "pass: " << cutvec[i]; |
567 |
> |
|
568 |
> |
if( i>PASS_TRIGGER&&i<=PASS_GOODZ1 ) |
569 |
> |
cout << "\t2e: " << zcutvec[0][i] |
570 |
> |
<< "\t2m: " << zcutvec[1][i]; |
571 |
> |
|
572 |
> |
if( i>PASS_ZCANDIDATE ) |
573 |
> |
cout << "\t4e: " << zzcutvec[0][i] |
574 |
> |
<< "\t4m: " << zzcutvec[1][i] |
575 |
> |
<< "\t2e2m: " << zzcutvec[2][i]; |
576 |
|
|
577 |
< |
chain->SetBranchAddress("Info", &info); |
120 |
< |
chain->SetBranchAddress("Electron", &electronArr); |
121 |
< |
chain->SetBranchAddress("Muon", &muonArr); |
577 |
> |
cout << "\t" << cutstrs[i] << endl; |
578 |
|
|
579 |
+ |
cout << endl; |
580 |
+ |
} |
581 |
|
|
582 |
+ |
} |
583 |
|
|
584 |
< |
cout << "nEntries: " << chain->GetEntries() << endl; |
585 |
< |
for(UInt_t ientry=0; ientry<chain->GetEntries(); ientry++) { |
584 |
> |
//---------------------------------------------------------------------------- |
585 |
> |
// |
586 |
> |
// Get primary vertices |
587 |
> |
// Assumes primary vertices are ordered by sum-pT^2 (as should be in CMSSW) |
588 |
> |
// NOTE: if no PV is found from fitting tracks, the beamspot is used |
589 |
> |
// |
590 |
> |
//---------------------------------------------------------------------------- |
591 |
> |
bool setPV(ControlFlags ctrl, |
592 |
> |
const mithep::Array<mithep::Vertex> * vtxArr, |
593 |
> |
mithep::Vertex & vtx) |
594 |
> |
//---------------------------------------------------------------------------- |
595 |
> |
{ |
596 |
> |
const Vertex *bestPV = 0; |
597 |
> |
float best_sumpt=-1; |
598 |
> |
|
599 |
> |
// good PV requirements |
600 |
> |
const UInt_t fMinNTracksFit = 0; |
601 |
> |
const Double_t fMinNdof = 4; |
602 |
> |
const Double_t fMaxAbsZ = 24; |
603 |
> |
const Double_t fMaxRho = 2; |
604 |
> |
|
605 |
> |
for(int i=0; i<vtxArr->GetEntries(); ++i) { |
606 |
> |
const Vertex *pv = (Vertex*)(vtxArr->At(i)); |
607 |
> |
if( ctrl.debug ) cout << "vertex :: " << i << "\tntrks: " << pv->NTracks() << endl; |
608 |
> |
|
609 |
> |
// Select best PV for corrected d0; if no PV passing cuts, the first PV in the collection will be used |
610 |
> |
if(!pv->IsValid()) continue; |
611 |
> |
if(pv->NTracksFit() < fMinNTracksFit) continue; |
612 |
> |
if(pv->Ndof() < fMinNdof) continue; |
613 |
> |
if(fabs(pv->Z()) > fMaxAbsZ) continue; |
614 |
> |
if(pv->Position().Rho() > fMaxRho) continue; |
615 |
> |
|
616 |
> |
// take the first ... |
617 |
> |
bestPV = pv; |
618 |
> |
break; |
619 |
> |
|
620 |
> |
// this never reached ... |
621 |
> |
float tmp_sumpt=0; |
622 |
> |
for( int t=0; t<pv->NTracks(); t++ ) |
623 |
> |
tmp_sumpt += pv->Trk(t)->Pt(); |
624 |
|
|
625 |
< |
chain->GetEntry(ientry); |
625 |
> |
if( tmp_sumpt > best_sumpt ) { |
626 |
> |
bestPV = pv; |
627 |
> |
best_sumpt = tmp_sumpt; |
628 |
> |
if( ctrl.debug) cout << "new PV set, pt : " << best_sumpt << endl; |
629 |
> |
} |
630 |
> |
} |
631 |
> |
// sync |
632 |
> |
if(!bestPV) bestPV = vtxArr->At(0); |
633 |
> |
//if(!bestPV) return false; |
634 |
> |
vtx.SetPosition(bestPV->X(),bestPV->Y(),bestPV->Z()); |
635 |
> |
vtx.SetErrors(bestPV->XErr(),bestPV->YErr(),bestPV->ZErr()); |
636 |
> |
return true; |
637 |
> |
}; |
638 |
|
|
130 |
– |
#ifdef THEIR_EVENTS |
131 |
– |
if( !( info->evtNum == 504867308 || |
132 |
– |
info->evtNum == 368148849 || |
133 |
– |
info->evtNum == 129514273 || |
134 |
– |
info->evtNum == 286336207 || |
135 |
– |
info->evtNum == 344708580 || |
136 |
– |
info->evtNum == 30998576 || |
137 |
– |
info->evtNum == 155679852 || |
138 |
– |
info->evtNum == 394010457 || |
139 |
– |
info->evtNum == 917379387 || |
140 |
– |
info->evtNum == 78213037 || |
141 |
– |
info->evtNum == 337493970 || |
142 |
– |
info->evtNum == 1491724484 || |
143 |
– |
info->evtNum == 480301165 || |
144 |
– |
info->evtNum == 1038911933 || |
145 |
– |
info->evtNum == 876658967 || |
146 |
– |
info->evtNum == 966824024 || |
147 |
– |
info->evtNum == 141954801 || |
148 |
– |
info->evtNum == 160966858 || |
149 |
– |
info->evtNum == 191231387 || |
150 |
– |
info->evtNum == 66033190 || |
151 |
– |
info->evtNum == 10347106 || |
152 |
– |
info->evtNum == 107360878 ) ) continue; |
153 |
– |
#endif |
639 |
|
|
155 |
– |
unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, passtuple ); |
156 |
– |
double eventweight = info->eventweight; |
157 |
– |
h_evtfail->Fill( evtfail, eventweight ); |
158 |
– |
cout << endl << endl; |
159 |
– |
|
160 |
– |
} //end loop over data |
640 |
|
|
641 |
+ |
//---------------------------------------------------------------------------- |
642 |
+ |
void setEffiencyWeights(EventData & evtdat, WeightStruct & weights ) |
643 |
+ |
//---------------------------------------------------------------------------- |
644 |
+ |
{ |
645 |
+ |
vector<SimpleLepton> lepvec = evtdat.Z1leptons; |
646 |
+ |
lepvec.insert(lepvec.end(), evtdat.Z2leptons.begin(), evtdat.Z2leptons.end()); |
647 |
+ |
double w_offline=-1, werr_offline=0; |
648 |
+ |
double w_online=-1, werr_online=0; |
649 |
+ |
|
650 |
+ |
vector< pair <double,double> > wlegs; // pair here is eff & err |
651 |
+ |
vector< pair <float,float> > mvec; // pair here is eta & pt |
652 |
|
|
653 |
+ |
// vector< pair <float,float> > evec; // pair here is eta & pt |
654 |
+ |
// now deal with medium vs loose |
655 |
+ |
vector< pair< bool, pair <float,float> > > evec; // pair here is eta & pt |
656 |
+ |
|
657 |
+ |
for( int k=0; k<lepvec.size(); k++ ) { |
658 |
+ |
if( abs(lepvec[k].type) == 13 ) { |
659 |
+ |
mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
660 |
+ |
wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
661 |
+ |
lepvec[k].vec.Pt() ) ); |
662 |
+ |
} else { |
663 |
+ |
|
664 |
+ |
// now deal with medium vs loose |
665 |
+ |
// evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
666 |
+ |
|
667 |
+ |
std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()); |
668 |
+ |
evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) ); |
669 |
+ |
|
670 |
+ |
// wlegs.push_back( elePerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
671 |
+ |
// lepvec[k].vec.Pt() ) ); |
672 |
+ |
|
673 |
+ |
wlegs.push_back( elePerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
674 |
+ |
lepvec[k].vec.Pt(), |
675 |
+ |
lepvec[k].isTight ) ); |
676 |
+ |
|
677 |
+ |
} |
678 |
+ |
} |
679 |
+ |
|
680 |
+ |
pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs ); |
681 |
+ |
weights.woff = offpair.first; |
682 |
+ |
weights.werroff = offpair.second; |
683 |
+ |
|
684 |
+ |
pair<double,double> onpair = getOnlineEfficiencyWeight( mvec, evec ); |
685 |
+ |
weights.won = onpair.first; |
686 |
+ |
weights.werron = onpair.second; |
687 |
+ |
} |
688 |
|
|
164 |
– |
delete info; |
165 |
– |
delete electronArr; |
166 |
– |
delete muonArr; |
689 |
|
|
690 |
+ |
//---------------------------------------------------------------------------- |
691 |
+ |
void initRunLumiRangeMap() |
692 |
+ |
//---------------------------------------------------------------------------- |
693 |
+ |
{ |
694 |
+ |
/* |
695 |
+ |
rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt")); |
696 |
+ |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt")); |
697 |
+ |
rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt")); |
698 |
+ |
rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt")); |
699 |
+ |
rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt")); |
700 |
+ |
// r11b |
701 |
+ |
rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt")); |
702 |
+ |
*/ |
703 |
+ |
}; |
704 |
|
|
705 |
|
|
706 |
< |
//-------------------------------------------------------------------------------------------------------------- |
707 |
< |
// Save Histograms; |
708 |
< |
//============================================================================================================== |
709 |
< |
const char * ofname; |
710 |
< |
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
711 |
< |
ofname = ctrl.outputfile.c_str(); |
712 |
< |
} else { |
713 |
< |
ofname = "tmp.root"; |
714 |
< |
} |
706 |
> |
//---------------------------------------------------------------------------- |
707 |
> |
void initPUWeights() |
708 |
> |
//---------------------------------------------------------------------------- |
709 |
> |
{ |
710 |
> |
TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root"); |
711 |
> |
hpu = (TH1D*)(puf->Get("puWeights")); |
712 |
> |
} |
713 |
> |
|
714 |
> |
//---------------------------------------------------------------------------- |
715 |
> |
double getPUWeight(unsigned npu) |
716 |
> |
//---------------------------------------------------------------------------- |
717 |
> |
{ |
718 |
> |
return hpu->GetBinContent(hpu->FindBin(npu)); |
719 |
> |
} |
720 |
|
|
721 |
< |
TFile *file = new TFile(ofname, "RECREATE"); |
722 |
< |
h_evt->Write(); |
723 |
< |
h_evtfail->Write(); |
724 |
< |
passtuple->Write(); |
725 |
< |
file->Close(); |
726 |
< |
delete file; |
721 |
> |
//---------------------------------------------------------------------------- |
722 |
> |
void initEvtRhoMap( map<unsigned, float> & evtrhoMap ) |
723 |
> |
//---------------------------------------------------------------------------- |
724 |
> |
{ |
725 |
> |
unsigned evt; |
726 |
> |
float rho; |
727 |
|
|
728 |
< |
cerr << "done!" << endl; |
729 |
< |
} |
728 |
> |
cout << "initialzing EvtRhoMap "; |
729 |
> |
//FILE * f = fopen("evtrho.dat", "r"); |
730 |
> |
// FILE * f = fopen("allrho.cali.uniq.dat", "r"); |
731 |
> |
FILE * f = fopen("allrhoAA.cali.uniq.dat", "r"); |
732 |
> |
int lcount=0; |
733 |
> |
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
734 |
> |
if( feof(f) ) break; |
735 |
> |
evtrhoMap[evt] = rho; |
736 |
> |
lcount++; |
737 |
> |
if( !(lcount%1000) ) cout << "."; flush(cout); |
738 |
> |
} |
739 |
> |
cout << " done" << endl; |
740 |
> |
} |
741 |
|
|
742 |
+ |
//---------------------------------------------------------------------------- |
743 |
+ |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
744 |
+ |
vector<bool> &pfNoPileUpflag, |
745 |
+ |
mithep::Array<Vertex> * vtxArr ) |
746 |
+ |
//---------------------------------------------------------------------------- |
747 |
+ |
{ |
748 |
+ |
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
749 |
+ |
const PFCandidate *pf = fPFCandidates->At(i); |
750 |
+ |
assert(pf); |
751 |
+ |
|
752 |
+ |
if(pf->PFType() == PFCandidate::eHadron) { |
753 |
+ |
if(pf->HasTrackerTrk() && |
754 |
+ |
vtxArr->At(0)->HasTrack(pf->TrackerTrk()) && |
755 |
+ |
vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) { |
756 |
+ |
|
757 |
+ |
pfNoPileUpflag.push_back(1); |
758 |
+ |
|
759 |
+ |
} else { |
760 |
+ |
|
761 |
+ |
Bool_t vertexFound = kFALSE; |
762 |
+ |
const Vertex *closestVtx = 0; |
763 |
+ |
Double_t dzmin = 10000; |
764 |
+ |
|
765 |
+ |
// loop over vertices |
766 |
+ |
for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) { |
767 |
+ |
const Vertex *vtx = vtxArr->At(j); |
768 |
+ |
assert(vtx); |
769 |
+ |
|
770 |
+ |
if(pf->HasTrackerTrk() && |
771 |
+ |
vtx->HasTrack(pf->TrackerTrk()) && |
772 |
+ |
vtx->TrackWeight(pf->TrackerTrk()) > 0) { |
773 |
+ |
vertexFound = kTRUE; |
774 |
+ |
closestVtx = vtx; |
775 |
+ |
break; |
776 |
+ |
} |
777 |
+ |
Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z()); |
778 |
+ |
if(dz < dzmin) { |
779 |
+ |
closestVtx = vtx; |
780 |
+ |
dzmin = dz; |
781 |
+ |
} |
782 |
+ |
} |
783 |
+ |
|
784 |
+ |
// if(fCheckClosestZVertex) { |
785 |
+ |
if(1) { |
786 |
+ |
// Fallback: if track is not associated with any vertex, |
787 |
+ |
// associate it with the vertex closest in z |
788 |
+ |
if(vertexFound || closestVtx != vtxArr->At(0)) { |
789 |
+ |
// pfPileUp->Add(pf); |
790 |
+ |
pfNoPileUpflag.push_back(0); |
791 |
+ |
} else { |
792 |
+ |
pfNoPileUpflag.push_back(1); |
793 |
+ |
} |
794 |
+ |
} else { |
795 |
+ |
if(vertexFound && closestVtx != vtxArr->At(0)) { |
796 |
+ |
// pfPileUp->Add(pf); |
797 |
+ |
pfNoPileUpflag.push_back(0); |
798 |
+ |
} else { |
799 |
+ |
// PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is |
800 |
+ |
pfNoPileUpflag.push_back(1); |
801 |
+ |
} |
802 |
+ |
} |
803 |
+ |
} //hadron & trk stuff |
804 |
+ |
} else { // hadron |
805 |
+ |
// PFCandidate * ptr = pfNoPileUp->AddNew(); |
806 |
+ |
pfNoPileUpflag.push_back(1); |
807 |
+ |
} |
808 |
+ |
} // Loop over PF candidates |
809 |
|
|
810 |
+ |
return pfNoPileUpflag.size(); |
811 |
+ |
} |
812 |
|
|