CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
28  // collection input tags
29  electronCollection_ = consumes<GsfElectronCollection>(conf.getParameter<edm::InputTag>("ElectronCollection"));
31  consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("MatchingObjectCollection"));
32  trackCollection_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackCollection"));
33  vertexCollection_ = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("VertexCollection"));
34  gsftrackCollection_ = consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("GsfTrackCollection"));
35  beamSpotTag_ = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"));
36  triggerResults_ = consumes<edm::TriggerResults>(conf.getParameter<edm::InputTag>("TriggerResults"));
37 
38  // // for trigger
39  // HLTPathsByName_= conf.getParameter<std::vector<std::string > >("HltPaths");
40  // HLTPathsByIndex_.resize(HLTPathsByName_.size());
41 }
42 
44 
47  bookH2(iBooker, "beamSpotXvsY", "beam spot x vs y", 100, -0.2, 0.2, 100, -0.2, 0.2, "x (cm)", "y (cm)");
49  bookP1(iBooker, "nElectronsVsLs", "# gsf electrons vs LS", 150, 0., 1500., 0., 20., "LS", "<N_{ele}>");
51  bookP1(iBooker, "nClustersVsLs", "# clusters vs LS", 150, 0., 1500., 0., 100., "LS", "<N_{SC}>");
53  bookP1(iBooker, "nGsfTracksVsLs", "# gsf tracks vs LS", 150, 0., 1500., 0., 20., "LS", "<N_{GSF tk}>");
54  py_ele_nTracksVsLs = bookP1(iBooker, "nTracksVsLs", "# tracks vs LS", 150, 0., 1500., 0., 100., "LS", "<N_{gen tk}>");
56  bookP1(iBooker, "nVerticesVsLs", "# vertices vs LS", 150, 0., 1500., 0., 10., "LS", "<N_{vert}>");
57  h1_ele_triggers = bookH1(iBooker, "triggers", "hlt triggers", 256, 0., 256., "HLT bit");
58 }
59 
62  iEvent.getByToken(electronCollection_, gsfElectrons);
64  iEvent.getByToken(matchingObjectCollection_, recoClusters);
66  iEvent.getByToken(trackCollection_, tracks);
68  iEvent.getByToken(gsftrackCollection_, gsfTracks);
70  iEvent.getByToken(vertexCollection_, vertices);
71  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
72  iEvent.getByToken(beamSpotTag_, recoBeamSpotHandle);
73  const BeamSpot bs = *recoBeamSpotHandle;
74 
75  edm::EventNumber_t ievt = iEvent.id().event();
76  edm::RunNumber_t irun = iEvent.id().run();
78 
79  edm::LogInfo("ElectronGeneralAnalyzer::analyze")
80  << "Treating " << gsfElectrons.product()->size() << " electrons"
81  << " from event " << ievt << " in run " << irun << " and lumiblock " << ils;
82 
83  h2_ele_beamSpotXvsY->Fill(bs.position().x(), bs.position().y());
84  py_ele_nElectronsVsLs->Fill(float(ils), (*gsfElectrons).size());
85  py_ele_nClustersVsLs->Fill(float(ils), (*recoClusters).size());
86  py_ele_nGsfTracksVsLs->Fill(float(ils), (*gsfTracks).size());
87  py_ele_nTracksVsLs->Fill(float(ils), (*tracks).size());
88  py_ele_nVerticesVsLs->Fill(float(ils), (*vertices).size());
89 
90  // trigger
92  iEvent.getByToken(triggerResults_, triggerResults);
93  if (triggerResults.isValid()) {
94  unsigned int i, n = triggerResults->size();
95  for (i = 0; i != n; ++i) {
96  if (triggerResults->accept(i)) {
97  h1_ele_triggers->Fill(float(i));
98  }
99  }
100  }
101 }
RunNumber_t run() const
Definition: EventID.h:38
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
EventNumber_t event() const
Definition: EventID.h:40
MonitorElement * py_ele_nGsfTracksVsLs
MonitorElement * h2_ele_beamSpotXvsY
MonitorElement * py_ele_nVerticesVsLs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
auto const & tracks
cannot be loose
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:44
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< reco::VertexCollection > vertexCollection_
Log< level::Info, false > LogInfo
T const * product() const
Definition: Handle.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
edm::EventID id() const
Definition: EventBase.h:59
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")
const Point & position() const
position
Definition: BeamSpot.h:59
unsigned int RunNumber_t
edm::EDGetTokenT< reco::GsfTrackCollection > gsftrackCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > matchingObjectCollection_
Definition: Run.h:45