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