16 |
|
photons_ (cfg.getParameter<edm::InputTag> ("photons")), |
17 |
|
superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")), |
18 |
|
triggers_ (cfg.getParameter<edm::InputTag> ("triggers")), |
19 |
< |
|
20 |
< |
|
19 |
> |
puFile_ (cfg.getParameter<std::string> ("puFile")), |
20 |
> |
deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")), |
21 |
> |
dataPU_ (cfg.getParameter<std::string> ("dataPU")), |
22 |
> |
dataset_ (cfg.getParameter<std::string> ("dataset")), |
23 |
> |
datasetType_ (cfg.getParameter<std::string> ("datasetType")), |
24 |
|
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
25 |
< |
|
26 |
< |
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")) |
25 |
> |
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
26 |
> |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")) |
27 |
|
|
28 |
|
{ |
29 |
|
|
27 |
– |
|
30 |
|
TH1::SetDefaultSumw2 (); |
31 |
< |
TH2::SetDefaultSumw2 (); |
31 |
> |
|
32 |
> |
//create pile-up reweighting object, if necessary |
33 |
> |
if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
34 |
|
|
35 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
36 |
|
// handle filling cut flow histograms. |
38 |
|
std::vector<TFileDirectory> directories; |
39 |
|
|
40 |
|
//always get vertex collection so we can assign the primary vertex in the event |
41 |
< |
allNecessaryObjects.push_back("primaryvertexs"); |
41 |
> |
|
42 |
> |
objectsToGet.push_back("primaryvertexs"); |
43 |
> |
//always make the plot of number of primary verticex (to check pile-up reweighting) |
44 |
> |
objectsToPlot.push_back("primaryvertexs"); |
45 |
> |
|
46 |
> |
//always get the MC particles to do GEN-matching |
47 |
> |
objectsToGet.push_back("mcparticles"); |
48 |
|
|
49 |
+ |
//always get the event collection to do pile-up reweighting |
50 |
+ |
objectsToGet.push_back("events"); |
51 |
|
|
52 |
|
//parse the histogram definitions |
53 |
|
for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){ |
54 |
|
|
55 |
< |
string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string>("inputCollection"); |
56 |
< |
objectsToPlot.push_back(tempInputCollection); |
57 |
< |
allNecessaryObjects.push_back(tempInputCollection); |
55 |
> |
string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection"); |
56 |
> |
if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs"; |
57 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
58 |
> |
objectsToGet.push_back(tempInputCollection); |
59 |
> |
objectsToPlot.push_back(tempInputCollection); |
60 |
> |
objectsToCut.push_back(tempInputCollection); |
61 |
> |
} |
62 |
> |
else{//pair of objects, need to add them both to the things to objectsToGet |
63 |
> |
int dashIndex = tempInputCollection.find("-"); |
64 |
> |
int spaceIndex = tempInputCollection.find(" "); |
65 |
> |
int secondWordLength = spaceIndex - dashIndex; |
66 |
> |
objectsToGet.push_back(tempInputCollection); |
67 |
> |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
68 |
> |
objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
69 |
> |
objectsToPlot.push_back(tempInputCollection); |
70 |
> |
objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
71 |
> |
objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
72 |
> |
objectsToCut.push_back(tempInputCollection); |
73 |
> |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
74 |
> |
objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
75 |
> |
|
76 |
> |
} |
77 |
> |
|
78 |
|
vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms")); |
79 |
|
|
80 |
|
for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){ |
85 |
|
tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title"); |
86 |
|
tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins"); |
87 |
|
tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables"); |
56 |
– |
if(histogramList_.at(currentHistogram).exists("function")) |
57 |
– |
tempHistogram.function = histogramList_.at(currentHistogram).getParameter<string>("function"); |
58 |
– |
else |
59 |
– |
tempHistogram.function = ""; |
88 |
|
|
89 |
|
histograms.push_back(tempHistogram); |
90 |
|
|
91 |
|
} |
92 |
|
} |
93 |
+ |
//make unique vector of objects we need to plot (so we can book a histogram with the number of each object) |
94 |
+ |
sort( objectsToPlot.begin(), objectsToPlot.end() ); |
95 |
+ |
objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() ); |
96 |
+ |
|
97 |
+ |
|
98 |
+ |
|
99 |
+ |
//add histograms with the gen-matched id, mother id, and grandmother id |
100 |
+ |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
101 |
+ |
|
102 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
103 |
+ |
if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue; |
104 |
+ |
|
105 |
+ |
histogram tempIdHisto; |
106 |
+ |
histogram tempMomIdHisto; |
107 |
+ |
histogram tempGmaIdHisto; |
108 |
+ |
|
109 |
+ |
tempIdHisto.inputCollection = currentObject; |
110 |
+ |
tempMomIdHisto.inputCollection = currentObject; |
111 |
+ |
tempGmaIdHisto.inputCollection = currentObject; |
112 |
+ |
|
113 |
+ |
currentObject = currentObject.substr(0, currentObject.size()-1); |
114 |
+ |
tempIdHisto.name = currentObject+"GenMatchId"; |
115 |
+ |
tempMomIdHisto.name = currentObject+"GenMatchMotherId"; |
116 |
+ |
tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId"; |
117 |
+ |
|
118 |
+ |
currentObject.at(0) = toupper(currentObject.at(0)); |
119 |
+ |
tempIdHisto.title = currentObject+" Gen-matched Particle"; |
120 |
+ |
tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother"; |
121 |
+ |
tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother"; |
122 |
+ |
|
123 |
+ |
int maxNum = 24; |
124 |
+ |
vector<double> binVector; |
125 |
+ |
binVector.push_back(maxNum); |
126 |
+ |
binVector.push_back(0); |
127 |
+ |
binVector.push_back(maxNum); |
128 |
+ |
|
129 |
+ |
tempIdHisto.bins = binVector; |
130 |
+ |
tempIdHisto.inputVariables.push_back("genMatchedId"); |
131 |
+ |
tempMomIdHisto.bins = binVector; |
132 |
+ |
tempMomIdHisto.inputVariables.push_back("genMatchedMotherId"); |
133 |
+ |
tempGmaIdHisto.bins = binVector; |
134 |
+ |
tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId"); |
135 |
+ |
|
136 |
+ |
histograms.push_back(tempIdHisto); |
137 |
+ |
histograms.push_back(tempMomIdHisto); |
138 |
+ |
histograms.push_back(tempGmaIdHisto); |
139 |
+ |
|
140 |
+ |
} |
141 |
|
|
142 |
|
|
143 |
|
|
158 |
|
triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers"); |
159 |
|
for(uint trigger = 0; trigger!= triggerNames.size(); trigger++) |
160 |
|
tempChannel.triggers.push_back(triggerNames.at(trigger)); |
161 |
< |
allNecessaryObjects.push_back("triggers"); |
161 |
> |
objectsToGet.push_back("triggers"); |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
+ |
|
167 |
|
//create cutFlow for this channel |
168 |
|
cutFlows_.push_back (new CutFlow (fs_, channelName)); |
169 |
|
|
176 |
|
std::map<std::string, TH2D*> twoDhistoMap; |
177 |
|
twoDHists_.push_back(twoDhistoMap); |
178 |
|
|
179 |
+ |
|
180 |
|
//book all histograms included in the configuration |
181 |
|
for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
182 |
|
histogram currentHistogram = histograms.at(currentHistogramIndex); |
183 |
|
int numBinsElements = currentHistogram.bins.size(); |
184 |
|
int numInputVariables = currentHistogram.inputVariables.size(); |
185 |
+ |
|
186 |
|
if(numBinsElements != 3 && numBinsElements !=6) { |
187 |
|
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
188 |
|
exit(0); |
191 |
|
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
192 |
|
exit(0); |
193 |
|
} |
194 |
< |
else if(numBinsElements == 3) |
194 |
> |
else if(numBinsElements == 3){ |
195 |
|
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)); |
196 |
< |
else if(numBinsElements == 6) |
196 |
> |
} |
197 |
> |
else if(numBinsElements == 6){ |
198 |
|
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)); |
199 |
|
|
200 |
+ |
} |
201 |
+ |
|
202 |
|
|
203 |
+ |
if(currentHistogram.name.find("GenMatch")==std::string::npos) continue; |
204 |
+ |
|
205 |
+ |
// bin particle type |
206 |
+ |
// --- ------------- |
207 |
+ |
// 0 unmatched |
208 |
+ |
// 1 u |
209 |
+ |
// 2 d |
210 |
+ |
// 3 s |
211 |
+ |
// 4 c |
212 |
+ |
// 5 b |
213 |
+ |
// 6 t |
214 |
+ |
// 7 e |
215 |
+ |
// 8 mu |
216 |
+ |
// 9 tau |
217 |
+ |
// 10 nu |
218 |
+ |
// 11 g |
219 |
+ |
// 12 gamma |
220 |
+ |
// 13 Z |
221 |
+ |
// 14 W |
222 |
+ |
// 15 light meson |
223 |
+ |
// 16 K meson |
224 |
+ |
// 17 D meson |
225 |
+ |
// 18 B meson |
226 |
+ |
// 19 light baryon |
227 |
+ |
// 20 strange baryon |
228 |
+ |
// 21 charm baryon |
229 |
+ |
// 22 bottom baryon |
230 |
+ |
// 23 other |
231 |
+ |
|
232 |
+ |
vector<TString> labelArray; |
233 |
+ |
labelArray.push_back("unmatched"); |
234 |
+ |
labelArray.push_back("u"); |
235 |
+ |
labelArray.push_back("d"); |
236 |
+ |
labelArray.push_back("s"); |
237 |
+ |
labelArray.push_back("c"); |
238 |
+ |
labelArray.push_back("b"); |
239 |
+ |
labelArray.push_back("t"); |
240 |
+ |
labelArray.push_back("e"); |
241 |
+ |
labelArray.push_back("#mu"); |
242 |
+ |
labelArray.push_back("#tau"); |
243 |
+ |
labelArray.push_back("#nu"); |
244 |
+ |
labelArray.push_back("g"); |
245 |
+ |
labelArray.push_back("#gamma"); |
246 |
+ |
labelArray.push_back("Z"); |
247 |
+ |
labelArray.push_back("W"); |
248 |
+ |
labelArray.push_back("light meson"); |
249 |
+ |
labelArray.push_back("K meson"); |
250 |
+ |
labelArray.push_back("D meson"); |
251 |
+ |
labelArray.push_back("B meson"); |
252 |
+ |
labelArray.push_back("light baryon"); |
253 |
+ |
labelArray.push_back("strange baryon"); |
254 |
+ |
labelArray.push_back("charm baryon"); |
255 |
+ |
labelArray.push_back("bottom baryon"); |
256 |
+ |
labelArray.push_back("other"); |
257 |
+ |
|
258 |
+ |
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
259 |
+ |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
260 |
+ |
} |
261 |
|
} |
262 |
|
//book a histogram for the number of each object type to be plotted |
263 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
264 |
|
string currentObject = objectsToPlot.at(currentObjectIndex); |
265 |
|
int maxNum = 10; |
266 |
|
if(currentObject == "mcparticles") maxNum = 50; |
267 |
< |
currentObject[0] = toupper(currentObject[0]); |
267 |
> |
else if(currentObject == "primaryvertexs") maxNum = 50; |
268 |
> |
else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
269 |
> |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
270 |
> |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
271 |
> |
|
272 |
> |
currentObject.at(0) = toupper(currentObject.at(0)); |
273 |
|
string histoName = "num" + currentObject; |
274 |
< |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
274 |
> |
|
275 |
> |
if(histoName == "numPrimaryvertexs"){ |
276 |
> |
string newHistoName = histoName + "BeforePileupCorrection"; |
277 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
278 |
> |
newHistoName = histoName + "AfterPileupCorrection"; |
279 |
> |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
280 |
> |
} |
281 |
> |
else |
282 |
> |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
+ |
|
287 |
+ |
|
288 |
+ |
|
289 |
|
//get list of cuts for this channel |
290 |
|
vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts")); |
291 |
|
|
292 |
|
//loop over and parse all cuts |
293 |
|
for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){ |
138 |
– |
|
294 |
|
cut tempCut; |
295 |
< |
//store input collection for cut |
296 |
< |
string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
297 |
< |
tempCut.inputCollection = inputCollection; |
298 |
< |
allNecessaryObjects.push_back(inputCollection); |
295 |
> |
//store input collection for cut |
296 |
> |
string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
297 |
> |
tempCut.inputCollection = tempInputCollection; |
298 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
299 |
> |
objectsToGet.push_back(tempInputCollection); |
300 |
> |
objectsToCut.push_back(tempInputCollection); |
301 |
> |
} |
302 |
> |
else{//pair of objects, need to add them both to the things to objectsToGet |
303 |
> |
int dashIndex = tempInputCollection.find("-"); |
304 |
> |
int spaceIndex = tempInputCollection.find(" "); |
305 |
> |
int secondWordLength = spaceIndex - dashIndex; |
306 |
> |
objectsToGet.push_back(tempInputCollection); |
307 |
> |
objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
308 |
> |
objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
309 |
> |
objectsToCut.push_back(tempInputCollection); |
310 |
> |
objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
311 |
> |
objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
312 |
> |
|
313 |
> |
} |
314 |
> |
|
315 |
> |
|
316 |
|
|
317 |
|
//split cut string into parts and store them |
318 |
|
string cutString = cuts_.at(currentCut).getParameter<string> ("cutString"); |
319 |
|
std::vector<string> cutStringVector = splitString(cutString); |
320 |
< |
if(cutStringVector.size()!=3){ |
321 |
< |
std::cout << "Error: Didn't find three elements in the following cut string: '" <<cutString << "'\n"; |
320 |
> |
if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){ |
321 |
> |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
322 |
|
exit(0); |
323 |
|
} |
324 |
< |
|
325 |
< |
tempCut.variable = cutStringVector.at(0);// variable to cut on |
326 |
< |
tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make |
327 |
< |
tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut |
324 |
> |
tempCut.numSubcuts = (cutStringVector.size()+1)/4; |
325 |
> |
for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,| |
326 |
> |
int indexOffset = 4 * subcutIndex; |
327 |
> |
string currentVariableString = cutStringVector.at(indexOffset); |
328 |
> |
if(currentVariableString.find("(")==std::string::npos){ |
329 |
> |
tempCut.functions.push_back("");//no function was specified |
330 |
> |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
331 |
> |
} |
332 |
> |
else{ |
333 |
> |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
334 |
> |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
335 |
> |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
336 |
> |
} |
337 |
> |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
338 |
> |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
339 |
> |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
340 |
> |
} |
341 |
|
|
342 |
|
//get number of objects required to pass cut for event to pass |
343 |
|
string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired"); |
347 |
|
exit(0); |
348 |
|
} |
349 |
|
|
165 |
– |
// determine number required if comparison contains "=" |
350 |
|
int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str()); |
167 |
– |
if(numberRequiredVector.at(0) == ">") numberRequiredInt++; |
168 |
– |
else if(numberRequiredVector.at(0) == "<") numberRequiredInt--; |
169 |
– |
|
351 |
|
tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut |
352 |
|
tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make |
353 |
|
|
354 |
< |
if(cuts_.at(currentCut).exists("function")){ |
174 |
< |
tempCut.function = cuts_.at(currentCut).getParameter<string> ("function"); |
175 |
< |
} |
176 |
< |
else tempCut.function = ""; |
354 |
> |
|
355 |
|
string tempCutName; |
356 |
|
if(cuts_.at(currentCut).exists("alias")){ |
357 |
|
tempCutName = cuts_.at(currentCut).getParameter<string> ("alias"); |
359 |
|
else{ |
360 |
|
//construct string for cutflow table |
361 |
|
bool plural = numberRequiredInt != 1; |
362 |
< |
string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1); |
362 |
> |
string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1); |
363 |
|
string cutName = numberRequiredString + " " + collectionString + " with " + cutString; |
364 |
|
tempCutName = cutName; |
365 |
|
} |
372 |
|
|
373 |
|
}//end loop over cuts |
374 |
|
|
197 |
– |
|
375 |
|
channels.push_back(tempChannel); |
376 |
|
tempChannel.cuts.clear(); |
377 |
|
|
378 |
|
}//end loop over channels |
379 |
|
|
380 |
|
|
381 |
< |
|
382 |
< |
|
383 |
< |
//make unique vector of objects we need to cut on (so we make sure to get them from the event) |
384 |
< |
sort( allNecessaryObjects.begin(), allNecessaryObjects.end() ); |
385 |
< |
allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() ); |
381 |
> |
//make unique vector of objects we need to get from the event |
382 |
> |
sort( objectsToGet.begin(), objectsToGet.end() ); |
383 |
> |
objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() ); |
384 |
> |
//make unique vector of objects we need to cut on |
385 |
> |
sort( objectsToCut.begin(), objectsToCut.end() ); |
386 |
> |
objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() ); |
387 |
|
|
388 |
|
|
389 |
|
} |
401 |
|
OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup) |
402 |
|
{ |
403 |
|
|
226 |
– |
|
404 |
|
// Retrieve necessary collections from the event. |
405 |
< |
edm::Handle<BNtriggerCollection> triggers; |
406 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end()) |
405 |
> |
|
406 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end()) |
407 |
|
event.getByLabel (triggers_, triggers); |
408 |
|
|
409 |
< |
edm::Handle<BNjetCollection> jets; |
233 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end()) |
409 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end()) |
410 |
|
event.getByLabel (jets_, jets); |
411 |
|
|
412 |
< |
edm::Handle<BNmuonCollection> muons; |
237 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end()) |
412 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end()) |
413 |
|
event.getByLabel (muons_, muons); |
414 |
|
|
415 |
< |
edm::Handle<BNelectronCollection> electrons; |
241 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end()) |
415 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end()) |
416 |
|
event.getByLabel (electrons_, electrons); |
417 |
|
|
418 |
< |
edm::Handle<BNeventCollection> events; |
245 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end()) |
418 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end()) |
419 |
|
event.getByLabel (events_, events); |
420 |
|
|
421 |
< |
edm::Handle<BNtauCollection> taus; |
249 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end()) |
421 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end()) |
422 |
|
event.getByLabel (taus_, taus); |
423 |
|
|
424 |
< |
edm::Handle<BNmetCollection> mets; |
253 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end()) |
424 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end()) |
425 |
|
event.getByLabel (mets_, mets); |
426 |
|
|
427 |
< |
edm::Handle<BNtrackCollection> tracks; |
257 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end()) |
427 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end()) |
428 |
|
event.getByLabel (tracks_, tracks); |
429 |
|
|
430 |
< |
edm::Handle<BNgenjetCollection> genjets; |
261 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end()) |
430 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end()) |
431 |
|
event.getByLabel (genjets_, genjets); |
432 |
|
|
433 |
< |
edm::Handle<BNmcparticleCollection> mcparticles; |
265 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end()) |
433 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end()) |
434 |
|
event.getByLabel (mcparticles_, mcparticles); |
435 |
|
|
436 |
< |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
269 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end()) |
436 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end()) |
437 |
|
event.getByLabel (primaryvertexs_, primaryvertexs); |
438 |
|
|
439 |
< |
edm::Handle<BNbxlumiCollection> bxlumis; |
273 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end()) |
439 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end()) |
440 |
|
event.getByLabel (bxlumis_, bxlumis); |
441 |
|
|
442 |
< |
edm::Handle<BNphotonCollection> photons; |
277 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end()) |
442 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end()) |
443 |
|
event.getByLabel (photons_, photons); |
444 |
|
|
445 |
< |
edm::Handle<BNsuperclusterCollection> superclusters; |
281 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end()) |
445 |
> |
if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end()) |
446 |
|
event.getByLabel (superclusters_, superclusters); |
447 |
|
|
448 |
|
|
449 |
+ |
//get pile-up event weight |
450 |
+ |
double puScaleFactor = 1.00; |
451 |
+ |
if(datasetType_ != "data") |
452 |
+ |
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
453 |
+ |
|
454 |
|
//loop over all channels |
455 |
|
|
456 |
|
for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){ |
467 |
|
} |
468 |
|
|
469 |
|
//loop over all cuts |
470 |
+ |
|
471 |
+ |
|
472 |
+ |
|
473 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
474 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
475 |
|
|
476 |
< |
for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){ |
476 |
> |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
477 |
> |
string currentObject = objectsToCut.at(currentObjectIndex); |
478 |
|
|
479 |
< |
string currentObject = allNecessaryObjects.at(currentObjectIndex); |
479 |
> |
//initialize maps to get ready to set cuts |
480 |
|
individualFlags[currentObject].push_back (vector<bool> ()); |
481 |
|
cumulativeFlags[currentObject].push_back (vector<bool> ()); |
482 |
|
|
483 |
+ |
} |
484 |
+ |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){ |
485 |
+ |
string currentObject = objectsToCut.at(currentObjectIndex); |
486 |
+ |
|
487 |
+ |
int flagsForPairCutsIndex = max(int(currentCutIndex-1),0); |
488 |
+ |
|
489 |
|
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
490 |
|
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
491 |
|
else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons"); |
500 |
|
else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons"); |
501 |
|
else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters"); |
502 |
|
|
503 |
+ |
|
504 |
+ |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \ |
505 |
+ |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
506 |
+ |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
507 |
+ |
"muon-muon pairs"); |
508 |
+ |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \ |
509 |
+ |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
510 |
+ |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
511 |
+ |
"electron-electron pairs"); |
512 |
+ |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \ |
513 |
+ |
cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \ |
514 |
+ |
cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \ |
515 |
+ |
"electron-muon pairs"); |
516 |
+ |
|
517 |
|
|
518 |
|
} |
519 |
|
|
522 |
|
}//end loop over all cuts |
523 |
|
|
524 |
|
|
332 |
– |
|
333 |
– |
|
525 |
|
//use cumulative flags to apply cuts at event level |
526 |
|
|
527 |
|
bool eventPassedAllCuts = true; |
530 |
|
eventPassedAllCuts = eventPassedAllCuts && triggerDecision; |
531 |
|
|
532 |
|
|
533 |
+ |
|
534 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
535 |
|
|
536 |
|
//loop over all objects and count how many passed the cumulative selection up to this point |
537 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
538 |
|
int numberPassing = 0; |
539 |
|
|
540 |
< |
for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++) |
541 |
< |
if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++; |
542 |
< |
|
540 |
> |
for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){ |
541 |
> |
if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++; |
542 |
> |
} |
543 |
|
|
544 |
|
bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired); |
545 |
|
cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision; |
548 |
|
|
549 |
|
} |
550 |
|
|
551 |
< |
cutFlows_.at(currentChannelIndex)->fillCutFlow(); |
551 |
> |
cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor); |
552 |
> |
|
553 |
|
|
554 |
|
|
555 |
|
if(!eventPassedAllCuts)continue; |
556 |
|
|
557 |
|
|
558 |
+ |
|
559 |
+ |
|
560 |
|
//set position of primary vertex in event, in order to calculate quantities relative to it |
561 |
< |
primaryVertex_ = 0; |
562 |
< |
vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back(); |
563 |
< |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
564 |
< |
if(!vertexFlags.at(vertexIndex)) continue; |
565 |
< |
primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex)); |
566 |
< |
break; |
561 |
> |
if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) { |
562 |
> |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back(); |
563 |
> |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
564 |
> |
if(!vertexFlags.at(vertexIndex)) continue; |
565 |
> |
chosenPrimaryVertex = & primaryvertexs->at(vertexIndex); |
566 |
> |
break; |
567 |
> |
} |
568 |
> |
} |
569 |
> |
else { |
570 |
> |
chosenPrimaryVertex = & primaryvertexs->at(0); |
571 |
|
} |
572 |
|
|
573 |
|
|
579 |
|
if(currentHistogram.inputVariables.size() == 1){ |
580 |
|
TH1D* histo; |
581 |
|
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
582 |
< |
if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product()); |
583 |
< |
else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product()); |
584 |
< |
else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product()); |
585 |
< |
else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product()); |
586 |
< |
else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product()); |
587 |
< |
else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product()); |
588 |
< |
else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product()); |
589 |
< |
else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product()); |
590 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product()); |
591 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product()); |
592 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product()); |
593 |
< |
else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product()); |
594 |
< |
else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product()); |
582 |
> |
|
583 |
> |
|
584 |
> |
|
585 |
> |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
586 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
587 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\ |
588 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\ |
589 |
> |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
590 |
> |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
591 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
592 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
593 |
> |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
594 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
595 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
596 |
> |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
597 |
> |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
598 |
> |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
599 |
> |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
600 |
> |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
601 |
> |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
602 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
603 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
604 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
605 |
> |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
606 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
607 |
|
} |
608 |
|
else if(currentHistogram.inputVariables.size() == 2){ |
609 |
|
TH2D* histo; |
610 |
|
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
611 |
< |
if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product()); |
612 |
< |
else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product()); |
613 |
< |
else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product()); |
614 |
< |
else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product()); |
615 |
< |
else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product()); |
616 |
< |
else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product()); |
617 |
< |
else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product()); |
618 |
< |
else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product()); |
619 |
< |
else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product()); |
620 |
< |
else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product()); |
621 |
< |
else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product()); |
622 |
< |
else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product()); |
623 |
< |
else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product()); |
611 |
> |
|
612 |
> |
|
613 |
> |
|
614 |
> |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
615 |
> |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
616 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
617 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
618 |
> |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
619 |
> |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
620 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
621 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
622 |
> |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
623 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
624 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
625 |
> |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
626 |
> |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
627 |
> |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
628 |
> |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
629 |
> |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
630 |
> |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
631 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
632 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
633 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
634 |
> |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
635 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
636 |
|
} |
637 |
|
} |
638 |
|
|
416 |
– |
|
639 |
|
//fills histograms with the sizes of collections |
640 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
641 |
|
string currentObject = objectsToPlot.at(currentObjectIndex); |
642 |
< |
string tempCurrentObject = currentObject; |
643 |
< |
tempCurrentObject[0] = toupper(tempCurrentObject[0]); |
642 |
> |
|
643 |
> |
string objectToPlot = ""; |
644 |
> |
|
645 |
> |
if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs"; |
646 |
> |
else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs"; |
647 |
> |
else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs"; |
648 |
> |
else objectToPlot = currentObject; |
649 |
> |
string tempCurrentObject = objectToPlot; |
650 |
> |
tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0)); |
651 |
|
string histoName = "num" + tempCurrentObject; |
652 |
|
|
653 |
< |
if(currentObject == "jets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(jets->size()); |
654 |
< |
else if(currentObject == "muons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(muons->size()); |
655 |
< |
else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(electrons->size()); |
656 |
< |
else if(currentObject == "events") oneDHists_.at(currentChannelIndex)[histoName]->Fill(events->size()); |
657 |
< |
else if(currentObject == "taus") oneDHists_.at(currentChannelIndex)[histoName]->Fill(taus->size()); |
658 |
< |
else if(currentObject == "mets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mets->size()); |
659 |
< |
else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex)[histoName]->Fill(tracks->size()); |
660 |
< |
else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(genjets->size()); |
661 |
< |
else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mcparticles->size()); |
662 |
< |
else if(currentObject == "primaryvertexs") oneDHists_.at(currentChannelIndex)[histoName]->Fill(primaryvertexs->size()); |
663 |
< |
else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex)[histoName]->Fill(bxlumis->size()); |
664 |
< |
else if(currentObject == "photons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(photons->size()); |
665 |
< |
else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex)[histoName]->Fill(superclusters->size()); |
653 |
> |
|
654 |
> |
|
655 |
> |
|
656 |
> |
//set position of primary vertex in event, in order to calculate quantities relative to it |
657 |
> |
if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) { |
658 |
> |
vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back(); |
659 |
> |
int numToPlot = 0; |
660 |
> |
for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){ |
661 |
> |
if(lastCutFlags.at(currentFlag)) numToPlot++; |
662 |
> |
} |
663 |
> |
if(objectToPlot == "primaryvertexs"){ |
664 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
665 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
666 |
> |
} |
667 |
> |
else |
668 |
> |
oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor); |
669 |
> |
} |
670 |
> |
else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor); |
671 |
> |
else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor); |
672 |
> |
else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor); |
673 |
> |
else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor); |
674 |
> |
else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor); |
675 |
> |
else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor); |
676 |
> |
else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor); |
677 |
> |
else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor); |
678 |
> |
else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor); |
679 |
> |
else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor); |
680 |
> |
else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor); |
681 |
> |
else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor); |
682 |
> |
else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor); |
683 |
> |
else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor); |
684 |
> |
else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor); |
685 |
> |
else if(objectToPlot == "primaryvertexs"){ |
686 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
687 |
> |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
688 |
> |
} |
689 |
|
|
690 |
|
} |
691 |
+ |
|
692 |
+ |
|
693 |
+ |
|
694 |
+ |
|
695 |
|
} //end loop over channel |
696 |
|
|
697 |
< |
masterCutFlow_->fillCutFlow(); |
697 |
> |
masterCutFlow_->fillCutFlow(puScaleFactor); |
698 |
> |
|
699 |
|
|
700 |
|
|
701 |
|
} |
710 |
|
else if(comparison == "<") return testValue < cutValue; |
711 |
|
else if(comparison == "<=") return testValue <= cutValue; |
712 |
|
else if(comparison == "==") return testValue == cutValue; |
713 |
+ |
else if(comparison == "=") return testValue == cutValue; |
714 |
|
else if(comparison == "!=") return testValue != cutValue; |
715 |
|
else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;} |
716 |
|
|
893 |
|
else if(variable == "ecalIso") value = object->ecalIso; |
894 |
|
else if(variable == "hcalIso") value = object->hcalIso; |
895 |
|
else if(variable == "caloIso") value = object->caloIso; |
896 |
< |
else if(variable == "trackIsoDR03") value = object->trackIsoDR03; |
896 |
> |
else if(variable == "trackIsDR03") value = object->trackIsoDR03; |
897 |
|
else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03; |
898 |
|
else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03; |
899 |
|
else if(variable == "caloIsoDR03") value = object->caloIsoDR03; |
1032 |
|
else if(variable == "time_ndof") value = object->time_ndof; |
1033 |
|
|
1034 |
|
//user-defined variables |
1035 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1036 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1037 |
< |
else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt; |
1035 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1036 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1037 |
> |
else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt; |
1038 |
|
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
1039 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1040 |
|
else if(variable == "tightID") { |
1045 |
|
&& object->numberOfMatchedStations > 1 \ |
1046 |
|
&& fabs(object->correctedD0Vertex) < 0.2 \ |
1047 |
|
&& fabs(object->correctedDZ) < 0.5 \ |
1048 |
< |
&& object->numberOfValidPixelHits > 0 \ |
1048 |
> |
&& object->numberOfValidPixelHits > 0 \ |
1049 |
|
&& object->numberOfLayersWithMeasurement > 5; |
792 |
– |
|
793 |
– |
|
1050 |
|
} |
1051 |
|
else if(variable == "tightIDdisplaced"){ |
1052 |
|
value = object->isGlobalMuon > 0 \ |
797 |
– |
&& object->isPFMuon > 0 \ |
1053 |
|
&& object->normalizedChi2 < 10 \ |
1054 |
|
&& object->numberOfValidMuonHits > 0 \ |
1055 |
|
&& object->numberOfMatchedStations > 1 \ |
1057 |
|
&& object->numberOfLayersWithMeasurement > 5; |
1058 |
|
} |
1059 |
|
|
1060 |
+ |
else if(variable == "genMatchedId"){ |
1061 |
+ |
int index = getGenMatchedParticleIndex(object); |
1062 |
+ |
if(index == -1) value = 0; |
1063 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1064 |
+ |
} |
1065 |
+ |
else if(variable == "genMatchedMotherId"){ |
1066 |
+ |
int index = getGenMatchedParticleIndex(object); |
1067 |
+ |
if(index == -1) value = 0; |
1068 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1069 |
+ |
} |
1070 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1071 |
+ |
int index = getGenMatchedParticleIndex(object); |
1072 |
+ |
if(index == -1) value = 0; |
1073 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1074 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1075 |
+ |
if(motherIndex == -1) value = 0; |
1076 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1077 |
+ |
} |
1078 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1079 |
+ |
} |
1080 |
+ |
|
1081 |
+ |
|
1082 |
+ |
|
1083 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1084 |
|
|
1085 |
|
value = applyFunction(function, value); |
1250 |
|
else if(variable == "passConvVeto") value = object->passConvVeto; |
1251 |
|
|
1252 |
|
//user-defined variables |
1253 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1254 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1255 |
< |
else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt; |
1253 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1254 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1255 |
> |
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1256 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1257 |
+ |
else if(variable == "correctedD0VertexInEB"){ |
1258 |
+ |
if(fabs(object->eta) < 0.8) value = object->correctedD0Vertex; |
1259 |
+ |
else value = -999; |
1260 |
+ |
} |
1261 |
+ |
else if(variable == "correctedD0VertexOutEB"){ |
1262 |
+ |
if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0Vertex; |
1263 |
+ |
else value = -999; |
1264 |
+ |
} |
1265 |
+ |
else if(variable == "correctedD0VertexEE"){ |
1266 |
+ |
if(object->isEE) value = object->correctedD0Vertex; |
1267 |
+ |
else value = -999; |
1268 |
+ |
} |
1269 |
+ |
|
1270 |
+ |
else if(variable == "correctedD0BeamspotInEB"){ |
1271 |
+ |
if(fabs(object->eta) < 0.8) value = object->correctedD0; |
1272 |
+ |
else value = -999; |
1273 |
+ |
} |
1274 |
+ |
else if(variable == "correctedD0BeamspotOutEB"){ |
1275 |
+ |
if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0; |
1276 |
+ |
else value = -999; |
1277 |
+ |
} |
1278 |
+ |
else if(variable == "correctedD0BeamspotEE"){ |
1279 |
+ |
if(object->isEE) value = object->correctedD0; |
1280 |
+ |
else value = -999; |
1281 |
+ |
} |
1282 |
+ |
|
1283 |
+ |
else if(variable == "correctedD0OriginInEB"){ |
1284 |
+ |
if(fabs(object->eta) < 0.8) value = object->tkD0; |
1285 |
+ |
else value = -999; |
1286 |
+ |
} |
1287 |
+ |
else if(variable == "correctedD0OriginOutEB"){ |
1288 |
+ |
if(object->isEB && fabs(object->eta) > 0.8) value = object->tkD0; |
1289 |
+ |
else value = -999; |
1290 |
+ |
} |
1291 |
+ |
else if(variable == "correctedD0OriginEE"){ |
1292 |
+ |
if(object->isEE) value = object->tkD0; |
1293 |
+ |
else value = -999; |
1294 |
+ |
} |
1295 |
+ |
|
1296 |
+ |
else if(variable == "tightIDdisplaced"){ |
1297 |
+ |
if (object->isEB) |
1298 |
+ |
{ |
1299 |
+ |
value = fabs(object->delEtaIn) < 0.004 \ |
1300 |
+ |
&& fabs (object->delPhiIn) < 0.03 \ |
1301 |
+ |
&& object->scSigmaIEtaIEta < 0.01 \ |
1302 |
+ |
&& object->hadOverEm < 0.12 \ |
1303 |
+ |
&& object->absInvEMinusInvPin < 0.05; |
1304 |
+ |
} |
1305 |
+ |
else |
1306 |
+ |
{ |
1307 |
+ |
value = fabs (object->delEtaIn) < 0.005 \ |
1308 |
+ |
&& fabs (object->delPhiIn) < 0.02 \ |
1309 |
+ |
&& object->scSigmaIEtaIEta < 0.03 \ |
1310 |
+ |
&& object->hadOverEm < 0.10 \ |
1311 |
+ |
&& object->absInvEMinusInvPin < 0.05; |
1312 |
+ |
} |
1313 |
+ |
} |
1314 |
+ |
|
1315 |
+ |
else if(variable == "genMatchedId"){ |
1316 |
+ |
int index = getGenMatchedParticleIndex(object); |
1317 |
+ |
if(index == -1) value = 0; |
1318 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1319 |
+ |
} |
1320 |
+ |
else if(variable == "genMatchedMotherId"){ |
1321 |
+ |
int index = getGenMatchedParticleIndex(object); |
1322 |
+ |
if(index == -1) value = 0; |
1323 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1324 |
+ |
} |
1325 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1326 |
+ |
int index = getGenMatchedParticleIndex(object); |
1327 |
+ |
if(index == -1) value = 0; |
1328 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1329 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1330 |
+ |
if(motherIndex == -1) value = 0; |
1331 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1332 |
+ |
} |
1333 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1334 |
+ |
} |
1335 |
+ |
|
1336 |
|
|
1337 |
|
|
1338 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1466 |
|
else if(variable == "leadingTrackValid") value = object->leadingTrackValid; |
1467 |
|
|
1468 |
|
|
1469 |
+ |
else if(variable == "genMatchedId"){ |
1470 |
+ |
int index = getGenMatchedParticleIndex(object); |
1471 |
+ |
if(index == -1) value = 0; |
1472 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1473 |
+ |
} |
1474 |
+ |
else if(variable == "genMatchedMotherId"){ |
1475 |
+ |
int index = getGenMatchedParticleIndex(object); |
1476 |
+ |
if(index == -1) value = 0; |
1477 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1478 |
+ |
} |
1479 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1480 |
+ |
int index = getGenMatchedParticleIndex(object); |
1481 |
+ |
if(index == -1) value = 0; |
1482 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1483 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1484 |
+ |
if(motherIndex == -1) value = 0; |
1485 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1486 |
+ |
} |
1487 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1488 |
+ |
} |
1489 |
+ |
|
1490 |
+ |
|
1491 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1492 |
|
|
1493 |
|
value = applyFunction(function, value); |
1571 |
|
OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){ |
1572 |
|
|
1573 |
|
double value = 0.0; |
1574 |
< |
|
1574 |
> |
double pMag = sqrt(object->pt * object->pt + |
1575 |
> |
object->pz * object->pz); |
1576 |
> |
|
1577 |
|
if(variable == "pt") value = object->pt; |
1578 |
|
else if(variable == "px") value = object->px; |
1579 |
|
else if(variable == "py") value = object->py; |
1591 |
|
else if(variable == "charge") value = object->charge; |
1592 |
|
else if(variable == "numValidHits") value = object->numValidHits; |
1593 |
|
else if(variable == "isHighPurity") value = object->isHighPurity; |
1594 |
+ |
//additional BNs info for disappTrks |
1595 |
+ |
else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution; |
1596 |
+ |
else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3; |
1597 |
+ |
else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3; |
1598 |
+ |
else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4; |
1599 |
+ |
else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4; |
1600 |
+ |
else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5; |
1601 |
+ |
else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5; |
1602 |
+ |
else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter; |
1603 |
+ |
else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner; |
1604 |
+ |
else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle; |
1605 |
+ |
//user defined variables |
1606 |
+ |
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; |
1607 |
+ |
else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz; |
1608 |
+ |
else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5); |
1609 |
+ |
else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag); |
1610 |
+ |
else if(variable == "isIso") value = getTrkIsIso(object, tracks.product()); |
1611 |
+ |
else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object); |
1612 |
+ |
|
1613 |
+ |
|
1614 |
+ |
else if(variable == "genMatchedId"){ |
1615 |
+ |
int index = getGenMatchedParticleIndex(object); |
1616 |
+ |
if(index == -1) value = 0; |
1617 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1618 |
+ |
} |
1619 |
+ |
else if(variable == "genMatchedMotherId"){ |
1620 |
+ |
int index = getGenMatchedParticleIndex(object); |
1621 |
+ |
if(index == -1) value = 0; |
1622 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1623 |
+ |
} |
1624 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1625 |
+ |
int index = getGenMatchedParticleIndex(object); |
1626 |
+ |
if(index == -1) value = 0; |
1627 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1628 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1629 |
+ |
if(motherIndex == -1) value = 0; |
1630 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1631 |
+ |
} |
1632 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1633 |
+ |
} |
1634 |
+ |
|
1635 |
|
|
1636 |
|
|
1637 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1761 |
|
|
1762 |
|
//user-defined variables |
1763 |
|
else if (variable == "d0"){ |
1764 |
< |
double vx = object->vx - primaryVertex_->x, |
1765 |
< |
vy = object->vy - primaryVertex_->y, |
1764 |
> |
double vx = object->vx - chosenPrimaryVertex->x, |
1765 |
> |
vy = object->vy - chosenPrimaryVertex->y, |
1766 |
|
px = object->px, |
1767 |
|
py = object->py, |
1768 |
|
pt = object->pt; |
1769 |
|
value = (-vx * py + vy * px) / pt; |
1770 |
|
} |
1771 |
|
else if (variable == "dz"){ |
1772 |
< |
double vx = object->vx - primaryVertex_->x, |
1773 |
< |
vy = object->vy - primaryVertex_->y, |
1774 |
< |
vz = object->vz - primaryVertex_->z, |
1772 |
> |
double vx = object->vx - chosenPrimaryVertex->x, |
1773 |
> |
vy = object->vy - chosenPrimaryVertex->y, |
1774 |
> |
vz = object->vz - chosenPrimaryVertex->z, |
1775 |
|
px = object->px, |
1776 |
|
py = object->py, |
1777 |
|
pz = object->pz, |
1778 |
|
pt = object->pt; |
1779 |
|
value = vz - (vx * px + vy * py)/pt * (pz/pt); |
1780 |
|
} |
1781 |
< |
|
1781 |
> |
else if(variable == "v0"){ |
1782 |
> |
value = sqrt(object->vx*object->vx + object->vy*object->vy); |
1783 |
> |
} |
1784 |
> |
else if(variable == "deltaV0"){ |
1785 |
> |
value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y)); |
1786 |
> |
} |
1787 |
> |
else if (variable == "deltaVx"){ |
1788 |
> |
value = object->vx - chosenPrimaryVertex->x; |
1789 |
> |
} |
1790 |
> |
else if (variable == "deltaVy"){ |
1791 |
> |
value = object->vy - chosenPrimaryVertex->y; |
1792 |
> |
} |
1793 |
> |
else if (variable == "deltaVz"){ |
1794 |
> |
value = object->vz - chosenPrimaryVertex->z; |
1795 |
> |
} |
1796 |
|
|
1797 |
|
|
1798 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1922 |
|
else if(variable == "seedRecoFlag") value = object->seedRecoFlag; |
1923 |
|
|
1924 |
|
|
1925 |
+ |
else if(variable == "genMatchedId"){ |
1926 |
+ |
int index = getGenMatchedParticleIndex(object); |
1927 |
+ |
if(index == -1) value = 0; |
1928 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1929 |
+ |
} |
1930 |
+ |
else if(variable == "genMatchedMotherId"){ |
1931 |
+ |
int index = getGenMatchedParticleIndex(object); |
1932 |
+ |
if(index == -1) value = 0; |
1933 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1934 |
+ |
} |
1935 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1936 |
+ |
int index = getGenMatchedParticleIndex(object); |
1937 |
+ |
if(index == -1) value = 0; |
1938 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1939 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1940 |
+ |
if(motherIndex == -1) value = 0; |
1941 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1942 |
+ |
} |
1943 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1944 |
+ |
} |
1945 |
+ |
|
1946 |
+ |
|
1947 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1948 |
|
|
1949 |
|
value = applyFunction(function, value); |
1975 |
|
|
1976 |
|
|
1977 |
|
double |
1978 |
+ |
OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){ |
1979 |
+ |
|
1980 |
+ |
double value = 0.0; |
1981 |
+ |
|
1982 |
+ |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
1983 |
+ |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
1984 |
+ |
else if(variable == "invMass"){ |
1985 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
1986 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
1987 |
+ |
|
1988 |
+ |
value = (fourVector1 + fourVector2).M();} |
1989 |
+ |
else if(variable == "threeDAngle") |
1990 |
+ |
{ |
1991 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
1992 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
1993 |
+ |
value = (threeVector1.Angle(threeVector2)); |
1994 |
+ |
} |
1995 |
+ |
|
1996 |
+ |
|
1997 |
+ |
|
1998 |
+ |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
1999 |
+ |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2000 |
+ |
else if(variable == "d0Sign"){ |
2001 |
+ |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2002 |
+ |
if(d0Sign < 0) value = -0.5; |
2003 |
+ |
else if (d0Sign > 0) value = 0.5; |
2004 |
+ |
else value = -999; |
2005 |
+ |
} |
2006 |
+ |
else if(variable == "muon1CorrectedD0Vertex"){ |
2007 |
+ |
value = object1->correctedD0Vertex; |
2008 |
+ |
} |
2009 |
+ |
else if(variable == "muon2CorrectedD0Vertex"){ |
2010 |
+ |
value = object2->correctedD0Vertex; |
2011 |
+ |
} |
2012 |
+ |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2013 |
+ |
|
2014 |
+ |
|
2015 |
+ |
|
2016 |
+ |
|
2017 |
+ |
|
2018 |
+ |
|
2019 |
+ |
|
2020 |
+ |
|
2021 |
+ |
value = applyFunction(function, value); |
2022 |
+ |
|
2023 |
+ |
return value; |
2024 |
+ |
} |
2025 |
+ |
|
2026 |
+ |
double |
2027 |
+ |
OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){ |
2028 |
+ |
|
2029 |
+ |
double value = 0.0; |
2030 |
+ |
|
2031 |
+ |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
2032 |
+ |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2033 |
+ |
else if(variable == "invMass"){ |
2034 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2035 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2036 |
+ |
|
2037 |
+ |
value = (fourVector1 + fourVector2).M();} |
2038 |
+ |
else if(variable == "threeDAngle") |
2039 |
+ |
{ |
2040 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2041 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2042 |
+ |
value = (threeVector1.Angle(threeVector2)); |
2043 |
+ |
} |
2044 |
+ |
|
2045 |
+ |
|
2046 |
+ |
|
2047 |
+ |
|
2048 |
+ |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2049 |
+ |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2050 |
+ |
|
2051 |
+ |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2052 |
+ |
|
2053 |
+ |
|
2054 |
+ |
|
2055 |
+ |
else if(variable == "d0Sign"){ |
2056 |
+ |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2057 |
+ |
if(d0Sign < 0) value = -0.5; |
2058 |
+ |
else if (d0Sign > 0) value = 0.5; |
2059 |
+ |
else value = -999; |
2060 |
+ |
} |
2061 |
+ |
else if(variable == "electron1CorrectedD0Vertex"){ |
2062 |
+ |
value = object1->correctedD0Vertex; |
2063 |
+ |
} |
2064 |
+ |
else if(variable == "electron2CorrectedD0Vertex"){ |
2065 |
+ |
value = object2->correctedD0Vertex; |
2066 |
+ |
} |
2067 |
+ |
|
2068 |
+ |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2069 |
+ |
|
2070 |
+ |
value = applyFunction(function, value); |
2071 |
+ |
|
2072 |
+ |
return value; |
2073 |
+ |
} |
2074 |
+ |
|
2075 |
+ |
double |
2076 |
+ |
OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){ |
2077 |
+ |
|
2078 |
+ |
double value = 0.0; |
2079 |
+ |
|
2080 |
+ |
if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi)); |
2081 |
+ |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2082 |
+ |
else if(variable == "invMass"){ |
2083 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2084 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2085 |
+ |
|
2086 |
+ |
value = (fourVector1 + fourVector2).M();} |
2087 |
+ |
else if(variable == "threeDAngle") |
2088 |
+ |
{ |
2089 |
+ |
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2090 |
+ |
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2091 |
+ |
value = (threeVector1.Angle(threeVector2)); |
2092 |
+ |
} |
2093 |
+ |
|
2094 |
+ |
|
2095 |
+ |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2096 |
+ |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2097 |
+ |
else if(variable == "d0Sign"){ |
2098 |
+ |
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2099 |
+ |
if(d0Sign < 0) value = -0.5; |
2100 |
+ |
else if (d0Sign > 0) value = 0.5; |
2101 |
+ |
else value = -999; |
2102 |
+ |
} |
2103 |
+ |
else if(variable == "electronCorrectedD0Vertex"){ |
2104 |
+ |
value = object1->correctedD0Vertex; |
2105 |
+ |
} |
2106 |
+ |
else if(variable == "muonCorrectedD0Vertex"){ |
2107 |
+ |
value = object2->correctedD0Vertex; |
2108 |
+ |
} |
2109 |
+ |
else if(variable == "electronCorrectedD0"){ |
2110 |
+ |
value = object1->correctedD0; |
2111 |
+ |
} |
2112 |
+ |
else if(variable == "muonCorrectedD0"){ |
2113 |
+ |
value = object2->correctedD0; |
2114 |
+ |
} |
2115 |
+ |
|
2116 |
+ |
|
2117 |
+ |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2118 |
+ |
|
2119 |
+ |
value = applyFunction(function, value); |
2120 |
+ |
|
2121 |
+ |
return value; |
2122 |
+ |
} |
2123 |
+ |
|
2124 |
+ |
|
2125 |
+ |
// Calculate the number of tracks in cone of DeltaR<0.5 around track1. |
2126 |
+ |
// Return true iff no other tracks are found in this cone. |
2127 |
+ |
int |
2128 |
+ |
OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){ |
2129 |
+ |
for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){ |
2130 |
+ |
if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself. |
2131 |
+ |
double deltaRtrk = deltaR(track1->eta, track2->eta, track1->phi, track2->phi); |
2132 |
+ |
if(deltaRtrk < 0.5) return 0; |
2133 |
+ |
} |
2134 |
+ |
return 1; |
2135 |
+ |
|
2136 |
+ |
} |
2137 |
+ |
|
2138 |
+ |
//creates a map of the dead Ecal channels in the barrel and endcap |
2139 |
+ |
//to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here: |
2140 |
+ |
//http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup |
2141 |
+ |
void |
2142 |
+ |
OSUAnalysis::WriteDeadEcal (){ |
2143 |
+ |
double etaEcal, phiEcal; |
2144 |
+ |
ifstream DeadEcalFile(deadEcalFile_); |
2145 |
+ |
if(!DeadEcalFile) { |
2146 |
+ |
cout << "Error: DeadEcalFile has not been found." << endl; |
2147 |
+ |
return; |
2148 |
+ |
} |
2149 |
+ |
if(DeadEcalVec.size()!= 0){ |
2150 |
+ |
cout << "Error: DeadEcalVec has a nonzero size" << endl; |
2151 |
+ |
return; |
2152 |
+ |
} |
2153 |
+ |
while(!DeadEcalFile.eof()) |
2154 |
+ |
{ |
2155 |
+ |
DeadEcalFile >> etaEcal >> phiEcal; |
2156 |
+ |
DeadEcal newChan; |
2157 |
+ |
newChan.etaEcal = etaEcal; |
2158 |
+ |
newChan.phiEcal = phiEcal; |
2159 |
+ |
DeadEcalVec.push_back(newChan); |
2160 |
+ |
} |
2161 |
+ |
if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl; |
2162 |
+ |
} |
2163 |
+ |
|
2164 |
+ |
//if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0 |
2165 |
+ |
int |
2166 |
+ |
OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){ |
2167 |
+ |
int value = 0; |
2168 |
+ |
if (DeadEcalVec.size() == 0) WriteDeadEcal(); |
2169 |
+ |
for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){ |
2170 |
+ |
double eta = ecal->etaEcal; |
2171 |
+ |
double phi = ecal->phiEcal; |
2172 |
+ |
if (deltaR(eta, track1->eta, phi, track1->phi)<0.05) {value = 1;} |
2173 |
+ |
else {value = 0;} |
2174 |
+ |
} |
2175 |
+ |
return value; |
2176 |
+ |
} |
2177 |
+ |
|
2178 |
+ |
|
2179 |
+ |
|
2180 |
+ |
|
2181 |
+ |
double |
2182 |
|
OSUAnalysis::applyFunction(string function, double value){ |
2183 |
|
|
2184 |
|
if(function == "abs") value = fabs(value); |
2185 |
+ |
else if(function == "fabs") value = fabs(value); |
2186 |
+ |
|
2187 |
|
|
2188 |
+ |
else if(function == "") value = value; |
2189 |
+ |
else{std::cout << "WARNING: invalid function '" << function << "'\n";} |
2190 |
|
|
2191 |
|
return value; |
2192 |
|
|
2199 |
|
|
2200 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2201 |
|
|
2202 |
+ |
|
2203 |
|
bool decision = true;//object passes if this cut doesn't cut on that type of object |
2204 |
|
|
1538 |
– |
if(currentCut.inputCollection == inputType){ |
2205 |
|
|
2206 |
< |
double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function); |
2206 |
> |
if(currentCut.inputCollection == inputType){ |
2207 |
|
|
2208 |
< |
decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue); |
2208 |
> |
vector<bool> subcutDecisions; |
2209 |
> |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2210 |
> |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2211 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2212 |
> |
} |
2213 |
> |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2214 |
> |
else{ |
2215 |
> |
bool tempDecision = true; |
2216 |
> |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2217 |
> |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2218 |
> |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2219 |
> |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2220 |
> |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2221 |
> |
} |
2222 |
> |
decision = tempDecision; |
2223 |
> |
} |
2224 |
|
} |
2225 |
< |
individualFlags[inputType].at(currentCutIndex).push_back(decision); |
2225 |
> |
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2226 |
|
|
2227 |
|
|
2228 |
|
//set flags for objects that pass each cut AND all the previous cuts |
2229 |
|
bool previousCumulativeFlag = true; |
2230 |
|
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
2231 |
< |
if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true; |
2231 |
> |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true; |
2232 |
|
else{ previousCumulativeFlag = false; break;} |
2233 |
|
} |
2234 |
< |
cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
2234 |
> |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
2235 |
> |
|
2236 |
> |
|
2237 |
> |
} |
2238 |
> |
|
2239 |
> |
} |
2240 |
> |
|
2241 |
> |
|
2242 |
> |
template <class InputCollection1, class InputCollection2> |
2243 |
> |
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \ |
2244 |
> |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){ |
2245 |
> |
|
2246 |
> |
|
2247 |
> |
bool sameObjects = false; |
2248 |
> |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2249 |
> |
|
2250 |
|
|
2251 |
+ |
int counter = 0; |
2252 |
+ |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2253 |
+ |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2254 |
+ |
|
2255 |
+ |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2256 |
+ |
|
2257 |
+ |
|
2258 |
+ |
bool decision = true;//object passes if this cut doesn't cut on that type of object |
2259 |
+ |
|
2260 |
+ |
if(currentCut.inputCollection == inputType){ |
2261 |
+ |
|
2262 |
+ |
vector<bool> subcutDecisions; |
2263 |
+ |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2264 |
+ |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2265 |
+ |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
2266 |
+ |
} |
2267 |
+ |
|
2268 |
+ |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2269 |
+ |
else{ |
2270 |
+ |
bool tempDecision = true; |
2271 |
+ |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2272 |
+ |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2273 |
+ |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2274 |
+ |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2275 |
+ |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2276 |
+ |
} |
2277 |
+ |
decision = tempDecision; |
2278 |
+ |
} |
2279 |
+ |
} |
2280 |
+ |
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
2281 |
+ |
|
2282 |
+ |
//set flags for objects that pass each cut AND all the previous cuts |
2283 |
+ |
bool previousCumulativeFlag = true; |
2284 |
+ |
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
2285 |
+ |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
2286 |
+ |
else{ previousCumulativeFlag = false; break;} |
2287 |
+ |
} |
2288 |
+ |
//apply flags for the components of the composite object as well |
2289 |
+ |
bool currentCumulativeFlag = true; |
2290 |
+ |
if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision; |
2291 |
+ |
else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2); |
2292 |
+ |
else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1); |
2293 |
+ |
else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2); |
2294 |
+ |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag); |
2295 |
+ |
|
2296 |
+ |
counter++; |
2297 |
+ |
} |
2298 |
+ |
|
2299 |
|
} |
2300 |
|
|
2301 |
+ |
|
2302 |
|
} |
2303 |
|
|
2304 |
|
|
2305 |
|
template <class InputCollection> |
2306 |
< |
void OSUAnalysis::fillHistogram(TH1* histo, histogram parameters, InputCollection inputCollection){ |
2306 |
> |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2307 |
> |
|
2308 |
> |
for (uint object = 0; object != inputCollection->size(); object++){ |
2309 |
> |
|
2310 |
> |
if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue; |
2311 |
> |
|
2312 |
> |
string currentString = parameters.inputVariables.at(0); |
2313 |
> |
string inputVariable = ""; |
2314 |
> |
string function = ""; |
2315 |
> |
if(currentString.find("(")==std::string::npos){ |
2316 |
> |
inputVariable = currentString;// variable to cut on |
2317 |
> |
} |
2318 |
> |
else{ |
2319 |
> |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2320 |
> |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2321 |
> |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2322 |
> |
} |
2323 |
> |
|
2324 |
> |
double value = valueLookup(&inputCollection->at(object), inputVariable, function); |
2325 |
> |
histo->Fill(value,puScaleFactor); |
2326 |
> |
|
2327 |
> |
} |
2328 |
|
|
2329 |
+ |
} |
2330 |
+ |
|
2331 |
+ |
template <class InputCollection1, class InputCollection2> |
2332 |
+ |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2333 |
+ |
|
2334 |
+ |
bool sameObjects = false; |
2335 |
+ |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2336 |
+ |
|
2337 |
+ |
int pairCounter = 0; |
2338 |
+ |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2339 |
+ |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2340 |
+ |
|
2341 |
+ |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2342 |
+ |
|
2343 |
+ |
//only take objects which have passed all cuts and pairs which have passed all cuts |
2344 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
2345 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
2346 |
+ |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue; |
2347 |
+ |
|
2348 |
+ |
string currentString = parameters.inputVariables.at(0); |
2349 |
+ |
string inputVariable = ""; |
2350 |
+ |
string function = ""; |
2351 |
+ |
if(currentString.find("(")==std::string::npos){ |
2352 |
+ |
inputVariable = currentString;// variable to cut on |
2353 |
+ |
} |
2354 |
+ |
else{ |
2355 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2356 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2357 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2358 |
+ |
} |
2359 |
+ |
|
2360 |
+ |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2361 |
+ |
histo->Fill(value,puScaleFactor); |
2362 |
+ |
|
2363 |
+ |
pairCounter++; |
2364 |
+ |
} |
2365 |
+ |
} |
2366 |
+ |
|
2367 |
+ |
} |
2368 |
+ |
|
2369 |
+ |
|
2370 |
+ |
template <class InputCollection> |
2371 |
+ |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
2372 |
|
|
2373 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
2374 |
< |
if(parameters.inputVariables.size() == 1){ |
2375 |
< |
double value = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function); |
2376 |
< |
histo->Fill(value); |
2377 |
< |
} |
2378 |
< |
else if(parameters.inputVariables.size() == 2){ |
2379 |
< |
double valueX = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function); |
2380 |
< |
double valueY = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(1), parameters.function); |
2381 |
< |
histo->Fill(valueX,valueY); |
2374 |
> |
|
2375 |
> |
if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue; |
2376 |
> |
|
2377 |
> |
string currentString = parameters.inputVariables.at(0); |
2378 |
> |
string inputVariable = ""; |
2379 |
> |
string function = ""; |
2380 |
> |
if(currentString.find("(")==std::string::npos){ |
2381 |
> |
inputVariable = currentString;// variable to cut on |
2382 |
|
} |
2383 |
+ |
else{ |
2384 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2385 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2386 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2387 |
+ |
} |
2388 |
+ |
double valueX = valueLookup(&inputCollection->at(object), inputVariable, function); |
2389 |
+ |
|
2390 |
+ |
currentString = parameters.inputVariables.at(1); |
2391 |
+ |
inputVariable = ""; |
2392 |
+ |
function = ""; |
2393 |
+ |
if(currentString.find("(")==std::string::npos){ |
2394 |
+ |
inputVariable = currentString;// variable to cut on |
2395 |
+ |
} |
2396 |
+ |
else{ |
2397 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2398 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2399 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2400 |
+ |
} |
2401 |
+ |
|
2402 |
+ |
double valueY = valueLookup(&inputCollection->at(object), inputVariable, function); |
2403 |
+ |
|
2404 |
+ |
histo->Fill(valueX,valueY,puScaleFactor); |
2405 |
+ |
|
2406 |
|
} |
2407 |
|
|
2408 |
|
} |
2409 |
|
|
2410 |
+ |
template <class InputCollection1, class InputCollection2> |
2411 |
+ |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
2412 |
|
|
2413 |
+ |
bool sameObjects = false; |
2414 |
+ |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
2415 |
+ |
|
2416 |
+ |
int pairCounter = 0; |
2417 |
+ |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
2418 |
+ |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
2419 |
+ |
|
2420 |
+ |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
2421 |
+ |
|
2422 |
+ |
//only take objects which have passed all cuts and pairs which have passed all cuts |
2423 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
2424 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
2425 |
+ |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue; |
2426 |
+ |
|
2427 |
+ |
string currentString = parameters.inputVariables.at(0); |
2428 |
+ |
string inputVariable = ""; |
2429 |
+ |
string function = ""; |
2430 |
+ |
if(currentString.find("(")==std::string::npos){ |
2431 |
+ |
inputVariable = currentString;// variable to cut on |
2432 |
+ |
} |
2433 |
+ |
else{ |
2434 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2435 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2436 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2437 |
+ |
} |
2438 |
+ |
double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2439 |
+ |
|
2440 |
+ |
currentString = parameters.inputVariables.at(1); |
2441 |
+ |
inputVariable = ""; |
2442 |
+ |
function = ""; |
2443 |
+ |
if(currentString.find("(")==std::string::npos){ |
2444 |
+ |
inputVariable = currentString;// variable to cut on |
2445 |
+ |
} |
2446 |
+ |
else{ |
2447 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
2448 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
2449 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
2450 |
+ |
} |
2451 |
+ |
double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
2452 |
+ |
|
2453 |
+ |
|
2454 |
+ |
histo->Fill(valueX,valueY,puScaleFactor); |
2455 |
+ |
|
2456 |
+ |
pairCounter++; |
2457 |
+ |
} |
2458 |
+ |
} |
2459 |
+ |
|
2460 |
+ |
} |
2461 |
+ |
|
2462 |
+ |
|
2463 |
+ |
template <class InputObject> |
2464 |
+ |
int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){ |
2465 |
+ |
|
2466 |
+ |
int bestMatchIndex = -1; |
2467 |
+ |
double bestMatchDeltaR = 999; |
2468 |
+ |
|
2469 |
+ |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2470 |
+ |
|
2471 |
+ |
double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi); |
2472 |
+ |
if(currentDeltaR > 0.05) continue; |
2473 |
+ |
|
2474 |
+ |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2475 |
+ |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2476 |
+ |
bestMatchDeltaR = currentDeltaR; |
2477 |
+ |
} |
2478 |
+ |
|
2479 |
+ |
} |
2480 |
+ |
|
2481 |
+ |
return bestMatchIndex; |
2482 |
+ |
|
2483 |
+ |
} |
2484 |
+ |
|
2485 |
+ |
|
2486 |
+ |
int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){ |
2487 |
+ |
|
2488 |
+ |
int bestMatchIndex = -1; |
2489 |
+ |
double bestMatchDeltaR = 999; |
2490 |
+ |
|
2491 |
+ |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2492 |
+ |
|
2493 |
+ |
if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue; |
2494 |
+ |
|
2495 |
+ |
double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi); |
2496 |
+ |
if(currentDeltaR > 0.05) continue; |
2497 |
+ |
|
2498 |
+ |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2499 |
+ |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2500 |
+ |
bestMatchDeltaR = currentDeltaR; |
2501 |
+ |
} |
2502 |
+ |
|
2503 |
+ |
} |
2504 |
+ |
|
2505 |
+ |
return bestMatchIndex; |
2506 |
+ |
} |
2507 |
+ |
|
2508 |
+ |
|
2509 |
+ |
// bin particle type |
2510 |
+ |
// --- ------------- |
2511 |
+ |
// 0 unmatched |
2512 |
+ |
// 1 u |
2513 |
+ |
// 2 d |
2514 |
+ |
// 3 s |
2515 |
+ |
// 4 c |
2516 |
+ |
// 5 b |
2517 |
+ |
// 6 t |
2518 |
+ |
// 7 e |
2519 |
+ |
// 8 mu |
2520 |
+ |
// 9 tau |
2521 |
+ |
// 10 nu |
2522 |
+ |
// 11 g |
2523 |
+ |
// 12 gamma |
2524 |
+ |
// 13 Z |
2525 |
+ |
// 14 W |
2526 |
+ |
// 15 light meson |
2527 |
+ |
// 16 K meson |
2528 |
+ |
// 17 D meson |
2529 |
+ |
// 18 B meson |
2530 |
+ |
// 19 light baryon |
2531 |
+ |
// 20 strange baryon |
2532 |
+ |
// 21 charm baryon |
2533 |
+ |
// 22 bottom baryon |
2534 |
+ |
// 23 other |
2535 |
+ |
|
2536 |
+ |
int OSUAnalysis::getPdgIdBinValue(int pdgId){ |
2537 |
+ |
|
2538 |
+ |
int binValue = -999; |
2539 |
+ |
int absPdgId = fabs(pdgId); |
2540 |
+ |
if(pdgId == -1) binValue = 0; |
2541 |
+ |
else if(absPdgId <= 6 ) binValue = absPdgId; |
2542 |
+ |
else if(absPdgId == 11 ) binValue = 7; |
2543 |
+ |
else if(absPdgId == 13 ) binValue = 8; |
2544 |
+ |
else if(absPdgId == 15 ) binValue = 9; |
2545 |
+ |
else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10; |
2546 |
+ |
else if(absPdgId == 21 ) binValue = 11; |
2547 |
+ |
else if(absPdgId == 22 ) binValue = 12; |
2548 |
+ |
else if(absPdgId == 23 ) binValue = 13; |
2549 |
+ |
else if(absPdgId == 24 ) binValue = 14; |
2550 |
+ |
else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130 ) binValue = 15; |
2551 |
+ |
else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400) ) binValue = 16; |
2552 |
+ |
else if(absPdgId > 400 && absPdgId < 500 ) binValue = 17; |
2553 |
+ |
else if(absPdgId > 500 && absPdgId < 600 ) binValue = 18; |
2554 |
+ |
else if(absPdgId > 1000 && absPdgId < 3000 ) binValue = 19; |
2555 |
+ |
else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20; |
2556 |
+ |
else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21; |
2557 |
+ |
else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22; |
2558 |
+ |
|
2559 |
+ |
else binValue = 23; |
2560 |
+ |
|
2561 |
+ |
return binValue; |
2562 |
+ |
|
2563 |
+ |
} |
2564 |
|
|
2565 |
|
|
2566 |
|
DEFINE_FWK_MODULE(OSUAnalysis); |