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.60 by jbrinson, Thu May 9 10:28:52 2013 UTC vs.
Revision 1.70 by qpython, Wed May 29 15:29:27 2013 UTC

# Line 33 | Line 33 | OSUAnalysis::OSUAnalysis (const edm::Par
33    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34    printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36 <  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
37 <
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
37 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
38   {
39  
40    TH1::SetDefaultSumw2 ();
# Line 54 | Line 54 | OSUAnalysis::OSUAnalysis (const edm::Par
54    // Construct Cutflow Objects. These store the results of cut decisions and
55    // handle filling cut flow histograms.
56    masterCutFlow_ = new CutFlow (fs_);
57  vector<TFileDirectory> directories;
57  
58    //always get vertex collection so we can assign the primary vertex in the event
59    objectsToGet.push_back("primaryvertexs");
# Line 171 | Line 170 | OSUAnalysis::OSUAnalysis (const edm::Par
170      tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
171  
172  
173 <    int maxNum = 24;
173 >    int maxNum = 25;
174      vector<double> binVector;
175      binVector.push_back(maxNum);
176      binVector.push_back(0);
# Line 226 | Line 225 | OSUAnalysis::OSUAnalysis (const edm::Par
225  
226      //create cutFlow for this channel
227      cutFlows_.push_back (new CutFlow (fs_, channelName));
228 +    vector<TFileDirectory> directories; //vector of directories in the output file.
229 +    vector<string> subSubDirNames;//subdirectories in each channel.
230 +    //get list of cuts for this channel
231 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
232  
230    //book a directory in the output file with the name of the channel
231    TFileDirectory subDir = fs_->mkdir( channelName );
232    directories.push_back(subDir);
233  
234 <    map<string, TH1D*> oneDhistoMap;
235 <    oneDHists_.push_back(oneDhistoMap);
236 <    map<string, TH2D*> twoDhistoMap;
237 <    twoDHists_.push_back(twoDhistoMap);
234 >    //loop over and parse all cuts
235 >    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
236 >      cut tempCut;
237 >      //store input collection for cut
238 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
239 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
240 >      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
241 >      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
242 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
243 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
244 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
245 >      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
246 >      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
247 >      tempCut.inputCollection = tempInputCollection;
248 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
249 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
250 >          int spaceIndex = tempInputCollection.find(" ");
251 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
252 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
253 >        }
254 >        else{
255 >          objectsToGet.push_back(tempInputCollection);
256 >        }
257 >        objectsToCut.push_back(tempInputCollection);
258 >      }
259 >      else{//pair of objects, need to add them both to objectsToGet
260 >        string obj1;
261 >        string obj2;
262 >        getTwoObjs(tempInputCollection, obj1, obj2);
263 >        string obj2ToGet = getObjToGet(obj2);
264 >        objectsToCut.push_back(tempInputCollection);
265 >        objectsToCut.push_back(obj1);
266 >        objectsToCut.push_back(obj2);
267 >        objectsToGet.push_back(tempInputCollection);
268 >        objectsToGet.push_back(obj1);
269 >        objectsToGet.push_back(obj2ToGet);
270 >
271 >      }
272 >
273 >
274 >
275 >      //split cut string into parts and store them
276 >      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
277 >      vector<string> cutStringVector = splitString(cutString);
278 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
279 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
280 >        exit(0);
281 >      }
282 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
283 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
284 >        int indexOffset = 4 * subcutIndex;
285 >        string currentVariableString = cutStringVector.at(indexOffset);
286 >        if(currentVariableString.find("(")==string::npos){
287 >          tempCut.functions.push_back("");//no function was specified
288 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
289 >        }
290 >        else{
291 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
292 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
293 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
294 >        }
295 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
296 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
297 >        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
298 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
299 >      }
300 >
301 >      //get number of objects required to pass cut for event to pass
302 >      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
303 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
304 >      if(numberRequiredVector.size()!=2){
305 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
306 >        exit(0);
307 >      }
308 >
309 >      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
310 >      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
311 >      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
312 >
313 >      //Set up vectors to store the directories and subDIrectories for each channel.
314 >      string subSubDirName;
315 >      string tempCutName;
316 >      if(cuts_.at(currentCut).exists("alias")){
317 >        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
318 >        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
319 >      }
320 >      else{
321 >        //construct string for cutflow table
322 >        bool plural = numberRequiredInt != 1;
323 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
324 >        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
325 >        tempCutName = cutName;
326 >        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
327 >      }
328 >
329 >      subSubDirNames.push_back(subSubDirName);
330 >      tempCut.name = tempCutName;
331 >
332 >      tempChannel.cuts.push_back(tempCut);
333  
334  
335 +    }//end loop over cuts
336  
337 +    vector<map<string, TH1D*>> oneDHistsTmp;
338 +    vector<map<string, TH2D*>> twoDHistsTmp;
339 +    //book a directory in the output file with the name of the channel
340 +    TFileDirectory subDir = fs_->mkdir( channelName );
341 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
342 +    if(GetPlotsAfterEachCut_){
343 +       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
344 +            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
345 +            directories.push_back(subSubDir);
346 +            map<string, TH1D*> oneDhistoMap;
347 +            oneDHistsTmp.push_back(oneDhistoMap);
348 +            map<string, TH2D*> twoDhistoMap;
349 +            twoDHistsTmp.push_back(twoDhistoMap);
350 +      }
351 +      oneDHists_.push_back(oneDHistsTmp);
352 +      twoDHists_.push_back(twoDHistsTmp);
353 +    }
354 +   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
355 +   else{
356 +      map<string, TH1D*> oneDhistoMap;
357 +      oneDHistsTmp.push_back(oneDhistoMap);
358 +      map<string, TH2D*> twoDhistoMap;
359 +      twoDHistsTmp.push_back(twoDhistoMap);
360 +      oneDHists_.push_back(oneDHistsTmp);
361 +      twoDHists_.push_back(twoDHistsTmp);
362 +      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();
# Line 264 | Line 388 | OSUAnalysis::OSUAnalysis (const edm::Par
388        }
389        else if(numBinsElements == 3){
390          if (currentHistogram.bins.size () == 3)
391 <          oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
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)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
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)[currentHistogram.name] = directories.at(currentChannel).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));
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)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
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  
# Line 305 | Line 429 | OSUAnalysis::OSUAnalysis (const edm::Par
429        // 20        strange baryon
430        // 21        charm baryon
431        // 22        bottom baryon
432 <      // 23        other
432 >      // 23        QCD string
433 >      // 24        other
434  
435        vector<TString> labelArray;
436        labelArray.push_back("unmatched");
# Line 331 | Line 456 | OSUAnalysis::OSUAnalysis (const edm::Par
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)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
464 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
465          }
466          else {
467 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
468 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
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)[currentHistogram.name]->GetXaxis()->CenterTitle();
473 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
472 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
473 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
474        }
475  
476      }
# Line 360 | Line 486 | OSUAnalysis::OSUAnalysis (const edm::Par
486        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
487        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
488        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
489 +      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
490        else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
491        else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
492        else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
# Line 372 | Line 499 | OSUAnalysis::OSUAnalysis (const edm::Par
499        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
500        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
501        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
502 <      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
502 >      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
503        else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
504        else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
505  
# Line 381 | Line 508 | OSUAnalysis::OSUAnalysis (const edm::Par
508  
509        if(histoName == "numPrimaryvertexs"){
510          string newHistoName = histoName + "BeforePileupCorrection";
511 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
511 >        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);
512          newHistoName = histoName + "AfterPileupCorrection";
513 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
513 >        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);
514        }
515        else
516 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
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 <
392 <
393 <
394 <
395 <    //get list of cuts for this channel
396 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
397 <
398 <    //loop over and parse all cuts
399 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
400 <      cut tempCut;
401 <      //store input collection for cut
402 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
403 <      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
404 <      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
405 <      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
406 <      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
407 <      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
408 <      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
409 <      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
410 <      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
411 <      tempCut.inputCollection = tempInputCollection;
412 <      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
413 <        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
414 <          int spaceIndex = tempInputCollection.find(" ");
415 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
416 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
417 <        }
418 <        else{
419 <          objectsToGet.push_back(tempInputCollection);
420 <        }
421 <        objectsToCut.push_back(tempInputCollection);
422 <      }
423 <      else{//pair of objects, need to add them both to objectsToGet
424 <        string obj1;
425 <        string obj2;
426 <        getTwoObjs(tempInputCollection, obj1, obj2);
427 <        string obj2ToGet = getObjToGet(obj2);
428 <        objectsToCut.push_back(tempInputCollection);
429 <        objectsToCut.push_back(obj1);
430 <        objectsToCut.push_back(obj2);
431 <        objectsToGet.push_back(tempInputCollection);
432 <        objectsToGet.push_back(obj1);
433 <        objectsToGet.push_back(obj2ToGet);
434 <
435 <      }
436 <
437 <
438 <
439 <      //split cut string into parts and store them
440 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
441 <      vector<string> cutStringVector = splitString(cutString);
442 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
443 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
444 <        exit(0);
445 <      }
446 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
447 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
448 <        int indexOffset = 4 * subcutIndex;
449 <        string currentVariableString = cutStringVector.at(indexOffset);
450 <        if(currentVariableString.find("(")==string::npos){
451 <          tempCut.functions.push_back("");//no function was specified
452 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
453 <        }
454 <        else{
455 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
456 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
457 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
458 <        }
459 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
460 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
461 <        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
462 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
463 <      }
464 <
465 <      //get number of objects required to pass cut for event to pass
466 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
467 <      vector<string> numberRequiredVector = splitString(numberRequiredString);
468 <      if(numberRequiredVector.size()!=2){
469 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
470 <        exit(0);
471 <      }
472 <
473 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
474 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
475 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
476 <
477 <
478 <      string tempCutName;
479 <      if(cuts_.at(currentCut).exists("alias")){
480 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
481 <      }
482 <      else{
483 <        //construct string for cutflow table
484 <        bool plural = numberRequiredInt != 1;
485 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
486 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
487 <        tempCutName = cutName;
488 <      }
489 <      tempCut.name = tempCutName;
490 <
491 <      tempChannel.cuts.push_back(tempCut);
492 <
493 <
494 <    }//end loop over cuts
495 <
518 >   }//end of loop over directories
519      channels.push_back(tempChannel);
520      tempChannel.cuts.clear();
498
521    }//end loop over channels
522  
523  
# Line 585 | Line 607 | OSUAnalysis::analyze (const edm::Event &
607    double masterScaleFactor = 1.0;
608  
609    //get pile-up event weight
610 <  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
610 >  if (doPileupReweighting_ && datasetType_ != "data") {
611 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  This will give an incorrect pile-up weight." << endl;  
612 > else
613 >    masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
614 >  }
615  
616    stopCTauScaleFactor_ = 1.0;
617    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
# Line 608 | Line 634 | OSUAnalysis::analyze (const edm::Event &
634      }
635  
636      //loop over all cuts
611
637      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
638        cut currentCut = currentChannel.cuts.at(currentCutIndex);
614
639        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
640          string currentObject = objectsToCut.at(currentObjectIndex);
641  
# Line 626 | Line 650 | OSUAnalysis::analyze (const edm::Event &
650          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
651  
652  
653 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
654 <
655 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
632 <
653 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
654 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
655 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
656          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
657          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
658          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 721 | Line 744 | OSUAnalysis::analyze (const edm::Event &
744  
745  
746      }//end loop over all cuts
724
725
747      //use cumulative flags to apply cuts at event level
748  
749      bool eventPassedAllCuts = true;
750 <
750 >    //a vector to store cumulative cut descisions after each cut.
751 >    vector<bool> eventPassedPreviousCuts;
752      //apply trigger (true if none were specified)
753      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
754  
# Line 743 | Line 765 | OSUAnalysis::analyze (const edm::Event &
765        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
766        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
767        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
768 <
768 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
769      }
748
770      double scaleFactor = masterScaleFactor;
771  
772 +    muonScaleFactor_ = electronScaleFactor_ = 1.0;
773      if(applyLeptonSF_ && datasetType_ != "data"){
774 <      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
775 <      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
774 >      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
775 >        vector<bool> muonFlags;
776 >        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
777 >          if (cumulativeFlags.at("muons").at(i).size()){
778 >            muonFlags = cumulativeFlags.at("muons").at(i);
779 >            break;
780 >          }
781 >        }
782 >        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
783 >          if(!muonFlags.at(muonIndex)) continue;
784 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
785 >        }
786 >      }
787 >      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
788 >        vector<bool> electronFlags;
789 >        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
790 >          if (cumulativeFlags.at("electrons").at(i).size()){
791 >            electronFlags = cumulativeFlags.at("electrons").at(i);
792 >            break;
793 >          }
794 >        }
795 >        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
796 >          if(!electronFlags.at(electronIndex)) continue;
797 >          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
798 >        }
799 >      }
800      }
801 +    scaleFactor *= muonScaleFactor_;
802 +    scaleFactor *= electronScaleFactor_;
803  
804      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
805 <
758 <    if(!eventPassedAllCuts)continue;
805 >    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
806  
807      if (printEventInfo_) {
808        // Write information about event to screen, for testing purposes.
# Line 765 | Line 812 | OSUAnalysis::analyze (const edm::Event &
812             << "  event=" << events->at(0).evt
813             << endl;
814      }
768
815      //filling histograms
816 <    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
817 <      histogram currentHistogram = histograms.at(histogramIndex);
816 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
817 >        uint currentDir;
818 >        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
819 >        else{
820 >          currentDir = currentCut;
821 >        }
822 >        if(eventPassedPreviousCuts.at(currentDir)){
823 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
824 >          histogram currentHistogram = histograms.at(histogramIndex);
825  
826        if(currentHistogram.inputVariables.size() == 1){
827          TH1D* histo;
828 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
829 <
830 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
831 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
832 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
833 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
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").back(),cumulativeFlags.at("muons").back(), \
836 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("secondary muons").back(), \
839 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
840 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
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").back(),cumulativeFlags.at("electrons").back(),\
843 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(),\
846 <                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("secondary electrons").back(), \
849 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("muons").back(),
852 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(),
855 <                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(),
858 <                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
861 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
864 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("taus").back(),
867 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("taus").back(),
870 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
873 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("trigobjs").back(),
876 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("trigobjs").back(),
879 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
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").back(),scaleFactor);
882 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
883 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
884 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
885 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
886 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
887 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
888 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
889 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
890 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
891 <        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
892 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
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(currentHistogram.name);
897 <
898 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
899 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
900 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
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").back(),cumulativeFlags.at("muons").back(), \
903 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("secondary muons").back(), \
906 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
907 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
908 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
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").back(),cumulativeFlags.at("electrons").back(), \
911 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(), \
914 <                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("secondary electrons").back(), \
917 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("muons").back(), \
920 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(), \
923 <                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("jets").back(), \
926 <                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
929 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
932 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("taus").back(),
935 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("taus").back(),
938 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("tracks").back(),
941 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("trigobjs").back(),
944 <                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
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").back(),cumulativeFlags.at("trigobjs").back(),
947 <                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
948 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
949 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
950 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
951 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
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").back(),cumulativeFlags.at("events").back(),
954 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);
955 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
956 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
957 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
958 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
959 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
960 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
961 <        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
962 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
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  
# Line 916 | Line 969 | OSUAnalysis::analyze (const edm::Event &
969      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
970  
971        string currentObject = objectsToPlot.at(currentObjectIndex);
919
972        string objectToPlot = "";
973  
974        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
# Line 925 | Line 977 | OSUAnalysis::analyze (const edm::Event &
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";
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";
# Line 946 | Line 999 | OSUAnalysis::analyze (const edm::Event &
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).back();
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(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1009 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
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(histoName)->Fill(numToPlot,scaleFactor);
1012 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1013          }
1014        }
1015 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
1016 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1017 <      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1018 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1019 <      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1020 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1021 <      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1022 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1023 <      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1024 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1025 <      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1026 <      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1027 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1028 <      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1029 <      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1030 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1031 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1032 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1033 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1034 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1035 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1036 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1037 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1038 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1039 <      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor);
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(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1043 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
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(histoName)->Fill(stops->size(),scaleFactor);
992 <
993 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
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++)
1048 +    }
1049 +  }
1050    } //end loop over channel
1051  
1052    masterCutFlow_->fillCutFlow(masterScaleFactor);
# Line 1382 | Line 1437 | OSUAnalysis::valueLookup (const BNmuon*
1437    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1438    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1439    else if(variable == "metMT") {
1440 <    const BNmet *met = chosenMET ();
1386 <    if (met)
1440 >    if (const BNmet *met = chosenMET ())
1441        {
1442 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1443 <          p2 (met->px, met->py, 0.0, met->pt);
1390 <
1391 <        value = (p1 + p2).Mt ();
1442 >        double dPhi = deltaPhi (object->phi, met->phi);
1443 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1444        }
1445      else
1446        value = -999;
# Line 1515 | Line 1567 | OSUAnalysis::valueLookup (const BNmuon*
1567    }
1568    else if(variable == "tightIDdisplaced"){
1569      value = object->isGlobalMuon > 0                \
1570 +      && object->isPFMuon > 0                        \
1571        && object->normalizedChi2 < 10                \
1572                                    && object->numberOfValidMuonHits > 0        \
1573        && object->numberOfMatchedStations > 1        \
# Line 1542 | Line 1595 | OSUAnalysis::valueLookup (const BNmuon*
1595    }
1596    else if(variable == "genMatchedMotherIdReverse"){
1597      int index = getGenMatchedParticleIndex(object);
1598 <    if(index == -1) value = 23;
1599 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1598 >    if(index == -1) value = 24;
1599 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1600    }
1601    else if(variable == "genMatchedGrandmotherId"){
1602      int index = getGenMatchedParticleIndex(object);
# Line 1557 | Line 1610 | OSUAnalysis::valueLookup (const BNmuon*
1610    }
1611    else if(variable == "genMatchedGrandmotherIdReverse"){
1612      int index = getGenMatchedParticleIndex(object);
1613 <    if(index == -1) value = 23;
1613 >    if(index == -1) value = 24;
1614      else if(fabs(mcparticles->at(index).motherId) == 15){
1615        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1616 <      if(motherIndex == -1) value = 23;
1617 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1616 >      if(motherIndex == -1) value = 24;
1617 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1618      }
1619 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1619 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1620 >  }
1621 >  else if(variable == "pfMuonsFromVertex"){
1622 >    double d0Error, dzError;
1623 >
1624 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1625 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1626 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1627 >         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1628 >         || fabs (object->correctedDZ / dzError) > 99.0;
1629 >    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1630    }
1631  
1632  
# Line 1743 | Line 1806 | OSUAnalysis::valueLookup (const BNelectr
1806    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1807    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1808    else if(variable == "metMT") {
1809 <    const BNmet *met = chosenMET ();
1747 <    if (met)
1809 >    if (const BNmet *met = chosenMET ())
1810        {
1811 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1812 <          p2 (met->px, met->py, 0.0, met->pt);
1751 <
1752 <        value = (p1 + p2).Mt ();
1811 >        double dPhi = deltaPhi (object->phi, met->phi);
1812 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1813        }
1814      else
1815        value = -999;
# Line 1935 | Line 1995 | OSUAnalysis::valueLookup (const BNelectr
1995    }
1996    else if(variable == "genMatchedMotherIdReverse"){
1997      int index = getGenMatchedParticleIndex(object);
1998 <    if(index == -1) value = 23;
1999 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1998 >    if(index == -1) value = 24;
1999 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2000    }
2001    else if(variable == "genMatchedGrandmotherId"){
2002      int index = getGenMatchedParticleIndex(object);
# Line 1950 | Line 2010 | OSUAnalysis::valueLookup (const BNelectr
2010    }
2011    else if(variable == "genMatchedGrandmotherIdReverse"){
2012      int index = getGenMatchedParticleIndex(object);
2013 <    if(index == -1) value = 23;
2013 >    if(index == -1) value = 24;
2014      else if(fabs(mcparticles->at(index).motherId) == 15){
2015        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2016 <      if(motherIndex == -1) value = 23;
2017 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2016 >      if(motherIndex == -1) value = 24;
2017 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2018      }
2019 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2019 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2020 >  }
2021 >  else if(variable == "pfElectronsFromVertex"){
2022 >    double d0Error, dzError;
2023 >
2024 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2025 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2026 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2027 >         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2028 >         || fabs (object->correctedDZ / dzError) > 99.0;
2029 >    value = !value;
2030    }
2031  
2032  
# Line 2039 | Line 2109 | OSUAnalysis::valueLookup (const BNevent*
2109    else if(variable == "id2") value = object->id2;
2110    else if(variable == "evt") value = object->evt;
2111    else if(variable == "puScaleFactor"){
2112 <    if(datasetType_ != "data")
2112 >    if(doPileupReweighting_ && datasetType_ != "data")
2113        value = puWeight_->at (events->at (0).numTruePV);
2114      else
2115        value = 1.0;
2116    }
2117 <  else if(variable == "muonScaleFactor"){
2118 <    if(datasetType_ != "data" && applyLeptonSF_)
2119 <      value = muonSFWeight_->at (chosenMuon ()->eta);
2050 <    else
2051 <      value = 1.0;
2052 <  }
2053 <  else if(variable == "electronScaleFactor"){
2054 <    if(datasetType_ != "data" && applyLeptonSF_)
2055 <      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
2056 <    else
2057 <      value = 1.0;
2058 <  }
2059 <  else if(variable == "stopCTauScaleFactor")
2060 <    value = stopCTauScaleFactor_;
2117 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2118 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2119 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2120  
2121    else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2122  
# Line 2134 | Line 2193 | OSUAnalysis::valueLookup (const BNtau* o
2193    }
2194    else if(variable == "genMatchedMotherIdReverse"){
2195      int index = getGenMatchedParticleIndex(object);
2196 <    if(index == -1) value = 23;
2197 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2196 >    if(index == -1) value = 24;
2197 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2198    }
2199    else if(variable == "genMatchedGrandmotherId"){
2200      int index = getGenMatchedParticleIndex(object);
# Line 2149 | Line 2208 | OSUAnalysis::valueLookup (const BNtau* o
2208    }
2209    else if(variable == "genMatchedGrandmotherIdReverse"){
2210      int index = getGenMatchedParticleIndex(object);
2211 <    if(index == -1) value = 23;
2211 >    if(index == -1) value = 24;
2212      else if(fabs(mcparticles->at(index).motherId) == 15){
2213        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2214 <      if(motherIndex == -1) value = 23;
2215 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2214 >      if(motherIndex == -1) value = 24;
2215 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2216      }
2217 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2217 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2218    }
2219  
2220  
# Line 2331 | Line 2390 | OSUAnalysis::valueLookup (const BNtrack*
2390    }
2391    else if(variable == "genMatchedMotherIdReverse"){
2392      int index = getGenMatchedParticleIndex(object);
2393 <    if(index == -1) value = 23;
2394 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2393 >    if(index == -1) value = 24;
2394 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2395    }
2396    else if(variable == "genMatchedGrandmotherId"){
2397      int index = getGenMatchedParticleIndex(object);
# Line 2346 | Line 2405 | OSUAnalysis::valueLookup (const BNtrack*
2405    }
2406    else if(variable == "genMatchedGrandmotherIdReverse"){
2407      int index = getGenMatchedParticleIndex(object);
2408 <    if(index == -1) value = 23;
2408 >    if(index == -1) value = 24;
2409      else if(fabs(mcparticles->at(index).motherId) == 15){
2410        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2411 <      if(motherIndex == -1) value = 23;
2412 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2411 >      if(motherIndex == -1) value = 24;
2412 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2413      }
2414 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2414 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2415    }
2416  
2417  
# Line 2674 | Line 2733 | OSUAnalysis::valueLookup (const BNphoton
2733    }
2734    else if(variable == "genMatchedMotherIdReverse"){
2735      int index = getGenMatchedParticleIndex(object);
2736 <    if(index == -1) value = 23;
2737 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2736 >    if(index == -1) value = 24;
2737 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2738    }
2739    else if(variable == "genMatchedGrandmotherId"){
2740      int index = getGenMatchedParticleIndex(object);
# Line 2689 | Line 2748 | OSUAnalysis::valueLookup (const BNphoton
2748    }
2749    else if(variable == "genMatchedGrandmotherIdReverse"){
2750      int index = getGenMatchedParticleIndex(object);
2751 <    if(index == -1) value = 23;
2751 >    if(index == -1) value = 24;
2752      else if(fabs(mcparticles->at(index).motherId) == 15){
2753        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2754 <      if(motherIndex == -1) value = 23;
2755 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2754 >      if(motherIndex == -1) value = 24;
2755 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2756      }
2757 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2757 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2758    }
2759  
2760  
# Line 3033 | Line 3092 | OSUAnalysis::valueLookup (const BNjet* o
3092  
3093    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3094    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3095 +  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3096    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3097    else if(variable == "invMass"){
3098      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3068 | Line 3128 | OSUAnalysis::valueLookup (const BNelectr
3128    TLorentzVector fourVector2(0, 0, 0, 0);
3129    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3130    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3131 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3132 <  else if(variable == "invMass"){        
3133 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3134 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3135 <        
3136 <    value = (fourVector1 + fourVector2).M();    
3131 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3132 >  else if(variable == "invMass"){
3133 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3134 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3135 >
3136 >    value = (fourVector1 + fourVector2).M();
3137    }
3138    else if(variable == "chargeProduct"){
3139      value = object1->charge*object2->charge;
3140    }
3141 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3142 <  value = applyFunction(function, value);        
3143 <  return value;  
3141 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3142 >  value = applyFunction(function, value);
3143 >  return value;
3144  
3145   }
3146  
# Line 3200 | Line 3260 | OSUAnalysis::valueLookup (const BNelectr
3260    double value = 0.0;
3261  
3262    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3263 +  else if (variable == "match"){
3264 +    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3265 +      stringValue = object2->filter;
3266 +    else
3267 +      stringValue = "none";
3268 +  }
3269  
3270    else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3271  
# Line 3667 | Line 3733 | void OSUAnalysis::fill1DHistogram(TH1* h
3733      string stringValue = "";
3734      double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3735      histo->Fill(value,scaleFactor);
3670
3736      if (printEventInfo_) {
3737        // Write information about event to screen, for testing purposes.
3738        cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
# Line 3896 | Line 3961 | int OSUAnalysis::findTauMotherIndex(cons
3961   // 20        strange baryon
3962   // 21        charm baryon
3963   // 22        bottom baryon
3964 < // 23        other
3964 > // 23        QCD string
3965 > // 24        other
3966  
3967   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3968  
# Line 3920 | Line 3986 | int OSUAnalysis::getPdgIdBinValue(int pd
3986    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3987    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3988    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3989 +  else if(absPdgId == 92  ) binValue = 23;
3990  
3991 <  else binValue = 23;
3991 >  else binValue = 24;
3992  
3993    return binValue;
3994  
# Line 3931 | Line 3998 | const BNprimaryvertex *
3998   OSUAnalysis::chosenVertex ()
3999   {
4000    const BNprimaryvertex *chosenVertex = 0;
4001 <  if(find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4001 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4002      vector<bool> vertexFlags;
4003      for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4004        if (cumulativeFlags.at("primaryvertexs").at(i).size()){
# Line 3945 | Line 4012 | OSUAnalysis::chosenVertex ()
4012        break;
4013      }
4014    }
4015 <  else {
4016 <    chosenVertex = &primaryvertexs->at(0);
3950 <  }
4015 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4016 >    chosenVertex = & primaryvertexs->at (0);
4017  
4018    return chosenVertex;
4019   }
# Line 3956 | Line 4022 | const BNmet *
4022   OSUAnalysis::chosenMET ()
4023   {
4024    const BNmet *chosenMET = 0;
4025 <  if(find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4025 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4026      vector<bool> metFlags;
4027      for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4028        if (cumulativeFlags.at("mets").at(i).size()){
# Line 3970 | Line 4036 | OSUAnalysis::chosenMET ()
4036        break;
4037      }
4038    }
4039 <  else {
4040 <    chosenMET = &mets->at(0);
3975 <  }
4039 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4040 >    chosenMET = & mets->at (0);
4041  
4042    return chosenMET;
4043   }
# Line 3981 | Line 4046 | const BNelectron *
4046   OSUAnalysis::chosenElectron ()
4047   {
4048    const BNelectron *chosenElectron = 0;
4049 <  if(find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4049 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4050      vector<bool> electronFlags;
4051      for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4052        if (cumulativeFlags.at("electrons").at(i).size()){
# Line 3995 | Line 4060 | OSUAnalysis::chosenElectron ()
4060        break;
4061      }
4062    }
4063 <  else {
4064 <    chosenElectron = &electrons->at(0);
4000 <  }
4063 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4064 >    chosenElectron = & electrons->at (0);
4065  
4066    return chosenElectron;
4067   }
# Line 4006 | Line 4070 | const BNmuon *
4070   OSUAnalysis::chosenMuon ()
4071   {
4072    const BNmuon *chosenMuon = 0;
4073 <  if(find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4073 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4074      vector<bool> muonFlags;
4075      for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4076        if (cumulativeFlags.at("muons").at(i).size()){
# Line 4020 | Line 4084 | OSUAnalysis::chosenMuon ()
4084        break;
4085      }
4086    }
4087 <  else {
4088 <    chosenMuon = &muons->at(0);
4025 <  }
4087 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4088 >    chosenMuon = & muons->at (0);
4089  
4090    return chosenMuon;
4091   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines