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.8 by ahart, Wed Jan 30 22:29:59 2013 UTC vs.
Revision 1.50 by lantonel, Thu Apr 25 07:52:02 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <
21 <
22 <  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels"))
20 >  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 >  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
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 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
34 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
35  
36   {
37 +
38    TH1::SetDefaultSumw2 ();
39  
40 +  //create pile-up reweighting object, if necessary
41 +  if(datasetType_ != "data") {
42 +    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
43 +    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
44 +    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 +  }
46 + #ifdef DISPLACED_SUSY
47 +  if (datasetType_ == "signalMC")
48 +    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 + #endif
50 +
51 +
52    // Construct Cutflow Objects. These store the results of cut decisions and
53    // handle filling cut flow histograms.
54    masterCutFlow_ = new CutFlow (fs_);
55    std::vector<TFileDirectory> directories;
56  
57 +  //always get vertex collection so we can assign the primary vertex in the event
58 +  objectsToGet.push_back("primaryvertexs");
59 +
60 +  //always make the plot of number of primary vertices (to check pile-up reweighting)
61 +  objectsToPlot.push_back("primaryvertexs");
62 +
63 +  //always get the MC particles to do GEN-matching
64 +  objectsToGet.push_back("mcparticles");
65 +
66 +  //always get the event collection to do pile-up reweighting
67 +  objectsToGet.push_back("events");
68 +
69 +  //parse the histogram definitions
70 +  for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
71 +
72 +    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
73 +    if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
74 +    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
75 +    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
76 +    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
77 +    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
78 +      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
79 +        int spaceIndex = tempInputCollection.find(" ");
80 +        int secondWordLength = tempInputCollection.size() - spaceIndex;
81 +        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
82 +      }
83 +      else{
84 +        objectsToGet.push_back(tempInputCollection);
85 +      }
86 +      objectsToPlot.push_back(tempInputCollection);
87 +      objectsToCut.push_back(tempInputCollection);
88 +    }
89 +    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
90 +      string obj1;
91 +      string obj2;
92 +      getTwoObjs(tempInputCollection, obj1, obj2);
93 +      string obj2ToGet = getObjToGet(obj2);  
94 +      objectsToCut.push_back(tempInputCollection);
95 +      objectsToCut.push_back(obj1);
96 +      objectsToCut.push_back(obj2);  
97 +      objectsToPlot.push_back(tempInputCollection);
98 +      objectsToPlot.push_back(obj1);
99 +      objectsToPlot.push_back(obj2);  
100 +      objectsToGet.push_back(tempInputCollection);
101 +      objectsToGet.push_back(obj1);
102 +      objectsToGet.push_back(obj2ToGet);
103 +
104 +    }
105 +
106 +    vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
107 +
108 +    for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
109 +
110 +      histogram tempHistogram;
111 +      tempHistogram.inputCollection = tempInputCollection;
112 +      tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
113 +      tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
114 +      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
115 +      tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
116 +
117 +      histograms.push_back(tempHistogram);
118 +
119 +    }
120 +  }
121 +  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
122 +  sort( objectsToPlot.begin(), objectsToPlot.end() );
123 +  objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
124 +
125 +
126 +
127 +  //add histograms with the gen-matched id, mother id, and grandmother id
128 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
129 +
130 +    string currentObject = objectsToPlot.at(currentObjectIndex);
131 +    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
132 +
133 +    histogram tempIdHisto;
134 +    histogram tempMomIdHisto;
135 +    histogram tempGmaIdHisto;
136 +    histogram tempIdVsMomIdHisto;
137 +    histogram tempIdVsGmaIdHisto;
138 +
139 +    tempIdHisto.inputCollection = currentObject;
140 +    tempMomIdHisto.inputCollection = currentObject;
141 +    tempGmaIdHisto.inputCollection = currentObject;
142 +    tempIdVsMomIdHisto.inputCollection = currentObject;
143 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
144 +
145 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
146 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
147 +
148 +    currentObject = currentObject.substr(0, currentObject.size()-1);
149 +    tempIdHisto.name = currentObject+"GenMatchId";
150 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
151 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
152 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
153 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
154 +
155 +    currentObject.at(0) = toupper(currentObject.at(0));
156 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
157 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
158 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
159 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
160 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
161 +
162 +
163 +    int maxNum = 24;
164 +    vector<double> binVector;
165 +    binVector.push_back(maxNum);
166 +    binVector.push_back(0);
167 +    binVector.push_back(maxNum);
168 +
169 +    tempIdHisto.bins = binVector;
170 +    tempIdHisto.inputVariables.push_back("genMatchedId");
171 +    tempMomIdHisto.bins = binVector;
172 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
173 +    tempGmaIdHisto.bins = binVector;
174 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
175 +    binVector.push_back(maxNum);
176 +    binVector.push_back(0);
177 +    binVector.push_back(maxNum);
178 +    tempIdVsMomIdHisto.bins = binVector;
179 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
180 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
181 +    tempIdVsGmaIdHisto.bins = binVector;
182 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
183 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
184 +
185 +    histograms.push_back(tempIdHisto);
186 +    histograms.push_back(tempMomIdHisto);
187 +    histograms.push_back(tempGmaIdHisto);
188 +    histograms.push_back(tempIdVsMomIdHisto);
189 +    histograms.push_back(tempIdVsGmaIdHisto);
190 +  }
191 +
192  
193    channel tempChannel;
194    //loop over all channels (event selections)
# Line 46 | Line 207 | OSUAnalysis::OSUAnalysis (const edm::Par
207        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
208        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
209          tempChannel.triggers.push_back(triggerNames.at(trigger));
210 <      allNecessaryObjects.push_back("triggers");
210 >      objectsToGet.push_back("triggers");
211      }
212  
213  
214 +
215 +
216      //create cutFlow for this channel
217      cutFlows_.push_back (new CutFlow (fs_, channelName));
218  
219      //book a directory in the output file with the name of the channel
220      TFileDirectory subDir = fs_->mkdir( channelName );
221      directories.push_back(subDir);
59    std::map<std::string, TH1D*> histoMap;
60    oneDHists_.push_back(histoMap);
222  
223 <    //gen histograms
224 <    oneDHists_.at(currentChannel)["genD0"] = directories.at(currentChannel).make<TH1D> ("genD0",channelLabel+" channel: Gen d_{0}; d_{0} [cm] ", 1000, -1, 1);
225 <    oneDHists_.at(currentChannel)["genAbsD0"] = directories.at(currentChannel).make<TH1D> ("genAbsD0",channelLabel+" channel: Gen d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
226 <    oneDHists_.at(currentChannel)["genDZ"] = directories.at(currentChannel).make<TH1D> ("genDZ",channelLabel+" channel: Gen d_{z}; d_{z} [cm] ", 1000, -10, 10);
66 <    oneDHists_.at(currentChannel)["genAbsDZ"] = directories.at(currentChannel).make<TH1D> ("genAbsDZ",channelLabel+" channel: Gen d_{z}; |d_{z}| [cm] ", 1000, 0, 10);
67 <
68 <    //muon histograms
69 <    allNecessaryObjects.push_back("muons");
70 <    oneDHists_.at(currentChannel)["muonPt"]  = directories.at(currentChannel).make<TH1D> ("muonPt",channelLabel+" channel: Muon Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
71 <    oneDHists_.at(currentChannel)["muonEta"] = directories.at(currentChannel).make<TH1D> ("muonEta",channelLabel+" channel: Muon Eta; #eta", 100, -5, 5);
72 <    oneDHists_.at(currentChannel)["muonD0"] = directories.at(currentChannel).make<TH1D> ("muonD0",channelLabel+" channel: Muon d_{0}; d_{0} [cm] ", 1000, -1, 1);
73 <    oneDHists_.at(currentChannel)["muonDz"] = directories.at(currentChannel).make<TH1D> ("muonDz",channelLabel+" channel: Muon d_{z}; d_{z} [cm] ", 1000, -20, 20);
74 <    oneDHists_.at(currentChannel)["muonAbsD0"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0",channelLabel+" channel: Muon d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
75 <    oneDHists_.at(currentChannel)["muonDZ"] = directories.at(currentChannel).make<TH1D> ("muonDZ",channelLabel+" channel: Muon d_{z}; d_{z} [cm] ", 1000, -10, 10);
76 <    oneDHists_.at(currentChannel)["muonAbsDZ"] = directories.at(currentChannel).make<TH1D> ("muonAbsDZ",channelLabel+" channel: Muon d_{z}; |d_{z}| [cm] ", 1000, 0, 10);
77 <    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);
78 <    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);
79 <    oneDHists_.at(currentChannel)["muonIso"] = directories.at(currentChannel).make<TH1D> ("muonIso",channelLabel+" channel: Muon Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
80 <    oneDHists_.at(currentChannel)["numMuons"] = directories.at(currentChannel).make<TH1D> ("numMuons",channelLabel+" channel: Number of Selected Muons; # muons", 10, 0, 10);
81 <
82 <
83 <    //electron histograms
84 <    allNecessaryObjects.push_back("electrons");
85 <    oneDHists_.at(currentChannel)["electronPt"]  = directories.at(currentChannel).make<TH1D> ("electronPt",channelLabel+" channel: Electron Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
86 <    oneDHists_.at(currentChannel)["electronEta"] = directories.at(currentChannel).make<TH1D> ("electronEta",channelLabel+" channel: Electron Eta; #eta", 50, -5, 5);
87 <    oneDHists_.at(currentChannel)["electronD0"] = directories.at(currentChannel).make<TH1D> ("electronD0",channelLabel+" channel: Electron d_{0}; d_{0} [cm] ", 1000, -1, 1);
88 <    oneDHists_.at(currentChannel)["electronDz"] = directories.at(currentChannel).make<TH1D> ("electronDz",channelLabel+" channel: Electron d_{z}; d_{z} [cm] ", 1000, -20, 20);
89 <    oneDHists_.at(currentChannel)["electronAbsD0"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0",channelLabel+" channel: Electron d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
90 <    oneDHists_.at(currentChannel)["electronDZ"] = directories.at(currentChannel).make<TH1D> ("electronDZ",channelLabel+" channel: Electron d_{z}; d_{z} [cm] ", 1000, -10, 10);
91 <    oneDHists_.at(currentChannel)["electronAbsDZ"] = directories.at(currentChannel).make<TH1D> ("electronAbsDZ",channelLabel+" channel: Electron d_{z}; |d_{z}| [cm] ", 1000, 0, 10);
92 <    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);
93 <    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);
94 <    oneDHists_.at(currentChannel)["electronIso"] = directories.at(currentChannel).make<TH1D> ("electronIso",channelLabel+" channel: Electron Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
95 <    oneDHists_.at(currentChannel)["electronFbrem"] = directories.at(currentChannel).make<TH1D> ("electronFbrem",channelLabel+" channel: Electron Brem. Energy Fraction; fbrem", 1000, 0, 2);
96 <    oneDHists_.at(currentChannel)["electronMVATrig"] = directories.at(currentChannel).make<TH1D> ("electronMVATrig",channelLabel+" channel: Electron ID MVA Output", 100, -1, 1);
97 <    oneDHists_.at(currentChannel)["electronMVANonTrig"] = directories.at(currentChannel).make<TH1D> ("electronMVANonTrig",channelLabel+" channel: Electron ID MVA Output", 100, -1, 1);
98 <    oneDHists_.at(currentChannel)["numElectrons"] = directories.at(currentChannel).make<TH1D> ("numElectrons",channelLabel+" channel: Number of Selected Electrons; # electrons", 10, 0, 10);
223 >    std::map<std::string, TH1D*> oneDhistoMap;
224 >    oneDHists_.push_back(oneDhistoMap);
225 >    std::map<std::string, TH2D*> twoDhistoMap;
226 >    twoDHists_.push_back(twoDhistoMap);
227  
228  
229  
230 <    //get list of cuts for this channel
231 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
230 >    //book all histograms included in the configuration
231 >    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
232 >      histogram currentHistogram = histograms.at(currentHistogramIndex);
233 >      int numBinsElements = currentHistogram.bins.size();
234 >      int numInputVariables = currentHistogram.inputVariables.size();
235 >
236 >      if(numBinsElements != 3 && numBinsElements !=6) {
237 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
238 >        exit(0);
239 >      }
240 >      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
241 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
242 >        exit(0);
243 >      }
244 >      else if(numBinsElements == 3){
245 >        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));
246 >      }
247 >      else if(numBinsElements == 6){
248 >        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));
249 >
250 >      }
251 >
252 >
253 >      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
254 >
255 >      // bin      particle type
256 >      // ---      -------------
257 >      //  0        unmatched
258 >      //  1        u
259 >      //  2        d
260 >      //  3        s
261 >      //  4        c
262 >      //  5        b
263 >      //  6        t
264 >      //  7        e
265 >      //  8        mu
266 >      //  9        tau
267 >      // 10        nu
268 >      // 11        g
269 >      // 12        gamma
270 >      // 13        Z
271 >      // 14        W
272 >      // 15        light meson
273 >      // 16        K meson
274 >      // 17        D meson
275 >      // 18        B meson
276 >      // 19        light baryon
277 >      // 20        strange baryon
278 >      // 21        charm baryon
279 >      // 22        bottom baryon
280 >      // 23        other
281 >
282 >      vector<TString> labelArray;
283 >      labelArray.push_back("unmatched");
284 >      labelArray.push_back("u");
285 >      labelArray.push_back("d");
286 >      labelArray.push_back("s");
287 >      labelArray.push_back("c");
288 >      labelArray.push_back("b");
289 >      labelArray.push_back("t");
290 >      labelArray.push_back("e");
291 >      labelArray.push_back("#mu");
292 >      labelArray.push_back("#tau");
293 >      labelArray.push_back("#nu");
294 >      labelArray.push_back("g");
295 >      labelArray.push_back("#gamma");
296 >      labelArray.push_back("Z");
297 >      labelArray.push_back("W");
298 >      labelArray.push_back("light meson");
299 >      labelArray.push_back("K meson");
300 >      labelArray.push_back("D meson");
301 >      labelArray.push_back("B meson");
302 >      labelArray.push_back("light baryon");
303 >      labelArray.push_back("strange baryon");
304 >      labelArray.push_back("charm baryon");
305 >      labelArray.push_back("bottom baryon");
306 >      labelArray.push_back("other");
307 >
308 >      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
309 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
310 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
311 >        }
312 >        else {
313 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
314 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
315 >        }
316 >      }
317 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
318 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
319 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
320 >      }
321 >
322 >    }
323 >
324 >    // Book a histogram for the number of each object type to be plotted.  
325 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
326 >    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
327 >      string currentObject = objectsToPlot.at(currentObjectIndex);
328 >      int maxNum = 10;
329 >      if(currentObject == "mcparticles") maxNum = 50;
330 >      else if(currentObject == "primaryvertexs") maxNum = 50;
331 >
332 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
333 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
334 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
335 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
336 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
337 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
338 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
339 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
340 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
341 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
342 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
343 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
344 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
345 >
346 >      currentObject.at(0) = toupper(currentObject.at(0));  
347 >      string histoName = "num" + currentObject;
348 >
349 >      if(histoName == "numPrimaryvertexs"){
350 >        string newHistoName = histoName + "BeforePileupCorrection";
351 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
352 >        newHistoName = histoName + "AfterPileupCorrection";
353 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
354 >      }
355 >      else
356 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
357 >    }
358 >
359  
105    vector<string> tempInputCollections;
360  
361  
362 +    //get list of cuts for this channel
363 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
364 +
365      //loop over and parse all cuts
366      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
110
367        cut tempCut;
368 <     //store input collection for cut
369 <      string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
370 <      tempCut.inputCollection = inputCollection;
368 >      //store input collection for cut
369 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
370 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
371 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
372 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
373 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
374 >      tempCut.inputCollection = tempInputCollection;
375 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
376 >        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
377 >          int spaceIndex = tempInputCollection.find(" ");
378 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
379 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
380 >        }
381 >        else{
382 >          objectsToGet.push_back(tempInputCollection);
383 >        }
384 >        objectsToCut.push_back(tempInputCollection);
385 >      }
386 >      else{//pair of objects, need to add them both to objectsToGet
387 >        string obj1;
388 >        string obj2;
389 >        getTwoObjs(tempInputCollection, obj1, obj2);
390 >        string obj2ToGet = getObjToGet(obj2);  
391 >        objectsToCut.push_back(tempInputCollection);
392 >        objectsToCut.push_back(obj1);
393 >        objectsToCut.push_back(obj2);  
394 >        objectsToGet.push_back(tempInputCollection);
395 >        objectsToGet.push_back(obj1);
396 >        objectsToGet.push_back(obj2ToGet);
397 >
398 >      }
399 >
400  
116      tempInputCollections.push_back(inputCollection);
117      allNecessaryObjects.push_back(inputCollection);
401  
402        //split cut string into parts and store them
403        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
404        std::vector<string> cutStringVector = splitString(cutString);
405 <      tempCut.variable = cutStringVector.at(0);// variable to cut on
406 <      tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
407 <      tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
405 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
406 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
407 >        exit(0);
408 >      }
409 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
410 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
411 >        int indexOffset = 4 * subcutIndex;
412 >        string currentVariableString = cutStringVector.at(indexOffset);
413 >        if(currentVariableString.find("(")==std::string::npos){
414 >          tempCut.functions.push_back("");//no function was specified
415 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
416 >        }
417 >        else{
418 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
419 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
420 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
421 >        }
422 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
423 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
424 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
425 >      }
426  
427        //get number of objects required to pass cut for event to pass
428        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
429        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
430 +      if(numberRequiredVector.size()!=2){
431 +        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
432 +        exit(0);
433 +      }
434  
130      // determine number required if comparison contains "="
435        int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
132      if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
133      else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
134
436        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
437        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
438  
439 <      if(cuts_.at(currentCut).exists("function")){
139 <        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
140 <      }
141 <      else tempCut.function = "";
439 >
440        string tempCutName;
441        if(cuts_.at(currentCut).exists("alias")){
442          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
# Line 146 | Line 444 | OSUAnalysis::OSUAnalysis (const edm::Par
444        else{
445          //construct string for cutflow table
446          bool plural = numberRequiredInt != 1;
447 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
447 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
448          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
449          tempCutName = cutName;
450        }
451        tempCut.name = tempCutName;
452  
155
453        tempChannel.cuts.push_back(tempCut);
454  
455  
456      }//end loop over cuts
457  
161    //make unique vector of all objects that this channel cuts on (so we know to set flags for those)
162    sort( tempInputCollections.begin(), tempInputCollections.end() );
163    tempInputCollections.erase( unique( tempInputCollections.begin(), tempInputCollections.end() ), tempInputCollections.end() );
164    tempChannel.inputCollections = tempInputCollections;
165
458      channels.push_back(tempChannel);
459      tempChannel.cuts.clear();
460  
461    }//end loop over channels
462  
463 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
464 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
465 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
463 >
464 >  //make unique vector of objects we need to get from the event
465 >  sort( objectsToGet.begin(), objectsToGet.end() );
466 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
467 >  //make unique vector of objects we need to cut on
468 >  sort( objectsToCut.begin(), objectsToCut.end() );
469 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
470  
471  
472   }
# Line 188 | Line 484 | void
484   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
485   {
486  
191
487    // Retrieve necessary collections from the event.
488 <  edm::Handle<BNtriggerCollection> triggers;
489 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
488 >
489 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
490      event.getByLabel (triggers_, triggers);
491  
492 <  edm::Handle<BNjetCollection> jets;
198 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
492 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
493      event.getByLabel (jets_, jets);
494  
495 <  edm::Handle<BNmuonCollection> muons;
202 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
495 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
496      event.getByLabel (muons_, muons);
497  
498 <  edm::Handle<BNelectronCollection> electrons;
206 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
498 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
499      event.getByLabel (electrons_, electrons);
500  
501 <  edm::Handle<BNeventCollection> events;
210 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
501 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
502      event.getByLabel (events_, events);
503  
504 <  edm::Handle<BNtauCollection> taus;
214 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
504 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
505      event.getByLabel (taus_, taus);
506  
507 <  edm::Handle<BNmetCollection> mets;
218 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
507 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
508      event.getByLabel (mets_, mets);
509  
510 <  edm::Handle<BNtrackCollection> tracks;
222 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
510 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
511      event.getByLabel (tracks_, tracks);
512  
513 <  edm::Handle<BNgenjetCollection> genjets;
226 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
513 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
514      event.getByLabel (genjets_, genjets);
515  
516 <  edm::Handle<BNmcparticleCollection> mcparticles;
230 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
516 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
517      event.getByLabel (mcparticles_, mcparticles);
518  
519 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
234 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
519 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
520      event.getByLabel (primaryvertexs_, primaryvertexs);
521  
522 <  edm::Handle<BNbxlumiCollection> bxlumis;
238 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
522 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
523      event.getByLabel (bxlumis_, bxlumis);
524  
525 <  edm::Handle<BNphotonCollection> photons;
242 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
525 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
526      event.getByLabel (photons_, photons);
527  
528 <  edm::Handle<BNsuperclusterCollection> superclusters;
246 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
528 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
529      event.getByLabel (superclusters_, superclusters);
530  
531 +  if (datasetType_ == "signalMC"){
532 +    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
533 +      event.getByLabel (stops_, stops);
534 +  }
535 +
536 +
537 +  if (useTrackCaloRhoCorr_) {  
538 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
539 +    // This rho collection is not available in all BEANs.  
540 +    // For description of rho values for different jet reconstruction algorithms, see
541 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
542 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
543 +  }
544 +
545 +
546 +  //get pile-up event weight
547 +  double scaleFactor = 1.00;
548 +  if(doPileupReweighting_ && datasetType_ != "data")
549 +    scaleFactor = puWeight_->at (events->at (0).numTruePV);
550 +
551 +  cTauScaleFactor_ = 1.0;
552 + #ifdef DISPLACED_SUSY
553 +  if (datasetType_ == "signalMC")
554 +    cTauScaleFactor_ = cTauWeight_->at (event);
555 + #endif
556 +  scaleFactor *= cTauScaleFactor_;
557  
558    //loop over all channels
559  
# Line 253 | Line 561 | OSUAnalysis::analyze (const edm::Event &
561      channel currentChannel = channels.at(currentChannelIndex);
562  
563      flagMap individualFlags;
256    flagMap cumulativeFlags;
564      counterMap passingCounter;
565 +    cumulativeFlags.clear ();
566  
567      bool triggerDecision = true;
568      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 263 | Line 571 | OSUAnalysis::analyze (const edm::Event &
571      }
572  
573      //loop over all cuts
574 +
575 +
576 +
577      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
578        cut currentCut = currentChannel.cuts.at(currentCutIndex);
579  
580 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
580 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
581 >        string currentObject = objectsToCut.at(currentObjectIndex);
582  
583 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
583 >        //initialize maps to get ready to set cuts
584          individualFlags[currentObject].push_back (vector<bool> ());
585          cumulativeFlags[currentObject].push_back (vector<bool> ());
586  
587 +      }
588 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
589 +        string currentObject = objectsToCut.at(currentObjectIndex);
590 +
591 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
592 +
593 +
594          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
595 +
596          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
597 +
598 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
599 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
600          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
601          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
602          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 286 | Line 609 | OSUAnalysis::analyze (const edm::Event &
609          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
610          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
611  
612 +        else if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
613  
614 +
615 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
616 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
617 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
618 +                                                                   "muon-muon pairs");
619 +
620 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
621 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
622 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
623 +                                                                   "muon-secondary muon pairs");
624 +
625 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
626 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
627 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
628 +                                                                   "electron-secondary electron pairs");
629 +
630 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
631 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
632 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
633 +                                                                           "electron-electron pairs");
634 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
635 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
636 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
637 +                                                                       "electron-muon pairs");
638 +        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
639 +                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
640 +                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
641 +                                                                     "track-event pairs");
642 +        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
643 +                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
644 +                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
645 +                                                                        "electron-track pairs");
646 +        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
647 +                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
648 +                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
649 +                                                                    "muon-track pairs");
650 +        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
651 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
652 +                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
653 +                                                                  "muon-tau pairs");
654 +        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
655 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
656 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
657 +                                                                 "tau-tau pairs");
658 +        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
659 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
660 +                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
661 +                                                                 "tau-track pairs");
662 +        
663 +        
664        }
665  
666  
# Line 294 | Line 668 | OSUAnalysis::analyze (const edm::Event &
668      }//end loop over all cuts
669  
670  
297
298
671      //use cumulative flags to apply cuts at event level
672  
673      bool eventPassedAllCuts = true;
# Line 310 | Line 682 | OSUAnalysis::analyze (const edm::Event &
682        cut currentCut = currentChannel.cuts.at(currentCutIndex);
683        int numberPassing = 0;
684  
685 <      for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
686 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
687 <
316 <
685 >      for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
686 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
687 >      }
688        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
689        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
319
690        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
691  
692      }
693  
694 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();
694 >    //     if(datasetType_ != "data") {
695 >    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
696 >    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
697 >    //     }
698  
699 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
700  
701  
328    if(!eventPassedAllCuts)continue;
329
330
331    TVector3 vertexPosition;
332    vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back();
333
334    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
335      if(!vertexFlags.at(vertexIndex)) continue;
702  
703 <      vertexPosition.SetXYZ (primaryvertexs->at(vertexIndex).x,primaryvertexs->at(vertexIndex).y,primaryvertexs->at(vertexIndex).z);
338 <      break;
339 <    }
340 <
341 <    vector<bool> mcparticleFlags = cumulativeFlags["mcparticles"].back();
342 <
343 <    for (uint mcparticleIndex = 0; mcparticleIndex != mcparticleFlags.size(); mcparticleIndex++){
344 <      if(!mcparticleFlags.at(mcparticleIndex)) continue;
703 >    if(!eventPassedAllCuts)continue;
704  
705 <      double vx = mcparticles->at(mcparticleIndex).vx - vertexPosition.X (),
706 <             vy = mcparticles->at(mcparticleIndex).vy - vertexPosition.Y (),
707 <             vz = mcparticles->at(mcparticleIndex).vz - vertexPosition.Z (),
708 <             px = mcparticles->at(mcparticleIndex).px,
709 <             py = mcparticles->at(mcparticleIndex).py,
710 <             pt = mcparticles->at(mcparticleIndex).pt,
711 <             d0;
353 <
354 <      d0 = (-vx * py + vy * px) / pt;
355 <      oneDHists_.at(currentChannelIndex)["genD0"]->Fill (d0);
356 <      oneDHists_.at(currentChannelIndex)["genAbsD0"]->Fill (fabs (d0));
357 <      oneDHists_.at(currentChannelIndex)["genDZ"]->Fill (vz);
358 <      oneDHists_.at(currentChannelIndex)["genAbsDZ"]->Fill (fabs (vz));
705 >    if (printEventInfo_) {
706 >      // Write information about event to screen, for testing purposes.  
707 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
708 >           << ": run="  << events->at(0).run
709 >           << "  lumi=" << events->at(0).lumi
710 >           << "  event=" << events->at(0).evt
711 >           << endl;  
712      }
713  
361    vector<bool> electronFlags = cumulativeFlags["electrons"].back();
362    int electronCounter = 0;
363
364    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
365      if(!electronFlags.at(electronIndex)) continue;
714  
715 +    //filling histograms
716 +    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
717 +      histogram currentHistogram = histograms.at(histogramIndex);
718 +
719 +      if(currentHistogram.inputVariables.size() == 1){
720 +        TH1D* histo;
721 +        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
722 +
723 +        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
724 +        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
725 +        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
726 +        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
727 +        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
728 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
729 +                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
730 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
731 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
732 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
733 +        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
734 +        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
735 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
736 +                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
737 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
738 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
739 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
740 +        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
741 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
742 +                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
743 +        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
744 +                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
745 +                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
746 +        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
747 +                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
748 +                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
749 +        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
750 +                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
751 +                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
752 +        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
753 +                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
754 +                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
755 +        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
756 +                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
757 +                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
758 +
759 +        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
760 +        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
761 +        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
762 +        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
763 +        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
764 +        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
765 +        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
766 +        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
767 +        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
768 +        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
769 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
770  
771 <      electronCounter++;
772 <      oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt);
773 <      oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta);
774 <      oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex);
775 <      oneDHists_.at(currentChannelIndex)["electronDz"]->Fill (electrons->at(electronIndex).correctedDZ);
776 <      oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex));
777 <      oneDHists_.at(currentChannelIndex)["electronDZ"]->Fill (electrons->at(electronIndex).correctedDZ);
778 <      oneDHists_.at(currentChannelIndex)["electronAbsDZ"]->Fill (fabs(electrons->at(electronIndex).correctedDZ));
779 <      oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err);
780 <      oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err);
781 <      oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (electrons->at(electronIndex).puChargedHadronIso / electrons->at(electronIndex).pt);
782 <      oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem);
783 <      oneDHists_.at(currentChannelIndex)["electronMVATrig"]->Fill (electrons->at(electronIndex).mvaTrigV0);
784 <      oneDHists_.at(currentChannelIndex)["electronMVANonTrig"]->Fill (electrons->at(electronIndex).mvaNonTrigV0);
771 >      }
772 >      else if(currentHistogram.inputVariables.size() == 2){
773 >        TH2D* histo;
774 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
775 >
776 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
777 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
778 >        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
779 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
780 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
781 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
782 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
783 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
784 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
785 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
786 >        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
787 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
788 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
789 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
790 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
791 >                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
792 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
793 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
794 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
795 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
796 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
797 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
798 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
799 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
800 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
801 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
802 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
803 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
804 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
805 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
806 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
807 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
808 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
809 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
810 >                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
811 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
812 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
813 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
814 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
815 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
816 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
817 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
818 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
819 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
820 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
821 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
822 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
823 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
824 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
825  
826 +      }
827      }
384    oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter);
828  
829  
387    vector<bool> muonFlags = cumulativeFlags["muons"].back();
388    int muonCounter = 0;
830  
831 +    //fills histograms with the sizes of collections
832 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
833  
834 <    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
392 <      if(!muonFlags.at(muonIndex)) continue;
393 <      muonCounter++;
394 <
395 <      oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt);
396 <      oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta);
397 <      oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex);
398 <      oneDHists_.at(currentChannelIndex)["muonDz"]->Fill (muons->at(muonIndex).correctedDZ);
399 <      oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex));
400 <      oneDHists_.at(currentChannelIndex)["muonDZ"]->Fill (muons->at(muonIndex).correctedDZ);
401 <      oneDHists_.at(currentChannelIndex)["muonAbsDZ"]->Fill (fabs(muons->at(muonIndex).correctedDZ));
402 <      oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err);
403 <      oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err);
404 <      oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (muons->at(muonIndex).puChargedHadronIso / muons->at(muonIndex).pt);
405 <    }
406 <    oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter);
407 <
834 >      string currentObject = objectsToPlot.at(currentObjectIndex);
835  
836 +      string objectToPlot = "";  
837  
838 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
839 +      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
840 +      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
841 +      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
842 +      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
843 +      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
844 +      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
845 +      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
846 +      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
847 +      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
848 +      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
849 +      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
850 +      else if(currentObject == "electron-secondary electron pairs")       objectToPlot = "electronSecondaryElectronPairs";  
851 +      else if(currentObject == "secondary electrons")         objectToPlot = "secondaryElectrons";  
852 +      else objectToPlot = currentObject;
853 +
854 +      string tempCurrentObject = objectToPlot;
855 +      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
856 +      string histoName = "num" + tempCurrentObject;
857 +
858 +      //set position of primary vertex in event, in order to calculate quantities relative to it
859 +      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
860 +        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
861 +        int numToPlot = 0;
862 +        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
863 +          if(lastCutFlags.at(currentFlag)) numToPlot++;
864 +        }
865 +        if(objectToPlot == "primaryvertexs"){
866 +          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
867 +          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
868 +        }
869 +        else {
870 +          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
871 +        }
872 +      }
873 +      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
874 +      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
875 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
876 +      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
877 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
878 +      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
879 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
880 +      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
881 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
882 +      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
883 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
884 +      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
885 +      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
886 +      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
887 +      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
888 +      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
889 +      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
890 +      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
891 +      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
892 +      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
893 +      else if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
894 +      else if(objectToPlot == "primaryvertexs"){
895 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
896 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
897 +      }
898  
899 +    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
900  
901    } //end loop over channel
902  
903 <  masterCutFlow_->fillCutFlow();
903 >  masterCutFlow_->fillCutFlow(scaleFactor);
904  
905 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
906  
417 }
907  
908  
909   bool
# Line 426 | Line 915 | OSUAnalysis::evaluateComparison (double
915    else if(comparison == "<")  return testValue <  cutValue;
916    else if(comparison == "<=") return testValue <= cutValue;
917    else if(comparison == "==") return testValue == cutValue;
918 +  else if(comparison == "=") return testValue == cutValue;
919    else if(comparison == "!=") return testValue != cutValue;
920    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
921  
# Line 461 | Line 951 | OSUAnalysis::splitString (string inputSt
951  
952   }
953  
954 +
955 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
956 +  // Set two object strings from the tempInputCollection string,
957 +  // For example, if tempInputCollection is "electron-muon pairs",
958 +  // then obj1 = "electrons" and obj2 = "muons".  
959 +  // Note that the objects have an "s" appended.  
960 +
961 +  int dashIndex = tempInputCollection.find("-");
962 +  int spaceIndex = tempInputCollection.find_last_of(" ");
963 +  int secondWordLength = spaceIndex - dashIndex;
964 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
965 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
966 +  
967 + }
968 +
969 +
970 + string OSUAnalysis::getObjToGet(string obj) {
971 +  // Return the string corresponding to the object to get for the given obj string.
972 +  // Right now this only handles the case in which obj contains "secondary",
973 +  // e.g, "secondary muons".  
974 +  // Note that "s" is NOT appended.  
975 +  
976 +  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
977 +  int firstSpaceIndex = obj.find_first_of(" ");  
978 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
979 +
980 + }  
981 +
982 +
983 +
984   double
985   OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
986  
# Line 608 | Line 1128 | OSUAnalysis::valueLookup (const BNmuon*
1128    else if(variable == "ecalIso") value = object->ecalIso;
1129    else if(variable == "hcalIso") value = object->hcalIso;
1130    else if(variable == "caloIso") value = object->caloIso;
1131 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
1131 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
1132    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1133    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1134    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 746 | Line 1266 | OSUAnalysis::valueLookup (const BNmuon*
1266    else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
1267    else if(variable == "time_ndof") value = object->time_ndof;
1268  
1269 +  //user-defined variables
1270 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1271 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1272 +  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1273 +  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1274 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1275 +  else if(variable == "metMT") {
1276 +    const BNmet *met = chosenMET ();
1277 +    if (met)
1278 +      {
1279 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1280 +          p2 (met->px, met->py, 0.0, met->pt);
1281 +
1282 +        value = (p1 + p2).Mt ();
1283 +      }
1284 +    else
1285 +      value = -999;
1286 +  }
1287 +
1288 +
1289 +
1290 +  else if(variable == "correctedD0VertexInEBPlus"){
1291 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1292 +    else value = -999;
1293 +  }
1294 +  else if(variable == "correctedD0VertexOutEBPlus"){
1295 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1296 +    else value = -999;
1297 +  }
1298 +  else if(variable == "correctedD0VertexEEPlus"){
1299 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1300 +    else value = -999;
1301 +  }
1302 +
1303 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1304 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1305 +    else value = -999;
1306 +  }
1307 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1308 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1309 +    else value = -999;
1310 +  }
1311 +  else if(variable == "correctedD0BeamspotEEPlus"){
1312 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1313 +    else value = -999;
1314 +  }
1315 +
1316 +  else if(variable == "correctedD0VertexInEBMinus"){
1317 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1318 +    else value = -999;
1319 +  }
1320 +  else if(variable == "correctedD0VertexOutEBMinus"){
1321 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1322 +    else value = -999;
1323 +  }
1324 +  else if(variable == "correctedD0VertexEEMinus"){
1325 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1326 +    else value = -999;
1327 +  }
1328 +
1329 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1330 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1331 +    else value = -999;
1332 +  }
1333 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1334 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1335 +    else value = -999;
1336 +  }
1337 +  else if(variable == "correctedD0BeamspotEEMinus"){
1338 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1339 +    else value = -999;
1340 +  }
1341 +
1342 +
1343 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1344 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1345 +    else value = -999;
1346 +  }
1347 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1348 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1349 +    else value = -999;
1350 +  }
1351 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1352 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1353 +    else value = -999;
1354 +  }
1355 +
1356 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1357 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1358 +    else value = -999;
1359 +  }
1360 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1361 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1362 +    else value = -999;
1363 +  }
1364 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1365 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1366 +    else value = -999;
1367 +  }
1368 +
1369 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1370 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1371 +    else value = -999;
1372 +  }
1373 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1374 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1375 +    else value = -999;
1376 +  }
1377 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1378 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1379 +    else value = -999;
1380 +  }
1381 +
1382 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1383 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1384 +    else value = -999;
1385 +  }
1386 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1387 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1388 +    else value = -999;
1389 +  }
1390 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1391 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1392 +    else value = -999;
1393 +  }
1394 +
1395 +
1396 +  else if(variable == "tightID") {
1397 +    value = object->isGlobalMuon > 0                \
1398 +      && object->isPFMuon > 0                        \
1399 +      && object->normalizedChi2 < 10                \
1400 +                                  && object->numberOfValidMuonHits > 0        \
1401 +      && object->numberOfMatchedStations > 1        \
1402 +      && fabs(object->correctedD0Vertex) < 0.2        \
1403 +      && fabs(object->correctedDZ) < 0.5        \
1404 +      && object->numberOfValidPixelHits > 0                \
1405 +      && object->numberOfLayersWithMeasurement > 5;
1406 +  }
1407 +  else if(variable == "tightIDdisplaced"){
1408 +    value = object->isGlobalMuon > 0                \
1409 +      && object->normalizedChi2 < 10                \
1410 +                                  && object->numberOfValidMuonHits > 0        \
1411 +      && object->numberOfMatchedStations > 1        \
1412 +      && object->numberOfValidPixelHits > 0        \
1413 +      && object->numberOfLayersWithMeasurement > 5;
1414 +  }
1415 +
1416 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1417 +
1418 +  else if(variable == "genMatchedPdgId"){
1419 +    int index = getGenMatchedParticleIndex(object);
1420 +    if(index == -1) value = 0;
1421 +    else value = mcparticles->at(index).id;
1422 +  }
1423 +
1424 +  else if(variable == "genMatchedId"){
1425 +    int index = getGenMatchedParticleIndex(object);
1426 +    if(index == -1) value = 0;
1427 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1428 +  }
1429 +  else if(variable == "genMatchedMotherId"){
1430 +    int index = getGenMatchedParticleIndex(object);
1431 +    if(index == -1) value = 0;
1432 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1433 +  }
1434 +  else if(variable == "genMatchedMotherIdReverse"){
1435 +    int index = getGenMatchedParticleIndex(object);
1436 +    if(index == -1) value = 23;
1437 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1438 +  }
1439 +  else if(variable == "genMatchedGrandmotherId"){
1440 +    int index = getGenMatchedParticleIndex(object);
1441 +    if(index == -1) value = 0;
1442 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1443 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1444 +      if(motherIndex == -1) value = 0;
1445 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1446 +    }
1447 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1448 +  }
1449 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1450 +    int index = getGenMatchedParticleIndex(object);
1451 +    if(index == -1) value = 23;
1452 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1453 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1454 +      if(motherIndex == -1) value = 23;
1455 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1456 +    }
1457 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1458 +  }
1459 +
1460 +
1461 +
1462    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1463  
1464    value = applyFunction(function, value);
# Line 915 | Line 1628 | OSUAnalysis::valueLookup (const BNelectr
1628    else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1629    else if(variable == "passConvVeto") value = object->passConvVeto;
1630  
1631 +  //user-defined variables
1632 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1633 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1634 +  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1635 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1636 +  else if(variable == "metMT") {
1637 +    const BNmet *met = chosenMET ();
1638 +    if (met)
1639 +      {
1640 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1641 +          p2 (met->px, met->py, 0.0, met->pt);
1642 +
1643 +        value = (p1 + p2).Mt ();
1644 +      }
1645 +    else
1646 +      value = -999;
1647 +  }
1648 +
1649 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1650 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1651 +    else value = -999;
1652 +  }
1653 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1654 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1655 +    else value = -999;
1656 +  }
1657 +
1658 +  else if(variable == "correctedD0VertexInEBPlus"){
1659 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1660 +    else value = -999;
1661 +  }
1662 +  else if(variable == "correctedD0VertexOutEBPlus"){
1663 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1664 +    else value = -999;
1665 +  }
1666 +  else if(variable == "correctedD0VertexEEPlus"){
1667 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1668 +    else value = -999;
1669 +  }
1670 +
1671 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1672 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1673 +    else value = -999;
1674 +  }
1675 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1676 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1677 +    else value = -999;
1678 +  }
1679 +  else if(variable == "correctedD0BeamspotEEPlus"){
1680 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1681 +    else value = -999;
1682 +  }
1683 +
1684 +  else if(variable == "correctedD0VertexInEBMinus"){
1685 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1686 +    else value = -999;
1687 +  }
1688 +  else if(variable == "correctedD0VertexOutEBMinus"){
1689 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1690 +    else value = -999;
1691 +  }
1692 +  else if(variable == "correctedD0VertexEEMinus"){
1693 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1694 +    else value = -999;
1695 +  }
1696 +
1697 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1698 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1699 +    else value = -999;
1700 +  }
1701 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1702 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1703 +    else value = -999;
1704 +  }
1705 +  else if(variable == "correctedD0BeamspotEEMinus"){
1706 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1707 +    else value = -999;
1708 +  }
1709 +
1710 +  else if(variable == "tightID"){
1711 +    if (object->isEB)
1712 +      {
1713 +        value = fabs(object->delEtaIn) < 0.004 \
1714 +          && fabs (object->delPhiIn) < 0.03 \
1715 +          && object->scSigmaIEtaIEta < 0.01 \
1716 +          && object->hadOverEm < 0.12 \
1717 +          && fabs (object->correctedD0Vertex) < 0.02 \
1718 +          && fabs (object->correctedDZ) < 0.1 \
1719 +          && object->absInvEMinusInvPin < 0.05 \
1720 +          && object->passConvVeto;
1721 +      }
1722 +    else
1723 +      {
1724 +        value = fabs(object->delEtaIn) < 0.005 \
1725 +          && fabs (object->delPhiIn) < 0.02 \
1726 +          && object->scSigmaIEtaIEta < 0.03 \
1727 +          && object->hadOverEm < 0.10 \
1728 +          && fabs (object->correctedD0Vertex) < 0.02 \
1729 +          && fabs (object->correctedDZ) < 0.1 \
1730 +          && object->absInvEMinusInvPin < 0.05 \
1731 +          && object->passConvVeto;
1732 +      }
1733 +  }
1734 +
1735 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1736 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1737 +    else value = -999;
1738 +  }
1739 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1740 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1741 +    else value = -999;
1742 +  }
1743 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1744 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1745 +    else value = -999;
1746 +  }
1747 +
1748 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1749 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1750 +    else value = -999;
1751 +  }
1752 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1753 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1754 +    else value = -999;
1755 +  }
1756 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1757 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1758 +    else value = -999;
1759 +  }
1760 +
1761 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1762 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1763 +    else value = -999;
1764 +  }
1765 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1766 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1767 +    else value = -999;
1768 +  }
1769 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1770 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1771 +    else value = -999;
1772 +  }
1773 +
1774 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1775 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1776 +    else value = -999;
1777 +  }
1778 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1779 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1780 +    else value = -999;
1781 +  }
1782 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1783 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1784 +    else value = -999;
1785 +  }
1786 +
1787 +
1788 +  else if(variable == "tightIDdisplaced"){
1789 +    if (object->isEB)
1790 +      {
1791 +        value = fabs(object->delEtaIn) < 0.004 \
1792 +          && fabs (object->delPhiIn) < 0.03 \
1793 +          && object->scSigmaIEtaIEta < 0.01 \
1794 +          && object->hadOverEm < 0.12 \
1795 +          && object->absInvEMinusInvPin < 0.05;
1796 +      }
1797 +    else
1798 +      {
1799 +        value = fabs (object->delEtaIn) < 0.005 \
1800 +          && fabs (object->delPhiIn) < 0.02 \
1801 +          && object->scSigmaIEtaIEta < 0.03 \
1802 +          && object->hadOverEm < 0.10 \
1803 +          && object->absInvEMinusInvPin < 0.05;
1804 +      }
1805 +  }
1806 +
1807 +
1808 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1809 +
1810 +  else if(variable == "genMatchedPdgId"){
1811 +    int index = getGenMatchedParticleIndex(object);
1812 +    if(index == -1) value = 0;
1813 +    else value = mcparticles->at(index).id;
1814 +  }
1815 +
1816 +
1817 +  else if(variable == "genMatchedId"){
1818 +    int index = getGenMatchedParticleIndex(object);
1819 +    if(index == -1) value = 0;
1820 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1821 +  }
1822 +  else if(variable == "genMatchedMotherId"){
1823 +    int index = getGenMatchedParticleIndex(object);
1824 +    if(index == -1) value = 0;
1825 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1826 +  }
1827 +  else if(variable == "genMatchedMotherIdReverse"){
1828 +    int index = getGenMatchedParticleIndex(object);
1829 +    if(index == -1) value = 23;
1830 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1831 +  }
1832 +  else if(variable == "genMatchedGrandmotherId"){
1833 +    int index = getGenMatchedParticleIndex(object);
1834 +    if(index == -1) value = 0;
1835 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1836 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1837 +      if(motherIndex == -1) value = 0;
1838 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1839 +    }
1840 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1841 +  }
1842 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1843 +    int index = getGenMatchedParticleIndex(object);
1844 +    if(index == -1) value = 23;
1845 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1846 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1847 +      if(motherIndex == -1) value = 23;
1848 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1849 +    }
1850 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1851 +  }
1852 +
1853 +
1854  
1855    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1856  
# Line 993 | Line 1929 | OSUAnalysis::valueLookup (const BNevent*
1929    else if(variable == "id1") value = object->id1;
1930    else if(variable == "id2") value = object->id2;
1931    else if(variable == "evt") value = object->evt;
1932 +  else if(variable == "puScaleFactor"){
1933 +    if(datasetType_ != "data")
1934 +      value = puWeight_->at (events->at (0).numTruePV);
1935 +    else
1936 +      value = 1.0;
1937 +  }
1938 +  else if(variable == "muonScaleFactor"){
1939 +    if(datasetType_ != "data")
1940 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1941 +      value = 1.0;
1942 +    else
1943 +      value = 1.0;
1944 +  }
1945 +  else if(variable == "electronScaleFactor"){
1946 +    if(datasetType_ != "data")
1947 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1948 +      value = 1.0;
1949 +    else
1950 +      value = 1.0;
1951 +  }
1952 +  else if(variable == "cTauScaleFactor")
1953 +    value = cTauScaleFactor_;
1954  
1955    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1956  
# Line 1047 | Line 2005 | OSUAnalysis::valueLookup (const BNtau* o
2005    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2006  
2007  
2008 +
2009 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2010 +
2011 +  else if(variable == "genMatchedPdgId"){
2012 +    int index = getGenMatchedParticleIndex(object);
2013 +    if(index == -1) value = 0;
2014 +    else value = mcparticles->at(index).id;
2015 +  }
2016 +
2017 +  else if(variable == "genMatchedId"){
2018 +    int index = getGenMatchedParticleIndex(object);
2019 +    if(index == -1) value = 0;
2020 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2021 +  }
2022 +  else if(variable == "genMatchedMotherId"){
2023 +    int index = getGenMatchedParticleIndex(object);
2024 +    if(index == -1) value = 0;
2025 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2026 +  }
2027 +  else if(variable == "genMatchedMotherIdReverse"){
2028 +    int index = getGenMatchedParticleIndex(object);
2029 +    if(index == -1) value = 23;
2030 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2031 +  }
2032 +  else if(variable == "genMatchedGrandmotherId"){
2033 +    int index = getGenMatchedParticleIndex(object);
2034 +    if(index == -1) value = 0;
2035 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2036 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2037 +      if(motherIndex == -1) value = 0;
2038 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2039 +    }
2040 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2041 +  }
2042 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2043 +    int index = getGenMatchedParticleIndex(object);
2044 +    if(index == -1) value = 23;
2045 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2046 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2047 +      if(motherIndex == -1) value = 23;
2048 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2049 +    }
2050 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2051 +  }
2052 +
2053 +
2054    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2055  
2056    value = applyFunction(function, value);
# Line 1130 | Line 2134 | double
2134   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2135  
2136    double value = 0.0;
2137 <
2137 >  double pMag = sqrt(object->pt * object->pt +
2138 >                     object->pz * object->pz);
2139 >  
2140    if(variable == "pt") value = object->pt;
2141    else if(variable == "px") value = object->px;
2142    else if(variable == "py") value = object->py;
# Line 1150 | Line 2156 | OSUAnalysis::valueLookup (const BNtrack*
2156    else if(variable == "isHighPurity") value = object->isHighPurity;
2157  
2158  
2159 +  //additional BNs info for disappTrks
2160 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2161 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2162 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2163 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2164 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2165 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2166 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2167 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2168 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2169 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2170 +  
2171 +
2172 +  //user defined variables
2173 +  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;
2174 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2175 +  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2176 +  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2177 +  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2178 +  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2179 +  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2180 +  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2181 +  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2182 +  else if(variable == "ptError")                    value = object->ptError;
2183 +  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2184 +  else if (variable == "d0wrtPV"){      
2185 +    double vx = object->vx - chosenVertex ()->x,        
2186 +      vy = object->vy - chosenVertex ()->y,      
2187 +      px = object->px,  
2188 +      py = object->py,  
2189 +      pt = object->pt;  
2190 +    value = (-vx * py + vy * px) / pt;  
2191 +  }      
2192 +  else if (variable == "dZwrtPV"){      
2193 +    double vx = object->vx - chosenVertex ()->x,        
2194 +      vy = object->vy - chosenVertex ()->y,      
2195 +      vz = object->vz - chosenVertex ()->z,      
2196 +      px = object->px,  
2197 +      py = object->py,  
2198 +      pz = object->pz,  
2199 +      pt = object->pt;  
2200 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2201 +  }    
2202 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2203 +
2204 +  else if(variable == "genMatchedPdgId"){
2205 +    int index = getGenMatchedParticleIndex(object);
2206 +    if(index == -1) value = 0;
2207 +    else value = mcparticles->at(index).id;
2208 +  }
2209 +
2210 +
2211 +  else if(variable == "genMatchedId"){
2212 +    int index = getGenMatchedParticleIndex(object);
2213 +    if(index == -1) value = 0;
2214 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2215 +  }
2216 +  else if(variable == "genMatchedMotherId"){
2217 +    int index = getGenMatchedParticleIndex(object);
2218 +    if(index == -1) value = 0;
2219 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2220 +  }
2221 +  else if(variable == "genMatchedMotherIdReverse"){
2222 +    int index = getGenMatchedParticleIndex(object);
2223 +    if(index == -1) value = 23;
2224 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2225 +  }
2226 +  else if(variable == "genMatchedGrandmotherId"){
2227 +    int index = getGenMatchedParticleIndex(object);
2228 +    if(index == -1) value = 0;
2229 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2230 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2231 +      if(motherIndex == -1) value = 0;
2232 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2233 +    }
2234 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2235 +  }
2236 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2237 +    int index = getGenMatchedParticleIndex(object);
2238 +    if(index == -1) value = 23;
2239 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2240 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2241 +      if(motherIndex == -1) value = 23;
2242 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2243 +    }
2244 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2245 +  }
2246 +
2247 +
2248 +
2249    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2250  
2251    value = applyFunction(function, value);
# Line 1275 | Line 2371 | OSUAnalysis::valueLookup (const BNmcpart
2371    else if(variable == "grandMother11Status") value = object->grandMother11Status;
2372    else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
2373  
2374 +  //user-defined variables
2375 +  else if (variable == "d0"){
2376 +    double vx = object->vx - chosenVertex ()->x,
2377 +      vy = object->vy - chosenVertex ()->y,
2378 +      px = object->px,
2379 +      py = object->py,
2380 +      pt = object->pt;
2381 +    value = (-vx * py + vy * px) / pt;
2382 +  }
2383 +  else if (variable == "dz"){
2384 +    double vx = object->vx - chosenVertex ()->x,
2385 +      vy = object->vy - chosenVertex ()->y,
2386 +      vz = object->vz - chosenVertex ()->z,
2387 +      px = object->px,
2388 +      py = object->py,
2389 +      pz = object->pz,
2390 +      pt = object->pt;
2391 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2392 +  }
2393 +  else if(variable == "v0"){
2394 +    value = sqrt(object->vx*object->vx + object->vy*object->vy);
2395 +  }
2396 +  else if(variable == "deltaV0"){
2397 +    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2398 +  }
2399 +  else if (variable == "deltaVx"){
2400 +    value = object->vx - chosenVertex ()->x;
2401 +  }
2402 +  else if (variable == "deltaVy"){
2403 +    value = object->vy - chosenVertex ()->y;
2404 +  }
2405 +  else if (variable == "deltaVz"){
2406 +    value = object->vz - chosenVertex ()->z;
2407 +  }
2408 +
2409 +
2410    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2411  
2412    value = applyFunction(function, value);
# Line 1402 | Line 2534 | OSUAnalysis::valueLookup (const BNphoton
2534    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2535  
2536  
2537 +
2538 +
2539 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2540 +
2541 +  else if(variable == "genMatchedPdgId"){
2542 +    int index = getGenMatchedParticleIndex(object);
2543 +    if(index == -1) value = 0;
2544 +    else value = mcparticles->at(index).id;
2545 +  }
2546 +
2547 +
2548 +
2549 +  else if(variable == "genMatchedId"){
2550 +    int index = getGenMatchedParticleIndex(object);
2551 +    if(index == -1) value = 0;
2552 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2553 +  }
2554 +  else if(variable == "genMatchedMotherId"){
2555 +    int index = getGenMatchedParticleIndex(object);
2556 +    if(index == -1) value = 0;
2557 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2558 +  }
2559 +  else if(variable == "genMatchedMotherIdReverse"){
2560 +    int index = getGenMatchedParticleIndex(object);
2561 +    if(index == -1) value = 23;
2562 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2563 +  }
2564 +  else if(variable == "genMatchedGrandmotherId"){
2565 +    int index = getGenMatchedParticleIndex(object);
2566 +    if(index == -1) value = 0;
2567 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2568 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2569 +      if(motherIndex == -1) value = 0;
2570 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2571 +    }
2572 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2573 +  }
2574 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2575 +    int index = getGenMatchedParticleIndex(object);
2576 +    if(index == -1) value = 23;
2577 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2578 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2579 +      if(motherIndex == -1) value = 23;
2580 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2581 +    }
2582 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2583 +  }
2584 +
2585 +
2586    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2587  
2588    value = applyFunction(function, value);
# Line 1433 | Line 2614 | OSUAnalysis::valueLookup (const BNsuperc
2614  
2615  
2616   double
2617 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2618 +
2619 +  double value = 0.0;
2620 +
2621 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2622 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2623 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2624 +  else if(variable == "invMass"){
2625 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2626 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2627 +    value = (fourVector1 + fourVector2).M();
2628 +  }
2629 +  else if(variable == "pt"){
2630 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2631 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2632 +    value = (fourVector1 + fourVector2).Pt();
2633 +  }
2634 +  else if(variable == "threeDAngle")
2635 +    {
2636 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2637 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2638 +      value = (threeVector1.Angle(threeVector2));
2639 +    }
2640 +  else if(variable == "alpha")
2641 +    {
2642 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2643 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2644 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2645 +      value = (pi-threeVector1.Angle(threeVector2));
2646 +    }
2647 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2648 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2649 +  else if(variable == "d0Sign"){
2650 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2651 +    if(d0Sign < 0) value = -0.5;
2652 +    else if (d0Sign > 0) value = 0.5;
2653 +    else value = -999;
2654 +  }
2655 +  else if(variable == "chargeProduct"){
2656 +    value = object1->charge*object2->charge;
2657 +  }
2658 +  else if(variable == "muon1CorrectedD0Vertex"){
2659 +    value = object1->correctedD0Vertex;
2660 +  }
2661 +  else if(variable == "muon2CorrectedD0Vertex"){
2662 +    value = object2->correctedD0Vertex;
2663 +  }
2664 +  else if(variable == "muon1timeAtIpInOut"){
2665 +    value = object1->timeAtIpInOut;
2666 +  }
2667 +  else if(variable == "muon2timeAtIpInOut"){
2668 +    value = object2->timeAtIpInOut;
2669 +  }
2670 +  else if(variable == "muon1correctedD0")
2671 +    {
2672 +      value = object1->correctedD0;
2673 +    }
2674 +  else if(variable == "muon2correctedD0")
2675 +    {
2676 +      value = object2->correctedD0;
2677 +    }
2678 +
2679 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2680 +
2681 +  value = applyFunction(function, value);
2682 +
2683 +  return value;
2684 + }
2685 +
2686 + double
2687 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2688 +
2689 +  double value = 0.0;
2690 +
2691 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2692 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2693 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2694 +  else if(variable == "invMass"){
2695 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2696 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2697 +    value = (fourVector1 + fourVector2).M();
2698 +  }
2699 +  else if(variable == "pt"){
2700 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2701 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2702 +    value = (fourVector1 + fourVector2).Pt();
2703 +  }
2704 +  else if(variable == "threeDAngle")
2705 +    {
2706 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2707 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2708 +      value = (threeVector1.Angle(threeVector2));
2709 +    }
2710 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2711 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2712 +  else if(variable == "d0Sign"){
2713 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2714 +    if(d0Sign < 0) value = -0.5;
2715 +    else if (d0Sign > 0) value = 0.5;
2716 +    else value = -999;
2717 +  }
2718 +  else if(variable == "chargeProduct"){
2719 +    value = object1->charge*object2->charge;
2720 +  }
2721 +  else if(variable == "electron1CorrectedD0Vertex"){
2722 +    value = object1->correctedD0Vertex;
2723 +  }
2724 +  else if(variable == "electron2CorrectedD0Vertex"){
2725 +    value = object2->correctedD0Vertex;
2726 +  }
2727 +  else if(variable == "electron1CorrectedD0"){
2728 +    value = object1->correctedD0;
2729 +  }
2730 +  else if(variable == "electron2CorrectedD0"){
2731 +    value = object2->correctedD0;
2732 +  }
2733 +
2734 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2735 +
2736 +  value = applyFunction(function, value);
2737 +
2738 +  return value;
2739 + }
2740 +
2741 + double
2742 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2743 +
2744 +  double value = 0.0;
2745 +
2746 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2747 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2748 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2749 +  else if(variable == "invMass"){
2750 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2751 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2752 +    value = (fourVector1 + fourVector2).M();
2753 +  }
2754 +  else if(variable == "pt"){
2755 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2756 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2757 +    value = (fourVector1 + fourVector2).Pt();
2758 +  }
2759 +  else if(variable == "threeDAngle")
2760 +    {
2761 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2762 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2763 +      value = (threeVector1.Angle(threeVector2));
2764 +    }
2765 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2766 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2767 +  else if(variable == "d0Sign"){
2768 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2769 +    if(d0Sign < 0) value = -0.5;
2770 +    else if (d0Sign > 0) value = 0.5;
2771 +    else value = -999;
2772 +  }
2773 +  else if(variable == "chargeProduct"){
2774 +    value = object1->charge*object2->charge;
2775 +  }
2776 +  else if(variable == "electronCorrectedD0Vertex"){
2777 +    value = object1->correctedD0Vertex;
2778 +  }
2779 +  else if(variable == "muonCorrectedD0Vertex"){
2780 +    value = object2->correctedD0Vertex;
2781 +  }
2782 +  else if(variable == "electronCorrectedD0"){
2783 +    value = object1->correctedD0;
2784 +  }
2785 +  else if(variable == "muonCorrectedD0"){
2786 +    value = object2->correctedD0;
2787 +  }
2788 +  else if(variable == "electronDetIso"){
2789 +    value = (object1->trackIso) / object1->pt;
2790 +  }
2791 +  else if(variable == "muonDetIso"){
2792 +    value = (object2->trackIsoDR03) / object2->pt;
2793 +  }
2794 +  else if(variable == "electronRelPFrhoIso"){
2795 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2796 +  }
2797 +  else if(variable == "muonRelPFdBetaIso"){
2798 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2799 +  }
2800 +
2801 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2802 +
2803 +  value = applyFunction(function, value);
2804 +
2805 +  return value;
2806 + }
2807 +
2808 +
2809 + double  
2810 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2811 +  double electronMass = 0.000511;        
2812 +  double value = 0.0;    
2813 +  TLorentzVector fourVector1(0, 0, 0, 0);        
2814 +  TLorentzVector fourVector2(0, 0, 0, 0);        
2815 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2816 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2817 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2818 +  else if(variable == "invMass"){        
2819 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2820 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2821 +        
2822 +    value = (fourVector1 + fourVector2).M();    
2823 +  }
2824 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2825 +  value = applyFunction(function, value);        
2826 +  return value;  
2827 + }
2828 +
2829 +
2830 +
2831 + double
2832 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2833 +  double pionMass = 0.140;
2834 +  double muonMass = 0.106;
2835 +  double value = 0.0;
2836 +  TLorentzVector fourVector1(0, 0, 0, 0);
2837 +  TLorentzVector fourVector2(0, 0, 0, 0);
2838 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2839 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2840 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2841 +  else if(variable == "invMass"){
2842 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2843 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2844 +
2845 +    value = (fourVector1 + fourVector2).M();
2846 +  }
2847 +
2848 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2849 +  value = applyFunction(function, value);
2850 +  return value;
2851 + }
2852 +
2853 +
2854 + double
2855 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2856 +  double value = 0.0;
2857 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2858 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2859 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2860 +  else if(variable == "invMass"){
2861 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2862 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2863 +    value = (fourVector1 + fourVector2).M();
2864 +  }
2865 +
2866 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2867 +  value = applyFunction(function, value);
2868 +  return value;
2869 + }
2870 +
2871 +
2872 + double
2873 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2874 +  double value = 0.0;
2875 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2876 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2877 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2878 +  else if(variable == "invMass"){
2879 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2880 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2881 +    value = (fourVector1 + fourVector2).M();
2882 +  }
2883 +
2884 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2885 +  value = applyFunction(function, value);
2886 +  return value;
2887 + }
2888 +
2889 + double
2890 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
2891 +  double value = 0.0;
2892 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2893 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2894 +
2895 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2896 +  value = applyFunction(function, value);
2897 +  return value;
2898 + }
2899 +
2900 +
2901 +
2902 + double
2903 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2904 +
2905 +  double value = 0.0;
2906 +  double pMag = sqrt(object1->pt * object1->pt +
2907 +                     object1->pz * object1->pz);  
2908 +
2909 +  if      (variable == "numPV")                      value = object2->numPV;
2910 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2911 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2912 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2913 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2914 +
2915 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2916 +
2917 +  value = applyFunction(function, value);
2918 +
2919 +  return value;
2920 +
2921 + }  
2922 +
2923 + double
2924 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
2925 +
2926 +
2927 +  double value = 0.0;
2928 +
2929 +  if(variable == "ctau") value = object->ctau;
2930 +
2931 +  else if (variable == "d0"){
2932 +    double vx = object->vx - chosenVertex ()->x,
2933 +      vy = object->vy - chosenVertex ()->y,
2934 +      px = object->px,
2935 +      py = object->py,
2936 +      pt = object->pt;
2937 +    value = (-vx * py + vy * px) / pt;
2938 +  }
2939 +
2940 +  else if (variable == "dz"){
2941 +    double vx = object->vx - chosenVertex ()->x,
2942 +      vy = object->vy - chosenVertex ()->y,
2943 +      vz = object->vz - chosenVertex ()->z,
2944 +      px = object->px,
2945 +      py = object->py,
2946 +      pz = object->pz,
2947 +      pt = object->pt;
2948 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2949 +  }
2950 +
2951 +  else if (variable == "minD0"){
2952 +    double minD0=999;
2953 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2954 +      double vx = object->vx - vertex->x,
2955 +        vy = object->vy - vertex->y,
2956 +        px = object->px,
2957 +        py = object->py,
2958 +        pt = object->pt;
2959 +      value = (-vx * py + vy * px) / pt;
2960 +      if(abs(value) < abs(minD0)) minD0 = value;
2961 +    }
2962 +    value = minD0;
2963 +  }
2964 +  else if (variable == "minDz"){
2965 +    double minDz=999;
2966 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2967 +      double vx = object->vx - vertex->x,
2968 +        vy = object->vy - vertex->y,
2969 +        vz = object->vz - vertex->z,
2970 +        px = object->px,
2971 +        py = object->py,
2972 +        pz = object->pz,
2973 +        pt = object->pt;
2974 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2975 +      if(abs(value) < abs(minDz)) minDz = value;
2976 +    }
2977 +    value = minDz;
2978 +  }
2979 +  else if(variable == "distToVertex"){
2980 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
2981 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
2982 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
2983 +  }
2984 +  else if (variable == "minDistToVertex"){
2985 +    double minDistToVertex=999;
2986 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2987 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
2988 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
2989 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
2990 +      
2991 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
2992 +    }
2993 +    value = minDistToVertex;
2994 +  }
2995 +  else if (variable == "distToVertexDifference"){
2996 +    double minDistToVertex=999;
2997 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
2998 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
2999 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3000 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3001 +      
3002 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3003 +    }
3004 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3005 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3006 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3007 +
3008 +    value = distToChosenVertex - minDistToVertex;
3009 +  }
3010 +
3011 +  else if (variable == "closestVertexRank"){
3012 +    double minDistToVertex=999;
3013 +    int vertex_rank = 0;
3014 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3015 +      vertex_rank++;
3016 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3017 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3018 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3019 +      
3020 +      if(abs(dist) < abs(minDistToVertex)){
3021 +        value = vertex_rank;
3022 +        minDistToVertex = dist;
3023 +      }
3024 +    }
3025 +  }
3026 +
3027 +
3028 +
3029 +
3030 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3031 +
3032 +  value = applyFunction(function, value);
3033 +
3034 +  return value;
3035 +
3036 + }  
3037 +
3038 +
3039 +
3040 +
3041 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3042 + // Return true iff no other tracks are found in this cone.
3043 + int
3044 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
3045 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
3046 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
3047 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
3048 +    if(deltaRtrk < 0.5) return 0;
3049 +  }
3050 +  return 1;
3051 +
3052 + }
3053 +
3054 +
3055 + double
3056 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
3057 +
3058 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
3059 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
3060 +
3061 +  return PtRes;
3062 +
3063 + }
3064 +
3065 +
3066 + double
3067 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
3068 +  double value = -99;
3069 +  double genDeltaRLowest = 999;
3070 +
3071 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
3072 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
3073 +    if (genDeltaRtemp < genDeltaRLowest) {
3074 +      genDeltaRLowest = genDeltaRtemp;
3075 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
3076 +        double ptTrue = genPart->pt;
3077 +        value = ptTrue;
3078 +      }
3079 +    }
3080 +  }
3081 +
3082 +  return value;
3083 +
3084 + }
3085 +
3086 + double
3087 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3088 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3089 +  if (!useTrackCaloRhoCorr_) return -99;  
3090 +  // if (!rhokt6CaloJetsHandle_) {
3091 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3092 +  //   return -99;  
3093 +  // }
3094 +  double radDeltaRCone = 0.5;  
3095 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3096 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3097 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3098 +  return caloTotRhoCorrCalo;  
3099 +
3100 + }
3101 +
3102 +
3103 +
3104 +
3105 + //creates a map of the dead Ecal channels in the barrel and endcap
3106 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3107 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
3108 + void
3109 + OSUAnalysis::WriteDeadEcal (){
3110 +  double etaEcal, phiEcal;
3111 +  ifstream DeadEcalFile(deadEcalFile_);
3112 +  if(!DeadEcalFile) {
3113 +    cout << "Error: DeadEcalFile has not been found." << endl;
3114 +    return;
3115 +  }
3116 +  if(DeadEcalVec.size()!= 0){
3117 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
3118 +    return;
3119 +  }
3120 +  while(!DeadEcalFile.eof())
3121 +    {
3122 +      DeadEcalFile >> etaEcal >> phiEcal;
3123 +      DeadEcal newChan;
3124 +      newChan.etaEcal = etaEcal;
3125 +      newChan.phiEcal = phiEcal;
3126 +      DeadEcalVec.push_back(newChan);
3127 +    }
3128 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
3129 + }
3130 +
3131 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
3132 + int
3133 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
3134 +  double deltaRLowest = 999;
3135 +  int value = 0;
3136 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
3137 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3138 +    double eta = ecal->etaEcal;
3139 +    double phi = ecal->phiEcal;
3140 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3141 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3142 +  }
3143 +  if (deltaRLowest<0.05) {value = 1;}
3144 +  else {value = 0;}
3145 +  return value;
3146 + }
3147 +
3148 + // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3149 + template <class InputObject>
3150 + double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3151 +  double genDeltaRLowest = 999.;
3152 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3153 +    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3154 +    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3155 +  }
3156 +  return genDeltaRLowest;
3157 + }
3158 +
3159 + double
3160   OSUAnalysis::applyFunction(string function, double value){
3161  
3162 <  if(function == "abs") value = abs(value);
3162 >  if(function == "abs") value = fabs(value);
3163 >  else if(function == "fabs") value = fabs(value);
3164 >  else if(function == "log10") value = log10(value);
3165 >  else if(function == "log") value = log10(value);
3166  
3167 +  else if(function == "") value = value;
3168 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3169  
3170    return value;
3171  
# Line 1445 | Line 3174 | OSUAnalysis::applyFunction(string functi
3174  
3175   template <class InputCollection>
3176   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3177 <
3177 >
3178 >  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3179 >    string obj1, obj2;
3180 >    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3181 >    if (inputType==obj1 ||
3182 >        inputType==obj2) {
3183 >      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3184 >      // and the inputType is a member of the pair.  
3185 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3186 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3187 >      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3188 >      return;
3189 >    }  
3190 >  }    
3191  
3192    for (uint object = 0; object != inputCollection->size(); object++){
3193  
# Line 1453 | Line 3195 | void OSUAnalysis::setObjectFlags(cut &cu
3195  
3196      if(currentCut.inputCollection == inputType){
3197  
3198 <      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
3198 >      vector<bool> subcutDecisions;
3199 >      for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3200 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3201 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3202  
3203 <      decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
3203 >      }
3204 >      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3205 >      else{
3206 >        bool tempDecision = true;
3207 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
3208 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
3209 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
3210 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3211 >            tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
3212 >        }
3213 >        decision = tempDecision;
3214 >      }
3215      }
1460    individualFlags[inputType].at(currentCutIndex).push_back(decision);
3216  
3217 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3218  
3219      //set flags for objects that pass each cut AND all the previous cuts
3220      bool previousCumulativeFlag = true;
3221      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3222 <      if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
3222 >      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
3223        else{ previousCumulativeFlag = false; break;}
3224      }
3225 <    cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3225 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3226  
3227    }
3228  
3229   }
3230  
3231  
3232 + template <class InputCollection1, class InputCollection2>
3233 + void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
3234 +                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
3235 +
3236 +
3237 +  bool sameObjects = false;
3238 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3239 +
3240 +  // Get the strings for the two objects that make up the pair.  
3241 +  string obj1Type, obj2Type;
3242 +  getTwoObjs(inputType, obj1Type, obj2Type);
3243 +  bool isTwoTypesOfObject = true;
3244 +  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3245 +
3246 +  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3247 +  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3248 +  if (currentCut.inputCollection == inputType) {    
3249 +    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3250 +      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3251 +      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3252 +    }
3253 +    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3254 +      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3255 +        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3256 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3257 +      }
3258 +    }
3259 +  }
3260 +  
3261 +  int counter = 0;
3262 +
3263 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3264 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3265 +
3266 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3267  
3268  
3269 +      bool decision = true;//object passes if this cut doesn't cut on that type of object
3270  
3271 < DEFINE_FWK_MODULE(OSUAnalysis);
3271 >      if(currentCut.inputCollection == inputType){
3272 >
3273 >        vector<bool> subcutDecisions;
3274 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3275 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3276 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3277 >        }
3278 >
3279 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3280 >        else{
3281 >          bool tempDecision = subcutDecisions.at(0);
3282 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
3283 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
3284 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
3285 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
3286 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
3287 >          }
3288 >          decision = tempDecision;
3289 >        }
3290 >      }
3291 >      // if (decision) isPassObj1.at(object1) = true;
3292 >      // if (decision) isPassObj2.at(object2) = true;
3293 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3294 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3295 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3296 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3297 >      }  
3298 >
3299 >      //set flags for objects that pass each cut AND all the previous cuts
3300 >      bool previousCumulativeFlag = true;
3301 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3302 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
3303 >        else{ previousCumulativeFlag = false; break;}
3304 >      }
3305 >      //apply flags for the components of the composite object as well
3306 >      bool currentCumulativeFlag = true;
3307 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
3308 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
3309 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3310 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3311 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3312 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3313 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3314 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3315 >      }
3316 >      counter++;
3317 >
3318 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3319 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3320 >
3321 > }
3322 >
3323 >
3324 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3325 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3326 >  // all cuts up to currentCutIndex  
3327 >  bool previousCumulativeFlag = true;  
3328 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3329 >    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3330 >    else {  
3331 >      previousCumulativeFlag = false; break;  
3332 >    }
3333 >  }
3334 >  return previousCumulativeFlag;  
3335 > }  
3336 >
3337 >
3338 > template <class InputCollection>
3339 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3340 >
3341 >  for (uint object = 0; object != inputCollection->size(); object++){
3342 >
3343 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3344 >
3345 >    string currentString = parameters.inputVariables.at(0);
3346 >    string inputVariable = "";
3347 >    string function = "";
3348 >    if(currentString.find("(")==std::string::npos){
3349 >      inputVariable = currentString;// variable to cut on
3350 >    }
3351 >    else{
3352 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3353 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3354 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3355 >    }
3356 >
3357 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3358 >    histo->Fill(value,scaleFactor);
3359 >
3360 >    if (printEventInfo_) {
3361 >      // Write information about event to screen, for testing purposes.  
3362 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3363 >    }
3364 >    
3365 >  }
3366 > }
3367 >
3368 > template <class InputCollection1, class InputCollection2>
3369 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3370 >
3371 >  bool sameObjects = false;
3372 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3373 >
3374 >  int pairCounter = -1;
3375 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3376 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3377 >
3378 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3379 >
3380 >      pairCounter++;
3381 >      //only take objects which have passed all cuts and pairs which have passed all cuts
3382 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3383 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3384 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3385 >
3386 >      string currentString = parameters.inputVariables.at(0);
3387 >      string inputVariable = "";
3388 >      string function = "";
3389 >      if(currentString.find("(")==std::string::npos){
3390 >        inputVariable = currentString;// variable to cut on
3391 >      }
3392 >      else{
3393 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3394 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3395 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3396 >      }
3397 >
3398 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3399 >      histo->Fill(value,scaleFactor);
3400 >
3401 >    }
3402 >  }
3403 >
3404 > }
3405 >
3406 >
3407 > template <class InputCollection>
3408 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3409 >
3410 >  for (uint object = 0; object != inputCollection->size(); object++){
3411 >
3412 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3413 >
3414 >    string currentString = parameters.inputVariables.at(0);
3415 >    string inputVariable = "";
3416 >    string function = "";
3417 >    if(currentString.find("(")==std::string::npos){
3418 >      inputVariable = currentString;// variable to cut on
3419 >    }
3420 >    else{
3421 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3422 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3423 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3424 >    }
3425 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3426 >
3427 >    currentString = parameters.inputVariables.at(1);
3428 >    inputVariable = "";
3429 >    function = "";
3430 >    if(currentString.find("(")==std::string::npos){
3431 >      inputVariable = currentString;// variable to cut on
3432 >    }
3433 >    else{
3434 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3435 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3436 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3437 >    }
3438 >
3439 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3440 >
3441 >    histo->Fill(valueX,valueY,scaleFactor);
3442 >
3443 >  }
3444 >
3445 > }
3446 >
3447 > template <class InputCollection1, class InputCollection2>
3448 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3449 >
3450 >  bool sameObjects = false;
3451 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3452  
3453 +  int pairCounter = -1;
3454 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3455 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3456 +
3457 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3458 +
3459 +      pairCounter++;
3460 +
3461 +      //only take objects which have passed all cuts and pairs which have passed all cuts
3462 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3463 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3464 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3465 +
3466 +      string currentString = parameters.inputVariables.at(0);
3467 +      string inputVariable = "";
3468 +      string function = "";
3469 +      if(currentString.find("(")==std::string::npos){
3470 +        inputVariable = currentString;// variable to cut on
3471 +      }
3472 +      else{
3473 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3474 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3475 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3476 +      }
3477 +      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3478 +
3479 +      currentString = parameters.inputVariables.at(1);
3480 +      inputVariable = "";
3481 +      function = "";
3482 +      if(currentString.find("(")==std::string::npos){
3483 +        inputVariable = currentString;// variable to cut on
3484 +      }
3485 +      else{
3486 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3487 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3488 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3489 +      }
3490 +      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3491 +
3492 +
3493 +      histo->Fill(valueX,valueY,scaleFactor);
3494 +
3495 +    }
3496 +  }
3497 +
3498 + }
3499 +
3500 +
3501 + template <class InputObject>
3502 + int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
3503 +
3504 +  int bestMatchIndex = -1;
3505 +  double bestMatchDeltaR = 999;
3506 +
3507 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3508 +
3509 +    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3510 +    if(currentDeltaR > 0.05) continue;
3511 +    //     cout << std::setprecision(3) << std::setw(20)
3512 +    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3513 +    //          << std::setw(20)
3514 +    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3515 +    //          << std::setw(20)
3516 +    //          << "\tdeltaR = " << currentDeltaR
3517 +    //          << std::setprecision(1)
3518 +    //          << std::setw(20)
3519 +    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3520 +    //          << std::setw(20)
3521 +    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3522 +    //          << std::setw(20)
3523 +    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3524 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3525 +      bestMatchIndex = mcparticle - mcparticles->begin();
3526 +      bestMatchDeltaR = currentDeltaR;
3527 +    }
3528 +
3529 +  }
3530 +  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3531 +  //   else cout << "no match found..." << endl;
3532 +  return bestMatchIndex;
3533 +
3534 + }
3535 +
3536 +
3537 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
3538 +
3539 +  int bestMatchIndex = -1;
3540 +  double bestMatchDeltaR = 999;
3541 +
3542 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3543 +
3544 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
3545 +
3546 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
3547 +    if(currentDeltaR > 0.05) continue;
3548 +
3549 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3550 +      bestMatchIndex = mcparticle - mcparticles->begin();
3551 +      bestMatchDeltaR = currentDeltaR;
3552 +    }
3553 +
3554 +  }
3555 +
3556 +  return bestMatchIndex;
3557 + }
3558 +
3559 +
3560 + // bin      particle type
3561 + // ---      -------------
3562 + //  0        unmatched
3563 + //  1        u
3564 + //  2        d
3565 + //  3        s
3566 + //  4        c
3567 + //  5        b
3568 + //  6        t
3569 + //  7        e
3570 + //  8        mu
3571 + //  9        tau
3572 + // 10        nu
3573 + // 11        g
3574 + // 12        gamma
3575 + // 13        Z
3576 + // 14        W
3577 + // 15        light meson
3578 + // 16        K meson
3579 + // 17        D meson
3580 + // 18        B meson
3581 + // 19        light baryon
3582 + // 20        strange baryon
3583 + // 21        charm baryon
3584 + // 22        bottom baryon
3585 + // 23        other
3586 +
3587 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
3588 +
3589 +  int binValue = -999;
3590 +  int absPdgId = fabs(pdgId);
3591 +  if(pdgId == -1) binValue = 0;
3592 +  else if(absPdgId <= 6 ) binValue = absPdgId;
3593 +  else if(absPdgId == 11 ) binValue = 7;
3594 +  else if(absPdgId == 13 ) binValue = 8;
3595 +  else if(absPdgId == 15 ) binValue = 9;
3596 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
3597 +  else if(absPdgId == 21 ) binValue = 11;
3598 +  else if(absPdgId == 22 ) binValue = 12;
3599 +  else if(absPdgId == 23 ) binValue = 13;
3600 +  else if(absPdgId == 24 ) binValue = 14;
3601 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
3602 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
3603 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
3604 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
3605 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
3606 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3607 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3608 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3609 +
3610 +  else binValue = 23;
3611 +
3612 +  return binValue;
3613 +
3614 + }
3615 +
3616 + const BNprimaryvertex *
3617 + OSUAnalysis::chosenVertex ()
3618 + {
3619 +  const BNprimaryvertex *chosenVertex = 0;
3620 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3621 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3622 +      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3623 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3624 +      if(!vertexFlags.at(vertexIndex)) continue;
3625 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3626 +      break;
3627 +    }
3628 +  }
3629 +  else {
3630 +    chosenVertex = &primaryvertexs->at(0);
3631 +  }
3632 +
3633 +  return chosenVertex;
3634 + }
3635  
3636 + const BNmet *
3637 + OSUAnalysis::chosenMET ()
3638 + {
3639 +  const BNmet *chosenMET = 0;
3640 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3641 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3642 +      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3643 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3644 +      if(!metFlags.at(metIndex)) continue;
3645 +      chosenMET = & mets->at(metIndex);
3646 +      break;
3647 +    }
3648 +  }
3649 +  else {
3650 +    chosenMET = &mets->at(0);
3651 +  }
3652 +
3653 +  return chosenMET;
3654 + }
3655 +
3656 + const BNelectron *
3657 + OSUAnalysis::chosenElectron ()
3658 + {
3659 +  const BNelectron *chosenElectron = 0;
3660 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3661 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3662 +      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3663 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3664 +      if(!electronFlags.at(electronIndex)) continue;
3665 +      chosenElectron = & electrons->at(electronIndex);
3666 +      break;
3667 +    }
3668 +  }
3669 +  else {
3670 +    chosenElectron = &electrons->at(0);
3671 +  }
3672 +
3673 +  return chosenElectron;
3674 + }
3675 +
3676 + const BNmuon *
3677 + OSUAnalysis::chosenMuon ()
3678 + {
3679 +  const BNmuon *chosenMuon = 0;
3680 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3681 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3682 +      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3683 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3684 +      if(!muonFlags.at(muonIndex)) continue;
3685 +      chosenMuon = & muons->at(muonIndex);
3686 +      break;
3687 +    }
3688 +  }
3689 +  else {
3690 +    chosenMuon = &muons->at(0);
3691 +  }
3692 +
3693 +  return chosenMuon;
3694 + }
3695 +
3696 +
3697 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines