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.21 by qpython, Wed Feb 27 14:16:26 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 +  allNecessaryObjects.push_back("primaryvertexs");
41 +  //always make the plot of number of primary verticex (to check pile-up reweighting)
42 +  objectsToPlot.push_back("primaryvertexs");
43 +
44 +  //always get the MC particles to do GEN-matching
45 +  allNecessaryObjects.push_back("mcparticles");
46 +
47 +  //always get the event collection to do pile-up reweighting
48 +  allNecessaryObjects.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 +      objectsToPlot.push_back(tempInputCollection);
57 +      allNecessaryObjects.push_back(tempInputCollection);
58 +    }
59 +    else{//pair of objects, need to add them both to the things to allNecessaryObjects
60 +      int dashIndex = tempInputCollection.find("-");
61 +      int spaceIndex = tempInputCollection.find(" ");
62 +      int secondWordLength = spaceIndex - dashIndex;
63 +      allNecessaryObjects.push_back(tempInputCollection);
64 +      allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
65 +      allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
66 +      objectsToPlot.push_back(tempInputCollection);
67 +      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
68 +      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
69 +      }
70 +
71 +    vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
72 +    
73 +    for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
74 +
75 +      histogram tempHistogram;
76 +      tempHistogram.inputCollection = tempInputCollection;
77 +      tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
78 +      tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
79 +      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
80 +      tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
81 +      
82 +      histograms.push_back(tempHistogram);
83 +
84 +    }
85 +  }
86 +  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
87 +  sort( objectsToPlot.begin(), objectsToPlot.end() );
88 +  objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
89 +
90 +
91 +
92  
93    channel tempChannel;
94    //loop over all channels (event selections)
# Line 50 | Line 111 | OSUAnalysis::OSUAnalysis (const edm::Par
111      }
112  
113  
114 +
115 +
116      //create cutFlow for this channel
117      cutFlows_.push_back (new CutFlow (fs_, channelName));
118  
119      //book a directory in the output file with the name of the channel
120      TFileDirectory subDir = fs_->mkdir( channelName );
121      directories.push_back(subDir);
59    std::map<std::string, TH1D*> histoMap;
60    oneDHists_.push_back(histoMap);
122  
123 <    //gen histograms
124 <    oneDHists_.at(currentChannel)["genD0"] = directories.at(currentChannel).make<TH1D> ("genD0",channelLabel+" channel: Gen d_{0}; d_{0} [cm] ", 1000, -1, 1);
125 <    oneDHists_.at(currentChannel)["genAbsD0"] = directories.at(currentChannel).make<TH1D> ("genAbsD0",channelLabel+" channel: Gen d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
126 <    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);
123 >    std::map<std::string, TH1D*> oneDhistoMap;
124 >    oneDHists_.push_back(oneDhistoMap);
125 >    std::map<std::string, TH2D*> twoDhistoMap;
126 >    twoDHists_.push_back(twoDhistoMap);
127  
128  
129 +    //book all histograms included in the configuration
130 +    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
131 +      histogram currentHistogram = histograms.at(currentHistogramIndex);
132 +      int numBinsElements = currentHistogram.bins.size();
133 +      int numInputVariables = currentHistogram.inputVariables.size();
134 +
135 +      if(numBinsElements != 3 && numBinsElements !=6) {
136 +        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
137 +        exit(0);
138 +      }
139 +      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
140 +        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
141 +        exit(0);
142 +      }
143 +      else if(numBinsElements == 3){
144 +        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));
145 +      }
146 +      else if(numBinsElements == 6){
147 +        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));
148  
149 <    //get list of cuts for this channel
103 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
149 >      }
150  
151 <    vector<string> tempInputCollections;
151 >
152 >    }
153 >    //book a histogram for the number of each object type to be plotted
154 >    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
155 >      string currentObject = objectsToPlot.at(currentObjectIndex);
156 >      int maxNum = 10;
157 >      if(currentObject == "mcparticles") maxNum = 50;
158 >      else if(currentObject == "primaryvertexs") maxNum = 50;
159 >      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
160 >      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
161 >      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
162 >
163 >      currentObject.at(0) = toupper(currentObject.at(0));
164 >      string histoName = "num" + currentObject;
165 >
166 >      if(histoName == "numPrimaryvertexs"){
167 >        string newHistoName = histoName + "BeforePileupCorrection";
168 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
169 >        newHistoName = histoName + "AfterPileupCorrection";
170 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
171 >      }
172 >      else
173 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
174 >    }
175  
176  
177 +    //get list of cuts for this channel
178 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
179 +
180      //loop over and parse all cuts
181      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
110
182        cut tempCut;
183 <     //store input collection for cut
184 <      string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
185 <      tempCut.inputCollection = inputCollection;
183 >      //store input collection for cut
184 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
185 >      tempCut.inputCollection = tempInputCollection;
186 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
187 >        allNecessaryObjects.push_back(tempInputCollection);
188 >      }
189 >      else{//pair of objects, need to add them both to the things to allNecessaryObjects
190 >        int dashIndex = tempInputCollection.find("-");
191 >        int spaceIndex = tempInputCollection.find(" ");
192 >        int secondWordLength = spaceIndex - dashIndex;
193 >        allNecessaryObjects.push_back(tempInputCollection);
194 >        allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
195 >        allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
196 >
197 >      }
198 >
199  
116      tempInputCollections.push_back(inputCollection);
117      allNecessaryObjects.push_back(inputCollection);
200  
201        //split cut string into parts and store them
202        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
203        std::vector<string> cutStringVector = splitString(cutString);
204 <      tempCut.variable = cutStringVector.at(0);// variable to cut on
205 <      tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
206 <      tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
204 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
205 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
206 >        exit(0);
207 >      }
208 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
209 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
210 >        int indexOffset = 4 * subcutIndex;
211 >        string currentVariableString = cutStringVector.at(indexOffset);
212 >        if(currentVariableString.find("(")==std::string::npos){
213 >          tempCut.functions.push_back("");//no function was specified
214 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
215 >        }
216 >        else{
217 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
218 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
219 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
220 >        }
221 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
222 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
223 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
224 >      }
225  
226        //get number of objects required to pass cut for event to pass
227        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
228        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
229 +      if(numberRequiredVector.size()!=2){
230 +        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
231 +        exit(0);
232 +      }
233  
130      // determine number required if comparison contains "="
234        int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
132      if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
133      else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
134
235        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
236        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
237  
238 <      if(cuts_.at(currentCut).exists("function")){
139 <        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
140 <      }
141 <      else tempCut.function = "";
238 >
239        string tempCutName;
240        if(cuts_.at(currentCut).exists("alias")){
241          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
# Line 146 | Line 243 | OSUAnalysis::OSUAnalysis (const edm::Par
243        else{
244          //construct string for cutflow table
245          bool plural = numberRequiredInt != 1;
246 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
246 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
247          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
248          tempCutName = cutName;
249        }
# Line 156 | Line 253 | OSUAnalysis::OSUAnalysis (const edm::Par
253        tempChannel.cuts.push_back(tempCut);
254  
255  
159    }//end loop over cuts
256  
257 <    //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;
257 >    }//end loop over cuts
258  
259      channels.push_back(tempChannel);
260      tempChannel.cuts.clear();
261  
262    }//end loop over channels
263  
264 +
265    //make unique vector of objects we need to cut on (so we make sure to get them from the event)
266    sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
267    allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
# Line 247 | Line 341 | OSUAnalysis::analyze (const edm::Event &
341      event.getByLabel (superclusters_, superclusters);
342  
343  
344 +  //get pile-up event weight
345 +  double puScaleFactor = 0;
346 +  if(datasetType_ != "data")
347 +    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
348 +  else
349 +    puScaleFactor = 1.00;
350 +
351 +
352    //loop over all channels
353  
354    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
# Line 267 | Line 369 | OSUAnalysis::analyze (const edm::Event &
369        cut currentCut = currentChannel.cuts.at(currentCutIndex);
370  
371        for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
270
372          string currentObject = allNecessaryObjects.at(currentObjectIndex);
373 +
374          individualFlags[currentObject].push_back (vector<bool> ());
375          cumulativeFlags[currentObject].push_back (vector<bool> ());
376  
377 +
378          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
379          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
380          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 286 | Line 389 | OSUAnalysis::analyze (const edm::Event &
389          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
390          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
391  
392 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
393 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
394 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
395  
396        }
397  
# Line 295 | Line 401 | OSUAnalysis::analyze (const edm::Event &
401  
402  
403  
298
404      //use cumulative flags to apply cuts at event level
405  
406      bool eventPassedAllCuts = true;
# Line 310 | Line 415 | OSUAnalysis::analyze (const edm::Event &
415        cut currentCut = currentChannel.cuts.at(currentCutIndex);
416        int numberPassing = 0;
417  
418 <      for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
419 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
420 <
418 >      for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
419 >          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
420 >      }
421  
422        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
423        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 321 | Line 426 | OSUAnalysis::analyze (const edm::Event &
426  
427      }
428  
429 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();
429 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
430  
431  
432  
433      if(!eventPassedAllCuts)continue;
434  
435  
331    TVector3 vertexPosition;
332    vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back();
436  
437 +
438 +    //set position of primary vertex in event, in order to calculate quantities relative to it
439 +    primaryVertex_ = 0;
440 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
441      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
442        if(!vertexFlags.at(vertexIndex)) continue;
443 <
337 <      vertexPosition.SetXYZ (primaryvertexs->at(vertexIndex).x,primaryvertexs->at(vertexIndex).y,primaryvertexs->at(vertexIndex).z);
443 >      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
444        break;
445      }
446  
341    vector<bool> mcparticleFlags = cumulativeFlags["mcparticles"].back();
342
343    for (uint mcparticleIndex = 0; mcparticleIndex != mcparticleFlags.size(); mcparticleIndex++){
344      if(!mcparticleFlags.at(mcparticleIndex)) continue;
447  
448 <      double vx = mcparticles->at(mcparticleIndex).vx - vertexPosition.X (),
449 <             vy = mcparticles->at(mcparticleIndex).vy - vertexPosition.Y (),
450 <             vz = mcparticles->at(mcparticleIndex).vz - vertexPosition.Z (),
451 <             px = mcparticles->at(mcparticleIndex).px,
452 <             py = mcparticles->at(mcparticleIndex).py,
453 <             pt = mcparticles->at(mcparticleIndex).pt,
454 <             d0;
455 <
456 <      d0 = (-vx * py + vy * px) / pt;
457 <      oneDHists_.at(currentChannelIndex)["genD0"]->Fill (d0);
458 <      oneDHists_.at(currentChannelIndex)["genAbsD0"]->Fill (fabs (d0));
459 <      oneDHists_.at(currentChannelIndex)["genDZ"]->Fill (vz);
460 <      oneDHists_.at(currentChannelIndex)["genAbsDZ"]->Fill (fabs (vz));
461 <    }
462 <
463 <    vector<bool> electronFlags = cumulativeFlags["electrons"].back();
464 <    int electronCounter = 0;
465 <
466 <    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
467 <      if(!electronFlags.at(electronIndex)) continue;
468 <
469 <
470 <      electronCounter++;
471 <      oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt);
472 <      oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta);
473 <      oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex);
474 <      oneDHists_.at(currentChannelIndex)["electronDz"]->Fill (electrons->at(electronIndex).correctedDZ);
475 <      oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex));
476 <      oneDHists_.at(currentChannelIndex)["electronDZ"]->Fill (electrons->at(electronIndex).correctedDZ);
477 <      oneDHists_.at(currentChannelIndex)["electronAbsDZ"]->Fill (fabs(electrons->at(electronIndex).correctedDZ));
478 <      oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err);
479 <      oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err);
480 <      oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (electrons->at(electronIndex).puChargedHadronIso / electrons->at(electronIndex).pt);
481 <      oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem);
482 <      oneDHists_.at(currentChannelIndex)["electronMVATrig"]->Fill (electrons->at(electronIndex).mvaTrigV0);
483 <      oneDHists_.at(currentChannelIndex)["electronMVANonTrig"]->Fill (electrons->at(electronIndex).mvaNonTrigV0);
484 <
485 <    }
486 <    oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter);
487 <
488 <
489 <    vector<bool> muonFlags = cumulativeFlags["muons"].back();
490 <    int muonCounter = 0;
491 <
492 <
493 <    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
494 <      if(!muonFlags.at(muonIndex)) continue;
495 <      muonCounter++;
496 <
497 <      oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt);
498 <      oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta);
499 <      oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex);
500 <      oneDHists_.at(currentChannelIndex)["muonDz"]->Fill (muons->at(muonIndex).correctedDZ);
501 <      oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex));
502 <      oneDHists_.at(currentChannelIndex)["muonDZ"]->Fill (muons->at(muonIndex).correctedDZ);
503 <      oneDHists_.at(currentChannelIndex)["muonAbsDZ"]->Fill (fabs(muons->at(muonIndex).correctedDZ));
402 <      oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err);
403 <      oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err);
404 <      oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (muons->at(muonIndex).puChargedHadronIso / muons->at(muonIndex).pt);
448 >    //filling histograms
449 >    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
450 >      histogram currentHistogram = histograms.at(histogramIndex);
451 >
452 >      if(currentHistogram.inputVariables.size() == 1){
453 >        TH1D* histo;
454 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
455 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
456 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
457 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
458 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
459 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
460 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
461 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
462 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
463 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
464 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
465 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
466 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
467 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
468 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
469 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
470 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
471 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
472 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
473 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
474 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
475 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
476 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
477 >      }
478 >      else if(currentHistogram.inputVariables.size() == 2){
479 >        TH2D* histo;
480 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
481 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
482 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
483 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
484 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
485 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
486 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
487 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
488 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
489 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
490 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
491 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
492 >                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
493 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
494 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
495 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
496 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
497 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
498 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
499 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
500 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
501 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
502 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
503 >      }
504      }
406    oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter);
407
408
505  
506  
507 +    //fills histograms with the sizes of collections
508 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
509 +      string currentObject = objectsToPlot.at(currentObjectIndex);
510 +
511 +      if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
512 +      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
513 +      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
514 +      string tempCurrentObject = currentObject;
515 +      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
516 +      string histoName = "num" + tempCurrentObject;
517 +
518 +
519 +      if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
520 +      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
521 +      else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
522 +      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
523 +      else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
524 +      else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
525 +      else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
526 +      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
527 +      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
528 +      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
529 +      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
530 +      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
531 +      else if(currentObject == "primaryvertexs"){
532 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
533 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
534 +      }
535 +      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
536 +      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
537 +      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
538  
539 +    }
540    } //end loop over channel
541  
542 <  masterCutFlow_->fillCutFlow();
542 >  masterCutFlow_->fillCutFlow(puScaleFactor);
543 >
544  
545  
546   }
# Line 426 | Line 555 | OSUAnalysis::evaluateComparison (double
555    else if(comparison == "<")  return testValue <  cutValue;
556    else if(comparison == "<=") return testValue <= cutValue;
557    else if(comparison == "==") return testValue == cutValue;
558 +  else if(comparison == "=") return testValue == cutValue;
559    else if(comparison == "!=") return testValue != cutValue;
560    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
561  
# Line 746 | Line 876 | OSUAnalysis::valueLookup (const BNmuon*
876    else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
877    else if(variable == "time_ndof") value = object->time_ndof;
878  
879 +  //user-defined variables
880 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
881 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
882 +  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
883 +  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
884 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
885 +  else if(variable == "tightID") {
886 +    value = object->isGlobalMuon > 0            \
887 +      && object->isPFMuon > 0                   \
888 +      && object->normalizedChi2 < 10            \
889 +      && object->numberOfValidMuonHits > 0      \
890 +      && object->numberOfMatchedStations > 1    \
891 +      && fabs(object->correctedD0Vertex) < 0.2  \
892 +      && fabs(object->correctedDZ) < 0.5        \
893 +      && object->numberOfValidPixelHits > 0             \
894 +      && object->numberOfLayersWithMeasurement > 5;
895 +  }
896 +  else if(variable == "tightIDdisplaced"){
897 +    value = object->isGlobalMuon > 0            \
898 +      && object->normalizedChi2 < 10            \
899 +      && object->numberOfValidMuonHits > 0      \
900 +      && object->numberOfMatchedStations > 1    \
901 +      && object->numberOfValidPixelHits > 0     \
902 +      && object->numberOfLayersWithMeasurement > 5;
903 +  }
904 +
905 + //   else if(variable == "genMatchedID"){
906 + //     value = getGenMatchedParticle(object)->id;
907 + //   }
908 + //   else if(variable == "genMatchedMotherID"){
909 + //     value = getGenMatchedParticle(object)->motherId;
910 + //   }
911 + //   else if(variable == "genMatchedGrandmotherID"){
912 + //     value = getGenMatchedParticle(object)->grandMotherId;
913 + //   }
914 +
915 +
916 +
917    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
918  
919    value = applyFunction(function, value);
# Line 915 | Line 1083 | OSUAnalysis::valueLookup (const BNelectr
1083    else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1084    else if(variable == "passConvVeto") value = object->passConvVeto;
1085  
1086 +  //user-defined variables
1087 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1088 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1089 +  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1090 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1091 +  else if(variable == "correctedD0VertexInEB"){
1092 +    if(fabs(object->eta) < 0.8) value = object->correctedD0Vertex;
1093 +    else value = -999;
1094 +  }
1095 +  else if(variable == "correctedD0VertexOutEB"){
1096 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0Vertex;
1097 +    else value = -999;
1098 +  }
1099 +  else if(variable == "correctedD0VertexEE"){
1100 +    if(object->isEE) value = object->correctedD0Vertex;
1101 +    else value = -999;
1102 +  }
1103 +
1104 +  else if(variable == "correctedD0BeamspotInEB"){
1105 +    if(fabs(object->eta) < 0.8) value = object->correctedD0;
1106 +    else value = -999;
1107 +  }
1108 +  else if(variable == "correctedD0BeamspotOutEB"){
1109 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0;
1110 +    else value = -999;
1111 +  }
1112 +  else if(variable == "correctedD0BeamspotEE"){
1113 +    if(object->isEE) value = object->correctedD0;
1114 +    else value = -999;
1115 +  }
1116 +
1117 +  else if(variable == "correctedD0OriginInEB"){
1118 +    if(fabs(object->eta) < 0.8) value = object->tkD0;
1119 +    else value = -999;
1120 +  }
1121 +  else if(variable == "correctedD0OriginOutEB"){
1122 +    if(object->isEB && fabs(object->eta) > 0.8) value = object->tkD0;
1123 +    else value = -999;
1124 +  }
1125 +  else if(variable == "correctedD0OriginEE"){
1126 +    if(object->isEE) value = object->tkD0;
1127 +    else value = -999;
1128 +  }
1129 +
1130 +  else if(variable == "tightIDdisplaced"){
1131 +    if (object->isEB)
1132 +      {
1133 +        value = fabs(object->delEtaIn) < 0.004 \
1134 +          && fabs (object->delPhiIn) < 0.03 \
1135 +          && object->scSigmaIEtaIEta < 0.01 \
1136 +          && object->hadOverEm < 0.12 \
1137 +          && object->absInvEMinusInvPin < 0.05;
1138 +      }
1139 +    else
1140 +      {
1141 +        value = fabs (object->delEtaIn) < 0.005 \
1142 +          && fabs (object->delPhiIn) < 0.02 \
1143 +          && object->scSigmaIEtaIEta < 0.03 \
1144 +          && object->hadOverEm < 0.10 \
1145 +          && object->absInvEMinusInvPin < 0.05;
1146 +      }
1147 +  }
1148  
1149    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1150  
# Line 1275 | Line 1505 | OSUAnalysis::valueLookup (const BNmcpart
1505    else if(variable == "grandMother11Status") value = object->grandMother11Status;
1506    else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
1507  
1508 +  //user-defined variables
1509 +  else if (variable == "d0"){
1510 +    double vx = object->vx - primaryVertex_->x,
1511 +      vy = object->vy - primaryVertex_->y,
1512 +      px = object->px,
1513 +      py = object->py,
1514 +      pt = object->pt;
1515 +    value = (-vx * py + vy * px) / pt;
1516 +  }
1517 +  else if (variable == "dz"){
1518 +    double vx = object->vx - primaryVertex_->x,
1519 +      vy = object->vy - primaryVertex_->y,
1520 +      vz = object->vz - primaryVertex_->z,
1521 +      px = object->px,
1522 +      py = object->py,
1523 +      pz = object->pz,
1524 +      pt = object->pt;
1525 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
1526 +  }
1527 +  else if(variable == "v0"){
1528 +    value = sqrt(object->vx*object->vx + object->vy*object->vy);
1529 +  }
1530 +  else if(variable == "deltaV0"){
1531 +    value = sqrt((object->vx-primaryVertex_->x)*(object->vx-primaryVertex_->x) + (object->vy-primaryVertex_->y)*(object->vy-primaryVertex_->y));
1532 +  }
1533 +  else if (variable == "deltaVx"){
1534 +    value = object->vx - primaryVertex_->x;
1535 +  }
1536 +  else if (variable == "deltaVy"){
1537 +    value = object->vy - primaryVertex_->y;
1538 +  }
1539 +  else if (variable == "deltaVz"){
1540 +    value = object->vz - primaryVertex_->z;
1541 +  }
1542 +
1543 +
1544    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1545  
1546    value = applyFunction(function, value);
# Line 1433 | Line 1699 | OSUAnalysis::valueLookup (const BNsuperc
1699  
1700  
1701   double
1702 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
1703 +
1704 +  double value = 0.0;
1705 +
1706 +  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1707 +  else if(variable == "invMass"){
1708 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1709 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1710 +
1711 +    value = (fourVector1 + fourVector2).M();}
1712 +  else if(variable == "threeDAngle")
1713 +    {
1714 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
1715 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
1716 +      value = (threeVector1.Angle(threeVector2));
1717 +    }
1718 +
1719 +
1720 +
1721 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1722 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1723 +  else if(variable == "d0Sign"){
1724 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1725 +    if(d0Sign < 0) value = -0.5;
1726 +    else if (d0Sign > 0) value = 0.5;
1727 +    else value = -999;
1728 +  }
1729 +  else if(variable == "muon1CorrectedD0Vertex"){
1730 +    value = object1->correctedD0Vertex;
1731 +  }
1732 +  else if(variable == "muon2CorrectedD0Vertex"){
1733 +    value = object2->correctedD0Vertex;
1734 +  }
1735 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1736 +
1737 +
1738 +
1739 +
1740 +
1741 +
1742 +
1743 +
1744 +  value = applyFunction(function, value);
1745 +
1746 +  return value;
1747 + }
1748 +
1749 + double
1750 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
1751 +
1752 +  double value = 0.0;
1753 +
1754 +  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1755 +  else if(variable == "invMass"){
1756 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1757 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1758 +
1759 +    value = (fourVector1 + fourVector2).M();}
1760 + else if(variable == "threeDAngle")
1761 +    {
1762 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
1763 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
1764 +      value = (threeVector1.Angle(threeVector2));
1765 +    }
1766 +  
1767 +
1768 +
1769 +
1770 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1771 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1772 +
1773 +
1774 +
1775 +
1776 +
1777 +  else if(variable == "d0Sign"){
1778 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1779 +    if(d0Sign < 0) value = -0.5;
1780 +    else if (d0Sign > 0) value = 0.5;
1781 +    else value = -999;
1782 +  }
1783 +  else if(variable == "electron1CorrectedD0Vertex"){
1784 +    value = object1->correctedD0Vertex;
1785 +  }
1786 +  else if(variable == "electron2CorrectedD0Vertex"){
1787 +    value = object2->correctedD0Vertex;
1788 +  }
1789 +
1790 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1791 +
1792 +  value = applyFunction(function, value);
1793 +
1794 +  return value;
1795 + }
1796 +
1797 + double
1798 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
1799 +
1800 +  double value = 0.0;
1801 +
1802 +  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1803 +  else if(variable == "invMass"){
1804 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1805 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1806 +
1807 +    value = (fourVector1 + fourVector2).M();}
1808 + else if(variable == "threeDAngle")
1809 +    {
1810 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
1811 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
1812 +      value = (threeVector1.Angle(threeVector2));
1813 +    }
1814 +  
1815 +
1816 +
1817 +
1818 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1819 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1820 +  else if(variable == "d0Sign"){
1821 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1822 +    if(d0Sign < 0) value = -0.5;
1823 +    else if (d0Sign > 0) value = 0.5;
1824 +    else value = -999;
1825 +  }
1826 +  else if(variable == "electronCorrectedD0Vertex"){
1827 +    value = object1->correctedD0Vertex;
1828 +  }
1829 +  else if(variable == "muonCorrectedD0Vertex"){
1830 +    value = object2->correctedD0Vertex;
1831 +  }
1832 +
1833 +
1834 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1835 +
1836 +  value = applyFunction(function, value);
1837 +
1838 +  return value;
1839 + }
1840 +
1841 +
1842 + double
1843   OSUAnalysis::applyFunction(string function, double value){
1844  
1845 <  if(function == "abs") value = abs(value);
1845 >  if(function == "abs") value = fabs(value);
1846 >  else if(function == "fabs") value = fabs(value);
1847 >
1848  
1849 +  else if(function == "") value = value;
1850 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
1851  
1852    return value;
1853  
# Line 1446 | Line 1857 | OSUAnalysis::applyFunction(string functi
1857   template <class InputCollection>
1858   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
1859  
1449
1860    for (uint object = 0; object != inputCollection->size(); object++){
1861  
1862      bool decision = true;//object passes if this cut doesn't cut on that type of object
1863  
1864      if(currentCut.inputCollection == inputType){
1865  
1866 <      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
1867 <
1868 <      decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
1866 >      vector<bool> subcutDecisions;
1867 >      for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
1868 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
1869 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
1870 >      }
1871 >      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
1872 >      else{
1873 >        bool tempDecision = true;
1874 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
1875 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
1876 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
1877 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
1878 >            tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
1879 >        }
1880 >        decision = tempDecision;
1881 >      }
1882      }
1883 <    individualFlags[inputType].at(currentCutIndex).push_back(decision);
1461 <
1883 >    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
1884  
1885      //set flags for objects that pass each cut AND all the previous cuts
1886      bool previousCumulativeFlag = true;
1887      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
1888 <      if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
1888 >      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
1889        else{ previousCumulativeFlag = false; break;}
1890      }
1891 <    cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1891 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1892 >
1893 >  }
1894 >
1895 > }
1896 >
1897 >
1898 > template <class InputCollection1, class InputCollection2>
1899 > void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
1900 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
1901 >
1902 >
1903 >  bool sameObjects = false;
1904 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
1905 >
1906 >  int counter = 0;  
1907 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
1908 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
1909 >      
1910 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
1911 >
1912 >
1913 >      bool decision = true;//object passes if this cut doesn't cut on that type of object
1914 >
1915 >      if(currentCut.inputCollection == inputType){
1916 >
1917 >        vector<bool> subcutDecisions;
1918 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
1919 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
1920 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
1921 >        }
1922 >
1923 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
1924 >        else{
1925 >          bool tempDecision = true;
1926 >          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
1927 >            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
1928 >              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
1929 >            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
1930 >              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
1931 >          }
1932 >          decision = tempDecision;
1933 >        }
1934 >      }
1935 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
1936 >      
1937 >      //set flags for objects that pass each cut AND all the previous cuts
1938 >      bool previousCumulativeFlag = true;
1939 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
1940 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
1941 >        else{ previousCumulativeFlag = false; break;}
1942 >      }
1943 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1944 >
1945 >      counter++;      
1946 >    }
1947 >    
1948 >  }
1949 >
1950 >
1951 > }
1952 >
1953 >
1954 > template <class InputCollection>
1955 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
1956 >
1957 >  for (uint object = 0; object != inputCollection->size(); object++){
1958 >
1959 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
1960 >
1961 >    string currentString = parameters.inputVariables.at(0);
1962 >    string inputVariable = "";
1963 >    string function = "";
1964 >    if(currentString.find("(")==std::string::npos){
1965 >      inputVariable = currentString;// variable to cut on                                                                                                                                        
1966 >    }
1967 >    else{
1968 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
1969 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
1970 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
1971 >    }
1972 >
1973 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
1974 >    histo->Fill(value,puScaleFactor);
1975 >
1976 >  }
1977 >
1978 > }
1979 >
1980 > template <class InputCollection1, class InputCollection2>
1981 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
1982 >
1983 >  bool sameObjects = false;
1984 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
1985 >
1986 >  int counter = 0;  
1987 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
1988 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
1989 >      
1990 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
1991 >
1992 >      //only take objects which have passed all cuts and pairs which have passed all cuts
1993 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
1994 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
1995 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
1996 >
1997 >      string currentString = parameters.inputVariables.at(0);
1998 >      string inputVariable = "";
1999 >      string function = "";
2000 >      if(currentString.find("(")==std::string::npos){
2001 >        inputVariable = currentString;// variable to cut on                                                                                                          
2002 >      }
2003 >      else{
2004 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2005 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2006 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2007 >      }
2008 >      
2009 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2010 >      histo->Fill(value,puScaleFactor);
2011 >
2012 >      counter++;      
2013 >    }
2014 >  }
2015 >
2016 > }
2017 >
2018  
2019 + template <class InputCollection>
2020 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2021 +
2022 +  for (uint object = 0; object != inputCollection->size(); object++){
2023 +
2024 +    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2025 +
2026 +    string currentString = parameters.inputVariables.at(0);
2027 +    string inputVariable = "";
2028 +    string function = "";
2029 +    if(currentString.find("(")==std::string::npos){
2030 +      inputVariable = currentString;// variable to cut on                                                                                                                                        
2031 +    }
2032 +    else{
2033 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2034 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2035 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2036 +    }
2037 +    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2038 +
2039 +    currentString = parameters.inputVariables.at(1);
2040 +    inputVariable = "";
2041 +    function = "";
2042 +    if(currentString.find("(")==std::string::npos){
2043 +      inputVariable = currentString;// variable to cut on                                                                                                                                        
2044 +    }
2045 +    else{
2046 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2047 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2048 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2049 +    }
2050 +
2051 +    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2052 +
2053 +    histo->Fill(valueX,valueY,puScaleFactor);
2054 +
2055 +  }
2056 +
2057 + }
2058 +
2059 + template <class InputCollection1, class InputCollection2>
2060 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2061 +
2062 +  bool sameObjects = false;
2063 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2064 +
2065 +  int counter = 0;  
2066 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2067 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2068 +      
2069 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2070 +
2071 +      //only take objects which have passed all cuts and pairs which have passed all cuts
2072 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2073 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2074 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2075 +
2076 +      string currentString = parameters.inputVariables.at(0);
2077 +      string inputVariable = "";
2078 +      string function = "";
2079 +      if(currentString.find("(")==std::string::npos){
2080 +        inputVariable = currentString;// variable to cut on                                                                                                          
2081 +      }
2082 +      else{
2083 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2084 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2085 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2086 +      }
2087 +      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2088 +
2089 +      currentString = parameters.inputVariables.at(1);
2090 +      inputVariable = "";
2091 +      function = "";
2092 +      if(currentString.find("(")==std::string::npos){
2093 +        inputVariable = currentString;// variable to cut on                                                                                                          
2094 +      }
2095 +      else{
2096 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2097 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2098 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2099 +      }
2100 +      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2101 +
2102 +
2103 +      histo->Fill(valueX,valueY,puScaleFactor);
2104 +
2105 +      counter++;      
2106 +    }
2107    }
2108  
2109   }
2110  
2111  
2112 + // template <class InputObject>
2113 + // BNmcparticle* getGenMatchedParticle(InputObject object){
2114  
2115 + //   BNmcparticle bestMatch;
2116 + //   std::cout << bestMatch.energy() << std:endl;
2117 + //   for(BNmcparticleCollection::const_iterator mcparticle = mcParticles_->begin (); mcparticle != mcParticles_->end (); mcparticle++){
2118 +
2119 + //   }
2120 + //   return bestMatch;
2121 + // }
2122  
2123  
2124   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines