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.24 by lantonel, Mon Mar 4 23:25:13 2013 UTC

# Line 16 | Line 16 | OSUAnalysis::OSUAnalysis (const edm::Par
16    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 <
20 <
21 <  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels"))
19 >  puFile_ (cfg.getParameter<std::string> ("puFile")),
20 >  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
21 >  dataset_ (cfg.getParameter<std::string> ("dataset")),
22 >  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
23 >  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
24 >  histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
25 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents"))
26  
27   {
28 +
29    TH1::SetDefaultSumw2 ();
30  
31 +  //create pile-up reweighting object, if necessary
32 +  if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
33 +
34    // Construct Cutflow Objects. These store the results of cut decisions and
35    // handle filling cut flow histograms.
36    masterCutFlow_ = new CutFlow (fs_);
37    std::vector<TFileDirectory> directories;
38  
39 +  //always get vertex collection so we can assign the primary vertex in the event
40 +  objectsToGet.push_back("primaryvertexs");
41 +  //always make the plot of number of primary verticex (to check pile-up reweighting)
42 +  objectsToPlot.push_back("primaryvertexs");
43 +
44 +  //always get the MC particles to do GEN-matching
45 +  objectsToGet.push_back("mcparticles");
46 +
47 +  //always get the event collection to do pile-up reweighting
48 +  objectsToGet.push_back("events");
49 +
50 +  //parse the histogram definitions
51 +  for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
52 +
53 +    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
54 +    if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
55 +    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
56 +      objectsToGet.push_back(tempInputCollection);
57 +      objectsToPlot.push_back(tempInputCollection);
58 +      objectsToCut.push_back(tempInputCollection);
59 +    }
60 +    else{//pair of objects, need to add them both to the things to objectsToGet
61 +      int dashIndex = tempInputCollection.find("-");
62 +      int spaceIndex = tempInputCollection.find(" ");
63 +      int secondWordLength = spaceIndex - dashIndex;
64 +      objectsToGet.push_back(tempInputCollection);
65 +      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
66 +      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
67 +      objectsToPlot.push_back(tempInputCollection);
68 +      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
69 +      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
70 +      objectsToCut.push_back(tempInputCollection);
71 +      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
72 +      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
73 +
74 +      }
75 +
76 +    vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
77 +    
78 +    for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
79 +
80 +      histogram tempHistogram;
81 +      tempHistogram.inputCollection = tempInputCollection;
82 +      tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
83 +      tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
84 +      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
85 +      tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
86 +      
87 +      histograms.push_back(tempHistogram);
88 +
89 +    }
90 +  }
91 +  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
92 +  sort( objectsToPlot.begin(), objectsToPlot.end() );
93 +  objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
94 +
95 +
96 +
97 +  //add histograms with the gen-matched id, mother id, and grandmother id
98 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
99 +
100 +    string currentObject = objectsToPlot.at(currentObjectIndex);
101 +    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
102 +
103 +    histogram tempIdHisto;
104 +    histogram tempMomIdHisto;
105 +    histogram tempGmaIdHisto;
106 +
107 +    tempIdHisto.inputCollection = currentObject;
108 +    tempMomIdHisto.inputCollection = currentObject;
109 +    tempGmaIdHisto.inputCollection = currentObject;
110 +
111 +    currentObject = currentObject.substr(0, currentObject.size()-1);
112 +    tempIdHisto.name = currentObject+"GenMatchId";
113 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
114 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
115 +
116 +    currentObject.at(0) = toupper(currentObject.at(0));
117 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
118 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
119 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
120 +
121 +    int maxNum = 24;
122 +    vector<double> binVector;
123 +    binVector.push_back(maxNum);
124 +    binVector.push_back(0);
125 +    binVector.push_back(maxNum);
126 +
127 +    tempIdHisto.bins = binVector;
128 +    tempIdHisto.inputVariables.push_back("genMatchedId");
129 +    tempMomIdHisto.bins = binVector;
130 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
131 +    tempGmaIdHisto.bins = binVector;
132 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
133 +
134 +    histograms.push_back(tempIdHisto);
135 +    histograms.push_back(tempMomIdHisto);
136 +    histograms.push_back(tempGmaIdHisto);
137 +    
138 +  }
139 +
140 +
141  
142    channel tempChannel;
143    //loop over all channels (event selections)
# Line 46 | Line 156 | OSUAnalysis::OSUAnalysis (const edm::Par
156        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
157        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
158          tempChannel.triggers.push_back(triggerNames.at(trigger));
159 <      allNecessaryObjects.push_back("triggers");
159 >      objectsToGet.push_back("triggers");
160      }
161  
162  
163 +
164 +
165      //create cutFlow for this channel
166      cutFlows_.push_back (new CutFlow (fs_, channelName));
167  
168      //book a directory in the output file with the name of the channel
169      TFileDirectory subDir = fs_->mkdir( channelName );
170      directories.push_back(subDir);
59    std::map<std::string, TH1D*> histoMap;
60    oneDHists_.push_back(histoMap);
171  
172 <    //gen histograms
173 <    oneDHists_.at(currentChannel)["genD0"] = directories.at(currentChannel).make<TH1D> ("genD0",channelLabel+" channel: Gen d_{0}; d_{0} [cm] ", 1000, -1, 1);
174 <    oneDHists_.at(currentChannel)["genAbsD0"] = directories.at(currentChannel).make<TH1D> ("genAbsD0",channelLabel+" channel: Gen d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
175 <    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);
172 >    std::map<std::string, TH1D*> oneDhistoMap;
173 >    oneDHists_.push_back(oneDhistoMap);
174 >    std::map<std::string, TH2D*> twoDhistoMap;
175 >    twoDHists_.push_back(twoDhistoMap);
176  
177  
178 +    //book all histograms included in the configuration
179 +    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
180 +      histogram currentHistogram = histograms.at(currentHistogramIndex);
181 +      int numBinsElements = currentHistogram.bins.size();
182 +      int numInputVariables = currentHistogram.inputVariables.size();
183 +
184 +      if(numBinsElements != 3 && numBinsElements !=6) {
185 +        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
186 +        exit(0);
187 +      }
188 +      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
189 +        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
190 +        exit(0);
191 +      }
192 +      else if(numBinsElements == 3){
193 +        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));
194 +      }
195 +      else if(numBinsElements == 6){
196 +        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));
197  
198 <    //get list of cuts for this channel
103 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
198 >      }
199  
105    vector<string> tempInputCollections;
200  
201 +      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
202 +
203 + // bin      particle type
204 + // ---      -------------
205 + //  0        unmatched
206 + //  1        u
207 + //  2        d
208 + //  3        s
209 + //  4        c
210 + //  5        b
211 + //  6        t
212 + //  7        e
213 + //  8        mu
214 + //  9        tau
215 + // 10        nu
216 + // 11        g
217 + // 12        gamma
218 + // 13        Z
219 + // 14        W
220 + // 15        light meson
221 + // 16        K meson
222 + // 17        D meson
223 + // 18        B meson
224 + // 19        light baryon
225 + // 20        strange baryon
226 + // 21        charm baryon
227 + // 22        bottom baryon
228 + // 23        other
229 +
230 +      vector<TString> labelArray;
231 +      labelArray.push_back("unmatched");
232 +      labelArray.push_back("u");
233 +      labelArray.push_back("d");
234 +      labelArray.push_back("s");
235 +      labelArray.push_back("c");
236 +      labelArray.push_back("b");
237 +      labelArray.push_back("t");
238 +      labelArray.push_back("e");
239 +      labelArray.push_back("#mu");
240 +      labelArray.push_back("#tau");
241 +      labelArray.push_back("#nu");
242 +      labelArray.push_back("g");
243 +      labelArray.push_back("#gamma");
244 +      labelArray.push_back("Z");
245 +      labelArray.push_back("W");
246 +      labelArray.push_back("light meson");
247 +      labelArray.push_back("K meson");
248 +      labelArray.push_back("D meson");
249 +      labelArray.push_back("B meson");
250 +      labelArray.push_back("light baryon");
251 +      labelArray.push_back("strange baryon");
252 +      labelArray.push_back("charm baryon");
253 +      labelArray.push_back("bottom baryon");
254 +      labelArray.push_back("other");
255 +
256 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
257 +        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
258 +      }
259 +    }
260 +    //book a histogram for the number of each object type to be plotted
261 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
262 +      string currentObject = objectsToPlot.at(currentObjectIndex);
263 +      int maxNum = 10;
264 +      if(currentObject == "mcparticles") maxNum = 50;
265 +      else if(currentObject == "primaryvertexs") maxNum = 50;
266 +      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
267 +      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
268 +      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
269 +
270 +      currentObject.at(0) = toupper(currentObject.at(0));
271 +      string histoName = "num" + currentObject;
272 +
273 +      if(histoName == "numPrimaryvertexs"){
274 +        string newHistoName = histoName + "BeforePileupCorrection";
275 +        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
276 +        newHistoName = histoName + "AfterPileupCorrection";
277 +        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
278 +      }
279 +      else
280 +        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
281 +    }
282 +
283 +
284 +    
285 +
286 +
287 +    //get list of cuts for this channel
288 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
289  
290      //loop over and parse all cuts
291      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
110
292        cut tempCut;
293 <     //store input collection for cut
294 <      string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
295 <      tempCut.inputCollection = inputCollection;
293 >      //store input collection for cut
294 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
295 >      tempCut.inputCollection = tempInputCollection;
296 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
297 >        objectsToGet.push_back(tempInputCollection);
298 >        objectsToCut.push_back(tempInputCollection);
299 >      }
300 >      else{//pair of objects, need to add them both to the things to objectsToGet
301 >        int dashIndex = tempInputCollection.find("-");
302 >        int spaceIndex = tempInputCollection.find(" ");
303 >        int secondWordLength = spaceIndex - dashIndex;
304 >        objectsToGet.push_back(tempInputCollection);
305 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
306 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
307 >        objectsToCut.push_back(tempInputCollection);
308 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
309 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
310 >
311 >      }
312 >
313  
116      tempInputCollections.push_back(inputCollection);
117      allNecessaryObjects.push_back(inputCollection);
314  
315        //split cut string into parts and store them
316        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
317        std::vector<string> cutStringVector = splitString(cutString);
318 <      tempCut.variable = cutStringVector.at(0);// variable to cut on
319 <      tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
320 <      tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
318 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
319 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
320 >        exit(0);
321 >      }
322 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
323 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
324 >        int indexOffset = 4 * subcutIndex;
325 >        string currentVariableString = cutStringVector.at(indexOffset);
326 >        if(currentVariableString.find("(")==std::string::npos){
327 >          tempCut.functions.push_back("");//no function was specified
328 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
329 >        }
330 >        else{
331 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
332 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
333 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
334 >        }
335 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
336 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
337 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
338 >      }
339  
340        //get number of objects required to pass cut for event to pass
341        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
342        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
343 +      if(numberRequiredVector.size()!=2){
344 +        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
345 +        exit(0);
346 +      }
347  
130      // determine number required if comparison contains "="
348        int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
132      if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
133      else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
134
349        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
350        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
351  
352 <      if(cuts_.at(currentCut).exists("function")){
139 <        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
140 <      }
141 <      else tempCut.function = "";
352 >
353        string tempCutName;
354        if(cuts_.at(currentCut).exists("alias")){
355          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
# Line 146 | Line 357 | OSUAnalysis::OSUAnalysis (const edm::Par
357        else{
358          //construct string for cutflow table
359          bool plural = numberRequiredInt != 1;
360 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
360 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
361          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
362          tempCutName = cutName;
363        }
# Line 156 | Line 367 | OSUAnalysis::OSUAnalysis (const edm::Par
367        tempChannel.cuts.push_back(tempCut);
368  
369  
159    }//end loop over cuts
370  
371 <    //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;
371 >    }//end loop over cuts
372  
373      channels.push_back(tempChannel);
374      tempChannel.cuts.clear();
375  
376    }//end loop over channels
377  
378 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
379 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
380 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
378 >
379 >  //make unique vector of objects we need to get from the event
380 >  sort( objectsToGet.begin(), objectsToGet.end() );
381 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
382 >  //make unique vector of objects we need to cut on
383 >  sort( objectsToCut.begin(), objectsToCut.end() );
384 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
385  
386  
387   }
# Line 188 | Line 399 | void
399   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
400   {
401  
191
402    // Retrieve necessary collections from the event.
403 <  edm::Handle<BNtriggerCollection> triggers;
404 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
403 >
404 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
405      event.getByLabel (triggers_, triggers);
406  
407 <  edm::Handle<BNjetCollection> jets;
198 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
407 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
408      event.getByLabel (jets_, jets);
409  
410 <  edm::Handle<BNmuonCollection> muons;
202 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
410 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
411      event.getByLabel (muons_, muons);
412  
413 <  edm::Handle<BNelectronCollection> electrons;
206 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
413 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
414      event.getByLabel (electrons_, electrons);
415  
416 <  edm::Handle<BNeventCollection> events;
210 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
416 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
417      event.getByLabel (events_, events);
418  
419 <  edm::Handle<BNtauCollection> taus;
214 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
419 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
420      event.getByLabel (taus_, taus);
421  
422 <  edm::Handle<BNmetCollection> mets;
218 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
422 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
423      event.getByLabel (mets_, mets);
424  
425 <  edm::Handle<BNtrackCollection> tracks;
222 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
425 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
426      event.getByLabel (tracks_, tracks);
427  
428 <  edm::Handle<BNgenjetCollection> genjets;
226 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
428 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
429      event.getByLabel (genjets_, genjets);
430  
431 <  edm::Handle<BNmcparticleCollection> mcparticles;
230 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
431 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
432      event.getByLabel (mcparticles_, mcparticles);
433  
434 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
234 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
434 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
435      event.getByLabel (primaryvertexs_, primaryvertexs);
436  
437 <  edm::Handle<BNbxlumiCollection> bxlumis;
238 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
437 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
438      event.getByLabel (bxlumis_, bxlumis);
439  
440 <  edm::Handle<BNphotonCollection> photons;
242 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
440 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
441      event.getByLabel (photons_, photons);
442  
443 <  edm::Handle<BNsuperclusterCollection> superclusters;
246 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
443 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
444      event.getByLabel (superclusters_, superclusters);
445  
446  
447 +  //get pile-up event weight
448 +  double puScaleFactor = 1.00;
449 +  if(datasetType_ != "data")
450 +    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
451 +
452    //loop over all channels
453  
454    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
# Line 263 | Line 465 | OSUAnalysis::analyze (const edm::Event &
465      }
466  
467      //loop over all cuts
468 +
469 +
470 +
471      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
472        cut currentCut = currentChannel.cuts.at(currentCutIndex);
473  
474 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
474 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
475 >        string currentObject = objectsToCut.at(currentObjectIndex);
476  
477 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
477 >        //initialize maps to get ready to set cuts
478          individualFlags[currentObject].push_back (vector<bool> ());
479          cumulativeFlags[currentObject].push_back (vector<bool> ());
480  
481 +      }
482 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
483 +        string currentObject = objectsToCut.at(currentObjectIndex);
484 +
485 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
486 +
487          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
488          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
489          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 286 | Line 498 | OSUAnalysis::analyze (const edm::Event &
498          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
499          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
500  
501 +        
502 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
503 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
504 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
505 +                                                                   "muon-muon pairs");
506 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
507 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
508 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
509 +                                                                           "electron-electron pairs");
510 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
511 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
512 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
513 +                                                                       "electron-muon pairs");
514  
515        }
516  
# Line 294 | Line 519 | OSUAnalysis::analyze (const edm::Event &
519      }//end loop over all cuts
520  
521  
297
298
522      //use cumulative flags to apply cuts at event level
523  
524      bool eventPassedAllCuts = true;
# Line 304 | Line 527 | OSUAnalysis::analyze (const edm::Event &
527      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
528  
529  
530 +
531      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
532  
533        //loop over all objects and count how many passed the cumulative selection up to this point
534        cut currentCut = currentChannel.cuts.at(currentCutIndex);
535        int numberPassing = 0;
536  
537 <      for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
538 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
539 <
537 >      for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
538 >          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
539 >      }
540  
541        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
542        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 321 | Line 545 | OSUAnalysis::analyze (const edm::Event &
545  
546      }
547  
548 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();
548 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
549  
550  
551  
552      if(!eventPassedAllCuts)continue;
553  
554  
555 <    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;
555 >    
556  
557 <      vertexPosition.SetXYZ (primaryvertexs->at(vertexIndex).x,primaryvertexs->at(vertexIndex).y,primaryvertexs->at(vertexIndex).z);
558 <      break;
557 >    //set position of primary vertex in event, in order to calculate quantities relative to it
558 >    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
559 >      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
560 >      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
561 >        if(!vertexFlags.at(vertexIndex)) continue;
562 >        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
563 >        break;
564 >      }
565 >    }
566 >    else {
567 >      chosenPrimaryVertex = & primaryvertexs->at(0);
568      }
569  
341    vector<bool> mcparticleFlags = cumulativeFlags["mcparticles"].back();
570  
343    for (uint mcparticleIndex = 0; mcparticleIndex != mcparticleFlags.size(); mcparticleIndex++){
344      if(!mcparticleFlags.at(mcparticleIndex)) continue;
571  
572 <      double vx = mcparticles->at(mcparticleIndex).vx - vertexPosition.X (),
573 <             vy = mcparticles->at(mcparticleIndex).vy - vertexPosition.Y (),
574 <             vz = mcparticles->at(mcparticleIndex).vz - vertexPosition.Z (),
575 <             px = mcparticles->at(mcparticleIndex).px,
576 <             py = mcparticles->at(mcparticleIndex).py,
577 <             pt = mcparticles->at(mcparticleIndex).pt,
578 <             d0;
572 >    //filling histograms
573 >    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
574 >      histogram currentHistogram = histograms.at(histogramIndex);
575 >
576 >      if(currentHistogram.inputVariables.size() == 1){
577 >        TH1D* histo;
578 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
579  
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));
359    }
580  
361    vector<bool> electronFlags = cumulativeFlags["electrons"].back();
362    int electronCounter = 0;
581  
582 <    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
583 <      if(!electronFlags.at(electronIndex)) continue;
582 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
583 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
584 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
585 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
586 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
587 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
588 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
589 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
590 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
591 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
592 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
593 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
594 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
595 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
596 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
597 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
598 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
599 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
600 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
601 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
602 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
603 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
604 >      }
605 >      else if(currentHistogram.inputVariables.size() == 2){
606 >        TH2D* histo;
607 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
608  
609  
368      electronCounter++;
369      oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt);
370      oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta);
371      oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex);
372      oneDHists_.at(currentChannelIndex)["electronDz"]->Fill (electrons->at(electronIndex).correctedDZ);
373      oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex));
374      oneDHists_.at(currentChannelIndex)["electronDZ"]->Fill (electrons->at(electronIndex).correctedDZ);
375      oneDHists_.at(currentChannelIndex)["electronAbsDZ"]->Fill (fabs(electrons->at(electronIndex).correctedDZ));
376      oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err);
377      oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err);
378      oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (electrons->at(electronIndex).puChargedHadronIso / electrons->at(electronIndex).pt);
379      oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem);
380      oneDHists_.at(currentChannelIndex)["electronMVATrig"]->Fill (electrons->at(electronIndex).mvaTrigV0);
381      oneDHists_.at(currentChannelIndex)["electronMVANonTrig"]->Fill (electrons->at(electronIndex).mvaNonTrigV0);
610  
611 +        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
612 +        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
613 +        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
614 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
615 +                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
616 +        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
617 +        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
618 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
619 +                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
620 +        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
621 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
622 +                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
623 +        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
624 +        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
625 +        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
626 +        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
627 +        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
628 +        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
629 +        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
630 +        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
631 +        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
632 +        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
633 +      }
634      }
384    oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter);
635  
636 +    //fills histograms with the sizes of collections
637 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
638 +      string currentObject = objectsToPlot.at(currentObjectIndex);
639 +
640 +      string objectToPlot = "";
641 +
642 +      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
643 +      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
644 +      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
645 +      else objectToPlot = currentObject;
646 +      string tempCurrentObject = objectToPlot;
647 +      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
648 +      string histoName = "num" + tempCurrentObject;
649  
387    vector<bool> muonFlags = cumulativeFlags["muons"].back();
388    int muonCounter = 0;
650  
651  
391    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
392      if(!muonFlags.at(muonIndex)) continue;
393      muonCounter++;
652  
653 <      oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt);
654 <      oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta);
655 <      oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex);
656 <      oneDHists_.at(currentChannelIndex)["muonDz"]->Fill (muons->at(muonIndex).correctedDZ);
657 <      oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex));
658 <      oneDHists_.at(currentChannelIndex)["muonDZ"]->Fill (muons->at(muonIndex).correctedDZ);
659 <      oneDHists_.at(currentChannelIndex)["muonAbsDZ"]->Fill (fabs(muons->at(muonIndex).correctedDZ));
660 <      oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err);
661 <      oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err);
662 <      oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (muons->at(muonIndex).puChargedHadronIso / muons->at(muonIndex).pt);
663 <    }
664 <    oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter);
653 >      //set position of primary vertex in event, in order to calculate quantities relative to it
654 >      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
655 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
656 >        int numToPlot = 0;
657 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
658 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
659 >        }
660 >        if(objectToPlot == "primaryvertexs"){
661 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
662 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
663 >        }
664 >        else
665 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
666 >      }
667 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
668 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
669 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
670 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
671 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
672 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
673 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
674 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
675 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
676 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
677 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
678 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
679 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
680 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
681 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
682 >      else if(objectToPlot == "primaryvertexs"){
683 >        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
684 >        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
685 >      }
686  
687 +    }
688  
689  
690  
691  
692    } //end loop over channel
693  
694 <  masterCutFlow_->fillCutFlow();
694 >  masterCutFlow_->fillCutFlow(puScaleFactor);
695 >
696  
697  
698   }
# Line 426 | Line 707 | OSUAnalysis::evaluateComparison (double
707    else if(comparison == "<")  return testValue <  cutValue;
708    else if(comparison == "<=") return testValue <= cutValue;
709    else if(comparison == "==") return testValue == cutValue;
710 +  else if(comparison == "=") return testValue == cutValue;
711    else if(comparison == "!=") return testValue != cutValue;
712    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
713  
# Line 608 | Line 890 | OSUAnalysis::valueLookup (const BNmuon*
890    else if(variable == "ecalIso") value = object->ecalIso;
891    else if(variable == "hcalIso") value = object->hcalIso;
892    else if(variable == "caloIso") value = object->caloIso;
893 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
893 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
894    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
895    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
896    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 746 | Line 1028 | OSUAnalysis::valueLookup (const BNmuon*
1028    else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
1029    else if(variable == "time_ndof") value = object->time_ndof;
1030  
1031 +  //user-defined variables
1032 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1033 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1034 +  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1035 +  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1036 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1037 +  else if(variable == "tightID") {
1038 +    value = object->isGlobalMuon > 0            \
1039 +      && object->isPFMuon > 0                   \
1040 +      && object->normalizedChi2 < 10            \
1041 +      && object->numberOfValidMuonHits > 0      \
1042 +      && object->numberOfMatchedStations > 1    \
1043 +      && fabs(object->correctedD0Vertex) < 0.2  \
1044 +      && fabs(object->correctedDZ) < 0.5        \
1045 +      && object->numberOfValidPixelHits > 0             \
1046 +      && object->numberOfLayersWithMeasurement > 5;
1047 +  }
1048 +  else if(variable == "tightIDdisplaced"){
1049 +    value = object->isGlobalMuon > 0            \
1050 +      && object->normalizedChi2 < 10            \
1051 +      && object->numberOfValidMuonHits > 0      \
1052 +      && object->numberOfMatchedStations > 1    \
1053 +      && object->numberOfValidPixelHits > 0     \
1054 +      && object->numberOfLayersWithMeasurement > 5;
1055 +  }
1056 +
1057 +  else if(variable == "genMatchedId"){
1058 +    int index = getGenMatchedParticleIndex(object);
1059 +    if(index == -1) value = 0;
1060 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1061 +  }
1062 +  else if(variable == "genMatchedMotherId"){
1063 +    int index = getGenMatchedParticleIndex(object);
1064 +    if(index == -1) value = 0;
1065 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1066 +  }
1067 +  else if(variable == "genMatchedGrandmotherId"){
1068 +    int index = getGenMatchedParticleIndex(object);
1069 +    if(index == -1) value = 0;
1070 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1071 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1072 +      if(motherIndex == -1) value = 0;
1073 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1074 +    }
1075 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1076 +  }
1077 +
1078 +
1079 +
1080    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1081  
1082    value = applyFunction(function, value);
# Line 915 | Line 1246 | OSUAnalysis::valueLookup (const BNelectr
1246    else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1247    else if(variable == "passConvVeto") value = object->passConvVeto;
1248  
1249 +  //user-defined variables
1250 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1251 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1252 +  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1253 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1254 +  else if(variable == "correctedD0VertexInEB"){
1255 +    if(fabs(object->eta) < 0.8) value = object->correctedD0Vertex;
1256 +    else value = -999;
1257 +  }
1258 +  else if(variable == "correctedD0VertexOutEB"){
1259 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0Vertex;
1260 +    else value = -999;
1261 +  }
1262 +  else if(variable == "correctedD0VertexEE"){
1263 +    if(object->isEE) value = object->correctedD0Vertex;
1264 +    else value = -999;
1265 +  }
1266 +
1267 +  else if(variable == "correctedD0BeamspotInEB"){
1268 +    if(fabs(object->eta) < 0.8) value = object->correctedD0;
1269 +    else value = -999;
1270 +  }
1271 +  else if(variable == "correctedD0BeamspotOutEB"){
1272 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0;
1273 +    else value = -999;
1274 +  }
1275 +  else if(variable == "correctedD0BeamspotEE"){
1276 +    if(object->isEE) value = object->correctedD0;
1277 +    else value = -999;
1278 +  }
1279 +
1280 +  else if(variable == "correctedD0OriginInEB"){
1281 +    if(fabs(object->eta) < 0.8) value = object->tkD0;
1282 +    else value = -999;
1283 +  }
1284 +  else if(variable == "correctedD0OriginOutEB"){
1285 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->tkD0;
1286 +    else value = -999;
1287 +  }
1288 +  else if(variable == "correctedD0OriginEE"){
1289 +    if(object->isEE) value = object->tkD0;
1290 +    else value = -999;
1291 +  }
1292 +
1293 +  else if(variable == "tightIDdisplaced"){
1294 +    if (object->isEB)
1295 +      {
1296 +        value = fabs(object->delEtaIn) < 0.004 \
1297 +          && fabs (object->delPhiIn) < 0.03 \
1298 +          && object->scSigmaIEtaIEta < 0.01 \
1299 +          && object->hadOverEm < 0.12 \
1300 +          && object->absInvEMinusInvPin < 0.05;
1301 +      }
1302 +    else
1303 +      {
1304 +        value = fabs (object->delEtaIn) < 0.005 \
1305 +          && fabs (object->delPhiIn) < 0.02 \
1306 +          && object->scSigmaIEtaIEta < 0.03 \
1307 +          && object->hadOverEm < 0.10 \
1308 +          && object->absInvEMinusInvPin < 0.05;
1309 +      }
1310 +  }
1311 +
1312 +  else if(variable == "genMatchedId"){
1313 +    int index = getGenMatchedParticleIndex(object);
1314 +    if(index == -1) value = 0;
1315 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1316 +  }
1317 +  else if(variable == "genMatchedMotherId"){
1318 +    int index = getGenMatchedParticleIndex(object);
1319 +    if(index == -1) value = 0;
1320 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1321 +  }
1322 +  else if(variable == "genMatchedGrandmotherId"){
1323 +    int index = getGenMatchedParticleIndex(object);
1324 +    if(index == -1) value = 0;
1325 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1326 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1327 +      if(motherIndex == -1) value = 0;
1328 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1329 +    }
1330 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1331 +  }
1332 +
1333 +
1334  
1335    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1336  
# Line 1047 | Line 1463 | OSUAnalysis::valueLookup (const BNtau* o
1463    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1464  
1465  
1466 +  else if(variable == "genMatchedId"){
1467 +    int index = getGenMatchedParticleIndex(object);
1468 +    if(index == -1) value = 0;
1469 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1470 +  }
1471 +  else if(variable == "genMatchedMotherId"){
1472 +    int index = getGenMatchedParticleIndex(object);
1473 +    if(index == -1) value = 0;
1474 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1475 +  }
1476 +  else if(variable == "genMatchedGrandmotherId"){
1477 +    int index = getGenMatchedParticleIndex(object);
1478 +    if(index == -1) value = 0;
1479 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1480 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1481 +      if(motherIndex == -1) value = 0;
1482 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1483 +    }
1484 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1485 +  }
1486 +
1487 +
1488    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1489  
1490    value = applyFunction(function, value);
# Line 1150 | Line 1588 | OSUAnalysis::valueLookup (const BNtrack*
1588    else if(variable == "isHighPurity") value = object->isHighPurity;
1589  
1590  
1591 +  else if(variable == "genMatchedId"){
1592 +    int index = getGenMatchedParticleIndex(object);
1593 +    if(index == -1) value = 0;
1594 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1595 +  }
1596 +  else if(variable == "genMatchedMotherId"){
1597 +    int index = getGenMatchedParticleIndex(object);
1598 +    if(index == -1) value = 0;
1599 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1600 +  }
1601 +  else if(variable == "genMatchedGrandmotherId"){
1602 +    int index = getGenMatchedParticleIndex(object);
1603 +    if(index == -1) value = 0;
1604 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1605 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1606 +      if(motherIndex == -1) value = 0;
1607 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1608 +    }
1609 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1610 +  }
1611 +
1612 +
1613 +
1614    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1615  
1616    value = applyFunction(function, value);
# Line 1275 | Line 1736 | OSUAnalysis::valueLookup (const BNmcpart
1736    else if(variable == "grandMother11Status") value = object->grandMother11Status;
1737    else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
1738  
1739 +  //user-defined variables
1740 +  else if (variable == "d0"){
1741 +    double vx = object->vx - chosenPrimaryVertex->x,
1742 +      vy = object->vy - chosenPrimaryVertex->y,
1743 +      px = object->px,
1744 +      py = object->py,
1745 +      pt = object->pt;
1746 +    value = (-vx * py + vy * px) / pt;
1747 +  }
1748 +  else if (variable == "dz"){
1749 +    double vx = object->vx - chosenPrimaryVertex->x,
1750 +      vy = object->vy - chosenPrimaryVertex->y,
1751 +      vz = object->vz - chosenPrimaryVertex->z,
1752 +      px = object->px,
1753 +      py = object->py,
1754 +      pz = object->pz,
1755 +      pt = object->pt;
1756 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
1757 +  }
1758 +  else if(variable == "v0"){
1759 +    value = sqrt(object->vx*object->vx + object->vy*object->vy);
1760 +  }
1761 +  else if(variable == "deltaV0"){
1762 +    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
1763 +  }
1764 +  else if (variable == "deltaVx"){
1765 +    value = object->vx - chosenPrimaryVertex->x;
1766 +  }
1767 +  else if (variable == "deltaVy"){
1768 +    value = object->vy - chosenPrimaryVertex->y;
1769 +  }
1770 +  else if (variable == "deltaVz"){
1771 +    value = object->vz - chosenPrimaryVertex->z;
1772 +  }
1773 +
1774 +
1775    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1776  
1777    value = applyFunction(function, value);
# Line 1402 | Line 1899 | OSUAnalysis::valueLookup (const BNphoton
1899    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
1900  
1901  
1902 +  else if(variable == "genMatchedId"){
1903 +    int index = getGenMatchedParticleIndex(object);
1904 +    if(index == -1) value = 0;
1905 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1906 +  }
1907 +  else if(variable == "genMatchedMotherId"){
1908 +    int index = getGenMatchedParticleIndex(object);
1909 +    if(index == -1) value = 0;
1910 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1911 +  }
1912 +  else if(variable == "genMatchedGrandmotherId"){
1913 +    int index = getGenMatchedParticleIndex(object);
1914 +    if(index == -1) value = 0;
1915 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1916 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1917 +      if(motherIndex == -1) value = 0;
1918 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1919 +    }
1920 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1921 +  }
1922 +
1923 +
1924    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1925  
1926    value = applyFunction(function, value);
# Line 1433 | Line 1952 | OSUAnalysis::valueLookup (const BNsuperc
1952  
1953  
1954   double
1955 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
1956 +
1957 +  double value = 0.0;
1958 +
1959 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
1960 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
1961 +  else if(variable == "invMass"){
1962 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1963 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1964 +
1965 +    value = (fourVector1 + fourVector2).M();}
1966 +  else if(variable == "threeDAngle")
1967 +    {
1968 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
1969 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
1970 +      value = (threeVector1.Angle(threeVector2));
1971 +    }
1972 +
1973 +
1974 +
1975 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1976 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1977 +  else if(variable == "d0Sign"){
1978 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1979 +    if(d0Sign < 0) value = -0.5;
1980 +    else if (d0Sign > 0) value = 0.5;
1981 +    else value = -999;
1982 +  }
1983 +  else if(variable == "muon1CorrectedD0Vertex"){
1984 +    value = object1->correctedD0Vertex;
1985 +  }
1986 +  else if(variable == "muon2CorrectedD0Vertex"){
1987 +    value = object2->correctedD0Vertex;
1988 +  }
1989 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1990 +
1991 +
1992 +
1993 +
1994 +
1995 +
1996 +
1997 +
1998 +  value = applyFunction(function, value);
1999 +
2000 +  return value;
2001 + }
2002 +
2003 + double
2004 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2005 +
2006 +  double value = 0.0;
2007 +
2008 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2009 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2010 +  else if(variable == "invMass"){
2011 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2012 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2013 +
2014 +    value = (fourVector1 + fourVector2).M();}
2015 + else if(variable == "threeDAngle")
2016 +    {
2017 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2018 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2019 +      value = (threeVector1.Angle(threeVector2));
2020 +    }
2021 +  
2022 +
2023 +
2024 +
2025 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2026 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2027 +
2028 +  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2029 +
2030 +
2031 +
2032 +  else if(variable == "d0Sign"){
2033 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2034 +    if(d0Sign < 0) value = -0.5;
2035 +    else if (d0Sign > 0) value = 0.5;
2036 +    else value = -999;
2037 +  }
2038 +  else if(variable == "electron1CorrectedD0Vertex"){
2039 +    value = object1->correctedD0Vertex;
2040 +  }
2041 +  else if(variable == "electron2CorrectedD0Vertex"){
2042 +    value = object2->correctedD0Vertex;
2043 +  }
2044 +
2045 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2046 +
2047 +  value = applyFunction(function, value);
2048 +
2049 +  return value;
2050 + }
2051 +
2052 + double
2053 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2054 +
2055 +  double value = 0.0;
2056 +
2057 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2058 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2059 +  else if(variable == "invMass"){
2060 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2061 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2062 +
2063 +    value = (fourVector1 + fourVector2).M();}
2064 + else if(variable == "threeDAngle")
2065 +    {
2066 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2067 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2068 +      value = (threeVector1.Angle(threeVector2));
2069 +    }
2070 +
2071 +
2072 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2073 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2074 +  else if(variable == "d0Sign"){
2075 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2076 +    if(d0Sign < 0) value = -0.5;
2077 +    else if (d0Sign > 0) value = 0.5;
2078 +    else value = -999;
2079 +  }
2080 +  else if(variable == "electronCorrectedD0Vertex"){
2081 +    value = object1->correctedD0Vertex;
2082 +  }
2083 +  else if(variable == "muonCorrectedD0Vertex"){
2084 +    value = object2->correctedD0Vertex;
2085 +  }
2086 +  else if(variable == "electronCorrectedD0"){
2087 +    value = object1->correctedD0;
2088 +  }
2089 +  else if(variable == "muonCorrectedD0"){
2090 +    value = object2->correctedD0;
2091 +  }
2092 +
2093 +
2094 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2095 +
2096 +  value = applyFunction(function, value);
2097 +
2098 +  return value;
2099 + }
2100 +
2101 +
2102 + double
2103   OSUAnalysis::applyFunction(string function, double value){
2104  
2105 <  if(function == "abs") value = abs(value);
2105 >  if(function == "abs") value = fabs(value);
2106 >  else if(function == "fabs") value = fabs(value);
2107 >
2108  
2109 +  else if(function == "") value = value;
2110 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2111  
2112    return value;
2113  
# Line 1449 | Line 2120 | void OSUAnalysis::setObjectFlags(cut &cu
2120  
2121    for (uint object = 0; object != inputCollection->size(); object++){
2122  
2123 +
2124      bool decision = true;//object passes if this cut doesn't cut on that type of object
2125  
1454    if(currentCut.inputCollection == inputType){
2126  
2127 <      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
2127 >    if(currentCut.inputCollection == inputType){
2128  
2129 <      decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
2129 >      vector<bool> subcutDecisions;
2130 >      for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2131 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2132 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2133 >      }
2134 >      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2135 >      else{
2136 >        bool tempDecision = true;
2137 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2138 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2139 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2140 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2141 >            tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2142 >        }
2143 >        decision = tempDecision;
2144 >      }
2145      }
2146 <    individualFlags[inputType].at(currentCutIndex).push_back(decision);
2146 >    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2147  
2148  
2149      //set flags for objects that pass each cut AND all the previous cuts
2150      bool previousCumulativeFlag = true;
2151      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2152 <      if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2152 >      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2153        else{ previousCumulativeFlag = false; break;}
2154      }
2155 <    cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2155 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2156 >
2157 >
2158 >  }
2159 >
2160 > }
2161 >
2162 >
2163 > template <class InputCollection1, class InputCollection2>
2164 > void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2165 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2166 >
2167 >
2168 >  bool sameObjects = false;
2169 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2170 >
2171 >
2172 >  int counter = 0;  
2173 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2174 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2175 >      
2176 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2177 >
2178 >
2179 >      bool decision = true;//object passes if this cut doesn't cut on that type of object
2180 >
2181 >      if(currentCut.inputCollection == inputType){
2182 >
2183 >        vector<bool> subcutDecisions;
2184 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2185 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2186 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2187 >        }
2188 >
2189 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2190 >        else{
2191 >          bool tempDecision = true;
2192 >          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2193 >            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2194 >              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2195 >            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2196 >              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2197 >          }
2198 >          decision = tempDecision;
2199 >        }
2200 >      }
2201 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2202 >      
2203 >      //set flags for objects that pass each cut AND all the previous cuts
2204 >      bool previousCumulativeFlag = true;
2205 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2206 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2207 >        else{ previousCumulativeFlag = false; break;}
2208 >      }
2209 >      //apply flags for the components of the composite object as well
2210 >      bool currentCumulativeFlag = true;
2211 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2212 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2213 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2214 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2215 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2216 >
2217 >      counter++;      
2218 >    }
2219 >    
2220 >  }
2221 >
2222 >
2223 > }
2224 >
2225 >
2226 > template <class InputCollection>
2227 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2228 >
2229 >  for (uint object = 0; object != inputCollection->size(); object++){
2230 >
2231 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2232 >
2233 >    string currentString = parameters.inputVariables.at(0);
2234 >    string inputVariable = "";
2235 >    string function = "";
2236 >    if(currentString.find("(")==std::string::npos){
2237 >      inputVariable = currentString;// variable to cut on                                                                                                                                        
2238 >    }
2239 >    else{
2240 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2241 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2242 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2243 >    }
2244 >
2245 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2246 >    histo->Fill(value,puScaleFactor);
2247 >
2248 >  }
2249 >
2250 > }
2251 >
2252 > template <class InputCollection1, class InputCollection2>
2253 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2254 >
2255 >  bool sameObjects = false;
2256 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2257 >
2258 >  int pairCounter = 0;  
2259 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2260 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2261 >      
2262 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2263 >
2264 >      //only take objects which have passed all cuts and pairs which have passed all cuts
2265 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2266 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2267 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2268 >
2269 >      string currentString = parameters.inputVariables.at(0);
2270 >      string inputVariable = "";
2271 >      string function = "";
2272 >      if(currentString.find("(")==std::string::npos){
2273 >        inputVariable = currentString;// variable to cut on                                                                                                          
2274 >      }
2275 >      else{
2276 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2277 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2278 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2279 >      }
2280 >      
2281 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2282 >      histo->Fill(value,puScaleFactor);
2283 >
2284 >      pairCounter++;      
2285 >    }
2286 >  }
2287 >
2288 > }
2289 >
2290 >
2291 > template <class InputCollection>
2292 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2293 >
2294 >  for (uint object = 0; object != inputCollection->size(); object++){
2295 >
2296 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2297 >
2298 >    string currentString = parameters.inputVariables.at(0);
2299 >    string inputVariable = "";
2300 >    string function = "";
2301 >    if(currentString.find("(")==std::string::npos){
2302 >      inputVariable = currentString;// variable to cut on                                                                                                                                        
2303 >    }
2304 >    else{
2305 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2306 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2307 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2308 >    }
2309 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2310 >
2311 >    currentString = parameters.inputVariables.at(1);
2312 >    inputVariable = "";
2313 >    function = "";
2314 >    if(currentString.find("(")==std::string::npos){
2315 >      inputVariable = currentString;// variable to cut on                                                                                                                                        
2316 >    }
2317 >    else{
2318 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2319 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2320 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2321 >    }
2322 >
2323 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2324 >
2325 >    histo->Fill(valueX,valueY,puScaleFactor);
2326 >
2327 >  }
2328 >
2329 > }
2330 >
2331 > template <class InputCollection1, class InputCollection2>
2332 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2333 >
2334 >  bool sameObjects = false;
2335 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2336 >
2337 >  int pairCounter = 0;  
2338 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2339 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2340 >      
2341 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2342 >
2343 >      //only take objects which have passed all cuts and pairs which have passed all cuts
2344 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2345 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2346 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2347 >
2348 >      string currentString = parameters.inputVariables.at(0);
2349 >      string inputVariable = "";
2350 >      string function = "";
2351 >      if(currentString.find("(")==std::string::npos){
2352 >        inputVariable = currentString;// variable to cut on                                                                                                          
2353 >      }
2354 >      else{
2355 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2356 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2357 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2358 >      }
2359 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2360 >
2361 >      currentString = parameters.inputVariables.at(1);
2362 >      inputVariable = "";
2363 >      function = "";
2364 >      if(currentString.find("(")==std::string::npos){
2365 >        inputVariable = currentString;// variable to cut on                                                                                                          
2366 >      }
2367 >      else{
2368 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2369 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2370 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2371 >      }
2372 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2373 >
2374 >
2375 >      histo->Fill(valueX,valueY,puScaleFactor);
2376 >
2377 >      pairCounter++;      
2378 >    }
2379 >  }
2380 >
2381 > }
2382 >
2383 >
2384 > template <class InputObject>
2385 > int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
2386 >
2387 >  int bestMatchIndex = -1;
2388 >  double bestMatchDeltaR = 999;
2389 >
2390 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2391 >
2392 >    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2393 >    if(currentDeltaR > 0.05) continue;
2394 >
2395 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2396 >      bestMatchIndex = mcparticle - mcparticles->begin();
2397 >      bestMatchDeltaR = currentDeltaR;
2398 >    }
2399  
2400    }
2401  
2402 +  return bestMatchIndex;
2403 +
2404   }
2405  
2406  
2407 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
2408 +
2409 +  int bestMatchIndex = -1;
2410 +  double bestMatchDeltaR = 999;
2411 +
2412 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2413 +
2414 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
2415 +
2416 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
2417 +    if(currentDeltaR > 0.05) continue;
2418 +
2419 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2420 +      bestMatchIndex = mcparticle - mcparticles->begin();
2421 +      bestMatchDeltaR = currentDeltaR;
2422 +    }
2423  
2424 +  }
2425 +
2426 +  return bestMatchIndex;
2427 + }
2428 +
2429 +
2430 + // bin      particle type
2431 + // ---      -------------
2432 + //  0        unmatched
2433 + //  1        u
2434 + //  2        d
2435 + //  3        s
2436 + //  4        c
2437 + //  5        b
2438 + //  6        t
2439 + //  7        e
2440 + //  8        mu
2441 + //  9        tau
2442 + // 10        nu
2443 + // 11        g
2444 + // 12        gamma
2445 + // 13        Z
2446 + // 14        W
2447 + // 15        light meson
2448 + // 16        K meson
2449 + // 17        D meson
2450 + // 18        B meson
2451 + // 19        light baryon
2452 + // 20        strange baryon
2453 + // 21        charm baryon
2454 + // 22        bottom baryon
2455 + // 23        other
2456 +
2457 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
2458 +
2459 +  int binValue = -999;
2460 +  int absPdgId = fabs(pdgId);  
2461 +  if(pdgId == -1) binValue = 0;
2462 +  else if(absPdgId <= 6 ) binValue = absPdgId;
2463 +  else if(absPdgId == 11 ) binValue = 7;
2464 +  else if(absPdgId == 13 ) binValue = 8;
2465 +  else if(absPdgId == 15 ) binValue = 9;
2466 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
2467 +  else if(absPdgId == 21 ) binValue = 11;
2468 +  else if(absPdgId == 22 ) binValue = 12;
2469 +  else if(absPdgId == 23 ) binValue = 13;
2470 +  else if(absPdgId == 24 ) binValue = 14;
2471 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
2472 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
2473 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
2474 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
2475 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
2476 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
2477 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
2478 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
2479 +
2480 +  else binValue = 23;
2481 +
2482 +  return binValue;
2483 +
2484 + }
2485  
2486  
2487   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines