CMS 3D CMS Logo

EcalEndcapDigisValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalEndcapDigisValidation.cc
3  *
4  * \author F. Cossutti
5  *
6 */
7 
10 
11 using namespace cms;
12 using namespace edm;
13 using namespace std;
14 
16  : EEdigiCollectionToken_(consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"))),
17  pAgc(esConsumes<edm::Transition::BeginRun>()) {
18  // verbosity switch
19  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
20 
21  gainConv_[1] = 1.;
22  gainConv_[2] = 2.;
23  gainConv_[3] = 12.;
24  gainConv_[0] = 12.; // saturated channels
25  barrelADCtoGeV_ = 0.035;
26  endcapADCtoGeV_ = 0.06;
27 
28  meEEDigiOccupancyzp_ = nullptr;
29  meEEDigiOccupancyzm_ = nullptr;
30 
31  meEEDigiMultiplicityzp_ = nullptr;
32  meEEDigiMultiplicityzm_ = nullptr;
33 
34  meEEDigiADCGlobal_ = nullptr;
35 
36  for (int i = 0; i < 10; i++) {
37  meEEDigiADCAnalog_[i] = nullptr;
38  meEEDigiADCgS_[i] = nullptr;
39  meEEDigiADCg1_[i] = nullptr;
40  meEEDigiADCg6_[i] = nullptr;
41  meEEDigiADCg12_[i] = nullptr;
42  meEEDigiGain_[i] = nullptr;
43  }
44 
45  meEEPedestal_ = nullptr;
46 
47  meEEMaximumgt100ADC_ = nullptr;
48 
49  meEEMaximumgt20ADC_ = nullptr;
50 
51  meEEnADCafterSwitch_ = nullptr;
52 }
53 
55 
57  Char_t histo[200];
58 
59  ibooker.setCurrentFolder("EcalDigisV/EcalDigiTask");
60 
61  sprintf(histo, "EcalDigiTask Endcap occupancy z+");
62  meEEDigiOccupancyzp_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
63 
64  sprintf(histo, "EcalDigiTask Endcap occupancy z-");
65  meEEDigiOccupancyzm_ = ibooker.book2D(histo, histo, 100, 0., 100., 100, 0., 100.);
66 
67  sprintf(histo, "EcalDigiTask Endcap multiplicity z+");
68  meEEDigiMultiplicityzp_ = ibooker.book1D(histo, histo, 100, 0., 7324.);
69 
70  sprintf(histo, "EcalDigiTask Endcap multiplicity z-");
71  meEEDigiMultiplicityzm_ = ibooker.book1D(histo, histo, 100, 0., 7324.);
72 
73  sprintf(histo, "EcalDigiTask Endcap global pulse shape");
74  meEEDigiADCGlobal_ = ibooker.bookProfile(histo, histo, 10, 0, 10, 10000, 0., 1000.);
75 
76  for (int i = 0; i < 10; i++) {
77  sprintf(histo, "EcalDigiTask Endcap analog pulse %02d", i + 1);
78  meEEDigiADCAnalog_[i] = ibooker.book1D(histo, histo, 4000, 0., 400.);
79 
80  sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 0 - Saturated", i + 1);
81  meEEDigiADCgS_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
82 
83  sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 1", i + 1);
84  meEEDigiADCg1_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
85 
86  sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 6", i + 1);
87  meEEDigiADCg6_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
88 
89  sprintf(histo, "EcalDigiTask Endcap ADC pulse %02d Gain 12", i + 1);
90  meEEDigiADCg12_[i] = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
91 
92  sprintf(histo, "EcalDigiTask Endcap gain pulse %02d", i + 1);
93  meEEDigiGain_[i] = ibooker.book1D(histo, histo, 4, 0, 4);
94  }
95 
96  sprintf(histo, "EcalDigiTask Endcap pedestal for pre-sample");
97  meEEPedestal_ = ibooker.book1D(histo, histo, 4096, -0.5, 4095.5);
98 
99  sprintf(histo, "EcalDigiTask Endcap maximum position gt 100 ADC");
100  meEEMaximumgt100ADC_ = ibooker.book1D(histo, histo, 10, 0., 10.);
101 
102  sprintf(histo, "EcalDigiTask Endcap maximum position gt 20 ADC");
103  meEEMaximumgt20ADC_ = ibooker.book1D(histo, histo, 10, 0., 10.);
104 
105  sprintf(histo, "EcalDigiTask Endcap ADC counts after gain switch");
106  meEEnADCafterSwitch_ = ibooker.book1D(histo, histo, 10, 0., 10.);
107 }
108 
110 
112  //LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
113 
114  Handle<EEDigiCollection> EcalDigiEE;
115 
116  e.getByToken(EEdigiCollectionToken_, EcalDigiEE);
117 
118  // Return if no Endcap data available
119  if (!EcalDigiEE.isValid())
120  return;
121 
122  // ENDCAP
123 
124  // loop over Digis
125 
126  const EEDigiCollection* endcapDigi = EcalDigiEE.product();
127 
128  std::vector<double> eeAnalogSignal;
129  std::vector<double> eeADCCounts;
130  std::vector<double> eeADCGains;
131  eeAnalogSignal.reserve(EEDataFrame::MAXSAMPLES);
132  eeADCCounts.reserve(EEDataFrame::MAXSAMPLES);
133  eeADCGains.reserve(EEDataFrame::MAXSAMPLES);
134 
135  int nDigiszp = 0;
136  int nDigiszm = 0;
137 
138  for (unsigned int digis = 0; digis < EcalDigiEE->size(); ++digis) {
139  EEDataFrame eedf = (*endcapDigi)[digis];
140  int nrSamples = eedf.size();
141 
142  EEDetId eeid = eedf.id();
143 
144  if (eeid.zside() > 0) {
146  meEEDigiOccupancyzp_->Fill(eeid.ix(), eeid.iy());
147  nDigiszp++;
148  } else if (eeid.zside() < 0) {
150  meEEDigiOccupancyzm_->Fill(eeid.ix(), eeid.iy());
151  nDigiszm++;
152  }
153 
154  double Emax = 0.;
155  int Pmax = 0;
156  double pedestalPreSample = 0.;
157  double pedestalPreSampleAnalog = 0.;
158  int countsAfterGainSwitch = -1;
159  double higherGain = 1.;
160  int higherGainSample = 0;
161 
162  for (int sample = 0; sample < nrSamples; ++sample) {
163  eeAnalogSignal[sample] = 0.;
164  eeADCCounts[sample] = 0.;
165  eeADCGains[sample] = 0.;
166  }
167 
168  for (int sample = 0; sample < nrSamples; ++sample) {
170 
171  eeADCCounts[sample] = (mySample.adc());
172  eeADCGains[sample] = (mySample.gainId());
173  eeAnalogSignal[sample] = (eeADCCounts[sample] * gainConv_[(int)eeADCGains[sample]] * endcapADCtoGeV_);
174 
175  if (Emax < eeAnalogSignal[sample]) {
176  Emax = eeAnalogSignal[sample];
177  Pmax = sample;
178  }
179 
180  if (sample < 3) {
181  pedestalPreSample += eeADCCounts[sample];
182  pedestalPreSampleAnalog += eeADCCounts[sample] * gainConv_[(int)eeADCGains[sample]] * endcapADCtoGeV_;
183  }
184 
185  if (sample > 0 && (((eeADCGains[sample] > eeADCGains[sample - 1]) && (eeADCGains[sample - 1] != 0)) ||
186  (countsAfterGainSwitch < 0 && eeADCGains[sample] == 0))) {
187  higherGain = eeADCGains[sample];
188  higherGainSample = sample;
189  countsAfterGainSwitch = 1;
190  }
191 
192  if ((higherGain > 1 && (higherGainSample != sample) && (eeADCGains[sample] == higherGain)) ||
193  (higherGain == 3 && (higherGainSample != sample) && (eeADCGains[sample] == 0)) ||
194  (higherGain == 0 && (higherGainSample != sample) && ((eeADCGains[sample] == 0) || (eeADCGains[sample] == 3))))
195  countsAfterGainSwitch++;
196  }
197  pedestalPreSample /= 3.;
198  pedestalPreSampleAnalog /= 3.;
199 
200  LogDebug("DigiInfo") << "Endcap Digi for EEDetId = " << eeid.rawId() << " x,y " << eeid.ix() << " " << eeid.iy();
201  for (int i = 0; i < 10; i++) {
202  LogDebug("DigiInfo") << "sample " << i << " ADC = " << eeADCCounts[i] << " gain = " << eeADCGains[i]
203  << " Analog = " << eeAnalogSignal[i];
204  }
205  LogDebug("DigiInfo") << "Maximum energy = " << Emax << " in sample " << Pmax
206  << " Pedestal from pre-sample = " << pedestalPreSampleAnalog;
207  if (countsAfterGainSwitch > 0)
208  LogDebug("DigiInfo") << "Counts after switch " << countsAfterGainSwitch;
209 
210  if (countsAfterGainSwitch > 0 && countsAfterGainSwitch < 5) {
211  edm::LogWarning("DigiWarning") << "Wrong number of counts after gain switch before next switch! "
212  << countsAfterGainSwitch;
213  for (int i = 0; i < 10; i++) {
214  edm::LogWarning("DigiWarning") << "sample " << i << " ADC = " << eeADCCounts[i] << " gain = " << eeADCGains[i]
215  << " Analog = " << eeAnalogSignal[i];
216  }
217  }
218 
219  for (int i = 0; i < 10; i++) {
220  if (meEEDigiADCGlobal_ &&
221  (Emax - pedestalPreSampleAnalog * gainConv_[(int)eeADCGains[Pmax]]) > 100. * endcapADCtoGeV_)
222  meEEDigiADCGlobal_->Fill(i, eeAnalogSignal[i]);
223  if (meEEDigiADCAnalog_[i])
224  meEEDigiADCAnalog_[i]->Fill(eeAnalogSignal[i]);
225  if (eeADCGains[i] == 0) {
226  if (meEEDigiADCgS_[i])
227  meEEDigiADCgS_[i]->Fill(eeADCCounts[i]);
228  } else if (eeADCGains[i] == 3) {
229  if (meEEDigiADCg1_[i])
230  meEEDigiADCg1_[i]->Fill(eeADCCounts[i]);
231  } else if (eeADCGains[i] == 2) {
232  if (meEEDigiADCg6_[i])
233  meEEDigiADCg6_[i]->Fill(eeADCCounts[i]);
234  } else if (eeADCGains[i] == 1) {
235  if (meEEDigiADCg12_[i])
236  meEEDigiADCg12_[i]->Fill(eeADCCounts[i]);
237  }
238  if (meEEDigiGain_[i])
239  meEEDigiGain_[i]->Fill(eeADCGains[i]);
240  }
241 
242  if (meEEPedestal_)
243  meEEPedestal_->Fill(pedestalPreSample);
244  if (meEEMaximumgt20ADC_ &&
245  (Emax - pedestalPreSampleAnalog * gainConv_[(int)eeADCGains[Pmax]]) > 20. * endcapADCtoGeV_)
247  if (meEEMaximumgt100ADC_ &&
248  (Emax - pedestalPreSampleAnalog * gainConv_[(int)eeADCGains[Pmax]]) > 100. * endcapADCtoGeV_)
251  meEEnADCafterSwitch_->Fill(countsAfterGainSwitch);
252  }
253 
255  meEEDigiMultiplicityzp_->Fill(nDigiszp);
257  meEEDigiMultiplicityzm_->Fill(nDigiszm);
258 }
259 
261  // ADC -> GeV Scale
262  const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);
263 
264  EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();
265 
266  gainConv_[1] = 1.;
267  gainConv_[2] = defaultRatios->gain12Over6();
268  gainConv_[3] = gainConv_[2] * (defaultRatios->gain6Over1());
269  gainConv_[0] = gainConv_[2] * (defaultRatios->gain6Over1());
270 
271  LogDebug("EcalDigi") << " Gains conversions: "
272  << "\n"
273  << " g0 = " << gainConv_[0] << "\n"
274  << " g1 = " << gainConv_[1] << "\n"
275  << " g2 = " << gainConv_[2] << "\n"
276  << " g3 = " << gainConv_[3];
277 
278  delete defaultRatios;
279 
280  const double barrelADCtoGeV_ = agc->getEBValue();
281  LogDebug("EcalDigi") << " Barrel GeV/ADC = " << barrelADCtoGeV_;
282  const double endcapADCtoGeV_ = agc->getEEValue();
283  LogDebug("EcalDigi") << " Endcap GeV/ADC = " << endcapADCtoGeV_;
284 }
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
~EcalEndcapDigisValidation() override
Destructor.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< EcalADCToGeVConstant, EcalADCToGeVConstantRcd > pAgc
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T const * product() const
Definition: Handle.h:70
int ix() const
Definition: EEDetId.h:77
key_type id() const
Definition: EEDataFrame.h:24
int size() const
Definition: EcalDataFrame.h:26
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
MonitorElement * meEEDigiADCAnalog_[10]
Transition
Definition: Transition.h:12
edm::EDGetTokenT< EEDigiCollection > EEdigiCollectionToken_
MonitorElement * meEEDigiADCg12_[10]
Namespace of DDCMS conversion namespace.
void reserve(size_t isize)
float gain12Over6() const
int zside() const
Definition: EEDetId.h:71
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
float gain6Over1() const
bool isValid() const
Definition: HandleBase.h:70
EcalEndcapDigisValidation(const edm::ParameterSet &ps)
Constructor.
void checkCalibrations(edm::EventSetup const &c)
void analyze(edm::Event const &e, edm::EventSetup const &c) override
Analyze.
HLT enums.
std::map< int, double, std::less< int > > gainConv_
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
Log< level::Warning, false > LogWarning
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
int iy() const
Definition: EEDetId.h:83
#define LogDebug(id)