CMS 3D CMS Logo

GlobalTest.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: GlobalTest
4 //
10 //
11 // Original Author: Ursula Berthon
12 // Created: Fri Sep 23 11:38:38 CEST 2005
13 //
14 //
15 
17 
18 // system include files
19 #include <memory>
20 #include <utility>
21 
22 #include <string>
23 
24 #include <fmt/format.h>
25 
26 // user include files
28 
31 
33 
35 #include "TFile.h"
36 
37 using namespace edm;
38 
40  : filename_(iConfig.getParameter<std::string>("fileName")),
41  minbunch_(iConfig.getParameter<int>("minBunch")),
42  maxbunch_(iConfig.getParameter<int>("maxBunch")),
43  cfTrackToken_(consumes<CrossingFrame<SimTrack>>(iConfig.getParameter<edm::InputTag>("cfTrackTag"))),
44  cfVertexToken_(consumes<CrossingFrame<SimTrack>>(iConfig.getParameter<edm::InputTag>("cfVertexTag"))) {
45  std::string ecalsubdetb("");
46  std::string ecalsubdete("g4SimHitsEcalHitsEE");
47  g4SimHits_EB_Token_ = consumes<CrossingFrame<PCaloHit>>(edm::InputTag("mix", "g4SimHitsEcalHitsEB"));
48  g4SimHits_EE_Token_ = consumes<CrossingFrame<PCaloHit>>(edm::InputTag("mix", "g4SimHitsEcalHitsEE"));
49 
50  std::cout << "Constructed GlobalTest, filename: " << filename_ << " minbunch: " << minbunch_
51  << ", maxbunch: " << maxbunch_ << std::endl;
52 }
53 
55  using namespace std;
56 
57  ibooker.setCurrentFolder("MixingV/Mixing");
58  // book histos
59 
60  for (int i = minbunch_; i <= maxbunch_; ++i) {
61  int ii = i - minbunch_;
62  auto label = fmt::format("NrPileupEvts_{}", i);
63  nrPileupsH_[ii] = ibooker.book1D(label, label, 100, 0, 100);
64  label = fmt::format("NrVertices_{}", i);
65  nrVerticesH_[ii] = ibooker.book1D(label, label, 100, 0, 5000);
66  label = fmt::format("NrTracks_{}", i);
67  nrTracksH_[ii] = ibooker.book1D(label, label, 100, 0, 10000);
68  label = fmt::format("TrackPartId", i);
69  trackPartIdH_[ii] = ibooker.book1D(label, label, 100, 0, 100);
70  label = fmt::format("CaloEnergyEB", i);
71  caloEnergyEBH_[ii] = ibooker.book1D(label, label, 100, 0., 1000.);
72  label = fmt::format("CaloEnergyEE", i);
73  caloEnergyEEH_[ii] = ibooker.book1D(label, label, 100, 0., 1000.);
74  }
75 }
76 
77 //
78 // member functions
79 //
80 
81 // ------------ method called to analyze the data ------------
83  using namespace edm;
84  using namespace std;
85 
86  // Get input
91  std::string ecalsubdetb("g4SimHitsEcalHitsEB");
92  std::string ecalsubdete("g4SimHitsEcalHitsEE");
93  iEvent.getByToken(cfTrackToken_, cf_track);
94  iEvent.getByToken(cfVertexToken_, cf_vertex);
95  iEvent.getByToken(g4SimHits_EB_Token_, cf_calohitB);
96  iEvent.getByToken(g4SimHits_EE_Token_, cf_calohitE);
97 
98  // number of events/bcr ??
99 
100  // number of tracks
101  for (int i = minbunch_; i <= maxbunch_; ++i) {
102  nrTracksH_[i - minbunch_]->Fill(cf_track->getNrPileups(i));
103  }
104 
105  // number of vertices
106  for (int i = minbunch_; i <= maxbunch_; ++i) {
107  nrVerticesH_[i - minbunch_]->Fill(cf_vertex->getNrPileups(i));
108  }
109 
110  // part id for each track
111  std::unique_ptr<MixCollection<SimTrack>> coltr(new MixCollection<SimTrack>(cf_track.product()));
113  for (cfitr = coltr->begin(); cfitr != coltr->end(); cfitr++) {
114  trackPartIdH_[cfitr.bunch() - minbunch_]->Fill(cfitr->type());
115  }
116 
117  // energy sum
118  double sumE[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
119  std::unique_ptr<MixCollection<PCaloHit>> colecalb(new MixCollection<PCaloHit>(cf_calohitB.product()));
121  for (cfiecalb = colecalb->begin(); cfiecalb != colecalb->end(); cfiecalb++) {
122  sumE[cfiecalb.bunch() - minbunch_] += cfiecalb->energy();
123  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
124  // else tofecalhist->Fill(cfiecal->time());
125  }
126  for (int i = minbunch_; i <= maxbunch_; ++i) {
127  caloEnergyEBH_[i - minbunch_]->Fill(sumE[i - minbunch_]);
128  }
129  double sumEE[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
130  std::unique_ptr<MixCollection<PCaloHit>> colecale(new MixCollection<PCaloHit>(cf_calohitE.product()));
132  for (cfiecale = colecale->begin(); cfiecale != colecale->end(); cfiecale++) {
133  sumEE[cfiecale.bunch() - minbunch_] += cfiecale->energy();
134  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
135  // else tofecalhist->Fill(cfiecal->time());
136  }
137  for (int i = minbunch_; i <= maxbunch_; ++i) {
138  caloEnergyEEH_[i - minbunch_]->Fill(sumEE[i - minbunch_]);
139  }
140 }
int maxbunch_
Definition: GlobalTest.h:53
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:62
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
T const * product() const
Definition: Handle.h:70
int minbunch_
Definition: GlobalTest.h:52
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EE_Token_
Definition: GlobalTest.h:67
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:60
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfTrackToken_
Definition: GlobalTest.h:64
std::string filename_
Definition: GlobalTest.h:51
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:61
void Fill(long long x)
char const * label
int iEvent
Definition: GenABIO.cc:224
GlobalTest(const edm::ParameterSet &)
Definition: GlobalTest.cc:39
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:57
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:59
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfVertexToken_
Definition: GlobalTest.h:65
ii
Definition: cuy.py:589
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GlobalTest.cc:54
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:58
HLT enums.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EB_Token_
Definition: GlobalTest.h:66
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GlobalTest.cc:82
Definition: Run.h:45