Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-14 02:34:05

0001 #include "DataFormats/FWLite/interface/Handle.h"
0002 #include "DataFormats/FWLite/interface/Event.h"
0003 #include "DataFormats/FWLite/interface/ChainEvent.h"
0004 #include "DataFormats/FWLite/interface/MultiChainEvent.h"
0005 #include "PhysicsTools/SelectorUtils/interface/WPlusJetsEventSelector.h"
0006 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
0007 #include "PhysicsTools/FWLite/interface/TFileService.h"
0008 #include "FWCore/ParameterSetReader/interface/ProcessDescImpl.h"
0009 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
0010 
0011 #include "Math/GenVector/PxPyPzM4D.h"
0012 
0013 #include <iostream>
0014 #include <cmath>  //necessary for absolute function fabs()
0015 
0016 //Root includes
0017 #include "TROOT.h"
0018 #include "TFile.h"
0019 #include "TH1.h"
0020 #include "TH2.h"
0021 #include "TCanvas.h"
0022 #include "TLegend.h"
0023 #include "TSystem.h"
0024 
0025 using namespace std;
0026 
0027 int main(int argc, char** argv) {
0028   // load framework libraries
0029   gSystem->Load("libFWCoreFWLite");
0030   FWLiteEnabler::enable();
0031 
0032   if (argc < 2) {
0033     std::cout << "Usage : " << argv[0] << " [parameters.py]" << std::endl;
0034     return 0;
0035   }
0036 
0037   // Get the python configuration
0038   ProcessDescImpl builder(argv[1]);
0039   edm::ParameterSet const& shyftParameters =
0040       builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("wplusjetsAnalysis");
0041   edm::ParameterSet const& inputs = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("inputs");
0042   edm::ParameterSet const& outputs =
0043       builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("outputs");
0044 
0045   // book a set of histograms
0046   fwlite::TFileService fs = fwlite::TFileService(outputs.getParameter<std::string>("outputName"));
0047   TFileDirectory theDir = fs.mkdir("histos");
0048 
0049   // This object 'event' is used both to get all information from the
0050   // event as well as to store histograms, etc.
0051   fwlite::ChainEvent ev(inputs.getParameter<std::vector<std::string> >("fileNames"));
0052 
0053   //cout << "Making event selector" << endl;
0054   WPlusJetsEventSelector wPlusJets(shyftParameters);
0055   pat::strbitset ret = wPlusJets.getBitTemplate();
0056 
0057   //loop through each event
0058   for (ev.toBegin(); !ev.atEnd(); ++ev) {
0059     ret.set(false);
0060 
0061     wPlusJets(ev, ret);
0062 
0063     std::vector<reco::ShallowClonePtrCandidate> const& electrons = wPlusJets.selectedElectrons();
0064     std::vector<reco::ShallowClonePtrCandidate> const& muons = wPlusJets.selectedMuons();
0065     std::vector<reco::ShallowClonePtrCandidate> const& jets = wPlusJets.cleanedJets();
0066     std::vector<reco::ShallowClonePtrCandidate> const& jetsBeforeClean = wPlusJets.selectedJets();
0067 
0068     string bit_;
0069 
0070     bit_ = "Trigger";
0071     bool passTrigger = ret[bit_];
0072     bit_ = "== 1 Lepton";
0073     bool passOneLepton = ret[bit_];
0074     bit_ = "= 0 Jets";
0075     // bool jet0 = ret[bit_];
0076     bit_ = ">=1 Jets";
0077     bool jet1 = ret[bit_];
0078     bit_ = ">=2 Jets";
0079     bool jet2 = ret[bit_];
0080     bit_ = ">=3 Jets";
0081     bool jet3 = ret[bit_];
0082     bit_ = ">=4 Jets";
0083     bool jet4 = ret[bit_];
0084     bit_ = ">=5 Jets";
0085     bool jet5 = ret[bit_];
0086 
0087     bool anyJets = jet1 || jet2 || jet3 || jet4 || jet5;
0088 
0089     if (anyJets && passOneLepton && passTrigger) {
0090       cout << "Nele = " << electrons.size() << ", Nmuo = " << muons.size() << ", Njets_all = " << jets.size()
0091            << ", Njets_clean = " << jetsBeforeClean.size() << endl;
0092     }
0093 
0094   }  //end event loop
0095 
0096   cout << "Printing" << endl;
0097   wPlusJets.print(std::cout);
0098   cout << "We're done!" << endl;
0099 
0100   return 0;
0101 }