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.64 by ahart, Sun May 19 00:04:50 2013 UTC vs.
Revision 1.73 by lantonel, Thu May 30 18:09:58 2013 UTC

# Line 33 | Line 33 | OSUAnalysis::OSUAnalysis (const edm::Par
33    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34    printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36 <  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
37 <
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
37 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
38   {
39  
40    TH1::SetDefaultSumw2 ();
# Line 54 | Line 54 | OSUAnalysis::OSUAnalysis (const edm::Par
54    // Construct Cutflow Objects. These store the results of cut decisions and
55    // handle filling cut flow histograms.
56    masterCutFlow_ = new CutFlow (fs_);
57  vector<TFileDirectory> directories;
57  
58    //always get vertex collection so we can assign the primary vertex in the event
59    objectsToGet.push_back("primaryvertexs");
61
62  //always make the plot of number of primary vertices (to check pile-up reweighting)
60    objectsToPlot.push_back("primaryvertexs");
61 +  objectsToCut.push_back("primaryvertexs");
62 +
63  
64    //always get the MC particles to do GEN-matching
65    objectsToGet.push_back("mcparticles");
# Line 109 | Line 108 | OSUAnalysis::OSUAnalysis (const edm::Par
108  
109      }
110  
111 +
112      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
113  
114      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
# Line 213 | Line 213 | OSUAnalysis::OSUAnalysis (const edm::Par
213      //set triggers for this channel
214      vector<string> triggerNames;
215      triggerNames.clear();
216 +    vector<string> triggerToVetoNames;
217 +    triggerToVetoNames.clear();
218 +
219      tempChannel.triggers.clear();
220 +    tempChannel.triggersToVeto.clear();
221      if(channels_.at(currentChannel).exists("triggers")){
222        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
223        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
224          tempChannel.triggers.push_back(triggerNames.at(trigger));
225        objectsToGet.push_back("triggers");
226      }
227 <
227 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
228 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
229 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
230 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
231 >      objectsToGet.push_back("triggers");
232 >    }
233  
234  
235  
236      //create cutFlow for this channel
237      cutFlows_.push_back (new CutFlow (fs_, channelName));
238 +    vector<TFileDirectory> directories; //vector of directories in the output file.
239 +    vector<string> subSubDirNames;//subdirectories in each channel.
240 +    //get list of cuts for this channel
241 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
242  
230    //book a directory in the output file with the name of the channel
231    TFileDirectory subDir = fs_->mkdir( channelName );
232    directories.push_back(subDir);
243  
244 <    map<string, TH1D*> oneDhistoMap;
245 <    oneDHists_.push_back(oneDhistoMap);
246 <    map<string, TH2D*> twoDhistoMap;
247 <    twoDHists_.push_back(twoDhistoMap);
244 >    //loop over and parse all cuts
245 >    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
246 >      cut tempCut;
247 >      //store input collection for cut
248 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
249 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
250 >      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
251 >      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
252 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
253 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
254 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
255 >      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
256 >      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
257 >      tempCut.inputCollection = tempInputCollection;
258 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
259 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
260 >          int spaceIndex = tempInputCollection.find(" ");
261 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
262 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
263 >        }
264 >        else{
265 >          objectsToGet.push_back(tempInputCollection);
266 >        }
267 >        objectsToCut.push_back(tempInputCollection);
268 >      }
269 >      else{//pair of objects, need to add them both to objectsToGet
270 >        string obj1;
271 >        string obj2;
272 >        getTwoObjs(tempInputCollection, obj1, obj2);
273 >        string obj2ToGet = getObjToGet(obj2);
274 >        objectsToCut.push_back(tempInputCollection);
275 >        objectsToCut.push_back(obj1);
276 >        objectsToCut.push_back(obj2);
277 >        objectsToGet.push_back(tempInputCollection);
278 >        objectsToGet.push_back(obj1);
279 >        objectsToGet.push_back(obj2ToGet);
280 >
281 >      }
282 >
283 >
284 >
285 >      //split cut string into parts and store them
286 >      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
287 >      vector<string> cutStringVector = splitString(cutString);
288 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
289 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
290 >        exit(0);
291 >      }
292 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
293 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
294 >        int indexOffset = 4 * subcutIndex;
295 >        string currentVariableString = cutStringVector.at(indexOffset);
296 >        if(currentVariableString.find("(")==string::npos){
297 >          tempCut.functions.push_back("");//no function was specified
298 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
299 >        }
300 >        else{
301 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
302 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
303 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
304 >        }
305 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
306 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
307 >        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
308 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
309 >      }
310 >
311 >      //get number of objects required to pass cut for event to pass
312 >      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
313 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
314 >      if(numberRequiredVector.size()!=2){
315 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
316 >        exit(0);
317 >      }
318  
319 +      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
320 +      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
321 +      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
322  
323 +      //Set up vectors to store the directories and subDIrectories for each channel.
324 +      string subSubDirName;
325 +      string tempCutName;
326 +      if(cuts_.at(currentCut).exists("alias")){
327 +        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
328 +        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
329 +      }
330 +      else{
331 +        //construct string for cutflow table
332 +        bool plural = numberRequiredInt != 1;
333 +        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
334 +        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
335 +        tempCutName = cutName;
336 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
337 +      }
338 +
339 +      subSubDirNames.push_back(subSubDirName);
340 +      tempCut.name = tempCutName;
341 +
342 +      tempChannel.cuts.push_back(tempCut);
343 +
344 +
345 +    }//end loop over cuts
346  
347 +    vector<map<string, TH1D*>> oneDHistsTmp;
348 +    vector<map<string, TH2D*>> twoDHistsTmp;
349 +    //book a directory in the output file with the name of the channel
350 +    TFileDirectory subDir = fs_->mkdir( channelName );
351 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
352 +    if(GetPlotsAfterEachCut_){
353 +       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
354 +            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
355 +            directories.push_back(subSubDir);
356 +            map<string, TH1D*> oneDhistoMap;
357 +            oneDHistsTmp.push_back(oneDhistoMap);
358 +            map<string, TH2D*> twoDhistoMap;
359 +            twoDHistsTmp.push_back(twoDhistoMap);
360 +      }
361 +      oneDHists_.push_back(oneDHistsTmp);
362 +      twoDHists_.push_back(twoDHistsTmp);
363 +    }
364 +   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
365 +   else{
366 +      map<string, TH1D*> oneDhistoMap;
367 +      oneDHistsTmp.push_back(oneDhistoMap);
368 +      map<string, TH2D*> twoDhistoMap;
369 +      twoDHistsTmp.push_back(twoDhistoMap);
370 +      oneDHists_.push_back(oneDHistsTmp);
371 +      twoDHists_.push_back(twoDHistsTmp);
372 +      directories.push_back(subDir);
373 +   }
374      //book all histograms included in the configuration
375 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
376      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
377        histogram currentHistogram = histograms.at(currentHistogramIndex);
378        int numBinsElements = currentHistogram.bins.size();
# Line 264 | Line 398 | OSUAnalysis::OSUAnalysis (const edm::Par
398        }
399        else if(numBinsElements == 3){
400          if (currentHistogram.bins.size () == 3)
401 <          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));
401 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
402          else
403            {
404 <            oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
404 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
405            }
406        }
407        else if(numBinsElements == 6){
408          if (currentHistogram.bins.size () == 6)
409 <          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));
409 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).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));
410          else
411 <          twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
411 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
412        }
413  
414  
# Line 337 | Line 471 | OSUAnalysis::OSUAnalysis (const edm::Par
471  
472        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
473          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
474 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
474 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475          }
476          else {
477 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
477 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
479          }
480        }
481        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
482 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
482 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
484        }
485  
486      }
# Line 362 | Line 496 | OSUAnalysis::OSUAnalysis (const edm::Par
496        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
497        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
498        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
499 +      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
500        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
501        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
502        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
# Line 374 | Line 509 | OSUAnalysis::OSUAnalysis (const edm::Par
509        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
510        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
511        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
512 <      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
512 >      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
513        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
514        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
515  
# Line 383 | Line 518 | OSUAnalysis::OSUAnalysis (const edm::Par
518  
519        if(histoName == "numPrimaryvertexs"){
520          string newHistoName = histoName + "BeforePileupCorrection";
521 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
521 >        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
522          newHistoName = histoName + "AfterPileupCorrection";
523 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
523 >        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
524        }
525        else
526 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
526 >        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
527      }
528 <
394 <
395 <
396 <
397 <    //get list of cuts for this channel
398 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
399 <
400 <    //loop over and parse all cuts
401 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
402 <      cut tempCut;
403 <      //store input collection for cut
404 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
405 <      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
406 <      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
407 <      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
408 <      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
409 <      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
410 <      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
411 <      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
412 <      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
413 <      tempCut.inputCollection = tempInputCollection;
414 <      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
415 <        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
416 <          int spaceIndex = tempInputCollection.find(" ");
417 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
418 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
419 <        }
420 <        else{
421 <          objectsToGet.push_back(tempInputCollection);
422 <        }
423 <        objectsToCut.push_back(tempInputCollection);
424 <      }
425 <      else{//pair of objects, need to add them both to objectsToGet
426 <        string obj1;
427 <        string obj2;
428 <        getTwoObjs(tempInputCollection, obj1, obj2);
429 <        string obj2ToGet = getObjToGet(obj2);
430 <        objectsToCut.push_back(tempInputCollection);
431 <        objectsToCut.push_back(obj1);
432 <        objectsToCut.push_back(obj2);
433 <        objectsToGet.push_back(tempInputCollection);
434 <        objectsToGet.push_back(obj1);
435 <        objectsToGet.push_back(obj2ToGet);
436 <
437 <      }
438 <
439 <
440 <
441 <      //split cut string into parts and store them
442 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
443 <      vector<string> cutStringVector = splitString(cutString);
444 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
445 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
446 <        exit(0);
447 <      }
448 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
449 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
450 <        int indexOffset = 4 * subcutIndex;
451 <        string currentVariableString = cutStringVector.at(indexOffset);
452 <        if(currentVariableString.find("(")==string::npos){
453 <          tempCut.functions.push_back("");//no function was specified
454 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
455 <        }
456 <        else{
457 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
458 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
459 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
460 <        }
461 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
462 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
463 <        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
464 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
465 <      }
466 <
467 <      //get number of objects required to pass cut for event to pass
468 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
469 <      vector<string> numberRequiredVector = splitString(numberRequiredString);
470 <      if(numberRequiredVector.size()!=2){
471 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
472 <        exit(0);
473 <      }
474 <
475 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
476 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
477 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
478 <
479 <
480 <      string tempCutName;
481 <      if(cuts_.at(currentCut).exists("alias")){
482 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
483 <      }
484 <      else{
485 <        //construct string for cutflow table
486 <        bool plural = numberRequiredInt != 1;
487 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
488 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
489 <        tempCutName = cutName;
490 <      }
491 <      tempCut.name = tempCutName;
492 <
493 <      tempChannel.cuts.push_back(tempCut);
494 <
495 <
496 <    }//end loop over cuts
497 <
528 >   }//end of loop over directories
529      channels.push_back(tempChannel);
530      tempChannel.cuts.clear();
500
531    }//end loop over channels
532  
533  
# Line 587 | Line 617 | OSUAnalysis::analyze (const edm::Event &
617    double masterScaleFactor = 1.0;
618  
619    //get pile-up event weight
620 <  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
620 >  if (doPileupReweighting_ && datasetType_ != "data") {
621 >    //for "data" datasets, the numTruePV is always set to -1
622 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
623 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
624 >  }
625  
626    stopCTauScaleFactor_ = 1.0;
627    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
# Line 604 | Line 638 | OSUAnalysis::analyze (const edm::Event &
638      cumulativeFlags.clear ();
639  
640      bool triggerDecision = true;
641 <    if(currentChannel.triggers.size() != 0){  //triggers specified
642 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
641 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
642 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
643        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
644      }
645  
646      //loop over all cuts
613
647      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
648        cut currentCut = currentChannel.cuts.at(currentCutIndex);
616
649        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
650          string currentObject = objectsToCut.at(currentObjectIndex);
651  
# Line 628 | Line 660 | OSUAnalysis::analyze (const edm::Event &
660          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
661  
662  
663 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
664 <
665 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
634 <
663 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
664 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
665 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
666          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
667          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
668          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 723 | Line 754 | OSUAnalysis::analyze (const edm::Event &
754  
755  
756      }//end loop over all cuts
726
727
757      //use cumulative flags to apply cuts at event level
758  
759      bool eventPassedAllCuts = true;
760 <
760 >    //a vector to store cumulative cut descisions after each cut.
761 >    vector<bool> eventPassedPreviousCuts;
762      //apply trigger (true if none were specified)
763      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
764  
# Line 745 | Line 775 | OSUAnalysis::analyze (const edm::Event &
775        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
776        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
777        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
778 <
778 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
779      }
750
780      double scaleFactor = masterScaleFactor;
781  
782      muonScaleFactor_ = electronScaleFactor_ = 1.0;
# Line 784 | Line 813 | OSUAnalysis::analyze (const edm::Event &
813  
814      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
815  
787    if(!eventPassedAllCuts)continue;
816  
817      if (printEventInfo_) {
818        // Write information about event to screen, for testing purposes.
# Line 795 | Line 823 | OSUAnalysis::analyze (const edm::Event &
823             << endl;
824      }
825  
798    //filling histograms
799    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
800      histogram currentHistogram = histograms.at(histogramIndex);
801
802      if(currentHistogram.inputVariables.size() == 1){
803        TH1D* histo;
804        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
805
806        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
807        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
808        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
809        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
810        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
811                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
812                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
813        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
814                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
815                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
816        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
817        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
818                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
819                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
820        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
821                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
822                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
823        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
824                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
825                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
826        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
827                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
828                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
829        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
830                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
831                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
832        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
833                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
834                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
835        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
836                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
837                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
838        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
839                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
840                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
841        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
842                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
843                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
844        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
845                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
846                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
847        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
848                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
849                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
850        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
851                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
852                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
853        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
854                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
855                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
856
857        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
858        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
859        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
860        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
861        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
862        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
863        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
864        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
865        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
866        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
867        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
868        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
869      }
870      else if(currentHistogram.inputVariables.size() == 2){
871        TH2D* histo;
872        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
873
874        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
875        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
876        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
877        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
878                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
879                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
880        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
881                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
882                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
883        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
884        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
885        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
886                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
887                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
888        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
889                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
890                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
891        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
892                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
893                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
894        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
895                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
896                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
897        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
898                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
899                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
900        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
901                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
902                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
903        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
904                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
905                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
906        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
907                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
908                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
909        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
910                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
911                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
912        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
913                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
914                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
915        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
916                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
917                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
918        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
919                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
920                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
921        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
922                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
923                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
924        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
925        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
926        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
927        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
928        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
929                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
930                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);
931        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
932        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
933        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
934        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
935        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
936        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
937        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
938        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
939      }
940    }
941
942
943
944    //fills histograms with the sizes of collections
945    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
946
947      string currentObject = objectsToPlot.at(currentObjectIndex);
826  
949      string objectToPlot = "";
827  
828 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
829 <      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
953 <      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
954 <      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
955 <      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
956 <      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
957 <      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
958 <      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
959 <      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
960 <      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
961 <      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
962 <      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
963 <      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
964 <      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
965 <      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
966 <      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
967 <      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
968 <      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
969 <      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
970 <      else objectToPlot = currentObject;
971 <
972 <      string tempCurrentObject = objectToPlot;
973 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
974 <      string histoName = "num" + tempCurrentObject;
975 <
976 <      //set position of primary vertex in event, in order to calculate quantities relative to it
977 <      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
978 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
979 <        int numToPlot = 0;
980 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
981 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
982 <        }
983 <        if(objectToPlot == "primaryvertexs"){
984 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
985 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
986 <        }
987 <        else {
988 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
989 <        }
990 <      }
991 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
992 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
993 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
994 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
995 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
996 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
997 <      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
998 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
999 <      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1000 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1001 <      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1002 <      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1003 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1004 <      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1005 <      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1006 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1007 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1008 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1009 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1010 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1011 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1012 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1013 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1014 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1015 <      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1016 <      else if(objectToPlot == "primaryvertexs"){
1017 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1018 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1019 <      }
1020 <      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
828 >    //filling histograms
829 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830  
831 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
831 >      uint currentDir;
832 >      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
833 >      else currentDir = currentCut;
834 >
835 >      if(!eventPassedPreviousCuts.at(currentDir)) continue;
836 >
837 >
838 >      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
839 >        histogram currentHistogram = histograms.at(histogramIndex);
840 >
841 >        if(currentHistogram.inputVariables.size() == 1){
842 >          TH1D* histo;
843 >          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
844 >
845 >          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
846 >          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
847 >          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
848 >          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
849 >          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
850 >          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
851 >                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
852 >                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
853 >          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
854 >                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
855 >                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
856 >          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
857 >          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
858 >                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
859 >                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
860 >          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
861 >                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
862 >                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
863 >          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
864 >                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
865 >                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
866 >          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
867 >                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
868 >                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
869 >          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
870 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
871 >                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
872 >          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
873 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
874 >                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
875 >          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
876 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
877 >                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
878 >          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
879 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
880 >                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
881 >          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
882 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
883 >                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
884 >          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
885 >                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
886 >                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
887 >          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
888 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
889 >                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
890 >          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
891 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
892 >                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
893 >          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
894 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
895 >                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
896 >          
897 >          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
898 >          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
899 >          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
900 >          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
901 >          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
902 >          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
903 >          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
904 >          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
905 >          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
906 >          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
907 >          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
908 >          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
909 >        }
910 >        else if(currentHistogram.inputVariables.size() == 2){
911 >          TH2D* histo;
912 >          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
913 >
914 >          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
915 >          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
916 >          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
917 >          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
918 >          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
919 >                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
920 >                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
921 >          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
922 >                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
923 >                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
924 >          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
925 >          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
926 >          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
927 >                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
928 >                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
929 >          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
930 >                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
931 >                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
932 >          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
933 >                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
934 >                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
935 >          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
936 >                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
937 >                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
938 >          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
939 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
940 >                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
941 >          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
942 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
943 >                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
944 >          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
945 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
946 >                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
947 >          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
948 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
949 >                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
950 >          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
951 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
952 >                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
953 >          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
954 >                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
955 >                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
956 >          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
957 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
958 >                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
959 >          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
960 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
961 >                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
962 >          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
963 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
964 >                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
965 >          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
966 >          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
967 >          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
968 >          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
969 >          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
970 >                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
971 >                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
972 >          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
973 >          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
974 >          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
975 >          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
976 >          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
977 >          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
978 >          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
979 >          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
980 >        }
981 >      }
982 >
983 >      //fills histograms with the sizes of collections
984 >
985 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
986 >        
987 >        string currentObject = objectsToPlot.at(currentObjectIndex);
988 >        string objectToPlot = "";
989 >        
990 >        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
991 >        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
992 >        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
993 >        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
994 >        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
995 >        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
996 >        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
997 >        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
998 >        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
999 >        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1000 >        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1001 >        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1002 >        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1003 >        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1004 >        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1005 >        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1006 >        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1007 >        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1008 >        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1009 >        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1010 >        else objectToPlot = currentObject;
1011 >        
1012 >        string tempCurrentObject = objectToPlot;
1013 >        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1014 >        string histoName = "num" + tempCurrentObject;
1015 >        
1016 >
1017 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1018 >
1019 >        //count the number of objects passing all cuts
1020 >        int numToPlot = 0;
1021 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1022 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
1023 >        }
1024 >
1025 >        if(objectToPlot == "primaryvertexs"){
1026 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1027 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1028 >        }
1029 >        else {
1030 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1031 >        }
1032 >      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1033 >    }
1034  
1035    } //end loop over channel
1036  
# Line 1060 | Line 1071 | OSUAnalysis::evaluateComparison (string
1071   }
1072  
1073   bool
1074 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1074 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1075  
1076 +  //initialize to false until a chosen trigger is passed
1077    bool triggerDecision = false;
1078  
1079 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1080 <    {
1081 <      if(trigger->pass != 1) continue;
1082 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1083 <        {
1072 <          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1073 <            triggerDecision = true;
1074 <          }
1075 <        }
1076 <    }
1077 <  return triggerDecision;
1079 >  //loop over all triggers defined in the event
1080 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1081 >
1082 >    //we're only interested in triggers that actually passed
1083 >    if(trigger->pass != 1) continue;
1084  
1085 +    //if the event passes one of the veto triggers, exit and return false
1086 +    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1087 +      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1088 +    }
1089 +    //if the event passes one of the chosen triggers, set triggerDecision to true
1090 +    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1091 +      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1092 +    }  
1093 +  }
1094 +  //if none of the veto triggers fired:
1095 +  //return the OR of all the chosen triggers
1096 +  if (triggersToTest.size() != 0) return triggerDecision;
1097 +  //or if no triggers were defined return true
1098 +  else return true;
1099   }
1100  
1101 +
1102   vector<string>
1103   OSUAnalysis::splitString (string inputString){
1104  
# Line 1541 | Line 1562 | OSUAnalysis::valueLookup (const BNmuon*
1562    }
1563    else if(variable == "tightIDdisplaced"){
1564      value = object->isGlobalMuon > 0                \
1565 +      && object->isPFMuon > 0                        \
1566        && object->normalizedChi2 < 10                \
1567                                    && object->numberOfValidMuonHits > 0        \
1568        && object->numberOfMatchedStations > 1        \
# Line 2082 | Line 2104 | OSUAnalysis::valueLookup (const BNevent*
2104    else if(variable == "id2") value = object->id2;
2105    else if(variable == "evt") value = object->evt;
2106    else if(variable == "puScaleFactor"){
2107 <    if(datasetType_ != "data")
2107 >    if(doPileupReweighting_ && datasetType_ != "data")
2108        value = puWeight_->at (events->at (0).numTruePV);
2109      else
2110        value = 1.0;
# Line 3065 | Line 3087 | OSUAnalysis::valueLookup (const BNjet* o
3087  
3088    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3089    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3090 +  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3091    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3092    else if(variable == "invMass"){
3093      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3705 | Line 3728 | void OSUAnalysis::fill1DHistogram(TH1* h
3728      string stringValue = "";
3729      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3730      histo->Fill(value,scaleFactor);
3708
3731      if (printEventInfo_) {
3732        // Write information about event to screen, for testing purposes.
3733        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines