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.73 by lantonel, Thu May 30 18:09:58 2013 UTC vs.
Revision 1.94 by jbrinson, Wed Jul 3 09:30:38 2013 UTC

# Line 28 | Line 28 | OSUAnalysis::OSUAnalysis (const edm::Par
28    datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 +  useEDMFormat_   (cfg.getParameter<bool>("useEDMFormat")),
32 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
36 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
38 >  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
39 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
40 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
41    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
42    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
43    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
44 < {
44 > {
45  
46    TH1::SetDefaultSumw2 ();
47  
# Line 46 | Line 52 | OSUAnalysis::OSUAnalysis (const edm::Par
52        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
53        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
54      }
55 +    if (applyBtagSF_){
56 +      bTagSFWeight_ = new BtagSFWeight;
57 +    }
58    }
59    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
60      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 67 | Line 76 | OSUAnalysis::OSUAnalysis (const edm::Par
76    //always get the event collection to do pile-up reweighting
77    objectsToGet.push_back("events");
78  
79 +
80 +  // Parse the tree variable definitions.
81 +  for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
82 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
83 +    if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
84 +    objectsToGet.push_back(tempInputCollection);
85 +    objectsToCut.push_back(tempInputCollection);
86 +
87 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
88 +
89 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
90 +      BranchSpecs br;
91 +      br.inputCollection = tempInputCollection;
92 +      br.inputVariable = branchList.at(iBranch);
93 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
94 +      br.name = string(newName.Data());
95 +      treeBranches_.push_back(br);
96 +    }
97 +
98 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
99 +
100 +
101    //parse the histogram definitions
102    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
103  
104      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
105      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
106 +    if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
107 +    if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
108      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
109 +    if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
110      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
111 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
112 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
113      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
114      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
115 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
116 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
119      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
120      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
121      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 90 | Line 130 | OSUAnalysis::OSUAnalysis (const edm::Par
130        }
131        objectsToPlot.push_back(tempInputCollection);
132        objectsToCut.push_back(tempInputCollection);
133 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
133 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
134        string obj1;
135        string obj2;
136        getTwoObjs(tempInputCollection, obj1, obj2);
# Line 105 | Line 144 | OSUAnalysis::OSUAnalysis (const edm::Par
144        objectsToGet.push_back(tempInputCollection);
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147 +    } // end else
148  
109    }
149  
150  
151      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 128 | Line 167 | OSUAnalysis::OSUAnalysis (const edm::Par
167        histograms.push_back(tempHistogram);
168  
169      }
170 <  }
170 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
171 >
172    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
173    sort( objectsToPlot.begin(), objectsToPlot.end() );
174    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 236 | Line 276 | OSUAnalysis::OSUAnalysis (const edm::Par
276      //create cutFlow for this channel
277      cutFlows_.push_back (new CutFlow (fs_, channelName));
278      vector<TFileDirectory> directories; //vector of directories in the output file.
279 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
280      vector<string> subSubDirNames;//subdirectories in each channel.
281      //get list of cuts for this channel
282      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 247 | Line 288 | OSUAnalysis::OSUAnalysis (const edm::Par
288        //store input collection for cut
289        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
290        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
291 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
292 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
293        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
294        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
295 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
296 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
297 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
298        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
299        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
300 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
301 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
302 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
303 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
304        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
305        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
306        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 320 | Line 370 | OSUAnalysis::OSUAnalysis (const edm::Par
370        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
371        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
372  
373 <      //Set up vectors to store the directories and subDIrectories for each channel.
373 >      //Set up vectors to store the directories and subDirectories for each channel.
374        string subSubDirName;
375        string tempCutName;
376        if(cuts_.at(currentCut).exists("alias")){
377          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
378 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
378 >        subSubDirName = "After " + tempCutName + " Cut Applied";
379        }
380        else{
381          //construct string for cutflow table
# Line 336 | Line 386 | OSUAnalysis::OSUAnalysis (const edm::Par
386          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
387        }
388  
389 +      tempCut.isVeto = false;
390 +      if(cuts_.at(currentCut).exists("isVeto")){
391 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
392 +        if (isVeto == true) tempCut.isVeto = true;
393 +      }
394        subSubDirNames.push_back(subSubDirName);
395        tempCut.name = tempCutName;
396  
# Line 350 | Line 405 | OSUAnalysis::OSUAnalysis (const edm::Par
405      TFileDirectory subDir = fs_->mkdir( channelName );
406      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
407      if(GetPlotsAfterEachCut_){
408 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
409 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
410 <            directories.push_back(subSubDir);
411 <            map<string, TH1D*> oneDhistoMap;
412 <            oneDHistsTmp.push_back(oneDhistoMap);
413 <            map<string, TH2D*> twoDhistoMap;
414 <            twoDHistsTmp.push_back(twoDhistoMap);
408 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
409 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
410 >        directories.push_back(subSubDir);
411 >        map<string, TH1D*> oneDhistoMap;
412 >        oneDHistsTmp.push_back(oneDhistoMap);
413 >        map<string, TH2D*> twoDhistoMap;
414 >        twoDHistsTmp.push_back(twoDhistoMap);
415        }
416 +      treeDirectories.push_back(subDir);
417        oneDHists_.push_back(oneDHistsTmp);
418        twoDHists_.push_back(twoDHistsTmp);
419      }
420 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
421 <   else{
420 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
421 >    else{
422        map<string, TH1D*> oneDhistoMap;
423        oneDHistsTmp.push_back(oneDhistoMap);
424        map<string, TH2D*> twoDhistoMap;
# Line 370 | Line 426 | OSUAnalysis::OSUAnalysis (const edm::Par
426        oneDHists_.push_back(oneDHistsTmp);
427        twoDHists_.push_back(twoDHistsTmp);
428        directories.push_back(subDir);
429 <   }
429 >      treeDirectories.push_back(subDir);
430 >
431 >    }
432 >
433 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
434 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
435 >      BNTrees_.push_back(newTree);
436 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
437 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
438 >        vector<float> newVec;
439 >        BNTreeBranchVals_[currentVar.name] = newVec;
440 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
441 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
442 >    }
443 >
444      //book all histograms included in the configuration
445      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
446 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
447 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
448 <      int numBinsElements = currentHistogram.bins.size();
449 <      int numInputVariables = currentHistogram.inputVariables.size();
450 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
451 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
452 <
453 <      if(numBinsElements == 1){
454 <        if(numBinEdgesX > 1){
455 <          if(numBinEdgesY > 1)
456 <            numBinsElements = 6;
446 >
447 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
448 >
449 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
450 >        int numBinsElements = currentHistogram.bins.size();
451 >        int numInputVariables = currentHistogram.inputVariables.size();
452 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
453 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
454 >
455 >        if(numBinsElements == 1){
456 >          if(numBinEdgesX > 1){
457 >            if(numBinEdgesY > 1)
458 >              numBinsElements = 6;
459 >            else
460 >              numBinsElements = 3;
461 >          }
462 >        }
463 >        if(numBinsElements != 3 && numBinsElements !=6){
464 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
465 >          exit(0);
466 >        }
467 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
468 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
469 >          exit(0);
470 >        }
471 >        else if(numBinsElements == 3){
472 >          if (currentHistogram.bins.size () == 3)
473 >            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));
474            else
475 <            numBinsElements = 3;
475 >            {
476 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
477 >            }
478          }
479 <      }
480 <      if(numBinsElements != 3 && numBinsElements !=6){
481 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
482 <        exit(0);
483 <      }
484 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
485 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
486 <        exit(0);
487 <      }
488 <      else if(numBinsElements == 3){
489 <        if (currentHistogram.bins.size () == 3)
490 <          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));
491 <        else
492 <          {
493 <            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
479 >        else if(numBinsElements == 6){
480 >          if (currentHistogram.bins.size () == 6)
481 >            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));
482 >          else
483 >            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 ());
484 >        }
485 >
486 >
487 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
488 >
489 >        // bin      particle type
490 >        // ---      -------------
491 >        //  0        unmatched
492 >        //  1        u
493 >        //  2        d
494 >        //  3        s
495 >        //  4        c
496 >        //  5        b
497 >        //  6        t
498 >        //  7        e
499 >        //  8        mu
500 >        //  9        tau
501 >        // 10        nu
502 >        // 11        g
503 >        // 12        gamma
504 >        // 13        Z
505 >        // 14        W
506 >        // 15        light meson
507 >        // 16        K meson
508 >        // 17        D meson
509 >        // 18        B meson
510 >        // 19        light baryon
511 >        // 20        strange baryon
512 >        // 21        charm baryon
513 >        // 22        bottom baryon
514 >        // 23        QCD string
515 >        // 24        other
516 >
517 >        vector<TString> labelArray;
518 >        labelArray.push_back("unmatched");
519 >        labelArray.push_back("u");
520 >        labelArray.push_back("d");
521 >        labelArray.push_back("s");
522 >        labelArray.push_back("c");
523 >        labelArray.push_back("b");
524 >        labelArray.push_back("t");
525 >        labelArray.push_back("e");
526 >        labelArray.push_back("#mu");
527 >        labelArray.push_back("#tau");
528 >        labelArray.push_back("#nu");
529 >        labelArray.push_back("g");
530 >        labelArray.push_back("#gamma");
531 >        labelArray.push_back("Z");
532 >        labelArray.push_back("W");
533 >        labelArray.push_back("light meson");
534 >        labelArray.push_back("K meson");
535 >        labelArray.push_back("D meson");
536 >        labelArray.push_back("B meson");
537 >        labelArray.push_back("light baryon");
538 >        labelArray.push_back("strange baryon");
539 >        labelArray.push_back("charm baryon");
540 >        labelArray.push_back("bottom baryon");
541 >        labelArray.push_back("QCD string");
542 >        labelArray.push_back("other");
543 >
544 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
545 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
546 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
547            }
548 <      }
549 <      else if(numBinsElements == 6){
550 <        if (currentHistogram.bins.size () == 6)
551 <          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));
552 <        else
553 <          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 ());
554 <      }
548 >          else {
549 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
550 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
551 >          }
552 >        }
553 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
554 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
555 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
556 >        }
557  
558 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
559  
415      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
560  
561 <      // bin      particle type
562 <      // ---      -------------
563 <      //  0        unmatched
564 <      //  1        u
565 <      //  2        d
566 <      //  3        s
567 <      //  4        c
568 <      //  5        b
569 <      //  6        t
570 <      //  7        e
571 <      //  8        mu
572 <      //  9        tau
573 <      // 10        nu
574 <      // 11        g
575 <      // 12        gamma
576 <      // 13        Z
577 <      // 14        W
578 <      // 15        light meson
579 <      // 16        K meson
580 <      // 17        D meson
581 <      // 18        B meson
582 <      // 19        light baryon
583 <      // 20        strange baryon
584 <      // 21        charm baryon
585 <      // 22        bottom baryon
586 <      // 23        QCD string
587 <      // 24        other
588 <
589 <      vector<TString> labelArray;
590 <      labelArray.push_back("unmatched");
591 <      labelArray.push_back("u");
592 <      labelArray.push_back("d");
593 <      labelArray.push_back("s");
594 <      labelArray.push_back("c");
595 <      labelArray.push_back("b");
596 <      labelArray.push_back("t");
597 <      labelArray.push_back("e");
598 <      labelArray.push_back("#mu");
599 <      labelArray.push_back("#tau");
600 <      labelArray.push_back("#nu");
601 <      labelArray.push_back("g");
602 <      labelArray.push_back("#gamma");
603 <      labelArray.push_back("Z");
604 <      labelArray.push_back("W");
605 <      labelArray.push_back("light meson");
606 <      labelArray.push_back("K meson");
607 <      labelArray.push_back("D meson");
608 <      labelArray.push_back("B meson");
465 <      labelArray.push_back("light baryon");
466 <      labelArray.push_back("strange baryon");
467 <      labelArray.push_back("charm baryon");
468 <      labelArray.push_back("bottom baryon");
469 <      labelArray.push_back("QCD string");
470 <      labelArray.push_back("other");
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).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475 <        }
476 <        else {
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).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 <        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
484 <      }
485 <
486 <    }
487 <
488 <    // Book a histogram for the number of each object type to be plotted.
489 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
490 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
491 <      string currentObject = objectsToPlot.at(currentObjectIndex);
492 <      int maxNum = 10;
493 <      if(currentObject == "mcparticles") maxNum = 50;
494 <      else if(currentObject == "primaryvertexs") maxNum = 50;
495 <
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";
503 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
504 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
505 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
506 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
507 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
508 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
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";
513 <      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
514 <      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
515 <
516 <      currentObject.at(0) = toupper(currentObject.at(0));
517 <      string histoName = "num" + currentObject;
518 <
519 <      if(histoName == "numPrimaryvertexs"){
520 <        string newHistoName = histoName + "BeforePileupCorrection";
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).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
561 >      // Book a histogram for the number of each object type to be plotted.
562 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
563 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
564 >        string currentObject = objectsToPlot.at(currentObjectIndex);
565 >        int maxNum = 10;
566 >        if(currentObject == "mcparticles") maxNum = 50;
567 >        else if(currentObject == "primaryvertexs") maxNum = 50;
568 >
569 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
570 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
571 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
572 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
573 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
574 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
575 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
576 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
577 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
578 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
579 >        else if(currentObject == "photon-jet pairs")          currentObject = "photonJetPairs";
580 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
581 >        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
582 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
583 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
584 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
585 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
586 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
587 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
588 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
589 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
590 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
591 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
592 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
593 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
594 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
595 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
596 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
597 >
598 >        currentObject.at(0) = toupper(currentObject.at(0));
599 >        string histoName = "num" + currentObject;
600 >
601 >        if(histoName == "numPrimaryvertexs"){
602 >          string newHistoName = histoName + "BeforePileupCorrection";
603 >          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);
604 >          newHistoName = histoName + "AfterPileupCorrection";
605 >          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);
606 >        }
607 >        else
608 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
609        }
610 <      else
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 <   }//end of loop over directories
610 >    }//end of loop over directories
611      channels.push_back(tempChannel);
612      tempChannel.cuts.clear();
613    }//end loop over channels
# Line 538 | Line 620 | OSUAnalysis::OSUAnalysis (const edm::Par
620    sort( objectsToCut.begin(), objectsToCut.end() );
621    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
622  
623 +  produces<map<string, bool> > ("channelDecisions");
624 +
625 + } // end constructor OSUAnalysis::OSUAnalysis()
626  
542 }
627  
628   OSUAnalysis::~OSUAnalysis ()
629   {
630 +
631    // Destroying the CutFlow objects causes the cut flow numbers and time
632    // information to be printed to standard output.
633    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
634      delete cutFlows_.at(currentChannel);
635    }
636 +
637 +  cout << "=============================================" << endl;  
638 +  cout << "Successfully completed OSUAnalysis." << endl;  
639 +  cout << "=============================================" << endl;  
640 +
641   }
642  
643   void
644 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
644 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
645   {
556
646    // Retrieve necessary collections from the event.
647  
648    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 619 | Line 708 | OSUAnalysis::analyze (const edm::Event &
708    //get pile-up event weight
709    if (doPileupReweighting_ && datasetType_ != "data") {
710      //for "data" datasets, the numTruePV is always set to -1
711 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
712 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
711 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
712 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
713    }
714  
715    stopCTauScaleFactor_ = 1.0;
# Line 630 | Line 719 | OSUAnalysis::analyze (const edm::Event &
719  
720    //loop over all channels
721  
722 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
723    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
724      channel currentChannel = channels.at(currentChannelIndex);
725  
# Line 637 | Line 727 | OSUAnalysis::analyze (const edm::Event &
727      counterMap passingCounter;
728      cumulativeFlags.clear ();
729  
730 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
731 +         iter != BNTreeBranchVals_.end(); iter++) {
732 +      iter->second.clear();  // clear array
733 +    }
734 +
735      bool triggerDecision = true;
736      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
737        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 650 | Line 745 | OSUAnalysis::analyze (const edm::Event &
745          string currentObject = objectsToCut.at(currentObjectIndex);
746  
747          //initialize maps to get ready to set cuts
748 <        individualFlags[currentObject].push_back (vector<bool> ());
749 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
748 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
749 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
750  
751        }
752        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
# Line 686 | Line 781 | OSUAnalysis::analyze (const edm::Event &
781                                                                     "muon-muon pairs");
782  
783          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
784 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
785 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
786 <                                                                   "muon-secondary muon pairs");
784 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
785 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
786 >                                                                             "muon-secondary muon pairs");
787 >
788 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
789 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
790 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
791 >                                                                             "muon-secondary jet pairs");
792 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
793 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
794 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
795 >                                                                             "photon-secondary jet pairs");
796 >
797 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
798 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
799 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
800 >                                                                             "electron-secondary jet pairs");
801  
802          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
803 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
804 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
805 <                                                                   "electron-secondary electron pairs");
803 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
804 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
805 >                                                                                     "electron-secondary electron pairs");
806  
807          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
808                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 704 | Line 813 | OSUAnalysis::analyze (const edm::Event &
813                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
814                                                                         "electron-muon pairs");
815          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
816 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
817 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 <                                                                           "jet-jet pairs");
816 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
817 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 >                                                                 "jet-jet pairs");
819 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
820 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
821 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
822 >                                                                 "jet-secondary jet pairs");
823          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
824 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826 <                                                                       "electron-jet pairs");
824 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826 >                                                                      "electron-jet pairs");
827 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
828 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
829 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
830 >                                                                      "electron-photon pairs");
831 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
832 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
833 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
834 >                                                                      "photon-jet pairs");
835          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
836 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 <                                                                       "muon-jet pairs");
836 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 >                                                                  "muon-jet pairs");
839 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
840 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
841 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
842 >                                                                  "met-jet pairs");
843 >        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
844 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
845 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
846 >                                                                 "track-jet pairs");
847 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
848 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
849 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
850 >                                                                  "muon-photon pairs");
851          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
852                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
853                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 736 | Line 869 | OSUAnalysis::analyze (const edm::Event &
869                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
870                                                                   "tau-tau pairs");
871          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
872 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
873 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
874 <                                                                 "tau-track pairs");
872 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
873 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
874 >                                                                   "tau-track pairs");
875          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
876                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
877                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 756 | Line 889 | OSUAnalysis::analyze (const edm::Event &
889      }//end loop over all cuts
890      //use cumulative flags to apply cuts at event level
891  
759    bool eventPassedAllCuts = true;
892      //a vector to store cumulative cut descisions after each cut.
893      vector<bool> eventPassedPreviousCuts;
894 +    bool eventPassedAllCuts = true;
895      //apply trigger (true if none were specified)
896      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
897  
765
898      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
899  
900        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 770 | Line 902 | OSUAnalysis::analyze (const edm::Event &
902        int numberPassing = 0;
903  
904        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
905 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
905 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
906        }
907        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
908        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 779 | Line 911 | OSUAnalysis::analyze (const edm::Event &
911      }
912      double scaleFactor = masterScaleFactor;
913  
914 <    muonScaleFactor_ = electronScaleFactor_ = 1.0;
914 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
915      if(applyLeptonSF_ && datasetType_ != "data"){
916        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
917 <        vector<bool> muonFlags;
917 >        flagPair muonFlags;
918          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
919            if (cumulativeFlags.at("muons").at(i).size()){
920              muonFlags = cumulativeFlags.at("muons").at(i);
# Line 790 | Line 922 | OSUAnalysis::analyze (const edm::Event &
922            }
923          }
924          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
925 <          if(!muonFlags.at(muonIndex)) continue;
925 >          if(!muonFlags.at(muonIndex).second) continue;
926            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
927          }
928        }
929        if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
930 <        vector<bool> electronFlags;
930 >        flagPair electronFlags;
931          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
932            if (cumulativeFlags.at("electrons").at(i).size()){
933              electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 803 | Line 935 | OSUAnalysis::analyze (const edm::Event &
935            }
936          }
937          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
938 <          if(!electronFlags.at(electronIndex)) continue;
938 >          if(!electronFlags.at(electronIndex).second) continue;
939            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
940          }
941        }
942      }
943 +    if(applyBtagSF_ && datasetType_ != "data"){
944 +     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
945 +       flagPair jetFlags;
946 +        vector<double> jetSFs;
947 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
948 +          if (cumulativeFlags.at("jets").at(i).size()){
949 +            jetFlags = cumulativeFlags.at("jets").at(i);
950 +            break;
951 +          }
952 +        }
953 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
954 +          if(!jetFlags.at(jetIndex).second) continue;
955 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
956 +          jetSFs.push_back(jetSFTmp);
957 +        }
958 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
959 +      }
960 +    }
961      scaleFactor *= muonScaleFactor_;
962      scaleFactor *= electronScaleFactor_;
963 <
963 >    scaleFactor *= bTagScaleFactor_;
964      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
965  
816
966      if (printEventInfo_) {
967        // Write information about event to screen, for testing purposes.
968        cout << "Event passed all cuts in channel " <<  currentChannel.name
# Line 824 | Line 973 | OSUAnalysis::analyze (const edm::Event &
973      }
974  
975  
827
976      //filling histograms
977      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830
978        uint currentDir;
979 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
980 <      else currentDir = currentCut;
979 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
980 >      else{
981 >        currentDir = currentCut;
982 >      }
983  
835      if(!eventPassedPreviousCuts.at(currentDir)) continue;
984  
985 +      if(eventPassedPreviousCuts.at(currentDir)){
986  
987 <      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
988 <        histogram currentHistogram = histograms.at(histogramIndex);
987 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
988 >          histogram currentHistogram = histograms.at(histogramIndex);
989  
990 <        if(currentHistogram.inputVariables.size() == 1){
991 <          TH1D* histo;
992 <          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
993 <
994 <          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
995 <          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
996 <          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
997 <          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
998 <          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
999 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1000 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1001 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1002 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1003 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1004 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1005 <          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1006 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1007 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1008 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1009 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1010 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1011 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1012 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1013 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1014 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1015 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1016 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1017 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1018 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1019 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1020 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1021 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1022 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1023 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1024 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1025 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1026 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1027 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1028 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1029 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1030 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1031 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1032 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1033 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1034 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1035 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1036 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1037 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1038 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1039 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1040 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1041 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1042 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1043 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1044 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1045 <          
1046 <          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1047 <          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1048 <          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1049 <          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1050 <          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1051 <          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1052 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1053 <          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1054 <          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1055 <          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1056 <          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1057 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1058 <        }
1059 <        else if(currentHistogram.inputVariables.size() == 2){
1060 <          TH2D* histo;
1061 <          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1062 <
1063 <          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1064 <          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1065 <          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1066 <          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1067 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1068 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1069 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1070 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1071 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1072 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1073 <          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1074 <          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1075 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1076 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1077 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1078 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1079 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1080 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1081 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1082 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1083 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1084 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1085 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1086 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1087 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1088 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1089 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1090 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1091 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1092 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1093 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1094 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1095 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1096 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1097 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1098 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1099 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1100 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1101 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1102 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1103 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1104 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1105 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1106 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1107 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1108 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1109 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1110 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1111 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1112 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1113 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1114 <          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1115 <          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1116 <          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1117 <          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1118 <          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1119 <                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1120 <                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1121 <          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1122 <          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1123 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1124 <          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1125 <          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1126 <          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1127 <          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1128 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1129 <        }
1130 <      }
990 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
991 >
992 >          if(currentHistogram.inputVariables.size() == 1){
993 >            TH1D* histo;
994 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
995 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
996 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
997 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
998 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
999 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1000 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1001 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1002 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1003 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1004 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1005 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1006 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1007 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1008 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1009 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1010 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1011 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1012 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1013 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1014 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1015 >
1016 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1017 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1018 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1019 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1020 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1021 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1022 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1023 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1024 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1025 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1026 >
1027 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1028 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1029 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1030 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1031 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1032 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1033 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1034 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1035 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1036 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1037 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1038 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1039 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1040 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1041 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1042 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1043 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1044 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1045 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1046 >                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1047 >                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1048 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1049 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1050 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1051 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1052 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1053 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1054 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1055 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1056 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1057 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1058 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1059 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1060 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1061 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1062 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1063 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1064 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1065 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1066 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1067 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1068 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1069 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1070 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1071 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1072 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1073 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1074 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1075 >
1076 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1077 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1078 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1079 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1080 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1081 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1082 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1083 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1084 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1085 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1086 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1087 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1088 >          }
1089 >          else if(currentHistogram.inputVariables.size() == 2){
1090 >            TH2D* histo;
1091 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1092 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1093 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1094 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1095 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1096 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1097 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1098 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1099 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1100 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1101 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1102 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1103 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1104 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1105 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1106 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1107 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1108 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1109 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1110 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1111 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1112 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1113 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1114 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1115 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1116 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1117 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1118 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1119 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1120 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1121 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1122 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1123 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1124 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1125 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1126 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1127 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1128 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1129 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1130 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1131 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1132 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1133 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1134 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1135 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1136 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1137 >            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1138 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1139 >                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1140 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1141 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1142 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1143 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1144 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1145 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1146 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1147 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1148 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1149 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1150 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1151 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1152 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1153 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1154 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1156 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1157 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1159 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1160 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1161 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1162 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1163 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1164 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1165 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1166 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1167 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1168 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1169 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1170 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1171 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1172 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1173 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1174 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1175 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1176 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1177 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1178 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1179 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1180 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1181 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1182 >          }
1183  
1184 <      //fills histograms with the sizes of collections
1184 >        }
1185  
1186 <      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1187 <        
1188 <        string currentObject = objectsToPlot.at(currentObjectIndex);
1189 <        string objectToPlot = "";
1190 <        
1191 <        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1192 <        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1193 <        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1194 <        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1195 <        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1196 <        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1197 <        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1198 <        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1199 <        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1200 <        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1201 <        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1202 <        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1203 <        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1204 <        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1205 <        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1206 <        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1207 <        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1208 <        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1209 <        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1210 <        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1211 <        else objectToPlot = currentObject;
1212 <        
1213 <        string tempCurrentObject = objectToPlot;
1214 <        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1215 <        string histoName = "num" + tempCurrentObject;
1216 <        
1217 <
1218 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1219 <
1220 <        //count the number of objects passing all cuts
1221 <        int numToPlot = 0;
1222 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1223 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1224 <        }
1225 <
1226 <        if(objectToPlot == "primaryvertexs"){
1227 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1228 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1229 <        }
1230 <        else {
1231 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1232 <        }
1233 <      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1186 >
1187 >        //fills histograms with the sizes of collections
1188 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1189 >
1190 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1191 >          string objectToPlot = "";
1192 >
1193 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1194 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1195 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1196 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1197 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1198 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1199 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1200 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1201 >          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1202 >          else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1203 >          else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1204 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1205 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1206 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1207 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1208 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1209 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1210 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1211 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1212 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1213 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1214 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1215 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1216 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1217 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1218 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1219 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1220 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1221 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1222 >          else objectToPlot = currentObject;
1223 >
1224 >          string tempCurrentObject = objectToPlot;
1225 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1226 >          string histoName = "num" + tempCurrentObject;
1227 >
1228 >
1229 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1230 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1231 >            int numToPlot = 0;
1232 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1233 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1234 >            }
1235 >
1236 >            if(objectToPlot == "primaryvertexs"){
1237 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1238 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1239 >            }
1240 >            else {
1241 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1242 >            }
1243 >          }
1244 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1245 >
1246 >
1247 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1248 >    } // end loop over cuts
1249 >
1250 >    if (!useEDMFormat_ && eventPassedAllCuts){
1251 >      // Assign BNTree variables
1252 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1253 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1254 >        string coll = brSpecs.inputCollection;
1255 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1256 >
1257 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1258 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1259 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1260 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1261 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1262 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1263 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1264 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1265 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1266 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1267 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1268 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1269 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1270 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1271 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1272 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1273 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1274 >        else if(coll == "stops"
1275 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1276 >      } // end loop over branches
1277 >
1278 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1279 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1280      }
1281  
1282 <  } //end loop over channel
1282 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1283 >
1284 >  } // end loop over channel
1285  
1286    masterCutFlow_->fillCutFlow(masterScaleFactor);
1287  
1288 +  event.put (channelDecisions, "channelDecisions");
1289 +
1290   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1291  
1292  
# Line 1076 | Line 1327 | OSUAnalysis::evaluateTriggers (vector<st
1327    //initialize to false until a chosen trigger is passed
1328    bool triggerDecision = false;
1329  
1330 +  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1331    //loop over all triggers defined in the event
1332    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1333  
1334 +    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1335 +
1336      //we're only interested in triggers that actually passed
1337      if(trigger->pass != 1) continue;
1338  
# Line 1089 | Line 1343 | OSUAnalysis::evaluateTriggers (vector<st
1343      //if the event passes one of the chosen triggers, set triggerDecision to true
1344      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1345        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1346 <    }  
1346 >    }
1347    }
1348 <  //if none of the veto triggers fired:
1348 >
1349 >  printAllTriggers_ = false;  // only print triggers once, not every event
1350 >
1351 >  //if none of the veto triggers fired:
1352    //return the OR of all the chosen triggers
1353    if (triggersToTest.size() != 0) return triggerDecision;
1354    //or if no triggers were defined return true
# Line 1260 | Line 1517 | OSUAnalysis::valueLookup (const BNjet* o
1517    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1518    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1519  
1520 +  //user defined variable
1521 +  else if(variable == "disappTrkLeadingJetID") {
1522 +    value = object->pt > 110
1523 +      && fabs(object->eta) < 2.4
1524 +      && object->chargedHadronEnergyFraction > 0.2
1525 +      && object->neutralHadronEnergyFraction < 0.7
1526 +      && object->chargedEmEnergyFraction < 0.5
1527 +      && object->neutralEmEnergyFraction < 0.7;
1528 +  }
1529 +
1530 +  else if(variable == "disappTrkSubLeadingJetID") {
1531 +    value = object->pt > 30
1532 +      && fabs(object->eta) < 4.5
1533 +      && object->neutralHadronEnergyFraction < 0.7
1534 +      && object->chargedEmEnergyFraction < 0.5;
1535 +  }
1536 +
1537 +  else if(variable == "dPhiMet") {
1538 +    if (const BNmet *met = chosenMET ()) {
1539 +      value = deltaPhi (object->phi, met->phi);
1540 +    } else value = -999;
1541 +  }
1542 +
1543  
1544    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1545  
1546    value = applyFunction(function, value);
1547  
1548    return value;
1549 < }
1549 > } // end jet valueLookup
1550  
1551  
1552   //!muon valueLookup
# Line 1426 | Line 1706 | OSUAnalysis::valueLookup (const BNmuon*
1706    else if(variable == "time_ndof") value = object->time_ndof;
1707  
1708    //user-defined variables
1709 +  else if(variable == "looseID") {
1710 +    value = object->pt > 10 &&
1711 +      (object->isGlobalMuon  > 0 ||
1712 +       object->isTrackerMuon > 0);
1713 +  }
1714    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1715    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1716    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
# Line 1553 | Line 1838 | OSUAnalysis::valueLookup (const BNmuon*
1838      value = object->isGlobalMuon > 0                \
1839        && object->isPFMuon > 0                        \
1840        && object->normalizedChi2 < 10                \
1841 <                                  && object->numberOfValidMuonHits > 0        \
1841 >      && object->numberOfValidMuonHits > 0        \
1842        && object->numberOfMatchedStations > 1        \
1843        && fabs(object->correctedD0Vertex) < 0.2        \
1844        && fabs(object->correctedDZ) < 0.5        \
# Line 1564 | Line 1849 | OSUAnalysis::valueLookup (const BNmuon*
1849      value = object->isGlobalMuon > 0                \
1850        && object->isPFMuon > 0                        \
1851        && object->normalizedChi2 < 10                \
1852 <                                  && object->numberOfValidMuonHits > 0        \
1852 >      && object->numberOfValidMuonHits > 0        \
1853        && object->numberOfMatchedStations > 1        \
1854        && object->numberOfValidPixelHits > 0        \
1855        && object->numberOfLayersWithMeasurement > 5;
# Line 1619 | Line 1904 | OSUAnalysis::valueLookup (const BNmuon*
1904      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1905      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1906      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1907 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1908 <         || fabs (object->correctedDZ / dzError) > 99.0;
1907 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1908 >      || fabs (object->correctedDZ / dzError) > 99.0;
1909      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1910    }
1911  
# Line 1631 | Line 1916 | OSUAnalysis::valueLookup (const BNmuon*
1916    value = applyFunction(function, value);
1917  
1918    return value;
1919 < }
1919 > } // end muon valueLookup
1920 >
1921  
1922   //!electron valueLookup
1923   double
# Line 1896 | Line 2182 | OSUAnalysis::valueLookup (const BNelectr
2182        }
2183    }
2184  
2185 +  else if(variable == "looseID"){
2186 +    value = object->pt > 10
2187 +      && object->mvaNonTrigV0 > 0;
2188 +      }
2189    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2190      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2191      else value = -999;
# Line 2019 | Line 2309 | OSUAnalysis::valueLookup (const BNelectr
2309      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2310      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2311      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2312 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2313 <         || fabs (object->correctedDZ / dzError) > 99.0;
2312 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2313 >      || fabs (object->correctedDZ / dzError) > 99.0;
2314      value = !value;
2315    }
2316  
# Line 2031 | Line 2321 | OSUAnalysis::valueLookup (const BNelectr
2321    value = applyFunction(function, value);
2322  
2323    return value;
2324 < }
2324 > } // end electron valueLookup
2325 >
2326  
2327   //!event valueLookup
2328   double
# Line 2112 | Line 2403 | OSUAnalysis::valueLookup (const BNevent*
2403    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2404    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2405    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2406 <
2406 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2407    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2408  
2409    value = applyFunction(function, value);
2410  
2411    return value;
2412 < }
2412 > } // end event valueLookup
2413 >
2414  
2415   //!tau valueLookup
2416   double
# Line 2166 | Line 2458 | OSUAnalysis::valueLookup (const BNtau* o
2458    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2459    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2460  
2461 <
2461 >  else if (variable == "looseHadronicID") {
2462 >    value = object->pt > 10
2463 >      && object->eta < 2.3
2464 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2465 >      && object->HPSdecayModeFinding > 0
2466 >      && object->HPSagainstElectronLoose > 0
2467 >      && object->HPSagainstMuonTight > 0;
2468 >  }
2469  
2470    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2471  
# Line 2218 | Line 2517 | OSUAnalysis::valueLookup (const BNtau* o
2517    value = applyFunction(function, value);
2518  
2519    return value;
2520 < }
2520 > } // end tau valueLookup
2521 >
2522  
2523   //!met valueLookup
2524   double
# Line 2291 | Line 2591 | OSUAnalysis::valueLookup (const BNmet* o
2591    value = applyFunction(function, value);
2592  
2593    return value;
2594 < }
2594 > } // end met valueLookup
2595 >
2596  
2597   //!track valueLookup
2598   double
# Line 2319 | Line 2620 | OSUAnalysis::valueLookup (const BNtrack*
2620    else if(variable == "numValidHits") value = object->numValidHits;
2621    else if(variable == "isHighPurity") value = object->isHighPurity;
2622  
2322
2623    //additional BNs info for disappTrks
2624 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2625 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2626 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2627 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2628 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2629 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2630 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2631 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2332 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2624 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2625 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2626 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2627 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2628 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2629 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2630 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2631 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2632    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2633 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2633 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2634 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2635 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2636 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2637 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2638 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2639 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2640 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2641 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2642 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2643 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2644 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2645 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2646 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2647 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2648 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2649 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2650 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2651  
2652    //user defined variables
2653    else if(variable == "d0wrtBS") value = (object->vx-events->at(0).BSx)*object->py/object->pt - (object->vy-events->at(0).BSy)*object->px/object->pt;
# Line 2364 | Line 2680 | OSUAnalysis::valueLookup (const BNtrack*
2680        pt = object->pt;
2681      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2682    }
2683 +
2684 +
2685    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2686  
2687    else if(variable == "genMatchedPdgId"){
# Line 2416 | Line 2734 | OSUAnalysis::valueLookup (const BNtrack*
2734    value = applyFunction(function, value);
2735  
2736    return value;
2737 < }
2737 > } // end track valueLookup
2738 >
2739  
2740   //!genjet valueLookup
2741   double
# Line 2579 | Line 2898 | OSUAnalysis::valueLookup (const BNmcpart
2898    value = applyFunction(function, value);
2899  
2900    return value;
2901 < }
2901 > } // end mcparticle valueLookup
2902 >
2903  
2904   //!primaryvertex valueLookup
2905   double
# Line 2758 | Line 3078 | OSUAnalysis::valueLookup (const BNphoton
3078    value = applyFunction(function, value);
3079  
3080    return value;
3081 < }
3081 > } // end photon valueLookup
3082 >
3083  
3084   //!supercluster valueLookup
3085   double
# Line 2886 | Line 3207 | OSUAnalysis::valueLookup (const BNmuon*
3207    value = applyFunction(function, value);
3208  
3209    return value;
3210 + } // end muon-muon pair valueLookup
3211 +
3212 +
3213 + //!muon-photon pair valueLookup
3214 + double
3215 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3216 +
3217 +  double value = 0.0;
3218 +
3219 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3220 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3221 +  else if(variable == "photonEta") value = object2->eta;
3222 +  else if(variable == "muonEta") value = object1->eta;
3223 +  else if(variable == "photonPhi") value = object2->phi;
3224 +  else if(variable == "muonPhi") value = object1->phi;
3225 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3226 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3227 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3228 +  else if(variable == "invMass"){
3229 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3230 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3231 +    value = (fourVector1 + fourVector2).M();
3232 +  }
3233 +  else if(variable == "pt"){
3234 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3235 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3236 +    value = (fourVector1 + fourVector2).Pt();
3237 +  }
3238 +  else if(variable == "threeDAngle")
3239 +    {
3240 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3241 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3242 +      value = (threeVector1.Angle(threeVector2));
3243 +    }
3244 +  else if(variable == "alpha")
3245 +    {
3246 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3247 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3248 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3249 +      value = (pi-threeVector1.Angle(threeVector2));
3250 +    }
3251 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3252 +
3253 +  value = applyFunction(function, value);
3254 +
3255 +  return value;
3256 + }
3257 +
3258 + //!electron-photon pair valueLookup
3259 + double
3260 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3261 +
3262 +  double value = 0.0;
3263 +
3264 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3265 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3266 +  else if(variable == "photonEta") value = object2->eta;
3267 +  else if(variable == "electronEta") value = object1->eta;
3268 +  else if(variable == "photonPhi") value = object2->phi;
3269 +  else if(variable == "electronPhi") value = object1->phi;
3270 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3271 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3272 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3273 +  else if(variable == "invMass"){
3274 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3275 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3276 +    value = (fourVector1 + fourVector2).M();
3277 +  }
3278 +  else if(variable == "pt"){
3279 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3280 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3281 +    value = (fourVector1 + fourVector2).Pt();
3282 +  }
3283 +  else if(variable == "threeDAngle")
3284 +    {
3285 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3286 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3287 +      value = (threeVector1.Angle(threeVector2));
3288 +    }
3289 +  else if(variable == "alpha")
3290 +    {
3291 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3292 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3293 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3294 +      value = (pi-threeVector1.Angle(threeVector2));
3295 +    }
3296 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3297 +
3298 +  value = applyFunction(function, value);
3299 +
3300 +  return value;
3301   }
3302  
3303   //!electron-electron pair valueLookup
# Line 2943 | Line 3355 | OSUAnalysis::valueLookup (const BNelectr
3355  
3356    return value;
3357   }
3358 +
3359   //!electron-muon pair valueLookup
3360   double
3361   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3007 | Line 3420 | OSUAnalysis::valueLookup (const BNelectr
3420    value = applyFunction(function, value);
3421  
3422    return value;
3423 < }
3423 > } // end electron-muon pair valueLookup
3424 >
3425  
3426   //!electron-jet pair valueLookup
3427   double
# Line 3017 | Line 3431 | OSUAnalysis::valueLookup (const BNelectr
3431  
3432    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3433    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3434 +  else if(variable == "jetEta") value = object2->eta;
3435 +  else if(variable == "jetPhi") value = object2->phi;
3436 +  else if(variable == "electronEta") value = object1->eta;
3437 +  else if(variable == "electronPhi") value = object1->phi;
3438    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3439    else if(variable == "invMass"){
3440      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3044 | Line 3462 | OSUAnalysis::valueLookup (const BNelectr
3462    return value;
3463   }
3464  
3465 + //!photon-jet pair valueLookup
3466 + double
3467 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3468 +
3469 +  double value = 0.0;
3470 +
3471 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3472 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3473 +  else if(variable == "jetEta") value = object2->eta;
3474 +  else if(variable == "jetPhi") value = object2->phi;
3475 +  else if(variable == "photonEta") value = object1->eta;
3476 +  else if(variable == "photonPhi") value = object1->phi;
3477 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3478 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3479 +  else if(variable == "invMass"){
3480 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3481 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3482 +    value = (fourVector1 + fourVector2).M();
3483 +  }
3484 +  else if(variable == "pt"){
3485 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3486 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3487 +    value = (fourVector1 + fourVector2).Pt();
3488 +  }
3489 +  else if(variable == "threeDAngle")
3490 +    {
3491 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3492 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3493 +      value = (threeVector1.Angle(threeVector2));
3494 +    }
3495 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3496 +  value = applyFunction(function, value);
3497 +
3498 +  return value;
3499 + }
3500 +
3501 + // track-jet pair valueLookup
3502 + double
3503 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3504 +
3505 +  double value = 0.0;
3506 +
3507 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3508 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3509 +
3510 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3511 +  value = applyFunction(function, value);
3512 +
3513 +  return value;
3514 +
3515 + }
3516 +
3517 +
3518 +
3519 + // met-jet pair valueLookup
3520 + double
3521 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3522 +
3523 +  double value = 0.0;
3524 +
3525 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3526 +
3527 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3528 +  value = applyFunction(function, value);
3529 +
3530 +  return value;
3531 +
3532 + }  
3533 +
3534 +
3535 +
3536   //!muon-jet pair valueLookup
3537   double
3538   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3051 | Line 3540 | OSUAnalysis::valueLookup (const BNmuon*
3540    double value = 0.0;
3541  
3542    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3543 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3543 >  else if(variable == "jetEta") value = object2->eta;
3544 >  else if(variable == "jetPhi") value = object2->phi;
3545 >  else if(variable == "muonEta") value = object1->eta;
3546 >  else if(variable == "muonPhi") value = object1->phi;
3547 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3548    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3549    else if(variable == "invMass"){
3550      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3078 | Line 3571 | OSUAnalysis::valueLookup (const BNmuon*
3571  
3572    return value;
3573   }
3081
3574   //!jet-jet pair valueLookup
3575   double
3576   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3114 | Line 3606 | OSUAnalysis::valueLookup (const BNjet* o
3606  
3607    return value;
3608   }
3609 +
3610   //!electron-track pair valueLookup
3611   double
3612   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3381 | Line 3874 | OSUAnalysis::valueLookup (const BNstop*
3874      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3875        vertex_rank++;
3876        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3877 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3878 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3877 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3878 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3879  
3880        if(abs(dist) < abs(minDistToVertex)){
3881          value = vertex_rank;
# Line 3400 | Line 3893 | OSUAnalysis::valueLookup (const BNstop*
3893  
3894    return value;
3895  
3896 < }
3896 > } // end stop valueLookup
3897 >
3898  
3899  
3900  
# Line 3546 | Line 4040 | void OSUAnalysis::setObjectFlags(cut &cu
4040      string obj1, obj2;
4041      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4042      if (inputType==obj1 ||
4043 <          inputType==obj2) {
4043 >        inputType==obj2) {
4044        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4045        // and the inputType is a member of the pair.
4046        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3558 | Line 4052 | void OSUAnalysis::setObjectFlags(cut &cu
4052  
4053    for (uint object = 0; object != inputCollection->size(); object++){
4054  
4055 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4055 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4056 >    bool plotDecision = true;
4057  
4058      if(currentCut.inputCollection == inputType){
4059  
# Line 3570 | Line 4065 | void OSUAnalysis::setObjectFlags(cut &cu
4065          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4066  
4067        }
4068 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4068 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4069        else{
4070          bool tempDecision = true;
4071          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3579 | Line 4074 | void OSUAnalysis::setObjectFlags(cut &cu
4074            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4075              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4076          }
4077 <        decision = tempDecision;
4077 >        cutDecision = tempDecision;
4078        }
4079 +      //invert the cut for plotting if this cut is a veto
4080 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4081 +      else plotDecision = cutDecision;
4082      }
4083  
4084 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4084 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4085  
4086 <    //set flags for objects that pass each cut AND all the previous cuts
4087 <    bool previousCumulativeFlag = true;
4086 >    //set flags for objects that pass this cut AND all the previous cuts
4087 >    bool previousCumulativeCutFlag = true;
4088 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4089 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4090 >      else{ previousCumulativeCutFlag = false; break;}
4091 >    }
4092 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4093 >    bool previousCumulativePlotFlag = true;
4094      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4095 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4096 <      else{ previousCumulativeFlag = false; break;}
4095 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4096 >      else{ previousCumulativePlotFlag = false; break;}
4097      }
4098 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4098 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4099 >
4100 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4101  
4102    }
4103  
# Line 3600 | Line 4106 | void OSUAnalysis::setObjectFlags(cut &cu
4106  
4107   template <class InputCollection1, class InputCollection2>
4108   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4109 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4109 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4110  
4111  
4112    bool sameObjects = false;
# Line 3616 | Line 4122 | void OSUAnalysis::setObjectFlags(cut &cu
4122    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4123    if (currentCut.inputCollection == inputType) {
4124      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4125 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4126 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4125 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4126 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4127      }
4128      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4129        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4130 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4131 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4130 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4131 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4132        }
4133      }
4134    }
# Line 3635 | Line 4141 | void OSUAnalysis::setObjectFlags(cut &cu
4141        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4142  
4143  
4144 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4144 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4145 >      bool plotDecision = true;
4146  
4147        if(currentCut.inputCollection == inputType){
4148  
# Line 3647 | Line 4154 | void OSUAnalysis::setObjectFlags(cut &cu
4154            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4155          }
4156  
4157 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4157 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4158          else{
4159            bool tempDecision = subcutDecisions.at(0);
4160            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3656 | Line 4163 | void OSUAnalysis::setObjectFlags(cut &cu
4163              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4164                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4165            }
4166 <          decision = tempDecision;
4166 >          cutDecision = tempDecision;
4167          }
4168 +        //invert the cut for plotting if this cut is a veto
4169 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4170 +        else plotDecision = cutDecision;
4171 +      }
4172 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4173 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4174 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4175 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4176 +      }
4177 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4178 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4179 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4180        }
4181 <      // if (decision) isPassObj1.at(object1) = true;
4182 <      // if (decision) isPassObj2.at(object2) = true;
4183 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4184 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4185 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4186 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4181 >
4182 >      //set flags for objects that pass this cut AND all the previous cuts
4183 >      bool previousCumulativeCutFlag = true;
4184 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4185 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4186 >        else{ previousCumulativeCutFlag = false; break;}
4187        }
4188 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4189  
4190 <      //set flags for objects that pass each cut AND all the previous cuts
3671 <      bool previousCumulativeFlag = true;
4190 >      bool previousCumulativePlotFlag = true;
4191        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4192 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4193 <        else{ previousCumulativeFlag = false; break;}
4192 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4193 >        else{ previousCumulativePlotFlag = false; break;}
4194        }
4195 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4196 +      
4197        //apply flags for the components of the composite object as well
4198 <      bool currentCumulativeFlag = true;
4199 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4200 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4201 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4202 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4203 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4204 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4205 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4206 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4198 >      bool currentCumulativeCutFlag = true;
4199 >      bool currentCumulativePlotFlag = true;
4200 >
4201 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4202 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4203 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4204 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4205 >
4206 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4207 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4208 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4209 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4210 >
4211 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4212 >
4213 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4214 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4215 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4216 >      }
4217 >
4218 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4219 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4220 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4221        }
4222 +
4223        counter++;
4224  
4225      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3692 | Line 4228 | void OSUAnalysis::setObjectFlags(cut &cu
4228   }
4229  
4230  
4231 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4231 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4232    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4233    // all cuts up to currentCutIndex
4234    bool previousCumulativeFlag = true;
4235    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4236 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4236 >    bool tempFlag = false;
4237 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4238 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4239 >
4240 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4241      else {
4242        previousCumulativeFlag = false; break;
4243      }
# Line 3706 | Line 4246 | bool OSUAnalysis::getPreviousCumulativeF
4246   }
4247  
4248  
4249 +
4250 +
4251 + template <class InputCollection>
4252 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4253 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4254 +
4255 +  if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;
4256 +  for (uint object = 0; object != inputCollection->size(); object++) {
4257 +
4258 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4259 +
4260 +    string inputVariable = parameters.inputVariable;
4261 +    string function = "";
4262 +    string stringValue = "";
4263 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4264 +    BNTreeBranchVals_.at(parameters.name).push_back(value);
4265 +
4266 +  }
4267 + }
4268 +
4269 +
4270   template <class InputCollection>
4271 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4271 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4272 >
4273  
4274    for (uint object = 0; object != inputCollection->size(); object++){
4275  
4276 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4276 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4277  
4278      string currentString = parameters.inputVariables.at(0);
4279      string inputVariable = "";
# Line 3728 | Line 4290 | void OSUAnalysis::fill1DHistogram(TH1* h
4290      string stringValue = "";
4291      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4292      histo->Fill(value,scaleFactor);
4293 +
4294      if (printEventInfo_) {
4295        // Write information about event to screen, for testing purposes.
4296        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3737 | Line 4300 | void OSUAnalysis::fill1DHistogram(TH1* h
4300   }
4301  
4302   template <class InputCollection1, class InputCollection2>
4303 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4303 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4304  
4305    bool sameObjects = false;
4306    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3750 | Line 4313 | void OSUAnalysis::fill1DHistogram(TH1* h
4313  
4314        pairCounter++;
4315        //only take objects which have passed all cuts and pairs which have passed all cuts
4316 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4317 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4318 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4316 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4317 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4318 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4319  
4320        string currentString = parameters.inputVariables.at(0);
4321        string inputVariable = "";
# Line 3777 | Line 4340 | void OSUAnalysis::fill1DHistogram(TH1* h
4340  
4341  
4342   template <class InputCollection>
4343 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4343 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4344  
4345    for (uint object = 0; object != inputCollection->size(); object++){
4346  
4347 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4347 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4348  
4349      string stringValue = "";
4350      string currentString = parameters.inputVariables.at(0);
# Line 3818 | Line 4381 | void OSUAnalysis::fill2DHistogram(TH2* h
4381   }
4382  
4383   template <class InputCollection1, class InputCollection2>
4384 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4384 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4385  
4386    bool sameObjects = false;
4387    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3832 | Line 4395 | void OSUAnalysis::fill2DHistogram(TH2* h
4395        pairCounter++;
4396  
4397        //only take objects which have passed all cuts and pairs which have passed all cuts
4398 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4399 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4400 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4398 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4399 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4400 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4401  
4402        string stringValue = "";
4403        string currentString = parameters.inputVariables.at(0);
# Line 3994 | Line 4557 | OSUAnalysis::chosenVertex ()
4557   {
4558    const BNprimaryvertex *chosenVertex = 0;
4559    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4560 <    vector<bool> vertexFlags;
4560 >    flagPair vertexFlags;
4561      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4562        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4563          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4002 | Line 4565 | OSUAnalysis::chosenVertex ()
4565        }
4566      }
4567      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4568 <      if(!vertexFlags.at(vertexIndex)) continue;
4568 >      if(!vertexFlags.at(vertexIndex).first) continue;
4569        chosenVertex = & primaryvertexs->at(vertexIndex);
4570        break;
4571      }
# Line 4018 | Line 4581 | OSUAnalysis::chosenMET ()
4581   {
4582    const BNmet *chosenMET = 0;
4583    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4584 <    vector<bool> metFlags;
4584 >    flagPair metFlags;
4585      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4586        if (cumulativeFlags.at("mets").at(i).size()){
4587          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4026 | Line 4589 | OSUAnalysis::chosenMET ()
4589        }
4590      }
4591      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4592 <      if(!metFlags.at(metIndex)) continue;
4592 >      if(!metFlags.at(metIndex).first) continue;
4593        chosenMET = & mets->at(metIndex);
4594        break;
4595      }
# Line 4042 | Line 4605 | OSUAnalysis::chosenElectron ()
4605   {
4606    const BNelectron *chosenElectron = 0;
4607    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4608 <    vector<bool> electronFlags;
4608 >    flagPair electronFlags;
4609      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4610        if (cumulativeFlags.at("electrons").at(i).size()){
4611          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4050 | Line 4613 | OSUAnalysis::chosenElectron ()
4613        }
4614      }
4615      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4616 <      if(!electronFlags.at(electronIndex)) continue;
4616 >      if(!electronFlags.at(electronIndex).first) continue;
4617        chosenElectron = & electrons->at(electronIndex);
4618        break;
4619      }
# Line 4061 | Line 4624 | OSUAnalysis::chosenElectron ()
4624    return chosenElectron;
4625   }
4626  
4627 +
4628   const BNmuon *
4629   OSUAnalysis::chosenMuon ()
4630   {
4631    const BNmuon *chosenMuon = 0;
4632    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4633 <    vector<bool> muonFlags;
4633 >    flagPair muonFlags;
4634      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4635        if (cumulativeFlags.at("muons").at(i).size()){
4636          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4074 | Line 4638 | OSUAnalysis::chosenMuon ()
4638        }
4639      }
4640      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4641 <      if(!muonFlags.at(muonIndex)) continue;
4641 >      if(!muonFlags.at(muonIndex).first) continue;
4642        chosenMuon = & muons->at(muonIndex);
4643        break;
4644      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines