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.93 by wulsin, Wed Jul 3 07:42:46 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 == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
116 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
117 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
118      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
119      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
120      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 90 | Line 129 | OSUAnalysis::OSUAnalysis (const edm::Par
129        }
130        objectsToPlot.push_back(tempInputCollection);
131        objectsToCut.push_back(tempInputCollection);
132 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
132 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
133        string obj1;
134        string obj2;
135        getTwoObjs(tempInputCollection, obj1, obj2);
# Line 105 | Line 143 | OSUAnalysis::OSUAnalysis (const edm::Par
143        objectsToGet.push_back(tempInputCollection);
144        objectsToGet.push_back(obj1);
145        objectsToGet.push_back(obj2ToGet);
146 +    } // end else
147  
109    }
148  
149  
150      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 128 | Line 166 | OSUAnalysis::OSUAnalysis (const edm::Par
166        histograms.push_back(tempHistogram);
167  
168      }
169 <  }
169 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
170 >
171    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
172    sort( objectsToPlot.begin(), objectsToPlot.end() );
173    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 236 | Line 275 | OSUAnalysis::OSUAnalysis (const edm::Par
275      //create cutFlow for this channel
276      cutFlows_.push_back (new CutFlow (fs_, channelName));
277      vector<TFileDirectory> directories; //vector of directories in the output file.
278 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
279      vector<string> subSubDirNames;//subdirectories in each channel.
280      //get list of cuts for this channel
281      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 247 | Line 287 | OSUAnalysis::OSUAnalysis (const edm::Par
287        //store input collection for cut
288        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
289        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
290 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
291 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
292        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
293        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
294 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
295 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
296        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
297        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
298 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
299 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
300 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
301 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
302        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
303        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
304        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 320 | Line 368 | OSUAnalysis::OSUAnalysis (const edm::Par
368        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
369        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
370  
371 <      //Set up vectors to store the directories and subDIrectories for each channel.
371 >      //Set up vectors to store the directories and subDirectories for each channel.
372        string subSubDirName;
373        string tempCutName;
374        if(cuts_.at(currentCut).exists("alias")){
375          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
376 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
376 >        subSubDirName = "After " + tempCutName + " Cut Applied";
377        }
378        else{
379          //construct string for cutflow table
# Line 336 | Line 384 | OSUAnalysis::OSUAnalysis (const edm::Par
384          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
385        }
386  
387 +      tempCut.isVeto = false;
388 +      if(cuts_.at(currentCut).exists("isVeto")){
389 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
390 +        if (isVeto == true) tempCut.isVeto = true;
391 +      }
392        subSubDirNames.push_back(subSubDirName);
393        tempCut.name = tempCutName;
394  
# Line 350 | Line 403 | OSUAnalysis::OSUAnalysis (const edm::Par
403      TFileDirectory subDir = fs_->mkdir( channelName );
404      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
405      if(GetPlotsAfterEachCut_){
406 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
407 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
408 <            directories.push_back(subSubDir);
409 <            map<string, TH1D*> oneDhistoMap;
410 <            oneDHistsTmp.push_back(oneDhistoMap);
411 <            map<string, TH2D*> twoDhistoMap;
412 <            twoDHistsTmp.push_back(twoDhistoMap);
406 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
407 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
408 >        directories.push_back(subSubDir);
409 >        map<string, TH1D*> oneDhistoMap;
410 >        oneDHistsTmp.push_back(oneDhistoMap);
411 >        map<string, TH2D*> twoDhistoMap;
412 >        twoDHistsTmp.push_back(twoDhistoMap);
413        }
414 +      treeDirectories.push_back(subDir);
415        oneDHists_.push_back(oneDHistsTmp);
416        twoDHists_.push_back(twoDHistsTmp);
417      }
418 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
419 <   else{
418 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
419 >    else{
420        map<string, TH1D*> oneDhistoMap;
421        oneDHistsTmp.push_back(oneDhistoMap);
422        map<string, TH2D*> twoDhistoMap;
# Line 370 | Line 424 | OSUAnalysis::OSUAnalysis (const edm::Par
424        oneDHists_.push_back(oneDHistsTmp);
425        twoDHists_.push_back(twoDHistsTmp);
426        directories.push_back(subDir);
427 <   }
427 >      treeDirectories.push_back(subDir);
428 >
429 >    }
430 >
431 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
432 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
433 >      BNTrees_.push_back(newTree);
434 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
435 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
436 >        vector<float> newVec;
437 >        BNTreeBranchVals_[currentVar.name] = newVec;
438 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
439 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
440 >    }
441 >
442      //book all histograms included in the configuration
443      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
444 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
445 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
446 <      int numBinsElements = currentHistogram.bins.size();
447 <      int numInputVariables = currentHistogram.inputVariables.size();
448 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
449 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
450 <
451 <      if(numBinsElements == 1){
452 <        if(numBinEdgesX > 1){
453 <          if(numBinEdgesY > 1)
454 <            numBinsElements = 6;
444 >
445 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
446 >
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;
457 >            else
458 >              numBinsElements = 3;
459 >          }
460 >        }
461 >        if(numBinsElements != 3 && numBinsElements !=6){
462 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
463 >          exit(0);
464 >        }
465 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
466 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
467 >          exit(0);
468 >        }
469 >        else if(numBinsElements == 3){
470 >          if (currentHistogram.bins.size () == 3)
471 >            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));
472            else
473 <            numBinsElements = 3;
473 >            {
474 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
475 >            }
476          }
477 <      }
478 <      if(numBinsElements != 3 && numBinsElements !=6){
479 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
480 <        exit(0);
481 <      }
482 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
483 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
484 <        exit(0);
485 <      }
486 <      else if(numBinsElements == 3){
487 <        if (currentHistogram.bins.size () == 3)
488 <          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));
489 <        else
490 <          {
491 <            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 >        else if(numBinsElements == 6){
478 >          if (currentHistogram.bins.size () == 6)
479 >            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));
480 >          else
481 >            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 ());
482 >        }
483 >
484 >
485 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
486 >
487 >        // bin      particle type
488 >        // ---      -------------
489 >        //  0        unmatched
490 >        //  1        u
491 >        //  2        d
492 >        //  3        s
493 >        //  4        c
494 >        //  5        b
495 >        //  6        t
496 >        //  7        e
497 >        //  8        mu
498 >        //  9        tau
499 >        // 10        nu
500 >        // 11        g
501 >        // 12        gamma
502 >        // 13        Z
503 >        // 14        W
504 >        // 15        light meson
505 >        // 16        K meson
506 >        // 17        D meson
507 >        // 18        B meson
508 >        // 19        light baryon
509 >        // 20        strange baryon
510 >        // 21        charm baryon
511 >        // 22        bottom baryon
512 >        // 23        QCD string
513 >        // 24        other
514 >
515 >        vector<TString> labelArray;
516 >        labelArray.push_back("unmatched");
517 >        labelArray.push_back("u");
518 >        labelArray.push_back("d");
519 >        labelArray.push_back("s");
520 >        labelArray.push_back("c");
521 >        labelArray.push_back("b");
522 >        labelArray.push_back("t");
523 >        labelArray.push_back("e");
524 >        labelArray.push_back("#mu");
525 >        labelArray.push_back("#tau");
526 >        labelArray.push_back("#nu");
527 >        labelArray.push_back("g");
528 >        labelArray.push_back("#gamma");
529 >        labelArray.push_back("Z");
530 >        labelArray.push_back("W");
531 >        labelArray.push_back("light meson");
532 >        labelArray.push_back("K meson");
533 >        labelArray.push_back("D meson");
534 >        labelArray.push_back("B meson");
535 >        labelArray.push_back("light baryon");
536 >        labelArray.push_back("strange baryon");
537 >        labelArray.push_back("charm baryon");
538 >        labelArray.push_back("bottom baryon");
539 >        labelArray.push_back("QCD string");
540 >        labelArray.push_back("other");
541 >
542 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
543 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
544 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
545            }
546 <      }
547 <      else if(numBinsElements == 6){
548 <        if (currentHistogram.bins.size () == 6)
549 <          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));
550 <        else
551 <          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 ());
552 <      }
546 >          else {
547 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
548 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
549 >          }
550 >        }
551 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
552 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
553 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
554 >        }
555  
556 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
557  
415      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
558  
559 <      // bin      particle type
560 <      // ---      -------------
561 <      //  0        unmatched
562 <      //  1        u
563 <      //  2        d
564 <      //  3        s
565 <      //  4        c
566 <      //  5        b
567 <      //  6        t
568 <      //  7        e
569 <      //  8        mu
570 <      //  9        tau
571 <      // 10        nu
572 <      // 11        g
573 <      // 12        gamma
574 <      // 13        Z
575 <      // 14        W
576 <      // 15        light meson
577 <      // 16        K meson
578 <      // 17        D meson
579 <      // 18        B meson
580 <      // 19        light baryon
581 <      // 20        strange baryon
582 <      // 21        charm baryon
583 <      // 22        bottom baryon
584 <      // 23        QCD string
585 <      // 24        other
586 <
587 <      vector<TString> labelArray;
588 <      labelArray.push_back("unmatched");
589 <      labelArray.push_back("u");
590 <      labelArray.push_back("d");
591 <      labelArray.push_back("s");
592 <      labelArray.push_back("c");
593 <      labelArray.push_back("b");
594 <      labelArray.push_back("t");
595 <      labelArray.push_back("e");
596 <      labelArray.push_back("#mu");
597 <      labelArray.push_back("#tau");
598 <      labelArray.push_back("#nu");
599 <      labelArray.push_back("g");
600 <      labelArray.push_back("#gamma");
601 <      labelArray.push_back("Z");
602 <      labelArray.push_back("W");
603 <      labelArray.push_back("light meson");
604 <      labelArray.push_back("K meson");
605 <      labelArray.push_back("D meson");
464 <      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);
559 >      // Book a histogram for the number of each object type to be plotted.
560 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
561 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
562 >        string currentObject = objectsToPlot.at(currentObjectIndex);
563 >        int maxNum = 10;
564 >        if(currentObject == "mcparticles") maxNum = 50;
565 >        else if(currentObject == "primaryvertexs") maxNum = 50;
566 >
567 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
568 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
569 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
570 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
571 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
572 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
573 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
574 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
575 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
576 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
577 >        else if(currentObject == "photon-jet pairs")          currentObject = "photonJetPairs";
578 >        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
579 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
580 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
581 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
582 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
583 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
584 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
585 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
586 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
587 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
588 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
589 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
590 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
591 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
592 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
593 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
594 >
595 >        currentObject.at(0) = toupper(currentObject.at(0));
596 >        string histoName = "num" + currentObject;
597 >
598 >        if(histoName == "numPrimaryvertexs"){
599 >          string newHistoName = histoName + "BeforePileupCorrection";
600 >          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);
601 >          newHistoName = histoName + "AfterPileupCorrection";
602 >          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);
603 >        }
604 >        else
605 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
606        }
607 <      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
607 >    }//end of loop over directories
608      channels.push_back(tempChannel);
609      tempChannel.cuts.clear();
610    }//end loop over channels
# Line 538 | Line 617 | OSUAnalysis::OSUAnalysis (const edm::Par
617    sort( objectsToCut.begin(), objectsToCut.end() );
618    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
619  
620 +  produces<map<string, bool> > ("channelDecisions");
621 +
622 + } // end constructor OSUAnalysis::OSUAnalysis()
623  
542 }
624  
625   OSUAnalysis::~OSUAnalysis ()
626   {
627 +
628    // Destroying the CutFlow objects causes the cut flow numbers and time
629    // information to be printed to standard output.
630    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
631      delete cutFlows_.at(currentChannel);
632    }
633 +
634 +  cout << "=============================================" << endl;  
635 +  cout << "Successfully completed OSUAnalysis." << endl;  
636 +  cout << "=============================================" << endl;  
637 +
638   }
639  
640   void
641 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
641 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
642   {
556
643    // Retrieve necessary collections from the event.
644  
645    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 619 | Line 705 | OSUAnalysis::analyze (const edm::Event &
705    //get pile-up event weight
706    if (doPileupReweighting_ && datasetType_ != "data") {
707      //for "data" datasets, the numTruePV is always set to -1
708 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
709 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
708 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
709 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
710    }
711  
712    stopCTauScaleFactor_ = 1.0;
# Line 630 | Line 716 | OSUAnalysis::analyze (const edm::Event &
716  
717    //loop over all channels
718  
719 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
720    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
721      channel currentChannel = channels.at(currentChannelIndex);
722  
# Line 637 | Line 724 | OSUAnalysis::analyze (const edm::Event &
724      counterMap passingCounter;
725      cumulativeFlags.clear ();
726  
727 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
728 +         iter != BNTreeBranchVals_.end(); iter++) {
729 +      iter->second.clear();  // clear array
730 +    }
731 +
732      bool triggerDecision = true;
733      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
734        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 650 | Line 742 | OSUAnalysis::analyze (const edm::Event &
742          string currentObject = objectsToCut.at(currentObjectIndex);
743  
744          //initialize maps to get ready to set cuts
745 <        individualFlags[currentObject].push_back (vector<bool> ());
746 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
745 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
746 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
747  
748        }
749        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
# Line 686 | Line 778 | OSUAnalysis::analyze (const edm::Event &
778                                                                     "muon-muon pairs");
779  
780          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
781 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
782 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
783 <                                                                   "muon-secondary muon pairs");
781 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
782 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
783 >                                                                             "muon-secondary muon pairs");
784 >
785 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
786 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
787 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
788 >                                                                             "muon-secondary jet pairs");
789 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
790 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
791 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
792 >                                                                             "photon-secondary jet pairs");
793 >
794 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
795 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
796 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
797 >                                                                             "electron-secondary jet pairs");
798  
799          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
800 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
801 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
802 <                                                                   "electron-secondary electron pairs");
800 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
801 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
802 >                                                                                     "electron-secondary electron pairs");
803  
804          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
805                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 704 | Line 810 | OSUAnalysis::analyze (const edm::Event &
810                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
811                                                                         "electron-muon pairs");
812          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
813 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
814 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
815 <                                                                           "jet-jet pairs");
813 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
814 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
815 >                                                                 "jet-jet pairs");
816 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
817 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
819 >                                                                 "jet-secondary jet pairs");
820          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
821 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
822 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
823 <                                                                       "electron-jet pairs");
821 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
822 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
823 >                                                                      "electron-jet pairs");
824 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
825 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
826 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
827 >                                                                      "electron-photon pairs");
828 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
829 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
830 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
831 >                                                                      "photon-jet pairs");
832          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
833 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
834 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
835 <                                                                       "muon-jet pairs");
833 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
834 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
835 >                                                                  "muon-jet pairs");
836 >        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
837 >                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
838 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
839 >                                                                  "met-jet pairs");
840 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
841 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
842 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
843 >                                                                  "muon-photon pairs");
844          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
845                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
846                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 736 | Line 862 | OSUAnalysis::analyze (const edm::Event &
862                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
863                                                                   "tau-tau pairs");
864          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
865 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
866 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
867 <                                                                 "tau-track pairs");
865 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
866 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
867 >                                                                   "tau-track pairs");
868          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
869                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
870                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 756 | Line 882 | OSUAnalysis::analyze (const edm::Event &
882      }//end loop over all cuts
883      //use cumulative flags to apply cuts at event level
884  
759    bool eventPassedAllCuts = true;
885      //a vector to store cumulative cut descisions after each cut.
886      vector<bool> eventPassedPreviousCuts;
887 +    bool eventPassedAllCuts = true;
888      //apply trigger (true if none were specified)
889      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
890  
765
891      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
892  
893        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 770 | Line 895 | OSUAnalysis::analyze (const edm::Event &
895        int numberPassing = 0;
896  
897        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
898 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
898 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
899        }
900        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
901        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 779 | Line 904 | OSUAnalysis::analyze (const edm::Event &
904      }
905      double scaleFactor = masterScaleFactor;
906  
907 <    muonScaleFactor_ = electronScaleFactor_ = 1.0;
907 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
908      if(applyLeptonSF_ && datasetType_ != "data"){
909        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
910 <        vector<bool> muonFlags;
910 >        flagPair muonFlags;
911          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
912            if (cumulativeFlags.at("muons").at(i).size()){
913              muonFlags = cumulativeFlags.at("muons").at(i);
# Line 790 | Line 915 | OSUAnalysis::analyze (const edm::Event &
915            }
916          }
917          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
918 <          if(!muonFlags.at(muonIndex)) continue;
918 >          if(!muonFlags.at(muonIndex).second) continue;
919            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
920          }
921        }
922        if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
923 <        vector<bool> electronFlags;
923 >        flagPair electronFlags;
924          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
925            if (cumulativeFlags.at("electrons").at(i).size()){
926              electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 803 | Line 928 | OSUAnalysis::analyze (const edm::Event &
928            }
929          }
930          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
931 <          if(!electronFlags.at(electronIndex)) continue;
931 >          if(!electronFlags.at(electronIndex).second) continue;
932            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
933          }
934        }
935      }
936 +    if(applyBtagSF_ && datasetType_ != "data"){
937 +     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
938 +       flagPair jetFlags;
939 +        vector<double> jetSFs;
940 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
941 +          if (cumulativeFlags.at("jets").at(i).size()){
942 +            jetFlags = cumulativeFlags.at("jets").at(i);
943 +            break;
944 +          }
945 +        }
946 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
947 +          if(!jetFlags.at(jetIndex).second) continue;
948 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
949 +          jetSFs.push_back(jetSFTmp);
950 +        }
951 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
952 +      }
953 +    }
954      scaleFactor *= muonScaleFactor_;
955      scaleFactor *= electronScaleFactor_;
956 <
956 >    scaleFactor *= bTagScaleFactor_;
957      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
958  
816
959      if (printEventInfo_) {
960        // Write information about event to screen, for testing purposes.
961        cout << "Event passed all cuts in channel " <<  currentChannel.name
# Line 824 | Line 966 | OSUAnalysis::analyze (const edm::Event &
966      }
967  
968  
827
969      //filling histograms
970      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830
971        uint currentDir;
972 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
973 <      else currentDir = currentCut;
972 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
973 >      else{
974 >        currentDir = currentCut;
975 >      }
976  
835      if(!eventPassedPreviousCuts.at(currentDir)) continue;
977  
978 +      if(eventPassedPreviousCuts.at(currentDir)){
979  
980 <      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
981 <        histogram currentHistogram = histograms.at(histogramIndex);
980 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
981 >          histogram currentHistogram = histograms.at(histogramIndex);
982  
983 <        if(currentHistogram.inputVariables.size() == 1){
984 <          TH1D* histo;
985 <          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
986 <
987 <          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
988 <          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
989 <          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
990 <          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
991 <          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
992 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
993 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
994 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
995 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
996 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
997 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
998 <          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
999 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1000 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1001 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1002 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1003 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1004 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1005 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1006 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1007 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1008 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1009 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1010 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1011 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1012 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1013 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1014 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1015 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1016 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1017 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1018 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1019 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1020 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1021 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1022 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1023 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1024 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1025 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1026 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1027 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1028 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1029 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1030 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1031 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1032 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1033 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1034 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1035 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1036 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1037 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1038 <          
1039 <          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1040 <          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1041 <          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1042 <          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1043 <          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1044 <          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1045 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1046 <          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1047 <          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1048 <          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1049 <          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1050 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1051 <        }
1052 <        else if(currentHistogram.inputVariables.size() == 2){
1053 <          TH2D* histo;
1054 <          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1055 <
1056 <          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1057 <          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1058 <          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1059 <          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1060 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1061 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1062 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1063 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1064 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1065 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1066 <          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1067 <          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1068 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1069 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1070 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1071 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1072 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1073 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1074 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1075 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1076 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1077 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1078 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1079 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1080 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1081 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1082 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1083 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1084 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1085 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1086 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1087 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1088 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1089 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1090 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1091 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1092 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1093 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1094 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1095 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1096 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1097 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1098 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1099 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1100 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1101 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1102 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1103 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1104 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1105 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1106 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1107 <          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1108 <          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1109 <          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1110 <          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1111 <          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1112 <                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1113 <                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1114 <          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1115 <          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1116 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1117 <          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1118 <          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1119 <          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1120 <          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1121 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1122 <        }
1123 <      }
983 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
984 >
985 >          if(currentHistogram.inputVariables.size() == 1){
986 >            TH1D* histo;
987 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
988 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
989 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
990 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
991 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
992 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
993 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
994 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
995 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
996 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
997 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
998 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
999 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1000 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1001 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1002 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1003 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1004 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1005 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1006 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1007 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1008 >
1009 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1010 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1011 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1012 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1013 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1014 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1015 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1016 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1017 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1018 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1019 >
1020 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1021 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1022 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1023 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1024 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1025 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1026 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1027 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1028 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1029 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1030 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1031 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1032 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1033 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1034 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1035 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1036 >                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1037 >                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1038 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1039 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1040 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1041 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1042 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1043 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1044 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1045 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1046 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1047 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1048 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1049 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1050 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1051 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1052 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1053 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1054 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1055 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1056 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1057 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1058 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1059 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1060 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1061 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1062 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1063 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1064 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1065 >
1066 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1067 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1068 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1069 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1070 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1071 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1072 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1073 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1074 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1075 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1076 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1077 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1078 >          }
1079 >          else if(currentHistogram.inputVariables.size() == 2){
1080 >            TH2D* histo;
1081 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1082 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1083 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1084 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1085 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1086 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1087 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1088 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1089 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1090 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1091 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1092 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1093 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1094 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1095 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1096 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1097 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1098 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1099 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1100 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1101 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1102 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1103 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1104 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1105 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1106 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1107 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1108 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1109 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1110 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1111 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1112 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1113 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1114 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1115 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1116 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1117 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1118 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1119 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1120 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1121 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1122 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1123 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1124 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1125 >                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1126 >                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1127 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1128 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1129 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1130 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1131 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1132 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1133 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1134 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1135 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1136 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1137 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1138 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1140 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1141 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1142 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1143 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1144 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1145 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1146 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1147 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1148 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1149 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1150 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1151 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1152 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1153 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1154 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1155 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1156 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1157 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1158 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1159 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1160 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1161 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1162 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1163 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1164 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1165 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1166 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1167 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1168 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1169 >          }
1170 >
1171 >        }
1172  
983      //fills histograms with the sizes of collections
1173  
1174 <      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1175 <        
1176 <        string currentObject = objectsToPlot.at(currentObjectIndex);
1177 <        string objectToPlot = "";
1178 <        
1179 <        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1180 <        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1181 <        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1182 <        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1183 <        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1184 <        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1185 <        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1186 <        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1187 <        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1188 <        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1189 <        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1190 <        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1191 <        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1192 <        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1193 <        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1194 <        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1195 <        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1196 <        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1197 <        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1198 <        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1199 <        else objectToPlot = currentObject;
1200 <        
1201 <        string tempCurrentObject = objectToPlot;
1202 <        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1203 <        string histoName = "num" + tempCurrentObject;
1204 <        
1205 <
1206 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1207 <
1208 <        //count the number of objects passing all cuts
1209 <        int numToPlot = 0;
1210 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1211 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1212 <        }
1213 <
1214 <        if(objectToPlot == "primaryvertexs"){
1215 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1216 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1217 <        }
1218 <        else {
1219 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1220 <        }
1221 <      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1174 >        //fills histograms with the sizes of collections
1175 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1176 >
1177 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1178 >          string objectToPlot = "";
1179 >
1180 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1181 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1182 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1183 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1184 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1185 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1186 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1187 >          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1188 >          else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1189 >          else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1190 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1191 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1192 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1193 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1194 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1195 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1196 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1197 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1198 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1199 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1200 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1201 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1202 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1203 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1204 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1205 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1206 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1207 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1208 >          else objectToPlot = currentObject;
1209 >
1210 >          string tempCurrentObject = objectToPlot;
1211 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1212 >          string histoName = "num" + tempCurrentObject;
1213 >
1214 >
1215 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1216 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1217 >            int numToPlot = 0;
1218 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1219 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1220 >            }
1221 >
1222 >            if(objectToPlot == "primaryvertexs"){
1223 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1224 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1225 >            }
1226 >            else {
1227 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1228 >            }
1229 >          }
1230 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1231 >
1232 >
1233 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1234 >    } // end loop over cuts
1235 >
1236 >    if (!useEDMFormat_ && eventPassedAllCuts){
1237 >      // Assign BNTree variables
1238 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1239 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1240 >        string coll = brSpecs.inputCollection;
1241 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1242 >
1243 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1244 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1245 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1246 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1247 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1248 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1249 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1250 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1251 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1252 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1253 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1254 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1255 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1256 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1257 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1258 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1259 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1260 >        else if(coll == "stops"
1261 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1262 >      } // end loop over branches
1263 >
1264 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1265 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1266      }
1267  
1268 <  } //end loop over channel
1268 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1269 >
1270 >  } // end loop over channel
1271  
1272    masterCutFlow_->fillCutFlow(masterScaleFactor);
1273  
1274 +  event.put (channelDecisions, "channelDecisions");
1275 +
1276   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1277  
1278  
# Line 1076 | Line 1313 | OSUAnalysis::evaluateTriggers (vector<st
1313    //initialize to false until a chosen trigger is passed
1314    bool triggerDecision = false;
1315  
1316 +  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1317    //loop over all triggers defined in the event
1318    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1319  
1320 +    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1321 +
1322      //we're only interested in triggers that actually passed
1323      if(trigger->pass != 1) continue;
1324  
# Line 1089 | Line 1329 | OSUAnalysis::evaluateTriggers (vector<st
1329      //if the event passes one of the chosen triggers, set triggerDecision to true
1330      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1331        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1332 <    }  
1332 >    }
1333    }
1334 <  //if none of the veto triggers fired:
1334 >
1335 >  printAllTriggers_ = false;  // only print triggers once, not every event
1336 >
1337 >  //if none of the veto triggers fired:
1338    //return the OR of all the chosen triggers
1339    if (triggersToTest.size() != 0) return triggerDecision;
1340    //or if no triggers were defined return true
# Line 1260 | Line 1503 | OSUAnalysis::valueLookup (const BNjet* o
1503    else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1504    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1505  
1506 +  //user defined variable
1507 +  else if(variable == "disappTrkLeadingJetID") {
1508 +    value = object->pt > 110
1509 +      && fabs(object->eta) < 2.4
1510 +      && object->chargedHadronEnergyFraction > 0.2
1511 +      && object->neutralHadronEnergyFraction < 0.7
1512 +      && object->chargedEmEnergyFraction < 0.5
1513 +      && object->neutralEmEnergyFraction < 0.7;
1514 +  }
1515 +
1516 +  else if(variable == "disappTrkSubLeadingJetID") {
1517 +    value = object->pt > 30
1518 +      && fabs(object->eta) < 4.5
1519 +      && object->neutralHadronEnergyFraction < 0.7
1520 +      && object->chargedEmEnergyFraction < 0.5;
1521 +  }
1522 +
1523 +  else if(variable == "dPhiMet") {
1524 +    if (const BNmet *met = chosenMET ()) {
1525 +      value = deltaPhi (object->phi, met->phi);
1526 +    } else value = -999;
1527 +  }
1528 +
1529  
1530    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1531  
1532    value = applyFunction(function, value);
1533  
1534    return value;
1535 < }
1535 > } // end jet valueLookup
1536  
1537  
1538   //!muon valueLookup
# Line 1426 | Line 1692 | OSUAnalysis::valueLookup (const BNmuon*
1692    else if(variable == "time_ndof") value = object->time_ndof;
1693  
1694    //user-defined variables
1695 +  else if(variable == "looseID") {
1696 +    value = object->pt > 10 &&
1697 +      (object->isGlobalMuon  > 0 ||
1698 +       object->isTrackerMuon > 0);
1699 +  }
1700    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1701    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1702    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
# Line 1553 | Line 1824 | OSUAnalysis::valueLookup (const BNmuon*
1824      value = object->isGlobalMuon > 0                \
1825        && object->isPFMuon > 0                        \
1826        && object->normalizedChi2 < 10                \
1827 <                                  && object->numberOfValidMuonHits > 0        \
1827 >      && object->numberOfValidMuonHits > 0        \
1828        && object->numberOfMatchedStations > 1        \
1829        && fabs(object->correctedD0Vertex) < 0.2        \
1830        && fabs(object->correctedDZ) < 0.5        \
# Line 1564 | Line 1835 | OSUAnalysis::valueLookup (const BNmuon*
1835      value = object->isGlobalMuon > 0                \
1836        && object->isPFMuon > 0                        \
1837        && object->normalizedChi2 < 10                \
1838 <                                  && object->numberOfValidMuonHits > 0        \
1838 >      && object->numberOfValidMuonHits > 0        \
1839        && object->numberOfMatchedStations > 1        \
1840        && object->numberOfValidPixelHits > 0        \
1841        && object->numberOfLayersWithMeasurement > 5;
# Line 1619 | Line 1890 | OSUAnalysis::valueLookup (const BNmuon*
1890      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1891      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1892      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1893 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1894 <         || fabs (object->correctedDZ / dzError) > 99.0;
1893 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1894 >      || fabs (object->correctedDZ / dzError) > 99.0;
1895      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1896    }
1897  
# Line 1631 | Line 1902 | OSUAnalysis::valueLookup (const BNmuon*
1902    value = applyFunction(function, value);
1903  
1904    return value;
1905 < }
1905 > } // end muon valueLookup
1906 >
1907  
1908   //!electron valueLookup
1909   double
# Line 1896 | Line 2168 | OSUAnalysis::valueLookup (const BNelectr
2168        }
2169    }
2170  
2171 +  else if(variable == "looseID"){
2172 +    value = object->pt > 10
2173 +      && object->mvaNonTrigV0 > 0;
2174 +      }
2175    else if(variable == "correctedD0VertexInEBPositiveCharge"){
2176      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2177      else value = -999;
# Line 2019 | Line 2295 | OSUAnalysis::valueLookup (const BNelectr
2295      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2296      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2297      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2298 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2299 <         || fabs (object->correctedDZ / dzError) > 99.0;
2298 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2299 >      || fabs (object->correctedDZ / dzError) > 99.0;
2300      value = !value;
2301    }
2302  
# Line 2031 | Line 2307 | OSUAnalysis::valueLookup (const BNelectr
2307    value = applyFunction(function, value);
2308  
2309    return value;
2310 < }
2310 > } // end electron valueLookup
2311 >
2312  
2313   //!event valueLookup
2314   double
# Line 2112 | Line 2389 | OSUAnalysis::valueLookup (const BNevent*
2389    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2390    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2391    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2392 <
2392 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2393    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2394  
2395    value = applyFunction(function, value);
2396  
2397    return value;
2398 < }
2398 > } // end event valueLookup
2399 >
2400  
2401   //!tau valueLookup
2402   double
# Line 2166 | Line 2444 | OSUAnalysis::valueLookup (const BNtau* o
2444    else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2445    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2446  
2447 <
2447 >  else if (variable == "looseHadronicID") {
2448 >    value = object->pt > 10
2449 >      && object->eta < 2.3
2450 >      && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2451 >      && object->HPSdecayModeFinding > 0
2452 >      && object->HPSagainstElectronLoose > 0
2453 >      && object->HPSagainstMuonTight > 0;
2454 >  }
2455  
2456    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2457  
# Line 2218 | Line 2503 | OSUAnalysis::valueLookup (const BNtau* o
2503    value = applyFunction(function, value);
2504  
2505    return value;
2506 < }
2506 > } // end tau valueLookup
2507 >
2508  
2509   //!met valueLookup
2510   double
# Line 2291 | Line 2577 | OSUAnalysis::valueLookup (const BNmet* o
2577    value = applyFunction(function, value);
2578  
2579    return value;
2580 < }
2580 > } // end met valueLookup
2581 >
2582  
2583   //!track valueLookup
2584   double
# Line 2319 | Line 2606 | OSUAnalysis::valueLookup (const BNtrack*
2606    else if(variable == "numValidHits") value = object->numValidHits;
2607    else if(variable == "isHighPurity") value = object->isHighPurity;
2608  
2322
2609    //additional BNs info for disappTrks
2610 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2611 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2612 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2613 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2614 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2615 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2616 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2617 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2332 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2610 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2611 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2612 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2613 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2614 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2615 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2616 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2617 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2618    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2619 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2619 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2620 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2621 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2622 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2623 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2624 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2625 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2626 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2627 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2628 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2629 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2630 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2631 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2632 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2633 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2634 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2635 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2636 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2637  
2638    //user defined variables
2639    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 2666 | OSUAnalysis::valueLookup (const BNtrack*
2666        pt = object->pt;
2667      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2668    }
2669 +
2670 +
2671    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2672  
2673    else if(variable == "genMatchedPdgId"){
# Line 2416 | Line 2720 | OSUAnalysis::valueLookup (const BNtrack*
2720    value = applyFunction(function, value);
2721  
2722    return value;
2723 < }
2723 > } // end track valueLookup
2724 >
2725  
2726   //!genjet valueLookup
2727   double
# Line 2579 | Line 2884 | OSUAnalysis::valueLookup (const BNmcpart
2884    value = applyFunction(function, value);
2885  
2886    return value;
2887 < }
2887 > } // end mcparticle valueLookup
2888 >
2889  
2890   //!primaryvertex valueLookup
2891   double
# Line 2758 | Line 3064 | OSUAnalysis::valueLookup (const BNphoton
3064    value = applyFunction(function, value);
3065  
3066    return value;
3067 < }
3067 > } // end photon valueLookup
3068 >
3069  
3070   //!supercluster valueLookup
3071   double
# Line 2886 | Line 3193 | OSUAnalysis::valueLookup (const BNmuon*
3193    value = applyFunction(function, value);
3194  
3195    return value;
3196 + } // end muon-muon pair valueLookup
3197 +
3198 +
3199 + //!muon-photon pair valueLookup
3200 + double
3201 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3202 +
3203 +  double value = 0.0;
3204 +
3205 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3206 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3207 +  else if(variable == "photonEta") value = object2->eta;
3208 +  else if(variable == "muonEta") value = object1->eta;
3209 +  else if(variable == "photonPhi") value = object2->phi;
3210 +  else if(variable == "muonPhi") value = object1->phi;
3211 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3212 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3213 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3214 +  else if(variable == "invMass"){
3215 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3216 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3217 +    value = (fourVector1 + fourVector2).M();
3218 +  }
3219 +  else if(variable == "pt"){
3220 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3221 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3222 +    value = (fourVector1 + fourVector2).Pt();
3223 +  }
3224 +  else if(variable == "threeDAngle")
3225 +    {
3226 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3227 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3228 +      value = (threeVector1.Angle(threeVector2));
3229 +    }
3230 +  else if(variable == "alpha")
3231 +    {
3232 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3233 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3234 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3235 +      value = (pi-threeVector1.Angle(threeVector2));
3236 +    }
3237 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3238 +
3239 +  value = applyFunction(function, value);
3240 +
3241 +  return value;
3242 + }
3243 +
3244 + //!electron-photon pair valueLookup
3245 + double
3246 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3247 +
3248 +  double value = 0.0;
3249 +
3250 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3251 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3252 +  else if(variable == "photonEta") value = object2->eta;
3253 +  else if(variable == "electronEta") value = object1->eta;
3254 +  else if(variable == "photonPhi") value = object2->phi;
3255 +  else if(variable == "electronPhi") value = object1->phi;
3256 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3257 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3258 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3259 +  else if(variable == "invMass"){
3260 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3261 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3262 +    value = (fourVector1 + fourVector2).M();
3263 +  }
3264 +  else if(variable == "pt"){
3265 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3266 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3267 +    value = (fourVector1 + fourVector2).Pt();
3268 +  }
3269 +  else if(variable == "threeDAngle")
3270 +    {
3271 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3272 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3273 +      value = (threeVector1.Angle(threeVector2));
3274 +    }
3275 +  else if(variable == "alpha")
3276 +    {
3277 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3278 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3279 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3280 +      value = (pi-threeVector1.Angle(threeVector2));
3281 +    }
3282 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3283 +
3284 +  value = applyFunction(function, value);
3285 +
3286 +  return value;
3287   }
3288  
3289   //!electron-electron pair valueLookup
# Line 2943 | Line 3341 | OSUAnalysis::valueLookup (const BNelectr
3341  
3342    return value;
3343   }
3344 +
3345   //!electron-muon pair valueLookup
3346   double
3347   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3007 | Line 3406 | OSUAnalysis::valueLookup (const BNelectr
3406    value = applyFunction(function, value);
3407  
3408    return value;
3409 < }
3409 > } // end electron-muon pair valueLookup
3410 >
3411  
3412   //!electron-jet pair valueLookup
3413   double
# Line 3017 | Line 3417 | OSUAnalysis::valueLookup (const BNelectr
3417  
3418    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3419    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3420 +  else if(variable == "jetEta") value = object2->eta;
3421 +  else if(variable == "jetPhi") value = object2->phi;
3422 +  else if(variable == "electronEta") value = object1->eta;
3423 +  else if(variable == "electronPhi") value = object1->phi;
3424    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3425    else if(variable == "invMass"){
3426      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3044 | Line 3448 | OSUAnalysis::valueLookup (const BNelectr
3448    return value;
3449   }
3450  
3451 + //!photon-jet pair valueLookup
3452 + double
3453 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3454 +
3455 +  double value = 0.0;
3456 +
3457 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3458 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3459 +  else if(variable == "jetEta") value = object2->eta;
3460 +  else if(variable == "jetPhi") value = object2->phi;
3461 +  else if(variable == "photonEta") value = object1->eta;
3462 +  else if(variable == "photonPhi") value = object1->phi;
3463 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3464 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3465 +  else if(variable == "invMass"){
3466 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3467 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3468 +    value = (fourVector1 + fourVector2).M();
3469 +  }
3470 +  else if(variable == "pt"){
3471 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3472 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3473 +    value = (fourVector1 + fourVector2).Pt();
3474 +  }
3475 +  else if(variable == "threeDAngle")
3476 +    {
3477 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3478 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3479 +      value = (threeVector1.Angle(threeVector2));
3480 +    }
3481 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3482 +  value = applyFunction(function, value);
3483 +
3484 +  return value;
3485 + }
3486 +
3487 + // met-jet pair valueLookup
3488 + double
3489 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3490 +
3491 +  double value = 0.0;
3492 +
3493 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3494 +
3495 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3496 +  value = applyFunction(function, value);
3497 +
3498 +  return value;
3499 +
3500 + }  
3501 +
3502 +
3503 +
3504   //!muon-jet pair valueLookup
3505   double
3506   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3051 | Line 3508 | OSUAnalysis::valueLookup (const BNmuon*
3508    double value = 0.0;
3509  
3510    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3511 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3511 >  else if(variable == "jetEta") value = object2->eta;
3512 >  else if(variable == "jetPhi") value = object2->phi;
3513 >  else if(variable == "muonEta") value = object1->eta;
3514 >  else if(variable == "muonPhi") value = object1->phi;
3515 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3516    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3517    else if(variable == "invMass"){
3518      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3078 | Line 3539 | OSUAnalysis::valueLookup (const BNmuon*
3539  
3540    return value;
3541   }
3081
3542   //!jet-jet pair valueLookup
3543   double
3544   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3114 | Line 3574 | OSUAnalysis::valueLookup (const BNjet* o
3574  
3575    return value;
3576   }
3577 +
3578   //!electron-track pair valueLookup
3579   double
3580   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3381 | Line 3842 | OSUAnalysis::valueLookup (const BNstop*
3842      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3843        vertex_rank++;
3844        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3845 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3846 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3845 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3846 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3847  
3848        if(abs(dist) < abs(minDistToVertex)){
3849          value = vertex_rank;
# Line 3400 | Line 3861 | OSUAnalysis::valueLookup (const BNstop*
3861  
3862    return value;
3863  
3864 < }
3864 > } // end stop valueLookup
3865 >
3866  
3867  
3868  
# Line 3546 | Line 4008 | void OSUAnalysis::setObjectFlags(cut &cu
4008      string obj1, obj2;
4009      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4010      if (inputType==obj1 ||
4011 <          inputType==obj2) {
4011 >        inputType==obj2) {
4012        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4013        // and the inputType is a member of the pair.
4014        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3558 | Line 4020 | void OSUAnalysis::setObjectFlags(cut &cu
4020  
4021    for (uint object = 0; object != inputCollection->size(); object++){
4022  
4023 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
4023 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4024 >    bool plotDecision = true;
4025  
4026      if(currentCut.inputCollection == inputType){
4027  
# Line 3570 | Line 4033 | void OSUAnalysis::setObjectFlags(cut &cu
4033          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4034  
4035        }
4036 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4036 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4037        else{
4038          bool tempDecision = true;
4039          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3579 | Line 4042 | void OSUAnalysis::setObjectFlags(cut &cu
4042            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4043              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4044          }
4045 <        decision = tempDecision;
4045 >        cutDecision = tempDecision;
4046        }
4047 +      //invert the cut for plotting if this cut is a veto
4048 +      if(currentCut.isVeto) plotDecision = !cutDecision;
4049 +      else plotDecision = cutDecision;
4050      }
4051  
4052 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4052 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4053  
4054 <    //set flags for objects that pass each cut AND all the previous cuts
4055 <    bool previousCumulativeFlag = true;
4054 >    //set flags for objects that pass this cut AND all the previous cuts
4055 >    bool previousCumulativeCutFlag = true;
4056      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4057 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
4058 <      else{ previousCumulativeFlag = false; break;}
4057 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4058 >      else{ previousCumulativeCutFlag = false; break;}
4059      }
4060 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
4060 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4061 >    bool previousCumulativePlotFlag = true;
4062 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4063 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4064 >      else{ previousCumulativePlotFlag = false; break;}
4065 >    }
4066 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4067 >
4068 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4069  
4070    }
4071  
# Line 3600 | Line 4074 | void OSUAnalysis::setObjectFlags(cut &cu
4074  
4075   template <class InputCollection1, class InputCollection2>
4076   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4077 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
4077 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4078  
4079  
4080    bool sameObjects = false;
# Line 3616 | Line 4090 | void OSUAnalysis::setObjectFlags(cut &cu
4090    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4091    if (currentCut.inputCollection == inputType) {
4092      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4093 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4094 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
4093 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4094 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4095      }
4096      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4097        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
4098 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4099 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
4098 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4099 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4100        }
4101      }
4102    }
# Line 3635 | Line 4109 | void OSUAnalysis::setObjectFlags(cut &cu
4109        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4110  
4111  
4112 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4112 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4113 >      bool plotDecision = true;
4114  
4115        if(currentCut.inputCollection == inputType){
4116  
# Line 3647 | Line 4122 | void OSUAnalysis::setObjectFlags(cut &cu
4122            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4123          }
4124  
4125 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4125 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4126          else{
4127            bool tempDecision = subcutDecisions.at(0);
4128            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3656 | Line 4131 | void OSUAnalysis::setObjectFlags(cut &cu
4131              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4132                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4133            }
4134 <          decision = tempDecision;
4134 >          cutDecision = tempDecision;
4135          }
4136 +        //invert the cut for plotting if this cut is a veto
4137 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4138 +        else plotDecision = cutDecision;
4139 +      }
4140 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4141 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4142 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4143 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4144 +      }
4145 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4146 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4147 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4148        }
4149 <      // if (decision) isPassObj1.at(object1) = true;
4150 <      // if (decision) isPassObj2.at(object2) = true;
4151 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4152 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4153 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4154 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4149 >
4150 >      //set flags for objects that pass this cut AND all the previous cuts
4151 >      bool previousCumulativeCutFlag = true;
4152 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4153 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4154 >        else{ previousCumulativeCutFlag = false; break;}
4155        }
4156 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4157  
4158 <      //set flags for objects that pass each cut AND all the previous cuts
3671 <      bool previousCumulativeFlag = true;
4158 >      bool previousCumulativePlotFlag = true;
4159        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4160 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4161 <        else{ previousCumulativeFlag = false; break;}
4160 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4161 >        else{ previousCumulativePlotFlag = false; break;}
4162        }
4163 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4164 +      
4165        //apply flags for the components of the composite object as well
4166 <      bool currentCumulativeFlag = true;
4167 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4168 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4169 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4170 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4171 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4172 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4173 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4174 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4166 >      bool currentCumulativeCutFlag = true;
4167 >      bool currentCumulativePlotFlag = true;
4168 >
4169 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4170 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4171 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4172 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4173 >
4174 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4175 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4176 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4177 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4178 >
4179 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4180 >
4181 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4182 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4183 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4184        }
4185 +
4186 +      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4187 +        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4188 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4189 +      }
4190 +
4191        counter++;
4192  
4193      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3692 | Line 4196 | void OSUAnalysis::setObjectFlags(cut &cu
4196   }
4197  
4198  
4199 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4199 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4200    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4201    // all cuts up to currentCutIndex
4202    bool previousCumulativeFlag = true;
4203    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4204 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4204 >    bool tempFlag = false;
4205 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4206 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4207 >
4208 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4209      else {
4210        previousCumulativeFlag = false; break;
4211      }
# Line 3706 | Line 4214 | bool OSUAnalysis::getPreviousCumulativeF
4214   }
4215  
4216  
4217 +
4218 +
4219   template <class InputCollection>
4220 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4220 > void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4221 >  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4222 >
4223 >  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;
4224 >  for (uint object = 0; object != inputCollection->size(); object++) {
4225 >
4226 >    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4227 >
4228 >    string inputVariable = parameters.inputVariable;
4229 >    string function = "";
4230 >    string stringValue = "";
4231 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4232 >    BNTreeBranchVals_.at(parameters.name).push_back(value);
4233 >
4234 >  }
4235 > }
4236 >
4237 >
4238 > template <class InputCollection>
4239 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4240 >
4241  
4242    for (uint object = 0; object != inputCollection->size(); object++){
4243  
4244 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4244 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4245  
4246      string currentString = parameters.inputVariables.at(0);
4247      string inputVariable = "";
# Line 3728 | Line 4258 | void OSUAnalysis::fill1DHistogram(TH1* h
4258      string stringValue = "";
4259      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4260      histo->Fill(value,scaleFactor);
4261 +
4262      if (printEventInfo_) {
4263        // Write information about event to screen, for testing purposes.
4264        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3737 | Line 4268 | void OSUAnalysis::fill1DHistogram(TH1* h
4268   }
4269  
4270   template <class InputCollection1, class InputCollection2>
4271 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4271 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4272  
4273    bool sameObjects = false;
4274    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3750 | Line 4281 | void OSUAnalysis::fill1DHistogram(TH1* h
4281  
4282        pairCounter++;
4283        //only take objects which have passed all cuts and pairs which have passed all cuts
4284 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4285 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4286 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4284 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4285 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4286 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4287  
4288        string currentString = parameters.inputVariables.at(0);
4289        string inputVariable = "";
# Line 3777 | Line 4308 | void OSUAnalysis::fill1DHistogram(TH1* h
4308  
4309  
4310   template <class InputCollection>
4311 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4311 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4312  
4313    for (uint object = 0; object != inputCollection->size(); object++){
4314  
4315 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4315 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4316  
4317      string stringValue = "";
4318      string currentString = parameters.inputVariables.at(0);
# Line 3818 | Line 4349 | void OSUAnalysis::fill2DHistogram(TH2* h
4349   }
4350  
4351   template <class InputCollection1, class InputCollection2>
4352 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4352 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4353  
4354    bool sameObjects = false;
4355    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3832 | Line 4363 | void OSUAnalysis::fill2DHistogram(TH2* h
4363        pairCounter++;
4364  
4365        //only take objects which have passed all cuts and pairs which have passed all cuts
4366 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4367 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4368 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4366 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4367 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4368 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4369  
4370        string stringValue = "";
4371        string currentString = parameters.inputVariables.at(0);
# Line 3994 | Line 4525 | OSUAnalysis::chosenVertex ()
4525   {
4526    const BNprimaryvertex *chosenVertex = 0;
4527    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4528 <    vector<bool> vertexFlags;
4528 >    flagPair vertexFlags;
4529      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4530        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4531          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4002 | Line 4533 | OSUAnalysis::chosenVertex ()
4533        }
4534      }
4535      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4536 <      if(!vertexFlags.at(vertexIndex)) continue;
4536 >      if(!vertexFlags.at(vertexIndex).first) continue;
4537        chosenVertex = & primaryvertexs->at(vertexIndex);
4538        break;
4539      }
# Line 4018 | Line 4549 | OSUAnalysis::chosenMET ()
4549   {
4550    const BNmet *chosenMET = 0;
4551    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4552 <    vector<bool> metFlags;
4552 >    flagPair metFlags;
4553      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4554        if (cumulativeFlags.at("mets").at(i).size()){
4555          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4026 | Line 4557 | OSUAnalysis::chosenMET ()
4557        }
4558      }
4559      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4560 <      if(!metFlags.at(metIndex)) continue;
4560 >      if(!metFlags.at(metIndex).first) continue;
4561        chosenMET = & mets->at(metIndex);
4562        break;
4563      }
# Line 4042 | Line 4573 | OSUAnalysis::chosenElectron ()
4573   {
4574    const BNelectron *chosenElectron = 0;
4575    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4576 <    vector<bool> electronFlags;
4576 >    flagPair electronFlags;
4577      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4578        if (cumulativeFlags.at("electrons").at(i).size()){
4579          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4050 | Line 4581 | OSUAnalysis::chosenElectron ()
4581        }
4582      }
4583      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4584 <      if(!electronFlags.at(electronIndex)) continue;
4584 >      if(!electronFlags.at(electronIndex).first) continue;
4585        chosenElectron = & electrons->at(electronIndex);
4586        break;
4587      }
# Line 4061 | Line 4592 | OSUAnalysis::chosenElectron ()
4592    return chosenElectron;
4593   }
4594  
4595 +
4596   const BNmuon *
4597   OSUAnalysis::chosenMuon ()
4598   {
4599    const BNmuon *chosenMuon = 0;
4600    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4601 <    vector<bool> muonFlags;
4601 >    flagPair muonFlags;
4602      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4603        if (cumulativeFlags.at("muons").at(i).size()){
4604          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4074 | Line 4606 | OSUAnalysis::chosenMuon ()
4606        }
4607      }
4608      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4609 <      if(!muonFlags.at(muonIndex)) continue;
4609 >      if(!muonFlags.at(muonIndex).first) continue;
4610        chosenMuon = & muons->at(muonIndex);
4611        break;
4612      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines