15 #include "TStopwatch.h" 36 gSystem->Load(
"libFWCoreFWLite" );
40 std::cout <<
"Usage : " << argv[0] <<
" [parameters.py]" << std::endl;
45 std::cout <<
" ERROR: ParametersSet 'process' is missing in your configuration file" << std::endl;
exit(0);
58 TH1F* muonPt_ = theDir.
make<TH1F>(
"muonPt",
"pt", 100, 0.,300.);
59 TH1F* muonEta_ = theDir.make<TH1F>(
"muonEta",
"eta", 100, -3., 3.);
60 TH1F* muonPhi_ = theDir.make<TH1F>(
"muonPhi",
"phi", 100, -5., 5.);
63 TStopwatch timer; timer.Start();
67 unsigned int nEventsAnalyzed = 0;
68 int maxEvents_( inputHandler_.maxEvents() );
69 for(
unsigned int iFile=0; iFile<inputHandler_.files().size(); ++iFile){
71 TFile* inFile = TFile::Open(inputHandler_.files()[iFile].c_str());
85 if(maxEvents_>0 ? ievt+1>maxEvents_ :
false)
break;
87 if(inputHandler_.reportAfter()!=0 ? (ievt>0 && ievt%inputHandler_.reportAfter()==0) :
false)
88 std::cout <<
" processing event: " << ievt << std::endl;
90 if ( wSelector(
event, wSelectorReturns ) ) {
91 pat::Muon const & wMuon = wSelector.wMuon();
92 muonPt_ ->Fill( wMuon.
pt() );
93 muonEta_->Fill( wMuon.
eta() );
94 muonPhi_->Fill( wMuon.
phi() );
103 if(maxEvents_>0 ? ievt+1>maxEvents_ :
false)
break;
112 double rtime = timer.RealTime();
113 double ctime = timer.CpuTime ();
115 printf(
"Analyzed events: %d \n",nEventsAnalyzed);
116 printf(
"RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
117 printf(
"%4.2f events / RealTime second .\n", (
double)nEventsAnalyzed/rtime);
118 printf(
"%4.2f events / CpuTime second .\n", (
double)nEventsAnalyzed/ctime);
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
virtual double eta() const final
momentum pseudorapidity
std::shared_ptr< ParameterSet > readPSetsFrom(std::string const &fileOrString)
virtual double phi() const final
momentum azimuthal angle
Event const & toBegin()
Go to the very first Event.
static void enable()
enable automatic library loading
T * make(const Args &...args) const
make new ROOT object
int main(int argc, char *argv[])
virtual bool atEnd() const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Example class of an EventSelector to apply a simple W Boson selection.
Analysis-level muon class.
std::string const & file() const
return output fuke name