CMS 3D CMS Logo

EcalPreshowerRecHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalPreshowerRecHitsValidation.cc
3  *
4  * \author C. Rovelli
5  *
6  */
7 
12 
13 using namespace cms;
14 using namespace edm;
15 using namespace std;
16 
18  // ----------------------
19  EEuncalibrechitCollection_token_ =
20  consumes<EEUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EEuncalibrechitCollection"));
21  EErechitCollection_token_ = consumes<EERecHitCollection>(ps.getParameter<edm::InputTag>("EErechitCollection"));
22  ESrechitCollection_token_ = consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("ESrechitCollection"));
23 
24  // ----------------------
25  // verbosity switch
26  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
27 
28  // ----------------------
29  meESRecHitsEnergy_ = nullptr; // total energy
30  meESRecHitsEnergy_zp1st_ = nullptr;
31  meESRecHitsEnergy_zp2nd_ = nullptr;
32  meESRecHitsEnergy_zm1st_ = nullptr;
33  meESRecHitsEnergy_zm2nd_ = nullptr;
34  meESRecHitsMultip_ = nullptr; // total multiplicity
35  meESRecHitsMultip_zp1st_ = nullptr;
36  meESRecHitsMultip_zp2nd_ = nullptr;
37  meESRecHitsMultip_zm1st_ = nullptr;
38  meESRecHitsMultip_zm2nd_ = nullptr;
39  meESEERecHitsEnergy_zp_ = nullptr; // versus EE energy
40  meESEERecHitsEnergy_zm_ = nullptr;
41 
42  for (int kk = 0; kk < 32; kk++) {
43  meESRecHitsStripOccupancy_zp1st_[kk] = nullptr;
44  meESRecHitsStripOccupancy_zm1st_[kk] = nullptr;
45  meESRecHitsStripOccupancy_zp2nd_[kk] = nullptr;
46  meESRecHitsStripOccupancy_zm2nd_[kk] = nullptr;
47  }
48 }
49 
51 
53  edm::Run const &,
54  edm::EventSetup const &) {
55  Char_t histo[200];
56 
57  ibooker.setCurrentFolder("EcalRecHitsV/EcalPreshowerRecHitsTask");
58 
59  sprintf(histo, "ES Energy");
60  meESRecHitsEnergy_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
61 
62  sprintf(histo, "ES Energy Plane1 Side+");
63  meESRecHitsEnergy_zp1st_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
64 
65  sprintf(histo, "ES Energy Plane2 Side+");
66  meESRecHitsEnergy_zp2nd_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
67 
68  sprintf(histo, "ES Energy Plane1 Side-");
69  meESRecHitsEnergy_zm1st_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
70 
71  sprintf(histo, "ES Energy Plane2 Side-");
72  meESRecHitsEnergy_zm2nd_ = ibooker.book1D(histo, histo, 210, -0.0005, 0.01);
73 
74  sprintf(histo, "ES Multiplicity");
75  meESRecHitsMultip_ = ibooker.book1D(histo, histo, 100, 0., 700.);
76 
77  sprintf(histo, "ES Multiplicity Plane1 Side+");
78  meESRecHitsMultip_zp1st_ = ibooker.book1D(histo, histo, 100, 0., 700.);
79 
80  sprintf(histo, "ES Multiplicity Plane2 Side+");
81  meESRecHitsMultip_zp2nd_ = ibooker.book1D(histo, histo, 100, 0., 700.);
82 
83  sprintf(histo, "ES Multiplicity Plane1 Side-");
84  meESRecHitsMultip_zm1st_ = ibooker.book1D(histo, histo, 100, 0., 700.);
85 
86  sprintf(histo, "ES Multiplicity Plane2 Side-");
87  meESRecHitsMultip_zm2nd_ = ibooker.book1D(histo, histo, 100, 0., 700.);
88 
89  sprintf(histo, "Preshower EE vs ES energy Side+");
90  meESEERecHitsEnergy_zp_ = ibooker.book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
91 
92  sprintf(histo, "Preshower EE vs ES energy Side-");
93  meESEERecHitsEnergy_zm_ = ibooker.book2D(histo, histo, 100, 0., 0.2, 100, 0., 150.);
94 
95  for (int kk = 0; kk < 32; kk++) {
96  sprintf(histo, "ES Occupancy Plane1 Side+ Strip%02d", kk + 1);
97  meESRecHitsStripOccupancy_zp1st_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
98 
99  sprintf(histo, "ES Occupancy Plane2 Side+ Strip%02d", kk + 1);
100  meESRecHitsStripOccupancy_zp2nd_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
101 
102  sprintf(histo, "ES Occupancy Plane1 Side- Strip%02d", kk + 1);
103  meESRecHitsStripOccupancy_zm1st_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
104 
105  sprintf(histo, "ES Occupancy Plane2 Side- Strip%02d", kk + 1);
106  meESRecHitsStripOccupancy_zm2nd_[kk] = ibooker.book2D(histo, histo, 40, 0., 40., 40, 0., 40.);
107  }
108 }
109 
111  const ESRecHitCollection *ESRecHit = nullptr;
112  Handle<ESRecHitCollection> EcalRecHitES;
113  e.getByToken(ESrechitCollection_token_, EcalRecHitES);
114  if (EcalRecHitES.isValid()) {
115  ESRecHit = EcalRecHitES.product();
116  } else {
117  return;
118  }
119 
120  bool skipEE = false;
121  const EERecHitCollection *EERecHit = nullptr;
122  Handle<EERecHitCollection> EcalRecHitEE;
123  e.getByToken(EErechitCollection_token_, EcalRecHitEE);
124  if (EcalRecHitEE.isValid()) {
125  EERecHit = EcalRecHitEE.product();
126  } else {
127  skipEE = true;
128  }
129 
131  Handle<EEUncalibratedRecHitCollection> EcalUncalibRecHitEE;
132  e.getByToken(EEuncalibrechitCollection_token_, EcalUncalibRecHitEE);
133  if (EcalUncalibRecHitEE.isValid()) {
134  EEUncalibRecHit = EcalUncalibRecHitEE.product();
135  } else {
136  skipEE = true;
137  }
138 
139  // ----------------------
140  // loop over RecHits
141  // multiplicities
142  int mult_tot = 0;
143  int mult_zp1st = 0;
144  int mult_zp2nd = 0;
145  int mult_zm1st = 0;
146  int mult_zm2nd = 0;
147 
148  // energies
149  float ene_zp1st = 0.;
150  float ene_zp2nd = 0.;
151  float ene_zm1st = 0.;
152  float ene_zm2nd = 0.;
153 
154  // ES
155  for (ESRecHitCollection::const_iterator recHit = ESRecHit->begin(); recHit != ESRecHit->end(); ++recHit) {
156  ESDetId ESid = ESDetId(recHit->id());
157 
158  int zside = ESid.zside();
159  int plane = ESid.plane();
160  int six = ESid.six();
161  int siy = ESid.siy();
162  int strip = ESid.strip();
163 
164  // global
165  mult_tot++;
166  if (meESRecHitsEnergy_)
167  meESRecHitsEnergy_->Fill(recHit->energy());
168 
169  // side +, plane 1
170  if ((zside == +1) && (plane == 1)) {
171  mult_zp1st++;
172  ene_zp1st += recHit->energy();
173  if (meESRecHitsEnergy_zp1st_) {
174  meESRecHitsEnergy_zp1st_->Fill(recHit->energy());
175  }
176  if (meESRecHitsStripOccupancy_zp1st_[strip - 1]) {
177  meESRecHitsStripOccupancy_zp1st_[strip - 1]->Fill(six, siy);
178  }
179  }
180 
181  // side +, plane 2
182  if ((zside == +1) && (plane == 2)) {
183  mult_zp2nd++;
184  ene_zp2nd += recHit->energy();
185  if (meESRecHitsEnergy_zp2nd_) {
186  meESRecHitsEnergy_zp2nd_->Fill(recHit->energy());
187  }
188  if (meESRecHitsStripOccupancy_zp2nd_[strip - 1]) {
189  meESRecHitsStripOccupancy_zp2nd_[strip - 1]->Fill(six, siy);
190  }
191  }
192 
193  // side -, plane 1
194  if ((zside == -1) && (plane == 1)) {
195  mult_zm1st++;
196  ene_zm1st += recHit->energy();
197  if (meESRecHitsEnergy_zm1st_) {
198  meESRecHitsEnergy_zm1st_->Fill(recHit->energy());
199  }
200  if (meESRecHitsStripOccupancy_zm1st_[strip - 1]) {
201  meESRecHitsStripOccupancy_zm1st_[strip - 1]->Fill(six, siy);
202  }
203  }
204 
205  // side +, plane 2
206  if ((zside == -1) && (plane == 2)) {
207  mult_zm2nd++;
208  ene_zm2nd += recHit->energy();
209  if (meESRecHitsEnergy_zm2nd_) {
210  meESRecHitsEnergy_zm2nd_->Fill(recHit->energy());
211  }
212  if (meESRecHitsStripOccupancy_zm2nd_[strip - 1]) {
213  meESRecHitsStripOccupancy_zm2nd_[strip - 1]->Fill(six, siy);
214  }
215  }
216 
217  } // loop over the ES RecHitCollection
218 
219  // EE
220  double zpEE = 0.;
221  double zmEE = 0.;
222  if (!skipEE) {
224  uncalibRecHit != EEUncalibRecHit->end();
225  ++uncalibRecHit) {
226  EEDetId EEid = EEDetId(uncalibRecHit->id());
227  int mySide = EEid.zside();
228 
229  // Find corresponding recHit
230  EcalRecHitCollection::const_iterator myRecHit = EERecHit->find(EEid);
231 
232  if (myRecHit != EERecHit->end()) {
233  if (mySide > 0) {
234  zpEE = zpEE + myRecHit->energy();
235  }
236  if (mySide < 0) {
237  zmEE = zmEE + myRecHit->energy();
238  }
239  }
240  }
241  }
242 
243  // filling histos
244  if (meESRecHitsMultip_) {
245  meESRecHitsMultip_->Fill(mult_tot);
246  }
247  if (meESRecHitsMultip_zp1st_) {
248  meESRecHitsMultip_zp1st_->Fill(mult_zp1st);
249  }
250  if (meESRecHitsMultip_zp2nd_) {
251  meESRecHitsMultip_zp2nd_->Fill(mult_zp2nd);
252  }
253  if (meESRecHitsMultip_zm1st_) {
254  meESRecHitsMultip_zm1st_->Fill(mult_zm1st);
255  }
256  if (meESRecHitsMultip_zm2nd_) {
257  meESRecHitsMultip_zm2nd_->Fill(mult_zm2nd);
258  }
259  if (meESEERecHitsEnergy_zp_) {
260  meESEERecHitsEnergy_zp_->Fill((ene_zp1st + 0.7 * ene_zp2nd) / 0.09, zpEE);
261  }
262  if (meESEERecHitsEnergy_zm_) {
263  meESEERecHitsEnergy_zm_->Fill((ene_zm1st + 0.7 * ene_zm2nd) / 0.09, zmEE);
264  }
265 }
EcalPreshowerRecHitsValidation(const edm::ParameterSet &ps)
Constructor.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
~EcalPreshowerRecHitsValidation() override
Destructor.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T const * product() const
Definition: Handle.h:70
std::vector< EcalRecHit >::const_iterator const_iterator
int zside() const
Definition: ESDetId.h:39
int zside(DetId const &)
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
int plane() const
Definition: ESDetId.h:41
const_iterator begin() const
Namespace of DDCMS conversion namespace.
const_iterator end() const
int zside() const
Definition: EEDetId.h:71
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
int siy() const
Definition: ESDetId.h:45
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
int six() const
Definition: ESDetId.h:43
int strip() const
Definition: ESDetId.h:47
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45