CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalPedestalWidthsValidation.cc
Go to the documentation of this file.
1 // Original Author: Steven Won
2 // Created: Fri May 2 15:34:43 CEST 2008
3 // Written to replace the combination of HcalPedestalAnalyzer and HcalPedestalAnalysis
4 // This code runs 1000x faster and produces all outputs from a single run
5 // (ADC, fC in .txt plus an .xml file)
6 //
7 #include <memory>
9 
11 {
12  firstTS = ps.getUntrackedParameter<int>("firstTS", 0);
13  lastTS = ps.getUntrackedParameter<int>("lastTS", 9);
14  firsttime = true;
15 
16  rawPedsItem = new HcalPedestals();
20 }
21 
22 
24 {
25  //Calculate pedestal constants
26  std::cout << "Calculating Pedestal constants...\n";
27  std::vector<NewPedBunchVal>::iterator bunch_it;
28  for(bunch_it=BunchVales.begin(); bunch_it != BunchVales.end(); bunch_it++)
29  {
30  if(bunch_it->usedflag){
31 
32  bunch_it->cap[0] /= bunch_it->num[0][0];
33  bunch_it->cap[1] /= bunch_it->num[1][1];
34  bunch_it->cap[2] /= bunch_it->num[2][2];
35  bunch_it->cap[3] /= bunch_it->num[3][3];
36  bunch_it->capfc[0] /= bunch_it->num[0][0];
37  bunch_it->capfc[1] /= bunch_it->num[1][1];
38  bunch_it->capfc[2] /= bunch_it->num[2][2];
39  bunch_it->capfc[3] /= bunch_it->num[3][3];
40  //widths are the covariance matrix--NOT assumed symmetric here
41  bunch_it->sig[0][0] = (bunch_it->prod[0][0]/bunch_it->num[0][0])-(bunch_it->cap[0])*(bunch_it->cap[0]);
42  bunch_it->sig[1][1] = (bunch_it->prod[1][1]/bunch_it->num[1][1])-(bunch_it->cap[1])*(bunch_it->cap[1]);
43  bunch_it->sig[2][2] = (bunch_it->prod[2][2]/bunch_it->num[2][2])-(bunch_it->cap[2])*(bunch_it->cap[2]);
44  bunch_it->sig[3][3] = (bunch_it->prod[3][3]/bunch_it->num[3][3])-(bunch_it->cap[3])*(bunch_it->cap[3]);
45  bunch_it->sig[0][1] = (bunch_it->prod[0][1])/(bunch_it->num[0][1])-(bunch_it->cap[0]*bunch_it->cap[1]);
46  bunch_it->sig[0][2] = (bunch_it->prod[0][2])/(bunch_it->num[0][2])-(bunch_it->cap[0]*bunch_it->cap[2]);
47  bunch_it->sig[0][3] = (bunch_it->prod[0][3])/(bunch_it->num[0][3])-(bunch_it->cap[0]*bunch_it->cap[3]);
48  bunch_it->sig[1][2] = (bunch_it->prod[1][2])/(bunch_it->num[1][2])-(bunch_it->cap[1]*bunch_it->cap[2]);
49  bunch_it->sig[1][3] = (bunch_it->prod[1][3])/(bunch_it->num[1][3])-(bunch_it->cap[1]*bunch_it->cap[3]);
50  bunch_it->sig[2][3] = (bunch_it->prod[2][3])/(bunch_it->num[2][3])-(bunch_it->cap[2]*bunch_it->cap[3]);
51 
52  bunch_it->sig[1][0] = (bunch_it->prod[1][0]/bunch_it->num[1][0])-(bunch_it->cap[1])*(bunch_it->cap[0]);
53  bunch_it->sig[2][0] = (bunch_it->prod[2][0]/bunch_it->num[2][0])-(bunch_it->cap[2])*(bunch_it->cap[0]);
54  bunch_it->sig[2][1] = (bunch_it->prod[2][1]/bunch_it->num[2][1])-(bunch_it->cap[2])*(bunch_it->cap[1]);
55  bunch_it->sig[3][0] = (bunch_it->prod[3][0]/bunch_it->num[3][0])-(bunch_it->cap[3])*(bunch_it->cap[0]);
56  bunch_it->sig[3][1] = (bunch_it->prod[3][1]/bunch_it->num[3][1])-(bunch_it->cap[3])*(bunch_it->cap[1]);
57  bunch_it->sig[3][2] = (bunch_it->prod[3][2]/bunch_it->num[3][2])-(bunch_it->cap[3])*(bunch_it->cap[2]);
58 
59 
60 
61  bunch_it->sigfc[0][0] = (bunch_it->prodfc[0][0]/bunch_it->num[0][0])-(bunch_it->capfc[0])*(bunch_it->capfc[0]);
62  bunch_it->sigfc[1][1] = (bunch_it->prodfc[1][1]/bunch_it->num[1][1])-(bunch_it->capfc[1])*(bunch_it->capfc[1]);
63  bunch_it->sigfc[2][2] = (bunch_it->prodfc[2][2]/bunch_it->num[2][2])-(bunch_it->capfc[2])*(bunch_it->capfc[2]);
64  bunch_it->sigfc[3][3] = (bunch_it->prodfc[3][3]/bunch_it->num[3][3])-(bunch_it->capfc[3])*(bunch_it->capfc[3]);
65  bunch_it->sigfc[0][1] = (bunch_it->prodfc[0][1]/(bunch_it->num[0][1]))-(bunch_it->capfc[0]*bunch_it->capfc[1]);
66  bunch_it->sigfc[0][2] = (bunch_it->prodfc[0][2]/(bunch_it->num[0][2]))-(bunch_it->capfc[0]*bunch_it->capfc[2]);
67  bunch_it->sigfc[0][3] = (bunch_it->prodfc[0][3]/(bunch_it->num[0][3]))-(bunch_it->capfc[0]*bunch_it->capfc[3]);
68  bunch_it->sigfc[1][2] = (bunch_it->prodfc[1][2]/(bunch_it->num[1][2]))-(bunch_it->capfc[1]*bunch_it->capfc[2]);
69  bunch_it->sigfc[1][3] = (bunch_it->prodfc[1][3]/(bunch_it->num[1][3]))-(bunch_it->capfc[1]*bunch_it->capfc[3]);
70  bunch_it->sigfc[2][3] = (bunch_it->prodfc[2][3]/(bunch_it->num[2][3]))-(bunch_it->capfc[2]*bunch_it->capfc[3]);
71 
72  bunch_it->sigfc[1][0] = (bunch_it->prodfc[1][0]/(bunch_it->num[1][0]))-(bunch_it->capfc[1]*bunch_it->capfc[0]);
73  bunch_it->sigfc[2][0] = (bunch_it->prodfc[2][0]/(bunch_it->num[2][0]))-(bunch_it->capfc[2]*bunch_it->capfc[0]);
74  bunch_it->sigfc[2][1] = (bunch_it->prodfc[2][1]/(bunch_it->num[2][1]))-(bunch_it->capfc[2]*bunch_it->capfc[1]);
75  bunch_it->sigfc[3][0] = (bunch_it->prodfc[3][0]/(bunch_it->num[3][0]))-(bunch_it->capfc[3]*bunch_it->capfc[0]);
76  bunch_it->sigfc[3][1] = (bunch_it->prodfc[3][1]/(bunch_it->num[3][1]))-(bunch_it->capfc[3]*bunch_it->capfc[1]);
77  bunch_it->sigfc[3][2] = (bunch_it->prodfc[3][2]/(bunch_it->num[3][2]))-(bunch_it->capfc[3]*bunch_it->capfc[2]);
78 
79  for(int i = 0; i != 4; i++){
80  for(int j = 0; j != 4; j++){
81  bunch_it->covarhistADC->Fill(i,j,bunch_it->sig[i][j]);
82  bunch_it->covarhistfC->Fill(i,j,bunch_it->sigfc[i][j]);
83  }
84  }
85 
86  if(bunch_it->detid.subdet() == 1){
87  theFile->cd("HB");
88  bunch_it->covarhistADC->Write();
89  bunch_it->covarhistfC->Write();
90  for(int i = 0; i != 4; i++){
91  bunch_it->hist[i]->Write();
92  HBMeans->Fill(bunch_it->cap[i]);
93  HBWidths->Fill(sqrt(bunch_it->sig[i][i]));
94  }
95  }
96  if(bunch_it->detid.subdet() == 2){
97  theFile->cd("HE");
98  bunch_it->covarhistADC->Write();
99  bunch_it->covarhistfC->Write();
100  for(int i = 0; i != 4; i++){
101  bunch_it->hist[i]->Write();
102  HEMeans->Fill(bunch_it->cap[i]);
103  HEWidths->Fill(sqrt(bunch_it->sig[i][i]));
104  }
105  }
106  if(bunch_it->detid.subdet() == 3){
107  theFile->cd("HO");
108  bunch_it->covarhistADC->Write();
109  bunch_it->covarhistfC->Write();
110  for(int i = 0; i != 4; i++){
111  bunch_it->hist[i]->Write();
112  HOMeans->Fill(bunch_it->cap[i]);
113  HOWidths->Fill(sqrt(bunch_it->sig[i][i]));
114  }
115  }
116  if(bunch_it->detid.subdet() == 4){
117  theFile->cd("HF");
118  bunch_it->covarhistADC->Write();
119  bunch_it->covarhistfC->Write();
120  for(int i = 0; i != 4; i++){
121  bunch_it->hist[i]->Write();
122  HFMeans->Fill(bunch_it->cap[i]);
123  HFWidths->Fill(sqrt(bunch_it->sig[i][i]));
124  }
125  }
126 
127  theFile->cd();
128 
129  const HcalPedestal item(bunch_it->detid, bunch_it->cap[0], bunch_it->cap[1], bunch_it->cap[2], bunch_it->cap[3]);
130  rawPedsItem->addValues(item);
131  HcalPedestalWidth widthsp(bunch_it->detid);
132  widthsp.setSigma(0,0,bunch_it->sig[0][0]);
133  widthsp.setSigma(0,1,bunch_it->sig[0][1]);
134  widthsp.setSigma(0,2,bunch_it->sig[0][2]);
135  widthsp.setSigma(0,3,bunch_it->sig[0][3]);
136  widthsp.setSigma(1,1,bunch_it->sig[1][1]);
137  widthsp.setSigma(1,2,bunch_it->sig[1][2]);
138  widthsp.setSigma(1,3,bunch_it->sig[1][3]);
139  widthsp.setSigma(2,2,bunch_it->sig[2][2]);
140  widthsp.setSigma(2,3,bunch_it->sig[2][3]);
141  widthsp.setSigma(3,3,bunch_it->sig[3][3]);
142  rawWidthsItem->addValues(widthsp);
143 
144  const HcalPedestal itemfc(bunch_it->detid, bunch_it->capfc[0], bunch_it->capfc[1],
145  bunch_it->capfc[2], bunch_it->capfc[3]);
146  rawPedsItemfc->addValues(itemfc);
147  HcalPedestalWidth widthspfc(bunch_it->detid);
148  widthspfc.setSigma(0,0,bunch_it->sigfc[0][0]);
149  widthspfc.setSigma(0,1,bunch_it->sigfc[0][1]);
150  widthspfc.setSigma(0,2,bunch_it->sigfc[0][2]);
151  widthspfc.setSigma(0,3,bunch_it->sigfc[0][3]);
152  widthspfc.setSigma(1,1,bunch_it->sigfc[1][1]);
153  widthspfc.setSigma(1,2,bunch_it->sigfc[1][2]);
154  widthspfc.setSigma(1,3,bunch_it->sigfc[1][3]);
155  widthspfc.setSigma(2,2,bunch_it->sigfc[2][2]);
156  widthspfc.setSigma(2,3,bunch_it->sigfc[2][3]);
157  widthspfc.setSigma(3,3,bunch_it->sigfc[3][3]);
158  rawWidthsItemfc->addValues(widthspfc);
159  }
160  }
161 
162  // dump the resulting list of pedestals into a file
163  std::ofstream outStream1(pedsADCfilename.c_str());
164  HcalDbASCIIIO::dumpObject (outStream1, (*rawPedsItem) );
165  std::ofstream outStream2(widthsADCfilename.c_str());
166  HcalDbASCIIIO::dumpObject (outStream2, (*rawWidthsItem) );
167 
168  std::ofstream outStream3(pedsfCfilename.c_str());
169  HcalDbASCIIIO::dumpObject (outStream3, (*rawPedsItemfc) );
170  std::ofstream outStream4(widthsfCfilename.c_str());
171  HcalDbASCIIIO::dumpObject (outStream4, (*rawWidthsItemfc) );
172 
173  theFile->cd();
174  theFile->cd("HB");
175  HBMeans->Write();
176  HBWidths->Write();
177  theFile->cd();
178  theFile->cd("HF");
179  HFMeans->Write();
180  HFWidths->Write();
181  theFile->cd();
182  theFile->cd("HE");
183  HEMeans->Write();
184  HEWidths->Write();
185  theFile->cd();
186  theFile->cd("HO");
187  HOMeans->Write();
188  HOWidths->Write();
189 
190  std::cout << "Writing ROOT file... ";
191  theFile->Close();
192  std::cout << "ROOT file closed.\n";
193 
194  delete rawPedsItem;
195  delete rawWidthsItem;
196  delete rawPedsItemfc;
197  delete rawWidthsItemfc;
198 }
199 
200 // ------------ method called to for each event ------------
201 void
203 {
204 
208  edm::ESHandle<HcalDbService> conditions;
209  iSetup.get<HcalDbRecord>().get(conditions);
210 
211  const HcalQIEShape* shape = conditions->getHcalShape();
212 
213  if(firsttime)
214  {
215  runnum = e.id().run();
216  std::string runnum_string;
217  std::stringstream tempstringout;
218  tempstringout << runnum;
219  runnum_string = tempstringout.str();
220  ROOTfilename = runnum_string + "-val_peds_ADC.root";
221  pedsADCfilename = runnum_string + "-val_peds_ADC.txt";
222  pedsfCfilename = runnum_string + "-val_peds_fC.txt";
223  widthsADCfilename = runnum_string + "-val_widths_ADC.txt";
224  widthsfCfilename = runnum_string + "-val_widths_fC.txt";
225 
226  theFile = new TFile(ROOTfilename.c_str(), "RECREATE");
227  theFile->cd();
228  // Create sub-directories
229  theFile->mkdir("HB");
230  theFile->mkdir("HE");
231  theFile->mkdir("HF");
232  theFile->mkdir("HO");
233  theFile->cd();
234 
235  HBMeans = new TH1F("All Ped Means HB","All Ped Means HB", 100, 0, 9);
236  HBWidths = new TH1F("All Ped Widths HB","All Ped Widths HB", 100, 0, 3);
237  HEMeans = new TH1F("All Ped Means HE","All Ped Means HE", 100, 0, 9);
238  HEWidths = new TH1F("All Ped Widths HE","All Ped Widths HE", 100, 0, 3);
239  HFMeans = new TH1F("All Ped Means HF","All Ped Means HF", 100, 0, 9);
240  HFWidths = new TH1F("All Ped Widths HF","All Ped Widths HF", 100, 0, 3);
241  HOMeans = new TH1F("All Ped Means HO","All Ped Means HO", 100, 0, 9);
242  HOWidths = new TH1F("All Ped Widths HO","All Ped Widths HO", 100, 0, 3);
243 
245  iSetup.get<HcalElectronicsMapRcd>().get(refEMap);
246  const HcalElectronicsMap* myRefEMap = refEMap.product();
247  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
248  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++)
249  {
250  HcalGenericDetId mygenid(it->rawId());
251  if(mygenid.isHcalDetId())
252  {
254  HcalDetId chanid(mygenid.rawId());
255  a.detid = chanid;
256  a.usedflag = false;
257  std::ostringstream s1;
258  s1 << mygenid;
259  std::string histname = s1.str();
260  histname += " Covariance Matrix";
261  a.covarhistADC = new TH2F(histname.c_str(), histname.c_str(), 4, -.5, 3.5, 4, -.5, 3.5);
262  a.covarhistADC->SetOption("TEXT");
263  a.covarhistADC->SetStats(0);
264  histname += " fC";
265  a.covarhistfC = new TH2F(histname.c_str(), histname.c_str(), 4, -.5, 3.5, 4, -.5, 3.5);
266  a.covarhistfC->SetOption("TEXT");
267  a.covarhistfC->SetStats(0);
268  for(int i = 0; i != 4; i++)
269  {
270  a.cap[i] = 0;
271  a.capfc[i] = 0;
272  std::ostringstream s3;
273  s3 << mygenid;
274  std::string histname = s3.str() + " Cap ";
275  std::ostringstream s4;
276  s4 << i;
277  histname += s4.str();
278  std::ostringstream s5;
279  s5 << std::hex << (mygenid.rawId()) << std::dec;
280  std::string histnamedetid = s5.str();
281  a.hist[i] = new TH1F(histname.c_str(), histnamedetid.c_str(), 16, -.5, 15.5);
282  for(int j = 0; j != 4; j++)
283  {
284  a.sig[i][j] = 0;
285  a.sigfc[i][j] = 0;
286  a.prod[i][j] = 0;
287  a.prodfc[i][j] = 0;
288  a.num[i][j] = 0;
289  }
290  }
291  BunchVales.push_back(a);
292 // theFile->cd();
293  }
294  }
295  firsttime = false;
296  }
297 
298  std::vector<NewPedBunchVal>::iterator bunch_it;
299 
300  for(HBHEDigiCollection::const_iterator j = hbhe->begin(); j != hbhe->end(); j++)
301  {
302  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
303  for(bunch_it = BunchVales.begin(); bunch_it != BunchVales.end(); bunch_it++)
304  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
305  bunch_it->usedflag = true;
306  for(int ts = firstTS; ts != lastTS+1; ts++)
307  {
308  if(digi.sample(ts).adc() > 15) continue;
309  bunch_it->hist[digi.sample(ts).capid()]->Fill(digi.sample(ts).adc());
310  const HcalQIECoder* coder = conditions->getHcalCoder(digi.id().rawId());
311  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
312  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
313  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
314  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
315  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] += (digi.sample(ts).adc() * digi.sample(ts).adc());
316  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
317  if((ts+1 < digi.size()) && (ts+1 < lastTS)){
318  if(digi.sample(ts+1).adc() > 15) continue;
319  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += digi.sample(ts).adc()*digi.sample(ts+1).adc();
320  double charge2 = coder->charge(*shape, digi.sample(ts+1).adc(), digi.sample(ts+1).capid());
321  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += charge1*charge2;
322  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += 1;
323  }
324  if((ts+2 < digi.size()) && (ts+2 < lastTS)){
325  if(digi.sample(ts+2).adc() > 15) continue;
326  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += digi.sample(ts).adc()*digi.sample(ts+2).adc();
327  double charge2 = coder->charge(*shape, digi.sample(ts+2).adc(), digi.sample(ts+2).capid());
328  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += charge1*charge2;
329  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += 1;
330  }
331  if((ts+3 < digi.size()) && (ts+3 < lastTS)){
332  if(digi.sample(ts+3).adc() > 15) continue;
333  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += digi.sample(ts).adc()*digi.sample(ts+3).adc();
334  double charge2 = coder->charge(*shape, digi.sample(ts+3).adc(), digi.sample(ts+3).capid());
335  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += charge1*charge2;
336  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += 1;
337  }
338  }
339  }
340 
341  for(HODigiCollection::const_iterator j = ho->begin(); j != ho->end(); j++)
342  {
343  const HODataFrame digi = (const HODataFrame)(*j);
344  for(bunch_it = BunchVales.begin(); bunch_it != BunchVales.end(); bunch_it++)
345  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
346  bunch_it->usedflag = true;
347  for(int ts = firstTS; ts <= lastTS; ts++)
348  {
349  if(digi.sample(ts).adc() > 15) continue;
350  bunch_it->hist[digi.sample(ts).capid()]->Fill(digi.sample(ts).adc());
351  const HcalQIECoder* coder = conditions->getHcalCoder(digi.id().rawId());
352  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
353  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
354  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
355  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
356  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] += (digi.sample(ts).adc() * digi.sample(ts).adc());
357  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
358  if((ts+1 < digi.size()) && (ts+1 < lastTS)){
359  if(digi.sample(ts+1).adc() > 15) continue;
360  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += digi.sample(ts).adc()*digi.sample(ts+1).adc();
361  double charge2 = coder->charge(*shape, digi.sample(ts+1).adc(), digi.sample(ts+1).capid());
362  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += charge1*charge2;
363  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += 1;
364  }
365  if((ts+2 < digi.size()) && (ts+2 < lastTS)){
366  if(digi.sample(ts+2).adc() > 15) continue;
367  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += digi.sample(ts).adc()*digi.sample(ts+2).adc();
368  double charge2 = coder->charge(*shape, digi.sample(ts+2).adc(), digi.sample(ts+2).capid());
369  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += charge1*charge2;
370  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += 1;
371  }
372  if((ts+3 < digi.size()) && (ts+3 < lastTS)){
373  if(digi.sample(ts+3).adc() > 15) continue;
374  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += digi.sample(ts).adc()*digi.sample(ts+3).adc();
375  double charge2 = coder->charge(*shape, digi.sample(ts+3).adc(), digi.sample(ts+3).capid());
376  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += charge1*charge2;
377  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += 1;
378  }
379  }
380  }
381 
382  for(HFDigiCollection::const_iterator j = hf->begin(); j != hf->end(); j++)
383  {
384  const HFDataFrame digi = (const HFDataFrame)(*j);
385  for(bunch_it = BunchVales.begin(); bunch_it != BunchVales.end(); bunch_it++)
386  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
387  bunch_it->usedflag = true;
388  for(int ts = firstTS; ts <= lastTS; ts++)
389  {
390  if(digi.sample(ts).adc() > 15) continue;
391  bunch_it->hist[digi.sample(ts).capid()]->Fill(digi.sample(ts).adc());
392  const HcalQIECoder* coder = conditions->getHcalCoder(digi.id().rawId());
393  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
394  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
395  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
396  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
397  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] += (digi.sample(ts).adc() * digi.sample(ts).adc());
398  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
399  if((ts+1 < digi.size()) && (ts+1 < lastTS)){
400  if(digi.sample(ts+1).adc() > 15) continue;
401  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += digi.sample(ts).adc()*digi.sample(ts+1).adc();
402  double charge2 = coder->charge(*shape, digi.sample(ts+1).adc(), digi.sample(ts+1).capid());
403  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += charge1*charge2;
404  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+1).capid()] += 1;
405  }
406  if((ts+2 < digi.size()) && (ts+2 < lastTS)){
407  if(digi.sample(ts+2).adc() > 15) continue;
408  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += digi.sample(ts).adc()*digi.sample(ts+2).adc();
409  double charge2 = coder->charge(*shape, digi.sample(ts+2).adc(), digi.sample(ts+2).capid());
410  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += charge1*charge2;
411  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+2).capid()] += 1;
412  }
413  if((ts+3 < digi.size()) && (ts+3 < lastTS)){
414  if(digi.sample(ts+3).adc() > 15) continue;
415  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += digi.sample(ts).adc()*digi.sample(ts+3).adc();
416  double charge2 = coder->charge(*shape, digi.sample(ts+3).adc(), digi.sample(ts+3).capid());
417  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += charge1*charge2;
418  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts+3).capid()] += 1;
419  }
420  }
421  }
422 
423 //this is the last brace
424 }
425 
426 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
bool addValues(const Item &myItem, bool h2mode_=false)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
std::vector< T >::const_iterator const_iterator
bool getByType(Handle< PROD > &result) const
Definition: Event.h:403
const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:40
const HcalDetId & id() const
Definition: HODataFrame.h:23
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
T sqrt(T t)
Definition: SSEVec.h:28
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
const HcalQIESample & sample(int i) const
access a sample
Definition: HFDataFrame.h:39
int j
Definition: DBlmapReader.cc:9
std::vector< HcalGenericDetId > allPrecisionId() const
std::vector< NewPedBunchVal > BunchVales
HcalPedestalWidthsValidation(const edm::ParameterSet &ps)
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:28
const HcalQIESample & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
edm::EventID id() const
Definition: EventBase.h:56
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
double a
Definition: hdecay.h:121
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
tuple cout
Definition: gather_cfg.py:41
const HcalDetId & id() const
Definition: HFDataFrame.h:22
void setSigma(int fCapId1, int fCapId2, float fSigma)
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22