CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalBarrelDigisValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalBarrelDigisValidation.cc
3  *
4  * $Date: 2010/01/04 15:10:59 $
5  * $Revision: 1.20 $
6  * \author F. Cossutti
7  *
8 */
9 
13 
14 using namespace cms;
15 using namespace edm;
16 using namespace std;
17 
19  EBdigiCollection_(ps.getParameter<edm::InputTag>("EBdigiCollection"))
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 
50 
52 
54 
55  for (int i = 0; i < 10 ; i++ ) {
56  meEBDigiADCAnalog_[i] = 0;
57  meEBDigiADCgS_[i] = 0;
58  meEBDigiADCg1_[i] = 0;
59  meEBDigiADCg6_[i] = 0;
60  meEBDigiADCg12_[i] = 0;
61  meEBDigiGain_[i] = 0;
62  }
63 
64  meEBPedestal_ = 0;
65 
67 
69 
71 
72  Char_t histo[200];
73 
74 
75  if ( dbe_ ) {
76  dbe_->setCurrentFolder("EcalDigisV/EcalDigiTask");
77 
78  sprintf (histo, "EcalDigiTask Barrel occupancy" ) ;
79  meEBDigiOccupancy_ = dbe_->book2D(histo, histo, 360, 0., 360., 170, -85., 85.);
80 
81  sprintf (histo, "EcalDigiTask Barrel digis multiplicity" ) ;
82  meEBDigiMultiplicity_ = dbe_->book1D(histo, histo, 612, 0., 61200);
83 
84  sprintf (histo, "EcalDigiTask Barrel global pulse shape" ) ;
85  meEBDigiADCGlobal_ = dbe_->bookProfile(histo, histo, 10, 0, 10, 10000, 0., 1000.) ;
86 
87  for (int i = 0; i < 10 ; i++ ) {
88 
89  sprintf (histo, "EcalDigiTask Barrel analog pulse %02d", i+1) ;
90  meEBDigiADCAnalog_[i] = dbe_->book1D(histo, histo, 4000, 0., 400.);
91 
92  sprintf (histo, "EcalDigiTask Barrel ADC pulse %02d Gain 0 - Saturated", i+1) ;
93  meEBDigiADCgS_[i] = dbe_->book1D(histo, histo, 4096, -0.5, 4095.5);
94 
95  sprintf (histo, "EcalDigiTask Barrel ADC pulse %02d Gain 1", i+1) ;
96  meEBDigiADCg1_[i] = dbe_->book1D(histo, histo, 4096, -0.5, 4095.5);
97 
98  sprintf (histo, "EcalDigiTask Barrel ADC pulse %02d Gain 6", i+1) ;
99  meEBDigiADCg6_[i] = dbe_->book1D(histo, histo, 4096, -0.5, 4095.5);
100 
101  sprintf (histo, "EcalDigiTask Barrel ADC pulse %02d Gain 12", i+1) ;
102  meEBDigiADCg12_[i] = dbe_->book1D(histo, histo, 4096, -0.5, 4095.5);
103 
104  sprintf (histo, "EcalDigiTask Barrel gain pulse %02d", i+1) ;
105  meEBDigiGain_[i] = dbe_->book1D(histo, histo, 4, 0, 4);
106 
107  }
108 
109  sprintf (histo, "EcalDigiTask Barrel pedestal for pre-sample" ) ;
110  meEBPedestal_ = dbe_->book1D(histo, histo, 4096, -0.5, 4095.5) ;
111 
112  sprintf (histo, "EcalDigiTask Barrel maximum position gt 100 ADC" ) ;
113  meEBMaximumgt100ADC_ = dbe_->book1D(histo, histo, 10, 0., 10.) ;
114 
115  sprintf (histo, "EcalDigiTask Barrel maximum position gt 10 ADC" ) ;
116  meEBMaximumgt10ADC_ = dbe_->book1D(histo, histo, 10, 0., 10.) ;
117 
118  sprintf (histo, "EcalDigiTask Barrel ADC counts after gain switch" ) ;
119  meEBnADCafterSwitch_ = dbe_->book1D(histo, histo, 10, 0., 10.) ;
120 
121  }
122 
123 }
124 
126 
127 }
128 
130 
132 
133 }
134 
136 
137 }
138 
140 
141  //LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
142 
143  Handle<EBDigiCollection> EcalDigiEB;
144 
145  e.getByLabel( EBdigiCollection_ , EcalDigiEB );
146 
147  //Return if no Barrel data
148  if( !EcalDigiEB.isValid() ) return;
149 
150  // BARREL
151 
152  // loop over Digis
153 
154  const EBDigiCollection * barrelDigi = EcalDigiEB.product () ;
155 
156  std::vector<double> ebAnalogSignal ;
157  std::vector<double> ebADCCounts ;
158  std::vector<double> ebADCGains ;
159  ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES);
160  ebADCCounts.reserve(EBDataFrame::MAXSAMPLES);
161  ebADCGains.reserve(EBDataFrame::MAXSAMPLES);
162 
163  int nDigis = 0;
164 
165  for (unsigned int digis=0; digis<EcalDigiEB->size(); ++digis)
166  {
167 
168  EBDataFrame ebdf = (*barrelDigi)[digis];
169  int nrSamples = ebdf.size();
170 
171  EBDetId ebid = ebdf.id () ;
172 
173  nDigis++;
174  if (meEBDigiOccupancy_) meEBDigiOccupancy_->Fill( ebid.iphi(), ebid.ieta() );
175 
176  double Emax = 0. ;
177  int Pmax = 0 ;
178  double pedestalPreSample = 0.;
179  double pedestalPreSampleAnalog = 0.;
180  int countsAfterGainSwitch = -1;
181  double higherGain = 1.;
182  int higherGainSample = 0;
183 
184  for (int sample = 0 ; sample < nrSamples; ++sample) {
185  ebAnalogSignal[sample] = 0.;
186  ebADCCounts[sample] = 0.;
187  ebADCGains[sample] = 0.;
188  }
189 
190  for (int sample = 0 ; sample < nrSamples; ++sample)
191  {
192  EcalMGPASample thisSample = ebdf[sample];
193 
194  ebADCCounts[sample] = (thisSample.adc());
195  ebADCGains[sample] = (thisSample.gainId());
196  ebAnalogSignal[sample] = (ebADCCounts[sample]*gainConv_[(int)ebADCGains[sample]]*barrelADCtoGeV_);
197 
198  if (Emax < ebAnalogSignal[sample] ) {
199  Emax = ebAnalogSignal[sample] ;
200  Pmax = sample ;
201  }
202 
203  if ( sample < 3 ) {
204  pedestalPreSample += ebADCCounts[sample] ;
205  pedestalPreSampleAnalog += ebADCCounts[sample]*gainConv_[(int)ebADCGains[sample]]*barrelADCtoGeV_ ;
206  }
207 
208  if ( sample > 0 && ( ((ebADCGains[sample] > ebADCGains[sample-1]) && (ebADCGains[sample-1]!=0)) || (countsAfterGainSwitch<0 && ebADCGains[sample]==0)) ) {
209  higherGain = ebADCGains[sample];
210  higherGainSample = sample;
211  countsAfterGainSwitch = 1;
212  }
213 
214  if ( (higherGain > 1 && (higherGainSample != sample) && (ebADCGains[sample] == higherGain)) || (higherGain==3 && (higherGainSample != sample) && (ebADCGains[sample]==0)) || (higherGain==0 && (higherGainSample != sample) && ((ebADCGains[sample] == 3) || (ebADCGains[sample]==0))) ) { countsAfterGainSwitch++ ; }
215  }
216 
217  pedestalPreSample /= 3. ;
218  pedestalPreSampleAnalog /= 3. ;
219 
220  LogDebug("DigiInfo") << "Barrel Digi for EBDetId = " << ebid.rawId() << " eta,phi " << ebid.ieta() << " " << ebid.iphi() ;
221  for ( int i = 0; i < 10 ; i++ ) {
222  LogDebug("DigiInfo") << "sample " << i << " ADC = " << ebADCCounts[i] << " gain = " << ebADCGains[i] << " Analog = " << ebAnalogSignal[i];
223  }
224  LogDebug("DigiInfo") << "Maximum energy = " << Emax << " in sample " << Pmax << " Pedestal from pre-sample = " << pedestalPreSampleAnalog;
225  if ( countsAfterGainSwitch > 0 ) LogDebug("DigiInfo") << "Counts after switch " << countsAfterGainSwitch;
226 
227  if ( countsAfterGainSwitch > 0 && countsAfterGainSwitch < 5 ) {
228  edm::LogWarning("DigiWarning") << "Wrong number of counts after gain switch before next switch! " << countsAfterGainSwitch ;
229  for ( int i = 0; i < 10 ; i++ ) {
230  edm::LogWarning("DigiWarning") << "sample " << i << " ADC = " << ebADCCounts[i] << " gain = " << ebADCGains[i] << " Analog = " << ebAnalogSignal[i];
231  }
232  }
233 
234  for ( int i = 0 ; i < 10 ; i++ ) {
235  if (meEBDigiADCGlobal_ && (Emax-pedestalPreSampleAnalog*gainConv_[(int)ebADCGains[Pmax]]) > 100.*barrelADCtoGeV_) meEBDigiADCGlobal_->Fill( i , ebAnalogSignal[i] ) ;
236  if (meEBDigiADCAnalog_[i]) meEBDigiADCAnalog_[i]->Fill( ebAnalogSignal[i] ) ;
237 
238  if ( ebADCGains[i] == 0) {
239  if (meEBDigiADCgS_[i]) meEBDigiADCgS_[i]->Fill( ebADCCounts[i] ) ;
240  }
241  else if ( ebADCGains[i] == 3 ) {
242  if (meEBDigiADCg1_[i]) meEBDigiADCg1_[i]->Fill( ebADCCounts[i] ) ;
243  }
244  else if ( ebADCGains[i] == 2 ) {
245  if (meEBDigiADCg6_[i]) meEBDigiADCg6_[i]->Fill( ebADCCounts[i] ) ;
246  }
247  else if ( ebADCGains[i] == 1 ) {
248  if (meEBDigiADCg12_[i]) meEBDigiADCg12_[i]->Fill( ebADCCounts[i] ) ;
249  }
250  if (meEBDigiGain_[i]) meEBDigiGain_[i]->Fill( ebADCGains[i] ) ;
251  }
252 
253  if (meEBPedestal_) meEBPedestal_->Fill ( pedestalPreSample ) ;
254  if (meEBMaximumgt10ADC_ && (Emax-pedestalPreSampleAnalog*gainConv_[(int)ebADCGains[Pmax]]) > 10.*barrelADCtoGeV_) meEBMaximumgt10ADC_->Fill( Pmax ) ;
255  if (meEBMaximumgt100ADC_ && (Emax-pedestalPreSampleAnalog*gainConv_[(int)ebADCGains[Pmax]]) > 100.*barrelADCtoGeV_) meEBMaximumgt100ADC_->Fill( Pmax ) ;
256  if (meEBnADCafterSwitch_) meEBnADCafterSwitch_->Fill( countsAfterGainSwitch ) ;
257 
258  }
259 
261 
262 }
263 
265  {
266 
267  // ADC -> GeV Scale
269  eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
270  const EcalADCToGeVConstant* agc = pAgc.product();
271 
272  EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
273 
274  gainConv_[1] = 1.;
275  gainConv_[2] = defaultRatios->gain12Over6() ;
276  gainConv_[3] = gainConv_[2]*(defaultRatios->gain6Over1()) ;
277  gainConv_[0] = gainConv_[2]*(defaultRatios->gain6Over1()) ;
278 
279  LogDebug("EcalDigi") << " Gains conversions: " << "\n" << " g0 = " << gainConv_[0] << "\n" << " g1 = " << gainConv_[1] << "\n" << " g2 = " << gainConv_[2] << "\n" << " g3 = " << gainConv_[3];
280 
281  delete defaultRatios;
282 
283  const double barrelADCtoGeV_ = agc->getEBValue();
284  LogDebug("EcalDigi") << " Barrel GeV/ADC = " << barrelADCtoGeV_;
285  const double endcapADCtoGeV_ = agc->getEEValue();
286  LogDebug("EcalDigi") << " Endcap GeV/ADC = " << endcapADCtoGeV_;
287 
288 }
289 
290 
#define LogDebug(id)
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyze.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< int, double, std::less< int > > gainConv_
key_type id() const
Definition: EBDataFrame.h:32
MonitorElement * meEBDigiADCAnalog_[10]
int gainId() const
get the gainId (2 bits)
int size() const
Definition: EcalDataFrame.h:27
void beginRun(edm::Run const &, edm::EventSetup const &c)
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void checkCalibrations(edm::EventSetup const &c)
EcalBarrelDigisValidation(const edm::ParameterSet &ps)
Constructor.
float gain6Over1() const
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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
MonitorElement * meEBDigiADCg12_[10]
static const int MAXSAMPLES
Definition: EcalDataFrame.h:49
Definition: Run.h:33
int adc() const
get the ADC sample (12 bits)