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.87 by biliu, Thu Jun 20 16:20:24 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 == "event-track pairs")   tempInputCollection = "track-event pairs";
112      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
113 +    if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
114 +    if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
115 +    if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
116 +    if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
117      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
118      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
119      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 90 | Line 128 | OSUAnalysis::OSUAnalysis (const edm::Par
128        }
129        objectsToPlot.push_back(tempInputCollection);
130        objectsToCut.push_back(tempInputCollection);
131 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
131 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
132        string obj1;
133        string obj2;
134        getTwoObjs(tempInputCollection, obj1, obj2);
# Line 105 | Line 142 | OSUAnalysis::OSUAnalysis (const edm::Par
142        objectsToGet.push_back(tempInputCollection);
143        objectsToGet.push_back(obj1);
144        objectsToGet.push_back(obj2ToGet);
145 +    } // end else
146  
109    }
147  
148  
149      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 128 | Line 165 | OSUAnalysis::OSUAnalysis (const edm::Par
165        histograms.push_back(tempHistogram);
166  
167      }
168 <  }
168 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
169 >
170    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
171    sort( objectsToPlot.begin(), objectsToPlot.end() );
172    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 236 | Line 274 | OSUAnalysis::OSUAnalysis (const edm::Par
274      //create cutFlow for this channel
275      cutFlows_.push_back (new CutFlow (fs_, channelName));
276      vector<TFileDirectory> directories; //vector of directories in the output file.
277 +    vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
278      vector<string> subSubDirNames;//subdirectories in each channel.
279      //get list of cuts for this channel
280      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
# Line 247 | Line 286 | OSUAnalysis::OSUAnalysis (const edm::Par
286        //store input collection for cut
287        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
288        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
289 +      if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
290 +      if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
291        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
292        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
293 +      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
294        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
295        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
296 +      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
297 +      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
298 +      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
299 +      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
300        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
301        if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
302        if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
# Line 320 | Line 366 | OSUAnalysis::OSUAnalysis (const edm::Par
366        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
367        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
368  
369 <      //Set up vectors to store the directories and subDIrectories for each channel.
369 >      //Set up vectors to store the directories and subDirectories for each channel.
370        string subSubDirName;
371        string tempCutName;
372        if(cuts_.at(currentCut).exists("alias")){
373          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
374 <        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
374 >        subSubDirName = "After " + tempCutName + " Cut Applied";
375        }
376        else{
377          //construct string for cutflow table
# Line 336 | Line 382 | OSUAnalysis::OSUAnalysis (const edm::Par
382          subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
383        }
384  
385 +      tempCut.isVeto = false;
386 +      if(cuts_.at(currentCut).exists("isVeto")){
387 +        bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
388 +        if (isVeto == true) tempCut.isVeto = true;
389 +      }
390        subSubDirNames.push_back(subSubDirName);
391        tempCut.name = tempCutName;
392  
# Line 350 | Line 401 | OSUAnalysis::OSUAnalysis (const edm::Par
401      TFileDirectory subDir = fs_->mkdir( channelName );
402      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
403      if(GetPlotsAfterEachCut_){
404 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
405 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
406 <            directories.push_back(subSubDir);
407 <            map<string, TH1D*> oneDhistoMap;
408 <            oneDHistsTmp.push_back(oneDhistoMap);
409 <            map<string, TH2D*> twoDhistoMap;
410 <            twoDHistsTmp.push_back(twoDhistoMap);
404 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
405 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
406 >        directories.push_back(subSubDir);
407 >        map<string, TH1D*> oneDhistoMap;
408 >        oneDHistsTmp.push_back(oneDhistoMap);
409 >        map<string, TH2D*> twoDhistoMap;
410 >        twoDHistsTmp.push_back(twoDhistoMap);
411        }
412 +      treeDirectories.push_back(subDir);
413        oneDHists_.push_back(oneDHistsTmp);
414        twoDHists_.push_back(twoDHistsTmp);
415      }
416 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
417 <   else{
416 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
417 >    else{
418        map<string, TH1D*> oneDhistoMap;
419        oneDHistsTmp.push_back(oneDhistoMap);
420        map<string, TH2D*> twoDhistoMap;
# Line 370 | Line 422 | OSUAnalysis::OSUAnalysis (const edm::Par
422        oneDHists_.push_back(oneDHistsTmp);
423        twoDHists_.push_back(twoDHistsTmp);
424        directories.push_back(subDir);
425 <   }
425 >      treeDirectories.push_back(subDir);
426 >
427 >    }
428 >
429 >    for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
430 >      TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
431 >      BNTrees_.push_back(newTree);
432 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
433 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
434 >        vector<float> newVec;
435 >        BNTreeBranchVals_[currentVar.name] = newVec;
436 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
437 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
438 >    }
439 >
440      //book all histograms included in the configuration
441      for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
442 <    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
443 <      histogram currentHistogram = histograms.at(currentHistogramIndex);
444 <      int numBinsElements = currentHistogram.bins.size();
445 <      int numInputVariables = currentHistogram.inputVariables.size();
446 <      int numBinEdgesX = currentHistogram.variableBinsX.size();
447 <      int numBinEdgesY = currentHistogram.variableBinsY.size();
448 <
449 <      if(numBinsElements == 1){
450 <        if(numBinEdgesX > 1){
451 <          if(numBinEdgesY > 1)
452 <            numBinsElements = 6;
442 >
443 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
444 >
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;
455 >            else
456 >              numBinsElements = 3;
457 >          }
458 >        }
459 >        if(numBinsElements != 3 && numBinsElements !=6){
460 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
461 >          exit(0);
462 >        }
463 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
464 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
465 >          exit(0);
466 >        }
467 >        else if(numBinsElements == 3){
468 >          if (currentHistogram.bins.size () == 3)
469 >            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));
470            else
471 <            numBinsElements = 3;
471 >            {
472 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
473 >            }
474          }
475 <      }
476 <      if(numBinsElements != 3 && numBinsElements !=6){
477 <        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
478 <        exit(0);
479 <      }
480 <      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
481 <        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
482 <        exit(0);
483 <      }
484 <      else if(numBinsElements == 3){
485 <        if (currentHistogram.bins.size () == 3)
486 <          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));
487 <        else
488 <          {
489 <            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 >        else if(numBinsElements == 6){
476 >          if (currentHistogram.bins.size () == 6)
477 >            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));
478 >          else
479 >            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 ());
480 >        }
481 >
482 >
483 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
484 >
485 >        // bin      particle type
486 >        // ---      -------------
487 >        //  0        unmatched
488 >        //  1        u
489 >        //  2        d
490 >        //  3        s
491 >        //  4        c
492 >        //  5        b
493 >        //  6        t
494 >        //  7        e
495 >        //  8        mu
496 >        //  9        tau
497 >        // 10        nu
498 >        // 11        g
499 >        // 12        gamma
500 >        // 13        Z
501 >        // 14        W
502 >        // 15        light meson
503 >        // 16        K meson
504 >        // 17        D meson
505 >        // 18        B meson
506 >        // 19        light baryon
507 >        // 20        strange baryon
508 >        // 21        charm baryon
509 >        // 22        bottom baryon
510 >        // 23        QCD string
511 >        // 24        other
512 >
513 >        vector<TString> labelArray;
514 >        labelArray.push_back("unmatched");
515 >        labelArray.push_back("u");
516 >        labelArray.push_back("d");
517 >        labelArray.push_back("s");
518 >        labelArray.push_back("c");
519 >        labelArray.push_back("b");
520 >        labelArray.push_back("t");
521 >        labelArray.push_back("e");
522 >        labelArray.push_back("#mu");
523 >        labelArray.push_back("#tau");
524 >        labelArray.push_back("#nu");
525 >        labelArray.push_back("g");
526 >        labelArray.push_back("#gamma");
527 >        labelArray.push_back("Z");
528 >        labelArray.push_back("W");
529 >        labelArray.push_back("light meson");
530 >        labelArray.push_back("K meson");
531 >        labelArray.push_back("D meson");
532 >        labelArray.push_back("B meson");
533 >        labelArray.push_back("light baryon");
534 >        labelArray.push_back("strange baryon");
535 >        labelArray.push_back("charm baryon");
536 >        labelArray.push_back("bottom baryon");
537 >        labelArray.push_back("QCD string");
538 >        labelArray.push_back("other");
539 >
540 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
541 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
542 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
543            }
544 <      }
545 <      else if(numBinsElements == 6){
546 <        if (currentHistogram.bins.size () == 6)
547 <          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));
548 <        else
549 <          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 ());
550 <      }
544 >          else {
545 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
546 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
547 >          }
548 >        }
549 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
550 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
551 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
552 >        }
553  
554 +      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
555  
415      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
556  
557 <      // bin      particle type
558 <      // ---      -------------
559 <      //  0        unmatched
560 <      //  1        u
561 <      //  2        d
562 <      //  3        s
563 <      //  4        c
564 <      //  5        b
565 <      //  6        t
566 <      //  7        e
567 <      //  8        mu
568 <      //  9        tau
569 <      // 10        nu
570 <      // 11        g
571 <      // 12        gamma
572 <      // 13        Z
573 <      // 14        W
574 <      // 15        light meson
575 <      // 16        K meson
576 <      // 17        D meson
577 <      // 18        B meson
578 <      // 19        light baryon
579 <      // 20        strange baryon
580 <      // 21        charm baryon
581 <      // 22        bottom baryon
582 <      // 23        QCD string
583 <      // 24        other
584 <
585 <      vector<TString> labelArray;
586 <      labelArray.push_back("unmatched");
587 <      labelArray.push_back("u");
588 <      labelArray.push_back("d");
589 <      labelArray.push_back("s");
590 <      labelArray.push_back("c");
591 <      labelArray.push_back("b");
592 <      labelArray.push_back("t");
593 <      labelArray.push_back("e");
594 <      labelArray.push_back("#mu");
595 <      labelArray.push_back("#tau");
596 <      labelArray.push_back("#nu");
597 <      labelArray.push_back("g");
598 <      labelArray.push_back("#gamma");
599 <      labelArray.push_back("Z");
600 <      labelArray.push_back("W");
601 <      labelArray.push_back("light meson");
602 <      labelArray.push_back("K meson");
463 <      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);
557 >      // Book a histogram for the number of each object type to be plotted.
558 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
559 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
560 >        string currentObject = objectsToPlot.at(currentObjectIndex);
561 >        int maxNum = 10;
562 >        if(currentObject == "mcparticles") maxNum = 50;
563 >        else if(currentObject == "primaryvertexs") maxNum = 50;
564 >
565 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
566 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
567 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
568 >        else if(currentObject == "electron-photon pairs")       currentObject = "electronPhotonPairs";
569 >        else if(currentObject == "muon-photon pairs")       currentObject = "muonPhotonPairs";
570 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
571 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
572 >        else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
573 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
574 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
575 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
576 >        else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
577 >        else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
578 >        else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
579 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
580 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
581 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
582 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
583 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
584 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
585 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
586 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
587 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
588 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
589 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
590 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
591 >
592 >        currentObject.at(0) = toupper(currentObject.at(0));
593 >        string histoName = "num" + currentObject;
594 >
595 >        if(histoName == "numPrimaryvertexs"){
596 >          string newHistoName = histoName + "BeforePileupCorrection";
597 >          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);
598 >          newHistoName = histoName + "AfterPileupCorrection";
599 >          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);
600 >        }
601 >        else
602 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
603        }
604 <      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
604 >    }//end of loop over directories
605      channels.push_back(tempChannel);
606      tempChannel.cuts.clear();
607    }//end loop over channels
# Line 538 | Line 614 | OSUAnalysis::OSUAnalysis (const edm::Par
614    sort( objectsToCut.begin(), objectsToCut.end() );
615    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
616  
617 +  produces<map<string, bool> > ("channelDecisions");
618 +
619 + } // end constructor OSUAnalysis::OSUAnalysis()
620  
542 }
621  
622   OSUAnalysis::~OSUAnalysis ()
623   {
624 +
625    // Destroying the CutFlow objects causes the cut flow numbers and time
626    // information to be printed to standard output.
627    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 551 | Line 630 | OSUAnalysis::~OSUAnalysis ()
630   }
631  
632   void
633 < OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
633 > OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
634   {
635 <
635 >  //cout << "**********************\n\n\n";
636    // Retrieve necessary collections from the event.
637  
638    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 619 | Line 698 | OSUAnalysis::analyze (const edm::Event &
698    //get pile-up event weight
699    if (doPileupReweighting_ && datasetType_ != "data") {
700      //for "data" datasets, the numTruePV is always set to -1
701 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
702 <    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
701 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
702 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
703    }
704  
705    stopCTauScaleFactor_ = 1.0;
# Line 630 | Line 709 | OSUAnalysis::analyze (const edm::Event &
709  
710    //loop over all channels
711  
712 +  auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
713    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
714      channel currentChannel = channels.at(currentChannelIndex);
715  
# Line 637 | Line 717 | OSUAnalysis::analyze (const edm::Event &
717      counterMap passingCounter;
718      cumulativeFlags.clear ();
719  
720 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
721 +         iter != BNTreeBranchVals_.end(); iter++) {
722 +      iter->second.clear();  // clear array
723 +    }
724 +
725      bool triggerDecision = true;
726      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
727        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 650 | Line 735 | OSUAnalysis::analyze (const edm::Event &
735          string currentObject = objectsToCut.at(currentObjectIndex);
736  
737          //initialize maps to get ready to set cuts
738 <        individualFlags[currentObject].push_back (vector<bool> ());
739 <        cumulativeFlags[currentObject].push_back (vector<bool> ());
738 >        individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
739 >        cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
740  
741        }
742        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
# Line 686 | Line 771 | OSUAnalysis::analyze (const edm::Event &
771                                                                     "muon-muon pairs");
772  
773          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
774 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
775 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
776 <                                                                   "muon-secondary muon pairs");
774 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
775 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
776 >                                                                             "muon-secondary muon pairs");
777 >
778 >        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
779 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
780 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
781 >                                                                             "muon-secondary jet pairs");
782 >        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
783 >                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
784 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
785 >                                                                             "photon-secondary jet pairs");
786 >
787 >        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
788 >                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
789 >                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
790 >                                                                             "electron-secondary jet pairs");
791  
792          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
793 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
794 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
795 <                                                                   "electron-secondary electron pairs");
793 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
794 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
795 >                                                                                     "electron-secondary electron pairs");
796  
797          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
798                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 704 | Line 803 | OSUAnalysis::analyze (const edm::Event &
803                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
804                                                                         "electron-muon pairs");
805          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
806 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
807 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
808 <                                                                           "jet-jet pairs");
806 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
807 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
808 >                                                                 "jet-jet pairs");
809 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
810 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
811 >                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
812 >                                                                 "jet-secondary jet pairs");
813          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
814 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
815 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
816 <                                                                       "electron-jet pairs");
814 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
815 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
816 >                                                                      "electron-jet pairs");
817 >        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
818 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
819 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
820 >                                                                      "electron-photon pairs");
821 >        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
822 >                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
823 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
824 >                                                                      "photon-jet pairs");
825          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
826 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
827 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
828 <                                                                       "muon-jet pairs");
826 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
827 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
828 >                                                                  "muon-jet pairs");
829 >        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
830 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
831 >                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
832 >                                                                  "muon-photon pairs");
833          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
834                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
835                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 736 | Line 851 | OSUAnalysis::analyze (const edm::Event &
851                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
852                                                                   "tau-tau pairs");
853          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
854 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
855 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
856 <                                                                 "tau-track pairs");
854 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
855 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
856 >                                                                   "tau-track pairs");
857          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
858                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
859                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 756 | Line 871 | OSUAnalysis::analyze (const edm::Event &
871      }//end loop over all cuts
872      //use cumulative flags to apply cuts at event level
873  
759    bool eventPassedAllCuts = true;
874      //a vector to store cumulative cut descisions after each cut.
875      vector<bool> eventPassedPreviousCuts;
876 +    bool eventPassedAllCuts = true;
877      //apply trigger (true if none were specified)
878      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
879  
765
880      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
881  
882        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 770 | Line 884 | OSUAnalysis::analyze (const edm::Event &
884        int numberPassing = 0;
885  
886        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
887 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
887 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
888        }
889        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
890        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 779 | Line 893 | OSUAnalysis::analyze (const edm::Event &
893      }
894      double scaleFactor = masterScaleFactor;
895  
896 <    muonScaleFactor_ = electronScaleFactor_ = 1.0;
896 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
897      if(applyLeptonSF_ && datasetType_ != "data"){
898        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
899 <        vector<bool> muonFlags;
899 >        flagPair muonFlags;
900          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
901            if (cumulativeFlags.at("muons").at(i).size()){
902              muonFlags = cumulativeFlags.at("muons").at(i);
# Line 790 | Line 904 | OSUAnalysis::analyze (const edm::Event &
904            }
905          }
906          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
907 <          if(!muonFlags.at(muonIndex)) continue;
907 >          if(!muonFlags.at(muonIndex).second) continue;
908            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
909          }
910        }
911        if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
912 <        vector<bool> electronFlags;
912 >        flagPair electronFlags;
913          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
914            if (cumulativeFlags.at("electrons").at(i).size()){
915              electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 803 | Line 917 | OSUAnalysis::analyze (const edm::Event &
917            }
918          }
919          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
920 <          if(!electronFlags.at(electronIndex)) continue;
920 >          if(!electronFlags.at(electronIndex).second) continue;
921            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
922          }
923        }
924      }
925 +    if(applyBtagSF_ && datasetType_ != "data"){
926 +     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
927 +       flagPair jetFlags;
928 +        vector<double> jetSFs;
929 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
930 +          if (cumulativeFlags.at("jets").at(i).size()){
931 +            jetFlags = cumulativeFlags.at("jets").at(i);
932 +            break;
933 +          }
934 +        }
935 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
936 +          if(!jetFlags.at(jetIndex).second) continue;
937 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
938 +          jetSFs.push_back(jetSFTmp);
939 +        }
940 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
941 +      }
942 +    }
943      scaleFactor *= muonScaleFactor_;
944      scaleFactor *= electronScaleFactor_;
945 <
945 >    scaleFactor *= bTagScaleFactor_;
946      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
947  
816
948      if (printEventInfo_) {
949        // Write information about event to screen, for testing purposes.
950        cout << "Event passed all cuts in channel " <<  currentChannel.name
# Line 824 | Line 955 | OSUAnalysis::analyze (const edm::Event &
955      }
956  
957  
827
958      //filling histograms
959      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830
960        uint currentDir;
961 <      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
962 <      else currentDir = currentCut;
961 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
962 >      else{
963 >        currentDir = currentCut;
964 >      }
965  
835      if(!eventPassedPreviousCuts.at(currentDir)) continue;
966  
967 +      if(eventPassedPreviousCuts.at(currentDir)){
968  
969 <      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
970 <        histogram currentHistogram = histograms.at(histogramIndex);
969 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
970 >          histogram currentHistogram = histograms.at(histogramIndex);
971  
972 <        if(currentHistogram.inputVariables.size() == 1){
973 <          TH1D* histo;
974 <          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
975 <
976 <          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
977 <          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
978 <          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
979 <          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
980 <          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
981 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
982 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
983 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
984 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
985 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
986 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
987 <          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
988 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
989 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
990 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
991 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
992 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
993 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
994 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
995 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
996 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
997 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
998 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
999 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1000 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1001 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1002 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1003 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1004 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1005 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1006 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1007 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1008 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1009 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1010 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1011 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1012 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1013 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1014 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1015 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1016 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1017 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1018 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1019 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1020 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1021 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1022 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1023 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1024 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1025 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1026 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1027 <          
1028 <          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1029 <          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1030 <          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1031 <          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1032 <          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1033 <          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1034 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1035 <          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1036 <          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1037 <          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1038 <          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1039 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1040 <        }
1041 <        else if(currentHistogram.inputVariables.size() == 2){
1042 <          TH2D* histo;
1043 <          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1044 <
1045 <          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1046 <          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1047 <          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1048 <          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1049 <          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1050 <                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1051 <                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1052 <          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1053 <                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1054 <                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1055 <          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1056 <          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1057 <          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1058 <                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1059 <                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1060 <          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1061 <                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1062 <                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1063 <          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1064 <                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1065 <                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1066 <          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1067 <                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1068 <                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1069 <          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1070 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1071 <                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1072 <          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1073 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1074 <                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1075 <          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1076 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1077 <                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1078 <          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1079 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1080 <                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1081 <          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1082 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1083 <                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1084 <          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1085 <                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1086 <                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1087 <          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1088 <                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1089 <                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1090 <          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1091 <                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1092 <                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1093 <          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1094 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1095 <                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1096 <          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1097 <          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1098 <          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1099 <          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1100 <          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1101 <                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1102 <                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1103 <          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1104 <          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1105 <          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1106 <          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1107 <          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1108 <          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1109 <          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1110 <          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1111 <        }
1112 <      }
972 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
973 >
974 >          if(currentHistogram.inputVariables.size() == 1){
975 >            TH1D* histo;
976 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
977 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
978 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
979 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
980 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
981 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
982 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
983 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
984 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
985 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
986 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
987 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
988 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
989 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
990 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
991 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
992 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
993 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
994 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
995 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
996 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
997 >
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 == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1006 >                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1007 >                                                                                                     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1008 >
1009 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1010 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1011 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1012 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1013 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1014 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1015 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1016 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1017 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1018 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1019 >                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1020 >                                                                                              cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1021 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1022 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1023 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1024 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1025 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1026 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1027 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1028 >                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1029 >                                                                                          cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1030 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1031 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1032 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1033 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1034 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1035 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1036 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1037 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1038 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1039 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1040 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1041 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1042 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1043 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1044 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1045 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1046 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1047 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1048 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1049 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1050 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1051 >
1052 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1053 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1054 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1055 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1056 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1057 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1058 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1059 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1060 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1061 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1062 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1063 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1064 >          }
1065 >          else if(currentHistogram.inputVariables.size() == 2){
1066 >            TH2D* histo;
1067 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1068 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1069 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1070 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1071 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1072 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1073 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1074 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1075 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1076 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1077 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1078 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1079 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1080 >                                                                                                     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1081 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1082 >                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1083 >                                                                                                     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1084 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1085 >                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1086 >                                                                                                     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1087 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1088 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1089 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1090 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1091 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1092 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1093 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1094 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1095 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1096 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1097 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1098 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1099 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1100 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1101 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1102 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1103 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1104 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1105 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1106 >                                                                                              cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1107 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1108 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1109 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1110 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1111 >                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1112 >                                                                                          cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1113 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1114 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1115 >                                                                                          cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1116 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1117 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1118 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1119 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1120 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1121 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1122 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1123 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1124 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1125 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1126 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1127 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1128 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1129 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1130 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1131 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1132 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1133 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1134 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1135 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1136 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1137 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1138 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1139 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1140 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1141 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1142 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1143 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1144 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1145 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1146 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1147 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1148 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1149 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1150 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1151 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1152 >          }
1153 >
1154 >        }
1155  
983      //fills histograms with the sizes of collections
1156  
1157 <      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1158 <        
1159 <        string currentObject = objectsToPlot.at(currentObjectIndex);
1160 <        string objectToPlot = "";
1161 <        
1162 <        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1163 <        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1164 <        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1165 <        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1166 <        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1167 <        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1168 <        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1169 <        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1170 <        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1171 <        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1172 <        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1173 <        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1174 <        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1175 <        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1176 <        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1177 <        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1178 <        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1179 <        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1180 <        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1181 <        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1182 <        else objectToPlot = currentObject;
1183 <        
1184 <        string tempCurrentObject = objectToPlot;
1185 <        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1186 <        string histoName = "num" + tempCurrentObject;
1187 <        
1188 <
1189 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1190 <
1191 <        //count the number of objects passing all cuts
1192 <        int numToPlot = 0;
1193 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1194 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1195 <        }
1196 <
1197 <        if(objectToPlot == "primaryvertexs"){
1198 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1199 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1200 <        }
1201 <        else {
1202 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1203 <        }
1204 <      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1157 >        //fills histograms with the sizes of collections
1158 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1159 >
1160 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1161 >          string objectToPlot = "";
1162 >
1163 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1164 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1165 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1166 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1167 >          else if(currentObject == "electron-photon pairs")                objectToPlot = "electronPhotonPairs";
1168 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1169 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1170 >          else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1171 >          else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1172 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1173 >          else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1174 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1175 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1176 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1177 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1178 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1179 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1180 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1181 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1182 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1183 >          else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1184 >          else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1185 >          else if(currentObject == "photon-secondary jet pairs")       objectToPlot = "photonSecondaryJetPairs";
1186 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1187 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1188 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1189 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1190 >          else objectToPlot = currentObject;
1191 >
1192 >          string tempCurrentObject = objectToPlot;
1193 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1194 >          string histoName = "num" + tempCurrentObject;
1195 >
1196 >
1197 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1198 >            flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1199 >            int numToPlot = 0;
1200 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1201 >              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1202 >            }
1203 >
1204 >            if(objectToPlot == "primaryvertexs"){
1205 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1206 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1207 >            }
1208 >            else {
1209 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1210 >            }
1211 >          }
1212 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1213 >
1214 >
1215 >      } // end if(eventPassedPreviousCuts.at(currentDir))
1216 >    } // end loop over cuts
1217 >
1218 >    if (!useEDMFormat_ && eventPassedAllCuts){
1219 >      // Assign BNTree variables
1220 >      for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1221 >        BranchSpecs brSpecs = treeBranches_.at(iBranch);
1222 >        string coll = brSpecs.inputCollection;
1223 >        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1224 >
1225 >        if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1226 >        else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1227 >        else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1228 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1229 >        else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1230 >        else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1231 >        else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
1232 >        else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).back());
1233 >        else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).back());
1234 >        else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).back());
1235 >        else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).back());
1236 >        else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).back());
1237 >        else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1238 >        else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).back());
1239 >        else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1240 >        else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1241 >        else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).back());
1242 >        else if(coll == "stops"
1243 >                && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1244 >      } // end loop over branches
1245 >
1246 >      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1247 >      BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1248      }
1249  
1250 <  } //end loop over channel
1250 >    (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1251 >
1252 >  } // end loop over channel
1253  
1254    masterCutFlow_->fillCutFlow(masterScaleFactor);
1255  
1256 +  event.put (channelDecisions, "channelDecisions");
1257 +
1258   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1259  
1260  
# Line 1076 | Line 1295 | OSUAnalysis::evaluateTriggers (vector<st
1295    //initialize to false until a chosen trigger is passed
1296    bool triggerDecision = false;
1297  
1298 +  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1299    //loop over all triggers defined in the event
1300    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1301  
1302 +    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1303 +
1304      //we're only interested in triggers that actually passed
1305      if(trigger->pass != 1) continue;
1306  
# Line 1089 | Line 1311 | OSUAnalysis::evaluateTriggers (vector<st
1311      //if the event passes one of the chosen triggers, set triggerDecision to true
1312      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1313        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1314 <    }  
1314 >    }
1315    }
1316 <  //if none of the veto triggers fired:
1316 >
1317 >  printAllTriggers_ = false;  // only print triggers once, not every event
1318 >
1319 >  //if none of the veto triggers fired:
1320    //return the OR of all the chosen triggers
1321    if (triggersToTest.size() != 0) return triggerDecision;
1322    //or if no triggers were defined return true
# Line 1553 | Line 1778 | OSUAnalysis::valueLookup (const BNmuon*
1778      value = object->isGlobalMuon > 0                \
1779        && object->isPFMuon > 0                        \
1780        && object->normalizedChi2 < 10                \
1781 <                                  && object->numberOfValidMuonHits > 0        \
1781 >      && object->numberOfValidMuonHits > 0        \
1782        && object->numberOfMatchedStations > 1        \
1783        && fabs(object->correctedD0Vertex) < 0.2        \
1784        && fabs(object->correctedDZ) < 0.5        \
# Line 1564 | Line 1789 | OSUAnalysis::valueLookup (const BNmuon*
1789      value = object->isGlobalMuon > 0                \
1790        && object->isPFMuon > 0                        \
1791        && object->normalizedChi2 < 10                \
1792 <                                  && object->numberOfValidMuonHits > 0        \
1792 >      && object->numberOfValidMuonHits > 0        \
1793        && object->numberOfMatchedStations > 1        \
1794        && object->numberOfValidPixelHits > 0        \
1795        && object->numberOfLayersWithMeasurement > 5;
# Line 1619 | Line 1844 | OSUAnalysis::valueLookup (const BNmuon*
1844      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1845      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1846      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1847 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1848 <         || fabs (object->correctedDZ / dzError) > 99.0;
1847 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1848 >      || fabs (object->correctedDZ / dzError) > 99.0;
1849      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1850    }
1851  
# Line 2019 | Line 2244 | OSUAnalysis::valueLookup (const BNelectr
2244      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2245      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2246      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2247 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2248 <         || fabs (object->correctedDZ / dzError) > 99.0;
2247 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2248 >      || fabs (object->correctedDZ / dzError) > 99.0;
2249      value = !value;
2250    }
2251  
# Line 2112 | Line 2337 | OSUAnalysis::valueLookup (const BNevent*
2337    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2338    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2339    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2340 <
2340 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2341    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2342  
2343    value = applyFunction(function, value);
# Line 2888 | Line 3113 | OSUAnalysis::valueLookup (const BNmuon*
3113    return value;
3114   }
3115  
3116 + //!muon-photon pair valueLookup
3117 + double
3118 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3119 +
3120 +  double value = 0.0;
3121 +
3122 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3123 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3124 +  else if(variable == "photonEta") value = object2->eta;
3125 +  else if(variable == "muonEta") value = object1->eta;
3126 +  else if(variable == "photonPhi") value = object2->phi;
3127 +  else if(variable == "muonPhi") value = object1->phi;
3128 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3129 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3130 +  else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3131 +  else if(variable == "invMass"){
3132 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3133 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3134 +    value = (fourVector1 + fourVector2).M();
3135 +  }
3136 +  else if(variable == "pt"){
3137 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3138 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3139 +    value = (fourVector1 + fourVector2).Pt();
3140 +  }
3141 +  else if(variable == "threeDAngle")
3142 +    {
3143 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3144 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3145 +      value = (threeVector1.Angle(threeVector2));
3146 +    }
3147 +  else if(variable == "alpha")
3148 +    {
3149 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3150 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3151 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3152 +      value = (pi-threeVector1.Angle(threeVector2));
3153 +    }
3154 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3155 +
3156 +  value = applyFunction(function, value);
3157 +
3158 +  return value;
3159 + }
3160 +
3161 + //!electron-photon pair valueLookup
3162 + double
3163 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3164 +
3165 +  double value = 0.0;
3166 +
3167 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3168 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3169 +  else if(variable == "photonEta") value = object2->eta;
3170 +  else if(variable == "electronEta") value = object1->eta;
3171 +  else if(variable == "photonPhi") value = object2->phi;
3172 +  else if(variable == "electronPhi") value = object1->phi;
3173 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3174 +  else if(variable == "photonGenMotherId") value = object2->genMotherId;
3175 +  else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3176 +  else if(variable == "invMass"){
3177 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3178 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3179 +    value = (fourVector1 + fourVector2).M();
3180 +  }
3181 +  else if(variable == "pt"){
3182 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3183 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3184 +    value = (fourVector1 + fourVector2).Pt();
3185 +  }
3186 +  else if(variable == "threeDAngle")
3187 +    {
3188 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3189 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3190 +      value = (threeVector1.Angle(threeVector2));
3191 +    }
3192 +  else if(variable == "alpha")
3193 +    {
3194 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3195 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3196 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3197 +      value = (pi-threeVector1.Angle(threeVector2));
3198 +    }
3199 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3200 +
3201 +  value = applyFunction(function, value);
3202 +
3203 +  return value;
3204 + }
3205 +
3206   //!electron-electron pair valueLookup
3207   double
3208   OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
# Line 3017 | Line 3332 | OSUAnalysis::valueLookup (const BNelectr
3332  
3333    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3334    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3335 +  else if(variable == "jetEta") value = object2->eta;
3336 +  else if(variable == "jetPhi") value = object2->phi;
3337 +  else if(variable == "electronEta") value = object1->eta;
3338 +  else if(variable == "electronPhi") value = object1->phi;
3339    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3340    else if(variable == "invMass"){
3341      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3044 | Line 3363 | OSUAnalysis::valueLookup (const BNelectr
3363    return value;
3364   }
3365  
3366 + //!photon-jet pair valueLookup
3367 + double
3368 + OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3369 +
3370 +  double value = 0.0;
3371 +
3372 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3373 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3374 +  else if(variable == "jetEta") value = object2->eta;
3375 +  else if(variable == "jetPhi") value = object2->phi;
3376 +  else if(variable == "photonEta") value = object1->eta;
3377 +  else if(variable == "photonPhi") value = object1->phi;
3378 +  else if(variable == "photonGenMotherId") value = object1->genMotherId;
3379 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3380 +  else if(variable == "invMass"){
3381 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3382 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3383 +    value = (fourVector1 + fourVector2).M();
3384 +  }
3385 +  else if(variable == "pt"){
3386 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3387 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3388 +    value = (fourVector1 + fourVector2).Pt();
3389 +  }
3390 +  else if(variable == "threeDAngle")
3391 +    {
3392 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3393 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3394 +      value = (threeVector1.Angle(threeVector2));
3395 +    }
3396 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3397 +  value = applyFunction(function, value);
3398 +
3399 +  return value;
3400 + }
3401 +
3402   //!muon-jet pair valueLookup
3403   double
3404   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3051 | Line 3406 | OSUAnalysis::valueLookup (const BNmuon*
3406    double value = 0.0;
3407  
3408    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3409 +  else if(variable == "jetEta") value = object2->eta;
3410 +  else if(variable == "jetPhi") value = object2->phi;
3411 +  else if(variable == "muonEta") value = object1->eta;
3412 +  else if(variable == "muonPhi") value = object1->phi;
3413    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3414    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3415    else if(variable == "invMass"){
# Line 3078 | Line 3437 | OSUAnalysis::valueLookup (const BNmuon*
3437  
3438    return value;
3439   }
3081
3440   //!jet-jet pair valueLookup
3441   double
3442   OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3381 | Line 3739 | OSUAnalysis::valueLookup (const BNstop*
3739      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3740        vertex_rank++;
3741        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3742 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3743 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3742 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3743 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3744  
3745        if(abs(dist) < abs(minDistToVertex)){
3746          value = vertex_rank;
# Line 3546 | Line 3904 | void OSUAnalysis::setObjectFlags(cut &cu
3904      string obj1, obj2;
3905      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3906      if (inputType==obj1 ||
3907 <          inputType==obj2) {
3907 >        inputType==obj2) {
3908        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3909        // and the inputType is a member of the pair.
3910        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3558 | Line 3916 | void OSUAnalysis::setObjectFlags(cut &cu
3916  
3917    for (uint object = 0; object != inputCollection->size(); object++){
3918  
3919 <    bool decision = true;//object passes if this cut doesn't cut on that type of object
3919 >    bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
3920 >    bool plotDecision = true;
3921  
3922      if(currentCut.inputCollection == inputType){
3923  
# Line 3570 | Line 3929 | void OSUAnalysis::setObjectFlags(cut &cu
3929          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3930  
3931        }
3932 <      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3932 >      if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
3933        else{
3934          bool tempDecision = true;
3935          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
# Line 3579 | Line 3938 | void OSUAnalysis::setObjectFlags(cut &cu
3938            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
3939              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
3940          }
3941 <        decision = tempDecision;
3941 >        cutDecision = tempDecision;
3942        }
3943 +      //invert the cut for plotting if this cut is a veto
3944 +      if(currentCut.isVeto) plotDecision = !cutDecision;
3945 +      else plotDecision = cutDecision;
3946      }
3947  
3948 <    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3948 >    //if(cutDecision != plotDecision && currentCut.variables.at(0) == "pt") cout << "---------------\n" << cutDecision << " " << plotDecision << endl;
3949 >    individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
3950  
3951 <    //set flags for objects that pass each cut AND all the previous cuts
3952 <    bool previousCumulativeFlag = true;
3951 >    //set flags for objects that pass this cut AND all the previous cuts
3952 >    bool previousCumulativeCutFlag = true;
3953      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3954 <      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
3955 <      else{ previousCumulativeFlag = false; break;}
3954 >      if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
3955 >      else{ previousCumulativeCutFlag = false; break;}
3956      }
3957 <    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3957 >    previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
3958 >    bool previousCumulativePlotFlag = true;
3959 >    for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
3960 >      if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
3961 >      else{ previousCumulativePlotFlag = false; break;}
3962 >    }
3963 >    previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
3964 >
3965 >    //if(inputType == "muons") cout << previousCumulativeCutFlag << " " << previousCumulativePlotFlag << " " << currentCut.variables.at(0) << "\n---------------\n\n";
3966 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
3967  
3968    }
3969  
# Line 3600 | Line 3972 | void OSUAnalysis::setObjectFlags(cut &cu
3972  
3973   template <class InputCollection1, class InputCollection2>
3974   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
3975 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
3975 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
3976  
3977  
3978    bool sameObjects = false;
# Line 3616 | Line 3988 | void OSUAnalysis::setObjectFlags(cut &cu
3988    // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3989    if (currentCut.inputCollection == inputType) {
3990      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3991 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3992 <      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3991 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
3992 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
3993      }
3994      if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3995        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3996 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3997 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3996 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
3997 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
3998        }
3999      }
4000    }
# Line 3635 | Line 4007 | void OSUAnalysis::setObjectFlags(cut &cu
4007        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4008  
4009  
4010 <      bool decision = true;//object passes if this cut doesn't cut on that type of object
4010 >      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4011 >      bool plotDecision = true;
4012  
4013        if(currentCut.inputCollection == inputType){
4014  
# Line 3647 | Line 4020 | void OSUAnalysis::setObjectFlags(cut &cu
4020            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4021          }
4022  
4023 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
4023 >        if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4024          else{
4025            bool tempDecision = subcutDecisions.at(0);
4026            for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
# Line 3656 | Line 4029 | void OSUAnalysis::setObjectFlags(cut &cu
4029              else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4030                tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4031            }
4032 <          decision = tempDecision;
4032 >          cutDecision = tempDecision;
4033          }
4034 +        //invert the cut for plotting if this cut is a veto
4035 +        if(currentCut.isVeto) plotDecision = !cutDecision;
4036 +        else plotDecision = cutDecision;
4037 +      }
4038 +      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4039 +      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4040 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4041 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4042 +      }
4043 +      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4044 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4045 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4046        }
4047 <      // if (decision) isPassObj1.at(object1) = true;
4048 <      // if (decision) isPassObj2.at(object2) = true;
4049 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
4050 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4051 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
4052 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
4047 >
4048 >      //set flags for objects that pass this cut AND all the previous cuts
4049 >      bool previousCumulativeCutFlag = true;
4050 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4051 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4052 >        else{ previousCumulativeCutFlag = false; break;}
4053        }
4054 +      previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4055  
4056 <      //set flags for objects that pass each cut AND all the previous cuts
3671 <      bool previousCumulativeFlag = true;
4056 >      bool previousCumulativePlotFlag = true;
4057        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4058 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
4059 <        else{ previousCumulativeFlag = false; break;}
4058 >        if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4059 >        else{ previousCumulativePlotFlag = false; break;}
4060        }
4061 +      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4062 +      
4063        //apply flags for the components of the composite object as well
4064 <      bool currentCumulativeFlag = true;
4065 <      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
4066 <      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
4067 <      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
4068 <      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
4069 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
4070 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4071 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
4072 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
4064 >      bool currentCumulativeCutFlag = true;
4065 >      bool currentCumulativePlotFlag = true;
4066 >
4067 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4068 >      else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4069 >      else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4070 >      else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4071 >
4072 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4073 >      else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4074 >      else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4075 >      else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4076 >
4077 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4078 >
4079 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4080 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4081 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4082 >      }
4083 >
4084 >      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4085 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4086 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4087        }
4088 +
4089        counter++;
4090  
4091      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
# Line 3692 | Line 4094 | void OSUAnalysis::setObjectFlags(cut &cu
4094   }
4095  
4096  
4097 < bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
4097 > bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4098    // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4099    // all cuts up to currentCutIndex
4100    bool previousCumulativeFlag = true;
4101    for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4102 <    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
4102 >    bool tempFlag = false;
4103 >    if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4104 >    else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4105 >
4106 >    if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4107      else {
4108        previousCumulativeFlag = false; break;
4109      }
# Line 3706 | Line 4112 | bool OSUAnalysis::getPreviousCumulativeF
4112   }
4113  
4114  
4115 +
4116 +
4117 + template <class InputCollection>
4118 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4119 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4120 +
4121 +  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;
4122 +  for (uint object = 0; object != inputCollection->size(); object++) {
4123 +
4124 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4125 +
4126 +    string inputVariable = parameters.inputVariable;
4127 +    string function = "";
4128 +    string stringValue = "";
4129 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4130 +    BNTreeBranchVals_.at(parameters.name).push_back(value);
4131 +
4132 +  }
4133 + }
4134 +
4135 +
4136   template <class InputCollection>
4137 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4137 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4138 >
4139  
4140    for (uint object = 0; object != inputCollection->size(); object++){
4141  
4142 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4142 >    //cout << "flags.at(object).second: " << flags.at(object).second << endl;
4143 >
4144 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4145  
4146      string currentString = parameters.inputVariables.at(0);
4147      string inputVariable = "";
# Line 3728 | Line 4158 | void OSUAnalysis::fill1DHistogram(TH1* h
4158      string stringValue = "";
4159      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4160      histo->Fill(value,scaleFactor);
4161 +
4162      if (printEventInfo_) {
4163        // Write information about event to screen, for testing purposes.
4164        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3737 | Line 4168 | void OSUAnalysis::fill1DHistogram(TH1* h
4168   }
4169  
4170   template <class InputCollection1, class InputCollection2>
4171 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4171 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4172  
4173    bool sameObjects = false;
4174    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3750 | Line 4181 | void OSUAnalysis::fill1DHistogram(TH1* h
4181  
4182        pairCounter++;
4183        //only take objects which have passed all cuts and pairs which have passed all cuts
4184 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4185 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4186 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4184 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4185 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4186 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4187  
4188        string currentString = parameters.inputVariables.at(0);
4189        string inputVariable = "";
# Line 3777 | Line 4208 | void OSUAnalysis::fill1DHistogram(TH1* h
4208  
4209  
4210   template <class InputCollection>
4211 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
4211 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4212  
4213    for (uint object = 0; object != inputCollection->size(); object++){
4214  
4215 <    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
4215 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4216  
4217      string stringValue = "";
4218      string currentString = parameters.inputVariables.at(0);
# Line 3818 | Line 4249 | void OSUAnalysis::fill2DHistogram(TH2* h
4249   }
4250  
4251   template <class InputCollection1, class InputCollection2>
4252 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
4252 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4253  
4254    bool sameObjects = false;
4255    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 3832 | Line 4263 | void OSUAnalysis::fill2DHistogram(TH2* h
4263        pairCounter++;
4264  
4265        //only take objects which have passed all cuts and pairs which have passed all cuts
4266 <      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
4267 <      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
4268 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
4266 >      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4267 >      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4268 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4269  
4270        string stringValue = "";
4271        string currentString = parameters.inputVariables.at(0);
# Line 3994 | Line 4425 | OSUAnalysis::chosenVertex ()
4425   {
4426    const BNprimaryvertex *chosenVertex = 0;
4427    if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4428 <    vector<bool> vertexFlags;
4428 >    flagPair vertexFlags;
4429      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4430        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4431          vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
# Line 4002 | Line 4433 | OSUAnalysis::chosenVertex ()
4433        }
4434      }
4435      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4436 <      if(!vertexFlags.at(vertexIndex)) continue;
4436 >      if(!vertexFlags.at(vertexIndex).first) continue;
4437        chosenVertex = & primaryvertexs->at(vertexIndex);
4438        break;
4439      }
# Line 4018 | Line 4449 | OSUAnalysis::chosenMET ()
4449   {
4450    const BNmet *chosenMET = 0;
4451    if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4452 <    vector<bool> metFlags;
4452 >    flagPair metFlags;
4453      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4454        if (cumulativeFlags.at("mets").at(i).size()){
4455          metFlags = cumulativeFlags.at("mets").at(i);
# Line 4026 | Line 4457 | OSUAnalysis::chosenMET ()
4457        }
4458      }
4459      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4460 <      if(!metFlags.at(metIndex)) continue;
4460 >      if(!metFlags.at(metIndex).first) continue;
4461        chosenMET = & mets->at(metIndex);
4462        break;
4463      }
# Line 4042 | Line 4473 | OSUAnalysis::chosenElectron ()
4473   {
4474    const BNelectron *chosenElectron = 0;
4475    if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4476 <    vector<bool> electronFlags;
4476 >    flagPair electronFlags;
4477      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4478        if (cumulativeFlags.at("electrons").at(i).size()){
4479          electronFlags = cumulativeFlags.at("electrons").at(i);
# Line 4050 | Line 4481 | OSUAnalysis::chosenElectron ()
4481        }
4482      }
4483      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4484 <      if(!electronFlags.at(electronIndex)) continue;
4484 >      if(!electronFlags.at(electronIndex).first) continue;
4485        chosenElectron = & electrons->at(electronIndex);
4486        break;
4487      }
# Line 4061 | Line 4492 | OSUAnalysis::chosenElectron ()
4492    return chosenElectron;
4493   }
4494  
4495 +
4496   const BNmuon *
4497   OSUAnalysis::chosenMuon ()
4498   {
4499    const BNmuon *chosenMuon = 0;
4500    if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4501 <    vector<bool> muonFlags;
4501 >    flagPair muonFlags;
4502      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4503        if (cumulativeFlags.at("muons").at(i).size()){
4504          muonFlags = cumulativeFlags.at("muons").at(i);
# Line 4074 | Line 4506 | OSUAnalysis::chosenMuon ()
4506        }
4507      }
4508      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4509 <      if(!muonFlags.at(muonIndex)) continue;
4509 >      if(!muonFlags.at(muonIndex).first) continue;
4510        chosenMuon = & muons->at(muonIndex);
4511        break;
4512      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines