17 |
|
superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")), |
18 |
|
triggers_ (cfg.getParameter<edm::InputTag> ("triggers")), |
19 |
|
puFile_ (cfg.getParameter<std::string> ("puFile")), |
20 |
+ |
deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")), |
21 |
+ |
muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")), |
22 |
|
dataPU_ (cfg.getParameter<std::string> ("dataPU")), |
23 |
+ |
electronSFID_ (cfg.getParameter<std::string> ("electronSFID")), |
24 |
+ |
muonSF_ (cfg.getParameter<std::string> ("muonSF")), |
25 |
|
dataset_ (cfg.getParameter<std::string> ("dataset")), |
26 |
|
datasetType_ (cfg.getParameter<std::string> ("datasetType")), |
27 |
|
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
28 |
|
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
29 |
< |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")) |
30 |
< |
|
29 |
> |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")), |
30 |
> |
doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")), |
31 |
> |
printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")) |
32 |
|
{ |
33 |
|
|
34 |
|
TH1::SetDefaultSumw2 (); |
35 |
|
|
36 |
|
//create pile-up reweighting object, if necessary |
37 |
< |
if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
37 |
> |
if(datasetType_ != "data") { |
38 |
> |
if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
39 |
> |
// muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_); |
40 |
> |
// electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_); |
41 |
> |
} |
42 |
> |
|
43 |
|
|
44 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
45 |
|
// handle filling cut flow histograms. |
47 |
|
std::vector<TFileDirectory> directories; |
48 |
|
|
49 |
|
//always get vertex collection so we can assign the primary vertex in the event |
50 |
< |
allNecessaryObjects.push_back("primaryvertexs"); |
50 |
> |
objectsToGet.push_back("primaryvertexs"); |
51 |
> |
|
52 |
|
//always make the plot of number of primary verticex (to check pile-up reweighting) |
53 |
|
objectsToPlot.push_back("primaryvertexs"); |
54 |
|
|
55 |
+ |
//always get the MC particles to do GEN-matching |
56 |
+ |
objectsToGet.push_back("mcparticles"); |
57 |
+ |
|
58 |
|
//always get the event collection to do pile-up reweighting |
59 |
< |
allNecessaryObjects.push_back("events"); |
59 |
> |
objectsToGet.push_back("events"); |
60 |
|
|
61 |
|
//parse the histogram definitions |
62 |
|
for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){ |
63 |
|
|
64 |
|
string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection"); |
65 |
|
if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs"; |
66 |
< |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
66 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
67 |
> |
objectsToGet.push_back(tempInputCollection); |
68 |
|
objectsToPlot.push_back(tempInputCollection); |
69 |
< |
allNecessaryObjects.push_back(tempInputCollection); |
69 |
> |
objectsToCut.push_back(tempInputCollection); |
70 |
|
} |
71 |
< |
else{//pair of objects, need to add them both to the things to allNecessaryObjects |
71 |
> |
else{//pair of objects, need to add them both to the things to objectsToGet |
72 |
|
int dashIndex = tempInputCollection.find("-"); |
73 |
|
int spaceIndex = tempInputCollection.find(" "); |
74 |
|
int secondWordLength = spaceIndex - dashIndex; |
75 |
< |
allNecessaryObjects.push_back(tempInputCollection); |
76 |
< |
allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
77 |
< |
allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
75 |
> |
objectsToGet.push_back(tempInputCollection); |
76 |
> |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
77 |
> |
objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
78 |
|
objectsToPlot.push_back(tempInputCollection); |
79 |
|
objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
80 |
|
objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
81 |
+ |
objectsToCut.push_back(tempInputCollection); |
82 |
+ |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
83 |
+ |
objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
84 |
+ |
|
85 |
|
} |
86 |
|
|
87 |
|
vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms")); |
88 |
< |
|
88 |
> |
|
89 |
|
for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){ |
90 |
|
|
91 |
|
histogram tempHistogram; |
94 |
|
tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title"); |
95 |
|
tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins"); |
96 |
|
tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables"); |
97 |
< |
|
97 |
> |
|
98 |
|
histograms.push_back(tempHistogram); |
99 |
|
|
100 |
|
} |
101 |
|
} |
102 |
< |
//make unique vector of objects we need to plot (so we can book a histogram with the number of each object |
102 |
> |
//make unique vector of objects we need to plot (so we can book a histogram with the number of each object) |
103 |
|
sort( objectsToPlot.begin(), objectsToPlot.end() ); |
104 |
|
objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() ); |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
+ |
//add histograms with the gen-matched id, mother id, and grandmother id |
109 |
+ |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
110 |
+ |
|
111 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
112 |
+ |
if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue; |
113 |
+ |
|
114 |
+ |
histogram tempIdHisto; |
115 |
+ |
histogram tempMomIdHisto; |
116 |
+ |
histogram tempGmaIdHisto; |
117 |
+ |
histogram tempIdVsMomIdHisto; |
118 |
+ |
|
119 |
+ |
tempIdHisto.inputCollection = currentObject; |
120 |
+ |
tempMomIdHisto.inputCollection = currentObject; |
121 |
+ |
tempGmaIdHisto.inputCollection = currentObject; |
122 |
+ |
tempIdVsMomIdHisto.inputCollection = currentObject; |
123 |
+ |
|
124 |
+ |
currentObject = currentObject.substr(0, currentObject.size()-1); |
125 |
+ |
tempIdHisto.name = currentObject+"GenMatchId"; |
126 |
+ |
tempMomIdHisto.name = currentObject+"GenMatchMotherId"; |
127 |
+ |
tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId"; |
128 |
+ |
tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId"; |
129 |
+ |
|
130 |
+ |
currentObject.at(0) = toupper(currentObject.at(0)); |
131 |
+ |
tempIdHisto.title = currentObject+" Gen-matched Particle"; |
132 |
+ |
tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother"; |
133 |
+ |
tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother"; |
134 |
+ |
tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother"; |
135 |
+ |
|
136 |
+ |
int maxNum = 24; |
137 |
+ |
vector<double> binVector; |
138 |
+ |
binVector.push_back(maxNum); |
139 |
+ |
binVector.push_back(0); |
140 |
+ |
binVector.push_back(maxNum); |
141 |
+ |
|
142 |
+ |
tempIdHisto.bins = binVector; |
143 |
+ |
tempIdHisto.inputVariables.push_back("genMatchedId"); |
144 |
+ |
tempMomIdHisto.bins = binVector; |
145 |
+ |
tempMomIdHisto.inputVariables.push_back("genMatchedMotherId"); |
146 |
+ |
tempGmaIdHisto.bins = binVector; |
147 |
+ |
tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId"); |
148 |
+ |
binVector.push_back(maxNum); |
149 |
+ |
binVector.push_back(0); |
150 |
+ |
binVector.push_back(maxNum); |
151 |
+ |
tempIdVsMomIdHisto.bins = binVector; |
152 |
+ |
tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId"); |
153 |
+ |
tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse"); |
154 |
+ |
|
155 |
+ |
histograms.push_back(tempIdHisto); |
156 |
+ |
histograms.push_back(tempMomIdHisto); |
157 |
+ |
histograms.push_back(tempGmaIdHisto); |
158 |
+ |
histograms.push_back(tempIdVsMomIdHisto); |
159 |
+ |
} |
160 |
+ |
|
161 |
|
|
162 |
|
channel tempChannel; |
163 |
|
//loop over all channels (event selections) |
176 |
|
triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers"); |
177 |
|
for(uint trigger = 0; trigger!= triggerNames.size(); trigger++) |
178 |
|
tempChannel.triggers.push_back(triggerNames.at(trigger)); |
179 |
< |
allNecessaryObjects.push_back("triggers"); |
179 |
> |
objectsToGet.push_back("triggers"); |
180 |
|
} |
181 |
|
|
182 |
|
|
195 |
|
twoDHists_.push_back(twoDhistoMap); |
196 |
|
|
197 |
|
|
198 |
+ |
|
199 |
|
//book all histograms included in the configuration |
200 |
|
for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
201 |
|
histogram currentHistogram = histograms.at(currentHistogramIndex); |
203 |
|
int numInputVariables = currentHistogram.inputVariables.size(); |
204 |
|
|
205 |
|
if(numBinsElements != 3 && numBinsElements !=6) { |
206 |
< |
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
207 |
< |
exit(0); |
206 |
> |
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
207 |
> |
exit(0); |
208 |
|
} |
209 |
|
else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){ |
210 |
< |
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
211 |
< |
exit(0); |
210 |
> |
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
211 |
> |
exit(0); |
212 |
|
} |
213 |
|
else if(numBinsElements == 3){ |
214 |
< |
oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2)); |
214 |
> |
oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2)); |
215 |
|
} |
216 |
|
else if(numBinsElements == 6){ |
217 |
< |
twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5)); |
217 |
> |
twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5)); |
218 |
|
|
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
+ |
if(currentHistogram.name.find("GenMatch")==std::string::npos) continue; |
223 |
+ |
|
224 |
+ |
// bin particle type |
225 |
+ |
// --- ------------- |
226 |
+ |
// 0 unmatched |
227 |
+ |
// 1 u |
228 |
+ |
// 2 d |
229 |
+ |
// 3 s |
230 |
+ |
// 4 c |
231 |
+ |
// 5 b |
232 |
+ |
// 6 t |
233 |
+ |
// 7 e |
234 |
+ |
// 8 mu |
235 |
+ |
// 9 tau |
236 |
+ |
// 10 nu |
237 |
+ |
// 11 g |
238 |
+ |
// 12 gamma |
239 |
+ |
// 13 Z |
240 |
+ |
// 14 W |
241 |
+ |
// 15 light meson |
242 |
+ |
// 16 K meson |
243 |
+ |
// 17 D meson |
244 |
+ |
// 18 B meson |
245 |
+ |
// 19 light baryon |
246 |
+ |
// 20 strange baryon |
247 |
+ |
// 21 charm baryon |
248 |
+ |
// 22 bottom baryon |
249 |
+ |
// 23 other |
250 |
+ |
|
251 |
+ |
vector<TString> labelArray; |
252 |
+ |
labelArray.push_back("unmatched"); |
253 |
+ |
labelArray.push_back("u"); |
254 |
+ |
labelArray.push_back("d"); |
255 |
+ |
labelArray.push_back("s"); |
256 |
+ |
labelArray.push_back("c"); |
257 |
+ |
labelArray.push_back("b"); |
258 |
+ |
labelArray.push_back("t"); |
259 |
+ |
labelArray.push_back("e"); |
260 |
+ |
labelArray.push_back("#mu"); |
261 |
+ |
labelArray.push_back("#tau"); |
262 |
+ |
labelArray.push_back("#nu"); |
263 |
+ |
labelArray.push_back("g"); |
264 |
+ |
labelArray.push_back("#gamma"); |
265 |
+ |
labelArray.push_back("Z"); |
266 |
+ |
labelArray.push_back("W"); |
267 |
+ |
labelArray.push_back("light meson"); |
268 |
+ |
labelArray.push_back("K meson"); |
269 |
+ |
labelArray.push_back("D meson"); |
270 |
+ |
labelArray.push_back("B meson"); |
271 |
+ |
labelArray.push_back("light baryon"); |
272 |
+ |
labelArray.push_back("strange baryon"); |
273 |
+ |
labelArray.push_back("charm baryon"); |
274 |
+ |
labelArray.push_back("bottom baryon"); |
275 |
+ |
labelArray.push_back("other"); |
276 |
+ |
|
277 |
+ |
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
278 |
+ |
if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) { |
279 |
+ |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
280 |
+ |
} |
281 |
+ |
else { |
282 |
+ |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1)); |
283 |
+ |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
284 |
+ |
} |
285 |
+ |
} |
286 |
+ |
if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) { |
287 |
+ |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle(); |
288 |
+ |
twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle(); |
289 |
+ |
} |
290 |
+ |
|
291 |
|
} |
292 |
+ |
|
293 |
|
//book a histogram for the number of each object type to be plotted |
294 |
+ |
|
295 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
296 |
|
string currentObject = objectsToPlot.at(currentObjectIndex); |
297 |
|
int maxNum = 10; |
305 |
|
string histoName = "num" + currentObject; |
306 |
|
|
307 |
|
if(histoName == "numPrimaryvertexs"){ |
308 |
< |
string newHistoName = histoName + "BeforePileupCorrection"; |
309 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
310 |
< |
newHistoName = histoName + "AfterPileupCorrection"; |
311 |
< |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
308 |
> |
string newHistoName = histoName + "BeforePileupCorrection"; |
309 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
310 |
> |
newHistoName = histoName + "AfterPileupCorrection"; |
311 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
312 |
|
} |
313 |
|
else |
314 |
< |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
314 |
> |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
315 |
|
} |
316 |
|
|
317 |
|
|
318 |
+ |
|
319 |
+ |
|
320 |
|
//get list of cuts for this channel |
321 |
|
vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts")); |
322 |
|
|
326 |
|
//store input collection for cut |
327 |
|
string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
328 |
|
tempCut.inputCollection = tempInputCollection; |
329 |
< |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
330 |
< |
allNecessaryObjects.push_back(tempInputCollection); |
331 |
< |
} |
332 |
< |
else{//pair of objects, need to add them both to the things to allNecessaryObjects |
333 |
< |
int dashIndex = tempInputCollection.find("-"); |
334 |
< |
int spaceIndex = tempInputCollection.find(" "); |
335 |
< |
int secondWordLength = spaceIndex - dashIndex; |
336 |
< |
allNecessaryObjects.push_back(tempInputCollection); |
337 |
< |
allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
338 |
< |
allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
329 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
330 |
> |
objectsToGet.push_back(tempInputCollection); |
331 |
> |
objectsToCut.push_back(tempInputCollection); |
332 |
> |
} |
333 |
> |
else{//pair of objects, need to add them both to the things to objectsToGet |
334 |
> |
int dashIndex = tempInputCollection.find("-"); |
335 |
> |
int spaceIndex = tempInputCollection.find(" "); |
336 |
> |
int secondWordLength = spaceIndex - dashIndex; |
337 |
> |
objectsToGet.push_back(tempInputCollection); |
338 |
> |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
339 |
> |
objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
340 |
> |
objectsToCut.push_back(tempInputCollection); |
341 |
> |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
342 |
> |
objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
343 |
|
|
344 |
|
} |
345 |
|
|
349 |
|
string cutString = cuts_.at(currentCut).getParameter<string> ("cutString"); |
350 |
|
std::vector<string> cutStringVector = splitString(cutString); |
351 |
|
if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){ |
352 |
< |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
353 |
< |
exit(0); |
352 |
> |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
353 |
> |
exit(0); |
354 |
|
} |
355 |
|
tempCut.numSubcuts = (cutStringVector.size()+1)/4; |
356 |
|
for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,| |
357 |
< |
int indexOffset = 4 * subcutIndex; |
358 |
< |
string currentVariableString = cutStringVector.at(indexOffset); |
359 |
< |
if(currentVariableString.find("(")==std::string::npos){ |
360 |
< |
tempCut.functions.push_back("");//no function was specified |
361 |
< |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
362 |
< |
} |
363 |
< |
else{ |
364 |
< |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
365 |
< |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
366 |
< |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
367 |
< |
} |
368 |
< |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
369 |
< |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
370 |
< |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
357 |
> |
int indexOffset = 4 * subcutIndex; |
358 |
> |
string currentVariableString = cutStringVector.at(indexOffset); |
359 |
> |
if(currentVariableString.find("(")==std::string::npos){ |
360 |
> |
tempCut.functions.push_back("");//no function was specified |
361 |
> |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
362 |
> |
} |
363 |
> |
else{ |
364 |
> |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
365 |
> |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
366 |
> |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
367 |
> |
} |
368 |
> |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
369 |
> |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
370 |
> |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
371 |
|
} |
372 |
|
|
373 |
|
//get number of objects required to pass cut for event to pass |
374 |
|
string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired"); |
375 |
|
std::vector<string> numberRequiredVector = splitString(numberRequiredString); |
376 |
|
if(numberRequiredVector.size()!=2){ |
377 |
< |
std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n"; |
377 |
> |
std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n"; |
378 |
|
exit(0); |
379 |
|
} |
380 |
|
|
409 |
|
}//end loop over channels |
410 |
|
|
411 |
|
|
412 |
< |
//make unique vector of objects we need to cut on (so we make sure to get them from the event) |
413 |
< |
sort( allNecessaryObjects.begin(), allNecessaryObjects.end() ); |
414 |
< |
allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() ); |
412 |
> |
//make unique vector of objects we need to get from the event |
413 |
> |
sort( objectsToGet.begin(), objectsToGet.end() ); |
414 |
> |
objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() ); |
415 |
> |
//make unique vector of objects we need to cut on |
416 |
> |
sort( objectsToCut.begin(), objectsToCut.end() ); |
417 |
> |
objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() ); |
418 |
|
|
419 |
|
|
420 |
|
} |
432 |
|
OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup) |
433 |
|
{ |
434 |
|
|
282 |
– |
|
435 |
|
// Retrieve necessary collections from the event. |
436 |
< |
edm::Handle<BNtriggerCollection> triggers; |
437 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end()) |
436 |
> |
|
437 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end()) |
438 |
|
event.getByLabel (triggers_, triggers); |
439 |
|
|
440 |
< |
edm::Handle<BNjetCollection> jets; |
289 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end()) |
440 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end()) |
441 |
|
event.getByLabel (jets_, jets); |
442 |
|
|
443 |
< |
edm::Handle<BNmuonCollection> muons; |
293 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end()) |
443 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end()) |
444 |
|
event.getByLabel (muons_, muons); |
445 |
|
|
446 |
< |
edm::Handle<BNelectronCollection> electrons; |
297 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end()) |
446 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end()) |
447 |
|
event.getByLabel (electrons_, electrons); |
448 |
|
|
449 |
< |
edm::Handle<BNeventCollection> events; |
301 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end()) |
449 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end()) |
450 |
|
event.getByLabel (events_, events); |
451 |
|
|
452 |
< |
edm::Handle<BNtauCollection> taus; |
305 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end()) |
452 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end()) |
453 |
|
event.getByLabel (taus_, taus); |
454 |
|
|
455 |
< |
edm::Handle<BNmetCollection> mets; |
309 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end()) |
455 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end()) |
456 |
|
event.getByLabel (mets_, mets); |
457 |
|
|
458 |
< |
edm::Handle<BNtrackCollection> tracks; |
313 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end()) |
458 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end()) |
459 |
|
event.getByLabel (tracks_, tracks); |
460 |
|
|
461 |
< |
edm::Handle<BNgenjetCollection> genjets; |
317 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end()) |
461 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end()) |
462 |
|
event.getByLabel (genjets_, genjets); |
463 |
|
|
464 |
< |
edm::Handle<BNmcparticleCollection> mcparticles; |
321 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end()) |
464 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end()) |
465 |
|
event.getByLabel (mcparticles_, mcparticles); |
466 |
|
|
467 |
< |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
325 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end()) |
467 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end()) |
468 |
|
event.getByLabel (primaryvertexs_, primaryvertexs); |
469 |
|
|
470 |
< |
edm::Handle<BNbxlumiCollection> bxlumis; |
329 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end()) |
470 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end()) |
471 |
|
event.getByLabel (bxlumis_, bxlumis); |
472 |
|
|
473 |
< |
edm::Handle<BNphotonCollection> photons; |
333 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end()) |
473 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end()) |
474 |
|
event.getByLabel (photons_, photons); |
475 |
|
|
476 |
< |
edm::Handle<BNsuperclusterCollection> superclusters; |
337 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end()) |
476 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end()) |
477 |
|
event.getByLabel (superclusters_, superclusters); |
478 |
|
|
340 |
– |
|
479 |
|
//get pile-up event weight |
480 |
< |
double puScaleFactor = 0; |
481 |
< |
if(datasetType_ != "data") |
482 |
< |
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
345 |
< |
else |
346 |
< |
puScaleFactor = 1.00; |
480 |
> |
double scaleFactor = 1.00; |
481 |
> |
if(doPileupReweighting_ && datasetType_ != "data") |
482 |
> |
scaleFactor = puWeight_->at (events->at (0).numTruePV); |
483 |
|
|
484 |
|
|
485 |
|
//loop over all channels |
488 |
|
channel currentChannel = channels.at(currentChannelIndex); |
489 |
|
|
490 |
|
flagMap individualFlags; |
355 |
– |
flagMap cumulativeFlags; |
491 |
|
counterMap passingCounter; |
492 |
+ |
cumulativeFlags.clear (); |
493 |
|
|
494 |
|
bool triggerDecision = true; |
495 |
|
if(currentChannel.triggers.size() != 0){ //triggers specified |
498 |
|
} |
499 |
|
|
500 |
|
//loop over all cuts |
501 |
+ |
|
502 |
+ |
|
503 |
+ |
|
504 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
505 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
506 |
|
|
507 |
< |
for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){ |
508 |
< |
string currentObject = allNecessaryObjects.at(currentObjectIndex); |
507 |
> |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
508 |
> |
string currentObject = objectsToCut.at(currentObjectIndex); |
509 |
|
|
510 |
+ |
//initialize maps to get ready to set cuts |
511 |
|
individualFlags[currentObject].push_back (vector<bool> ()); |
512 |
|
cumulativeFlags[currentObject].push_back (vector<bool> ()); |
513 |
|
|
514 |
+ |
} |
515 |
+ |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
516 |
+ |
string currentObject = objectsToCut.at(currentObjectIndex); |
517 |
+ |
|
518 |
+ |
int flagsForPairCutsIndex = max(int(currentCutIndex-1),0); |
519 |
+ |
|
520 |
|
|
521 |
|
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
522 |
|
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
532 |
|
else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons"); |
533 |
|
else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters"); |
534 |
|
|
535 |
< |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs"); |
536 |
< |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs"); |
537 |
< |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs"); |
535 |
> |
|
536 |
> |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \ |
537 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
538 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
539 |
> |
"muon-muon pairs"); |
540 |
> |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
541 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
542 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
543 |
> |
"electron-electron pairs"); |
544 |
> |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \ |
545 |
> |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
546 |
> |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
547 |
> |
"electron-muon pairs"); |
548 |
> |
|
549 |
|
|
550 |
|
} |
551 |
|
|
554 |
|
}//end loop over all cuts |
555 |
|
|
556 |
|
|
400 |
– |
|
557 |
|
//use cumulative flags to apply cuts at event level |
558 |
|
|
559 |
|
bool eventPassedAllCuts = true; |
562 |
|
eventPassedAllCuts = eventPassedAllCuts && triggerDecision; |
563 |
|
|
564 |
|
|
565 |
+ |
|
566 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
567 |
|
|
568 |
|
//loop over all objects and count how many passed the cumulative selection up to this point |
580 |
|
|
581 |
|
} |
582 |
|
|
583 |
< |
cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor); |
583 |
> |
cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor); |
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
if(!eventPassedAllCuts)continue; |
588 |
|
|
589 |
< |
|
590 |
< |
|
591 |
< |
|
592 |
< |
//set position of primary vertex in event, in order to calculate quantities relative to it |
593 |
< |
primaryVertex_ = 0; |
594 |
< |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back(); |
595 |
< |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
439 |
< |
if(!vertexFlags.at(vertexIndex)) continue; |
440 |
< |
primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex)); |
441 |
< |
break; |
589 |
> |
if (printEventInfo_) { |
590 |
> |
// Write information about event to screen, for testing purposes. |
591 |
> |
cout << "Event passed all cuts in channel " << currentChannel.name |
592 |
> |
<< ": run=" << events->at(0).run |
593 |
> |
<< " lumi=" << events->at(0).lumi |
594 |
> |
<< " event=" << events->at(0).evt |
595 |
> |
<< endl; |
596 |
|
} |
597 |
|
|
598 |
|
|
599 |
+ |
// if(datasetType_ != "data") { |
600 |
+ |
// scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta); |
601 |
+ |
// scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
602 |
+ |
// } |
603 |
|
|
604 |
|
//filling histograms |
605 |
|
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
606 |
|
histogram currentHistogram = histograms.at(histogramIndex); |
607 |
|
|
608 |
|
if(currentHistogram.inputVariables.size() == 1){ |
609 |
< |
TH1D* histo; |
610 |
< |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
611 |
< |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
612 |
< |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
613 |
< |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\ |
614 |
< |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\ |
615 |
< |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
616 |
< |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
617 |
< |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
618 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
619 |
< |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
620 |
< |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
621 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
622 |
< |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
623 |
< |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
624 |
< |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
625 |
< |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
626 |
< |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
627 |
< |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
628 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
629 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
630 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
631 |
< |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
632 |
< |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
609 |
> |
TH1D* histo; |
610 |
> |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
611 |
> |
|
612 |
> |
|
613 |
> |
|
614 |
> |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
615 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
616 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
617 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
618 |
> |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
619 |
> |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
620 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
621 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
622 |
> |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
623 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
624 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
625 |
> |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
626 |
> |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
627 |
> |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
628 |
> |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
629 |
> |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
630 |
> |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
631 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
632 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
633 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
634 |
> |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
635 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
636 |
|
} |
637 |
|
else if(currentHistogram.inputVariables.size() == 2){ |
638 |
< |
TH2D* histo; |
639 |
< |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
479 |
< |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
480 |
< |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
481 |
< |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
482 |
< |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
483 |
< |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
484 |
< |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
485 |
< |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
486 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
487 |
< |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
488 |
< |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
489 |
< |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
490 |
< |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
491 |
< |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
492 |
< |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
493 |
< |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
494 |
< |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
495 |
< |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
496 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
497 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
498 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
499 |
< |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
500 |
< |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
501 |
< |
} |
502 |
< |
} |
638 |
> |
TH2D* histo; |
639 |
> |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
640 |
|
|
641 |
|
|
642 |
+ |
|
643 |
+ |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor); |
644 |
+ |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor); |
645 |
+ |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
646 |
+ |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
647 |
+ |
cumulativeFlags.at("muon-muon pairs").back(),scaleFactor); |
648 |
+ |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor); |
649 |
+ |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
650 |
+ |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
651 |
+ |
cumulativeFlags.at("electron-electron pairs").back(),scaleFactor); |
652 |
+ |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
653 |
+ |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
654 |
+ |
cumulativeFlags.at("electron-muon pairs").back(),scaleFactor); |
655 |
+ |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor); |
656 |
+ |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor); |
657 |
+ |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor); |
658 |
+ |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor); |
659 |
+ |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor); |
660 |
+ |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor); |
661 |
+ |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor); |
662 |
+ |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor); |
663 |
+ |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor); |
664 |
+ |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor); |
665 |
+ |
} |
666 |
+ |
} |
667 |
+ |
|
668 |
|
//fills histograms with the sizes of collections |
669 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
670 |
|
string currentObject = objectsToPlot.at(currentObjectIndex); |
671 |
|
|
672 |
< |
if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
673 |
< |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
674 |
< |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
675 |
< |
string tempCurrentObject = currentObject; |
672 |
> |
string objectToPlot = ""; |
673 |
> |
|
674 |
> |
if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs"; |
675 |
> |
else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs"; |
676 |
> |
else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs"; |
677 |
> |
else objectToPlot = currentObject; |
678 |
> |
string tempCurrentObject = objectToPlot; |
679 |
|
tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0)); |
680 |
|
string histoName = "num" + tempCurrentObject; |
681 |
|
|
682 |
|
|
683 |
< |
if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor); |
684 |
< |
else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor); |
685 |
< |
else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor); |
686 |
< |
else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor); |
687 |
< |
else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor); |
688 |
< |
else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor); |
689 |
< |
else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor); |
690 |
< |
else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor); |
691 |
< |
else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor); |
692 |
< |
else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor); |
693 |
< |
else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor); |
694 |
< |
else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor); |
695 |
< |
else if(currentObject == "primaryvertexs"){ |
696 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
697 |
< |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
698 |
< |
} |
699 |
< |
else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor); |
700 |
< |
else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor); |
701 |
< |
else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor); |
683 |
> |
|
684 |
> |
|
685 |
> |
//set position of primary vertex in event, in order to calculate quantities relative to it |
686 |
> |
if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) { |
687 |
> |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back(); |
688 |
> |
int numToPlot = 0; |
689 |
> |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
690 |
> |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
691 |
> |
} |
692 |
> |
if(objectToPlot == "primaryvertexs"){ |
693 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
694 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
695 |
> |
} |
696 |
> |
else |
697 |
> |
oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor); |
698 |
> |
} |
699 |
> |
else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor); |
700 |
> |
else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor); |
701 |
> |
else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor); |
702 |
> |
else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor); |
703 |
> |
else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor); |
704 |
> |
else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor); |
705 |
> |
else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor); |
706 |
> |
else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor); |
707 |
> |
else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor); |
708 |
> |
else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor); |
709 |
> |
else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor); |
710 |
> |
else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor); |
711 |
> |
else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor); |
712 |
> |
else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor); |
713 |
> |
else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor); |
714 |
> |
else if(objectToPlot == "primaryvertexs"){ |
715 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
716 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor); |
717 |
> |
} |
718 |
|
|
719 |
|
} |
720 |
+ |
|
721 |
+ |
|
722 |
+ |
|
723 |
+ |
|
724 |
|
} //end loop over channel |
725 |
|
|
726 |
< |
masterCutFlow_->fillCutFlow(puScaleFactor); |
726 |
> |
masterCutFlow_->fillCutFlow(scaleFactor); |
727 |
|
|
728 |
|
|
729 |
|
|
922 |
|
else if(variable == "ecalIso") value = object->ecalIso; |
923 |
|
else if(variable == "hcalIso") value = object->hcalIso; |
924 |
|
else if(variable == "caloIso") value = object->caloIso; |
925 |
< |
else if(variable == "trackIsoDR03") value = object->trackIsoDR03; |
925 |
> |
else if(variable == "trackIsDR03") value = object->trackIsoDR03; |
926 |
|
else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03; |
927 |
|
else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03; |
928 |
|
else if(variable == "caloIsoDR03") value = object->caloIsoDR03; |
1061 |
|
else if(variable == "time_ndof") value = object->time_ndof; |
1062 |
|
|
1063 |
|
//user-defined variables |
1064 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1065 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1066 |
< |
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1067 |
< |
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1064 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1065 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1066 |
> |
else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt; |
1067 |
> |
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1068 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1069 |
+ |
else if(variable == "metMT") { |
1070 |
+ |
const BNmet *met = chosenMET (); |
1071 |
+ |
if (met) |
1072 |
+ |
{ |
1073 |
+ |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1074 |
+ |
p2 (met->px, met->py, 0.0, met->pt); |
1075 |
+ |
|
1076 |
+ |
value = (p1 + p2).Mt (); |
1077 |
+ |
} |
1078 |
+ |
else |
1079 |
+ |
value = -999; |
1080 |
+ |
} |
1081 |
+ |
|
1082 |
+ |
|
1083 |
+ |
|
1084 |
+ |
else if(variable == "correctedD0VertexInEBPlus"){ |
1085 |
+ |
if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex; |
1086 |
+ |
else value = -999; |
1087 |
+ |
} |
1088 |
+ |
else if(variable == "correctedD0VertexOutEBPlus"){ |
1089 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex; |
1090 |
+ |
else value = -999; |
1091 |
+ |
} |
1092 |
+ |
else if(variable == "correctedD0VertexEEPlus"){ |
1093 |
+ |
if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex; |
1094 |
+ |
else value = -999; |
1095 |
+ |
} |
1096 |
+ |
|
1097 |
+ |
else if(variable == "correctedD0BeamspotInEBPlus"){ |
1098 |
+ |
if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0; |
1099 |
+ |
else value = -999; |
1100 |
+ |
} |
1101 |
+ |
else if(variable == "correctedD0BeamspotOutEBPlus"){ |
1102 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0; |
1103 |
+ |
else value = -999; |
1104 |
+ |
} |
1105 |
+ |
else if(variable == "correctedD0BeamspotEEPlus"){ |
1106 |
+ |
if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0; |
1107 |
+ |
else value = -999; |
1108 |
+ |
} |
1109 |
+ |
|
1110 |
+ |
else if(variable == "correctedD0VertexInEBMinus"){ |
1111 |
+ |
if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex; |
1112 |
+ |
else value = -999; |
1113 |
+ |
} |
1114 |
+ |
else if(variable == "correctedD0VertexOutEBMinus"){ |
1115 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex; |
1116 |
+ |
else value = -999; |
1117 |
+ |
} |
1118 |
+ |
else if(variable == "correctedD0VertexEEMinus"){ |
1119 |
+ |
if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex; |
1120 |
+ |
else value = -999; |
1121 |
+ |
} |
1122 |
+ |
|
1123 |
+ |
else if(variable == "correctedD0BeamspotInEBMinus"){ |
1124 |
+ |
if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0; |
1125 |
+ |
else value = -999; |
1126 |
+ |
} |
1127 |
+ |
else if(variable == "correctedD0BeamspotOutEBMinus"){ |
1128 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0; |
1129 |
+ |
else value = -999; |
1130 |
+ |
} |
1131 |
+ |
else if(variable == "correctedD0BeamspotEEMinus"){ |
1132 |
+ |
if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0; |
1133 |
+ |
else value = -999; |
1134 |
+ |
} |
1135 |
+ |
|
1136 |
+ |
|
1137 |
+ |
else if(variable == "correctedD0VertexInEBPositiveCharge"){ |
1138 |
+ |
if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex; |
1139 |
+ |
else value = -999; |
1140 |
+ |
} |
1141 |
+ |
else if(variable == "correctedD0VertexOutEBPositiveCharge"){ |
1142 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex; |
1143 |
+ |
else value = -999; |
1144 |
+ |
} |
1145 |
+ |
else if(variable == "correctedD0VertexEEPositiveCharge"){ |
1146 |
+ |
if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex; |
1147 |
+ |
else value = -999; |
1148 |
+ |
} |
1149 |
+ |
|
1150 |
+ |
else if(variable == "correctedD0BeamspotInEBPositiveCharge"){ |
1151 |
+ |
if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0; |
1152 |
+ |
else value = -999; |
1153 |
+ |
} |
1154 |
+ |
else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){ |
1155 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0; |
1156 |
+ |
else value = -999; |
1157 |
+ |
} |
1158 |
+ |
else if(variable == "correctedD0BeamspotEEPositiveCharge"){ |
1159 |
+ |
if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0; |
1160 |
+ |
else value = -999; |
1161 |
+ |
} |
1162 |
+ |
|
1163 |
+ |
else if(variable == "correctedD0VertexInEBNegativeCharge"){ |
1164 |
+ |
if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex; |
1165 |
+ |
else value = -999; |
1166 |
+ |
} |
1167 |
+ |
else if(variable == "correctedD0VertexOutEBNegativeCharge"){ |
1168 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex; |
1169 |
+ |
else value = -999; |
1170 |
+ |
} |
1171 |
+ |
else if(variable == "correctedD0VertexEENegativeCharge"){ |
1172 |
+ |
if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex; |
1173 |
+ |
else value = -999; |
1174 |
+ |
} |
1175 |
+ |
|
1176 |
+ |
else if(variable == "correctedD0BeamspotInEBNegativeCharge"){ |
1177 |
+ |
if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0; |
1178 |
+ |
else value = -999; |
1179 |
+ |
} |
1180 |
+ |
else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){ |
1181 |
+ |
if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0; |
1182 |
+ |
else value = -999; |
1183 |
+ |
} |
1184 |
+ |
else if(variable == "correctedD0BeamspotEENegativeCharge"){ |
1185 |
+ |
if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0; |
1186 |
+ |
else value = -999; |
1187 |
+ |
} |
1188 |
+ |
|
1189 |
+ |
|
1190 |
|
else if(variable == "tightID") { |
1191 |
< |
value = object->isGlobalMuon > 0 \ |
1192 |
< |
&& object->isPFMuon > 0 \ |
1193 |
< |
&& object->normalizedChi2 < 10 \ |
1194 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1195 |
< |
&& object->numberOfMatchedStations > 1 \ |
1196 |
< |
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1197 |
< |
&& fabs(object->correctedDZ) < 0.5 \ |
1198 |
< |
&& object->numberOfValidPixelHits > 0 \ |
1191 |
> |
value = object->isGlobalMuon > 0 \ |
1192 |
> |
&& object->isPFMuon > 0 \ |
1193 |
> |
&& object->normalizedChi2 < 10 \ |
1194 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1195 |
> |
&& object->numberOfMatchedStations > 1 \ |
1196 |
> |
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1197 |
> |
&& fabs(object->correctedDZ) < 0.5 \ |
1198 |
> |
&& object->numberOfValidPixelHits > 0 \ |
1199 |
|
&& object->numberOfLayersWithMeasurement > 5; |
893 |
– |
|
894 |
– |
|
1200 |
|
} |
1201 |
|
else if(variable == "tightIDdisplaced"){ |
1202 |
< |
value = object->isGlobalMuon > 0 \ |
1203 |
< |
&& object->isPFMuon > 0 \ |
1204 |
< |
&& object->normalizedChi2 < 10 \ |
1205 |
< |
&& object->numberOfValidMuonHits > 0 \ |
1206 |
< |
&& object->numberOfMatchedStations > 1 \ |
902 |
< |
&& object->numberOfValidPixelHits > 0 \ |
1202 |
> |
value = object->isGlobalMuon > 0 \ |
1203 |
> |
&& object->normalizedChi2 < 10 \ |
1204 |
> |
&& object->numberOfValidMuonHits > 0 \ |
1205 |
> |
&& object->numberOfMatchedStations > 1 \ |
1206 |
> |
&& object->numberOfValidPixelHits > 0 \ |
1207 |
|
&& object->numberOfLayersWithMeasurement > 5; |
1208 |
|
} |
1209 |
|
|
1210 |
+ |
else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object); |
1211 |
+ |
|
1212 |
+ |
else if(variable == "genMatchedPdgId"){ |
1213 |
+ |
int index = getGenMatchedParticleIndex(object); |
1214 |
+ |
if(index == -1) value = 0; |
1215 |
+ |
else value = mcparticles->at(index).id; |
1216 |
+ |
} |
1217 |
+ |
|
1218 |
+ |
else if(variable == "genMatchedId"){ |
1219 |
+ |
int index = getGenMatchedParticleIndex(object); |
1220 |
+ |
if(index == -1) value = 0; |
1221 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1222 |
+ |
} |
1223 |
+ |
else if(variable == "genMatchedMotherId"){ |
1224 |
+ |
int index = getGenMatchedParticleIndex(object); |
1225 |
+ |
if(index == -1) value = 0; |
1226 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1227 |
+ |
} |
1228 |
+ |
else if(variable == "genMatchedMotherIdReverse"){ |
1229 |
+ |
int index = getGenMatchedParticleIndex(object); |
1230 |
+ |
if(index == -1) value = 23; |
1231 |
+ |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
1232 |
+ |
} |
1233 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1234 |
+ |
int index = getGenMatchedParticleIndex(object); |
1235 |
+ |
if(index == -1) value = 0; |
1236 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1237 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1238 |
+ |
if(motherIndex == -1) value = 0; |
1239 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1240 |
+ |
} |
1241 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1242 |
+ |
} |
1243 |
+ |
|
1244 |
+ |
|
1245 |
+ |
|
1246 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1247 |
|
|
1248 |
|
value = applyFunction(function, value); |
1413 |
|
else if(variable == "passConvVeto") value = object->passConvVeto; |
1414 |
|
|
1415 |
|
//user-defined variables |
1416 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1417 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1416 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1417 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError)); |
1418 |
|
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1419 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1420 |
+ |
else if(variable == "metMT") { |
1421 |
+ |
const BNmet *met = chosenMET (); |
1422 |
+ |
if (met) |
1423 |
+ |
{ |
1424 |
+ |
TLorentzVector p1 (object->px, object->py, object->pz, object->energy), |
1425 |
+ |
p2 (met->px, met->py, 0.0, met->pt); |
1426 |
+ |
|
1427 |
+ |
value = (p1 + p2).Mt (); |
1428 |
+ |
} |
1429 |
+ |
else |
1430 |
+ |
value = -999; |
1431 |
+ |
} |
1432 |
+ |
|
1433 |
+ |
else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){ |
1434 |
+ |
if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex; |
1435 |
+ |
else value = -999; |
1436 |
+ |
} |
1437 |
+ |
else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){ |
1438 |
+ |
if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex; |
1439 |
+ |
else value = -999; |
1440 |
+ |
} |
1441 |
+ |
|
1442 |
+ |
else if(variable == "correctedD0VertexInEBPlus"){ |
1443 |
+ |
if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex; |
1444 |
+ |
else value = -999; |
1445 |
+ |
} |
1446 |
+ |
else if(variable == "correctedD0VertexOutEBPlus"){ |
1447 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex; |
1448 |
+ |
else value = -999; |
1449 |
+ |
} |
1450 |
+ |
else if(variable == "correctedD0VertexEEPlus"){ |
1451 |
+ |
if(object->isEE && object->eta > 0) value = object->correctedD0Vertex; |
1452 |
+ |
else value = -999; |
1453 |
+ |
} |
1454 |
+ |
|
1455 |
+ |
else if(variable == "correctedD0BeamspotInEBPlus"){ |
1456 |
+ |
if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0; |
1457 |
+ |
else value = -999; |
1458 |
+ |
} |
1459 |
+ |
else if(variable == "correctedD0BeamspotOutEBPlus"){ |
1460 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0; |
1461 |
+ |
else value = -999; |
1462 |
+ |
} |
1463 |
+ |
else if(variable == "correctedD0BeamspotEEPlus"){ |
1464 |
+ |
if(object->isEE && object->eta > 0) value = object->correctedD0; |
1465 |
+ |
else value = -999; |
1466 |
+ |
} |
1467 |
+ |
|
1468 |
+ |
else if(variable == "correctedD0VertexInEBMinus"){ |
1469 |
+ |
if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex; |
1470 |
+ |
else value = -999; |
1471 |
+ |
} |
1472 |
+ |
else if(variable == "correctedD0VertexOutEBMinus"){ |
1473 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex; |
1474 |
+ |
else value = -999; |
1475 |
+ |
} |
1476 |
+ |
else if(variable == "correctedD0VertexEEMinus"){ |
1477 |
+ |
if(object->isEE && object->eta < 0) value = object->correctedD0Vertex; |
1478 |
+ |
else value = -999; |
1479 |
+ |
} |
1480 |
+ |
|
1481 |
+ |
else if(variable == "correctedD0BeamspotInEBMinus"){ |
1482 |
+ |
if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0; |
1483 |
+ |
else value = -999; |
1484 |
+ |
} |
1485 |
+ |
else if(variable == "correctedD0BeamspotOutEBMinus"){ |
1486 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0; |
1487 |
+ |
else value = -999; |
1488 |
+ |
} |
1489 |
+ |
else if(variable == "correctedD0BeamspotEEMinus"){ |
1490 |
+ |
if(object->isEE && object->eta < 0) value = object->correctedD0; |
1491 |
+ |
else value = -999; |
1492 |
+ |
} |
1493 |
+ |
|
1494 |
+ |
else if(variable == "tightID"){ |
1495 |
+ |
if (object->isEB) |
1496 |
+ |
{ |
1497 |
+ |
value = fabs(object->delEtaIn) < 0.004 \ |
1498 |
+ |
&& fabs (object->delPhiIn) < 0.03 \ |
1499 |
+ |
&& object->scSigmaIEtaIEta < 0.01 \ |
1500 |
+ |
&& object->hadOverEm < 0.12 \ |
1501 |
+ |
&& fabs (object->correctedD0Vertex) < 0.02 \ |
1502 |
+ |
&& fabs (object->correctedDZ) < 0.1 \ |
1503 |
+ |
&& object->absInvEMinusInvPin < 0.05 \ |
1504 |
+ |
&& object->passConvVeto; |
1505 |
+ |
} |
1506 |
+ |
else |
1507 |
+ |
{ |
1508 |
+ |
value = fabs(object->delEtaIn) < 0.005 \ |
1509 |
+ |
&& fabs (object->delPhiIn) < 0.02 \ |
1510 |
+ |
&& object->scSigmaIEtaIEta < 0.03 \ |
1511 |
+ |
&& object->hadOverEm < 0.10 \ |
1512 |
+ |
&& fabs (object->correctedD0Vertex) < 0.02 \ |
1513 |
+ |
&& fabs (object->correctedDZ) < 0.1 \ |
1514 |
+ |
&& object->absInvEMinusInvPin < 0.05 \ |
1515 |
+ |
&& object->passConvVeto; |
1516 |
+ |
} |
1517 |
+ |
} |
1518 |
+ |
|
1519 |
+ |
else if(variable == "correctedD0VertexInEBPositiveCharge"){ |
1520 |
+ |
if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex; |
1521 |
+ |
else value = -999; |
1522 |
+ |
} |
1523 |
+ |
else if(variable == "correctedD0VertexOutEBPositiveCharge"){ |
1524 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex; |
1525 |
+ |
else value = -999; |
1526 |
+ |
} |
1527 |
+ |
else if(variable == "correctedD0VertexEEPositiveCharge"){ |
1528 |
+ |
if(object->isEE && object->charge > 0) value = object->correctedD0Vertex; |
1529 |
+ |
else value = -999; |
1530 |
+ |
} |
1531 |
+ |
|
1532 |
+ |
else if(variable == "correctedD0BeamspotInEBPositiveCharge"){ |
1533 |
+ |
if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0; |
1534 |
+ |
else value = -999; |
1535 |
+ |
} |
1536 |
+ |
else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){ |
1537 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0; |
1538 |
+ |
else value = -999; |
1539 |
+ |
} |
1540 |
+ |
else if(variable == "correctedD0BeamspotEEPositiveCharge"){ |
1541 |
+ |
if(object->isEE && object->charge > 0) value = object->correctedD0; |
1542 |
+ |
else value = -999; |
1543 |
+ |
} |
1544 |
+ |
|
1545 |
+ |
else if(variable == "correctedD0VertexInEBNegativeCharge"){ |
1546 |
+ |
if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex; |
1547 |
+ |
else value = -999; |
1548 |
+ |
} |
1549 |
+ |
else if(variable == "correctedD0VertexOutEBNegativeCharge"){ |
1550 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex; |
1551 |
+ |
else value = -999; |
1552 |
+ |
} |
1553 |
+ |
else if(variable == "correctedD0VertexEENegativeCharge"){ |
1554 |
+ |
if(object->isEE && object->charge < 0) value = object->correctedD0Vertex; |
1555 |
+ |
else value = -999; |
1556 |
+ |
} |
1557 |
+ |
|
1558 |
+ |
else if(variable == "correctedD0BeamspotInEBNegativeCharge"){ |
1559 |
+ |
if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0; |
1560 |
+ |
else value = -999; |
1561 |
+ |
} |
1562 |
+ |
else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){ |
1563 |
+ |
if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0; |
1564 |
+ |
else value = -999; |
1565 |
+ |
} |
1566 |
+ |
else if(variable == "correctedD0BeamspotEENegativeCharge"){ |
1567 |
+ |
if(object->isEE && object->charge < 0) value = object->correctedD0; |
1568 |
+ |
else value = -999; |
1569 |
+ |
} |
1570 |
+ |
|
1571 |
+ |
|
1572 |
+ |
else if(variable == "tightIDdisplaced"){ |
1573 |
+ |
if (object->isEB) |
1574 |
+ |
{ |
1575 |
+ |
value = fabs(object->delEtaIn) < 0.004 \ |
1576 |
+ |
&& fabs (object->delPhiIn) < 0.03 \ |
1577 |
+ |
&& object->scSigmaIEtaIEta < 0.01 \ |
1578 |
+ |
&& object->hadOverEm < 0.12 \ |
1579 |
+ |
&& object->absInvEMinusInvPin < 0.05; |
1580 |
+ |
} |
1581 |
+ |
else |
1582 |
+ |
{ |
1583 |
+ |
value = fabs (object->delEtaIn) < 0.005 \ |
1584 |
+ |
&& fabs (object->delPhiIn) < 0.02 \ |
1585 |
+ |
&& object->scSigmaIEtaIEta < 0.03 \ |
1586 |
+ |
&& object->hadOverEm < 0.10 \ |
1587 |
+ |
&& object->absInvEMinusInvPin < 0.05; |
1588 |
+ |
} |
1589 |
+ |
} |
1590 |
+ |
|
1591 |
+ |
|
1592 |
+ |
else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object); |
1593 |
+ |
|
1594 |
+ |
else if(variable == "genMatchedPdgId"){ |
1595 |
+ |
int index = getGenMatchedParticleIndex(object); |
1596 |
+ |
if(index == -1) value = 0; |
1597 |
+ |
else value = mcparticles->at(index).id; |
1598 |
+ |
} |
1599 |
+ |
|
1600 |
+ |
|
1601 |
+ |
else if(variable == "genMatchedId"){ |
1602 |
+ |
int index = getGenMatchedParticleIndex(object); |
1603 |
+ |
if(index == -1) value = 0; |
1604 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1605 |
+ |
} |
1606 |
+ |
else if(variable == "genMatchedMotherId"){ |
1607 |
+ |
int index = getGenMatchedParticleIndex(object); |
1608 |
+ |
if(index == -1) value = 0; |
1609 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1610 |
+ |
} |
1611 |
+ |
else if(variable == "genMatchedMotherIdReverse"){ |
1612 |
+ |
int index = getGenMatchedParticleIndex(object); |
1613 |
+ |
if(index == -1) value = 23; |
1614 |
+ |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
1615 |
+ |
} |
1616 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1617 |
+ |
int index = getGenMatchedParticleIndex(object); |
1618 |
+ |
if(index == -1) value = 0; |
1619 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1620 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1621 |
+ |
if(motherIndex == -1) value = 0; |
1622 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1623 |
+ |
} |
1624 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1625 |
+ |
} |
1626 |
+ |
|
1627 |
|
|
1628 |
|
|
1629 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1703 |
|
else if(variable == "id1") value = object->id1; |
1704 |
|
else if(variable == "id2") value = object->id2; |
1705 |
|
else if(variable == "evt") value = object->evt; |
1706 |
+ |
else if(variable == "puScaleFactor"){ |
1707 |
+ |
if(datasetType_ != "data") |
1708 |
+ |
value = puWeight_->at (events->at (0).numTruePV); |
1709 |
+ |
else |
1710 |
+ |
value = 1.0; |
1711 |
+ |
} |
1712 |
+ |
else if(variable == "muonScaleFactor"){ |
1713 |
+ |
if(datasetType_ != "data") |
1714 |
+ |
// value = muonSFWeight_->at (chosenMuon ()->eta); |
1715 |
+ |
value = 1.0; |
1716 |
+ |
else |
1717 |
+ |
value = 1.0; |
1718 |
+ |
} |
1719 |
+ |
else if(variable == "electronScaleFactor"){ |
1720 |
+ |
if(datasetType_ != "data") |
1721 |
+ |
// value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt); |
1722 |
+ |
value = 1.0; |
1723 |
+ |
else |
1724 |
+ |
value = 1.0; |
1725 |
+ |
} |
1726 |
|
|
1727 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1728 |
|
|
1777 |
|
else if(variable == "leadingTrackValid") value = object->leadingTrackValid; |
1778 |
|
|
1779 |
|
|
1780 |
+ |
|
1781 |
+ |
else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object); |
1782 |
+ |
|
1783 |
+ |
else if(variable == "genMatchedPdgId"){ |
1784 |
+ |
int index = getGenMatchedParticleIndex(object); |
1785 |
+ |
if(index == -1) value = 0; |
1786 |
+ |
else value = mcparticles->at(index).id; |
1787 |
+ |
} |
1788 |
+ |
|
1789 |
+ |
else if(variable == "genMatchedId"){ |
1790 |
+ |
int index = getGenMatchedParticleIndex(object); |
1791 |
+ |
if(index == -1) value = 0; |
1792 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1793 |
+ |
} |
1794 |
+ |
else if(variable == "genMatchedMotherId"){ |
1795 |
+ |
int index = getGenMatchedParticleIndex(object); |
1796 |
+ |
if(index == -1) value = 0; |
1797 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1798 |
+ |
} |
1799 |
+ |
else if(variable == "genMatchedMotherIdReverse"){ |
1800 |
+ |
int index = getGenMatchedParticleIndex(object); |
1801 |
+ |
if(index == -1) value = 23; |
1802 |
+ |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
1803 |
+ |
} |
1804 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1805 |
+ |
int index = getGenMatchedParticleIndex(object); |
1806 |
+ |
if(index == -1) value = 0; |
1807 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1808 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1809 |
+ |
if(motherIndex == -1) value = 0; |
1810 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1811 |
+ |
} |
1812 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1813 |
+ |
} |
1814 |
+ |
|
1815 |
+ |
|
1816 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1817 |
|
|
1818 |
|
value = applyFunction(function, value); |
1896 |
|
OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){ |
1897 |
|
|
1898 |
|
double value = 0.0; |
1899 |
+ |
double pMag = sqrt(object->pt * object->pt + |
1900 |
+ |
object->pz * object->pz); |
1901 |
|
|
1902 |
|
if(variable == "pt") value = object->pt; |
1903 |
|
else if(variable == "px") value = object->px; |
1918 |
|
else if(variable == "isHighPurity") value = object->isHighPurity; |
1919 |
|
|
1920 |
|
|
1921 |
+ |
//additional BNs info for disappTrks |
1922 |
+ |
else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution; |
1923 |
+ |
else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3; |
1924 |
+ |
else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3; |
1925 |
+ |
else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4; |
1926 |
+ |
else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4; |
1927 |
+ |
else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5; |
1928 |
+ |
else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5; |
1929 |
+ |
else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter; |
1930 |
+ |
else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner; |
1931 |
+ |
else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle; |
1932 |
+ |
|
1933 |
+ |
|
1934 |
+ |
//user defined variables |
1935 |
+ |
else if(variable == "d0wrtBS") value = (object->vx-events->at(0).BSx)*object->py/object->pt - (object->vy-events->at(0).BSy)*object->px/object->pt; |
1936 |
+ |
else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz; |
1937 |
+ |
else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5); |
1938 |
+ |
else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag); |
1939 |
+ |
|
1940 |
+ |
|
1941 |
+ |
|
1942 |
+ |
|
1943 |
+ |
|
1944 |
+ |
else if(variable == "isIso") value = getTrkIsIso(object, tracks.product()); |
1945 |
+ |
else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object); |
1946 |
+ |
else if(variable == "ptErrorByPt") value = (object->ptError/object->pt); |
1947 |
+ |
else if(variable == "ptError") value = object->ptError; |
1948 |
+ |
else if(variable == "ptRes") value = getTrkPtRes(object); |
1949 |
+ |
|
1950 |
+ |
else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object); |
1951 |
+ |
|
1952 |
+ |
else if(variable == "genMatchedPdgId"){ |
1953 |
+ |
int index = getGenMatchedParticleIndex(object); |
1954 |
+ |
if(index == -1) value = 0; |
1955 |
+ |
else value = mcparticles->at(index).id; |
1956 |
+ |
} |
1957 |
+ |
|
1958 |
+ |
|
1959 |
+ |
else if(variable == "genMatchedId"){ |
1960 |
+ |
int index = getGenMatchedParticleIndex(object); |
1961 |
+ |
if(index == -1) value = 0; |
1962 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1963 |
+ |
} |
1964 |
+ |
else if(variable == "genMatchedMotherId"){ |
1965 |
+ |
int index = getGenMatchedParticleIndex(object); |
1966 |
+ |
if(index == -1) value = 0; |
1967 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1968 |
+ |
} |
1969 |
+ |
else if(variable == "genMatchedMotherIdReverse"){ |
1970 |
+ |
int index = getGenMatchedParticleIndex(object); |
1971 |
+ |
if(index == -1) value = 23; |
1972 |
+ |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
1973 |
+ |
} |
1974 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1975 |
+ |
int index = getGenMatchedParticleIndex(object); |
1976 |
+ |
if(index == -1) value = 0; |
1977 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1978 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1979 |
+ |
if(motherIndex == -1) value = 0; |
1980 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1981 |
+ |
} |
1982 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1983 |
+ |
} |
1984 |
+ |
|
1985 |
+ |
|
1986 |
+ |
|
1987 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1988 |
|
|
1989 |
|
value = applyFunction(function, value); |
2111 |
|
|
2112 |
|
//user-defined variables |
2113 |
|
else if (variable == "d0"){ |
2114 |
< |
double vx = object->vx - primaryVertex_->x, |
2115 |
< |
vy = object->vy - primaryVertex_->y, |
2114 |
> |
double vx = object->vx - chosenVertex ()->x, |
2115 |
> |
vy = object->vy - chosenVertex ()->y, |
2116 |
|
px = object->px, |
2117 |
|
py = object->py, |
2118 |
|
pt = object->pt; |
2119 |
|
value = (-vx * py + vy * px) / pt; |
2120 |
|
} |
2121 |
|
else if (variable == "dz"){ |
2122 |
< |
double vx = object->vx - primaryVertex_->x, |
2123 |
< |
vy = object->vy - primaryVertex_->y, |
2124 |
< |
vz = object->vz - primaryVertex_->z, |
2122 |
> |
double vx = object->vx - chosenVertex ()->x, |
2123 |
> |
vy = object->vy - chosenVertex ()->y, |
2124 |
> |
vz = object->vz - chosenVertex ()->z, |
2125 |
|
px = object->px, |
2126 |
|
py = object->py, |
2127 |
|
pz = object->pz, |
2128 |
|
pt = object->pt; |
2129 |
|
value = vz - (vx * px + vy * py)/pt * (pz/pt); |
2130 |
|
} |
2131 |
< |
|
2131 |
> |
else if(variable == "v0"){ |
2132 |
> |
value = sqrt(object->vx*object->vx + object->vy*object->vy); |
2133 |
> |
} |
2134 |
> |
else if(variable == "deltaV0"){ |
2135 |
> |
value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y)); |
2136 |
> |
} |
2137 |
> |
else if (variable == "deltaVx"){ |
2138 |
> |
value = object->vx - chosenVertex ()->x; |
2139 |
> |
} |
2140 |
> |
else if (variable == "deltaVy"){ |
2141 |
> |
value = object->vy - chosenVertex ()->y; |
2142 |
> |
} |
2143 |
> |
else if (variable == "deltaVz"){ |
2144 |
> |
value = object->vz - chosenVertex ()->z; |
2145 |
> |
} |
2146 |
|
|
2147 |
|
|
2148 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2272 |
|
else if(variable == "seedRecoFlag") value = object->seedRecoFlag; |
2273 |
|
|
2274 |
|
|
2275 |
+ |
|
2276 |
+ |
|
2277 |
+ |
else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object); |
2278 |
+ |
|
2279 |
+ |
else if(variable == "genMatchedPdgId"){ |
2280 |
+ |
int index = getGenMatchedParticleIndex(object); |
2281 |
+ |
if(index == -1) value = 0; |
2282 |
+ |
else value = mcparticles->at(index).id; |
2283 |
+ |
} |
2284 |
+ |
|
2285 |
+ |
|
2286 |
+ |
|
2287 |
+ |
else if(variable == "genMatchedId"){ |
2288 |
+ |
int index = getGenMatchedParticleIndex(object); |
2289 |
+ |
if(index == -1) value = 0; |
2290 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
2291 |
+ |
} |
2292 |
+ |
else if(variable == "genMatchedMotherId"){ |
2293 |
+ |
int index = getGenMatchedParticleIndex(object); |
2294 |
+ |
if(index == -1) value = 0; |
2295 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
2296 |
+ |
} |
2297 |
+ |
else if(variable == "genMatchedMotherIdReverse"){ |
2298 |
+ |
int index = getGenMatchedParticleIndex(object); |
2299 |
+ |
if(index == -1) value = 23; |
2300 |
+ |
else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId); |
2301 |
+ |
} |
2302 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
2303 |
+ |
int index = getGenMatchedParticleIndex(object); |
2304 |
+ |
if(index == -1) value = 0; |
2305 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
2306 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
2307 |
+ |
if(motherIndex == -1) value = 0; |
2308 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
2309 |
+ |
} |
2310 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
2311 |
+ |
} |
2312 |
+ |
|
2313 |
+ |
|
2314 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2315 |
|
|
2316 |
|
value = applyFunction(function, value); |
2346 |
|
|
2347 |
|
double value = 0.0; |
2348 |
|
|
2349 |
< |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
2349 |
> |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
2350 |
> |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2351 |
|
else if(variable == "invMass"){ |
2352 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2353 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2354 |
|
value = (fourVector1 + fourVector2).M(); |
2355 |
|
} |
2356 |
+ |
else if(variable == "pt"){ |
2357 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2358 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2359 |
+ |
value = (fourVector1 + fourVector2).Et(); |
2360 |
+ |
} |
2361 |
+ |
else if(variable == "threeDAngle") |
2362 |
+ |
{ |
2363 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2364 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2365 |
+ |
value = (threeVector1.Angle(threeVector2)); |
2366 |
+ |
} |
2367 |
+ |
else if(variable == "alpha") |
2368 |
+ |
{ |
2369 |
+ |
static const double pi = 3.1415926535897932384626433832795028841971693993751058; |
2370 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2371 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2372 |
+ |
value = (pi-threeVector1.Angle(threeVector2)); |
2373 |
+ |
} |
2374 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2375 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2376 |
< |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2376 |
> |
else if(variable == "d0Sign"){ |
2377 |
> |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2378 |
> |
if(d0Sign < 0) value = -0.5; |
2379 |
> |
else if (d0Sign > 0) value = 0.5; |
2380 |
> |
else value = -999; |
2381 |
> |
} |
2382 |
> |
else if(variable == "chargeProduct"){ |
2383 |
> |
value = object1->charge*object2->charge; |
2384 |
> |
} |
2385 |
> |
else if(variable == "muon1CorrectedD0Vertex"){ |
2386 |
> |
value = object1->correctedD0Vertex; |
2387 |
> |
} |
2388 |
> |
else if(variable == "muon2CorrectedD0Vertex"){ |
2389 |
> |
value = object2->correctedD0Vertex; |
2390 |
> |
} |
2391 |
> |
else if(variable == "muon1timeAtIpInOut"){ |
2392 |
> |
value = object1->timeAtIpInOut; |
2393 |
> |
} |
2394 |
> |
else if(variable == "muon2timeAtIpInOut"){ |
2395 |
> |
value = object2->timeAtIpInOut; |
2396 |
> |
} |
2397 |
> |
else if(variable == "muon1correctedD0") |
2398 |
> |
{ |
2399 |
> |
value = object1->correctedD0; |
2400 |
> |
} |
2401 |
> |
else if(variable == "muon2correctedD0") |
2402 |
> |
{ |
2403 |
> |
value = object2->correctedD0; |
2404 |
> |
} |
2405 |
|
|
2406 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2407 |
|
|
2415 |
|
|
2416 |
|
double value = 0.0; |
2417 |
|
|
2418 |
< |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
2418 |
> |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
2419 |
> |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2420 |
|
else if(variable == "invMass"){ |
2421 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2422 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2423 |
|
value = (fourVector1 + fourVector2).M(); |
2424 |
|
} |
2425 |
+ |
else if(variable == "pt"){ |
2426 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2427 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2428 |
+ |
value = (fourVector1 + fourVector2).Et(); |
2429 |
+ |
} |
2430 |
+ |
else if(variable == "threeDAngle") |
2431 |
+ |
{ |
2432 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2433 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2434 |
+ |
value = (threeVector1.Angle(threeVector2)); |
2435 |
+ |
} |
2436 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2437 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2438 |
< |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2438 |
> |
else if(variable == "d0Sign"){ |
2439 |
> |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2440 |
> |
if(d0Sign < 0) value = -0.5; |
2441 |
> |
else if (d0Sign > 0) value = 0.5; |
2442 |
> |
else value = -999; |
2443 |
> |
} |
2444 |
> |
else if(variable == "chargeProduct"){ |
2445 |
> |
value = object1->charge*object2->charge; |
2446 |
> |
} |
2447 |
> |
else if(variable == "electron1CorrectedD0Vertex"){ |
2448 |
> |
value = object1->correctedD0Vertex; |
2449 |
> |
} |
2450 |
> |
else if(variable == "electron2CorrectedD0Vertex"){ |
2451 |
> |
value = object2->correctedD0Vertex; |
2452 |
> |
} |
2453 |
> |
else if(variable == "electron1CorrectedD0"){ |
2454 |
> |
value = object1->correctedD0; |
2455 |
> |
} |
2456 |
> |
else if(variable == "electron2CorrectedD0"){ |
2457 |
> |
value = object2->correctedD0; |
2458 |
> |
} |
2459 |
|
|
2460 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2461 |
|
|
2469 |
|
|
2470 |
|
double value = 0.0; |
2471 |
|
|
2472 |
< |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
2472 |
> |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
2473 |
> |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2474 |
|
else if(variable == "invMass"){ |
2475 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2476 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2477 |
|
value = (fourVector1 + fourVector2).M(); |
2478 |
|
} |
2479 |
+ |
else if(variable == "pt"){ |
2480 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2481 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2482 |
+ |
value = (fourVector1 + fourVector2).Pt(); |
2483 |
+ |
} |
2484 |
+ |
else if(variable == "threeDAngle") |
2485 |
+ |
{ |
2486 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2487 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2488 |
+ |
value = (threeVector1.Angle(threeVector2)); |
2489 |
+ |
} |
2490 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2491 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2492 |
< |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2492 |
> |
else if(variable == "d0Sign"){ |
2493 |
> |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2494 |
> |
if(d0Sign < 0) value = -0.5; |
2495 |
> |
else if (d0Sign > 0) value = 0.5; |
2496 |
> |
else value = -999; |
2497 |
> |
} |
2498 |
> |
else if(variable == "chargeProduct"){ |
2499 |
> |
value = object1->charge*object2->charge; |
2500 |
> |
} |
2501 |
> |
else if(variable == "electronCorrectedD0Vertex"){ |
2502 |
> |
value = object1->correctedD0Vertex; |
2503 |
> |
} |
2504 |
> |
else if(variable == "muonCorrectedD0Vertex"){ |
2505 |
> |
value = object2->correctedD0Vertex; |
2506 |
> |
} |
2507 |
> |
else if(variable == "electronCorrectedD0"){ |
2508 |
> |
value = object1->correctedD0; |
2509 |
> |
} |
2510 |
> |
else if(variable == "muonCorrectedD0"){ |
2511 |
> |
value = object2->correctedD0; |
2512 |
> |
} |
2513 |
> |
else if(variable == "electronDetIso"){ |
2514 |
> |
value = (object1->trackIso) / object1->pt; |
2515 |
> |
} |
2516 |
> |
else if(variable == "muonDetIso"){ |
2517 |
> |
value = (object2->trackIsoDR03) / object2->pt; |
2518 |
> |
} |
2519 |
> |
|
2520 |
|
|
2521 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2522 |
|
|
2526 |
|
} |
2527 |
|
|
2528 |
|
|
2529 |
+ |
// Calculate the number of tracks in cone of DeltaR<0.5 around track1. |
2530 |
+ |
// Return true iff no other tracks are found in this cone. |
2531 |
+ |
int |
2532 |
+ |
OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){ |
2533 |
+ |
for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){ |
2534 |
+ |
if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself. |
2535 |
+ |
double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi); |
2536 |
+ |
if(deltaRtrk < 0.5) return 0; |
2537 |
+ |
} |
2538 |
+ |
return 1; |
2539 |
+ |
|
2540 |
+ |
} |
2541 |
+ |
|
2542 |
+ |
|
2543 |
+ |
double |
2544 |
+ |
OSUAnalysis::getTrkPtRes (const BNtrack* track1){ |
2545 |
+ |
|
2546 |
+ |
double ptTrue = getTrkPtTrue(track1, mcparticles.product()); |
2547 |
+ |
double PtRes = (track1->pt - ptTrue) / ptTrue; |
2548 |
+ |
|
2549 |
+ |
return PtRes; |
2550 |
+ |
|
2551 |
+ |
} |
2552 |
+ |
|
2553 |
+ |
|
2554 |
+ |
double |
2555 |
+ |
OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){ |
2556 |
+ |
double value = -99; |
2557 |
+ |
double genDeltaRLowest = 999; |
2558 |
+ |
|
2559 |
+ |
for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){ |
2560 |
+ |
double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi); |
2561 |
+ |
if (genDeltaRtemp < genDeltaRLowest) { |
2562 |
+ |
genDeltaRLowest = genDeltaRtemp; |
2563 |
+ |
if (genDeltaRLowest < 0.05) { // Only consider it truth-matched if DeltaR<0.15. |
2564 |
+ |
double ptTrue = genPart->pt; |
2565 |
+ |
value = ptTrue; |
2566 |
+ |
} |
2567 |
+ |
} |
2568 |
+ |
} |
2569 |
+ |
|
2570 |
+ |
return value; |
2571 |
+ |
|
2572 |
+ |
} |
2573 |
+ |
|
2574 |
+ |
//creates a map of the dead Ecal channels in the barrel and endcap |
2575 |
+ |
//to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here: |
2576 |
+ |
//http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup |
2577 |
+ |
void |
2578 |
+ |
OSUAnalysis::WriteDeadEcal (){ |
2579 |
+ |
double etaEcal, phiEcal; |
2580 |
+ |
ifstream DeadEcalFile(deadEcalFile_); |
2581 |
+ |
if(!DeadEcalFile) { |
2582 |
+ |
cout << "Error: DeadEcalFile has not been found." << endl; |
2583 |
+ |
return; |
2584 |
+ |
} |
2585 |
+ |
if(DeadEcalVec.size()!= 0){ |
2586 |
+ |
cout << "Error: DeadEcalVec has a nonzero size" << endl; |
2587 |
+ |
return; |
2588 |
+ |
} |
2589 |
+ |
while(!DeadEcalFile.eof()) |
2590 |
+ |
{ |
2591 |
+ |
DeadEcalFile >> etaEcal >> phiEcal; |
2592 |
+ |
DeadEcal newChan; |
2593 |
+ |
newChan.etaEcal = etaEcal; |
2594 |
+ |
newChan.phiEcal = phiEcal; |
2595 |
+ |
DeadEcalVec.push_back(newChan); |
2596 |
+ |
} |
2597 |
+ |
if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl; |
2598 |
+ |
} |
2599 |
+ |
|
2600 |
+ |
//if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0 |
2601 |
+ |
int |
2602 |
+ |
OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){ |
2603 |
+ |
double deltaRLowest = 999; |
2604 |
+ |
int value = 0; |
2605 |
+ |
if (DeadEcalVec.size() == 0) WriteDeadEcal(); |
2606 |
+ |
for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){ |
2607 |
+ |
double eta = ecal->etaEcal; |
2608 |
+ |
double phi = ecal->phiEcal; |
2609 |
+ |
double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi); |
2610 |
+ |
if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp; |
2611 |
+ |
} |
2612 |
+ |
if (deltaRLowest<0.05) {value = 1;} |
2613 |
+ |
else {value = 0;} |
2614 |
+ |
return value; |
2615 |
+ |
} |
2616 |
+ |
|
2617 |
+ |
// Returns the smallest DeltaR between the object and any generated true particle in the event. |
2618 |
+ |
template <class InputObject> |
2619 |
+ |
double OSUAnalysis::getGenDeltaRLowest(InputObject object){ |
2620 |
+ |
double genDeltaRLowest = 999.; |
2621 |
+ |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2622 |
+ |
double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi); |
2623 |
+ |
if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp; |
2624 |
+ |
} |
2625 |
+ |
return genDeltaRLowest; |
2626 |
+ |
} |
2627 |
+ |
|
2628 |
|
double |
2629 |
|
OSUAnalysis::applyFunction(string function, double value){ |
2630 |
|
|
2631 |
|
if(function == "abs") value = fabs(value); |
2632 |
+ |
else if(function == "fabs") value = fabs(value); |
2633 |
+ |
else if(function == "log10") value = log10(value); |
2634 |
+ |
else if(function == "log") value = log10(value); |
2635 |
|
|
2636 |
+ |
else if(function == "") value = value; |
2637 |
+ |
else{std::cout << "WARNING: invalid function '" << function << "'\n";} |
2638 |
|
|
2639 |
|
return value; |
2640 |
|
|
2644 |
|
template <class InputCollection> |
2645 |
|
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){ |
2646 |
|
|
2647 |
+ |
|
2648 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2649 |
|
|
2650 |
+ |
|
2651 |
|
bool decision = true;//object passes if this cut doesn't cut on that type of object |
2652 |
|
|
2653 |
+ |
|
2654 |
|
if(currentCut.inputCollection == inputType){ |
2655 |
|
|
2656 |
|
vector<bool> subcutDecisions; |
2657 |
|
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2658 |
< |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2659 |
< |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2658 |
> |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2659 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2660 |
|
} |
2661 |
|
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2662 |
|
else{ |
2663 |
< |
bool tempDecision = true; |
2664 |
< |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2665 |
< |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2666 |
< |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2667 |
< |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2663 |
> |
bool tempDecision = true; |
2664 |
> |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2665 |
> |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2666 |
> |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2667 |
> |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2668 |
|
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2669 |
< |
} |
2670 |
< |
decision = tempDecision; |
2669 |
> |
} |
2670 |
> |
decision = tempDecision; |
2671 |
|
} |
2672 |
|
} |
2673 |
|
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2674 |
|
|
2675 |
+ |
|
2676 |
|
//set flags for objects that pass each cut AND all the previous cuts |
2677 |
|
bool previousCumulativeFlag = true; |
2678 |
|
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
2681 |
|
} |
2682 |
|
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
2683 |
|
|
2684 |
+ |
|
2685 |
|
} |
2686 |
|
|
2687 |
|
} |
2689 |
|
|
2690 |
|
template <class InputCollection1, class InputCollection2> |
2691 |
|
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \ |
2692 |
< |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){ |
2692 |
> |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){ |
2693 |
|
|
2694 |
|
|
2695 |
|
bool sameObjects = false; |
2696 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2697 |
|
|
2698 |
< |
int counter = 0; |
2698 |
> |
|
2699 |
> |
int counter = 0; |
2700 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2701 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2702 |
< |
|
2702 |
> |
|
2703 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2704 |
|
|
2705 |
|
|
2707 |
|
|
2708 |
|
if(currentCut.inputCollection == inputType){ |
2709 |
|
|
2710 |
< |
vector<bool> subcutDecisions; |
2711 |
< |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2712 |
< |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2713 |
< |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2714 |
< |
} |
2710 |
> |
vector<bool> subcutDecisions; |
2711 |
> |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2712 |
> |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2713 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2714 |
> |
} |
2715 |
|
|
2716 |
< |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2717 |
< |
else{ |
2718 |
< |
bool tempDecision = true; |
2719 |
< |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2720 |
< |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2721 |
< |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2722 |
< |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2723 |
< |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2724 |
< |
} |
2725 |
< |
decision = tempDecision; |
2726 |
< |
} |
2716 |
> |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2717 |
> |
else{ |
2718 |
> |
bool tempDecision = subcutDecisions.at(0); |
2719 |
> |
for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){ |
2720 |
> |
if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&") |
2721 |
> |
tempDecision = tempDecision && subcutDecisions.at(subcutIndex); |
2722 |
> |
else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||") |
2723 |
> |
tempDecision = tempDecision || subcutDecisions.at(subcutIndex); |
2724 |
> |
} |
2725 |
> |
decision = tempDecision; |
2726 |
> |
} |
2727 |
|
} |
2728 |
|
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2729 |
< |
|
2729 |
> |
|
2730 |
|
//set flags for objects that pass each cut AND all the previous cuts |
2731 |
|
bool previousCumulativeFlag = true; |
2732 |
|
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
2733 |
< |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
2734 |
< |
else{ previousCumulativeFlag = false; break;} |
2733 |
> |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
2734 |
> |
else{ previousCumulativeFlag = false; break;} |
2735 |
|
} |
2736 |
< |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
2736 |
> |
//apply flags for the components of the composite object as well |
2737 |
> |
bool currentCumulativeFlag = true; |
2738 |
> |
if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision; |
2739 |
> |
else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2); |
2740 |
> |
else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1); |
2741 |
> |
else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2); |
2742 |
> |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag); |
2743 |
|
|
2744 |
< |
counter++; |
2744 |
> |
counter++; |
2745 |
|
} |
2746 |
< |
|
2746 |
> |
|
2747 |
|
} |
2748 |
|
|
2749 |
|
|
2751 |
|
|
2752 |
|
|
2753 |
|
template <class InputCollection> |
2754 |
< |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2754 |
> |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){ |
2755 |
|
|
2756 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2757 |
|
|
2761 |
|
string inputVariable = ""; |
2762 |
|
string function = ""; |
2763 |
|
if(currentString.find("(")==std::string::npos){ |
2764 |
< |
inputVariable = currentString;// variable to cut on |
2764 |
> |
inputVariable = currentString;// variable to cut on |
2765 |
|
} |
2766 |
|
else{ |
2767 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2768 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2769 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2767 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2768 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2769 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2770 |
|
} |
2771 |
|
|
2772 |
|
double value = valueLookup(&inputCollection->at(object), inputVariable, function); |
2773 |
< |
histo->Fill(value,puScaleFactor); |
2773 |
> |
histo->Fill(value,scaleFactor); |
2774 |
|
|
2775 |
+ |
if (printEventInfo_) { |
2776 |
+ |
// Write information about event to screen, for testing purposes. |
2777 |
+ |
cout << " Info for event: value for histogram " << histo->GetName() << ": " << value << endl; |
2778 |
+ |
} |
2779 |
+ |
|
2780 |
|
} |
1818 |
– |
|
2781 |
|
} |
2782 |
|
|
2783 |
|
template <class InputCollection1, class InputCollection2> |
2784 |
< |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2784 |
> |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){ |
2785 |
|
|
2786 |
|
bool sameObjects = false; |
2787 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2788 |
|
|
2789 |
< |
int counter = 0; |
2789 |
> |
int pairCounter = 0; |
2790 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2791 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2792 |
< |
|
2792 |
> |
|
2793 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2794 |
|
|
2795 |
|
//only take objects which have passed all cuts and pairs which have passed all cuts |
2796 |
|
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
2797 |
|
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
2798 |
< |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue; |
2798 |
> |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue; |
2799 |
|
|
2800 |
|
string currentString = parameters.inputVariables.at(0); |
2801 |
|
string inputVariable = ""; |
2802 |
|
string function = ""; |
2803 |
|
if(currentString.find("(")==std::string::npos){ |
2804 |
< |
inputVariable = currentString;// variable to cut on |
2804 |
> |
inputVariable = currentString;// variable to cut on |
2805 |
|
} |
2806 |
|
else{ |
2807 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2808 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2809 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2807 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2808 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2809 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2810 |
|
} |
2811 |
< |
|
2811 |
> |
|
2812 |
|
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2813 |
< |
histo->Fill(value,puScaleFactor); |
2813 |
> |
histo->Fill(value,scaleFactor); |
2814 |
|
|
2815 |
< |
counter++; |
2815 |
> |
pairCounter++; |
2816 |
|
} |
2817 |
|
} |
2818 |
|
|
2820 |
|
|
2821 |
|
|
2822 |
|
template <class InputCollection> |
2823 |
< |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2823 |
> |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){ |
2824 |
|
|
2825 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2826 |
|
|
2830 |
|
string inputVariable = ""; |
2831 |
|
string function = ""; |
2832 |
|
if(currentString.find("(")==std::string::npos){ |
2833 |
< |
inputVariable = currentString;// variable to cut on |
2833 |
> |
inputVariable = currentString;// variable to cut on |
2834 |
|
} |
2835 |
|
else{ |
2836 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2837 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2838 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2836 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2837 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2838 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2839 |
|
} |
2840 |
|
double valueX = valueLookup(&inputCollection->at(object), inputVariable, function); |
2841 |
|
|
2843 |
|
inputVariable = ""; |
2844 |
|
function = ""; |
2845 |
|
if(currentString.find("(")==std::string::npos){ |
2846 |
< |
inputVariable = currentString;// variable to cut on |
2846 |
> |
inputVariable = currentString;// variable to cut on |
2847 |
|
} |
2848 |
|
else{ |
2849 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2850 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2851 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2849 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2850 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2851 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2852 |
|
} |
2853 |
|
|
2854 |
|
double valueY = valueLookup(&inputCollection->at(object), inputVariable, function); |
2855 |
|
|
2856 |
< |
histo->Fill(valueX,valueY,puScaleFactor); |
2856 |
> |
histo->Fill(valueX,valueY,scaleFactor); |
2857 |
|
|
2858 |
|
} |
2859 |
|
|
2860 |
|
} |
2861 |
|
|
2862 |
|
template <class InputCollection1, class InputCollection2> |
2863 |
< |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2863 |
> |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){ |
2864 |
|
|
2865 |
|
bool sameObjects = false; |
2866 |
|
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2867 |
|
|
2868 |
< |
int counter = 0; |
2868 |
> |
int pairCounter = 0; |
2869 |
|
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2870 |
|
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2871 |
< |
|
2871 |
> |
|
2872 |
|
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2873 |
|
|
2874 |
|
//only take objects which have passed all cuts and pairs which have passed all cuts |
2875 |
|
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
2876 |
|
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
2877 |
< |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue; |
2877 |
> |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue; |
2878 |
|
|
2879 |
|
string currentString = parameters.inputVariables.at(0); |
2880 |
|
string inputVariable = ""; |
2881 |
|
string function = ""; |
2882 |
|
if(currentString.find("(")==std::string::npos){ |
2883 |
< |
inputVariable = currentString;// variable to cut on |
2883 |
> |
inputVariable = currentString;// variable to cut on |
2884 |
|
} |
2885 |
|
else{ |
2886 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2887 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2888 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2886 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2887 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2888 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2889 |
|
} |
2890 |
|
double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2891 |
|
|
2893 |
|
inputVariable = ""; |
2894 |
|
function = ""; |
2895 |
|
if(currentString.find("(")==std::string::npos){ |
2896 |
< |
inputVariable = currentString;// variable to cut on |
2896 |
> |
inputVariable = currentString;// variable to cut on |
2897 |
|
} |
2898 |
|
else{ |
2899 |
< |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2900 |
< |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2901 |
< |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2899 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2900 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2901 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2902 |
|
} |
2903 |
|
double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2904 |
|
|
2905 |
|
|
2906 |
< |
histo->Fill(valueX,valueY,puScaleFactor); |
2906 |
> |
histo->Fill(valueX,valueY,scaleFactor); |
2907 |
> |
|
2908 |
> |
pairCounter++; |
2909 |
|
|
1946 |
– |
counter++; |
2910 |
|
} |
2911 |
|
} |
2912 |
|
|
2913 |
|
} |
2914 |
|
|
2915 |
|
|
2916 |
+ |
template <class InputObject> |
2917 |
+ |
int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){ |
2918 |
|
|
2919 |
< |
DEFINE_FWK_MODULE(OSUAnalysis); |
2919 |
> |
int bestMatchIndex = -1; |
2920 |
> |
double bestMatchDeltaR = 999; |
2921 |
> |
|
2922 |
> |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2923 |
> |
|
2924 |
> |
double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi); |
2925 |
> |
if(currentDeltaR > 0.05) continue; |
2926 |
> |
// cout << std::setprecision(3) << std::setw(20) |
2927 |
> |
// << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta |
2928 |
> |
// << std::setw(20) |
2929 |
> |
// << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi |
2930 |
> |
// << std::setw(20) |
2931 |
> |
// << "\tdeltaR = " << currentDeltaR |
2932 |
> |
// << std::setprecision(1) |
2933 |
> |
// << std::setw(20) |
2934 |
> |
// << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id |
2935 |
> |
// << std::setw(20) |
2936 |
> |
// << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId |
2937 |
> |
// << std::setw(20) |
2938 |
> |
// << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl; |
2939 |
> |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2940 |
> |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2941 |
> |
bestMatchDeltaR = currentDeltaR; |
2942 |
> |
} |
2943 |
> |
|
2944 |
> |
} |
2945 |
> |
// if(bestMatchDeltaR != 999) cout << "bestMatch: deltaR = " << bestMatchDeltaR << " id = " << mcparticles->at(bestMatchIndex).id << " motherId = " << mcparticles->at(bestMatchIndex).motherId << endl; |
2946 |
> |
// else cout << "no match found..." << endl; |
2947 |
> |
return bestMatchIndex; |
2948 |
> |
|
2949 |
> |
} |
2950 |
> |
|
2951 |
> |
|
2952 |
> |
int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){ |
2953 |
> |
|
2954 |
> |
int bestMatchIndex = -1; |
2955 |
> |
double bestMatchDeltaR = 999; |
2956 |
> |
|
2957 |
> |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2958 |
> |
|
2959 |
> |
if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue; |
2960 |
|
|
2961 |
+ |
double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi); |
2962 |
+ |
if(currentDeltaR > 0.05) continue; |
2963 |
|
|
2964 |
+ |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2965 |
+ |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2966 |
+ |
bestMatchDeltaR = currentDeltaR; |
2967 |
+ |
} |
2968 |
+ |
|
2969 |
+ |
} |
2970 |
+ |
|
2971 |
+ |
return bestMatchIndex; |
2972 |
+ |
} |
2973 |
+ |
|
2974 |
+ |
|
2975 |
+ |
// bin particle type |
2976 |
+ |
// --- ------------- |
2977 |
+ |
// 0 unmatched |
2978 |
+ |
// 1 u |
2979 |
+ |
// 2 d |
2980 |
+ |
// 3 s |
2981 |
+ |
// 4 c |
2982 |
+ |
// 5 b |
2983 |
+ |
// 6 t |
2984 |
+ |
// 7 e |
2985 |
+ |
// 8 mu |
2986 |
+ |
// 9 tau |
2987 |
+ |
// 10 nu |
2988 |
+ |
// 11 g |
2989 |
+ |
// 12 gamma |
2990 |
+ |
// 13 Z |
2991 |
+ |
// 14 W |
2992 |
+ |
// 15 light meson |
2993 |
+ |
// 16 K meson |
2994 |
+ |
// 17 D meson |
2995 |
+ |
// 18 B meson |
2996 |
+ |
// 19 light baryon |
2997 |
+ |
// 20 strange baryon |
2998 |
+ |
// 21 charm baryon |
2999 |
+ |
// 22 bottom baryon |
3000 |
+ |
// 23 other |
3001 |
+ |
|
3002 |
+ |
int OSUAnalysis::getPdgIdBinValue(int pdgId){ |
3003 |
+ |
|
3004 |
+ |
int binValue = -999; |
3005 |
+ |
int absPdgId = fabs(pdgId); |
3006 |
+ |
if(pdgId == -1) binValue = 0; |
3007 |
+ |
else if(absPdgId <= 6 ) binValue = absPdgId; |
3008 |
+ |
else if(absPdgId == 11 ) binValue = 7; |
3009 |
+ |
else if(absPdgId == 13 ) binValue = 8; |
3010 |
+ |
else if(absPdgId == 15 ) binValue = 9; |
3011 |
+ |
else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10; |
3012 |
+ |
else if(absPdgId == 21 ) binValue = 11; |
3013 |
+ |
else if(absPdgId == 22 ) binValue = 12; |
3014 |
+ |
else if(absPdgId == 23 ) binValue = 13; |
3015 |
+ |
else if(absPdgId == 24 ) binValue = 14; |
3016 |
+ |
else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130 ) binValue = 15; |
3017 |
+ |
else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400) ) binValue = 16; |
3018 |
+ |
else if(absPdgId > 400 && absPdgId < 500 ) binValue = 17; |
3019 |
+ |
else if(absPdgId > 500 && absPdgId < 600 ) binValue = 18; |
3020 |
+ |
else if(absPdgId > 1000 && absPdgId < 3000 ) binValue = 19; |
3021 |
+ |
else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20; |
3022 |
+ |
else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21; |
3023 |
+ |
else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22; |
3024 |
+ |
|
3025 |
+ |
else binValue = 23; |
3026 |
+ |
|
3027 |
+ |
return binValue; |
3028 |
+ |
|
3029 |
+ |
} |
3030 |
+ |
|
3031 |
+ |
const BNprimaryvertex * |
3032 |
+ |
OSUAnalysis::chosenVertex () |
3033 |
+ |
{ |
3034 |
+ |
const BNprimaryvertex *chosenVertex = 0; |
3035 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) { |
3036 |
+ |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() : |
3037 |
+ |
cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2); |
3038 |
+ |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
3039 |
+ |
if(!vertexFlags.at(vertexIndex)) continue; |
3040 |
+ |
chosenVertex = & primaryvertexs->at(vertexIndex); |
3041 |
+ |
break; |
3042 |
+ |
} |
3043 |
+ |
} |
3044 |
+ |
else { |
3045 |
+ |
chosenVertex = &primaryvertexs->at(0); |
3046 |
+ |
} |
3047 |
+ |
|
3048 |
+ |
return chosenVertex; |
3049 |
+ |
} |
3050 |
+ |
|
3051 |
+ |
const BNmet * |
3052 |
+ |
OSUAnalysis::chosenMET () |
3053 |
+ |
{ |
3054 |
+ |
const BNmet *chosenMET = 0; |
3055 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) { |
3056 |
+ |
vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() : |
3057 |
+ |
cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2); |
3058 |
+ |
for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){ |
3059 |
+ |
if(!metFlags.at(metIndex)) continue; |
3060 |
+ |
chosenMET = & mets->at(metIndex); |
3061 |
+ |
break; |
3062 |
+ |
} |
3063 |
+ |
} |
3064 |
+ |
else { |
3065 |
+ |
chosenMET = &mets->at(0); |
3066 |
+ |
} |
3067 |
+ |
|
3068 |
+ |
return chosenMET; |
3069 |
+ |
} |
3070 |
+ |
|
3071 |
+ |
const BNelectron * |
3072 |
+ |
OSUAnalysis::chosenElectron () |
3073 |
+ |
{ |
3074 |
+ |
const BNelectron *chosenElectron = 0; |
3075 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) { |
3076 |
+ |
vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() : |
3077 |
+ |
cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2); |
3078 |
+ |
for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){ |
3079 |
+ |
if(!electronFlags.at(electronIndex)) continue; |
3080 |
+ |
chosenElectron = & electrons->at(electronIndex); |
3081 |
+ |
break; |
3082 |
+ |
} |
3083 |
+ |
} |
3084 |
+ |
else { |
3085 |
+ |
chosenElectron = &electrons->at(0); |
3086 |
+ |
} |
3087 |
+ |
|
3088 |
+ |
return chosenElectron; |
3089 |
+ |
} |
3090 |
+ |
|
3091 |
+ |
const BNmuon * |
3092 |
+ |
OSUAnalysis::chosenMuon () |
3093 |
+ |
{ |
3094 |
+ |
const BNmuon *chosenMuon = 0; |
3095 |
+ |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) { |
3096 |
+ |
vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() : |
3097 |
+ |
cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2); |
3098 |
+ |
for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){ |
3099 |
+ |
if(!muonFlags.at(muonIndex)) continue; |
3100 |
+ |
chosenMuon = & muons->at(muonIndex); |
3101 |
+ |
break; |
3102 |
+ |
} |
3103 |
+ |
} |
3104 |
+ |
else { |
3105 |
+ |
chosenMuon = &muons->at(0); |
3106 |
+ |
} |
3107 |
+ |
|
3108 |
+ |
return chosenMuon; |
3109 |
+ |
} |
3110 |
+ |
|
3111 |
+ |
|
3112 |
+ |
DEFINE_FWK_MODULE(OSUAnalysis); |