CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronGeneralAnalyzer.cc
Go to the documentation of this file.
1 
3 
5 
12 
19 
20 //#include "CLHEP/Units/GlobalPhysicalConstants.h"
21 //#include "TMath.h"
22 
23 #include <iostream>
24 
25 using namespace reco ;
26 
29  {
30  // collection input tags
31  electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
32  matchingObjectCollection_ = consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
33  trackCollection_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
34  vertexCollection_ = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
35  gsftrackCollection_ = consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
36  beamSpotTag_ = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
37  triggerResults_ = consumes<edm::TriggerResults>(conf.getParameter<edm::InputTag>("TriggerResults"));
38 
39 // // for trigger
40 // HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
41 // HLTPathsByIndex_.resize(HLTPathsByName_.size());
42  }
43 
45  {}
46 
48  {
49  h2_ele_beamSpotXvsY = bookH2("beamSpotXvsY","beam spot x vs y",100,-0.2,0.2,100,-0.2,0.2,"x (cm)","y (cm)") ;
50  py_ele_nElectronsVsLs = bookP1("nElectronsVsLs","# gsf electrons vs LS",150,0.,1500.,0.,20.,"LS","<N_{ele}>") ;
51  py_ele_nClustersVsLs = bookP1("nClustersVsLs","# clusters vs LS",150,0.,1500.,0.,100.,"LS","<N_{SC}>") ;
52  py_ele_nGsfTracksVsLs = bookP1("nGsfTracksVsLs","# gsf tracks vs LS",150,0.,1500.,0.,20.,"LS","<N_{GSF tk}>") ;
53  py_ele_nTracksVsLs = bookP1("nTracksVsLs","# tracks vs LS",150,0.,1500.,0.,100.,"LS","<N_{gen tk}>") ;
54  py_ele_nVerticesVsLs = bookP1("nVerticesVsLs","# vertices vs LS",150,0.,1500.,0.,10.,"LS","<N_{vert}>") ;
55  h1_ele_triggers = bookH1("triggers","hlt triggers",256,0.,256.,"HLT bit") ;
56  }
57 
59  {
61  iEvent.getByToken(electronCollection_,gsfElectrons) ;
63  iEvent.getByToken(matchingObjectCollection_,recoClusters) ;
65  iEvent.getByToken(trackCollection_,tracks);
67  iEvent.getByToken(gsftrackCollection_,gsfTracks);
69  iEvent.getByToken(vertexCollection_,vertices);
70  edm::Handle<reco::BeamSpot> recoBeamSpotHandle ;
71  iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle) ;
72  const BeamSpot bs = *recoBeamSpotHandle ;
73 
74  int ievt = iEvent.id().event();
75  int irun = iEvent.id().run();
76  int ils = iEvent.luminosityBlock();
77 
78  edm::LogInfo("ElectronGeneralAnalyzer::analyze")
79  <<"Treating "<<gsfElectrons.product()->size()<<" electrons"
80  <<" from event "<<ievt<<" in run "<<irun<<" and lumiblock "<<ils ;
81 
82  h2_ele_beamSpotXvsY->Fill(bs.position().x(),bs.position().y());
83  py_ele_nElectronsVsLs->Fill(float(ils),(*gsfElectrons).size());
84  py_ele_nClustersVsLs->Fill(float(ils),(*recoClusters).size());
85  py_ele_nGsfTracksVsLs->Fill(float(ils),(*gsfTracks).size());
86  py_ele_nTracksVsLs->Fill(float(ils),(*tracks).size());
87  py_ele_nVerticesVsLs->Fill(float(ils),(*vertices).size());
88 
89  // trigger
91  iEvent.getByToken(triggerResults_,triggerResults) ;
92  if (triggerResults.isValid())
93  {
94  unsigned int i, n = triggerResults->size() ;
95  for ( i=0 ; i!=n ; ++i )
96  {
97  if (triggerResults->accept(i))
98  { h1_ele_triggers->Fill(float(i)) ; }
99  }
100  }
101  }
102 
RunNumber_t run() const
Definition: EventID.h:42
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
MonitorElement * py_ele_nGsfTracksVsLs
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookP1(const std::string &name, const std::string &title, int nchX, double lowX, double highX, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="E1 P")
MonitorElement * h2_ele_beamSpotXvsY
MonitorElement * bookH1(const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
MonitorElement * py_ele_nVerticesVsLs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * py_ele_nElectronsVsLs
ElectronGeneralAnalyzer(const edm::ParameterSet &conf)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
MonitorElement * py_ele_nClustersVsLs
void Fill(long long x)
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::GsfElectronCollection > electronCollection_
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool isValid() const
Definition: HandleBase.h:76
tuple conf
Definition: dbtoconf.py:185
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
tuple tracks
Definition: testEve_cfg.py:39
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
T const * product() const
Definition: Handle.h:81
MonitorElement * bookH2(const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
edm::EventID id() const
Definition: EventBase.h:56
const Point & position() const
position
Definition: BeamSpot.h:62
edm::EDGetTokenT< reco::GsfTrackCollection > gsftrackCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > matchingObjectCollection_