CMS 3D CMS Logo

JPsiFWLiteAnalyzer.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <vector>
4 #include <sstream>
5 #include <fstream>
6 #include <iostream>
7 
8 #include <TH1F.h>
9 #include <TROOT.h>
10 #include <TFile.h>
11 #include <TSystem.h>
12 
17 
18 using namespace std;
19 
20 int main(int argc, char* argv[])
21 {
22  // ----------------------------------------------------------------------
23  // First Part:
24  //
25  // * enable FWLite
26  // * book the histograms of interest
27  // * open the input file
28  // ----------------------------------------------------------------------
29 
30  // load framework libraries
31  gSystem->Load( "libFWCoreFWLite" );
33 
34  // open input file (can be located on castor)
35  TFile* inFile = TFile::Open( "file:jpsi.root" );
36 
37  // ----------------------------------------------------------------------
38  // Second Part:
39  //
40  // * loop the events in the input file
41  // * receive the collections of interest via fwlite::Handle
42  // * fill the histograms
43  // * after the loop close the input file
44  // ----------------------------------------------------------------------
45 
46  // loop the events
47  unsigned int iEvent=0;
48  fwlite::Event event(inFile);
49  for(event.toBegin(); !event.atEnd(); ++event, ++iEvent){
50  // break loop after end of file is reached
51  // or after 1000 events have been processed
52  if( iEvent==1000 ) break;
53 
54  // simple event counter
55  if(iEvent>0 && iEvent%1==0){
56  std::cout << " processing event: " << iEvent << std::endl;
57  }
58 
59  // fwlite::Handle to to jpsi collection
61  jpsis.getByLabel(event, "patJPsiCandidates");
62 
63  // loop jpsi collection and fill histograms
64  for(unsigned i=0; i<jpsis->size(); ++i){
65  cout << "jpsi " << i << ", mass = " << jpsis->at(i).mass() << ", dR = " << jpsis->at(i).userFloat("dR") << endl;
66  }
67  }
68  // close input file
69  inFile->Close();
70 
71  // that's it!
72  return 0;
73 }
Event const & toBegin() override
Go to the very first Event.
Definition: Event.cc:240
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=0, const char *iProcessLabel=0)
Definition: Handle.h:91
virtual bool atEnd() const override
Definition: Event.cc:283
int iEvent
Definition: GenABIO.cc:230
static void enable()
enable automatic library loading
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int main(int argc, char *argv[])