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.70 by qpython, Wed May 29 15:29:27 2013 UTC vs.
Revision 1.75 by wulsin, Fri May 31 09:15:04 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")),
# Line 57 | Line 58 | OSUAnalysis::OSUAnalysis (const edm::Par
58  
59    //always get vertex collection so we can assign the primary vertex in the event
60    objectsToGet.push_back("primaryvertexs");
60
61  //always make the plot of number of primary vertices (to check pile-up reweighting)
61    objectsToPlot.push_back("primaryvertexs");
62 +  objectsToCut.push_back("primaryvertexs");
63 +
64  
65    //always get the MC particles to do GEN-matching
66    objectsToGet.push_back("mcparticles");
# Line 67 | Line 68 | OSUAnalysis::OSUAnalysis (const edm::Par
68    //always get the event collection to do pile-up reweighting
69    objectsToGet.push_back("events");
70  
71 +
72 +  // Parse the tree variable definitions.    
73 +  for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++) {
74 +    string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
75 +    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; }  
76 +    objectsToGet.push_back(tempInputCollection);
77 +    objectsToCut.push_back(tempInputCollection);
78 +
79 +    //    vector<edm::ParameterSet> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<edm::ParameterSet> >("histograms"));
80 +    vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
81 +
82 +    for(uint iBranch = 0; iBranch<branchList.size(); iBranch++){
83 +
84 +      vector<double> defaultValue;
85 +      defaultValue.push_back (-1.0);
86 +
87 +      BranchSpecs br;
88 +      br.inputCollection = tempInputCollection;
89 +      br.inputVariable = branchList.at(iBranch);  
90 +      TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);  
91 +      br.name = string(newName.Data());  
92 +
93 +      treeBranches_.push_back(br);
94 +
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 212 | Line 243 | OSUAnalysis::OSUAnalysis (const edm::Par
243      //set triggers for this channel
244      vector<string> triggerNames;
245      triggerNames.clear();
246 +    vector<string> triggerToVetoNames;
247 +    triggerToVetoNames.clear();
248 +
249      tempChannel.triggers.clear();
250 +    tempChannel.triggersToVeto.clear();
251      if(channels_.at(currentChannel).exists("triggers")){
252        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
253        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
254          tempChannel.triggers.push_back(triggerNames.at(trigger));
255        objectsToGet.push_back("triggers");
256      }
257 <
257 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
258 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
259 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
260 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
261 >      objectsToGet.push_back("triggers");
262 >    }
263  
264  
265  
# Line 340 | 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 360 | Line 400 | OSUAnalysis::OSUAnalysis (const edm::Par
400        oneDHists_.push_back(oneDHistsTmp);
401        twoDHists_.push_back(twoDHistsTmp);
402        directories.push_back(subDir);
363   }
364    //book all histograms included in the configuration
365    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
366    for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
367      histogram currentHistogram = histograms.at(currentHistogramIndex);
368      int numBinsElements = currentHistogram.bins.size();
369      int numInputVariables = currentHistogram.inputVariables.size();
370      int numBinEdgesX = currentHistogram.variableBinsX.size();
371      int numBinEdgesY = currentHistogram.variableBinsY.size();
372
373      if(numBinsElements == 1){
374        if(numBinEdgesX > 1){
375          if(numBinEdgesY > 1)
376            numBinsElements = 6;
377          else
378            numBinsElements = 3;
379        }
380      }
381      if(numBinsElements != 3 && numBinsElements !=6){
382        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
383        exit(0);
384      }
385      else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
386        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
387        exit(0);
388      }
389      else if(numBinsElements == 3){
390        if (currentHistogram.bins.size () == 3)
391          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));
392        else
393          {
394            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
395          }
396      }
397      else if(numBinsElements == 6){
398        if (currentHistogram.bins.size () == 6)
399          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));
400        else
401          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 ());
402      }
403
404
405      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
406
407      // bin      particle type
408      // ---      -------------
409      //  0        unmatched
410      //  1        u
411      //  2        d
412      //  3        s
413      //  4        c
414      //  5        b
415      //  6        t
416      //  7        e
417      //  8        mu
418      //  9        tau
419      // 10        nu
420      // 11        g
421      // 12        gamma
422      // 13        Z
423      // 14        W
424      // 15        light meson
425      // 16        K meson
426      // 17        D meson
427      // 18        B meson
428      // 19        light baryon
429      // 20        strange baryon
430      // 21        charm baryon
431      // 22        bottom baryon
432      // 23        QCD string
433      // 24        other
434
435      vector<TString> labelArray;
436      labelArray.push_back("unmatched");
437      labelArray.push_back("u");
438      labelArray.push_back("d");
439      labelArray.push_back("s");
440      labelArray.push_back("c");
441      labelArray.push_back("b");
442      labelArray.push_back("t");
443      labelArray.push_back("e");
444      labelArray.push_back("#mu");
445      labelArray.push_back("#tau");
446      labelArray.push_back("#nu");
447      labelArray.push_back("g");
448      labelArray.push_back("#gamma");
449      labelArray.push_back("Z");
450      labelArray.push_back("W");
451      labelArray.push_back("light meson");
452      labelArray.push_back("K meson");
453      labelArray.push_back("D meson");
454      labelArray.push_back("B meson");
455      labelArray.push_back("light baryon");
456      labelArray.push_back("strange baryon");
457      labelArray.push_back("charm baryon");
458      labelArray.push_back("bottom baryon");
459      labelArray.push_back("QCD string");
460      labelArray.push_back("other");
461
462      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
463        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
464          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
465        }
466        else {
467          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
468          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
469        }
470      }
471      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
472        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
473        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
474      }
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 >      
413 >      for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
414 >        BranchSpecs currentVar = treeBranches_.at(iBranch);
415 >        vector<float> newVec;  
416 >        BNTreeBranchVals_[currentVar.name] = newVec;  
417 >        BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
418 >
419 >      } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
420 >
421 >
422 >      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
423 >
424 >        histogram currentHistogram = histograms.at(currentHistogramIndex);
425 >        int numBinsElements = currentHistogram.bins.size();
426 >        int numInputVariables = currentHistogram.inputVariables.size();
427 >        int numBinEdgesX = currentHistogram.variableBinsX.size();
428 >        int numBinEdgesY = currentHistogram.variableBinsY.size();
429 >        
430 >        if(numBinsElements == 1){
431 >          if(numBinEdgesX > 1){
432 >            if(numBinEdgesY > 1)
433 >              numBinsElements = 6;
434 >            else
435 >              numBinsElements = 3;
436 >          }
437 >        }
438 >        if(numBinsElements != 3 && numBinsElements !=6){
439 >          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
440 >          exit(0);
441 >        }
442 >        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
443 >          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
444 >          exit(0);
445 >        }
446 >        else if(numBinsElements == 3){
447 >          if (currentHistogram.bins.size () == 3)
448 >            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));
449 >          else
450 >            {
451 >              oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
452 >            }
453 >        }
454 >        else if(numBinsElements == 6){
455 >          if (currentHistogram.bins.size () == 6)
456 >            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));
457 >          else
458 >            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 ());
459 >        }
460 >
461 >
462 >        if(currentHistogram.name.find("GenMatch")==string::npos) continue;
463 >
464 >        // bin      particle type
465 >        // ---      -------------
466 >        //  0        unmatched
467 >        //  1        u
468 >        //  2        d
469 >        //  3        s
470 >        //  4        c
471 >        //  5        b
472 >        //  6        t
473 >        //  7        e
474 >        //  8        mu
475 >        //  9        tau
476 >        // 10        nu
477 >        // 11        g
478 >        // 12        gamma
479 >        // 13        Z
480 >        // 14        W
481 >        // 15        light meson
482 >        // 16        K meson
483 >        // 17        D meson
484 >        // 18        B meson
485 >        // 19        light baryon
486 >        // 20        strange baryon
487 >        // 21        charm baryon
488 >        // 22        bottom baryon
489 >        // 23        QCD string
490 >        // 24        other
491 >
492 >        vector<TString> labelArray;
493 >        labelArray.push_back("unmatched");
494 >        labelArray.push_back("u");
495 >        labelArray.push_back("d");
496 >        labelArray.push_back("s");
497 >        labelArray.push_back("c");
498 >        labelArray.push_back("b");
499 >        labelArray.push_back("t");
500 >        labelArray.push_back("e");
501 >        labelArray.push_back("#mu");
502 >        labelArray.push_back("#tau");
503 >        labelArray.push_back("#nu");
504 >        labelArray.push_back("g");
505 >        labelArray.push_back("#gamma");
506 >        labelArray.push_back("Z");
507 >        labelArray.push_back("W");
508 >        labelArray.push_back("light meson");
509 >        labelArray.push_back("K meson");
510 >        labelArray.push_back("D meson");
511 >        labelArray.push_back("B meson");
512 >        labelArray.push_back("light baryon");
513 >        labelArray.push_back("strange baryon");
514 >        labelArray.push_back("charm baryon");
515 >        labelArray.push_back("bottom baryon");
516 >        labelArray.push_back("QCD string");
517 >        labelArray.push_back("other");
518 >
519 >        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
520 >          if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
521 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
522 >          }
523 >          else {
524 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
525 >            twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
526 >          }
527 >        }
528 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
529 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
530 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
531 >        }
532 >
533 >      }  // end      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
534 >
535 >
536 >      // Book a histogram for the number of each object type to be plotted.
537 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
538 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
539 >        string currentObject = objectsToPlot.at(currentObjectIndex);
540 >        int maxNum = 10;
541 >        if(currentObject == "mcparticles") maxNum = 50;
542 >        else if(currentObject == "primaryvertexs") maxNum = 50;
543 >
544 >        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
545 >        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
546 >        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
547 >        else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
548 >        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
549 >        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
550 >        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
551 >        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
552 >        else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
553 >        else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
554 >        else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
555 >        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
556 >        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
557 >        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
558 >        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
559 >        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
560 >        else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
561 >        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
562 >        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
563 >
564 >        currentObject.at(0) = toupper(currentObject.at(0));
565 >        string histoName = "num" + currentObject;
566 >
567 >        if(histoName == "numPrimaryvertexs"){
568 >          string newHistoName = histoName + "BeforePileupCorrection";
569 >          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);
570 >          newHistoName = histoName + "AfterPileupCorrection";
571 >          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);
572 >        }
573 >        else
574 >          oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
575        }
576 <      else
516 <        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
517 <    }
518 <   }//end of loop over directories
576 >    }//end of loop over directories
577      channels.push_back(tempChannel);
578      tempChannel.cuts.clear();
579    }//end loop over channels
# Line 608 | Line 666 | OSUAnalysis::analyze (const edm::Event &
666  
667    //get pile-up event weight
668    if (doPileupReweighting_ && datasetType_ != "data") {
669 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  This will give an incorrect pile-up weight." << endl;  
670 < else
671 <    masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
669 >    //for "data" datasets, the numTruePV is always set to -1
670 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
671 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
672    }
673  
674    stopCTauScaleFactor_ = 1.0;
# Line 627 | Line 685 | else
685      counterMap passingCounter;
686      cumulativeFlags.clear ();
687  
688 +    for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
689 +         iter != BNTreeBranchVals_.end(); iter++) {
690 +      iter->second.clear();  // clear array
691 +    }
692 +
693 +
694      bool triggerDecision = true;
695 <    if(currentChannel.triggers.size() != 0){  //triggers specified
696 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
695 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
696 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
697        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
698      }
699  
# Line 676 | Line 740 | else
740                                                                     "muon-muon pairs");
741  
742          else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
743 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
744 <                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
745 <                                                                   "muon-secondary muon pairs");
743 >                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
744 >                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
745 >                                                                             "muon-secondary muon pairs");
746  
747          else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
748 <                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
749 <                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
750 <                                                                   "electron-secondary electron pairs");
748 >                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
749 >                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
750 >                                                                                     "electron-secondary electron pairs");
751  
752          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
753                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 694 | Line 758 | else
758                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
759                                                                         "electron-muon pairs");
760          else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
761 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
762 <                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
763 <                                                                           "jet-jet pairs");
761 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
762 >                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
763 >                                                                 "jet-jet pairs");
764          else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
765 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
766 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
767 <                                                                       "electron-jet pairs");
765 >                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
766 >                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
767 >                                                                      "electron-jet pairs");
768          else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
769 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
770 <                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
771 <                                                                       "muon-jet pairs");
769 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
770 >                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
771 >                                                                  "muon-jet pairs");
772          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
773                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
774                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 726 | Line 790 | else
790                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
791                                                                   "tau-tau pairs");
792          else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
793 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
794 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
795 <                                                                 "tau-track pairs");
793 >                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
794 >                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
795 >                                                                   "tau-track pairs");
796          else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
797                                                                            cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
798                                                                            cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
# Line 752 | Line 816 | else
816      //apply trigger (true if none were specified)
817      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
818  
755
819      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
820  
821        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 802 | Line 865 | else
865      scaleFactor *= electronScaleFactor_;
866  
867      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
805    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
868  
869      if (printEventInfo_) {
870        // Write information about event to screen, for testing purposes.
# Line 812 | Line 874 | else
874             << "  event=" << events->at(0).evt
875             << endl;
876      }
877 +
878 +
879      //filling histograms
880      for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
881 <        uint currentDir;
882 <        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
883 <        else{
884 <          currentDir = currentCut;
885 <        }
886 <        if(eventPassedPreviousCuts.at(currentDir)){
881 >      uint currentDir;
882 >      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
883 >      else{
884 >        currentDir = currentCut;
885 >      }
886 >      if(eventPassedPreviousCuts.at(currentDir)){
887 >
888 >        // Assign BNTree variables
889 >        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
890 >          BranchSpecs brSpecs = treeBranches_.at(iBranch);  
891 >          string coll = brSpecs.inputCollection;  
892 >          if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
893 >
894 >          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));            
895 >          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).at(currentDir));
896 >          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));        
897 >          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).at(currentDir));
898 >          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
899 >          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).at(currentDir));
900 >          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).at(currentDir));
901 >          else if(coll == "taus")                assignTreeBranch(brSpecs,taus.product(),          cumulativeFlags.at(coll).at(currentDir));
902 >          else if(coll == "mets")                assignTreeBranch(brSpecs,mets.product(),          cumulativeFlags.at(coll).at(currentDir));
903 >          else if(coll == "tracks")              assignTreeBranch(brSpecs,tracks.product(),        cumulativeFlags.at(coll).at(currentDir));
904 >          else if(coll == "genjets")             assignTreeBranch(brSpecs,genjets.product(),       cumulativeFlags.at(coll).at(currentDir));
905 >          else if(coll == "mcparticles")         assignTreeBranch(brSpecs,mcparticles.product(),   cumulativeFlags.at(coll).at(currentDir));
906 >          else if(coll == "primaryvertexs")      assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).at(currentDir));
907 >          else if(coll == "bxlumis")             assignTreeBranch(brSpecs,bxlumis.product(),       cumulativeFlags.at(coll).at(currentDir));
908 >          else if(coll == "photons")             assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).at(currentDir));
909 >          else if(coll == "superclusters")       assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).at(currentDir));
910 >          else if(coll == "trigobjs")            assignTreeBranch(brSpecs,trigobjs.product(),      cumulativeFlags.at(coll).at(currentDir));
911 >          else if(coll == "stops"
912 >                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).at(currentDir));
913 >        } // end loop over histograms  
914 >                                                                                          
915 >
916          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
917            histogram currentHistogram = histograms.at(histogramIndex);
918  
919 <      if(currentHistogram.inputVariables.size() == 1){
827 <        TH1D* histo;
828 <        histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
829 <        if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
830 <        else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
831 <        else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
832 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
833 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
834 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
835 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
836 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
837 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
838 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
839 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
840 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
841 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
842 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
843 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
844 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
845 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
846 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
847 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
848 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
849 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
850 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
851 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
852 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
853 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
854 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
855 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
856 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
857 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
858 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
859 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
860 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
861 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
863 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
864 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
866 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
867 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
869 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
870 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
871 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
872 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
873 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
874 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
875 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
876 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
877 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
878 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
879 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
880 <
881 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
882 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
883 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
884 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
885 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
886 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
887 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
888 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
889 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
890 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
891 <        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
892 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
893 <      }
894 <      else if(currentHistogram.inputVariables.size() == 2){
895 <        TH2D* histo;
896 <        histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
897 <        if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
898 <        else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
899 <        else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
900 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
901 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
902 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
903 <                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
904 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
905 <                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
906 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
907 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
908 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
909 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
910 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
911 <                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
912 <        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
913 <                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
914 <                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
915 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
916 <                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
917 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
918 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
919 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
920 <                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
921 <        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
922 <                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
923 <                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
924 <        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
925 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
926 <                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
927 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
928 <                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
929 <                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
930 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
931 <                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
932 <                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
933 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
934 <                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
935 <                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
936 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
937 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
938 <                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
939 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
940 <                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
941 <                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
942 <        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
943 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
944 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
945 <        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
946 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
947 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
948 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
949 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
950 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
951 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
952 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
953 <                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
954 <                                                                                         cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
955 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
956 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
957 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
958 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
959 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
960 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
961 <        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
962 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
963 <      }
964 <    }
965 <
919 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
920  
921 +          if(currentHistogram.inputVariables.size() == 1){
922 +            TH1D* histo;  
923 +            histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
924 +            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
925 +            else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
926 +            else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
927 +            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
928 +            else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
929 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
930 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
931 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
932 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
933 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
934 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
935 +            else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
936 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
937 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
938 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
939 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
940 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
941 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
942 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
943 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
944 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
945 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
946 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
947 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
948 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
949 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
950 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
951 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
952 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
953 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
954 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
955 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
956 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
957 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
958 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
959 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
960 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
961 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
962 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
963 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
964 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
965 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
966 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
967 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
968 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
969 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
970 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
971 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
972 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
973 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
974 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
975 +
976 +            else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
977 +            else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
978 +            else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
979 +            else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
980 +            else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
981 +            else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
982 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
983 +            else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
984 +            else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
985 +            else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
986 +            else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
987 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
988 +          }
989 +          else if(currentHistogram.inputVariables.size() == 2){
990 +            TH2D* histo;
991 +            histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
992 +            if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
993 +            else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
994 +            else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
995 +            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
996 +            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
997 +                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
998 +                                                                                           cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
999 +            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1000 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1001 +                                                                                                     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1002 +            else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1003 +            else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1004 +            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1005 +                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1006 +                                                                                                   cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1007 +            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1008 +                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1009 +                                                                                         cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1010 +            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1011 +                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1012 +                                                                                                             cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1013 +            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1014 +                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1015 +                                                                                               cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1016 +            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1017 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1018 +                                                                                              cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1019 +            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1020 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1021 +                                                                                          cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1022 +            else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1023 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1024 +                                                                                                cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1025 +            else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1026 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1027 +                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1028 +            else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1029 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1030 +                                                                                          cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1031 +            else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1032 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1033 +                                                                                         cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1034 +            else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1035 +                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1036 +                                                                                           cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1037 +            else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1038 +                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1039 +                                                                                                  cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1040 +            else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1041 +                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1042 +                                                                                              cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1043 +            else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1044 +            else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1045 +            else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1046 +            else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1047 +            else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1048 +                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1049 +                                                                                             cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1050 +            else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1051 +            else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1052 +            else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1053 +            else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1054 +            else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1055 +            else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1056 +            else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1057 +            else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1058 +          }
1059 +          
1060 +        }
1061 +
1062 +
1063 +        //fills histograms with the sizes of collections
1064 +        for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1065 +
1066 +          string currentObject = objectsToPlot.at(currentObjectIndex);
1067 +          string objectToPlot = "";
1068 +
1069 +          // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1070 +          if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1071 +          else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1072 +          else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1073 +          else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1074 +          else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1075 +          else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1076 +          else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1077 +          else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1078 +          else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1079 +          else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1080 +          else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1081 +          else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1082 +          else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1083 +          else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1084 +          else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1085 +          else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1086 +          else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1087 +          else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1088 +          else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1089 +          else objectToPlot = currentObject;
1090 +
1091 +          string tempCurrentObject = objectToPlot;
1092 +          tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1093 +          string histoName = "num" + tempCurrentObject;
1094 +
1095 +          //set position of primary vertex in event, in order to calculate quantities relative to it
1096 +          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1097 +            vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1098 +            int numToPlot = 0;
1099 +            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1100 +              if(lastCutFlags.at(currentFlag)) numToPlot++;
1101 +            }
1102 +            if(objectToPlot == "primaryvertexs"){
1103 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1104 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1105 +            }
1106 +            else {
1107 +              oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1108 +            }
1109 +          }
1110 +          else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1111 +          else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1112 +          else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1113 +          else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1114 +          else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1115 +          else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1116 +          else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1117 +          else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1118 +          else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1119 +          else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1120 +          else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1121 +          else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1122 +          else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1123 +          else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1124 +          else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1125 +          else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1126 +          else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1127 +          else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1128 +          else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1129 +          else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1130 +          else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1131 +          else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1132 +          else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1133 +          else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1134 +          else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1135 +          else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1136 +          else if(objectToPlot == "primaryvertexs"){
1137 +            oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1138 +            oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1139 +          }
1140 +          if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1141  
1142 <    //fills histograms with the sizes of collections
969 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
970 <
971 <      string currentObject = objectsToPlot.at(currentObjectIndex);
972 <      string objectToPlot = "";
973 <
974 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
975 <      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
976 <      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
977 <      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
978 <      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
979 <      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
980 <      else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
981 <      else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
982 <      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
983 <      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
984 <      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
985 <      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
986 <      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
987 <      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
988 <      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
989 <      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
990 <      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
991 <      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
992 <      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
993 <      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
994 <      else objectToPlot = currentObject;
995 <
996 <      string tempCurrentObject = objectToPlot;
997 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
998 <      string histoName = "num" + tempCurrentObject;
999 <
1000 <      //set position of primary vertex in event, in order to calculate quantities relative to it
1001 <      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1002 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1003 <        int numToPlot = 0;
1004 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1005 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
1006 <        }
1007 <        if(objectToPlot == "primaryvertexs"){
1008 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1009 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1010 <        }
1011 <        else {
1012 <          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1013 <        }
1142 >        } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1143        }
1015      else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1016      else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1017      else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1018      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1019      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1020      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1021      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1022      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1023      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1024      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1025      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1026      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1027      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1028      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1029      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1030      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1031      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1032      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1033      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1034      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1035      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1036      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1037      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1038      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1039      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1040      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1041      else if(objectToPlot == "primaryvertexs"){
1042        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1043        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1044      }
1045      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1046
1047     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1144      }
1145 <  }
1145 >
1146 >    BNTrees_.at(currentChannelIndex)->Fill();  
1147 >
1148    } //end loop over channel
1149  
1150    masterCutFlow_->fillCutFlow(masterScaleFactor);
1151  
1152 +
1153   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1154  
1155  
# Line 1086 | Line 1185 | OSUAnalysis::evaluateComparison (string
1185   }
1186  
1187   bool
1188 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1188 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1189  
1190 +  //initialize to false until a chosen trigger is passed
1191    bool triggerDecision = false;
1192  
1193 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1194 <    {
1195 <      if(trigger->pass != 1) continue;
1196 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1197 <        {
1098 <          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1099 <            triggerDecision = true;
1100 <          }
1101 <        }
1102 <    }
1103 <  return triggerDecision;
1193 >  //loop over all triggers defined in the event
1194 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1195 >
1196 >    //we're only interested in triggers that actually passed
1197 >    if(trigger->pass != 1) continue;
1198  
1199 +    //if the event passes one of the veto triggers, exit and return false
1200 +    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1201 +      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1202 +    }
1203 +    //if the event passes one of the chosen triggers, set triggerDecision to true
1204 +    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1205 +      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1206 +    }  
1207 +  }
1208 +  //if none of the veto triggers fired:
1209 +  //return the OR of all the chosen triggers
1210 +  if (triggersToTest.size() != 0) return triggerDecision;
1211 +  //or if no triggers were defined return true
1212 +  else return true;
1213   }
1214  
1215 +
1216   vector<string>
1217   OSUAnalysis::splitString (string inputString){
1218  
# Line 1558 | Line 1667 | OSUAnalysis::valueLookup (const BNmuon*
1667      value = object->isGlobalMuon > 0                \
1668        && object->isPFMuon > 0                        \
1669        && object->normalizedChi2 < 10                \
1670 <                                  && object->numberOfValidMuonHits > 0        \
1670 >      && object->numberOfValidMuonHits > 0        \
1671        && object->numberOfMatchedStations > 1        \
1672        && fabs(object->correctedD0Vertex) < 0.2        \
1673        && fabs(object->correctedDZ) < 0.5        \
# Line 1569 | Line 1678 | OSUAnalysis::valueLookup (const BNmuon*
1678      value = object->isGlobalMuon > 0                \
1679        && object->isPFMuon > 0                        \
1680        && object->normalizedChi2 < 10                \
1681 <                                  && object->numberOfValidMuonHits > 0        \
1681 >      && object->numberOfValidMuonHits > 0        \
1682        && object->numberOfMatchedStations > 1        \
1683        && object->numberOfValidPixelHits > 0        \
1684        && object->numberOfLayersWithMeasurement > 5;
# Line 1624 | Line 1733 | OSUAnalysis::valueLookup (const BNmuon*
1733      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1734      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1735      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1736 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1737 <         || fabs (object->correctedDZ / dzError) > 99.0;
1736 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
1737 >      || fabs (object->correctedDZ / dzError) > 99.0;
1738      value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1739    }
1740  
# Line 2024 | Line 2133 | OSUAnalysis::valueLookup (const BNelectr
2133      d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2134      dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2135      value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2136 <         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2137 <         || fabs (object->correctedDZ / dzError) > 99.0;
2136 >      || fabs (object->correctedD0Vertex / d0Error) > 99.0
2137 >      || fabs (object->correctedDZ / dzError) > 99.0;
2138      value = !value;
2139    }
2140  
# Line 3386 | 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 3551 | 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 3711 | 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 +  for (uint object = 0; object != inputCollection->size(); object++){
3829 +
3830 +    if (!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3831 +
3832 +    string inputVariable = parameters.inputVariable;
3833 +    string function = "";
3834 +    string stringValue = "";  
3835 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3836 +    BNTreeBranchVals_.at(parameters.name).push_back(value);  
3837 +
3838 +  }
3839 + }
3840 +
3841 +
3842   template <class InputCollection>
3843   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3844  
# Line 3728 | Line 3856 | void OSUAnalysis::fill1DHistogram(TH1* h
3856        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3857        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3858        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3859 <    }
3859 >    }  
3860 >
3861 >    string stringValue = "";  
3862 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);  
3863 >    histo->Fill(value,scaleFactor);  
3864  
3733    string stringValue = "";
3734    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3735    histo->Fill(value,scaleFactor);
3865      if (printEventInfo_) {
3866        // Write information about event to screen, for testing purposes.
3867        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines