15 |
|
bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")), |
16 |
|
photons_ (cfg.getParameter<edm::InputTag> ("photons")), |
17 |
|
superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")), |
18 |
< |
|
19 |
< |
|
20 |
< |
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")) |
18 |
> |
triggers_ (cfg.getParameter<edm::InputTag> ("triggers")), |
19 |
> |
puFile_ (cfg.getParameter<std::string> ("puFile")), |
20 |
> |
dataPU_ (cfg.getParameter<std::string> ("dataPU")), |
21 |
> |
dataset_ (cfg.getParameter<std::string> ("dataset")), |
22 |
> |
datasetType_ (cfg.getParameter<std::string> ("datasetType")), |
23 |
> |
channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")), |
24 |
> |
histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")), |
25 |
> |
plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")) |
26 |
|
|
27 |
|
{ |
28 |
+ |
|
29 |
|
TH1::SetDefaultSumw2 (); |
30 |
|
|
31 |
+ |
//create pile-up reweighting object, if necessary |
32 |
+ |
if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_); |
33 |
+ |
|
34 |
|
// Construct Cutflow Objects. These store the results of cut decisions and |
35 |
|
// handle filling cut flow histograms. |
36 |
|
masterCutFlow_ = new CutFlow (fs_); |
37 |
|
std::vector<TFileDirectory> directories; |
38 |
|
|
39 |
+ |
//always get vertex collection so we can assign the primary vertex in the event |
40 |
+ |
allNecessaryObjects.push_back("primaryvertexs"); |
41 |
+ |
//always make the plot of number of primary verticex (to check pile-up reweighting) |
42 |
+ |
objectsToPlot.push_back("primaryvertexs"); |
43 |
+ |
|
44 |
+ |
//always get the event collection to do pile-up reweighting |
45 |
+ |
allNecessaryObjects.push_back("events"); |
46 |
+ |
|
47 |
+ |
//parse the histogram definitions |
48 |
+ |
for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){ |
49 |
+ |
|
50 |
+ |
string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection"); |
51 |
+ |
if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs"; |
52 |
+ |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
53 |
+ |
objectsToPlot.push_back(tempInputCollection); |
54 |
+ |
allNecessaryObjects.push_back(tempInputCollection); |
55 |
+ |
} |
56 |
+ |
else{//pair of objects, need to add them both to the things to allNecessaryObjects |
57 |
+ |
int dashIndex = tempInputCollection.find("-"); |
58 |
+ |
int spaceIndex = tempInputCollection.find(" "); |
59 |
+ |
int secondWordLength = spaceIndex - dashIndex; |
60 |
+ |
allNecessaryObjects.push_back(tempInputCollection); |
61 |
+ |
allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
62 |
+ |
allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
63 |
+ |
objectsToPlot.push_back(tempInputCollection); |
64 |
+ |
objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
65 |
+ |
objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
66 |
+ |
} |
67 |
+ |
|
68 |
+ |
vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms")); |
69 |
+ |
|
70 |
+ |
for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){ |
71 |
+ |
|
72 |
+ |
histogram tempHistogram; |
73 |
+ |
tempHistogram.inputCollection = tempInputCollection; |
74 |
+ |
tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name"); |
75 |
+ |
tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title"); |
76 |
+ |
tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins"); |
77 |
+ |
tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables"); |
78 |
+ |
|
79 |
+ |
histograms.push_back(tempHistogram); |
80 |
+ |
|
81 |
+ |
} |
82 |
+ |
} |
83 |
+ |
//make unique vector of objects we need to plot (so we can book a histogram with the number of each object |
84 |
+ |
sort( objectsToPlot.begin(), objectsToPlot.end() ); |
85 |
+ |
objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() ); |
86 |
+ |
|
87 |
+ |
|
88 |
+ |
|
89 |
|
|
90 |
|
channel tempChannel; |
91 |
|
//loop over all channels (event selections) |
92 |
|
for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){ |
93 |
< |
|
93 |
> |
|
94 |
|
//get name of channel |
95 |
|
string channelName (channels_.at(currentChannel).getParameter<string>("name")); |
96 |
|
tempChannel.name = channelName; |
97 |
|
TString channelLabel = channelName; |
98 |
|
|
99 |
+ |
//set triggers for this channel |
100 |
+ |
vector<string> triggerNames; |
101 |
+ |
triggerNames.clear(); |
102 |
+ |
tempChannel.triggers.clear(); |
103 |
+ |
if(channels_.at(currentChannel).exists("triggers")){ |
104 |
+ |
triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers"); |
105 |
+ |
for(uint trigger = 0; trigger!= triggerNames.size(); trigger++) |
106 |
+ |
tempChannel.triggers.push_back(triggerNames.at(trigger)); |
107 |
+ |
allNecessaryObjects.push_back("triggers"); |
108 |
+ |
} |
109 |
+ |
|
110 |
+ |
|
111 |
+ |
|
112 |
|
|
113 |
|
//create cutFlow for this channel |
114 |
|
cutFlows_.push_back (new CutFlow (fs_, channelName)); |
116 |
|
//book a directory in the output file with the name of the channel |
117 |
|
TFileDirectory subDir = fs_->mkdir( channelName ); |
118 |
|
directories.push_back(subDir); |
47 |
– |
std::map<std::string, TH1D*> histoMap; |
48 |
– |
oneDHists_.push_back(histoMap); |
119 |
|
|
120 |
+ |
std::map<std::string, TH1D*> oneDhistoMap; |
121 |
+ |
oneDHists_.push_back(oneDhistoMap); |
122 |
+ |
std::map<std::string, TH2D*> twoDhistoMap; |
123 |
+ |
twoDHists_.push_back(twoDhistoMap); |
124 |
|
|
51 |
– |
//muon histograms |
52 |
– |
oneDHists_.at(currentChannel)["muonPt"] = directories.at(currentChannel).make<TH1D> ("muonPt",channelLabel+" channel: Muon Transverse Momentum; p_{T} [GeV]", 100, 0, 500); |
53 |
– |
oneDHists_.at(currentChannel)["muonEta"] = directories.at(currentChannel).make<TH1D> ("muonEta",channelLabel+" channel: Muon Eta; #eta", 100, -5, 5); |
54 |
– |
oneDHists_.at(currentChannel)["muonD0"] = directories.at(currentChannel).make<TH1D> ("muonD0",channelLabel+" channel: Muon d_{0}; d_{0} [cm] ", 1000, -1, 1); |
55 |
– |
oneDHists_.at(currentChannel)["muonAbsD0"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0",channelLabel+" channel: Muon d_{0}; |d_{0}| [cm] ", 1000, 0, 1); |
56 |
– |
oneDHists_.at(currentChannel)["muonD0Sig"] = directories.at(currentChannel).make<TH1D> ("muonD0Sig",channelLabel+" channel: Muon d_{0} Significance; d_{0} / #sigma_{d_{0}} ", 1000, -10.0, 10.0); |
57 |
– |
oneDHists_.at(currentChannel)["muonAbsD0Sig"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0Sig",channelLabel+" channel: Muon d_{0} Significance; |d_{0}| / #sigma_{d_{0}} ", 1000, 0, 10.0); |
58 |
– |
oneDHists_.at(currentChannel)["muonIso"] = directories.at(currentChannel).make<TH1D> ("muonIso",channelLabel+" channel: Muon Combined Relative Isolation; rel. iso. ", 1000, 0, 1); |
59 |
– |
oneDHists_.at(currentChannel)["numMuons"] = directories.at(currentChannel).make<TH1D> ("numMuons",channelLabel+" channel: Number of Selected Muons; # muons", 10, 0, 10); |
60 |
– |
|
61 |
– |
|
62 |
– |
//electron histograms |
63 |
– |
oneDHists_.at(currentChannel)["electronPt"] = directories.at(currentChannel).make<TH1D> ("electronPt",channelLabel+" channel: Electron Transverse Momentum; p_{T} [GeV]", 100, 0, 500); |
64 |
– |
oneDHists_.at(currentChannel)["electronEta"] = directories.at(currentChannel).make<TH1D> ("electronEta",channelLabel+" channel: Electron Eta; #eta", 50, -5, 5); |
65 |
– |
oneDHists_.at(currentChannel)["electronD0"] = directories.at(currentChannel).make<TH1D> ("electronD0",channelLabel+" channel: Electron d_{0}; d_{0} [cm] ", 1000, -1, 1); |
66 |
– |
oneDHists_.at(currentChannel)["electronAbsD0"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0",channelLabel+" channel: Electron d_{0}; |d_{0}| [cm] ", 1000, 0, 1); |
67 |
– |
oneDHists_.at(currentChannel)["electronD0Sig"] = directories.at(currentChannel).make<TH1D> ("electronD0Sig",channelLabel+" channel: Electron d_{0} Significance; d_{0} / #sigma_{d_{0}} ", 1000, -10.0, 10.0); |
68 |
– |
oneDHists_.at(currentChannel)["electronAbsD0Sig"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0Sig",channelLabel+" channel: Electron d_{0} Significance; |d_{0}| / #sigma_{d_{0}} ", 1000, 0, 10.0); |
69 |
– |
oneDHists_.at(currentChannel)["electronIso"] = directories.at(currentChannel).make<TH1D> ("electronIso",channelLabel+" channel: Electron Combined Relative Isolation; rel. iso. ", 1000, 0, 1); |
70 |
– |
oneDHists_.at(currentChannel)["electronFbrem"] = directories.at(currentChannel).make<TH1D> ("electronFbrem",channelLabel+" channel: Electron Brem. Energy Fraction; fbrem", 1000, 0, 2); |
71 |
– |
oneDHists_.at(currentChannel)["numElectrons"] = directories.at(currentChannel).make<TH1D> ("numElectrons",channelLabel+" channel: Number of Selected Electrons; # electrons", 10, 0, 10); |
125 |
|
|
126 |
+ |
//book all histograms included in the configuration |
127 |
+ |
for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){ |
128 |
+ |
histogram currentHistogram = histograms.at(currentHistogramIndex); |
129 |
+ |
int numBinsElements = currentHistogram.bins.size(); |
130 |
+ |
int numInputVariables = currentHistogram.inputVariables.size(); |
131 |
+ |
|
132 |
+ |
if(numBinsElements != 3 && numBinsElements !=6) { |
133 |
+ |
std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n"; |
134 |
+ |
exit(0); |
135 |
+ |
} |
136 |
+ |
else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){ |
137 |
+ |
std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n"; |
138 |
+ |
exit(0); |
139 |
+ |
} |
140 |
+ |
else if(numBinsElements == 3){ |
141 |
+ |
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)); |
142 |
+ |
} |
143 |
+ |
else if(numBinsElements == 6){ |
144 |
+ |
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)); |
145 |
+ |
|
146 |
+ |
} |
147 |
+ |
|
148 |
+ |
|
149 |
+ |
} |
150 |
+ |
//book a histogram for the number of each object type to be plotted |
151 |
+ |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
152 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
153 |
+ |
int maxNum = 10; |
154 |
+ |
if(currentObject == "mcparticles") maxNum = 50; |
155 |
+ |
else if(currentObject == "primaryvertexs") maxNum = 50; |
156 |
+ |
else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
157 |
+ |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
158 |
+ |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
159 |
+ |
|
160 |
+ |
currentObject.at(0) = toupper(currentObject.at(0)); |
161 |
+ |
string histoName = "num" + currentObject; |
162 |
+ |
|
163 |
+ |
if(histoName == "numPrimaryvertexs"){ |
164 |
+ |
string newHistoName = histoName + "BeforePileupCorrection"; |
165 |
+ |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
166 |
+ |
newHistoName = histoName + "AfterPileupCorrection"; |
167 |
+ |
oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum); |
168 |
+ |
} |
169 |
+ |
else |
170 |
+ |
oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum); |
171 |
+ |
} |
172 |
|
|
173 |
|
|
174 |
|
//get list of cuts for this channel |
175 |
|
vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts")); |
176 |
|
|
78 |
– |
vector<string> tempInputCollections; |
79 |
– |
|
80 |
– |
|
177 |
|
//loop over and parse all cuts |
178 |
|
for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){ |
83 |
– |
|
179 |
|
cut tempCut; |
180 |
< |
//store input collection for cut |
181 |
< |
string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
182 |
< |
tempCut.inputCollection = inputCollection; |
183 |
< |
|
184 |
< |
tempInputCollections.push_back(inputCollection); |
185 |
< |
allNecessaryObjects.push_back(inputCollection); |
180 |
> |
//store input collection for cut |
181 |
> |
string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection"); |
182 |
> |
tempCut.inputCollection = tempInputCollection; |
183 |
> |
if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object |
184 |
> |
allNecessaryObjects.push_back(tempInputCollection); |
185 |
> |
} |
186 |
> |
else{//pair of objects, need to add them both to the things to allNecessaryObjects |
187 |
> |
int dashIndex = tempInputCollection.find("-"); |
188 |
> |
int spaceIndex = tempInputCollection.find(" "); |
189 |
> |
int secondWordLength = spaceIndex - dashIndex; |
190 |
> |
allNecessaryObjects.push_back(tempInputCollection); |
191 |
> |
allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s"); |
192 |
> |
allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s"); |
193 |
> |
|
194 |
> |
} |
195 |
> |
|
196 |
> |
|
197 |
|
|
198 |
|
//split cut string into parts and store them |
199 |
|
string cutString = cuts_.at(currentCut).getParameter<string> ("cutString"); |
200 |
|
std::vector<string> cutStringVector = splitString(cutString); |
201 |
< |
tempCut.variable = cutStringVector.at(0);// variable to cut on |
202 |
< |
tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make |
203 |
< |
tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut |
201 |
> |
if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){ |
202 |
> |
std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n"; |
203 |
> |
exit(0); |
204 |
> |
} |
205 |
> |
tempCut.numSubcuts = (cutStringVector.size()+1)/4; |
206 |
> |
for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,| |
207 |
> |
int indexOffset = 4 * subcutIndex; |
208 |
> |
string currentVariableString = cutStringVector.at(indexOffset); |
209 |
> |
if(currentVariableString.find("(")==std::string::npos){ |
210 |
> |
tempCut.functions.push_back("");//no function was specified |
211 |
> |
tempCut.variables.push_back(currentVariableString);// variable to cut on |
212 |
> |
} |
213 |
> |
else{ |
214 |
> |
tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "(" |
215 |
> |
string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string |
216 |
> |
tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")" |
217 |
> |
} |
218 |
> |
tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make |
219 |
> |
tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut |
220 |
> |
if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or) |
221 |
> |
} |
222 |
|
|
223 |
|
//get number of objects required to pass cut for event to pass |
224 |
|
string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired"); |
225 |
|
std::vector<string> numberRequiredVector = splitString(numberRequiredString); |
226 |
+ |
if(numberRequiredVector.size()!=2){ |
227 |
+ |
std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n"; |
228 |
+ |
exit(0); |
229 |
+ |
} |
230 |
|
|
231 |
< |
// determine number required if comparison contains "=" |
104 |
< |
int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str()); |
105 |
< |
if(numberRequiredVector.at(0) == ">") numberRequiredInt++; |
106 |
< |
else if(numberRequiredVector.at(0) == "<") numberRequiredInt--; |
107 |
< |
|
231 |
> |
int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str()); |
232 |
|
tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut |
233 |
|
tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make |
234 |
< |
|
234 |
> |
|
235 |
|
|
236 |
|
string tempCutName; |
237 |
|
if(cuts_.at(currentCut).exists("alias")){ |
238 |
< |
tempCutName = cuts_.at(currentCut).getParameter<string> ("alias"); |
238 |
> |
tempCutName = cuts_.at(currentCut).getParameter<string> ("alias"); |
239 |
|
} |
240 |
|
else{ |
241 |
< |
//construct string for cutflow table |
242 |
< |
bool plural = numberRequiredInt != 1; |
243 |
< |
string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1); |
244 |
< |
string cutName = numberRequiredString + " " + collectionString + " with " + cutString; |
245 |
< |
tempCutName = cutName; |
241 |
> |
//construct string for cutflow table |
242 |
> |
bool plural = numberRequiredInt != 1; |
243 |
> |
string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1); |
244 |
> |
string cutName = numberRequiredString + " " + collectionString + " with " + cutString; |
245 |
> |
tempCutName = cutName; |
246 |
|
} |
247 |
|
tempCut.name = tempCutName; |
248 |
|
|
250 |
|
tempChannel.cuts.push_back(tempCut); |
251 |
|
|
252 |
|
|
129 |
– |
}//end loop over cuts |
253 |
|
|
254 |
< |
//make unique vector of all objects that this channel cuts on (so we know to set flags for those) |
132 |
< |
sort( tempInputCollections.begin(), tempInputCollections.end() ); |
133 |
< |
tempInputCollections.erase( unique( tempInputCollections.begin(), tempInputCollections.end() ), tempInputCollections.end() ); |
134 |
< |
tempChannel.inputCollections = tempInputCollections; |
254 |
> |
}//end loop over cuts |
255 |
|
|
256 |
|
channels.push_back(tempChannel); |
257 |
|
tempChannel.cuts.clear(); |
278 |
|
void |
279 |
|
OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup) |
280 |
|
{ |
281 |
+ |
|
282 |
+ |
|
283 |
|
// Retrieve necessary collections from the event. |
284 |
+ |
edm::Handle<BNtriggerCollection> triggers; |
285 |
+ |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end()) |
286 |
+ |
event.getByLabel (triggers_, triggers); |
287 |
+ |
|
288 |
|
edm::Handle<BNjetCollection> jets; |
289 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end()) |
289 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end()) |
290 |
|
event.getByLabel (jets_, jets); |
291 |
|
|
292 |
|
edm::Handle<BNmuonCollection> muons; |
293 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end()) |
293 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end()) |
294 |
|
event.getByLabel (muons_, muons); |
295 |
|
|
296 |
|
edm::Handle<BNelectronCollection> electrons; |
297 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end()) |
297 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end()) |
298 |
|
event.getByLabel (electrons_, electrons); |
299 |
|
|
300 |
|
edm::Handle<BNeventCollection> events; |
301 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end()) |
301 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end()) |
302 |
|
event.getByLabel (events_, events); |
303 |
|
|
304 |
|
edm::Handle<BNtauCollection> taus; |
305 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end()) |
305 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end()) |
306 |
|
event.getByLabel (taus_, taus); |
307 |
|
|
308 |
|
edm::Handle<BNmetCollection> mets; |
309 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end()) |
309 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end()) |
310 |
|
event.getByLabel (mets_, mets); |
311 |
|
|
312 |
|
edm::Handle<BNtrackCollection> tracks; |
313 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end()) |
313 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end()) |
314 |
|
event.getByLabel (tracks_, tracks); |
315 |
|
|
316 |
|
edm::Handle<BNgenjetCollection> genjets; |
317 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end()) |
317 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end()) |
318 |
|
event.getByLabel (genjets_, genjets); |
319 |
|
|
320 |
|
edm::Handle<BNmcparticleCollection> mcparticles; |
321 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end()) |
321 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end()) |
322 |
|
event.getByLabel (mcparticles_, mcparticles); |
323 |
|
|
324 |
|
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
325 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end()) |
325 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end()) |
326 |
|
event.getByLabel (primaryvertexs_, primaryvertexs); |
327 |
|
|
328 |
|
edm::Handle<BNbxlumiCollection> bxlumis; |
329 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end()) |
329 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end()) |
330 |
|
event.getByLabel (bxlumis_, bxlumis); |
331 |
|
|
332 |
|
edm::Handle<BNphotonCollection> photons; |
333 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end()) |
333 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end()) |
334 |
|
event.getByLabel (photons_, photons); |
335 |
|
|
336 |
|
edm::Handle<BNsuperclusterCollection> superclusters; |
337 |
< |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end()) |
337 |
> |
if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end()) |
338 |
|
event.getByLabel (superclusters_, superclusters); |
339 |
|
|
340 |
|
|
341 |
+ |
//get pile-up event weight |
342 |
+ |
double puScaleFactor = 0; |
343 |
+ |
if(datasetType_ != "data") |
344 |
+ |
puScaleFactor = puWeight_->at (events->at (0).numTruePV); |
345 |
+ |
else |
346 |
+ |
puScaleFactor = 1.00; |
347 |
+ |
|
348 |
+ |
|
349 |
|
//loop over all channels |
350 |
|
|
351 |
|
for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){ |
352 |
|
channel currentChannel = channels.at(currentChannelIndex); |
353 |
|
|
354 |
< |
flagMap individualFlags; |
355 |
< |
flagMap cumulativeFlags; |
356 |
< |
counterMap passingCounter; |
357 |
< |
|
358 |
< |
|
359 |
< |
|
354 |
> |
flagMap individualFlags; |
355 |
> |
flagMap cumulativeFlags; |
356 |
> |
counterMap passingCounter; |
357 |
> |
|
358 |
> |
bool triggerDecision = true; |
359 |
> |
if(currentChannel.triggers.size() != 0){ //triggers specified |
360 |
> |
triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product()); |
361 |
> |
cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision; |
362 |
> |
} |
363 |
|
|
364 |
|
//loop over all cuts |
365 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
366 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
367 |
|
|
368 |
|
for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){ |
369 |
+ |
string currentObject = allNecessaryObjects.at(currentObjectIndex); |
370 |
|
|
371 |
< |
string currentObject = allNecessaryObjects.at(currentObjectIndex); |
372 |
< |
individualFlags[currentObject].push_back (vector<bool> ()); |
235 |
< |
cumulativeFlags[currentObject].push_back (vector<bool> ()); |
236 |
< |
|
237 |
< |
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
238 |
< |
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
239 |
< |
else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons"); |
240 |
< |
else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events"); |
241 |
< |
else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus"); |
242 |
< |
else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets"); |
243 |
< |
else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks"); |
244 |
< |
else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets"); |
245 |
< |
else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles"); |
246 |
< |
else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs"); |
247 |
< |
else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis"); |
248 |
< |
else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons"); |
249 |
< |
else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters"); |
371 |
> |
individualFlags[currentObject].push_back (vector<bool> ()); |
372 |
> |
cumulativeFlags[currentObject].push_back (vector<bool> ()); |
373 |
|
|
374 |
|
|
375 |
+ |
if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets"); |
376 |
+ |
else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons"); |
377 |
+ |
else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons"); |
378 |
+ |
else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events"); |
379 |
+ |
else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus"); |
380 |
+ |
else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets"); |
381 |
+ |
else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks"); |
382 |
+ |
else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets"); |
383 |
+ |
else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles"); |
384 |
+ |
else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs"); |
385 |
+ |
else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis"); |
386 |
+ |
else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons"); |
387 |
+ |
else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters"); |
388 |
+ |
|
389 |
+ |
else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs"); |
390 |
+ |
else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs"); |
391 |
+ |
else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs"); |
392 |
+ |
|
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
}//end loop over all cuts |
398 |
< |
|
398 |
> |
|
399 |
|
|
400 |
|
|
401 |
|
//use cumulative flags to apply cuts at event level |
402 |
|
|
403 |
|
bool eventPassedAllCuts = true; |
404 |
|
|
405 |
+ |
//apply trigger (true if none were specified) |
406 |
+ |
eventPassedAllCuts = eventPassedAllCuts && triggerDecision; |
407 |
+ |
|
408 |
+ |
|
409 |
|
for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){ |
410 |
|
|
411 |
|
//loop over all objects and count how many passed the cumulative selection up to this point |
412 |
|
cut currentCut = currentChannel.cuts.at(currentCutIndex); |
413 |
|
int numberPassing = 0; |
269 |
– |
|
270 |
– |
for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++) |
271 |
– |
if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++; |
414 |
|
|
415 |
+ |
for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){ |
416 |
+ |
if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++; |
417 |
+ |
} |
418 |
|
|
419 |
|
bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired); |
420 |
|
cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision; |
423 |
|
|
424 |
|
} |
425 |
|
|
426 |
< |
cutFlows_.at(currentChannelIndex)->fillCutFlow(); |
282 |
< |
|
283 |
< |
string lastCutName = currentChannel.cuts.back().name; //get name of final cut |
284 |
< |
|
285 |
< |
|
426 |
> |
cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor); |
427 |
|
|
428 |
|
|
429 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
293 |
– |
vector<bool> electronFlags = cumulativeFlags["electrons"].back(); |
294 |
– |
int electronCounter = 0; |
434 |
|
|
435 |
< |
for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){ |
436 |
< |
if(!electronFlags.at(electronIndex)) continue; |
437 |
< |
|
438 |
< |
|
439 |
< |
electronCounter++; |
440 |
< |
oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt); |
441 |
< |
oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta); |
303 |
< |
oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex); |
304 |
< |
oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex)); |
305 |
< |
oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err); |
306 |
< |
oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err); |
307 |
< |
oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (((electrons->at(electronIndex).trackIso + electrons->at(electronIndex).caloIso) / electrons->at(electronIndex).pt)); |
308 |
< |
oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem); |
435 |
> |
//set position of primary vertex in event, in order to calculate quantities relative to it |
436 |
> |
primaryVertex_ = 0; |
437 |
> |
vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back(); |
438 |
> |
for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){ |
439 |
> |
if(!vertexFlags.at(vertexIndex)) continue; |
440 |
> |
primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex)); |
441 |
> |
break; |
442 |
|
} |
310 |
– |
oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter); |
443 |
|
|
312 |
– |
|
313 |
– |
vector<bool> muonFlags = cumulativeFlags["muons"].back(); |
314 |
– |
int muonCounter = 0; |
444 |
|
|
445 |
|
|
446 |
< |
for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){ |
447 |
< |
if(!muonFlags.at(muonIndex)) continue; |
448 |
< |
muonCounter++; |
449 |
< |
|
450 |
< |
oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt); |
451 |
< |
oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta); |
452 |
< |
oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex); |
453 |
< |
oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex)); |
454 |
< |
oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err); |
455 |
< |
oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err); |
456 |
< |
oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (((muons->at(muonIndex).trackIso + muons->at(muonIndex).caloIso) / muons->at(muonIndex).pt)); |
446 |
> |
//filling histograms |
447 |
> |
for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){ |
448 |
> |
histogram currentHistogram = histograms.at(histogramIndex); |
449 |
> |
|
450 |
> |
if(currentHistogram.inputVariables.size() == 1){ |
451 |
> |
TH1D* histo; |
452 |
> |
histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name); |
453 |
> |
if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
454 |
> |
else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
455 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\ |
456 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\ |
457 |
> |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
458 |
> |
else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
459 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\ |
460 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\ |
461 |
> |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
462 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \ |
463 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), |
464 |
> |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
465 |
> |
else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
466 |
> |
else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
467 |
> |
else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
468 |
> |
else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
469 |
> |
else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
470 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
471 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
472 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
473 |
> |
else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
474 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
475 |
> |
} |
476 |
> |
else if(currentHistogram.inputVariables.size() == 2){ |
477 |
> |
TH2D* histo; |
478 |
> |
histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name); |
479 |
> |
if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor); |
480 |
> |
else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor); |
481 |
> |
else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \ |
482 |
> |
cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \ |
483 |
> |
cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor); |
484 |
> |
else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor); |
485 |
> |
else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \ |
486 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \ |
487 |
> |
cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor); |
488 |
> |
else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \ |
489 |
> |
cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \ |
490 |
> |
cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor); |
491 |
> |
else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor); |
492 |
> |
else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor); |
493 |
> |
else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor); |
494 |
> |
else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor); |
495 |
> |
else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor); |
496 |
> |
else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor); |
497 |
> |
else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor); |
498 |
> |
else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor); |
499 |
> |
else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor); |
500 |
> |
else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor); |
501 |
> |
} |
502 |
|
} |
329 |
– |
oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter); |
330 |
– |
|
331 |
– |
|
503 |
|
|
504 |
|
|
505 |
+ |
//fills histograms with the sizes of collections |
506 |
+ |
for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){ |
507 |
+ |
string currentObject = objectsToPlot.at(currentObjectIndex); |
508 |
+ |
|
509 |
+ |
if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs"; |
510 |
+ |
else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs"; |
511 |
+ |
else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs"; |
512 |
+ |
string tempCurrentObject = currentObject; |
513 |
+ |
tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0)); |
514 |
+ |
string histoName = "num" + tempCurrentObject; |
515 |
+ |
|
516 |
+ |
|
517 |
+ |
if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor); |
518 |
+ |
else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor); |
519 |
+ |
else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor); |
520 |
+ |
else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor); |
521 |
+ |
else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor); |
522 |
+ |
else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor); |
523 |
+ |
else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor); |
524 |
+ |
else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor); |
525 |
+ |
else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor); |
526 |
+ |
else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor); |
527 |
+ |
else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor); |
528 |
+ |
else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor); |
529 |
+ |
else if(currentObject == "primaryvertexs"){ |
530 |
+ |
oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size()); |
531 |
+ |
oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor); |
532 |
+ |
} |
533 |
+ |
else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor); |
534 |
+ |
else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor); |
535 |
+ |
else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor); |
536 |
|
|
537 |
+ |
} |
538 |
|
} //end loop over channel |
539 |
|
|
540 |
< |
masterCutFlow_->fillCutFlow(); |
540 |
> |
masterCutFlow_->fillCutFlow(puScaleFactor); |
541 |
> |
|
542 |
|
|
543 |
|
|
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
< |
bool |
547 |
> |
bool |
548 |
|
OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){ |
549 |
|
|
550 |
+ |
|
551 |
|
if(comparison == ">") return testValue > cutValue; |
552 |
|
else if(comparison == ">=") return testValue >= cutValue; |
553 |
|
else if(comparison == "<") return testValue < cutValue; |
554 |
|
else if(comparison == "<=") return testValue <= cutValue; |
555 |
+ |
else if(comparison == "==") return testValue == cutValue; |
556 |
+ |
else if(comparison == "=") return testValue == cutValue; |
557 |
+ |
else if(comparison == "!=") return testValue != cutValue; |
558 |
|
else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;} |
559 |
|
|
560 |
|
} |
561 |
|
|
562 |
+ |
bool |
563 |
+ |
OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){ |
564 |
+ |
|
565 |
+ |
bool triggerDecision = false; |
566 |
+ |
|
567 |
+ |
for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++) |
568 |
+ |
{ |
569 |
+ |
if(trigger->pass != 1) continue; |
570 |
+ |
for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++) |
571 |
+ |
{ |
572 |
+ |
if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){ |
573 |
+ |
triggerDecision = true; |
574 |
+ |
} |
575 |
+ |
} |
576 |
+ |
} |
577 |
+ |
return triggerDecision; |
578 |
+ |
|
579 |
+ |
} |
580 |
+ |
|
581 |
|
std::vector<std::string> |
582 |
|
OSUAnalysis::splitString (string inputString){ |
583 |
|
|
590 |
|
} |
591 |
|
|
592 |
|
double |
593 |
< |
OSUAnalysis::valueLookup (const BNjet* object, string variable){ |
593 |
> |
OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){ |
594 |
|
|
595 |
|
double value = 0.0; |
596 |
|
if(variable == "energy") value = object->energy; |
708 |
|
else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full; |
709 |
|
else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple; |
710 |
|
else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased; |
711 |
< |
|
712 |
< |
|
711 |
> |
|
712 |
> |
|
713 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
714 |
< |
|
714 |
> |
|
715 |
> |
value = applyFunction(function, value); |
716 |
|
|
717 |
|
return value; |
718 |
|
} |
720 |
|
|
721 |
|
|
722 |
|
double |
723 |
< |
OSUAnalysis::valueLookup (const BNmuon* object, string variable){ |
723 |
> |
OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){ |
724 |
|
|
725 |
|
double value = 0.0; |
726 |
|
if(variable == "energy") value = object->energy; |
874 |
|
else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations; |
875 |
|
else if(variable == "time_ndof") value = object->time_ndof; |
876 |
|
|
877 |
+ |
//user-defined variables |
878 |
+ |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
879 |
+ |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
880 |
+ |
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
881 |
+ |
else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt; |
882 |
+ |
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt; |
883 |
+ |
else if(variable == "tightID") { |
884 |
+ |
value = object->isGlobalMuon > 0 \ |
885 |
+ |
&& object->isPFMuon > 0 \ |
886 |
+ |
&& object->normalizedChi2 < 10 \ |
887 |
+ |
&& object->numberOfValidMuonHits > 0 \ |
888 |
+ |
&& object->numberOfMatchedStations > 1 \ |
889 |
+ |
&& fabs(object->correctedD0Vertex) < 0.2 \ |
890 |
+ |
&& fabs(object->correctedDZ) < 0.5 \ |
891 |
+ |
&& object->numberOfValidPixelHits > 0 \ |
892 |
+ |
&& object->numberOfLayersWithMeasurement > 5; |
893 |
+ |
|
894 |
+ |
|
895 |
+ |
} |
896 |
+ |
else if(variable == "tightIDdisplaced"){ |
897 |
+ |
value = object->isGlobalMuon > 0 \ |
898 |
+ |
&& object->isPFMuon > 0 \ |
899 |
+ |
&& object->normalizedChi2 < 10 \ |
900 |
+ |
&& object->numberOfValidMuonHits > 0 \ |
901 |
+ |
&& object->numberOfMatchedStations > 1 \ |
902 |
+ |
&& object->numberOfValidPixelHits > 0 \ |
903 |
+ |
&& object->numberOfLayersWithMeasurement > 5; |
904 |
+ |
} |
905 |
+ |
|
906 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
907 |
< |
|
907 |
> |
|
908 |
> |
value = applyFunction(function, value); |
909 |
|
|
910 |
|
return value; |
911 |
|
} |
912 |
|
|
913 |
|
|
914 |
|
double |
915 |
< |
OSUAnalysis::valueLookup (const BNelectron* object, string variable){ |
915 |
> |
OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){ |
916 |
|
|
917 |
|
double value = 0.0; |
918 |
|
if(variable == "energy") value = object->energy; |
1072 |
|
else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC; |
1073 |
|
else if(variable == "passConvVeto") value = object->passConvVeto; |
1074 |
|
|
1075 |
+ |
//user-defined variables |
1076 |
+ |
else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1077 |
+ |
else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError)); |
1078 |
+ |
else if(variable == "detIso") value = (object->trackIso) / object->pt; |
1079 |
+ |
else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt; |
1080 |
+ |
|
1081 |
|
|
1082 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1083 |
< |
|
1083 |
> |
|
1084 |
> |
value = applyFunction(function, value); |
1085 |
|
|
1086 |
|
return value; |
1087 |
|
} |
1088 |
|
|
1089 |
|
|
1090 |
|
double |
1091 |
< |
OSUAnalysis::valueLookup (const BNevent* object, string variable){ |
1091 |
> |
OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){ |
1092 |
|
|
1093 |
|
double value = 0.0; |
1094 |
|
|
1158 |
|
else if(variable == "evt") value = object->evt; |
1159 |
|
|
1160 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1161 |
< |
|
1161 |
> |
|
1162 |
> |
value = applyFunction(function, value); |
1163 |
|
|
1164 |
|
return value; |
1165 |
|
} |
1166 |
|
|
1167 |
|
double |
1168 |
< |
OSUAnalysis::valueLookup (const BNtau* object, string variable){ |
1168 |
> |
OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){ |
1169 |
|
|
1170 |
|
double value = 0.0; |
1171 |
|
|
1211 |
|
|
1212 |
|
|
1213 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1214 |
< |
|
1214 |
> |
|
1215 |
> |
value = applyFunction(function, value); |
1216 |
|
|
1217 |
|
return value; |
1218 |
|
} |
1219 |
|
|
1220 |
|
double |
1221 |
< |
OSUAnalysis::valueLookup (const BNmet* object, string variable){ |
1221 |
> |
OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){ |
1222 |
|
|
1223 |
|
double value = 0.0; |
1224 |
|
|
1283 |
|
else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi; |
1284 |
|
|
1285 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1286 |
< |
|
1286 |
> |
|
1287 |
> |
value = applyFunction(function, value); |
1288 |
|
|
1289 |
|
return value; |
1290 |
|
} |
1291 |
|
|
1292 |
|
double |
1293 |
< |
OSUAnalysis::valueLookup (const BNtrack* object, string variable){ |
1293 |
> |
OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){ |
1294 |
|
|
1295 |
|
double value = 0.0; |
1296 |
|
|
1314 |
|
|
1315 |
|
|
1316 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1317 |
< |
|
1317 |
> |
|
1318 |
> |
value = applyFunction(function, value); |
1319 |
|
|
1320 |
|
return value; |
1321 |
|
} |
1322 |
|
|
1323 |
|
double |
1324 |
< |
OSUAnalysis::valueLookup (const BNgenjet* object, string variable){ |
1324 |
> |
OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){ |
1325 |
|
|
1326 |
|
double value = 0.0; |
1327 |
|
|
1342 |
|
|
1343 |
|
|
1344 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1345 |
< |
|
1345 |
> |
|
1346 |
> |
value = applyFunction(function, value); |
1347 |
|
|
1348 |
|
return value; |
1349 |
|
} |
1350 |
|
|
1351 |
|
double |
1352 |
< |
OSUAnalysis::valueLookup (const BNmcparticle* object, string variable){ |
1352 |
> |
OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){ |
1353 |
|
|
1354 |
|
double value = 0.0; |
1355 |
|
|
1438 |
|
else if(variable == "grandMother11Status") value = object->grandMother11Status; |
1439 |
|
else if(variable == "grandMother11Charge") value = object->grandMother11Charge; |
1440 |
|
|
1441 |
+ |
//user-defined variables |
1442 |
+ |
else if (variable == "d0"){ |
1443 |
+ |
double vx = object->vx - primaryVertex_->x, |
1444 |
+ |
vy = object->vy - primaryVertex_->y, |
1445 |
+ |
px = object->px, |
1446 |
+ |
py = object->py, |
1447 |
+ |
pt = object->pt; |
1448 |
+ |
value = (-vx * py + vy * px) / pt; |
1449 |
+ |
} |
1450 |
+ |
else if (variable == "dz"){ |
1451 |
+ |
double vx = object->vx - primaryVertex_->x, |
1452 |
+ |
vy = object->vy - primaryVertex_->y, |
1453 |
+ |
vz = object->vz - primaryVertex_->z, |
1454 |
+ |
px = object->px, |
1455 |
+ |
py = object->py, |
1456 |
+ |
pz = object->pz, |
1457 |
+ |
pt = object->pt; |
1458 |
+ |
value = vz - (vx * px + vy * py)/pt * (pz/pt); |
1459 |
+ |
} |
1460 |
+ |
|
1461 |
+ |
|
1462 |
+ |
|
1463 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1464 |
< |
|
1464 |
> |
|
1465 |
> |
value = applyFunction(function, value); |
1466 |
|
|
1467 |
|
return value; |
1468 |
|
} |
1469 |
|
|
1470 |
|
double |
1471 |
< |
OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable){ |
1471 |
> |
OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){ |
1472 |
|
|
1473 |
|
double value = 0.0; |
1474 |
|
|
1488 |
|
|
1489 |
|
|
1490 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1491 |
< |
|
1491 |
> |
|
1492 |
> |
value = applyFunction(function, value); |
1493 |
|
|
1494 |
|
return value; |
1495 |
|
} |
1496 |
|
|
1497 |
|
double |
1498 |
< |
OSUAnalysis::valueLookup (const BNbxlumi* object, string variable){ |
1498 |
> |
OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){ |
1499 |
|
|
1500 |
|
double value = 0.0; |
1501 |
|
|
1505 |
|
|
1506 |
|
|
1507 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1508 |
< |
|
1508 |
> |
|
1509 |
> |
value = applyFunction(function, value); |
1510 |
|
|
1511 |
|
return value; |
1512 |
|
} |
1513 |
|
|
1514 |
|
double |
1515 |
< |
OSUAnalysis::valueLookup (const BNphoton* object, string variable){ |
1515 |
> |
OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){ |
1516 |
|
|
1517 |
|
double value = 0.0; |
1518 |
|
|
1588 |
|
|
1589 |
|
|
1590 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1591 |
< |
|
1591 |
> |
|
1592 |
> |
value = applyFunction(function, value); |
1593 |
|
|
1594 |
|
return value; |
1595 |
|
} |
1596 |
|
|
1597 |
|
double |
1598 |
< |
OSUAnalysis::valueLookup (const BNsupercluster* object, string variable){ |
1598 |
> |
OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){ |
1599 |
|
|
1600 |
|
double value = 0.0; |
1601 |
|
|
1610 |
|
|
1611 |
|
|
1612 |
|
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1613 |
< |
|
1613 |
> |
|
1614 |
> |
value = applyFunction(function, value); |
1615 |
> |
|
1616 |
> |
return value; |
1617 |
> |
} |
1618 |
> |
|
1619 |
> |
|
1620 |
> |
double |
1621 |
> |
OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){ |
1622 |
> |
|
1623 |
> |
double value = 0.0; |
1624 |
> |
|
1625 |
> |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
1626 |
> |
else if(variable == "invMass"){ |
1627 |
> |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
1628 |
> |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
1629 |
> |
value = (fourVector1 + fourVector2).M(); |
1630 |
> |
} |
1631 |
> |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
1632 |
> |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
1633 |
> |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
1634 |
> |
|
1635 |
> |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1636 |
> |
|
1637 |
> |
value = applyFunction(function, value); |
1638 |
|
|
1639 |
|
return value; |
1640 |
|
} |
1641 |
|
|
1642 |
+ |
double |
1643 |
+ |
OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){ |
1644 |
+ |
|
1645 |
+ |
double value = 0.0; |
1646 |
+ |
|
1647 |
+ |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
1648 |
+ |
else if(variable == "invMass"){ |
1649 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
1650 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
1651 |
+ |
value = (fourVector1 + fourVector2).M(); |
1652 |
+ |
} |
1653 |
+ |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
1654 |
+ |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
1655 |
+ |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
1656 |
+ |
|
1657 |
+ |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1658 |
+ |
|
1659 |
+ |
value = applyFunction(function, value); |
1660 |
+ |
|
1661 |
+ |
return value; |
1662 |
+ |
} |
1663 |
+ |
|
1664 |
+ |
double |
1665 |
+ |
OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){ |
1666 |
+ |
|
1667 |
+ |
double value = 0.0; |
1668 |
+ |
|
1669 |
+ |
if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi); |
1670 |
+ |
else if(variable == "invMass"){ |
1671 |
+ |
TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy); |
1672 |
+ |
TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy); |
1673 |
+ |
value = (fourVector1 + fourVector2).M(); |
1674 |
+ |
} |
1675 |
+ |
else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex; |
1676 |
+ |
else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex); |
1677 |
+ |
else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex); |
1678 |
+ |
|
1679 |
+ |
else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;} |
1680 |
+ |
|
1681 |
+ |
value = applyFunction(function, value); |
1682 |
+ |
|
1683 |
+ |
return value; |
1684 |
+ |
} |
1685 |
+ |
|
1686 |
+ |
|
1687 |
+ |
double |
1688 |
+ |
OSUAnalysis::applyFunction(string function, double value){ |
1689 |
+ |
|
1690 |
+ |
if(function == "abs") value = fabs(value); |
1691 |
+ |
|
1692 |
+ |
|
1693 |
+ |
return value; |
1694 |
+ |
|
1695 |
+ |
} |
1696 |
|
|
1323 |
– |
template <class InputCollection> |
1324 |
– |
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){ |
1697 |
|
|
1698 |
+ |
template <class InputCollection> |
1699 |
+ |
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){ |
1700 |
|
|
1701 |
|
for (uint object = 0; object != inputCollection->size(); object++){ |
1702 |
< |
|
1702 |
> |
|
1703 |
|
bool decision = true;//object passes if this cut doesn't cut on that type of object |
1330 |
– |
|
1331 |
– |
if(currentCut.inputCollection == inputType){ |
1332 |
– |
|
1333 |
– |
double value = valueLookup(&inputCollection->at(object), currentCut.variable); |
1704 |
|
|
1705 |
< |
decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue); |
1705 |
> |
if(currentCut.inputCollection == inputType){ |
1706 |
> |
|
1707 |
> |
vector<bool> subcutDecisions; |
1708 |
> |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
1709 |
> |
double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
1710 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
1711 |
> |
} |
1712 |
> |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
1713 |
> |
else{ |
1714 |
> |
bool tempDecision = true; |
1715 |
> |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
1716 |
> |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
1717 |
> |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
1718 |
> |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
1719 |
> |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
1720 |
> |
} |
1721 |
> |
decision = tempDecision; |
1722 |
> |
} |
1723 |
|
} |
1724 |
< |
individualFlags[inputType].at(currentCutIndex).push_back(decision); |
1338 |
< |
|
1724 |
> |
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
1725 |
|
|
1726 |
|
//set flags for objects that pass each cut AND all the previous cuts |
1727 |
|
bool previousCumulativeFlag = true; |
1728 |
|
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
1729 |
< |
if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true; |
1729 |
> |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true; |
1730 |
|
else{ previousCumulativeFlag = false; break;} |
1731 |
|
} |
1732 |
< |
cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
1732 |
> |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
1733 |
> |
|
1734 |
> |
} |
1735 |
> |
|
1736 |
> |
} |
1737 |
> |
|
1738 |
> |
|
1739 |
> |
template <class InputCollection1, class InputCollection2> |
1740 |
> |
void OSUAnalysis::setObjectFlags(cut ¤tCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \ |
1741 |
> |
InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){ |
1742 |
> |
|
1743 |
> |
|
1744 |
> |
bool sameObjects = false; |
1745 |
> |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
1746 |
> |
|
1747 |
> |
int counter = 0; |
1748 |
> |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
1749 |
> |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
1750 |
> |
|
1751 |
> |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
1752 |
> |
|
1753 |
> |
|
1754 |
> |
bool decision = true;//object passes if this cut doesn't cut on that type of object |
1755 |
> |
|
1756 |
> |
if(currentCut.inputCollection == inputType){ |
1757 |
> |
|
1758 |
> |
vector<bool> subcutDecisions; |
1759 |
> |
for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){ |
1760 |
> |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex)); |
1761 |
> |
subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex))); |
1762 |
> |
} |
1763 |
> |
|
1764 |
> |
if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0); |
1765 |
> |
else{ |
1766 |
> |
bool tempDecision = true; |
1767 |
> |
for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){ |
1768 |
> |
if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&") |
1769 |
> |
tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1); |
1770 |
> |
else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||") |
1771 |
> |
tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1); |
1772 |
> |
} |
1773 |
> |
decision = tempDecision; |
1774 |
> |
} |
1775 |
> |
} |
1776 |
> |
individualFlags.at(inputType).at(currentCutIndex).push_back(decision); |
1777 |
> |
|
1778 |
> |
//set flags for objects that pass each cut AND all the previous cuts |
1779 |
> |
bool previousCumulativeFlag = true; |
1780 |
> |
for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){ |
1781 |
> |
if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true; |
1782 |
> |
else{ previousCumulativeFlag = false; break;} |
1783 |
> |
} |
1784 |
> |
cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision); |
1785 |
> |
|
1786 |
> |
counter++; |
1787 |
> |
} |
1788 |
|
|
1789 |
|
} |
1790 |
< |
|
1790 |
> |
|
1791 |
> |
|
1792 |
|
} |
1793 |
|
|
1794 |
|
|
1795 |
+ |
template <class InputCollection> |
1796 |
+ |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
1797 |
+ |
|
1798 |
+ |
for (uint object = 0; object != inputCollection->size(); object++){ |
1799 |
+ |
|
1800 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue; |
1801 |
+ |
|
1802 |
+ |
string currentString = parameters.inputVariables.at(0); |
1803 |
+ |
string inputVariable = ""; |
1804 |
+ |
string function = ""; |
1805 |
+ |
if(currentString.find("(")==std::string::npos){ |
1806 |
+ |
inputVariable = currentString;// variable to cut on |
1807 |
+ |
} |
1808 |
+ |
else{ |
1809 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1810 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1811 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1812 |
+ |
} |
1813 |
+ |
|
1814 |
+ |
double value = valueLookup(&inputCollection->at(object), inputVariable, function); |
1815 |
+ |
histo->Fill(value,puScaleFactor); |
1816 |
+ |
|
1817 |
+ |
} |
1818 |
+ |
|
1819 |
+ |
} |
1820 |
+ |
|
1821 |
+ |
template <class InputCollection1, class InputCollection2> |
1822 |
+ |
void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
1823 |
+ |
|
1824 |
+ |
bool sameObjects = false; |
1825 |
+ |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
1826 |
+ |
|
1827 |
+ |
int counter = 0; |
1828 |
+ |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
1829 |
+ |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
1830 |
+ |
|
1831 |
+ |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
1832 |
+ |
|
1833 |
+ |
//only take objects which have passed all cuts and pairs which have passed all cuts |
1834 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
1835 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
1836 |
+ |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue; |
1837 |
+ |
|
1838 |
+ |
string currentString = parameters.inputVariables.at(0); |
1839 |
+ |
string inputVariable = ""; |
1840 |
+ |
string function = ""; |
1841 |
+ |
if(currentString.find("(")==std::string::npos){ |
1842 |
+ |
inputVariable = currentString;// variable to cut on |
1843 |
+ |
} |
1844 |
+ |
else{ |
1845 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1846 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1847 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1848 |
+ |
} |
1849 |
+ |
|
1850 |
+ |
double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
1851 |
+ |
histo->Fill(value,puScaleFactor); |
1852 |
+ |
|
1853 |
+ |
counter++; |
1854 |
+ |
} |
1855 |
+ |
} |
1856 |
+ |
|
1857 |
+ |
} |
1858 |
+ |
|
1859 |
+ |
|
1860 |
+ |
template <class InputCollection> |
1861 |
+ |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){ |
1862 |
+ |
|
1863 |
+ |
for (uint object = 0; object != inputCollection->size(); object++){ |
1864 |
+ |
|
1865 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue; |
1866 |
+ |
|
1867 |
+ |
string currentString = parameters.inputVariables.at(0); |
1868 |
+ |
string inputVariable = ""; |
1869 |
+ |
string function = ""; |
1870 |
+ |
if(currentString.find("(")==std::string::npos){ |
1871 |
+ |
inputVariable = currentString;// variable to cut on |
1872 |
+ |
} |
1873 |
+ |
else{ |
1874 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1875 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1876 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1877 |
+ |
} |
1878 |
+ |
double valueX = valueLookup(&inputCollection->at(object), inputVariable, function); |
1879 |
+ |
|
1880 |
+ |
currentString = parameters.inputVariables.at(1); |
1881 |
+ |
inputVariable = ""; |
1882 |
+ |
function = ""; |
1883 |
+ |
if(currentString.find("(")==std::string::npos){ |
1884 |
+ |
inputVariable = currentString;// variable to cut on |
1885 |
+ |
} |
1886 |
+ |
else{ |
1887 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1888 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1889 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1890 |
+ |
} |
1891 |
+ |
|
1892 |
+ |
double valueY = valueLookup(&inputCollection->at(object), inputVariable, function); |
1893 |
+ |
|
1894 |
+ |
histo->Fill(valueX,valueY,puScaleFactor); |
1895 |
+ |
|
1896 |
+ |
} |
1897 |
+ |
|
1898 |
+ |
} |
1899 |
+ |
|
1900 |
+ |
template <class InputCollection1, class InputCollection2> |
1901 |
+ |
void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){ |
1902 |
+ |
|
1903 |
+ |
bool sameObjects = false; |
1904 |
+ |
if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true; |
1905 |
+ |
|
1906 |
+ |
int counter = 0; |
1907 |
+ |
for (uint object1 = 0; object1 != inputCollection1->size(); object1++){ |
1908 |
+ |
for (uint object2 = 0; object2 != inputCollection2->size(); object2++){ |
1909 |
+ |
|
1910 |
+ |
if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same |
1911 |
+ |
|
1912 |
+ |
//only take objects which have passed all cuts and pairs which have passed all cuts |
1913 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue; |
1914 |
+ |
if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue; |
1915 |
+ |
if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue; |
1916 |
+ |
|
1917 |
+ |
string currentString = parameters.inputVariables.at(0); |
1918 |
+ |
string inputVariable = ""; |
1919 |
+ |
string function = ""; |
1920 |
+ |
if(currentString.find("(")==std::string::npos){ |
1921 |
+ |
inputVariable = currentString;// variable to cut on |
1922 |
+ |
} |
1923 |
+ |
else{ |
1924 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1925 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1926 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1927 |
+ |
} |
1928 |
+ |
double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
1929 |
+ |
|
1930 |
+ |
currentString = parameters.inputVariables.at(1); |
1931 |
+ |
inputVariable = ""; |
1932 |
+ |
function = ""; |
1933 |
+ |
if(currentString.find("(")==std::string::npos){ |
1934 |
+ |
inputVariable = currentString;// variable to cut on |
1935 |
+ |
} |
1936 |
+ |
else{ |
1937 |
+ |
function = currentString.substr(0,currentString.find("("));//function comes before the "(" |
1938 |
+ |
inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string |
1939 |
+ |
inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")" |
1940 |
+ |
} |
1941 |
+ |
double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function); |
1942 |
+ |
|
1943 |
+ |
|
1944 |
+ |
histo->Fill(valueX,valueY,puScaleFactor); |
1945 |
+ |
|
1946 |
+ |
counter++; |
1947 |
+ |
} |
1948 |
+ |
} |
1949 |
+ |
|
1950 |
+ |
} |
1951 |
|
|
1952 |
|
|
1953 |
|
|