89 |
|
|
90 |
|
|
91 |
|
|
92 |
+ |
//add histograms with the gen-matched id, mother id, and grandmother id |
93 |
+ |
for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
94 |
+ |
|
95 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
96 |
+ |
if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue; |
97 |
+ |
|
98 |
+ |
histogram tempIdHisto; |
99 |
+ |
histogram tempMomIdHisto; |
100 |
+ |
histogram tempGmaIdHisto; |
101 |
+ |
|
102 |
+ |
tempIdHisto.inputCollection = currentObject; |
103 |
+ |
tempMomIdHisto.inputCollection = currentObject; |
104 |
+ |
tempGmaIdHisto.inputCollection = currentObject; |
105 |
+ |
|
106 |
+ |
currentObject = currentObject.substr(0, currentObject.size()-1); |
107 |
+ |
tempIdHisto.name = currentObject+"GenMatchId"; |
108 |
+ |
tempMomIdHisto.name = currentObject+"GenMatchMotherId"; |
109 |
+ |
tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId"; |
110 |
+ |
|
111 |
+ |
currentObject.at(0) = toupper(currentObject.at(0)); |
112 |
+ |
tempIdHisto.title = currentObject+" Gen-matched Particle"; |
113 |
+ |
tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother"; |
114 |
+ |
tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother"; |
115 |
+ |
|
116 |
+ |
int maxNum = 24; |
117 |
+ |
vector<double> binVector; |
118 |
+ |
binVector.push_back(maxNum); |
119 |
+ |
binVector.push_back(0); |
120 |
+ |
binVector.push_back(maxNum); |
121 |
+ |
|
122 |
+ |
tempIdHisto.bins = binVector; |
123 |
+ |
tempIdHisto.inputVariables.push_back("genMatchedId"); |
124 |
+ |
tempMomIdHisto.bins = binVector; |
125 |
+ |
tempMomIdHisto.inputVariables.push_back("genMatchedMotherId"); |
126 |
+ |
tempGmaIdHisto.bins = binVector; |
127 |
+ |
tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId"); |
128 |
+ |
|
129 |
+ |
histograms.push_back(tempIdHisto); |
130 |
+ |
histograms.push_back(tempMomIdHisto); |
131 |
+ |
histograms.push_back(tempGmaIdHisto); |
132 |
+ |
|
133 |
+ |
} |
134 |
+ |
|
135 |
+ |
|
136 |
|
|
137 |
|
channel tempChannel; |
138 |
|
//loop over all channels (event selections) |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
+ |
if(currentHistogram.name.find("GenMatch")==std::string::npos) continue; |
197 |
+ |
|
198 |
+ |
// bin particle type |
199 |
+ |
// --- ------------- |
200 |
+ |
// 0 unmatched |
201 |
+ |
// 1 u |
202 |
+ |
// 2 d |
203 |
+ |
// 3 s |
204 |
+ |
// 4 c |
205 |
+ |
// 5 b |
206 |
+ |
// 6 t |
207 |
+ |
// 7 e |
208 |
+ |
// 8 mu |
209 |
+ |
// 9 tau |
210 |
+ |
// 10 nu |
211 |
+ |
// 11 g |
212 |
+ |
// 12 gamma |
213 |
+ |
// 13 Z |
214 |
+ |
// 14 W |
215 |
+ |
// 15 light meson |
216 |
+ |
// 16 K meson |
217 |
+ |
// 17 D meson |
218 |
+ |
// 18 B meson |
219 |
+ |
// 19 light baryon |
220 |
+ |
// 20 strange baryon |
221 |
+ |
// 21 charm baryon |
222 |
+ |
// 22 bottom baryon |
223 |
+ |
// 23 other |
224 |
+ |
|
225 |
+ |
vector<TString> labelArray; |
226 |
+ |
labelArray.push_back("unmatched"); |
227 |
+ |
labelArray.push_back("u"); |
228 |
+ |
labelArray.push_back("d"); |
229 |
+ |
labelArray.push_back("s"); |
230 |
+ |
labelArray.push_back("c"); |
231 |
+ |
labelArray.push_back("b"); |
232 |
+ |
labelArray.push_back("t"); |
233 |
+ |
labelArray.push_back("e"); |
234 |
+ |
labelArray.push_back("#mu"); |
235 |
+ |
labelArray.push_back("#tau"); |
236 |
+ |
labelArray.push_back("#nu"); |
237 |
+ |
labelArray.push_back("g"); |
238 |
+ |
labelArray.push_back("#gamma"); |
239 |
+ |
labelArray.push_back("Z"); |
240 |
+ |
labelArray.push_back("W"); |
241 |
+ |
labelArray.push_back("light meson"); |
242 |
+ |
labelArray.push_back("K meson"); |
243 |
+ |
labelArray.push_back("D meson"); |
244 |
+ |
labelArray.push_back("B meson"); |
245 |
+ |
labelArray.push_back("light baryon"); |
246 |
+ |
labelArray.push_back("strange baryon"); |
247 |
+ |
labelArray.push_back("charm baryon"); |
248 |
+ |
labelArray.push_back("bottom baryon"); |
249 |
+ |
labelArray.push_back("other"); |
250 |
+ |
|
251 |
+ |
for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){ |
252 |
+ |
oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin)); |
253 |
+ |
} |
254 |
|
} |
255 |
|
//book a histogram for the number of each object type to be plotted |
256 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
276 |
|
} |
277 |
|
|
278 |
|
|
279 |
+ |
|
280 |
+ |
|
281 |
+ |
|
282 |
+ |
|
283 |
+ |
|
284 |
|
//get list of cuts for this channel |
285 |
|
vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts")); |
286 |
|
|
391 |
|
|
392 |
|
|
393 |
|
// Retrieve necessary collections from the event. |
394 |
< |
edm::Handle<BNtriggerCollection> triggers; |
394 |
> |
|
395 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end()) |
396 |
|
event.getByLabel (triggers_, triggers); |
397 |
|
|
291 |
– |
edm::Handle<BNjetCollection> jets; |
398 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end()) |
399 |
|
event.getByLabel (jets_, jets); |
400 |
|
|
295 |
– |
edm::Handle<BNmuonCollection> muons; |
401 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end()) |
402 |
|
event.getByLabel (muons_, muons); |
403 |
|
|
299 |
– |
edm::Handle<BNelectronCollection> electrons; |
404 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end()) |
405 |
|
event.getByLabel (electrons_, electrons); |
406 |
|
|
303 |
– |
edm::Handle<BNeventCollection> events; |
407 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end()) |
408 |
|
event.getByLabel (events_, events); |
409 |
|
|
307 |
– |
edm::Handle<BNtauCollection> taus; |
410 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end()) |
411 |
|
event.getByLabel (taus_, taus); |
412 |
|
|
311 |
– |
edm::Handle<BNmetCollection> mets; |
413 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end()) |
414 |
|
event.getByLabel (mets_, mets); |
415 |
|
|
315 |
– |
edm::Handle<BNtrackCollection> tracks; |
416 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end()) |
417 |
|
event.getByLabel (tracks_, tracks); |
418 |
|
|
319 |
– |
edm::Handle<BNgenjetCollection> genjets; |
419 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end()) |
420 |
|
event.getByLabel (genjets_, genjets); |
421 |
|
|
323 |
– |
edm::Handle<BNmcparticleCollection> mcparticles; |
422 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end()) |
423 |
|
event.getByLabel (mcparticles_, mcparticles); |
424 |
|
|
327 |
– |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
425 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end()) |
426 |
|
event.getByLabel (primaryvertexs_, primaryvertexs); |
427 |
|
|
331 |
– |
edm::Handle<BNbxlumiCollection> bxlumis; |
428 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end()) |
429 |
|
event.getByLabel (bxlumis_, bxlumis); |
430 |
|
|
335 |
– |
edm::Handle<BNphotonCollection> photons; |
431 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end()) |
432 |
|
event.getByLabel (photons_, photons); |
433 |
|
|
339 |
– |
edm::Handle<BNsuperclusterCollection> superclusters; |
434 |
|
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end()) |
435 |
|
event.getByLabel (superclusters_, superclusters); |
436 |
|
|
437 |
|
|
438 |
|
//get pile-up event weight |
439 |
< |
double puScaleFactor = 0; |
439 |
> |
double puScaleFactor = 1.00; |
440 |
|
if(datasetType_ != "data") |
441 |
|
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
348 |
– |
else |
349 |
– |
puScaleFactor = 1.00; |
350 |
– |
|
442 |
|
|
443 |
|
//loop over all channels |
444 |
|
|
527 |
|
|
528 |
|
|
529 |
|
//set position of primary vertex in event, in order to calculate quantities relative to it |
439 |
– |
primaryVertex_ = 0; |
530 |
|
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back(); |
531 |
|
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
532 |
|
if(!vertexFlags.at(vertexIndex)) continue; |
533 |
< |
primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex)); |
533 |
> |
chosenPrimaryVertex = & primaryvertexs->at(vertexIndex); |
534 |
|
break; |
535 |
|
} |
536 |
|
|
447 |
– |
|
537 |
|
//filling histograms |
538 |
|
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
539 |
|
histogram currentHistogram = histograms.at(histogramIndex); |
541 |
|
if(currentHistogram.inputVariables.size() == 1){ |
542 |
|
TH1D* histo; |
543 |
|
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
544 |
+ |
// std::cout << currentHistogram.inputCollection << std::endl; |
545 |
+ |
// std::cout << "\t" << currentHistogram.inputVariables.at(0) << std::endl; |
546 |
|
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
547 |
< |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
547 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
548 |
|
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\ |
549 |
|
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\ |
550 |
|
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
594 |
|
} |
595 |
|
} |
596 |
|
|
506 |
– |
|
597 |
|
//fills histograms with the sizes of collections |
598 |
|
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
599 |
|
string currentObject = objectsToPlot.at(currentObjectIndex); |
627 |
|
else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor); |
628 |
|
|
629 |
|
} |
630 |
+ |
|
631 |
+ |
|
632 |
+ |
|
633 |
+ |
|
634 |
|
} //end loop over channel |
635 |
|
|
636 |
|
masterCutFlow_->fillCutFlow(puScaleFactor); |
832 |
|
else if(variable == "ecalIso") value = object->ecalIso; |
833 |
|
else if(variable == "hcalIso") value = object->hcalIso; |
834 |
|
else if(variable == "caloIso") value = object->caloIso; |
835 |
< |
else if(variable == "trackIsoDR03") value = object->trackIsoDR03; |
835 |
> |
else if(variable == "trackIsDR03") value = object->trackIsoDR03; |
836 |
|
else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03; |
837 |
|
else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03; |
838 |
|
else if(variable == "caloIsoDR03") value = object->caloIsoDR03; |
971 |
|
else if(variable == "time_ndof") value = object->time_ndof; |
972 |
|
|
973 |
|
//user-defined variables |
974 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
975 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
974 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
975 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
976 |
|
else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt; |
977 |
|
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
978 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
996 |
|
&& object->numberOfLayersWithMeasurement > 5; |
997 |
|
} |
998 |
|
|
999 |
< |
// else if(variable == "genMatchedID"){ |
1000 |
< |
// value = getGenMatchedParticle(object)->id; |
1001 |
< |
// } |
1002 |
< |
// else if(variable == "genMatchedMotherID"){ |
1003 |
< |
// value = getGenMatchedParticle(object)->motherId; |
1004 |
< |
// } |
1005 |
< |
// else if(variable == "genMatchedGrandmotherID"){ |
1006 |
< |
// value = getGenMatchedParticle(object)->grandMotherId; |
1007 |
< |
// } |
999 |
> |
else if(variable == "genMatchedId"){ |
1000 |
> |
int index = getGenMatchedParticleIndex(object); |
1001 |
> |
if(index == -1) value = 0; |
1002 |
> |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1003 |
> |
} |
1004 |
> |
else if(variable == "genMatchedMotherId"){ |
1005 |
> |
int index = getGenMatchedParticleIndex(object); |
1006 |
> |
if(index == -1) value = 0; |
1007 |
> |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1008 |
> |
} |
1009 |
> |
else if(variable == "genMatchedGrandmotherId"){ |
1010 |
> |
int index = getGenMatchedParticleIndex(object); |
1011 |
> |
if(index == -1) value = 0; |
1012 |
> |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1013 |
> |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1014 |
> |
if(motherIndex == -1) value = 0; |
1015 |
> |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1016 |
> |
} |
1017 |
> |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1018 |
> |
} |
1019 |
|
|
1020 |
|
|
1021 |
|
|
1189 |
|
else if(variable == "passConvVeto") value = object->passConvVeto; |
1190 |
|
|
1191 |
|
//user-defined variables |
1192 |
< |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1193 |
< |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1192 |
> |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1193 |
> |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError)); |
1194 |
|
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1195 |
|
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1196 |
|
else if(variable == "correctedD0VertexInEB"){ |
1251 |
|
} |
1252 |
|
} |
1253 |
|
|
1254 |
+ |
else if(variable == "genMatchedId"){ |
1255 |
+ |
int index = getGenMatchedParticleIndex(object); |
1256 |
+ |
if(index == -1) value = 0; |
1257 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1258 |
+ |
} |
1259 |
+ |
else if(variable == "genMatchedMotherId"){ |
1260 |
+ |
int index = getGenMatchedParticleIndex(object); |
1261 |
+ |
if(index == -1) value = 0; |
1262 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1263 |
+ |
} |
1264 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1265 |
+ |
int index = getGenMatchedParticleIndex(object); |
1266 |
+ |
if(index == -1) value = 0; |
1267 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1268 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1269 |
+ |
if(motherIndex == -1) value = 0; |
1270 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1271 |
+ |
} |
1272 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1273 |
+ |
} |
1274 |
+ |
|
1275 |
+ |
|
1276 |
+ |
|
1277 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1278 |
|
|
1279 |
|
value = applyFunction(function, value); |
1405 |
|
else if(variable == "leadingTrackValid") value = object->leadingTrackValid; |
1406 |
|
|
1407 |
|
|
1408 |
+ |
else if(variable == "genMatchedId"){ |
1409 |
+ |
int index = getGenMatchedParticleIndex(object); |
1410 |
+ |
if(index == -1) value = 0; |
1411 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1412 |
+ |
} |
1413 |
+ |
else if(variable == "genMatchedMotherId"){ |
1414 |
+ |
int index = getGenMatchedParticleIndex(object); |
1415 |
+ |
if(index == -1) value = 0; |
1416 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1417 |
+ |
} |
1418 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1419 |
+ |
int index = getGenMatchedParticleIndex(object); |
1420 |
+ |
if(index == -1) value = 0; |
1421 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1422 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1423 |
+ |
if(motherIndex == -1) value = 0; |
1424 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1425 |
+ |
} |
1426 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1427 |
+ |
} |
1428 |
+ |
|
1429 |
+ |
|
1430 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1431 |
|
|
1432 |
|
value = applyFunction(function, value); |
1530 |
|
else if(variable == "isHighPurity") value = object->isHighPurity; |
1531 |
|
|
1532 |
|
|
1533 |
+ |
else if(variable == "genMatchedId"){ |
1534 |
+ |
int index = getGenMatchedParticleIndex(object); |
1535 |
+ |
if(index == -1) value = 0; |
1536 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1537 |
+ |
} |
1538 |
+ |
else if(variable == "genMatchedMotherId"){ |
1539 |
+ |
int index = getGenMatchedParticleIndex(object); |
1540 |
+ |
if(index == -1) value = 0; |
1541 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1542 |
+ |
} |
1543 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1544 |
+ |
int index = getGenMatchedParticleIndex(object); |
1545 |
+ |
if(index == -1) value = 0; |
1546 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1547 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1548 |
+ |
if(motherIndex == -1) value = 0; |
1549 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1550 |
+ |
} |
1551 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1552 |
+ |
} |
1553 |
+ |
|
1554 |
+ |
|
1555 |
+ |
|
1556 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1557 |
|
|
1558 |
|
value = applyFunction(function, value); |
1680 |
|
|
1681 |
|
//user-defined variables |
1682 |
|
else if (variable == "d0"){ |
1683 |
< |
double vx = object->vx - primaryVertex_->x, |
1684 |
< |
vy = object->vy - primaryVertex_->y, |
1683 |
> |
double vx = object->vx - chosenPrimaryVertex->x, |
1684 |
> |
vy = object->vy - chosenPrimaryVertex->y, |
1685 |
|
px = object->px, |
1686 |
|
py = object->py, |
1687 |
|
pt = object->pt; |
1688 |
|
value = (-vx * py + vy * px) / pt; |
1689 |
|
} |
1690 |
|
else if (variable == "dz"){ |
1691 |
< |
double vx = object->vx - primaryVertex_->x, |
1692 |
< |
vy = object->vy - primaryVertex_->y, |
1693 |
< |
vz = object->vz - primaryVertex_->z, |
1691 |
> |
double vx = object->vx - chosenPrimaryVertex->x, |
1692 |
> |
vy = object->vy - chosenPrimaryVertex->y, |
1693 |
> |
vz = object->vz - chosenPrimaryVertex->z, |
1694 |
|
px = object->px, |
1695 |
|
py = object->py, |
1696 |
|
pz = object->pz, |
1701 |
|
value = sqrt(object->vx*object->vx + object->vy*object->vy); |
1702 |
|
} |
1703 |
|
else if(variable == "deltaV0"){ |
1704 |
< |
value = sqrt((object->vx-primaryVertex_->x)*(object->vx-primaryVertex_->x) + (object->vy-primaryVertex_->y)*(object->vy-primaryVertex_->y)); |
1704 |
> |
value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y)); |
1705 |
|
} |
1706 |
|
else if (variable == "deltaVx"){ |
1707 |
< |
value = object->vx - primaryVertex_->x; |
1707 |
> |
value = object->vx - chosenPrimaryVertex->x; |
1708 |
|
} |
1709 |
|
else if (variable == "deltaVy"){ |
1710 |
< |
value = object->vy - primaryVertex_->y; |
1710 |
> |
value = object->vy - chosenPrimaryVertex->y; |
1711 |
|
} |
1712 |
|
else if (variable == "deltaVz"){ |
1713 |
< |
value = object->vz - primaryVertex_->z; |
1713 |
> |
value = object->vz - chosenPrimaryVertex->z; |
1714 |
|
} |
1715 |
|
|
1716 |
|
|
1841 |
|
else if(variable == "seedRecoFlag") value = object->seedRecoFlag; |
1842 |
|
|
1843 |
|
|
1844 |
+ |
else if(variable == "genMatchedId"){ |
1845 |
+ |
int index = getGenMatchedParticleIndex(object); |
1846 |
+ |
if(index == -1) value = 0; |
1847 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).id); |
1848 |
+ |
} |
1849 |
+ |
else if(variable == "genMatchedMotherId"){ |
1850 |
+ |
int index = getGenMatchedParticleIndex(object); |
1851 |
+ |
if(index == -1) value = 0; |
1852 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).motherId); |
1853 |
+ |
} |
1854 |
+ |
else if(variable == "genMatchedGrandmotherId"){ |
1855 |
+ |
int index = getGenMatchedParticleIndex(object); |
1856 |
+ |
if(index == -1) value = 0; |
1857 |
+ |
else if(fabs(mcparticles->at(index).motherId) == 15){ |
1858 |
+ |
int motherIndex = findTauMotherIndex(&mcparticles->at(index)); |
1859 |
+ |
if(motherIndex == -1) value = 0; |
1860 |
+ |
else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId); |
1861 |
+ |
} |
1862 |
+ |
else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId); |
1863 |
+ |
} |
1864 |
+ |
|
1865 |
+ |
|
1866 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1867 |
|
|
1868 |
|
value = applyFunction(function, value); |
1965 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
1966 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
1967 |
|
|
1968 |
< |
|
1968 |
> |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
1969 |
|
|
1970 |
|
|
1971 |
|
|
2006 |
|
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2007 |
|
value = (threeVector1.Angle(threeVector2)); |
2008 |
|
} |
2009 |
< |
|
1815 |
< |
|
1816 |
< |
|
2009 |
> |
|
2010 |
|
|
2011 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2012 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2022 |
|
else if(variable == "muonCorrectedD0Vertex"){ |
2023 |
|
value = object2->correctedD0Vertex; |
2024 |
|
} |
2025 |
+ |
else if(variable == "electronCorrectedD0"){ |
2026 |
+ |
value = object1->correctedD0; |
2027 |
+ |
} |
2028 |
+ |
else if(variable == "muonCorrectedD0"){ |
2029 |
+ |
value = object2->correctedD0; |
2030 |
+ |
} |
2031 |
|
|
2032 |
|
|
2033 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2308 |
|
} |
2309 |
|
|
2310 |
|
|
2311 |
< |
// template <class InputObject> |
2312 |
< |
// BNmcparticle* getGenMatchedParticle(InputObject object){ |
2311 |
> |
template <class InputObject> |
2312 |
> |
int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){ |
2313 |
> |
// std::cout << "starting gen match\n"; |
2314 |
> |
int bestMatchIndex = -1; |
2315 |
> |
double bestMatchDeltaR = 999; |
2316 |
> |
//std::cout << "\n\n\n"; |
2317 |
> |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2318 |
> |
//std::cout << "pdgId = " << mcparticle->id << " status = " << mcparticle->status << " motherId = " << mcparticle->motherId << " grandMotherId = " << mcparticle->grandMotherId << std::endl; |
2319 |
> |
|
2320 |
> |
|
2321 |
> |
double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi); |
2322 |
> |
if(currentDeltaR > 0.05) continue; |
2323 |
> |
|
2324 |
> |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2325 |
> |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2326 |
> |
bestMatchDeltaR = currentDeltaR; |
2327 |
> |
} |
2328 |
> |
|
2329 |
> |
} |
2330 |
> |
// if(bestMatchIndex != -1) std::cout << "best match: pdgId = " << mcparticles->at(bestMatchIndex).id << " status = " << mcparticles->at(bestMatchIndex).status << " motherId = " << mcparticles->at(bestMatchIndex).motherId << " grandMotherId = " << mcparticles->at(bestMatchIndex).grandMotherId << std::endl; |
2331 |
> |
// std::cout << "finished gen match\n"; |
2332 |
> |
return bestMatchIndex; |
2333 |
> |
|
2334 |
> |
} |
2335 |
> |
|
2336 |
> |
|
2337 |
> |
int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){ |
2338 |
> |
|
2339 |
> |
int bestMatchIndex = -1; |
2340 |
> |
double bestMatchDeltaR = 999; |
2341 |
> |
|
2342 |
> |
for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){ |
2343 |
> |
|
2344 |
> |
if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue; |
2345 |
> |
|
2346 |
> |
double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi); |
2347 |
> |
if(currentDeltaR > 0.05) continue; |
2348 |
> |
|
2349 |
> |
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2350 |
> |
bestMatchIndex = mcparticle - mcparticles->begin(); |
2351 |
> |
bestMatchDeltaR = currentDeltaR; |
2352 |
> |
} |
2353 |
> |
|
2354 |
> |
} |
2355 |
> |
// if(bestMatchIndex != -1) std::cout << "best match: pdgId = " << mcparticles->at(bestMatchIndex).id << " status = " << mcparticles->at(bestMatchIndex).status << " motherId = " << mcparticles->at(bestMatchIndex).motherId << " grandMotherId = " << mcparticles->at(bestMatchIndex).grandMotherId << std::endl; |
2356 |
> |
return bestMatchIndex; |
2357 |
> |
} |
2358 |
> |
|
2359 |
> |
|
2360 |
> |
// bin particle type |
2361 |
> |
// --- ------------- |
2362 |
> |
// 0 unmatched |
2363 |
> |
// 1 u |
2364 |
> |
// 2 d |
2365 |
> |
// 3 s |
2366 |
> |
// 4 c |
2367 |
> |
// 5 b |
2368 |
> |
// 6 t |
2369 |
> |
// 7 e |
2370 |
> |
// 8 mu |
2371 |
> |
// 9 tau |
2372 |
> |
// 10 nu |
2373 |
> |
// 11 g |
2374 |
> |
// 12 gamma |
2375 |
> |
// 13 Z |
2376 |
> |
// 14 W |
2377 |
> |
// 15 light meson |
2378 |
> |
// 16 K meson |
2379 |
> |
// 17 D meson |
2380 |
> |
// 18 B meson |
2381 |
> |
// 19 light baryon |
2382 |
> |
// 20 strange baryon |
2383 |
> |
// 21 charm baryon |
2384 |
> |
// 22 bottom baryon |
2385 |
> |
// 23 other |
2386 |
> |
|
2387 |
> |
int OSUAnalysis::getPdgIdBinValue(int pdgId){ |
2388 |
> |
|
2389 |
> |
int binValue = -999; |
2390 |
> |
int absPdgId = fabs(pdgId); |
2391 |
> |
if(pdgId == -1) binValue = 0; |
2392 |
> |
else if(absPdgId <= 6 ) binValue = absPdgId; |
2393 |
> |
else if(absPdgId == 11 ) binValue = 7; |
2394 |
> |
else if(absPdgId == 13 ) binValue = 8; |
2395 |
> |
else if(absPdgId == 15 ) binValue = 9; |
2396 |
> |
else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10; |
2397 |
> |
else if(absPdgId == 21 ) binValue = 11; |
2398 |
> |
else if(absPdgId == 22 ) binValue = 12; |
2399 |
> |
else if(absPdgId == 23 ) binValue = 13; |
2400 |
> |
else if(absPdgId == 24 ) binValue = 14; |
2401 |
> |
else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130 ) binValue = 15; |
2402 |
> |
else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400) ) binValue = 16; |
2403 |
> |
else if(absPdgId > 400 && absPdgId < 500 ) binValue = 17; |
2404 |
> |
else if(absPdgId > 500 && absPdgId < 600 ) binValue = 18; |
2405 |
> |
else if(absPdgId > 1000 && absPdgId < 3000 ) binValue = 19; |
2406 |
> |
else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20; |
2407 |
> |
else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21; |
2408 |
> |
else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22; |
2409 |
|
|
2410 |
< |
// BNmcparticle bestMatch; |
2411 |
< |
// std::cout << bestMatch.energy() << std:endl; |
2412 |
< |
// for(BNmcparticleCollection::const_iterator mcparticle = mcParticles_->begin (); mcparticle != mcParticles_->end (); mcparticle++){ |
2413 |
< |
|
2414 |
< |
// } |
2120 |
< |
// return bestMatch; |
2121 |
< |
// } |
2410 |
> |
else binValue = 23; |
2411 |
> |
|
2412 |
> |
return binValue; |
2413 |
> |
|
2414 |
> |
} |
2415 |
|
|
2416 |
|
|
2417 |
|
DEFINE_FWK_MODULE(OSUAnalysis); |