23 |
|
datasetType_ (cfg.getParameter<std::string> ("datasetType")), |
24 |
|
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
25 |
|
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
26 |
< |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")) |
26 |
> |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")), |
27 |
> |
doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")) |
28 |
|
|
29 |
|
{ |
30 |
|
|
31 |
|
TH1::SetDefaultSumw2 (); |
32 |
|
|
33 |
|
//create pile-up reweighting object, if necessary |
34 |
< |
// if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
34 |
> |
if(doPileupReweighting_ && datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
35 |
|
|
36 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
37 |
|
// handle filling cut flow histograms. |
39 |
|
std::vector<TFileDirectory> directories; |
40 |
|
|
41 |
|
//always get vertex collection so we can assign the primary vertex in the event |
42 |
< |
|
43 |
< |
objectsToGet.push_back("primaryvertexs"); |
42 |
> |
objectsToGet.push_back("primaryvertexs"); |
43 |
> |
|
44 |
|
//always make the plot of number of primary verticex (to check pile-up reweighting) |
45 |
|
objectsToPlot.push_back("primaryvertexs"); |
46 |
|
|
268 |
|
int maxNum = 10; |
269 |
|
if(currentObject == "mcparticles") maxNum = 50; |
270 |
|
else if(currentObject == "primaryvertexs") maxNum = 50; |
271 |
< |
else if(currentObject == "muon-muon pairs") |
271 |
< |
{ |
272 |
< |
currentObject = "dimuonPairs"; |
273 |
< |
} |
271 |
> |
else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
272 |
|
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
273 |
|
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
274 |
|
|
434 |
|
event.getByLabel (genjets_, genjets); |
435 |
|
|
436 |
|
if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end()) |
437 |
< |
event.getByLabel (mcparticles_, mcparticles); |
440 |
< |
|
437 |
> |
event.getByLabel (mcparticles_, mcparticles); |
438 |
|
|
439 |
|
if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end()) |
440 |
|
event.getByLabel (primaryvertexs_, primaryvertexs); |
451 |
|
|
452 |
|
//get pile-up event weight |
453 |
|
double puScaleFactor = 1.00; |
454 |
< |
// if(datasetType_ != "data"){ |
455 |
< |
// puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
456 |
< |
// cout << puScaleFactor << endl; |
457 |
< |
//} |
454 |
> |
if(doPileupReweighting_ && datasetType_ != "data"){ |
455 |
> |
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
456 |
> |
//cout << puScaleFactor << endl; |
457 |
> |
} |
458 |
|
|
459 |
|
|
460 |
|
|
591 |
|
|
592 |
|
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
593 |
|
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
594 |
< |
else if(currentHistogram.inputCollection == "muon-muon pairs") |
595 |
< |
{ |
596 |
< |
fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
600 |
< |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
601 |
< |
|
602 |
< |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
603 |
< |
|
604 |
< |
} |
594 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
595 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
596 |
> |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
597 |
|
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
598 |
|
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
599 |
|
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
2186 |
|
else if(variable == "invMass"){ |
2187 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2188 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2189 |
< |
|
2190 |
< |
value = (fourVector1 + fourVector2).M();} |
2199 |
< |
|
2189 |
> |
value = (fourVector1 + fourVector2).M(); |
2190 |
> |
} |
2191 |
|
else if(variable == "threeDAngle") |
2192 |
|
{ |
2193 |
|
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2199 |
|
static const double pi = 3.1415926535897932384626433832795028841971693993751058; |
2200 |
|
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2201 |
|
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2202 |
< |
value = (pi-threeVector1.Angle( threeVector2)); |
2202 |
> |
value = (pi-threeVector1.Angle(threeVector2)); |
2203 |
|
} |
2213 |
– |
|
2214 |
– |
else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi); |
2215 |
– |
|
2216 |
– |
|
2204 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2205 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2206 |
|
else if(variable == "d0Sign"){ |
2209 |
|
else if (d0Sign > 0) value = 0.5; |
2210 |
|
else value = -999; |
2211 |
|
} |
2212 |
+ |
else if(variable == "chargeProduct"){ |
2213 |
+ |
value = object1->charge*object2->charge; |
2214 |
+ |
} |
2215 |
|
else if(variable == "muon1CorrectedD0Vertex"){ |
2216 |
|
value = object1->correctedD0Vertex; |
2217 |
|
} |
2226 |
|
} |
2227 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
2228 |
|
|
2239 |
– |
|
2240 |
– |
|
2241 |
– |
|
2242 |
– |
|
2243 |
– |
|
2244 |
– |
|
2245 |
– |
|
2229 |
|
value = applyFunction(function, value); |
2230 |
|
|
2231 |
|
return value; |
2241 |
|
else if(variable == "invMass"){ |
2242 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2243 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2244 |
< |
|
2245 |
< |
value = (fourVector1 + fourVector2).M();} |
2246 |
< |
else if(variable == "threeDAngle") |
2244 |
> |
value = (fourVector1 + fourVector2).M(); |
2245 |
> |
} |
2246 |
> |
else if(variable == "threeDAngle") |
2247 |
|
{ |
2248 |
|
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2249 |
|
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2250 |
|
value = (threeVector1.Angle(threeVector2)); |
2251 |
|
} |
2269 |
– |
|
2270 |
– |
|
2271 |
– |
|
2272 |
– |
|
2252 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2253 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2275 |
– |
|
2276 |
– |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2277 |
– |
|
2278 |
– |
|
2279 |
– |
|
2254 |
|
else if(variable == "d0Sign"){ |
2255 |
|
double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
2256 |
|
if(d0Sign < 0) value = -0.5; |
2257 |
|
else if (d0Sign > 0) value = 0.5; |
2258 |
|
else value = -999; |
2259 |
|
} |
2260 |
+ |
else if(variable == "chargeProduct"){ |
2261 |
+ |
value = object1->charge*object2->charge; |
2262 |
+ |
} |
2263 |
|
else if(variable == "electron1CorrectedD0Vertex"){ |
2264 |
|
value = object1->correctedD0Vertex; |
2265 |
|
} |
2284 |
|
else if(variable == "invMass"){ |
2285 |
|
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
2286 |
|
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
2287 |
< |
|
2288 |
< |
value = (fourVector1 + fourVector2).M();} |
2289 |
< |
else if(variable == "threeDAngle") |
2287 |
> |
value = (fourVector1 + fourVector2).M(); |
2288 |
> |
} |
2289 |
> |
else if(variable == "threeDAngle") |
2290 |
|
{ |
2291 |
|
TVector3 threeVector1(object1->px, object1->py, object1->pz); |
2292 |
|
TVector3 threeVector2(object2->px, object2->py, object2->pz); |
2293 |
|
value = (threeVector1.Angle(threeVector2)); |
2294 |
|
} |
2318 |
– |
|
2319 |
– |
|
2295 |
|
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
2296 |
|
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
2297 |
|
else if(variable == "d0Sign"){ |
2300 |
|
else if (d0Sign > 0) value = 0.5; |
2301 |
|
else value = -999; |
2302 |
|
} |
2303 |
+ |
else if(variable == "chargeProduct"){ |
2304 |
+ |
value = object1->charge*object2->charge; |
2305 |
+ |
} |
2306 |
|
else if(variable == "electronCorrectedD0Vertex"){ |
2307 |
|
value = object1->correctedD0Vertex; |
2308 |
|
} |
2497 |
|
bool decision = true;//object passes if this cut doesn't cut on that type of object |
2498 |
|
|
2499 |
|
if(currentCut.inputCollection == inputType){ |
2500 |
< |
|
2500 |
> |
|
2501 |
|
vector<bool> subcutDecisions; |
2502 |
|
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
2503 |
|
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
2506 |
|
|
2507 |
|
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
2508 |
|
else{ |
2509 |
< |
bool tempDecision = true; |
2510 |
< |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
2511 |
< |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
2512 |
< |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
2513 |
< |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
2514 |
< |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
2509 |
> |
bool tempDecision = subcutDecisions.at(0); |
2510 |
> |
for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){ |
2511 |
> |
if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&") |
2512 |
> |
tempDecision = tempDecision && subcutDecisions.at(subcutIndex); |
2513 |
> |
else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||") |
2514 |
> |
tempDecision = tempDecision || subcutDecisions.at(subcutIndex); |
2515 |
|
} |
2516 |
|
decision = tempDecision; |
2517 |
|
} |
2710 |
|
|
2711 |
|
double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi); |
2712 |
|
if(currentDeltaR > 0.05) continue; |
2713 |
< |
|
2713 |
> |
// cout << std::setprecision(3) << std::setw(20) |
2714 |
> |
// << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta |
2715 |
> |
// << std::setw(20) |
2716 |
> |
// << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi |
2717 |
> |
// << std::setw(20) |
2718 |
> |
// << "\tdeltaR = " << currentDeltaR |
2719 |
> |
// << std::setprecision(1) |
2720 |
> |
// << std::setw(20) |
2721 |
> |
// << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id |
2722 |
> |
// << std::setw(20) |
2723 |
> |
// << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId |
2724 |
> |
// << std::setw(20) |
2725 |
> |
// << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl; |
2726 |
|
if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){ |
2727 |
|
bestMatchIndex = mcparticle - mcparticles->begin(); |
2728 |
|
bestMatchDeltaR = currentDeltaR; |
2729 |
|
} |
2730 |
|
|
2731 |
|
} |
2732 |
< |
|
2732 |
> |
// if(bestMatchDeltaR != 999) cout << "bestMatch: deltaR = " << bestMatchDeltaR << " id = " << mcparticles->at(bestMatchIndex).id << " motherId = " << mcparticles->at(bestMatchIndex).motherId << endl; |
2733 |
> |
// else cout << "no match found..." << endl; |
2734 |
|
return bestMatchIndex; |
2735 |
|
|
2736 |
|
} |