CMS 3D CMS Logo

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