CMS 3D CMS Logo

ElectronGeneralAnalyzer.cc
Go to the documentation of this file.
1 
3 
5 
12 
18 
19 //#include "CLHEP/Units/GlobalPhysicalConstants.h"
20 //#include "TMath.h"
21 
22 #include <iostream>
23 
24 using namespace reco;
25 
27  // collection input tags
28  electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
30  consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
31  trackCollection_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
32  vertexCollection_ = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
33  gsftrackCollection_ = consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
34  beamSpotTag_ = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
35  triggerResults_ = consumes<edm::TriggerResults>(conf.getParameter<edm::InputTag>("TriggerResults"));
36 
37  // // for trigger
38  // HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
39  // HLTPathsByIndex_.resize(HLTPathsByName_.size());
40 }
41 
43 
46  bookH2(iBooker, "beamSpotXvsY", "beam spot x vs y", 100, -0.2, 0.2, 100, -0.2, 0.2, "x (cm)", "y (cm)");
48  bookP1(iBooker, "nElectronsVsLs", "# gsf electrons vs LS", 150, 0., 1500., 0., 20., "LS", "<N_{ele}>");
50  bookP1(iBooker, "nClustersVsLs", "# clusters vs LS", 150, 0., 1500., 0., 100., "LS", "<N_{SC}>");
52  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}>");
55  bookP1(iBooker, "nVerticesVsLs", "# vertices vs LS", 150, 0., 1500., 0., 10., "LS", "<N_{vert}>");
56  h1_ele_triggers = bookH1(iBooker, "triggers", "hlt triggers", 256, 0., 256., "HLT bit");
57 }
58 
63  iEvent.getByToken(matchingObjectCollection_, recoClusters);
65  iEvent.getByToken(trackCollection_, tracks);
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();
76  edm::LuminosityBlockNumber_t 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
92  if (triggerResults.isValid()) {
93  unsigned int i, n = triggerResults->size();
94  for (i = 0; i != n; ++i) {
95  if (triggerResults->accept(i)) {
96  h1_ele_triggers->Fill(float(i));
97  }
98  }
99  }
100 }
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
MonitorElement * py_ele_nGsfTracksVsLs
MonitorElement * h2_ele_beamSpotXvsY
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * py_ele_nVerticesVsLs
MonitorElement * py_ele_nElectronsVsLs
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
ElectronGeneralAnalyzer(const edm::ParameterSet &conf)
unsigned long long EventNumber_t
unsigned int LuminosityBlockNumber_t
MonitorElement * py_ele_nClustersVsLs
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void Fill(long long x)
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")
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::GsfElectronCollection > electronCollection_
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")
static std::string const triggerResults
Definition: EdmProvDump.cc:47
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
Log< level::Info, false > LogInfo
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
fixed size matrix
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 RunNumber_t
edm::EDGetTokenT< reco::GsfTrackCollection > gsftrackCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > matchingObjectCollection_
Definition: Run.h:45