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