CMS 3D CMS Logo

EcalBarrelRecHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalBarrelRecHitsValidation.cc
3  *
4  * \author C. Rovelli
5  *
6  */
7 
11 
12 using namespace cms;
13 using namespace edm;
14 using namespace std;
15 
17  // ----------------------
18  EBdigiCollection_token_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"));
19  EBuncalibrechitCollection_token_ =
20  consumes<EBUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EBuncalibrechitCollection"));
21 
22  // ----------------------
23  // verbosity switch
24  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
25 
26  // ----------------------
27  meEBUncalibRecHitsOccupancy_ = nullptr;
28  meEBUncalibRecHitsAmplitude_ = nullptr;
29  meEBUncalibRecHitsPedestal_ = nullptr;
30  meEBUncalibRecHitsJitter_ = nullptr;
31  meEBUncalibRecHitsChi2_ = nullptr;
32  meEBUncalibRecHitMaxSampleRatio_ = nullptr;
33  meEBUncalibRecHitsOccupancyGt100adc_ = nullptr;
34  meEBUncalibRecHitsAmplitudeGt100adc_ = nullptr;
35  meEBUncalibRecHitsPedestalGt100adc_ = nullptr;
36  meEBUncalibRecHitsJitterGt100adc_ = nullptr;
37  meEBUncalibRecHitsChi2Gt100adc_ = nullptr;
38  meEBUncalibRecHitMaxSampleRatioGt100adc_ = nullptr;
39  meEBUncalibRecHitsAmpFullMap_ = nullptr;
40  meEBUncalibRecHitsPedFullMap_ = nullptr;
41  for (int i = 0; i < 36; i++) {
42  meEBUncalibRecHitAmplMap_[i] = nullptr;
43  meEBUncalibRecHitPedMap_[i] = nullptr;
44  }
45 }
46 
48 
50  edm::Run const &,
51  edm::EventSetup const &) {
52  Char_t histo[200];
53 
54  ibooker.setCurrentFolder("EcalRecHitsV/EcalBarrelRecHitsTask");
55 
56  sprintf(histo, "EB Occupancy");
57  meEBUncalibRecHitsOccupancy_ = ibooker.book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
58 
59  sprintf(histo, "EB Amplitude");
60  meEBUncalibRecHitsAmplitude_ = ibooker.book1D(histo, histo, 201, -20., 4000.);
61 
62  sprintf(histo, "EB Pedestal");
63  meEBUncalibRecHitsPedestal_ = ibooker.book1D(histo, histo, 50, 190., 210.);
64 
65  sprintf(histo, "EB Jitter");
66  meEBUncalibRecHitsJitter_ = ibooker.book1D(histo, histo, 100, 0., 100.);
67 
68  sprintf(histo, "EB Chi2");
69  meEBUncalibRecHitsChi2_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
70 
71  sprintf(histo, "EB RecHit Max Sample Ratio");
72  meEBUncalibRecHitMaxSampleRatio_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
73 
74  sprintf(histo, "EB Occupancy gt 100 adc counts");
75  meEBUncalibRecHitsOccupancyGt100adc_ = ibooker.book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
76 
77  sprintf(histo, "EB Amplitude gt 100 adc counts");
78  meEBUncalibRecHitsAmplitudeGt100adc_ = ibooker.book1D(histo, histo, 200, 0., 4000.);
79 
80  sprintf(histo, "EB Pedestal gt 100 adc counts");
81  meEBUncalibRecHitsPedestalGt100adc_ = ibooker.book1D(histo, histo, 50, 190., 210.);
82 
83  sprintf(histo, "EB Jitter gt 100 adc counts");
84  meEBUncalibRecHitsJitterGt100adc_ = ibooker.book1D(histo, histo, 100, 0., 100.);
85 
86  sprintf(histo, "EB Chi2 gt 100 adc counts");
87  meEBUncalibRecHitsChi2Gt100adc_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
88 
89  sprintf(histo, "EB RecHit Max Sample Ratio gt 100 adc counts");
90  meEBUncalibRecHitMaxSampleRatioGt100adc_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
91 
92  sprintf(histo, "EB Amplitude Full Map");
93  meEBUncalibRecHitsAmpFullMap_ = ibooker.bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 200, 0., 4000.);
94 
95  sprintf(histo, "EB Pedestal Full Map");
96  meEBUncalibRecHitsPedFullMap_ = ibooker.bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 50, 194., 201.);
97 
98  for (int i = 0; i < 36; i++) {
99  sprintf(histo, "EB Amp SM%02d", i + 1);
100  meEBUncalibRecHitAmplMap_[i] = ibooker.bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 200, 0., 4000.);
101 
102  sprintf(histo, "EB Ped SM%02d", i + 1);
103  meEBUncalibRecHitPedMap_[i] = ibooker.bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 50, 194., 201.);
104  }
105 }
106 
108  const EBUncalibratedRecHitCollection *EBUncalibRecHit = nullptr;
109  Handle<EBUncalibratedRecHitCollection> EcalUncalibRecHitEB;
110  e.getByToken(EBuncalibrechitCollection_token_, EcalUncalibRecHitEB);
111  if (EcalUncalibRecHitEB.isValid()) {
112  EBUncalibRecHit = EcalUncalibRecHitEB.product();
113  } else {
114  return;
115  }
116 
117  bool skipDigis = false;
118  const EBDigiCollection *EBDigi = nullptr;
119  Handle<EBDigiCollection> EcalDigiEB;
120  e.getByToken(EBdigiCollection_token_, EcalDigiEB);
121  if (EcalDigiEB.isValid()) {
122  EBDigi = EcalDigiEB.product();
123  } else {
124  skipDigis = true;
125  }
126 
128  c.get<EcalPedestalsRcd>().get(ecalPeds);
129 
130  // ----------------------
131  // loop over UncalibRecHits
132  for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EBUncalibRecHit->begin();
133  uncalibRecHit != EBUncalibRecHit->end();
134  ++uncalibRecHit) {
135  EBDetId EBid = EBDetId(uncalibRecHit->id());
136 
137  // general checks
138  if (meEBUncalibRecHitsOccupancy_)
139  meEBUncalibRecHitsOccupancy_->Fill(EBid.ieta(), EBid.iphi());
140  if (meEBUncalibRecHitsAmplitude_)
141  meEBUncalibRecHitsAmplitude_->Fill(uncalibRecHit->amplitude());
142  if (meEBUncalibRecHitsPedestal_)
143  meEBUncalibRecHitsPedestal_->Fill(uncalibRecHit->pedestal());
144  if (meEBUncalibRecHitsJitter_)
145  meEBUncalibRecHitsJitter_->Fill(uncalibRecHit->jitter());
146  if (meEBUncalibRecHitsChi2_)
147  meEBUncalibRecHitsChi2_->Fill(uncalibRecHit->chi2());
148  if (meEBUncalibRecHitsAmpFullMap_)
149  meEBUncalibRecHitsAmpFullMap_->Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->amplitude());
150  if (meEBUncalibRecHitsPedFullMap_)
151  meEBUncalibRecHitsPedFullMap_->Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->pedestal());
152 
153  // general checks, with threshold at 3.5 GeV = 100 ADC counts
154  if (uncalibRecHit->amplitude() > 100) {
155  if (meEBUncalibRecHitsOccupancyGt100adc_)
156  meEBUncalibRecHitsOccupancyGt100adc_->Fill(EBid.ieta(), EBid.iphi());
157  if (meEBUncalibRecHitsAmplitudeGt100adc_)
158  meEBUncalibRecHitsAmplitudeGt100adc_->Fill(uncalibRecHit->amplitude());
159  if (meEBUncalibRecHitsPedestalGt100adc_)
160  meEBUncalibRecHitsPedestalGt100adc_->Fill(uncalibRecHit->pedestal());
161  if (meEBUncalibRecHitsJitterGt100adc_)
162  meEBUncalibRecHitsJitterGt100adc_->Fill(uncalibRecHit->jitter());
163  if (meEBUncalibRecHitsChi2Gt100adc_)
164  meEBUncalibRecHitsChi2Gt100adc_->Fill(uncalibRecHit->chi2());
165  }
166 
167  // supermodule maps
168  int ic = EBid.ic();
169  int ie = (ic - 1) / 20 + 1;
170  int ip = (ic - 1) % 20 + 1;
171  int ism = EBid.ism();
172  float xie = ie - 0.5;
173  float xip = ip - 0.5;
174  if (meEBUncalibRecHitPedMap_[ism - 1])
175  meEBUncalibRecHitPedMap_[ism - 1]->Fill(xie, xip, uncalibRecHit->pedestal());
176  if (meEBUncalibRecHitAmplMap_[ism - 1])
177  meEBUncalibRecHitAmplMap_[ism - 1]->Fill(xie, xip, uncalibRecHit->amplitude());
178 
179  if (!skipDigis) {
180  // find the rechit corresponding digi and the max sample
181  EBDigiCollection::const_iterator myDigi = EBDigi->find(EBid);
182  // int sMax = -1; // UNUSED
183  double eMax = 0.;
184  if (myDigi != EBDigi->end()) {
185  for (unsigned int sample = 0; sample < myDigi->size(); ++sample) {
186  EcalMGPASample thisSample = (*myDigi)[sample];
187  double analogSample = thisSample.adc();
188  if (eMax < analogSample) {
189  eMax = analogSample;
190  // sMax = sample; // UNUSED
191  }
192  }
193  } else
194  continue;
195 
196  // ratio uncalibratedRecHit amplitude + ped / max energy digi
197  const EcalPedestals *myped = ecalPeds.product();
198  EcalPedestalsMap::const_iterator it = myped->getMap().find(EBid);
199  if (it != myped->getMap().end()) {
200  if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0) { // only real signal RecHit
201 
202  if (meEBUncalibRecHitMaxSampleRatio_)
203  meEBUncalibRecHitMaxSampleRatio_->Fill((uncalibRecHit->amplitude() + uncalibRecHit->pedestal()) / eMax);
204  if (meEBUncalibRecHitMaxSampleRatioGt100adc_ && (uncalibRecHit->amplitude() > 100))
205  meEBUncalibRecHitMaxSampleRatioGt100adc_->Fill((uncalibRecHit->amplitude() + uncalibRecHit->pedestal()) /
206  eMax);
207  LogDebug("EcalRecHitsTaskInfo")
208  << "barrel, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude() + uncalibRecHit->pedestal();
209  } else
210  continue;
211  } else
212  continue;
213  }
214 
215  } // loop over the UncalibratedRecHitCollection
216 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalBarrelRecHitsValidation(const edm::ParameterSet &ps)
Constructor.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const self & getMap() const
std::vector< T >::const_iterator const_iterator
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Analyze.
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
const_iterator find(id_type i) const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:114
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
bool isValid() const
Definition: HandleBase.h:74
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Namespace of DDCMS conversion namespace.
const_iterator end() const
T const * product() const
Definition: Handle.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::vector< Item >::const_iterator const_iterator
const_iterator end() const
HLT enums.
T get() const
Definition: EventSetup.h:71
const_iterator find(uint32_t rawId) const
const_iterator end() const
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
T const * product() const
Definition: ESHandle.h:86
const_iterator begin() const
Definition: Run.h:45
int adc() const
get the ADC sample (12 bits)
~EcalBarrelRecHitsValidation() override
Destructor.