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.72 by lantonel, Wed May 29 20:15:01 2013 UTC vs.
Revision 1.83 by biliu, Wed Jun 5 03:18:56 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 +  treeBranchSets_   (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
32    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
33    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36 >  minBtag_ (cfg.getParameter<int> ("minBtag")),
37 >  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
38 >  printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
39 >  printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
40    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
41    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
42    GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
43 < {
43 > {
44  
45    TH1::SetDefaultSumw2 ();
46  
# Line 46 | Line 51 | OSUAnalysis::OSUAnalysis (const edm::Par
51        muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
52        electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
53      }
54 +    if (applyBtagSF_){
55 +      bTagSFWeight_ = new BtagSFWeight;
56 +    }
57    }
58    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
59      stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
# Line 57 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65  
66    //always get vertex collection so we can assign the primary vertex in the event
67    objectsToGet.push_back("primaryvertexs");
60
61  //always make the plot of number of primary vertices (to check pile-up reweighting)
68    objectsToPlot.push_back("primaryvertexs");
69 +  objectsToCut.push_back("primaryvertexs");
70 +
71  
72    //always get the MC particles to do GEN-matching
73    objectsToGet.push_back("mcparticles");
# Line 67 | Line 75 | OSUAnalysis::OSUAnalysis (const edm::Par
75    //always get the event collection to do pile-up reweighting
76    objectsToGet.push_back("events");
77  
78 +
79 +  // Parse the tree variable definitions.    
80 +  for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
81 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
82 +    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; }  
83 +    objectsToGet.push_back(tempInputCollection);
84 +    objectsToCut.push_back(tempInputCollection);
85 +
86 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
87 +
88 +    for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
89 +      BranchSpecs br;
90 +      br.inputCollection = tempInputCollection;
91 +      br.inputVariable = branchList.at(iBranch);  
92 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);  
93 +      br.name = string(newName.Data());  
94 +      treeBranches_.push_back(br);
95 +    }  
96 +
97 +  } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
98 +
99 +
100    //parse the histogram definitions
101    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
102  
# Line 90 | Line 120 | OSUAnalysis::OSUAnalysis (const edm::Par
120        }
121        objectsToPlot.push_back(tempInputCollection);
122        objectsToCut.push_back(tempInputCollection);
123 <    }
94 <    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
123 >    } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
124        string obj1;
125        string obj2;
126        getTwoObjs(tempInputCollection, obj1, obj2);
# Line 105 | Line 134 | OSUAnalysis::OSUAnalysis (const edm::Par
134        objectsToGet.push_back(tempInputCollection);
135        objectsToGet.push_back(obj1);
136        objectsToGet.push_back(obj2ToGet);
137 +    } // end else
138 +
139  
109    }
140  
141      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
142  
# Line 127 | Line 157 | OSUAnalysis::OSUAnalysis (const edm::Par
157        histograms.push_back(tempHistogram);
158  
159      }
160 <  }
160 >  } //   for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
161 >
162    //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
163    sort( objectsToPlot.begin(), objectsToPlot.end() );
164    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
# Line 349 | Line 380 | OSUAnalysis::OSUAnalysis (const edm::Par
380      TFileDirectory subDir = fs_->mkdir( channelName );
381      //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
382      if(GetPlotsAfterEachCut_){
383 <       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
384 <            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
385 <            directories.push_back(subSubDir);
386 <            map<string, TH1D*> oneDhistoMap;
387 <            oneDHistsTmp.push_back(oneDhistoMap);
388 <            map<string, TH2D*> twoDhistoMap;
389 <            twoDHistsTmp.push_back(twoDhistoMap);
383 >      for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
384 >        TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
385 >        directories.push_back(subSubDir);
386 >        map<string, TH1D*> oneDhistoMap;
387 >        oneDHistsTmp.push_back(oneDhistoMap);
388 >        map<string, TH2D*> twoDhistoMap;
389 >        twoDHistsTmp.push_back(twoDhistoMap);
390        }
391        oneDHists_.push_back(oneDHistsTmp);
392        twoDHists_.push_back(twoDHistsTmp);
393      }
394 <   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
395 <   else{
394 >    //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
395 >    else{
396        map<string, TH1D*> oneDhistoMap;
397        oneDHistsTmp.push_back(oneDhistoMap);
398        map<string, TH2D*> twoDhistoMap;
# Line 369 | Line 400 | OSUAnalysis::OSUAnalysis (const edm::Par
400        oneDHists_.push_back(oneDHistsTmp);
401        twoDHists_.push_back(twoDHistsTmp);
402        directories.push_back(subDir);
372   }
373    //book all histograms included in the configuration
374    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
375    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
376      histogram currentHistogram = histograms.at(currentHistogramIndex);
377      int numBinsElements = currentHistogram.bins.size();
378      int numInputVariables = currentHistogram.inputVariables.size();
379      int numBinEdgesX = currentHistogram.variableBinsX.size();
380      int numBinEdgesY = currentHistogram.variableBinsY.size();
381
382      if(numBinsElements == 1){
383        if(numBinEdgesX > 1){
384          if(numBinEdgesY > 1)
385            numBinsElements = 6;
386          else
387            numBinsElements = 3;
388        }
389      }
390      if(numBinsElements != 3 && numBinsElements !=6){
391        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
392        exit(0);
393      }
394      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
395        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
396        exit(0);
397      }
398      else if(numBinsElements == 3){
399        if (currentHistogram.bins.size () == 3)
400          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));
401        else
402          {
403            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
404          }
405      }
406      else if(numBinsElements == 6){
407        if (currentHistogram.bins.size () == 6)
408          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));
409        else
410          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 ());
411      }
412
413
414      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
415
416      // bin      particle type
417      // ---      -------------
418      //  0        unmatched
419      //  1        u
420      //  2        d
421      //  3        s
422      //  4        c
423      //  5        b
424      //  6        t
425      //  7        e
426      //  8        mu
427      //  9        tau
428      // 10        nu
429      // 11        g
430      // 12        gamma
431      // 13        Z
432      // 14        W
433      // 15        light meson
434      // 16        K meson
435      // 17        D meson
436      // 18        B meson
437      // 19        light baryon
438      // 20        strange baryon
439      // 21        charm baryon
440      // 22        bottom baryon
441      // 23        QCD string
442      // 24        other
443
444      vector<TString> labelArray;
445      labelArray.push_back("unmatched");
446      labelArray.push_back("u");
447      labelArray.push_back("d");
448      labelArray.push_back("s");
449      labelArray.push_back("c");
450      labelArray.push_back("b");
451      labelArray.push_back("t");
452      labelArray.push_back("e");
453      labelArray.push_back("#mu");
454      labelArray.push_back("#tau");
455      labelArray.push_back("#nu");
456      labelArray.push_back("g");
457      labelArray.push_back("#gamma");
458      labelArray.push_back("Z");
459      labelArray.push_back("W");
460      labelArray.push_back("light meson");
461      labelArray.push_back("K meson");
462      labelArray.push_back("D meson");
463      labelArray.push_back("B meson");
464      labelArray.push_back("light baryon");
465      labelArray.push_back("strange baryon");
466      labelArray.push_back("charm baryon");
467      labelArray.push_back("bottom baryon");
468      labelArray.push_back("QCD string");
469      labelArray.push_back("other");
470
471      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
472        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
473          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
474        }
475        else {
476          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
477          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
478        }
479      }
480      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
481        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
482        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
483      }
403  
404      }
405  
406 <    // Book a histogram for the number of each object type to be plotted.
407 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
408 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
409 <      string currentObject = objectsToPlot.at(currentObjectIndex);
410 <      int maxNum = 10;
411 <      if(currentObject == "mcparticles") maxNum = 50;
412 <      else if(currentObject == "primaryvertexs") maxNum = 50;
413 <
414 <      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
415 <      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
416 <      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
417 <      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
418 <      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
419 <      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
420 <      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
421 <      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
422 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
423 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
424 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
425 <      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
426 <      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
427 <      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
428 <      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
429 <      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
430 <      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
431 <      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
432 <      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
433 <
434 <      currentObject.at(0) = toupper(currentObject.at(0));
435 <      string histoName = "num" + currentObject;
436 <
437 <      if(histoName == "numPrimaryvertexs"){
438 <        string newHistoName = histoName + "BeforePileupCorrection";
439 <        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);
440 <        newHistoName = histoName + "AfterPileupCorrection";
441 <        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);
406 >
407 >    //book all histograms included in the configuration
408 >    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
409 >      
410 >      TTree* newTree = directories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));  
411 >      BNTrees_.push_back(newTree);      
412 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
413 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
414 >        vector<float> newVec;  
415 >        BNTreeBranchVals_[currentVar.name] = newVec;  
416 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
417 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
418 >
419 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
420 >
421 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
422 >        int numBinsElements = currentHistogram.bins.size();
423 >        int numInputVariables = currentHistogram.inputVariables.size();
424 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
425 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
426 >        
427 >        if(numBinsElements == 1){
428 >          if(numBinEdgesX > 1){
429 >            if(numBinEdgesY > 1)
430 >              numBinsElements = 6;
431 >            else
432 >              numBinsElements = 3;
433 >          }
434 >        }
435 >        if(numBinsElements != 3 && numBinsElements !=6){
436 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
437 >          exit(0);
438 >        }
439 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
440 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
441 >          exit(0);
442 >        }
443 >        else if(numBinsElements == 3){
444 >          if (currentHistogram.bins.size () == 3)
445 >            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));
446 >          else
447 >            {
448 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
449 >            }
450 >        }
451 >        else if(numBinsElements == 6){
452 >          if (currentHistogram.bins.size () == 6)
453 >            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));
454 >          else
455 >            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 ());
456 >        }
457 >
458 >
459 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
460 >
461 >        // bin      particle type
462 >        // ---      -------------
463 >        //  0        unmatched
464 >        //  1        u
465 >        //  2        d
466 >        //  3        s
467 >        //  4        c
468 >        //  5        b
469 >        //  6        t
470 >        //  7        e
471 >        //  8        mu
472 >        //  9        tau
473 >        // 10        nu
474 >        // 11        g
475 >        // 12        gamma
476 >        // 13        Z
477 >        // 14        W
478 >        // 15        light meson
479 >        // 16        K meson
480 >        // 17        D meson
481 >        // 18        B meson
482 >        // 19        light baryon
483 >        // 20        strange baryon
484 >        // 21        charm baryon
485 >        // 22        bottom baryon
486 >        // 23        QCD string
487 >        // 24        other
488 >
489 >        vector<TString> labelArray;
490 >        labelArray.push_back("unmatched");
491 >        labelArray.push_back("u");
492 >        labelArray.push_back("d");
493 >        labelArray.push_back("s");
494 >        labelArray.push_back("c");
495 >        labelArray.push_back("b");
496 >        labelArray.push_back("t");
497 >        labelArray.push_back("e");
498 >        labelArray.push_back("#mu");
499 >        labelArray.push_back("#tau");
500 >        labelArray.push_back("#nu");
501 >        labelArray.push_back("g");
502 >        labelArray.push_back("#gamma");
503 >        labelArray.push_back("Z");
504 >        labelArray.push_back("W");
505 >        labelArray.push_back("light meson");
506 >        labelArray.push_back("K meson");
507 >        labelArray.push_back("D meson");
508 >        labelArray.push_back("B meson");
509 >        labelArray.push_back("light baryon");
510 >        labelArray.push_back("strange baryon");
511 >        labelArray.push_back("charm baryon");
512 >        labelArray.push_back("bottom baryon");
513 >        labelArray.push_back("QCD string");
514 >        labelArray.push_back("other");
515 >
516 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
517 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
518 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
519 >          }
520 >          else {
521 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
522 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
523 >          }
524 >        }
525 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
526 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
527 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
528 >        }
529 >
530 >      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
531 >
532 >
533 >      // Book a histogram for the number of each object type to be plotted.
534 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
535 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
536 >        string currentObject = objectsToPlot.at(currentObjectIndex);
537 >        int maxNum = 10;
538 >        if(currentObject == "mcparticles") maxNum = 50;
539 >        else if(currentObject == "primaryvertexs") maxNum = 50;
540 >
541 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
542 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
543 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
544 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
545 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
546 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
547 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
548 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
549 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
550 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
551 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
552 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
553 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
554 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
555 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
556 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
557 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
558 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
559 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
560 >
561 >        currentObject.at(0) = toupper(currentObject.at(0));
562 >        string histoName = "num" + currentObject;
563 >
564 >        if(histoName == "numPrimaryvertexs"){
565 >          string newHistoName = histoName + "BeforePileupCorrection";
566 >          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);
567 >          newHistoName = histoName + "AfterPileupCorrection";
568 >          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);
569 >        }
570 >        else
571 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
572        }
573 <      else
525 <        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
526 <    }
527 <   }//end of loop over directories
573 >    }//end of loop over directories
574      channels.push_back(tempChannel);
575      tempChannel.cuts.clear();
576    }//end loop over channels
# Line 538 | Line 584 | OSUAnalysis::OSUAnalysis (const edm::Par
584    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
585  
586  
587 < }
587 > } // end constructor OSUAnalysis::OSUAnalysis()
588 >
589  
590   OSUAnalysis::~OSUAnalysis ()
591   {
592 +
593    // Destroying the CutFlow objects causes the cut flow numbers and time
594    // information to be printed to standard output.
595    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 636 | Line 684 | OSUAnalysis::analyze (const edm::Event &
684      counterMap passingCounter;
685      cumulativeFlags.clear ();
686  
687 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
688 +         iter != BNTreeBranchVals_.end(); iter++) {
689 +      iter->second.clear();  // clear array
690 +    }
691 +
692      bool triggerDecision = true;
693      if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
694        triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
# Line 685 | Line 738 | OSUAnalysis::analyze (const edm::Event &
738                                                                     "muon-muon pairs");
739  
740          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
741 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
742 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
743 <                                                                   "muon-secondary muon pairs");
741 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
742 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
743 >                                                                             "muon-secondary muon pairs");
744  
745          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
746 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
747 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
748 <                                                                   "electron-secondary electron pairs");
746 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
747 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
748 >                                                                                     "electron-secondary electron pairs");
749  
750          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
751                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 703 | Line 756 | OSUAnalysis::analyze (const edm::Event &
756                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
757                                                                         "electron-muon pairs");
758          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
759 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
760 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
761 <                                                                           "jet-jet pairs");
759 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
760 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
761 >                                                                 "jet-jet pairs");
762          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
763 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
764 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
765 <                                                                       "electron-jet pairs");
763 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
764 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
765 >                                                                      "electron-jet pairs");
766          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
767 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
768 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
769 <                                                                       "muon-jet pairs");
767 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
768 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
769 >                                                                  "muon-jet pairs");
770          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
771                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
772                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 735 | Line 788 | OSUAnalysis::analyze (const edm::Event &
788                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
789                                                                   "tau-tau pairs");
790          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
791 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
792 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
793 <                                                                 "tau-track pairs");
791 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
792 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
793 >                                                                   "tau-track pairs");
794          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
795                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
796                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 761 | Line 814 | OSUAnalysis::analyze (const edm::Event &
814      //apply trigger (true if none were specified)
815      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
816  
764
817      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
818  
819        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 778 | Line 830 | OSUAnalysis::analyze (const edm::Event &
830      }
831      double scaleFactor = masterScaleFactor;
832  
833 <    muonScaleFactor_ = electronScaleFactor_ = 1.0;
833 >    muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
834      if(applyLeptonSF_ && datasetType_ != "data"){
835        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
836          vector<bool> muonFlags;
# Line 807 | Line 859 | OSUAnalysis::analyze (const edm::Event &
859          }
860        }
861      }
862 +    if(applyBtagSF_ && datasetType_ != "data"){
863 +     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
864 +        vector<bool> jetFlags;        
865 +        vector<double> jetSFs;
866 +        for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
867 +          if (cumulativeFlags.at("jets").at(i).size()){            
868 +            jetFlags = cumulativeFlags.at("jets").at(i);
869 +            break;          
870 +          }
871 +        }        
872 +        for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
873 +          if(!jetFlags.at(jetIndex)) continue;          
874 +          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt);
875 +          jetSFs.push_back(jetSFTmp);
876 +        }
877 +        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );    
878 +      }
879 +    }
880      scaleFactor *= muonScaleFactor_;
881      scaleFactor *= electronScaleFactor_;
882 <
882 >    scaleFactor *= bTagScaleFactor_;
883      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
814    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
884  
885      if (printEventInfo_) {
886        // Write information about event to screen, for testing purposes.
# Line 821 | Line 890 | OSUAnalysis::analyze (const edm::Event &
890             << "  event=" << events->at(0).evt
891             << endl;
892      }
893 +
894 +
895      //filling histograms
896      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
897 <        uint currentDir;
898 <        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
899 <        else{
900 <          currentDir = currentCut;
830 <        }
831 <        if(eventPassedPreviousCuts.at(currentDir)){
832 <        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
833 <          histogram currentHistogram = histograms.at(histogramIndex);
834 <
835 <      if(currentHistogram.inputVariables.size() == 1){
836 <        TH1D* histo;
837 <        histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
838 <        if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
839 <        else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
840 <        else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
841 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
842 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
843 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
844 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
845 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
846 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
847 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
848 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
849 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
850 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
851 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
852 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
853 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
854 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
855 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
856 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
857 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
858 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
859 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
860 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
861 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
863 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
864 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
866 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
867 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
869 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
870 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
871 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
872 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
873 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
874 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
875 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
876 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
877 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
878 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
879 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
880 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
881 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
882 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
883 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
884 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
885 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
886 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
887 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
888 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
889 <
890 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
891 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
892 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
893 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
894 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
895 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
896 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
897 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
898 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
899 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
900 <        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
901 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
902 <      }
903 <      else if(currentHistogram.inputVariables.size() == 2){
904 <        TH2D* histo;
905 <        histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
906 <        if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
907 <        else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
908 <        else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
909 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
910 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
911 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
912 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
913 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
914 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
915 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
916 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
917 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
918 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
919 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
920 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
921 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
922 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
923 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
924 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
925 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
926 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
927 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
928 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
929 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
930 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
931 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
932 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
933 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
934 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
935 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
936 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
937 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
938 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
939 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
940 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
941 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
942 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
943 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
944 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
945 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
946 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
947 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
948 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
949 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
950 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
951 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
952 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
953 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
954 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
955 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
956 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
957 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
958 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
959 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
960 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
961 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
962 <                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
963 <                                                                                         cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
964 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
965 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
966 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
967 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
968 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
969 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
970 <        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
971 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
897 >      uint currentDir;
898 >      if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
899 >      else{
900 >        currentDir = currentCut;
901        }
902 <    }
902 >      if(eventPassedPreviousCuts.at(currentDir)){
903  
904 +        // Assign BNTree variables
905 +        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
906 +          BranchSpecs brSpecs = treeBranches_.at(iBranch);  
907 +          string coll = brSpecs.inputCollection;  
908 +          if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
909 +
910 +          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));            
911 +          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));
912 +          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));        
913 +          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));
914 +          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
915 +          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
916 +          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).at(currentDir));
917 +          else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).at(currentDir));
918 +          else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).at(currentDir));
919 +          else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).at(currentDir));
920 +          else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).at(currentDir));
921 +          else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).at(currentDir));
922 +          else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir));
923 +          else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).at(currentDir));
924 +          else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).at(currentDir));
925 +          else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir));
926 +          else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).at(currentDir));
927 +          else if(coll == "stops"
928 +                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).at(currentDir));
929 +        } // end loop over branches  
930 +                                                                                          
931 +        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
932 +          histogram currentHistogram = histograms.at(histogramIndex);
933  
934 +          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
935  
936 <    //fills histograms with the sizes of collections
937 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
938 <
939 <      string currentObject = objectsToPlot.at(currentObjectIndex);
940 <      string objectToPlot = "";
941 <
942 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
943 <      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
944 <      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
945 <      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
946 <      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
947 <      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
948 <      else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
949 <      else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
950 <      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
951 <      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
952 <      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
953 <      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
954 <      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
955 <      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
956 <      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
957 <      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
958 <      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
959 <      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
960 <      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
961 <      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
962 <      else objectToPlot = currentObject;
963 <
964 <      string tempCurrentObject = objectToPlot;
965 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
966 <      string histoName = "num" + tempCurrentObject;
967 <
968 <      //set position of primary vertex in event, in order to calculate quantities relative to it
969 <      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
970 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
971 <        int numToPlot = 0;
972 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
973 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
974 <        }
975 <        if(objectToPlot == "primaryvertexs"){
976 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
977 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
978 <        }
979 <        else {
980 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
981 <        }
982 <      }
983 <      else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
984 <      else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
985 <      else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
986 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
987 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
988 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
989 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
990 <      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
991 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
992 <      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
993 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
994 <      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
995 <      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
996 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
997 <      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
998 <      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
999 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1000 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1001 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1002 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1003 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1004 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1005 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1006 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1007 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1008 <      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1009 <      else if(objectToPlot == "primaryvertexs"){
1010 <        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1011 <        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1012 <      }
1013 <      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
936 >          if(currentHistogram.inputVariables.size() == 1){
937 >            TH1D* histo;  
938 >            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
939 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
940 >            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
941 >            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
942 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
943 >            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
944 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
945 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
946 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
947 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
948 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
949 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
950 >            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
951 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
952 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
953 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
954 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
955 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
956 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
957 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
958 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
959 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
960 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
961 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
962 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
963 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
964 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
965 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
966 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
967 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
968 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
969 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
970 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
971 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
972 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
973 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
974 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
975 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
976 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
977 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
978 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
979 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
980 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
981 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
982 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
983 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
984 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
985 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
986 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
987 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
988 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
989 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
990 >
991 >            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
992 >            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
993 >            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
994 >            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
995 >            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
996 >            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
997 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
998 >            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
999 >            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1000 >            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1001 >            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1002 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1003 >          }
1004 >          else if(currentHistogram.inputVariables.size() == 2){
1005 >            TH2D* histo;
1006 >            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1007 >            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1008 >            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1009 >            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1010 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1011 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1012 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1013 >                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1014 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1015 >                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1016 >                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1017 >            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1018 >            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1019 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1020 >                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1021 >                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1022 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1023 >                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1024 >                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1025 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1026 >                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1027 >                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1028 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1029 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1030 >                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1031 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1032 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1033 >                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1034 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1035 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1036 >                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1037 >            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1038 >                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1039 >                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1040 >            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1041 >                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1042 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1043 >            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1044 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1045 >                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1046 >            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1047 >                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1048 >                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1049 >            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1050 >                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1051 >                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1052 >            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1053 >                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1054 >                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1055 >            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1056 >                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1057 >                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1058 >            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1059 >            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1060 >            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1061 >            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1062 >            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1063 >                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1064 >                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1065 >            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1066 >            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1067 >            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1068 >            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1069 >            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1070 >            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1071 >            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1072 >            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1073 >          }
1074 >          
1075 >        }
1076 >
1077 >
1078 >        //fills histograms with the sizes of collections
1079 >        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1080 >
1081 >          string currentObject = objectsToPlot.at(currentObjectIndex);
1082 >          string objectToPlot = "";
1083 >
1084 >          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1085 >          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1086 >          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1087 >          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1088 >          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1089 >          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1090 >          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1091 >          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1092 >          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1093 >          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1094 >          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1095 >          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1096 >          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1097 >          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1098 >          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1099 >          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1100 >          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1101 >          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1102 >          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1103 >          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1104 >          else objectToPlot = currentObject;
1105 >
1106 >          string tempCurrentObject = objectToPlot;
1107 >          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1108 >          string histoName = "num" + tempCurrentObject;
1109 >
1110 >          //set position of primary vertex in event, in order to calculate quantities relative to it
1111 >          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1112 >            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1113 >            int numToPlot = 0;
1114 >            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1115 >              if(lastCutFlags.at(currentFlag)) numToPlot++;
1116 >            }
1117 >            if(objectToPlot == "primaryvertexs"){
1118 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1119 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1120 >            }
1121 >            else {
1122 >              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1123 >            }
1124 >          }
1125 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1126 >        
1127 >        if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }  
1128 >        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts  
1129 >
1130 >      } // end if(eventPassedPreviousCuts.at(currentDir)){
1131 >    } // end loop over cuts
1132 >    
1133 >  } // end loop over channel
1134  
1056     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1057    }
1058  }
1059  } //end loop over channel
1135  
1136    masterCutFlow_->fillCutFlow(masterScaleFactor);
1137  
1138 +
1139   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1140  
1141  
# Line 1100 | Line 1176 | OSUAnalysis::evaluateTriggers (vector<st
1176    //initialize to false until a chosen trigger is passed
1177    bool triggerDecision = false;
1178  
1179 +  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;  
1180    //loop over all triggers defined in the event
1181    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1182  
1183 +    if (printAllTriggers_) cout << "   " << trigger->name << endl;  
1184 +
1185      //we're only interested in triggers that actually passed
1186      if(trigger->pass != 1) continue;
1187  
# Line 1115 | Line 1194 | OSUAnalysis::evaluateTriggers (vector<st
1194        if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1195      }  
1196    }
1197 +
1198 +  printAllTriggers_ = false;  // only print triggers once, not every event  
1199 +
1200    //if none of the veto triggers fired:
1201    //return the OR of all the chosen triggers
1202    if (triggersToTest.size() != 0) return triggerDecision;
# Line 1577 | Line 1659 | OSUAnalysis::valueLookup (const BNmuon*
1659      value = object->isGlobalMuon > 0                \
1660        && object->isPFMuon > 0                        \
1661        && object->normalizedChi2 < 10                \
1662 <                                  && object->numberOfValidMuonHits > 0        \
1662 >      && object->numberOfValidMuonHits > 0        \
1663        && object->numberOfMatchedStations > 1        \
1664        && fabs(object->correctedD0Vertex) < 0.2        \
1665        && fabs(object->correctedDZ) < 0.5        \
# Line 1588 | Line 1670 | OSUAnalysis::valueLookup (const BNmuon*
1670      value = object->isGlobalMuon > 0                \
1671        && object->isPFMuon > 0                        \
1672        && object->normalizedChi2 < 10                \
1673 <                                  && object->numberOfValidMuonHits > 0        \
1673 >      && object->numberOfValidMuonHits > 0        \
1674        && object->numberOfMatchedStations > 1        \
1675        && object->numberOfValidPixelHits > 0        \
1676        && object->numberOfLayersWithMeasurement > 5;
# Line 1643 | Line 1725 | OSUAnalysis::valueLookup (const BNmuon*
1725      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1726      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1727      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1728 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1729 <         || fabs (object->correctedDZ / dzError) > 99.0;
1728 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1729 >      || fabs (object->correctedDZ / dzError) > 99.0;
1730      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1731    }
1732  
# Line 2043 | Line 2125 | OSUAnalysis::valueLookup (const BNelectr
2125      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2126      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2127      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2128 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2129 <         || fabs (object->correctedDZ / dzError) > 99.0;
2128 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2129 >      || fabs (object->correctedDZ / dzError) > 99.0;
2130      value = !value;
2131    }
2132  
# Line 2136 | Line 2218 | OSUAnalysis::valueLookup (const BNevent*
2218    else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2219    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2220    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2221 <
2221 >  else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2222    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2223  
2224    value = applyFunction(function, value);
# Line 3041 | Line 3123 | OSUAnalysis::valueLookup (const BNelectr
3123  
3124    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3125    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3126 +  else if(variable == "jetEta") value = object2->eta;
3127 +  else if(variable == "jetPhi") value = object2->phi;
3128 +  else if(variable == "electronEta") value = object1->eta;
3129 +  else if(variable == "electronPhi") value = object1->phi;
3130    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3131    else if(variable == "invMass"){
3132      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3075 | Line 3161 | OSUAnalysis::valueLookup (const BNmuon*
3161    double value = 0.0;
3162  
3163    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3164 +  else if(variable == "jetEta") value = object2->eta;
3165 +  else if(variable == "jetPhi") value = object2->phi;
3166 +  else if(variable == "muonEta") value = object1->eta;
3167 +  else if(variable == "muonPhi") value = object1->phi;
3168    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3169    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3170    else if(variable == "invMass"){
# Line 3405 | Line 3495 | OSUAnalysis::valueLookup (const BNstop*
3495      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3496        vertex_rank++;
3497        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3498 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3499 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3498 >                      (object->vy-vertex->y)*(object->vy-vertex->y) + \
3499 >                      (object->vz-vertex->z)*(object->vz-vertex->z));
3500  
3501        if(abs(dist) < abs(minDistToVertex)){
3502          value = vertex_rank;
# Line 3570 | Line 3660 | void OSUAnalysis::setObjectFlags(cut &cu
3660      string obj1, obj2;
3661      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3662      if (inputType==obj1 ||
3663 <          inputType==obj2) {
3663 >        inputType==obj2) {
3664        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3665        // and the inputType is a member of the pair.
3666        // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
# Line 3730 | Line 3820 | bool OSUAnalysis::getPreviousCumulativeF
3820   }
3821  
3822  
3823 +
3824 + template <class InputCollection>
3825 + void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, vector<bool> flags){
3826 +  // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree  
3827 +
3828 +  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;  
3829 +  for (uint object = 0; object != inputCollection->size(); object++) {  
3830 +
3831 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;  
3832 +
3833 +    string inputVariable = parameters.inputVariable;
3834 +    string function = "";
3835 +    string stringValue = "";  
3836 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3837 +    BNTreeBranchVals_.at(parameters.name).push_back(value);  
3838 +
3839 +  }
3840 + }
3841 +
3842 +
3843   template <class InputCollection>
3844   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3845  
# Line 3747 | Line 3857 | void OSUAnalysis::fill1DHistogram(TH1* h
3857        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3858        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3859        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3860 <    }
3860 >    }  
3861 >
3862 >    string stringValue = "";  
3863 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3864 >    histo->Fill(value,scaleFactor);  
3865  
3752    string stringValue = "";
3753    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3754    histo->Fill(value,scaleFactor);
3866      if (printEventInfo_) {
3867        // Write information about event to screen, for testing purposes.
3868        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines