ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.4 by lantonel, Tue Jan 29 15:29:06 2013 UTC vs.
Revision 1.39 by jbrinson, Wed Mar 27 16:52:25 2013 UTC

# Line 16 | Line 16 | OSUAnalysis::OSUAnalysis (const edm::Par
16    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 +  puFile_ (cfg.getParameter<std::string> ("puFile")),
20 +  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
21 +  
22 + muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23 +  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 +  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 +  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26 +  dataset_ (cfg.getParameter<std::string> ("dataset")),
27 +  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
28 +  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29 +  histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 +  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31 +  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 +  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo"))
33 + {
34  
35 +  TH1::SetDefaultSumw2 ();
36  
37 <  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels"))
37 >  //create pile-up reweighting object, if necessary
38 >  if(datasetType_ != "data") {
39 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
40 >    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
41 >    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
42 >  }
43  
23 {
24  TH1::SetDefaultSumw2 ();
44  
45    // Construct Cutflow Objects. These store the results of cut decisions and
46    // handle filling cut flow histograms.
47    masterCutFlow_ = new CutFlow (fs_);
48    std::vector<TFileDirectory> directories;
49  
50 +  //always get vertex collection so we can assign the primary vertex in the event
51 +  objectsToGet.push_back("primaryvertexs");
52 +
53 +  //always make the plot of number of primary verticex (to check pile-up reweighting)
54 +  objectsToPlot.push_back("primaryvertexs");
55 +
56 +  //always get the MC particles to do GEN-matching
57 +  objectsToGet.push_back("mcparticles");
58 +
59 +  //always get the event collection to do pile-up reweighting
60 +  objectsToGet.push_back("events");
61 +
62 +  //parse the histogram definitions
63 +  for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
64 +
65 +    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
66 +    if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
67 +    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
68 +      objectsToGet.push_back(tempInputCollection);
69 +      objectsToPlot.push_back(tempInputCollection);
70 +      objectsToCut.push_back(tempInputCollection);
71 +    }
72 +    else{//pair of objects, need to add them both to the things to objectsToGet
73 +      int dashIndex = tempInputCollection.find("-");
74 +      int spaceIndex = tempInputCollection.find(" ");
75 +      int secondWordLength = spaceIndex - dashIndex;
76 +      objectsToGet.push_back(tempInputCollection);
77 +      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
78 +      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
79 +      objectsToPlot.push_back(tempInputCollection);
80 +      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
81 +      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
82 +      objectsToCut.push_back(tempInputCollection);
83 +      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
84 +      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
85 +
86 +      }
87 +
88 +    vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
89 +
90 +    for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
91 +
92 +      histogram tempHistogram;
93 +      tempHistogram.inputCollection = tempInputCollection;
94 +      tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
95 +      tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
96 +      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
97 +      tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
98 +
99 +      histograms.push_back(tempHistogram);
100 +
101 +    }
102 +  }
103 +  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
104 +  sort( objectsToPlot.begin(), objectsToPlot.end() );
105 +  objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
106 +
107 +
108 +
109 +  //add histograms with the gen-matched id, mother id, and grandmother id
110 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
111 +
112 +    string currentObject = objectsToPlot.at(currentObjectIndex);
113 +    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
114 +
115 +    histogram tempIdHisto;
116 +    histogram tempMomIdHisto;
117 +    histogram tempGmaIdHisto;
118 +    histogram tempIdVsMomIdHisto;
119 +
120 +    tempIdHisto.inputCollection = currentObject;
121 +    tempMomIdHisto.inputCollection = currentObject;
122 +    tempGmaIdHisto.inputCollection = currentObject;
123 +    tempIdVsMomIdHisto.inputCollection = currentObject;
124 +
125 +    currentObject = currentObject.substr(0, currentObject.size()-1);
126 +    tempIdHisto.name = currentObject+"GenMatchId";
127 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
128 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
129 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
130 +
131 +    currentObject.at(0) = toupper(currentObject.at(0));
132 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
133 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
134 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
135 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
136 +
137 +    int maxNum = 24;
138 +    vector<double> binVector;
139 +    binVector.push_back(maxNum);
140 +    binVector.push_back(0);
141 +    binVector.push_back(maxNum);
142 +
143 +    tempIdHisto.bins = binVector;
144 +    tempIdHisto.inputVariables.push_back("genMatchedId");
145 +    tempMomIdHisto.bins = binVector;
146 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
147 +    tempGmaIdHisto.bins = binVector;
148 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
149 +    binVector.push_back(maxNum);
150 +    binVector.push_back(0);
151 +    binVector.push_back(maxNum);
152 +    tempIdVsMomIdHisto.bins = binVector;
153 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
154 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
155 +
156 +    histograms.push_back(tempIdHisto);
157 +    histograms.push_back(tempMomIdHisto);
158 +    histograms.push_back(tempGmaIdHisto);
159 +    histograms.push_back(tempIdVsMomIdHisto);
160 +  }
161 +
162  
163    channel tempChannel;
164    //loop over all channels (event selections)
165    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
166 <    
166 >
167      //get name of channel
168      string channelName  (channels_.at(currentChannel).getParameter<string>("name"));
169      tempChannel.name = channelName;
# Line 45 | Line 176 | OSUAnalysis::OSUAnalysis (const edm::Par
176      if(channels_.at(currentChannel).exists("triggers")){
177        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
178        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
179 <        tempChannel.triggers.push_back(triggerNames.at(trigger));
180 <      allNecessaryObjects.push_back("triggers");
179 >        tempChannel.triggers.push_back(triggerNames.at(trigger));
180 >      objectsToGet.push_back("triggers");
181      }
182  
183  
184 +
185 +
186      //create cutFlow for this channel
187      cutFlows_.push_back (new CutFlow (fs_, channelName));
188  
189      //book a directory in the output file with the name of the channel
190      TFileDirectory subDir = fs_->mkdir( channelName );
191      directories.push_back(subDir);
59    std::map<std::string, TH1D*> histoMap;
60    oneDHists_.push_back(histoMap);
192  
193 +    std::map<std::string, TH1D*> oneDhistoMap;
194 +    oneDHists_.push_back(oneDhistoMap);
195 +    std::map<std::string, TH2D*> twoDhistoMap;
196 +    twoDHists_.push_back(twoDhistoMap);
197 +
198 +
199 +
200 +    //book all histograms included in the configuration
201 +    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
202 +      histogram currentHistogram = histograms.at(currentHistogramIndex);
203 +      int numBinsElements = currentHistogram.bins.size();
204 +      int numInputVariables = currentHistogram.inputVariables.size();
205 +
206 +      if(numBinsElements != 3 && numBinsElements !=6) {
207 +        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
208 +        exit(0);
209 +      }
210 +      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
211 +        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
212 +        exit(0);
213 +      }
214 +      else if(numBinsElements == 3){
215 +        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));
216 +      }
217 +      else if(numBinsElements == 6){
218 +        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));
219 +
220 +      }
221 +
222 +
223 +      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
224 +
225 + // bin      particle type
226 + // ---      -------------
227 + //  0        unmatched
228 + //  1        u
229 + //  2        d
230 + //  3        s
231 + //  4        c
232 + //  5        b
233 + //  6        t
234 + //  7        e
235 + //  8        mu
236 + //  9        tau
237 + // 10        nu
238 + // 11        g
239 + // 12        gamma
240 + // 13        Z
241 + // 14        W
242 + // 15        light meson
243 + // 16        K meson
244 + // 17        D meson
245 + // 18        B meson
246 + // 19        light baryon
247 + // 20        strange baryon
248 + // 21        charm baryon
249 + // 22        bottom baryon
250 + // 23        other
251 +
252 +      vector<TString> labelArray;
253 +      labelArray.push_back("unmatched");
254 +      labelArray.push_back("u");
255 +      labelArray.push_back("d");
256 +      labelArray.push_back("s");
257 +      labelArray.push_back("c");
258 +      labelArray.push_back("b");
259 +      labelArray.push_back("t");
260 +      labelArray.push_back("e");
261 +      labelArray.push_back("#mu");
262 +      labelArray.push_back("#tau");
263 +      labelArray.push_back("#nu");
264 +      labelArray.push_back("g");
265 +      labelArray.push_back("#gamma");
266 +      labelArray.push_back("Z");
267 +      labelArray.push_back("W");
268 +      labelArray.push_back("light meson");
269 +      labelArray.push_back("K meson");
270 +      labelArray.push_back("D meson");
271 +      labelArray.push_back("B meson");
272 +      labelArray.push_back("light baryon");
273 +      labelArray.push_back("strange baryon");
274 +      labelArray.push_back("charm baryon");
275 +      labelArray.push_back("bottom baryon");
276 +      labelArray.push_back("other");
277 +
278 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
279 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
280 +          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
281 +        }
282 +        else {
283 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
284 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
285 +        }
286 +      }
287 +      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
288 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
289 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
290 +      }
291 +
292 +    }
293 +
294 +    //book a histogram for the number of each object type to be plotted
295 +
296 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
297 +      string currentObject = objectsToPlot.at(currentObjectIndex);
298 +      int maxNum = 10;
299 +      if(currentObject == "mcparticles") maxNum = 50;
300 +      else if(currentObject == "primaryvertexs") maxNum = 50;
301 +      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
302 +      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
303 +      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
304 +
305 +      else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
306 +      else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
307 +      else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
308 +      else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
309 +
310 +      currentObject.at(0) = toupper(currentObject.at(0));
311 +      string histoName = "num" + currentObject;
312 +
313 +      if(histoName == "numPrimaryvertexs"){
314 +        string newHistoName = histoName + "BeforePileupCorrection";
315 +        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
316 +        newHistoName = histoName + "AfterPileupCorrection";
317 +        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
318 +      }
319 +      else
320 +        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
321 +    }
322  
63    //muon histograms
64    allNecessaryObjects.push_back("muons");
65    oneDHists_.at(currentChannel)["muonPt"]  = directories.at(currentChannel).make<TH1D> ("muonPt",channelLabel+" channel: Muon Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
66    oneDHists_.at(currentChannel)["muonEta"] = directories.at(currentChannel).make<TH1D> ("muonEta",channelLabel+" channel: Muon Eta; #eta", 100, -5, 5);
67    oneDHists_.at(currentChannel)["muonD0"] = directories.at(currentChannel).make<TH1D> ("muonD0",channelLabel+" channel: Muon d_{0}; d_{0} [cm] ", 1000, -1, 1);
68    oneDHists_.at(currentChannel)["muonAbsD0"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0",channelLabel+" channel: Muon d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
69    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);
70    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);
71    oneDHists_.at(currentChannel)["muonIso"] = directories.at(currentChannel).make<TH1D> ("muonIso",channelLabel+" channel: Muon Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
72    oneDHists_.at(currentChannel)["numMuons"] = directories.at(currentChannel).make<TH1D> ("numMuons",channelLabel+" channel: Number of Selected Muons; # muons", 10, 0, 10);
73
74
75    //electron histograms
76    allNecessaryObjects.push_back("electrons");
77    oneDHists_.at(currentChannel)["electronPt"]  = directories.at(currentChannel).make<TH1D> ("electronPt",channelLabel+" channel: Electron Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
78    oneDHists_.at(currentChannel)["electronEta"] = directories.at(currentChannel).make<TH1D> ("electronEta",channelLabel+" channel: Electron Eta; #eta", 50, -5, 5);
79    oneDHists_.at(currentChannel)["electronD0"] = directories.at(currentChannel).make<TH1D> ("electronD0",channelLabel+" channel: Electron d_{0}; d_{0} [cm] ", 1000, -1, 1);
80    oneDHists_.at(currentChannel)["electronAbsD0"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0",channelLabel+" channel: Electron d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
81    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);
82    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);
83    oneDHists_.at(currentChannel)["electronIso"] = directories.at(currentChannel).make<TH1D> ("electronIso",channelLabel+" channel: Electron Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
84    oneDHists_.at(currentChannel)["electronFbrem"] = directories.at(currentChannel).make<TH1D> ("electronFbrem",channelLabel+" channel: Electron Brem. Energy Fraction; fbrem", 1000, 0, 2);
85    oneDHists_.at(currentChannel)["electronMVATrig"] = directories.at(currentChannel).make<TH1D> ("electronMVATrig",channelLabel+" channel: Electron ID MVA Output", 100, -1, 1);
86    oneDHists_.at(currentChannel)["electronMVANonTrig"] = directories.at(currentChannel).make<TH1D> ("electronMVANonTrig",channelLabel+" channel: Electron ID MVA Output", 100, -1, 1);
87    oneDHists_.at(currentChannel)["numElectrons"] = directories.at(currentChannel).make<TH1D> ("numElectrons",channelLabel+" channel: Number of Selected Electrons; # electrons", 10, 0, 10);
323  
324  
325  
326      //get list of cuts for this channel
327      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
328  
94    vector<string> tempInputCollections;
95
96
329      //loop over and parse all cuts
330      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
99
331        cut tempCut;
332 <     //store input collection for cut
333 <      string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
334 <      tempCut.inputCollection = inputCollection;
335 <      
336 <      tempInputCollections.push_back(inputCollection);
337 <      allNecessaryObjects.push_back(inputCollection);
332 >      //store input collection for cut
333 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
334 >      tempCut.inputCollection = tempInputCollection;
335 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
336 >        objectsToGet.push_back(tempInputCollection);
337 >        objectsToCut.push_back(tempInputCollection);
338 >      }
339 >      else{//pair of objects, need to add them both to the things to objectsToGet
340 >        int dashIndex = tempInputCollection.find("-");
341 >        int spaceIndex = tempInputCollection.find(" ");
342 >        int secondWordLength = spaceIndex - dashIndex;
343 >        objectsToGet.push_back(tempInputCollection);
344 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
345 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
346 >        objectsToCut.push_back(tempInputCollection);
347 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
348 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
349 >
350 >      }
351 >
352 >
353  
354        //split cut string into parts and store them
355        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
356        std::vector<string> cutStringVector = splitString(cutString);
357 <      tempCut.variable = cutStringVector.at(0);// variable to cut on
358 <      tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
359 <      tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
357 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
358 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
359 >        exit(0);
360 >      }
361 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
362 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
363 >        int indexOffset = 4 * subcutIndex;
364 >        string currentVariableString = cutStringVector.at(indexOffset);
365 >        if(currentVariableString.find("(")==std::string::npos){
366 >          tempCut.functions.push_back("");//no function was specified
367 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
368 >        }
369 >        else{
370 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
371 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
372 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
373 >        }
374 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
375 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
376 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
377 >      }
378  
379        //get number of objects required to pass cut for event to pass
380        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
381        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
382 +      if(numberRequiredVector.size()!=2){
383 +        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
384 +        exit(0);
385 +      }
386  
387 <      // determine number required if comparison contains "="
120 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
121 <      if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
122 <      else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
123 <
387 >      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
388        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
389        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
390 <      
391 <      if(cuts_.at(currentCut).exists("function")){
128 <        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
129 <      }
130 <      else tempCut.function = "";
390 >
391 >
392        string tempCutName;
393        if(cuts_.at(currentCut).exists("alias")){
394 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
394 >        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
395        }
396        else{
397 <        //construct string for cutflow table
398 <        bool plural = numberRequiredInt != 1;
399 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
400 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
401 <        tempCutName = cutName;
397 >        //construct string for cutflow table
398 >        bool plural = numberRequiredInt != 1;
399 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
400 >        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
401 >        tempCutName = cutName;
402        }
403        tempCut.name = tempCutName;
404  
# Line 145 | Line 406 | OSUAnalysis::OSUAnalysis (const edm::Par
406        tempChannel.cuts.push_back(tempCut);
407  
408  
148    }//end loop over cuts
409  
410 <    //make unique vector of all objects that this channel cuts on (so we know to set flags for those)
151 <    sort( tempInputCollections.begin(), tempInputCollections.end() );
152 <    tempInputCollections.erase( unique( tempInputCollections.begin(), tempInputCollections.end() ), tempInputCollections.end() );
153 <    tempChannel.inputCollections = tempInputCollections;    
410 >    }//end loop over cuts
411  
412      channels.push_back(tempChannel);
413      tempChannel.cuts.clear();
414  
415    }//end loop over channels
416  
417 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
418 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
419 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
417 >
418 >  //make unique vector of objects we need to get from the event
419 >  sort( objectsToGet.begin(), objectsToGet.end() );
420 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
421 >  //make unique vector of objects we need to cut on
422 >  sort( objectsToCut.begin(), objectsToCut.end() );
423 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
424  
425  
426   }
# Line 177 | Line 438 | void
438   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
439   {
440  
180
441    // Retrieve necessary collections from the event.
442 <  edm::Handle<BNtriggerCollection> triggers;
443 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
442 >
443 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
444      event.getByLabel (triggers_, triggers);
445  
446 <  edm::Handle<BNjetCollection> jets;
187 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())  
446 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
447      event.getByLabel (jets_, jets);
448  
449 <  edm::Handle<BNmuonCollection> muons;
191 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())  
449 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
450      event.getByLabel (muons_, muons);
451  
452 <  edm::Handle<BNelectronCollection> electrons;
195 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())  
452 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
453      event.getByLabel (electrons_, electrons);
454  
455 <  edm::Handle<BNeventCollection> events;
199 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())  
455 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
456      event.getByLabel (events_, events);
457  
458 <  edm::Handle<BNtauCollection> taus;
203 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())  
458 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
459      event.getByLabel (taus_, taus);
460  
461 <  edm::Handle<BNmetCollection> mets;
207 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())  
461 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
462      event.getByLabel (mets_, mets);
463  
464 <  edm::Handle<BNtrackCollection> tracks;
211 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())  
464 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
465      event.getByLabel (tracks_, tracks);
466  
467 <  edm::Handle<BNgenjetCollection> genjets;
215 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())  
467 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
468      event.getByLabel (genjets_, genjets);
469  
470 <  edm::Handle<BNmcparticleCollection> mcparticles;
219 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())  
470 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
471      event.getByLabel (mcparticles_, mcparticles);
472  
473 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
223 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())  
473 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
474      event.getByLabel (primaryvertexs_, primaryvertexs);
475  
476 <  edm::Handle<BNbxlumiCollection> bxlumis;
227 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())  
476 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
477      event.getByLabel (bxlumis_, bxlumis);
478  
479 <  edm::Handle<BNphotonCollection> photons;
231 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())  
479 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
480      event.getByLabel (photons_, photons);
481  
482 <  edm::Handle<BNsuperclusterCollection> superclusters;
235 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())  
482 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
483      event.getByLabel (superclusters_, superclusters);
484  
485 +  //get pile-up event weight
486 +  double scaleFactor = 1.00;
487 +  if(doPileupReweighting_ && datasetType_ != "data")
488 +    scaleFactor = puWeight_->at (events->at (0).numTruePV);
489 +
490  
491    //loop over all channels
492  
493    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
494      channel currentChannel = channels.at(currentChannelIndex);
243    
244    flagMap individualFlags;  
245    flagMap cumulativeFlags;  
246    counterMap passingCounter;
495  
496 +    flagMap individualFlags;
497 +    counterMap passingCounter;
498 +    cumulativeFlags.clear ();
499 +
500 +    bool triggerDecision = true;
501      if(currentChannel.triggers.size() != 0){  //triggers specified
502 <      bool triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
502 >      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
503        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
504      }
505  
506      //loop over all cuts
507 +
508 +
509 +
510      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
511        cut currentCut = currentChannel.cuts.at(currentCutIndex);
512  
513 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
513 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
514 >        string currentObject = objectsToCut.at(currentObjectIndex);
515  
516 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
517 <        individualFlags[currentObject].push_back (vector<bool> ());
518 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
519 <
520 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
521 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
522 <        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
523 <        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
524 <        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
525 <        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
526 <        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
527 <        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
528 <        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
529 <        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
530 <        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
531 <        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
532 <        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
516 >        //initialize maps to get ready to set cuts
517 >        individualFlags[currentObject].push_back (vector<bool> ());
518 >        cumulativeFlags[currentObject].push_back (vector<bool> ());
519 >
520 >      }
521 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
522 >        string currentObject = objectsToCut.at(currentObjectIndex);
523 >
524 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
525 >
526 >
527 >        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
528 >        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
529 >        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
530 >        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
531 >        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
532 >        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
533 >        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
534 >        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
535 >        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
536 >        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
537 >        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
538 >        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
539 >        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
540 >
541 >
542 >        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
543 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
544 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
545 >                                                                   "muon-muon pairs");
546 >        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
547 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
548 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
549 >                                                                           "electron-electron pairs");
550 >        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
551 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
552 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
553 >                                                                       "electron-muon pairs");
554 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(), \
555 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
556 >                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
557 >                                                                       "electron-track pairs");
558 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(), \
559 >                                                                        cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
560 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
561 >                                                                        "muon-track pairs");
562 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(), \
563 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
564 >                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
565 >                                                                    "muon-tau pairs");
566 >
567 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(), \
568 >                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
569 >                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
570 >                                                                        "tau-tau pairs");
571  
572  
573        }
# Line 280 | Line 575 | OSUAnalysis::analyze (const edm::Event &
575  
576  
577      }//end loop over all cuts
283    
284
578  
579  
580      //use cumulative flags to apply cuts at event level
581  
582      bool eventPassedAllCuts = true;
583  
584 +    //apply trigger (true if none were specified)
585 +    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
586 +
587  
292    if(currentChannel.triggers.size() != 0){  //triggers specified
293      bool triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
294      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
295    }
588  
589      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
590  
# Line 300 | Line 592 | OSUAnalysis::analyze (const edm::Event &
592        cut currentCut = currentChannel.cuts.at(currentCutIndex);
593        int numberPassing = 0;
594  
595 <      for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
596 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
597 <
595 >      for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
596 >          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
597 >      }
598  
599        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
600        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 311 | Line 603 | OSUAnalysis::analyze (const edm::Event &
603  
604      }
605  
606 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();  
607 <  
606 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
607 >
608  
609  
610      if(!eventPassedAllCuts)continue;
611  
612 +    if (printEventInfo_) {
613 +      // Write information about event to screen, for testing purposes.  
614 +      cout << "Event passed all cuts in channel " <<  currentChannel.name
615 +           << ": run="  << events->at(0).run
616 +           << "  lumi=" << events->at(0).lumi
617 +           << "  event=" << events->at(0).evt
618 +           << endl;  
619 +    }
620  
621  
622 <    vector<bool> electronFlags = cumulativeFlags["electrons"].back();
623 <    int electronCounter = 0;
622 > //     if(datasetType_ != "data") {
623 > //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
624 > //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
625 > //     }
626 >
627 >    //filling histograms
628 >    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
629 >      histogram currentHistogram = histograms.at(histogramIndex);
630 >
631 >      if(currentHistogram.inputVariables.size() == 1){
632 >        TH1D* histo;
633 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
634  
325    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
326      if(!electronFlags.at(electronIndex)) continue;
635  
636  
637 <      electronCounter++;
638 <      oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt);
639 <      oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta);
640 <      oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex);
641 <      oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex));
642 <      oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err);
643 <      oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err);
644 <      oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (((electrons->at(electronIndex).trackIso + electrons->at(electronIndex).caloIso) / electrons->at(electronIndex).pt));
645 <      oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem);
646 <      oneDHists_.at(currentChannelIndex)["electronMVATrig"]->Fill (electrons->at(electronIndex).mvaTrigV0);
647 <      oneDHists_.at(currentChannelIndex)["electronMVANonTrig"]->Fill (electrons->at(electronIndex).mvaNonTrigV0);
637 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
638 >         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
639 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
640 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
641 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
642 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
643 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
644 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
645 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
646 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
647 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
648 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
649 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), \
650 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
651 >                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
652 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), \
653 >                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
654 >                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
655 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), \
656 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
657 >                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
658 >
659 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), \
660 >                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
661 >                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
662 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
663 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
664 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
665 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
666 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
667 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
668 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
669 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
670 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
671 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
672 >      }
673 >      else if(currentHistogram.inputVariables.size() == 2){
674 >        TH2D* histo;
675 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
676 >
677  
678 +
679 +        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
680 +        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
681 +        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
682 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
683 +                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
684 +        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
685 +        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
686 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
687 +                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
688 +        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
689 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
690 +                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
691 +        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), \
692 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), \
693 +                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
694 +        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), \
695 +                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), \
696 +                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
697 +        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), \
698 +                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), \
699 +                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
700 +        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), \
701 +                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), \
702 +                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
703 +        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
704 +        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
705 +        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
706 +        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
707 +        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
708 +        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
709 +        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
710 +        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
711 +        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
712 +        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
713 +      }
714      }
342    oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter);
715  
716 <    
717 <    vector<bool> muonFlags = cumulativeFlags["muons"].back();
718 <    int muonCounter = 0;
716 >    //fills histograms with the sizes of collections
717 >    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
718 >      string currentObject = objectsToPlot.at(currentObjectIndex);
719 >
720 >      string objectToPlot = "";
721 >
722 >      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
723 >      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
724 >      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
725 >      else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
726 >      else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
727 >      else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
728 >      else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
729 >      else objectToPlot = currentObject;
730 >      string tempCurrentObject = objectToPlot;
731 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
732 >      string histoName = "num" + tempCurrentObject;
733  
734  
349    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
350      if(!muonFlags.at(muonIndex)) continue;
351      muonCounter++;
735  
353      oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt);
354      oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta);
355      oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex);
356      oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex));
357      oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err);
358      oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err);
359      oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (((muons->at(muonIndex).trackIso + muons->at(muonIndex).caloIso) / muons->at(muonIndex).pt));
360    }
361    oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter);
736  
737 +      //set position of primary vertex in event, in order to calculate quantities relative to it
738 +      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
739 +        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
740 +        int numToPlot = 0;
741 +        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
742 +          if(lastCutFlags.at(currentFlag)) numToPlot++;
743 +        }
744 +        if(objectToPlot == "primaryvertexs"){
745 +          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
746 +          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
747 +        }
748 +        else
749 +          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
750 +      }
751 +      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
752 +      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
753 +      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
754 +      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
755 +      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
756 +      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
757 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
758 +      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
759 +      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
760 +      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
761 +      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
762 +      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
763 +      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
764 +      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
765 +      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
766 +      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
767 +      else if(objectToPlot == "primaryvertexs"){
768 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
769 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
770 +      }
771 +
772 +    }
773  
774  
775  
776  
777    } //end loop over channel
778  
779 <  masterCutFlow_->fillCutFlow();    
779 >  masterCutFlow_->fillCutFlow(scaleFactor);
780 >
781  
782  
783   }
784  
785  
786 < bool
786 > bool
787   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
788  
789  
# Line 380 | Line 791 | OSUAnalysis::evaluateComparison (double
791    else if(comparison == ">=") return testValue >= cutValue;
792    else if(comparison == "<")  return testValue <  cutValue;
793    else if(comparison == "<=") return testValue <= cutValue;
794 +  else if(comparison == "==") return testValue == cutValue;
795 +  else if(comparison == "=") return testValue == cutValue;
796 +  else if(comparison == "!=") return testValue != cutValue;
797    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
798  
799   }
# Line 395 | Line 809 | OSUAnalysis::evaluateTriggers (vector<st
809        for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
810          {
811            if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
812 <            triggerDecision = true;
812 >            triggerDecision = true;
813            }
814          }
815      }
# Line 533 | Line 947 | OSUAnalysis::valueLookup (const BNjet* o
947    else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
948    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
949    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
950 <  
951 <  
950 >
951 >
952    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
953 <  
954 <  if(function == "abs") value = abs(value);
953 >
954 >  value = applyFunction(function, value);
955  
956    return value;
957   }
# Line 561 | Line 975 | OSUAnalysis::valueLookup (const BNmuon*
975    else if(variable == "ecalIso") value = object->ecalIso;
976    else if(variable == "hcalIso") value = object->hcalIso;
977    else if(variable == "caloIso") value = object->caloIso;
978 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
978 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
979    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
980    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
981    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 699 | Line 1113 | OSUAnalysis::valueLookup (const BNmuon*
1113    else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
1114    else if(variable == "time_ndof") value = object->time_ndof;
1115  
1116 +  //user-defined variables
1117 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1118 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1119 +  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1120 +  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1121 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1122 +  else if(variable == "metMT") {
1123 +    const BNmet *met = chosenMET ();
1124 +    if (met)
1125 +      {
1126 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1127 +                       p2 (met->px, met->py, 0.0, met->pt);
1128 +
1129 +        value = (p1 + p2).Mt ();
1130 +      }
1131 +    else
1132 +      value = -999;
1133 +  }
1134 +
1135 +
1136 +
1137 +  else if(variable == "correctedD0VertexInEBPlus"){
1138 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1139 +    else value = -999;
1140 +  }
1141 +  else if(variable == "correctedD0VertexOutEBPlus"){
1142 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1143 +    else value = -999;
1144 +  }
1145 +  else if(variable == "correctedD0VertexEEPlus"){
1146 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1147 +    else value = -999;
1148 +  }
1149 +
1150 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1151 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1152 +    else value = -999;
1153 +  }
1154 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1155 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1156 +    else value = -999;
1157 +  }
1158 +  else if(variable == "correctedD0BeamspotEEPlus"){
1159 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1160 +    else value = -999;
1161 +  }
1162 +
1163 +  else if(variable == "correctedD0VertexInEBMinus"){
1164 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1165 +    else value = -999;
1166 +  }
1167 +  else if(variable == "correctedD0VertexOutEBMinus"){
1168 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1169 +    else value = -999;
1170 +  }
1171 +  else if(variable == "correctedD0VertexEEMinus"){
1172 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1173 +    else value = -999;
1174 +  }
1175 +
1176 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1177 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1178 +    else value = -999;
1179 +  }
1180 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1181 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1182 +    else value = -999;
1183 +  }
1184 +  else if(variable == "correctedD0BeamspotEEMinus"){
1185 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1186 +    else value = -999;
1187 +  }
1188 +
1189 +
1190 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1191 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1192 +    else value = -999;
1193 +  }
1194 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1195 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1196 +    else value = -999;
1197 +  }
1198 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1199 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1200 +    else value = -999;
1201 +  }
1202 +
1203 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1204 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1205 +    else value = -999;
1206 +  }
1207 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1208 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1209 +    else value = -999;
1210 +  }
1211 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1212 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1213 +    else value = -999;
1214 +  }
1215 +
1216 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1217 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1218 +    else value = -999;
1219 +  }
1220 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1221 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1222 +    else value = -999;
1223 +  }
1224 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1225 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1226 +    else value = -999;
1227 +  }
1228 +
1229 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1230 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1231 +    else value = -999;
1232 +  }
1233 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1234 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1235 +    else value = -999;
1236 +  }
1237 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1238 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1239 +    else value = -999;
1240 +  }
1241 +
1242 +
1243 +  else if(variable == "tightID") {
1244 +    value = object->isGlobalMuon > 0                \
1245 +      && object->isPFMuon > 0                        \
1246 +      && object->normalizedChi2 < 10                \
1247 +      && object->numberOfValidMuonHits > 0        \
1248 +      && object->numberOfMatchedStations > 1        \
1249 +      && fabs(object->correctedD0Vertex) < 0.2        \
1250 +      && fabs(object->correctedDZ) < 0.5        \
1251 +      && object->numberOfValidPixelHits > 0                \
1252 +      && object->numberOfLayersWithMeasurement > 5;
1253 +  }
1254 +  else if(variable == "tightIDdisplaced"){
1255 +    value = object->isGlobalMuon > 0                \
1256 +      && object->normalizedChi2 < 10                \
1257 +      && object->numberOfValidMuonHits > 0        \
1258 +      && object->numberOfMatchedStations > 1        \
1259 +      && object->numberOfValidPixelHits > 0        \
1260 +      && object->numberOfLayersWithMeasurement > 5;
1261 +  }
1262 +
1263 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1264 +
1265 +  else if(variable == "genMatchedPdgId"){
1266 +    int index = getGenMatchedParticleIndex(object);
1267 +    if(index == -1) value = 0;
1268 +    else value = mcparticles->at(index).id;
1269 +  }
1270 +
1271 +  else if(variable == "genMatchedId"){
1272 +    int index = getGenMatchedParticleIndex(object);
1273 +    if(index == -1) value = 0;
1274 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1275 +  }
1276 +  else if(variable == "genMatchedMotherId"){
1277 +    int index = getGenMatchedParticleIndex(object);
1278 +    if(index == -1) value = 0;
1279 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1280 +  }
1281 +  else if(variable == "genMatchedMotherIdReverse"){
1282 +    int index = getGenMatchedParticleIndex(object);
1283 +    if(index == -1) value = 23;
1284 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1285 +  }
1286 +  else if(variable == "genMatchedGrandmotherId"){
1287 +    int index = getGenMatchedParticleIndex(object);
1288 +    if(index == -1) value = 0;
1289 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1290 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1291 +      if(motherIndex == -1) value = 0;
1292 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1293 +    }
1294 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1295 +  }
1296 +
1297 +
1298 +
1299    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1300 <  
1300 >
1301 >  value = applyFunction(function, value);
1302  
1303    return value;
1304   }
# Line 867 | Line 1465 | OSUAnalysis::valueLookup (const BNelectr
1465    else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1466    else if(variable == "passConvVeto") value = object->passConvVeto;
1467  
1468 +  //user-defined variables
1469 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1470 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1471 +  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1472 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1473 +  else if(variable == "metMT") {
1474 +    const BNmet *met = chosenMET ();
1475 +    if (met)
1476 +      {
1477 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1478 +                       p2 (met->px, met->py, 0.0, met->pt);
1479 +
1480 +        value = (p1 + p2).Mt ();
1481 +      }
1482 +    else
1483 +      value = -999;
1484 +  }
1485 +
1486 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1487 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1488 +    else value = -999;
1489 +  }
1490 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1491 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1492 +    else value = -999;
1493 +  }
1494 +
1495 +  else if(variable == "correctedD0VertexInEBPlus"){
1496 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1497 +    else value = -999;
1498 +  }
1499 +  else if(variable == "correctedD0VertexOutEBPlus"){
1500 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1501 +    else value = -999;
1502 +  }
1503 +  else if(variable == "correctedD0VertexEEPlus"){
1504 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1505 +    else value = -999;
1506 +  }
1507 +
1508 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1509 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1510 +    else value = -999;
1511 +  }
1512 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1513 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1514 +    else value = -999;
1515 +  }
1516 +  else if(variable == "correctedD0BeamspotEEPlus"){
1517 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1518 +    else value = -999;
1519 +  }
1520 +
1521 +  else if(variable == "correctedD0VertexInEBMinus"){
1522 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1523 +    else value = -999;
1524 +  }
1525 +  else if(variable == "correctedD0VertexOutEBMinus"){
1526 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1527 +    else value = -999;
1528 +  }
1529 +  else if(variable == "correctedD0VertexEEMinus"){
1530 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1531 +    else value = -999;
1532 +  }
1533 +
1534 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1535 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1536 +    else value = -999;
1537 +  }
1538 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1539 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1540 +    else value = -999;
1541 +  }
1542 +  else if(variable == "correctedD0BeamspotEEMinus"){
1543 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1544 +    else value = -999;
1545 +  }
1546 +
1547 +  else if(variable == "tightID"){
1548 +    if (object->isEB)
1549 +      {
1550 +        value = fabs(object->delEtaIn) < 0.004 \
1551 +          && fabs (object->delPhiIn) < 0.03 \
1552 +          && object->scSigmaIEtaIEta < 0.01 \
1553 +          && object->hadOverEm < 0.12 \
1554 +          && fabs (object->correctedD0Vertex) < 0.02 \
1555 +          && fabs (object->correctedDZ) < 0.1 \
1556 +          && object->absInvEMinusInvPin < 0.05 \
1557 +          && object->passConvVeto;
1558 +      }
1559 +    else
1560 +      {
1561 +        value = fabs(object->delEtaIn) < 0.005 \
1562 +          && fabs (object->delPhiIn) < 0.02 \
1563 +          && object->scSigmaIEtaIEta < 0.03 \
1564 +          && object->hadOverEm < 0.10 \
1565 +          && fabs (object->correctedD0Vertex) < 0.02 \
1566 +          && fabs (object->correctedDZ) < 0.1 \
1567 +          && object->absInvEMinusInvPin < 0.05 \
1568 +          && object->passConvVeto;
1569 +      }
1570 +  }
1571 +
1572 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1573 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1574 +    else value = -999;
1575 +  }
1576 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1577 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1578 +    else value = -999;
1579 +  }
1580 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1581 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1582 +    else value = -999;
1583 +  }
1584 +
1585 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1586 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1587 +    else value = -999;
1588 +  }
1589 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1590 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1591 +    else value = -999;
1592 +  }
1593 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1594 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1595 +    else value = -999;
1596 +  }
1597 +
1598 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1599 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1600 +    else value = -999;
1601 +  }
1602 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1603 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1604 +    else value = -999;
1605 +  }
1606 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1607 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1608 +    else value = -999;
1609 +  }
1610 +
1611 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1612 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1613 +    else value = -999;
1614 +  }
1615 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1616 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1617 +    else value = -999;
1618 +  }
1619 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1620 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1621 +    else value = -999;
1622 +  }
1623 +
1624 +
1625 +  else if(variable == "tightIDdisplaced"){
1626 +    if (object->isEB)
1627 +      {
1628 +        value = fabs(object->delEtaIn) < 0.004 \
1629 +          && fabs (object->delPhiIn) < 0.03 \
1630 +          && object->scSigmaIEtaIEta < 0.01 \
1631 +          && object->hadOverEm < 0.12 \
1632 +          && object->absInvEMinusInvPin < 0.05;
1633 +      }
1634 +    else
1635 +      {
1636 +        value = fabs (object->delEtaIn) < 0.005 \
1637 +          && fabs (object->delPhiIn) < 0.02 \
1638 +          && object->scSigmaIEtaIEta < 0.03 \
1639 +          && object->hadOverEm < 0.10 \
1640 +          && object->absInvEMinusInvPin < 0.05;
1641 +      }
1642 +  }
1643 +
1644 +
1645 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1646 +
1647 +  else if(variable == "genMatchedPdgId"){
1648 +    int index = getGenMatchedParticleIndex(object);
1649 +    if(index == -1) value = 0;
1650 +    else value = mcparticles->at(index).id;
1651 +  }
1652 +
1653 +
1654 +  else if(variable == "genMatchedId"){
1655 +    int index = getGenMatchedParticleIndex(object);
1656 +    if(index == -1) value = 0;
1657 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1658 +  }
1659 +  else if(variable == "genMatchedMotherId"){
1660 +    int index = getGenMatchedParticleIndex(object);
1661 +    if(index == -1) value = 0;
1662 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1663 +  }
1664 +  else if(variable == "genMatchedMotherIdReverse"){
1665 +    int index = getGenMatchedParticleIndex(object);
1666 +    if(index == -1) value = 23;
1667 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1668 +  }
1669 +  else if(variable == "genMatchedGrandmotherId"){
1670 +    int index = getGenMatchedParticleIndex(object);
1671 +    if(index == -1) value = 0;
1672 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1673 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1674 +      if(motherIndex == -1) value = 0;
1675 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1676 +    }
1677 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1678 +  }
1679 +
1680 +
1681  
1682    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1683 <  
1683 >
1684 >  value = applyFunction(function, value);
1685  
1686    return value;
1687   }
# Line 944 | Line 1756 | OSUAnalysis::valueLookup (const BNevent*
1756    else if(variable == "id1") value = object->id1;
1757    else if(variable == "id2") value = object->id2;
1758    else if(variable == "evt") value = object->evt;
1759 +  else if(variable == "puScaleFactor"){
1760 +    if(datasetType_ != "data")
1761 +      value = puWeight_->at (events->at (0).numTruePV);
1762 +    else
1763 +      value = 1.0;
1764 +  }
1765 +  else if(variable == "muonScaleFactor"){
1766 +    if(datasetType_ != "data")
1767 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1768 +    value = 1.0;
1769 +    else
1770 +      value = 1.0;
1771 +  }
1772 +  else if(variable == "electronScaleFactor"){
1773 +    if(datasetType_ != "data")
1774 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1775 +    value = 1.0;
1776 +    else
1777 +      value = 1.0;
1778 +  }
1779  
1780    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1781 <  
1781 >
1782 >  value = applyFunction(function, value);
1783  
1784    return value;
1785   }
# Line 997 | Line 1830 | OSUAnalysis::valueLookup (const BNtau* o
1830    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1831  
1832  
1833 +
1834 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1835 +
1836 +  else if(variable == "genMatchedPdgId"){
1837 +    int index = getGenMatchedParticleIndex(object);
1838 +    if(index == -1) value = 0;
1839 +    else value = mcparticles->at(index).id;
1840 +  }
1841 +
1842 +  else if(variable == "genMatchedId"){
1843 +    int index = getGenMatchedParticleIndex(object);
1844 +    if(index == -1) value = 0;
1845 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1846 +  }
1847 +  else if(variable == "genMatchedMotherId"){
1848 +    int index = getGenMatchedParticleIndex(object);
1849 +    if(index == -1) value = 0;
1850 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1851 +  }
1852 +  else if(variable == "genMatchedMotherIdReverse"){
1853 +    int index = getGenMatchedParticleIndex(object);
1854 +    if(index == -1) value = 23;
1855 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1856 +  }
1857 +  else if(variable == "genMatchedGrandmotherId"){
1858 +    int index = getGenMatchedParticleIndex(object);
1859 +    if(index == -1) value = 0;
1860 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1861 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1862 +      if(motherIndex == -1) value = 0;
1863 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1864 +    }
1865 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1866 +  }
1867 +
1868 +
1869    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1870 <  
1870 >
1871 >  value = applyFunction(function, value);
1872  
1873    return value;
1874   }
# Line 1069 | Line 1939 | OSUAnalysis::valueLookup (const BNmet* o
1939    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
1940  
1941    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1942 <  
1942 >
1943 >  value = applyFunction(function, value);
1944  
1945    return value;
1946   }
# Line 1078 | Line 1949 | double
1949   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1950  
1951    double value = 0.0;
1952 +  double pMag = sqrt(object->pt * object->pt +
1953 +                         object->pz * object->pz);
1954  
1955    if(variable == "pt") value = object->pt;
1956    else if(variable == "px") value = object->px;
# Line 1098 | Line 1971 | OSUAnalysis::valueLookup (const BNtrack*
1971    else if(variable == "isHighPurity") value = object->isHighPurity;
1972  
1973  
1974 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1974 >  //additional BNs info for disappTrks
1975 >  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1976 >  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1977 >  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
1978 >  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
1979 >  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
1980 >  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
1981 >  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
1982 >  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1983 >  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1984 >  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1985    
1986  
1987 +  //user defined variables
1988 +  else if(variable == "d0wrtBS") value = (object->vx-events->at(0).BSx)*object->py/object->pt - (object->vy-events->at(0).BSy)*object->px/object->pt;
1989 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1990 +  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1991 +  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1992 +  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1993 +  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1994 +  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
1995 +  else if(variable == "ptError") value = object->ptError;
1996 +  else if(variable == "ptRes") value = getTrkPtRes(object);
1997 +
1998 +  else if (variable == "d0wrtPV"){
1999 +    double vx = object->vx - chosenVertex ()->x,
2000 +      vy = object->vy - chosenVertex ()->y,
2001 +      px = object->px,
2002 +      py = object->py,
2003 +      pt = object->pt;
2004 +    value = (-vx * py + vy * px) / pt;
2005 +  }
2006 +  else if (variable == "dZwrtPV"){
2007 +    double vx = object->vx - chosenVertex ()->x,
2008 +      vy = object->vy - chosenVertex ()->y,
2009 +      vz = object->vz - chosenVertex ()->z,
2010 +      px = object->px,
2011 +      py = object->py,
2012 +      pz = object->pz,
2013 +      pt = object->pt;
2014 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2015 +  }
2016 +
2017 +
2018 +
2019 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2020 +
2021 +  else if(variable == "genMatchedPdgId"){
2022 +    int index = getGenMatchedParticleIndex(object);
2023 +    if(index == -1) value = 0;
2024 +    else value = mcparticles->at(index).id;
2025 +  }
2026 +
2027 +  else if(variable == "genMatchedId"){
2028 +    int index = getGenMatchedParticleIndex(object);
2029 +    if(index == -1) value = 0;
2030 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2031 +  }
2032 +  else if(variable == "genMatchedMotherId"){
2033 +    int index = getGenMatchedParticleIndex(object);
2034 +    if(index == -1) value = 0;
2035 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2036 +  }
2037 +  else if(variable == "genMatchedMotherIdReverse"){
2038 +    int index = getGenMatchedParticleIndex(object);
2039 +    if(index == -1) value = 23;
2040 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2041 +  }
2042 +  else if(variable == "genMatchedGrandmotherId"){
2043 +    int index = getGenMatchedParticleIndex(object);
2044 +    if(index == -1) value = 0;
2045 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2046 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2047 +      if(motherIndex == -1) value = 0;
2048 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2049 +    }
2050 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2051 +  }
2052 +
2053 +
2054 +
2055 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2056 +
2057 +  value = applyFunction(function, value);
2058 +
2059    return value;
2060   }
2061  
# Line 1126 | Line 2081 | OSUAnalysis::valueLookup (const BNgenjet
2081  
2082  
2083    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2084 <  
2084 >
2085 >  value = applyFunction(function, value);
2086  
2087    return value;
2088   }
# Line 1221 | Line 2177 | OSUAnalysis::valueLookup (const BNmcpart
2177    else if(variable == "grandMother11Status") value = object->grandMother11Status;
2178    else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
2179  
2180 +  //user-defined variables
2181 +  else if (variable == "d0"){
2182 +    double vx = object->vx - chosenVertex ()->x,
2183 +      vy = object->vy - chosenVertex ()->y,
2184 +      px = object->px,
2185 +      py = object->py,
2186 +      pt = object->pt;
2187 +    value = (-vx * py + vy * px) / pt;
2188 +  }
2189 +  else if (variable == "dz"){
2190 +    double vx = object->vx - chosenVertex ()->x,
2191 +      vy = object->vy - chosenVertex ()->y,
2192 +      vz = object->vz - chosenVertex ()->z,
2193 +      px = object->px,
2194 +      py = object->py,
2195 +      pz = object->pz,
2196 +      pt = object->pt;
2197 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2198 +  }
2199 +  else if(variable == "v0"){
2200 +    value = sqrt(object->vx*object->vx + object->vy*object->vy);
2201 +  }
2202 +  else if(variable == "deltaV0"){
2203 +    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2204 +  }
2205 +  else if (variable == "deltaVx"){
2206 +    value = object->vx - chosenVertex ()->x;
2207 +  }
2208 +  else if (variable == "deltaVy"){
2209 +    value = object->vy - chosenVertex ()->y;
2210 +  }
2211 +  else if (variable == "deltaVz"){
2212 +    value = object->vz - chosenVertex ()->z;
2213 +  }
2214 +
2215 +
2216    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2217 <  
2217 >
2218 >  value = applyFunction(function, value);
2219  
2220    return value;
2221   }
# Line 1248 | Line 2241 | OSUAnalysis::valueLookup (const BNprimar
2241  
2242  
2243    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2244 <  
2244 >
2245 >  value = applyFunction(function, value);
2246  
2247    return value;
2248   }
# Line 1264 | Line 2258 | OSUAnalysis::valueLookup (const BNbxlumi
2258  
2259  
2260    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2261 <  
2261 >
2262 >  value = applyFunction(function, value);
2263  
2264    return value;
2265   }
# Line 1343 | Line 2338 | OSUAnalysis::valueLookup (const BNphoton
2338    else if(variable == "isEEGap") value = object->isEEGap;
2339    else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2340    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2341 +
2342 +
2343 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2344 +
2345 +  else if(variable == "genMatchedPdgId"){
2346 +    int index = getGenMatchedParticleIndex(object);
2347 +    if(index == -1) value = 0;
2348 +    else value = mcparticles->at(index).id;
2349 +  }
2350 +  else if(variable == "genMatchedId"){
2351 +    int index = getGenMatchedParticleIndex(object);
2352 +    if(index == -1) value = 0;
2353 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2354 +  }
2355 +  else if(variable == "genMatchedMotherId"){
2356 +    int index = getGenMatchedParticleIndex(object);
2357 +    if(index == -1) value = 0;
2358 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2359 +  }
2360 +  else if(variable == "genMatchedMotherIdReverse"){
2361 +    int index = getGenMatchedParticleIndex(object);
2362 +    if(index == -1) value = 23;
2363 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2364 +  }
2365 +  else if(variable == "genMatchedGrandmotherId"){
2366 +    int index = getGenMatchedParticleIndex(object);
2367 +    if(index == -1) value = 0;
2368 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2369 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2370 +      if(motherIndex == -1) value = 0;
2371 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2372 +    }
2373 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2374 +  }
2375  
2376  
2377    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2378 <  
2378 >
2379 >  value = applyFunction(function, value);
2380  
2381    return value;
2382   }
# Line 1367 | Line 2397 | OSUAnalysis::valueLookup (const BNsuperc
2397  
2398  
2399    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2400 +
2401 +  value = applyFunction(function, value);
2402 +
2403 +  return value;
2404 + }
2405 +
2406 +
2407 + double
2408 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2409 +
2410 +  double value = 0.0;
2411 +
2412 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2413 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2414 +  else if(variable == "invMass"){
2415 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2416 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2417 +    value = (fourVector1 + fourVector2).M();
2418 +  }
2419 +  else if(variable == "pt"){
2420 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2421 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2422 +    value = (fourVector1 + fourVector2).Et();
2423 +  }
2424 +  else if(variable == "threeDAngle")
2425 +    {
2426 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2427 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2428 +      value = (threeVector1.Angle(threeVector2));
2429 +    }
2430 +  else if(variable == "alpha")
2431 +    {
2432 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2433 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2434 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2435 +      value = (pi-threeVector1.Angle(threeVector2));
2436 +    }
2437 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2438 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2439 +  else if(variable == "d0Sign"){
2440 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2441 +    if(d0Sign < 0) value = -0.5;
2442 +    else if (d0Sign > 0) value = 0.5;
2443 +    else value = -999;
2444 +  }
2445 +  else if(variable == "chargeProduct"){
2446 +    value = object1->charge*object2->charge;
2447 +  }
2448 +  else if(variable == "muon1CorrectedD0Vertex"){
2449 +    value = object1->correctedD0Vertex;
2450 +  }
2451 +  else if(variable == "muon2CorrectedD0Vertex"){
2452 +    value = object2->correctedD0Vertex;
2453 +  }
2454 + else if(variable == "muon1timeAtIpInOut"){
2455 +    value = object1->timeAtIpInOut;
2456 +  }
2457 + else if(variable == "muon2timeAtIpInOut"){
2458 +    value = object2->timeAtIpInOut;
2459 +  }
2460 + else if(variable == "muon1correctedD0")
2461 +   {
2462 +     value = object1->correctedD0;
2463 +   }
2464 + else if(variable == "muon2correctedD0")
2465 +   {
2466 +     value = object2->correctedD0;
2467 +   }
2468 +
2469 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2470 +
2471 +  value = applyFunction(function, value);
2472 +
2473 +  return value;
2474 + }
2475 +
2476 + double
2477 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2478 +
2479 +  double value = 0.0;
2480 +
2481 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2482 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2483 +  else if(variable == "invMass"){
2484 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2485 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2486 +    value = (fourVector1 + fourVector2).M();
2487 +  }
2488 +  else if(variable == "pt"){
2489 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2490 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2491 +    value = (fourVector1 + fourVector2).Et();
2492 +  }
2493 +  else if(variable == "threeDAngle")
2494 +    {
2495 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2496 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2497 +      value = (threeVector1.Angle(threeVector2));
2498 +    }
2499 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2500 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2501 +  else if(variable == "d0Sign"){
2502 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2503 +    if(d0Sign < 0) value = -0.5;
2504 +    else if (d0Sign > 0) value = 0.5;
2505 +    else value = -999;
2506 +  }
2507 +  else if(variable == "chargeProduct"){
2508 +    value = object1->charge*object2->charge;
2509 +  }
2510 +  else if(variable == "electron1CorrectedD0Vertex"){
2511 +    value = object1->correctedD0Vertex;
2512 +  }
2513 +  else if(variable == "electron2CorrectedD0Vertex"){
2514 +    value = object2->correctedD0Vertex;
2515 +  }
2516 +  else if(variable == "electron1CorrectedD0"){
2517 +    value = object1->correctedD0;
2518 +  }
2519 +  else if(variable == "electron2CorrectedD0"){
2520 +    value = object2->correctedD0;
2521 +  }
2522 +
2523 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2524 +
2525 +  value = applyFunction(function, value);
2526 +
2527 +  return value;
2528 + }
2529 +
2530 + double
2531 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2532 +
2533 +  double value = 0.0;
2534 +
2535 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2536 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2537 +  else if(variable == "invMass"){
2538 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2539 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2540 +    value = (fourVector1 + fourVector2).M();
2541 +  }
2542 +  else if(variable == "pt"){
2543 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2544 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2545 +    value = (fourVector1 + fourVector2).Et();
2546 +  }
2547 +  else if(variable == "threeDAngle")
2548 +    {
2549 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2550 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2551 +      value = (threeVector1.Angle(threeVector2));
2552 +    }
2553 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2554 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2555 +  else if(variable == "d0Sign"){
2556 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2557 +    if(d0Sign < 0) value = -0.5;
2558 +    else if (d0Sign > 0) value = 0.5;
2559 +    else value = -999;
2560 +  }
2561 +  else if(variable == "chargeProduct"){
2562 +    value = object1->charge*object2->charge;
2563 +  }
2564 +  else if(variable == "electronCorrectedD0Vertex"){
2565 +    value = object1->correctedD0Vertex;
2566 +  }
2567 +  else if(variable == "muonCorrectedD0Vertex"){
2568 +    value = object2->correctedD0Vertex;
2569 +  }
2570 +  else if(variable == "electronCorrectedD0"){
2571 +    value = object1->correctedD0;
2572 +  }
2573 +  else if(variable == "muonCorrectedD0"){
2574 +    value = object2->correctedD0;
2575 +  }
2576 +  else if(variable == "electronDetIso"){
2577 +    value = (object1->trackIso) / object1->pt;
2578 +  }
2579 +  else if(variable == "muonDetIso"){
2580 +    value = (object2->trackIsoDR03) / object2->pt;
2581 +  }
2582 +
2583 +
2584 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2585 +
2586 +  value = applyFunction(function, value);
2587 +
2588 +  return value;
2589 + }
2590 +
2591 +
2592 + double
2593 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
2594 +  double electronMass = 0.000511;
2595 +  double value = 0.0;
2596 +  TLorentzVector fourVector1(0, 0, 0, 0);  
2597 +  TLorentzVector fourVector2(0, 0, 0, 0);  
2598 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2599 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2600 +  else if(variable == "invMass"){
2601 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
2602 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
2603 +    
2604 +    value = (fourVector1 + fourVector2).M();
2605 +  }
2606    
2607 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2608 +  value = applyFunction(function, value);
2609 +  return value;
2610 + }
2611 +
2612 + double
2613 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2614 +  double pionMass = 0.140;
2615 +  double muonMass = 0.106;
2616 +  double value = 0.0;
2617 +  TLorentzVector fourVector1(0, 0, 0, 0);
2618 +  TLorentzVector fourVector2(0, 0, 0, 0);
2619 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2620 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2621 +  else if(variable == "invMass"){
2622 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2623 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2624 +
2625 +    value = (fourVector1 + fourVector2).M();
2626 +  }
2627 +
2628 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2629 +  value = applyFunction(function, value);
2630 +  return value;
2631 + }
2632 +
2633 +
2634 + double
2635 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2636 +  double value = 0.0;
2637 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2638 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2639 +  else if(variable == "invMass"){
2640 +  TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2641 +  TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2642 +     value = (fourVector1 + fourVector2).M();
2643 +  }
2644 +
2645 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2646 +  value = applyFunction(function, value);
2647 +  return value;
2648 + }
2649 +
2650 + double
2651 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2652 +  double value = 0.0;
2653 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2654 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2655 +  else if(variable == "invMass"){
2656 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2657 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2658 +    value = (fourVector1 + fourVector2).M();
2659 +  }
2660 +
2661 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2662 +  value = applyFunction(function, value);
2663 +  return value;
2664 + }
2665 +
2666 +
2667 +
2668 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2669 + // Return true iff no other tracks are found in this cone.
2670 + int
2671 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2672 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2673 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2674 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2675 +    if(deltaRtrk < 0.5) return 0;
2676 +  }
2677 +  return 1;
2678 +
2679 + }
2680 +
2681 +
2682 + double
2683 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2684 +
2685 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2686 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
2687 +
2688 +  return PtRes;
2689  
2690 + }
2691 +
2692 +
2693 + double
2694 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2695 +  double value = -99;
2696 +  double genDeltaRLowest = 999;
2697 +
2698 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2699 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2700 +    if (genDeltaRtemp < genDeltaRLowest) {
2701 +      genDeltaRLowest = genDeltaRtemp;
2702 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2703 +        double ptTrue = genPart->pt;
2704 +        value = ptTrue;
2705 +      }
2706 +    }
2707 +  }
2708 +
2709 +  return value;
2710 +
2711 + }
2712 +
2713 + //creates a map of the dead Ecal channels in the barrel and endcap
2714 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2715 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2716 + void
2717 + OSUAnalysis::WriteDeadEcal (){
2718 +  double etaEcal, phiEcal;
2719 +  ifstream DeadEcalFile(deadEcalFile_);
2720 +  if(!DeadEcalFile) {
2721 +    cout << "Error: DeadEcalFile has not been found." << endl;
2722 +    return;
2723 +  }
2724 +  if(DeadEcalVec.size()!= 0){
2725 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2726 +    return;
2727 +  }
2728 +  while(!DeadEcalFile.eof())
2729 +    {
2730 +      DeadEcalFile >> etaEcal >> phiEcal;
2731 +      DeadEcal newChan;
2732 +      newChan.etaEcal = etaEcal;
2733 +      newChan.phiEcal = phiEcal;
2734 +      DeadEcalVec.push_back(newChan);
2735 +    }
2736 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2737 + }
2738 +
2739 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2740 + int
2741 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2742 +  double deltaRLowest = 999;
2743 +  int value = 0;
2744 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2745 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2746 +    double eta = ecal->etaEcal;
2747 +    double phi = ecal->phiEcal;
2748 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2749 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2750 +  }
2751 +  if (deltaRLowest<0.05) {value = 1;}
2752 +  else {value = 0;}
2753    return value;
2754   }
2755  
2756  
2757 < template <class InputCollection>
2757 > // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2758 > template <class InputObject>
2759 > double OSUAnalysis::getGenDeltaRLowest(InputObject object){
2760 >  double genDeltaRLowest = 999.;
2761 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2762 >    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2763 >    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2764 > }
2765 >  return genDeltaRLowest;
2766 > }
2767 >
2768 >
2769 > double
2770 > OSUAnalysis::applyFunction(string function, double value){
2771 >
2772 >  if(function == "abs") value = fabs(value);
2773 >  else if(function == "fabs") value = fabs(value);
2774 >  else if(function == "log10") value = log10(value);
2775 >  else if(function == "log") value = log10(value);
2776 >
2777 >  else if(function == "") value = value;
2778 >  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2779 >
2780 >  return value;
2781 >
2782 > }
2783 >
2784 >
2785 > template <class InputCollection>
2786   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
2787  
2788  
2789    for (uint object = 0; object != inputCollection->size(); object++){
2790 <    
2790 >
2791 >
2792      bool decision = true;//object passes if this cut doesn't cut on that type of object
1383    
1384    if(currentCut.inputCollection == inputType){
1385      
1386      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
2793  
2794 <      decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
2794 >
2795 >    if(currentCut.inputCollection == inputType){
2796 >
2797 >      vector<bool> subcutDecisions;
2798 >      for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2799 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2800 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2801 >      }
2802 >      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2803 >      else{
2804 >        bool tempDecision = true;
2805 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2806 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2807 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2808 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2809 >            tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2810 >        }
2811 >        decision = tempDecision;
2812 >      }
2813      }
2814 <    individualFlags[inputType].at(currentCutIndex).push_back(decision);
2815 <    
2814 >    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2815 >
2816  
2817      //set flags for objects that pass each cut AND all the previous cuts
2818      bool previousCumulativeFlag = true;
2819      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2820 <      if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2820 >      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2821        else{ previousCumulativeFlag = false; break;}
2822      }
2823 <    cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2823 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2824 >
2825 >
2826 >  }
2827 >
2828 > }
2829 >
2830 >
2831 > template <class InputCollection1, class InputCollection2>
2832 > void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2833 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2834 >
2835 >
2836 >  bool sameObjects = false;
2837 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2838 >
2839 >
2840 >  int counter = 0;
2841 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2842 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2843 >
2844 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2845 >
2846 >
2847 >      bool decision = true;//object passes if this cut doesn't cut on that type of object
2848 >
2849 >      if(currentCut.inputCollection == inputType){
2850 >
2851 >        vector<bool> subcutDecisions;
2852 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2853 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2854 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2855 >        }
2856 >
2857 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2858 >        else{
2859 >          bool tempDecision = subcutDecisions.at(0);
2860 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2861 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2862 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2863 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2864 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2865 >          }
2866 >          decision = tempDecision;
2867 >        }
2868 >      }
2869 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2870 >
2871 >      //set flags for objects that pass each cut AND all the previous cuts
2872 >      bool previousCumulativeFlag = true;
2873 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2874 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2875 >        else{ previousCumulativeFlag = false; break;}
2876 >      }
2877 >      //apply flags for the components of the composite object as well
2878 >      bool currentCumulativeFlag = true;
2879 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2880 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2881 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2882 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2883 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2884 >
2885 >      counter++;
2886 >    }
2887 >
2888 >  }
2889 >
2890 >
2891 > }
2892 >
2893 >
2894 > template <class InputCollection>
2895 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2896 >
2897 >  for (uint object = 0; object != inputCollection->size(); object++){
2898 >
2899 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2900 >
2901 >    string currentString = parameters.inputVariables.at(0);
2902 >    string inputVariable = "";
2903 >    string function = "";
2904 >    if(currentString.find("(")==std::string::npos){
2905 >      inputVariable = currentString;// variable to cut on
2906 >    }
2907 >    else{
2908 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2909 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2910 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2911 >    }
2912 >
2913 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2914 >    histo->Fill(value,scaleFactor);
2915 >
2916 >    if (printEventInfo_) {
2917 >      // Write information about event to screen, for testing purposes.  
2918 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
2919 >    }
2920      
2921    }
1402  
2922   }
2923  
2924 + template <class InputCollection1, class InputCollection2>
2925 + void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2926  
2927 +  bool sameObjects = false;
2928 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2929  
2930 +  int pairCounter = 0;
2931 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2932 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2933 +
2934 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2935 +
2936 +      //only take objects which have passed all cuts and pairs which have passed all cuts
2937 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2938 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2939 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2940 +
2941 +      string currentString = parameters.inputVariables.at(0);
2942 +      string inputVariable = "";
2943 +      string function = "";
2944 +      if(currentString.find("(")==std::string::npos){
2945 +        inputVariable = currentString;// variable to cut on
2946 +      }
2947 +      else{
2948 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2949 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2950 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2951 +      }
2952  
2953 +      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2954 +      histo->Fill(value,scaleFactor);
2955 +
2956 +      pairCounter++;
2957 +    }
2958 +  }
2959 +
2960 + }
2961 +
2962 +
2963 + template <class InputCollection>
2964 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2965 +
2966 +  for (uint object = 0; object != inputCollection->size(); object++){
2967 +
2968 +    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2969 +
2970 +    string currentString = parameters.inputVariables.at(0);
2971 +    string inputVariable = "";
2972 +    string function = "";
2973 +    if(currentString.find("(")==std::string::npos){
2974 +      inputVariable = currentString;// variable to cut on
2975 +    }
2976 +    else{
2977 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2978 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2979 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2980 +    }
2981 +    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2982 +
2983 +    currentString = parameters.inputVariables.at(1);
2984 +    inputVariable = "";
2985 +    function = "";
2986 +    if(currentString.find("(")==std::string::npos){
2987 +      inputVariable = currentString;// variable to cut on
2988 +    }
2989 +    else{
2990 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2991 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2992 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2993 +    }
2994 +
2995 +    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2996 +
2997 +    histo->Fill(valueX,valueY,scaleFactor);
2998 +
2999 +  }
3000 +
3001 + }
3002 +
3003 + template <class InputCollection1, class InputCollection2>
3004 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3005 +
3006 +  bool sameObjects = false;
3007 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3008 +
3009 +  int pairCounter = 0;
3010 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3011 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3012 +
3013 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3014 +
3015 +      //only take objects which have passed all cuts and pairs which have passed all cuts
3016 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3017 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3018 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3019 +
3020 +      string currentString = parameters.inputVariables.at(0);
3021 +      string inputVariable = "";
3022 +      string function = "";
3023 +      if(currentString.find("(")==std::string::npos){
3024 +        inputVariable = currentString;// variable to cut on
3025 +      }
3026 +      else{
3027 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3028 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3029 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3030 +      }
3031 +      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3032 +
3033 +      currentString = parameters.inputVariables.at(1);
3034 +      inputVariable = "";
3035 +      function = "";
3036 +      if(currentString.find("(")==std::string::npos){
3037 +        inputVariable = currentString;// variable to cut on
3038 +      }
3039 +      else{
3040 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3041 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3042 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3043 +      }
3044 +      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3045 +
3046 +
3047 +      histo->Fill(valueX,valueY,scaleFactor);
3048 +
3049 +      pairCounter++;
3050 +
3051 +    }
3052 +  }
3053 +
3054 + }
3055 +
3056 +
3057 + template <class InputObject>
3058 + int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
3059 +
3060 +  int bestMatchIndex = -1;
3061 +  double bestMatchDeltaR = 999;
3062 +
3063 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3064 +
3065 +    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3066 +    if(currentDeltaR > 0.05) continue;
3067 + //     cout << std::setprecision(3) << std::setw(20)
3068 + //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3069 + //          << std::setw(20)
3070 + //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3071 + //          << std::setw(20)
3072 + //          << "\tdeltaR = " << currentDeltaR
3073 + //          << std::setprecision(1)
3074 + //          << std::setw(20)
3075 + //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3076 + //          << std::setw(20)
3077 + //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3078 + //          << std::setw(20)
3079 + //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3080 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3081 +      bestMatchIndex = mcparticle - mcparticles->begin();
3082 +      bestMatchDeltaR = currentDeltaR;
3083 +    }
3084 +
3085 +  }
3086 + //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3087 + //   else cout << "no match found..." << endl;
3088 +  return bestMatchIndex;
3089 +
3090 + }
3091 +
3092 +
3093 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
3094 +
3095 +  int bestMatchIndex = -1;
3096 +  double bestMatchDeltaR = 999;
3097 +
3098 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3099 +
3100 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
3101 +
3102 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
3103 +    if(currentDeltaR > 0.05) continue;
3104 +
3105 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3106 +      bestMatchIndex = mcparticle - mcparticles->begin();
3107 +      bestMatchDeltaR = currentDeltaR;
3108 +    }
3109 +
3110 +  }
3111 +
3112 +  return bestMatchIndex;
3113 + }
3114  
1409 DEFINE_FWK_MODULE(OSUAnalysis);
3115  
3116 + // bin      particle type
3117 + // ---      -------------
3118 + //  0        unmatched
3119 + //  1        u
3120 + //  2        d
3121 + //  3        s
3122 + //  4        c
3123 + //  5        b
3124 + //  6        t
3125 + //  7        e
3126 + //  8        mu
3127 + //  9        tau
3128 + // 10        nu
3129 + // 11        g
3130 + // 12        gamma
3131 + // 13        Z
3132 + // 14        W
3133 + // 15        light meson
3134 + // 16        K meson
3135 + // 17        D meson
3136 + // 18        B meson
3137 + // 19        light baryon
3138 + // 20        strange baryon
3139 + // 21        charm baryon
3140 + // 22        bottom baryon
3141 + // 23        other
3142 +
3143 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
3144 +
3145 +  int binValue = -999;
3146 +  int absPdgId = fabs(pdgId);
3147 +  if(pdgId == -1) binValue = 0;
3148 +  else if(absPdgId <= 6 ) binValue = absPdgId;
3149 +  else if(absPdgId == 11 ) binValue = 7;
3150 +  else if(absPdgId == 13 ) binValue = 8;
3151 +  else if(absPdgId == 15 ) binValue = 9;
3152 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
3153 +  else if(absPdgId == 21 ) binValue = 11;
3154 +  else if(absPdgId == 22 ) binValue = 12;
3155 +  else if(absPdgId == 23 ) binValue = 13;
3156 +  else if(absPdgId == 24 ) binValue = 14;
3157 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
3158 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
3159 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
3160 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
3161 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
3162 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3163 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3164 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3165  
3166 +  else binValue = 23;
3167 +
3168 +  return binValue;
3169 +
3170 + }
3171 +
3172 + const BNprimaryvertex *
3173 + OSUAnalysis::chosenVertex ()
3174 + {
3175 +  const BNprimaryvertex *chosenVertex = 0;
3176 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3177 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3178 +                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3179 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3180 +      if(!vertexFlags.at(vertexIndex)) continue;
3181 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3182 +      break;
3183 +    }
3184 +  }
3185 +  else {
3186 +    chosenVertex = &primaryvertexs->at(0);
3187 +  }
3188 +
3189 +  return chosenVertex;
3190 + }
3191 +
3192 + const BNmet *
3193 + OSUAnalysis::chosenMET ()
3194 + {
3195 +  const BNmet *chosenMET = 0;
3196 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3197 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3198 +                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3199 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3200 +      if(!metFlags.at(metIndex)) continue;
3201 +      chosenMET = & mets->at(metIndex);
3202 +      break;
3203 +    }
3204 +  }
3205 +  else {
3206 +    chosenMET = &mets->at(0);
3207 +  }
3208 +
3209 +  return chosenMET;
3210 + }
3211 +
3212 + const BNelectron *
3213 + OSUAnalysis::chosenElectron ()
3214 + {
3215 +  const BNelectron *chosenElectron = 0;
3216 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3217 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3218 +                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3219 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3220 +      if(!electronFlags.at(electronIndex)) continue;
3221 +      chosenElectron = & electrons->at(electronIndex);
3222 +      break;
3223 +    }
3224 +  }
3225 +  else {
3226 +    chosenElectron = &electrons->at(0);
3227 +  }
3228 +
3229 +  return chosenElectron;
3230 + }
3231 +
3232 + const BNmuon *
3233 + OSUAnalysis::chosenMuon ()
3234 + {
3235 +  const BNmuon *chosenMuon = 0;
3236 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3237 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3238 +                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3239 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3240 +      if(!muonFlags.at(muonIndex)) continue;
3241 +      chosenMuon = & muons->at(muonIndex);
3242 +      break;
3243 +    }
3244 +  }
3245 +  else {
3246 +    chosenMuon = &muons->at(0);
3247 +  }
3248 +
3249 +  return chosenMuon;
3250 + }
3251 +
3252 +
3253 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines