CMS 3D CMS Logo

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(iBooker, "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(iBooker, "nElectronsVsLs","# gsf electrons vs LS",150,0.,1500.,0.,20.,"LS","<N_{ele}>") ;
51  py_ele_nClustersVsLs = bookP1(iBooker, "nClustersVsLs","# clusters vs LS",150,0.,1500.,0.,100.,"LS","<N_{SC}>") ;
52  py_ele_nGsfTracksVsLs = bookP1(iBooker, "nGsfTracksVsLs","# gsf tracks vs LS",150,0.,1500.,0.,20.,"LS","<N_{GSF tk}>") ;
53  py_ele_nTracksVsLs = bookP1(iBooker, "nTracksVsLs","# tracks vs LS",150,0.,1500.,0.,100.,"LS","<N_{gen tk}>") ;
54  py_ele_nVerticesVsLs = bookP1(iBooker, "nVerticesVsLs","# vertices vs LS",150,0.,1500.,0.,10.,"LS","<N_{vert}>") ;
55  h1_ele_triggers = bookH1(iBooker, "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  edm::EventNumber_t ievt = iEvent.id().event();
75  edm::RunNumber_t irun = iEvent.id().run();
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:39
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
MonitorElement * py_ele_nGsfTracksVsLs
MonitorElement * h2_ele_beamSpotXvsY
MonitorElement * py_ele_nVerticesVsLs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
MonitorElement * py_ele_nElectronsVsLs
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
ElectronGeneralAnalyzer(const edm::ParameterSet &conf)
bool accept() const
Has at least one path accepted the event?
unsigned long long EventNumber_t
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
MonitorElement * bookH2(DQMStore::IBooker &, 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")
unsigned int LuminosityBlockNumber_t
MonitorElement * py_ele_nClustersVsLs
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void Fill(long long x)
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::GsfElectronCollection > electronCollection_
unsigned int size() const
Get number of paths stored.
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * bookP1(DQMStore::IBooker &, 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")
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
edm::EventID id() const
Definition: EventBase.h:60
fixed size matrix
const Point & position() const
position
Definition: BeamSpot.h:62
MonitorElement * bookH1(DQMStore::IBooker &, 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")
unsigned int RunNumber_t
edm::EDGetTokenT< reco::GsfTrackCollection > gsftrackCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > matchingObjectCollection_
Definition: Run.h:43