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