CMS 3D CMS Logo

EcalBarrelDigisValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalBarrelDigisValidation.cc
3  *
4  * \author F. Cossutti
5  *
6 */
7 
11 
12 using namespace cms;
13 using namespace edm;
14 using namespace std;
15 
17  : EBdigiCollection_(consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"))) {
18  // verbosity switch
19  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
20 
21  // get hold of back-end interface
22 
23  gainConv_[1] = 1.;
24  gainConv_[2] = 2.;
25  gainConv_[3] = 12.;
26  gainConv_[0] = 12.; // saturated channels
27  barrelADCtoGeV_ = 0.035;
28  endcapADCtoGeV_ = 0.06;
29 
30  meEBDigiOccupancy_ = nullptr;
31 
32  meEBDigiMultiplicity_ = nullptr;
33 
34  meEBDigiADCGlobal_ = nullptr;
35 
36  for (int i = 0; i < 10; i++) {
37  meEBDigiADCAnalog_[i] = nullptr;
38  meEBDigiADCgS_[i] = nullptr;
39  meEBDigiADCg1_[i] = nullptr;
40  meEBDigiADCg6_[i] = nullptr;
41  meEBDigiADCg12_[i] = nullptr;
42  meEBDigiGain_[i] = nullptr;
43  }
44 
45  meEBPedestal_ = nullptr;
46 
47  meEBMaximumgt100ADC_ = nullptr;
48 
49  meEBMaximumgt10ADC_ = nullptr;
50 
51  meEBnADCafterSwitch_ = nullptr;
52 }
53 
55 
57  Char_t histo[200];
58 
59  ibooker.setCurrentFolder("EcalDigisV/EcalDigiTask");
60 
61  sprintf(histo, "EcalDigiTask Barrel occupancy");
62  meEBDigiOccupancy_ = ibooker.book2D(histo, histo, 360, 0., 360., 170, -85., 85.);
63 
64  sprintf(histo, "EcalDigiTask Barrel digis multiplicity");
65  meEBDigiMultiplicity_ = ibooker.book1D(histo, histo, 612, 0., 61200);
66 
67  sprintf(histo, "EcalDigiTask Barrel global pulse shape");
68  meEBDigiADCGlobal_ = ibooker.bookProfile(histo, histo, 10, 0, 10, 10000, 0., 1000.);
69 
70  for (int i = 0; i < 10; i++) {
71  sprintf(histo, "EcalDigiTask Barrel analog pulse %02d", i + 1);
72  meEBDigiADCAnalog_[i] = ibooker.book1D(histo, histo, 4000, 0., 400.);
73 
74  sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 0 - Saturated", i + 1);
75  meEBDigiADCgS_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
76 
77  sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 1", i + 1);
78  meEBDigiADCg1_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
79 
80  sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 6", i + 1);
81  meEBDigiADCg6_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
82 
83  sprintf(histo, "EcalDigiTask Barrel ADC pulse %02d Gain 12", i + 1);
84  meEBDigiADCg12_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
85 
86  sprintf(histo, "EcalDigiTask Barrel gain pulse %02d", i + 1);
87  meEBDigiGain_[i] = ibooker.book1D(histo, histo, 4, 0, 4);
88  }
89 
90  sprintf(histo, "EcalDigiTask Barrel pedestal for pre-sample");
91  meEBPedestal_ = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
92 
93  sprintf(histo, "EcalDigiTask Barrel maximum position gt 100 ADC");
94  meEBMaximumgt100ADC_ = ibooker.book1D(histo, histo, 10, 0., 10.);
95 
96  sprintf(histo, "EcalDigiTask Barrel maximum position gt 10 ADC");
97  meEBMaximumgt10ADC_ = ibooker.book1D(histo, histo, 10, 0., 10.);
98 
99  sprintf(histo, "EcalDigiTask Barrel ADC counts after gain switch");
100  meEBnADCafterSwitch_ = ibooker.book1D(histo, histo, 10, 0., 10.);
101 }
102 
104 
106  //LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
107 
108  Handle<EBDigiCollection> EcalDigiEB;
109 
110  e.getByToken(EBdigiCollection_, EcalDigiEB);
111 
112  //Return if no Barrel data
113  if (!EcalDigiEB.isValid())
114  return;
115 
116  // BARREL
117 
118  // loop over Digis
119 
120  const EBDigiCollection* barrelDigi = EcalDigiEB.product();
121 
122  std::vector<double> ebAnalogSignal;
123  std::vector<double> ebADCCounts;
124  std::vector<double> ebADCGains;
125  ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
126  ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
127  ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
128 
129  int nDigis = 0;
130 
131  for (unsigned int digis = 0; digis < EcalDigiEB->size(); ++digis) {
132  EBDataFrame ebdf = (*barrelDigi)[digis];
133  int nrSamples = ebdf.size();
134 
135  EBDetId ebid = ebdf.id();
136 
137  nDigis++;
138  if (meEBDigiOccupancy_)
139  meEBDigiOccupancy_->Fill(ebid.iphi(), ebid.ieta());
140 
141  double Emax = 0.;
142  int Pmax = 0;
143  double pedestalPreSample = 0.;
144  double pedestalPreSampleAnalog = 0.;
145  int countsAfterGainSwitch = -1;
146  double higherGain = 1.;
147  int higherGainSample = 0;
148 
149  for (int sample = 0; sample < nrSamples; ++sample) {
150  ebAnalogSignal[sample] = 0.;
151  ebADCCounts[sample] = 0.;
152  ebADCGains[sample] = 0.;
153  }
154 
155  for (int sample = 0; sample < nrSamples; ++sample) {
156  EcalMGPASample thisSample = ebdf[sample];
157 
158  ebADCCounts[sample] = (thisSample.adc());
159  ebADCGains[sample] = (thisSample.gainId());
160  ebAnalogSignal[sample] = (ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_);
161 
162  if (Emax < ebAnalogSignal[sample]) {
163  Emax = ebAnalogSignal[sample];
164  Pmax = sample;
165  }
166 
167  if (sample < 3) {
168  pedestalPreSample += ebADCCounts[sample];
169  pedestalPreSampleAnalog += ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_;
170  }
171 
172  if (sample > 0 && (((ebADCGains[sample] > ebADCGains[sample - 1]) && (ebADCGains[sample - 1] != 0)) ||
173  (countsAfterGainSwitch < 0 && ebADCGains[sample] == 0))) {
174  higherGain = ebADCGains[sample];
175  higherGainSample = sample;
176  countsAfterGainSwitch = 1;
177  }
178 
179  if ((higherGain > 1 && (higherGainSample != sample) && (ebADCGains[sample] == higherGain)) ||
180  (higherGain == 3 && (higherGainSample != sample) && (ebADCGains[sample] == 0)) ||
181  (higherGain == 0 && (higherGainSample != sample) &&
182  ((ebADCGains[sample] == 3) || (ebADCGains[sample] == 0)))) {
183  countsAfterGainSwitch++;
184  }
185  }
186 
187  pedestalPreSample /= 3.;
188  pedestalPreSampleAnalog /= 3.;
189 
190  LogDebug("DigiInfo") << "Barrel Digi for EBDetId = " << ebid.rawId() << " eta,phi " << ebid.ieta() << " "
191  << ebid.iphi();
192  for (int i = 0; i < 10; i++) {
193  LogDebug("DigiInfo") << "sample " << i << " ADC = " << ebADCCounts[i] << " gain = " << ebADCGains[i]
194  << " Analog = " << ebAnalogSignal[i];
195  }
196  LogDebug("DigiInfo") << "Maximum energy = " << Emax << " in sample " << Pmax
197  << " Pedestal from pre-sample = " << pedestalPreSampleAnalog;
198  if (countsAfterGainSwitch > 0)
199  LogDebug("DigiInfo") << "Counts after switch " << countsAfterGainSwitch;
200 
201  if (countsAfterGainSwitch > 0 && countsAfterGainSwitch < 5) {
202  edm::LogWarning("DigiWarning") << "Wrong number of counts after gain switch before next switch! "
203  << countsAfterGainSwitch;
204  for (int i = 0; i < 10; i++) {
205  edm::LogWarning("DigiWarning") << "sample " << i << " ADC = " << ebADCCounts[i] << " gain = " << ebADCGains[i]
206  << " Analog = " << ebAnalogSignal[i];
207  }
208  }
209 
210  for (int i = 0; i < 10; i++) {
211  if (meEBDigiADCGlobal_ &&
212  (Emax - pedestalPreSampleAnalog * gainConv_[(int)ebADCGains[Pmax]]) > 100. * barrelADCtoGeV_)
213  meEBDigiADCGlobal_->Fill(i, ebAnalogSignal[i]);
214  if (meEBDigiADCAnalog_[i])
215  meEBDigiADCAnalog_[i]->Fill(ebAnalogSignal[i]);
216 
217  if (ebADCGains[i] == 0) {
218  if (meEBDigiADCgS_[i])
219  meEBDigiADCgS_[i]->Fill(ebADCCounts[i]);
220  } else if (ebADCGains[i] == 3) {
221  if (meEBDigiADCg1_[i])
222  meEBDigiADCg1_[i]->Fill(ebADCCounts[i]);
223  } else if (ebADCGains[i] == 2) {
224  if (meEBDigiADCg6_[i])
225  meEBDigiADCg6_[i]->Fill(ebADCCounts[i]);
226  } else if (ebADCGains[i] == 1) {
227  if (meEBDigiADCg12_[i])
228  meEBDigiADCg12_[i]->Fill(ebADCCounts[i]);
229  }
230  if (meEBDigiGain_[i])
231  meEBDigiGain_[i]->Fill(ebADCGains[i]);
232  }
233 
234  if (meEBPedestal_)
235  meEBPedestal_->Fill(pedestalPreSample);
236  if (meEBMaximumgt10ADC_ &&
237  (Emax - pedestalPreSampleAnalog * gainConv_[(int)ebADCGains[Pmax]]) > 10. * barrelADCtoGeV_)
238  meEBMaximumgt10ADC_->Fill(Pmax);
239  if (meEBMaximumgt100ADC_ &&
240  (Emax - pedestalPreSampleAnalog * gainConv_[(int)ebADCGains[Pmax]]) > 100. * barrelADCtoGeV_)
241  meEBMaximumgt100ADC_->Fill(Pmax);
243  meEBnADCafterSwitch_->Fill(countsAfterGainSwitch);
244  }
245 
247  meEBDigiMultiplicity_->Fill(nDigis);
248 }
249 
251  // ADC -> GeV Scale
253  eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
254  const EcalADCToGeVConstant* agc = pAgc.product();
255 
256  EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();
257 
258  gainConv_[1] = 1.;
259  gainConv_[2] = defaultRatios->gain12Over6();
260  gainConv_[3] = gainConv_[2] * (defaultRatios->gain6Over1());
261  gainConv_[0] = gainConv_[2] * (defaultRatios->gain6Over1());
262 
263  LogDebug("EcalDigi") << " Gains conversions: "
264  << "\n"
265  << " g0 = " << gainConv_[0] << "\n"
266  << " g1 = " << gainConv_[1] << "\n"
267  << " g2 = " << gainConv_[2] << "\n"
268  << " g3 = " << gainConv_[3];
269 
270  delete defaultRatios;
271 
272  const double barrelADCtoGeV_ = agc->getEBValue();
273  LogDebug("EcalDigi") << " Barrel GeV/ADC = " << barrelADCtoGeV_;
274  const double endcapADCtoGeV_ = agc->getEEValue();
275  LogDebug("EcalDigi") << " Endcap GeV/ADC = " << endcapADCtoGeV_;
276 }
#define LogDebug(id)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
T getUntrackedParameter(std::string const &, T const &) const
std::map< int, double, std::less< int > > gainConv_
key_type id() const
Definition: EBDataFrame.h:28
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
~EcalBarrelDigisValidation() override
Destructor.
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MonitorElement * meEBDigiADCAnalog_[10]
int gainId() const
get the gainId (2 bits)
int size() const
Definition: EcalDataFrame.h:26
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
void Fill(long long x)
void checkCalibrations(edm::EventSetup const &c)
void analyze(edm::Event const &e, edm::EventSetup const &c) override
Analyze.
edm::EDGetTokenT< EBDigiCollection > EBdigiCollection_
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
Definition: DQMStore.cc:333
EcalBarrelDigisValidation(const edm::ParameterSet &ps)
Constructor.
float gain6Over1() const
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
bool isValid() const
Definition: HandleBase.h:70
Namespace of DDCMS conversion namespace.
void reserve(size_t isize)
T const * product() const
Definition: Handle.h:69
float gain12Over6() const
MonitorElement * meEBDigiADCg12_[10]
HLT enums.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: DQMStore.cc:266
T get() const
Definition: EventSetup.h:73
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:45
int adc() const
get the ADC sample (12 bits)