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.1 by lantonel, Mon Jan 21 10:39:34 2013 UTC vs.
Revision 1.12 by ahart, Fri Feb 8 11:07:51 2013 UTC

# Line 15 | Line 15 | OSUAnalysis::OSUAnalysis (const edm::Par
15    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
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"))
21 >  channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
22 >
23 >  histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets"))
24  
25   {
26 +
27 +
28    TH1::SetDefaultSumw2 ();
29 +  TH2::SetDefaultSumw2 ();
30  
31    // Construct Cutflow Objects. These store the results of cut decisions and
32    // handle filling cut flow histograms.
33    masterCutFlow_ = new CutFlow (fs_);
34    std::vector<TFileDirectory> directories;
35  
36 +  //always get vertex collection so we can assign the primary vertex in the event
37 +  allNecessaryObjects.push_back("primaryvertexs");
38 +
39 +
40 +  //parse the histogram definitions
41 +  for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
42 +
43 +    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string>("inputCollection");
44 +    objectsToPlot.push_back(tempInputCollection);
45 +    allNecessaryObjects.push_back(tempInputCollection);
46 +    vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
47 +    
48 +    for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
49 +
50 +      histogram tempHistogram;
51 +      tempHistogram.inputCollection = tempInputCollection;
52 +      tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
53 +      tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
54 +      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
55 +      tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
56 +      if(histogramList_.at(currentHistogram).exists("function"))
57 +        tempHistogram.function = histogramList_.at(currentHistogram).getParameter<string>("function");
58 +      else
59 +        tempHistogram.function = "";
60 +      
61 +      histograms.push_back(tempHistogram);
62 +
63 +    }
64 +  }
65 +
66 +
67  
68    channel tempChannel;
69    //loop over all channels (event selections)
70    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
71 <    
71 >
72      //get name of channel
73      string channelName  (channels_.at(currentChannel).getParameter<string>("name"));
74      tempChannel.name = channelName;
75      TString channelLabel = channelName;
76  
77 +    //set triggers for this channel
78 +    vector<string> triggerNames;
79 +    triggerNames.clear();
80 +    tempChannel.triggers.clear();
81 +    if(channels_.at(currentChannel).exists("triggers")){
82 +      triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
83 +      for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
84 +        tempChannel.triggers.push_back(triggerNames.at(trigger));
85 +      allNecessaryObjects.push_back("triggers");
86 +    }
87 +
88 +
89  
90      //create cutFlow for this channel
91      cutFlows_.push_back (new CutFlow (fs_, channelName));
# Line 44 | Line 93 | OSUAnalysis::OSUAnalysis (const edm::Par
93      //book a directory in the output file with the name of the channel
94      TFileDirectory subDir = fs_->mkdir( channelName );
95      directories.push_back(subDir);
47    std::map<std::string, TH1D*> histoMap;
48    oneDHists_.push_back(histoMap);
96  
97 +    std::map<std::string, TH1D*> oneDhistoMap;
98 +    oneDHists_.push_back(oneDhistoMap);
99 +    std::map<std::string, TH2D*> twoDhistoMap;
100 +    twoDHists_.push_back(twoDhistoMap);
101 +
102 +    //book all histograms included in the configuration
103 +    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
104 +      histogram currentHistogram = histograms.at(currentHistogramIndex);
105 +      int numBinsElements = currentHistogram.bins.size();
106 +      int numInputVariables = currentHistogram.inputVariables.size();
107 +      if(numBinsElements != 3 && numBinsElements !=6) {
108 +        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
109 +        exit(0);
110 +      }
111 +      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
112 +        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
113 +        exit(0);
114 +      }
115 +      else if(numBinsElements == 3)
116 +        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));
117 +      else if(numBinsElements == 6)
118 +        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));
119  
51    //muon histograms
52    oneDHists_.at(currentChannel)["muonPt"]  = directories.at(currentChannel).make<TH1D> ("muonPt",channelLabel+" channel: Muon Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
53    oneDHists_.at(currentChannel)["muonEta"] = directories.at(currentChannel).make<TH1D> ("muonEta",channelLabel+" channel: Muon Eta; #eta", 100, -5, 5);
54    oneDHists_.at(currentChannel)["muonD0"] = directories.at(currentChannel).make<TH1D> ("muonD0",channelLabel+" channel: Muon d_{0}; d_{0} [cm] ", 1000, -1, 1);
55    oneDHists_.at(currentChannel)["muonAbsD0"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0",channelLabel+" channel: Muon d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
56    oneDHists_.at(currentChannel)["muonD0Sig"] = directories.at(currentChannel).make<TH1D> ("muonD0Sig",channelLabel+" channel: Muon d_{0} Significance; d_{0} / #sigma_{d_{0}} ", 1000, -10.0, 10.0);
57    oneDHists_.at(currentChannel)["muonAbsD0Sig"] = directories.at(currentChannel).make<TH1D> ("muonAbsD0Sig",channelLabel+" channel: Muon d_{0} Significance; |d_{0}| / #sigma_{d_{0}} ", 1000, 0, 10.0);
58    oneDHists_.at(currentChannel)["muonIso"] = directories.at(currentChannel).make<TH1D> ("muonIso",channelLabel+" channel: Muon Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
59    oneDHists_.at(currentChannel)["numMuons"] = directories.at(currentChannel).make<TH1D> ("numMuons",channelLabel+" channel: Number of Selected Muons; # muons", 10, 0, 10);
60
61
62    //electron histograms
63    oneDHists_.at(currentChannel)["electronPt"]  = directories.at(currentChannel).make<TH1D> ("electronPt",channelLabel+" channel: Electron Transverse Momentum; p_{T} [GeV]", 100, 0, 500);
64    oneDHists_.at(currentChannel)["electronEta"] = directories.at(currentChannel).make<TH1D> ("electronEta",channelLabel+" channel: Electron Eta; #eta", 50, -5, 5);
65    oneDHists_.at(currentChannel)["electronD0"] = directories.at(currentChannel).make<TH1D> ("electronD0",channelLabel+" channel: Electron d_{0}; d_{0} [cm] ", 1000, -1, 1);
66    oneDHists_.at(currentChannel)["electronAbsD0"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0",channelLabel+" channel: Electron d_{0}; |d_{0}| [cm] ", 1000, 0, 1);
67    oneDHists_.at(currentChannel)["electronD0Sig"] = directories.at(currentChannel).make<TH1D> ("electronD0Sig",channelLabel+" channel: Electron d_{0} Significance; d_{0} / #sigma_{d_{0}} ", 1000, -10.0, 10.0);
68    oneDHists_.at(currentChannel)["electronAbsD0Sig"] = directories.at(currentChannel).make<TH1D> ("electronAbsD0Sig",channelLabel+" channel: Electron d_{0} Significance; |d_{0}| / #sigma_{d_{0}} ", 1000, 0, 10.0);
69    oneDHists_.at(currentChannel)["electronIso"] = directories.at(currentChannel).make<TH1D> ("electronIso",channelLabel+" channel: Electron Combined Relative Isolation; rel. iso. ", 1000, 0, 1);
70    oneDHists_.at(currentChannel)["electronFbrem"] = directories.at(currentChannel).make<TH1D> ("electronFbrem",channelLabel+" channel: Electron Brem. Energy Fraction; fbrem", 1000, 0, 2);
71    oneDHists_.at(currentChannel)["numElectrons"] = directories.at(currentChannel).make<TH1D> ("numElectrons",channelLabel+" channel: Number of Selected Electrons; # electrons", 10, 0, 10);
120  
121 +    }
122 +    //book a histogram for the number of each object type to be plotted
123 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
124 +      string currentObject = objectsToPlot.at(currentObjectIndex);
125 +      int maxNum = 10;
126 +      if(currentObject == "mcparticles") maxNum = 50;
127 +      currentObject[0] = toupper(currentObject[0]);
128 +      string histoName = "num" + currentObject;
129 +      oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
130 +    }
131  
132  
133      //get list of cuts for this channel
134      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
135  
78    vector<string> tempInputCollections;
79
80
136      //loop over and parse all cuts
137      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
138  
# Line 85 | Line 140 | OSUAnalysis::OSUAnalysis (const edm::Par
140       //store input collection for cut
141        string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
142        tempCut.inputCollection = inputCollection;
88      
89      tempInputCollections.push_back(inputCollection);
143        allNecessaryObjects.push_back(inputCollection);
144  
145        //split cut string into parts and store them
146        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
147        std::vector<string> cutStringVector = splitString(cutString);
148 +      if(cutStringVector.size()!=3){
149 +        std::cout << "Error: Didn't find three elements in the following cut string: '" <<cutString << "'\n";
150 +        exit(0);
151 +      }
152 +
153        tempCut.variable = cutStringVector.at(0);// variable to cut on
154        tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
155        tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
# Line 99 | Line 157 | OSUAnalysis::OSUAnalysis (const edm::Par
157        //get number of objects required to pass cut for event to pass
158        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
159        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
160 +      if(numberRequiredVector.size()!=2){
161 +        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
162 +        exit(0);
163 +      }
164  
165        // determine number required if comparison contains "="
166 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
166 >      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
167        if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
168        else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
169  
170        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
171        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
110      
172  
173 +      if(cuts_.at(currentCut).exists("function")){
174 +        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
175 +      }
176 +      else tempCut.function = "";
177        string tempCutName;
178        if(cuts_.at(currentCut).exists("alias")){
179 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
179 >        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
180        }
181        else{
182 <        //construct string for cutflow table
183 <        bool plural = numberRequiredInt != 1;
184 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
185 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
186 <        tempCutName = cutName;
182 >        //construct string for cutflow table
183 >        bool plural = numberRequiredInt != 1;
184 >        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
185 >        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
186 >        tempCutName = cutName;
187        }
188        tempCut.name = tempCutName;
189  
# Line 126 | Line 191 | OSUAnalysis::OSUAnalysis (const edm::Par
191        tempChannel.cuts.push_back(tempCut);
192  
193  
194 +
195      }//end loop over cuts
196  
131    //make unique vector of all objects that this channel cuts on (so we know to set flags for those)
132    sort( tempInputCollections.begin(), tempInputCollections.end() );
133    tempInputCollections.erase( unique( tempInputCollections.begin(), tempInputCollections.end() ), tempInputCollections.end() );
134    tempChannel.inputCollections = tempInputCollections;    
197  
198      channels.push_back(tempChannel);
199      tempChannel.cuts.clear();
# Line 139 | Line 201 | OSUAnalysis::OSUAnalysis (const edm::Par
201    }//end loop over channels
202  
203  
204 +
205 +
206    //make unique vector of objects we need to cut on (so we make sure to get them from the event)
207    sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
208    allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
# Line 158 | Line 222 | OSUAnalysis::~OSUAnalysis ()
222   void
223   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
224   {
225 +
226 +
227    // Retrieve necessary collections from the event.
228 +  edm::Handle<BNtriggerCollection> triggers;
229 +  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
230 +    event.getByLabel (triggers_, triggers);
231 +
232    edm::Handle<BNjetCollection> jets;
233 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())  
233 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
234      event.getByLabel (jets_, jets);
235  
236    edm::Handle<BNmuonCollection> muons;
237 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())  
237 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
238      event.getByLabel (muons_, muons);
239  
240    edm::Handle<BNelectronCollection> electrons;
241 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())  
241 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
242      event.getByLabel (electrons_, electrons);
243  
244    edm::Handle<BNeventCollection> events;
245 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())  
245 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
246      event.getByLabel (events_, events);
247  
248    edm::Handle<BNtauCollection> taus;
249 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())  
249 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
250      event.getByLabel (taus_, taus);
251  
252    edm::Handle<BNmetCollection> mets;
253 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())  
253 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
254      event.getByLabel (mets_, mets);
255  
256    edm::Handle<BNtrackCollection> tracks;
257 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())  
257 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
258      event.getByLabel (tracks_, tracks);
259  
260    edm::Handle<BNgenjetCollection> genjets;
261 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())  
261 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
262      event.getByLabel (genjets_, genjets);
263  
264    edm::Handle<BNmcparticleCollection> mcparticles;
265 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())  
265 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
266      event.getByLabel (mcparticles_, mcparticles);
267  
268    edm::Handle<BNprimaryvertexCollection> primaryvertexs;
269 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())  
269 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
270      event.getByLabel (primaryvertexs_, primaryvertexs);
271  
272    edm::Handle<BNbxlumiCollection> bxlumis;
273 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())  
273 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
274      event.getByLabel (bxlumis_, bxlumis);
275  
276    edm::Handle<BNphotonCollection> photons;
277 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())  
277 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
278      event.getByLabel (photons_, photons);
279  
280    edm::Handle<BNsuperclusterCollection> superclusters;
281 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())  
281 >  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
282      event.getByLabel (superclusters_, superclusters);
283  
284  
# Line 217 | Line 287 | OSUAnalysis::analyze (const edm::Event &
287    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
288      channel currentChannel = channels.at(currentChannelIndex);
289  
290 <    flagMap individualFlags;  
291 <    flagMap cumulativeFlags;  
292 <    counterMap passingCounter;
293 <
294 <
295 <
290 >    flagMap individualFlags;
291 >    flagMap cumulativeFlags;
292 >    counterMap passingCounter;
293 >
294 >    bool triggerDecision = true;
295 >    if(currentChannel.triggers.size() != 0){  //triggers specified
296 >      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
297 >      cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
298 >    }
299  
300      //loop over all cuts
301      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
# Line 230 | Line 303 | OSUAnalysis::analyze (const edm::Event &
303  
304        for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
305  
306 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
307 <        individualFlags[currentObject].push_back (vector<bool> ());
308 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
309 <
310 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
311 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
312 <        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
313 <        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
314 <        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
315 <        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
316 <        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
317 <        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
318 <        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
319 <        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
320 <        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
321 <        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
322 <        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
306 >        string currentObject = allNecessaryObjects.at(currentObjectIndex);
307 >        individualFlags[currentObject].push_back (vector<bool> ());
308 >        cumulativeFlags[currentObject].push_back (vector<bool> ());
309 >
310 >        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
311 >        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
312 >        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
313 >        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
314 >        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
315 >        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
316 >        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
317 >        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
318 >        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
319 >        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
320 >        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
321 >        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
322 >        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
323  
324  
325        }
# Line 254 | Line 327 | OSUAnalysis::analyze (const edm::Event &
327  
328  
329      }//end loop over all cuts
330 <    
330 >
331 >
332  
333  
334      //use cumulative flags to apply cuts at event level
335  
336      bool eventPassedAllCuts = true;
337  
338 +    //apply trigger (true if none were specified)
339 +    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
340 +
341 +
342      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
343  
344        //loop over all objects and count how many passed the cumulative selection up to this point
345        cut currentCut = currentChannel.cuts.at(currentCutIndex);
346        int numberPassing = 0;
347 <      
347 >
348        for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
349 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
349 >          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
350  
351  
352        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
# Line 278 | Line 356 | OSUAnalysis::analyze (const edm::Event &
356  
357      }
358  
359 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();  
282 <  
283 <    string lastCutName = currentChannel.cuts.back().name; //get name of final cut
284 <
285 <
286 <
359 >    cutFlows_.at(currentChannelIndex)->fillCutFlow();
360  
361  
362      if(!eventPassedAllCuts)continue;
363  
364  
365 <
366 <    vector<bool> electronFlags = cumulativeFlags["electrons"].back();
367 <    int electronCounter = 0;
368 <
369 <    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
370 <      if(!electronFlags.at(electronIndex)) continue;
371 <
299 <
300 <      electronCounter++;
301 <      oneDHists_.at(currentChannelIndex)["electronPt"]->Fill (electrons->at(electronIndex).pt);
302 <      oneDHists_.at(currentChannelIndex)["electronEta"]->Fill (electrons->at(electronIndex).eta);
303 <      oneDHists_.at(currentChannelIndex)["electronD0"]->Fill (electrons->at(electronIndex).correctedD0Vertex);
304 <      oneDHists_.at(currentChannelIndex)["electronAbsD0"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex));
305 <      oneDHists_.at(currentChannelIndex)["electronD0Sig"]->Fill (electrons->at(electronIndex).correctedD0Vertex / electrons->at(electronIndex).tkD0err);
306 <      oneDHists_.at(currentChannelIndex)["electronAbsD0Sig"]->Fill (fabs(electrons->at(electronIndex).correctedD0Vertex) / electrons->at(electronIndex).tkD0err);
307 <      oneDHists_.at(currentChannelIndex)["electronIso"]->Fill (((electrons->at(electronIndex).trackIso + electrons->at(electronIndex).caloIso) / electrons->at(electronIndex).pt));
308 <      oneDHists_.at(currentChannelIndex)["electronFbrem"]->Fill (electrons->at(electronIndex).fbrem);
365 >    //set position of primary vertex in event, in order to calculate quantities relative to it
366 >    primaryVertex_ = 0;
367 >    vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back();
368 >    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
369 >      if(!vertexFlags.at(vertexIndex)) continue;
370 >      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
371 >      break;
372      }
310    oneDHists_.at(currentChannelIndex)["numElectrons"]->Fill (electronCounter);
373  
312    
313    vector<bool> muonFlags = cumulativeFlags["muons"].back();
314    int muonCounter = 0;
374  
375  
376 <    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
377 <      if(!muonFlags.at(muonIndex)) continue;
378 <      muonCounter++;
379 <
380 <      oneDHists_.at(currentChannelIndex)["muonPt"]->Fill (muons->at(muonIndex).pt);
381 <      oneDHists_.at(currentChannelIndex)["muonEta"]->Fill (muons->at(muonIndex).eta);
382 <      oneDHists_.at(currentChannelIndex)["muonD0"]->Fill (muons->at(muonIndex).correctedD0Vertex);
383 <      oneDHists_.at(currentChannelIndex)["muonAbsD0"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex));
384 <      oneDHists_.at(currentChannelIndex)["muonD0Sig"]->Fill (muons->at(muonIndex).correctedD0Vertex / muons->at(muonIndex).tkD0err);
385 <      oneDHists_.at(currentChannelIndex)["muonAbsD0Sig"]->Fill (fabs(muons->at(muonIndex).correctedD0Vertex) / muons->at(muonIndex).tkD0err);
386 <      oneDHists_.at(currentChannelIndex)["muonIso"]->Fill (((muons->at(muonIndex).trackIso + muons->at(muonIndex).caloIso) / muons->at(muonIndex).pt));
376 >    //filling histograms
377 >    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
378 >      histogram currentHistogram = histograms.at(histogramIndex);
379 >
380 >      if(currentHistogram.inputVariables.size() == 1){
381 >        TH1D* histo;
382 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
383 >        if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product());
384 >        else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product());
385 >        else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product());
386 >        else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product());
387 >        else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product());
388 >        else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product());
389 >        else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product());
390 >        else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product());
391 >        else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product());
392 >        else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product());
393 >        else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product());
394 >        else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product());
395 >        else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product());
396 >      }
397 >      else if(currentHistogram.inputVariables.size() == 2){
398 >        TH2D* histo;
399 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
400 >        if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product());
401 >        else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product());
402 >        else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product());
403 >        else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product());
404 >        else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product());
405 >        else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product());
406 >        else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product());
407 >        else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product());
408 >        else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product());
409 >        else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product());
410 >        else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product());
411 >        else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product());
412 >        else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product());
413 >      }
414      }
329    oneDHists_.at(currentChannelIndex)["numMuons"]->Fill (muonCounter);
330
331
415  
416  
417 +    //fills histograms with the sizes of collections
418 +    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
419 +      string currentObject = objectsToPlot.at(currentObjectIndex);
420 +      string tempCurrentObject = currentObject;
421 +      tempCurrentObject[0] = toupper(tempCurrentObject[0]);
422 +      string histoName = "num" + tempCurrentObject;
423 +
424 +      if(currentObject == "jets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(jets->size());
425 +      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(muons->size());
426 +      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(electrons->size());
427 +      else if(currentObject == "events") oneDHists_.at(currentChannelIndex)[histoName]->Fill(events->size());
428 +      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex)[histoName]->Fill(taus->size());
429 +      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mets->size());
430 +      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex)[histoName]->Fill(tracks->size());
431 +      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(genjets->size());
432 +      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mcparticles->size());
433 +      else if(currentObject == "primaryvertexs") oneDHists_.at(currentChannelIndex)[histoName]->Fill(primaryvertexs->size());
434 +      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex)[histoName]->Fill(bxlumis->size());
435 +      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(photons->size());
436 +      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex)[histoName]->Fill(superclusters->size());
437  
438 +    }
439    } //end loop over channel
440  
441 <  masterCutFlow_->fillCutFlow();    
441 >  masterCutFlow_->fillCutFlow();
442  
443  
444   }
445  
446  
447 < bool
447 > bool
448   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
449  
450 +
451    if(comparison == ">")       return testValue >  cutValue;
452    else if(comparison == ">=") return testValue >= cutValue;
453    else if(comparison == "<")  return testValue <  cutValue;
454    else if(comparison == "<=") return testValue <= cutValue;
455 +  else if(comparison == "==") return testValue == cutValue;
456 +  else if(comparison == "!=") return testValue != cutValue;
457    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
458  
459   }
460  
461 + bool
462 + OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
463 +
464 +  bool triggerDecision = false;
465 +
466 +  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
467 +    {
468 +      if(trigger->pass != 1) continue;
469 +      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
470 +        {
471 +          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
472 +            triggerDecision = true;
473 +          }
474 +        }
475 +    }
476 +  return triggerDecision;
477 +
478 + }
479 +
480   std::vector<std::string>
481   OSUAnalysis::splitString (string inputString){
482  
# Line 363 | Line 489 | OSUAnalysis::splitString (string inputSt
489   }
490  
491   double
492 < OSUAnalysis::valueLookup (const BNjet* object, string variable){
492 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
493  
494    double value = 0.0;
495    if(variable == "energy") value = object->energy;
# Line 481 | Line 607 | OSUAnalysis::valueLookup (const BNjet* o
607    else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
608    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
609    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
610 <  
611 <  
610 >
611 >
612    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
613 <  
613 >
614 >  value = applyFunction(function, value);
615  
616    return value;
617   }
# Line 492 | Line 619 | OSUAnalysis::valueLookup (const BNjet* o
619  
620  
621   double
622 < OSUAnalysis::valueLookup (const BNmuon* object, string variable){
622 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
623  
624    double value = 0.0;
625    if(variable == "energy") value = object->energy;
# Line 646 | Line 773 | OSUAnalysis::valueLookup (const BNmuon*
773    else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
774    else if(variable == "time_ndof") value = object->time_ndof;
775  
776 +  //user-defined variables
777 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
778 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
779 +  else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
780 +  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
781 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
782 +  else if(variable == "tightID") {
783 +    value = object->isGlobalMuon > 0            \
784 +      && object->isPFMuon > 0                   \
785 +      && object->normalizedChi2 < 10            \
786 +      && object->numberOfValidMuonHits > 0      \
787 +      && object->numberOfMatchedStations > 1    \
788 +      && fabs(object->correctedD0Vertex) < 0.2  \
789 +      && fabs(object->correctedDZ) < 0.5        \
790 +      && object->numberOfValidPixelHits > 0     \
791 +      && object->numberOfLayersWithMeasurement > 5;
792 +    
793 +
794 +  }
795 +  else if(variable == "tightIDdisplaced"){
796 +    value = object->isGlobalMuon > 0            \
797 +      && object->isPFMuon > 0                   \
798 +      && object->normalizedChi2 < 10            \
799 +      && object->numberOfValidMuonHits > 0      \
800 +      && object->numberOfMatchedStations > 1    \
801 +      && object->numberOfValidPixelHits > 0     \
802 +      && object->numberOfLayersWithMeasurement > 5;
803 +  }
804 +
805    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
806 <  
806 >
807 >  value = applyFunction(function, value);
808  
809    return value;
810   }
811  
812  
813   double
814 < OSUAnalysis::valueLookup (const BNelectron* object, string variable){
814 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
815  
816    double value = 0.0;
817    if(variable == "energy") value = object->energy;
# Line 814 | Line 971 | OSUAnalysis::valueLookup (const BNelectr
971    else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
972    else if(variable == "passConvVeto") value = object->passConvVeto;
973  
974 +  //user-defined variables
975 +  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
976 +  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
977 +  else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
978 +  else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
979 +
980  
981    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
982 <  
982 >
983 >  value = applyFunction(function, value);
984  
985    return value;
986   }
987  
988  
989   double
990 < OSUAnalysis::valueLookup (const BNevent* object, string variable){
990 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
991  
992    double value = 0.0;
993  
# Line 893 | Line 1057 | OSUAnalysis::valueLookup (const BNevent*
1057    else if(variable == "evt") value = object->evt;
1058  
1059    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1060 <  
1060 >
1061 >  value = applyFunction(function, value);
1062  
1063    return value;
1064   }
1065  
1066   double
1067 < OSUAnalysis::valueLookup (const BNtau* object, string variable){
1067 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
1068  
1069    double value = 0.0;
1070  
# Line 945 | Line 1110 | OSUAnalysis::valueLookup (const BNtau* o
1110  
1111  
1112    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1113 <  
1113 >
1114 >  value = applyFunction(function, value);
1115  
1116    return value;
1117   }
1118  
1119   double
1120 < OSUAnalysis::valueLookup (const BNmet* object, string variable){
1120 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
1121  
1122    double value = 0.0;
1123  
# Line 1016 | Line 1182 | OSUAnalysis::valueLookup (const BNmet* o
1182    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
1183  
1184    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1185 <  
1185 >
1186 >  value = applyFunction(function, value);
1187  
1188    return value;
1189   }
1190  
1191   double
1192 < OSUAnalysis::valueLookup (const BNtrack* object, string variable){
1192 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1193  
1194    double value = 0.0;
1195  
# Line 1046 | Line 1213 | OSUAnalysis::valueLookup (const BNtrack*
1213  
1214  
1215    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1216 <  
1216 >
1217 >  value = applyFunction(function, value);
1218  
1219    return value;
1220   }
1221  
1222   double
1223 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable){
1223 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
1224  
1225    double value = 0.0;
1226  
# Line 1073 | Line 1241 | OSUAnalysis::valueLookup (const BNgenjet
1241  
1242  
1243    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1244 <  
1244 >
1245 >  value = applyFunction(function, value);
1246  
1247    return value;
1248   }
1249  
1250   double
1251 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable){
1251 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
1252  
1253    double value = 0.0;
1254  
# Line 1168 | Line 1337 | OSUAnalysis::valueLookup (const BNmcpart
1337    else if(variable == "grandMother11Status") value = object->grandMother11Status;
1338    else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
1339  
1340 +  //user-defined variables
1341 +  else if (variable == "d0"){
1342 +    double vx = object->vx - primaryVertex_->x,
1343 +      vy = object->vy - primaryVertex_->y,
1344 +      px = object->px,
1345 +      py = object->py,
1346 +      pt = object->pt;
1347 +    value = (-vx * py + vy * px) / pt;
1348 +  }
1349 +  else if (variable == "dz"){
1350 +    double vx = object->vx - primaryVertex_->x,
1351 +      vy = object->vy - primaryVertex_->y,
1352 +      vz = object->vz - primaryVertex_->z,
1353 +      px = object->px,
1354 +      py = object->py,
1355 +      pz = object->pz,
1356 +      pt = object->pt;
1357 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
1358 +  }
1359 +
1360 +
1361 +
1362    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1363 <  
1363 >
1364 >  value = applyFunction(function, value);
1365  
1366    return value;
1367   }
1368  
1369   double
1370 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable){
1370 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
1371  
1372    double value = 0.0;
1373  
# Line 1195 | Line 1387 | OSUAnalysis::valueLookup (const BNprimar
1387  
1388  
1389    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1390 <  
1390 >
1391 >  value = applyFunction(function, value);
1392  
1393    return value;
1394   }
1395  
1396   double
1397 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable){
1397 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
1398  
1399    double value = 0.0;
1400  
# Line 1211 | Line 1404 | OSUAnalysis::valueLookup (const BNbxlumi
1404  
1405  
1406    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1407 <  
1407 >
1408 >  value = applyFunction(function, value);
1409  
1410    return value;
1411   }
1412  
1413   double
1414 < OSUAnalysis::valueLookup (const BNphoton* object, string variable){
1414 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
1415  
1416    double value = 0.0;
1417  
# Line 1293 | Line 1487 | OSUAnalysis::valueLookup (const BNphoton
1487  
1488  
1489    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1490 <  
1490 >
1491 >  value = applyFunction(function, value);
1492  
1493    return value;
1494   }
1495  
1496   double
1497 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable){
1497 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
1498  
1499    double value = 0.0;
1500  
# Line 1314 | Line 1509 | OSUAnalysis::valueLookup (const BNsuperc
1509  
1510  
1511    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1512 <  
1512 >
1513 >  value = applyFunction(function, value);
1514  
1515    return value;
1516   }
1517  
1518  
1519 < template <class InputCollection>
1519 > double
1520 > OSUAnalysis::applyFunction(string function, double value){
1521 >
1522 >  if(function == "abs") value = fabs(value);
1523 >
1524 >
1525 >  return value;
1526 >
1527 > }
1528 >
1529 >
1530 > template <class InputCollection>
1531   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
1532  
1533  
1534    for (uint object = 0; object != inputCollection->size(); object++){
1535 <    
1535 >
1536      bool decision = true;//object passes if this cut doesn't cut on that type of object
1537 <    
1538 <    if(currentCut.inputCollection == inputType){
1539 <      
1540 <      double value = valueLookup(&inputCollection->at(object), currentCut.variable);
1537 >
1538 >    if(currentCut.inputCollection == inputType){
1539 >
1540 >      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
1541  
1542        decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
1543      }
1544      individualFlags[inputType].at(currentCutIndex).push_back(decision);
1545 <    
1545 >
1546  
1547      //set flags for objects that pass each cut AND all the previous cuts
1548      bool previousCumulativeFlag = true;
# Line 1344 | Line 1551 | void OSUAnalysis::setObjectFlags(cut &cu
1551        else{ previousCumulativeFlag = false; break;}
1552      }
1553      cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1554 <    
1554 >
1555    }
1556 <  
1556 >
1557   }
1558  
1559  
1560 + template <class InputCollection>
1561 + void OSUAnalysis::fillHistogram(TH1* histo, histogram parameters, InputCollection inputCollection){
1562 +
1563 +
1564 +  for (uint object = 0; object != inputCollection->size(); object++){
1565 +    if(parameters.inputVariables.size() == 1){
1566 +      double value = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function);
1567 +      histo->Fill(value);
1568 +    }
1569 +    else if(parameters.inputVariables.size() == 2){
1570 +      double valueX = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function);
1571 +      double valueY = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(1), parameters.function);
1572 +      histo->Fill(valueX,valueY);
1573 +    }
1574 +  }
1575 +
1576 + }
1577 +
1578  
1579  
1580  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines