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