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.62 by jbrinson, Tue May 14 10:58:21 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 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 337 | Line 461 | OSUAnalysis::OSUAnalysis (const edm::Par
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 362 | 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 374 | 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 383 | 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 <
394 <
395 <
396 <
397 <    //get list of cuts for this channel
398 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
399 <
400 <    //loop over and parse all cuts
401 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
402 <      cut tempCut;
403 <      //store input collection for cut
404 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
405 <      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
406 <      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
407 <      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
408 <      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
409 <      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
410 <      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
411 <      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
412 <      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
413 <      tempCut.inputCollection = tempInputCollection;
414 <      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
415 <        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
416 <          int spaceIndex = tempInputCollection.find(" ");
417 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
418 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
419 <        }
420 <        else{
421 <          objectsToGet.push_back(tempInputCollection);
422 <        }
423 <        objectsToCut.push_back(tempInputCollection);
424 <      }
425 <      else{//pair of objects, need to add them both to objectsToGet
426 <        string obj1;
427 <        string obj2;
428 <        getTwoObjs(tempInputCollection, obj1, obj2);
429 <        string obj2ToGet = getObjToGet(obj2);
430 <        objectsToCut.push_back(tempInputCollection);
431 <        objectsToCut.push_back(obj1);
432 <        objectsToCut.push_back(obj2);
433 <        objectsToGet.push_back(tempInputCollection);
434 <        objectsToGet.push_back(obj1);
435 <        objectsToGet.push_back(obj2ToGet);
436 <
437 <      }
438 <
439 <
440 <
441 <      //split cut string into parts and store them
442 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
443 <      vector<string> cutStringVector = splitString(cutString);
444 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
445 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
446 <        exit(0);
447 <      }
448 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
449 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
450 <        int indexOffset = 4 * subcutIndex;
451 <        string currentVariableString = cutStringVector.at(indexOffset);
452 <        if(currentVariableString.find("(")==string::npos){
453 <          tempCut.functions.push_back("");//no function was specified
454 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
455 <        }
456 <        else{
457 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
458 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
459 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
460 <        }
461 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
462 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
463 <        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
464 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
465 <      }
466 <
467 <      //get number of objects required to pass cut for event to pass
468 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
469 <      vector<string> numberRequiredVector = splitString(numberRequiredString);
470 <      if(numberRequiredVector.size()!=2){
471 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
472 <        exit(0);
473 <      }
474 <
475 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
476 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
477 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
478 <
479 <
480 <      string tempCutName;
481 <      if(cuts_.at(currentCut).exists("alias")){
482 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
483 <      }
484 <      else{
485 <        //construct string for cutflow table
486 <        bool plural = numberRequiredInt != 1;
487 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
488 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
489 <        tempCutName = cutName;
490 <      }
491 <      tempCut.name = tempCutName;
492 <
493 <      tempChannel.cuts.push_back(tempCut);
494 <
495 <
496 <    }//end loop over cuts
497 <
518 >   }//end of loop over directories
519      channels.push_back(tempChannel);
520      tempChannel.cuts.clear();
500
521    }//end loop over channels
522  
523  
# Line 587 | 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 610 | Line 634 | OSUAnalysis::analyze (const edm::Event &
634      }
635  
636      //loop over all cuts
613
637      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
638        cut currentCut = currentChannel.cuts.at(currentCutIndex);
616
639        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
640          string currentObject = objectsToCut.at(currentObjectIndex);
641  
# Line 628 | 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");
634 <
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 723 | Line 744 | OSUAnalysis::analyze (const edm::Event &
744  
745  
746      }//end loop over all cuts
726
727
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 745 | 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      }
750
770      double scaleFactor = masterScaleFactor;
771  
772 +    muonScaleFactor_ = electronScaleFactor_ = 1.0;
773      if(applyLeptonSF_ && datasetType_ != "data"){
774        if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
775          vector<bool> muonFlags;
# Line 761 | Line 781 | OSUAnalysis::analyze (const edm::Event &
781          }
782          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
783            if(!muonFlags.at(muonIndex)) continue;
784 <          scaleFactor *= muonSFWeight_->at (muons->at(muonIndex).eta);
784 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
785          }
786        }
787        if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
# Line 774 | Line 794 | OSUAnalysis::analyze (const edm::Event &
794          }
795          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
796            if(!electronFlags.at(electronIndex)) continue;
797 <          scaleFactor *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
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 <
784 <    if(!eventPassedAllCuts)continue;
805 >    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
806  
807      if (printEventInfo_) {
808        // Write information about event to screen, for testing purposes.
# Line 791 | Line 812 | OSUAnalysis::analyze (const edm::Event &
812             << "  event=" << events->at(0).evt
813             << endl;
814      }
794
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 942 | Line 969 | OSUAnalysis::analyze (const edm::Event &
969      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
970  
971        string currentObject = objectsToPlot.at(currentObjectIndex);
945
972        string objectToPlot = "";
973  
974        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
# Line 951 | 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 972 | 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);
1018 <
1019 <    } // 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 1408 | 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 ();
1412 <    if (met)
1440 >    if (const BNmet *met = chosenMET ())
1441        {
1442          double dPhi = deltaPhi (object->phi, met->phi);
1443          value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
# Line 1539 | 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 1589 | Line 1618 | OSUAnalysis::valueLookup (const BNmuon*
1618      }
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  
1633  
# Line 1767 | 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 ();
1771 <    if (met)
1809 >    if (const BNmet *met = chosenMET ())
1810        {
1811          double dPhi = deltaPhi (object->phi, met->phi);
1812          value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
# Line 1980 | Line 2018 | OSUAnalysis::valueLookup (const BNelectr
2018      }
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  
2033  
# Line 2061 | 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_ && chosenMuon ())
2119 <      value = muonSFWeight_->at (chosenMuon ()->eta);
2072 <    else
2073 <      value = 1.0;
2074 <  }
2075 <  else if(variable == "electronScaleFactor"){
2076 <    if(datasetType_ != "data" && applyLeptonSF_ && chosenElectron ())
2077 <      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
2078 <    else
2079 <      value = 1.0;
2080 <  }
2081 <  else if(variable == "stopCTauScaleFactor")
2082 <    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 3055 | 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 3090 | 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 3695 | 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);
3698
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 3975 | Line 4012 | OSUAnalysis::chosenVertex ()
4012        break;
4013      }
4014    }
4015 +  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4016 +    chosenVertex = & primaryvertexs->at (0);
4017  
4018    return chosenVertex;
4019   }
# Line 3997 | Line 4036 | OSUAnalysis::chosenMET ()
4036        break;
4037      }
4038    }
4039 +  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4040 +    chosenMET = & mets->at (0);
4041  
4042    return chosenMET;
4043   }
# Line 4019 | Line 4060 | OSUAnalysis::chosenElectron ()
4060        break;
4061      }
4062    }
4063 +  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4064 +    chosenElectron = & electrons->at (0);
4065  
4066    return chosenElectron;
4067   }
# Line 4041 | Line 4084 | OSUAnalysis::chosenMuon ()
4084        break;
4085      }
4086    }
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