CMS 3D CMS Logo

EcalDccWeightBuilder.cc
Go to the documentation of this file.
1 /*
2  *
3  * authors: Ph. Gras (CEA/Saclay), F. Cavallari (INFN/Roma)
4  * some code copied from CalibCalorimetry/EcalTPGTools code
5  * written by P. Paganini and F. Cavallari
6  */
7 
8 #define DB_WRITE_SUPPORT
9 
11 
12 #include <limits>
13 #include <algorithm>
14 #include <fstream>
15 #include <iomanip>
16 #include <TFile.h>
17 #include <TTree.h>
18 
25 
29 
30 #ifdef DB_WRITE_SUPPORT
33 #endif //DB_WRITE_SUPPORT defined
34 
36 
37 using namespace std;
38 using namespace edm;
39 
40 const double EcalDccWeightBuilder::weightScale_ = 1024.;
41 
42 
43 //TODO: handling case of weight encoding saturation: weights shall be downscaled to prevent saturation
44 
46  dcc1stSample_(ps.getParameter<int>("dcc1stSample")),
47  sampleToSkip_(ps.getParameter<int>("sampleToSkip")),
48  nDccWeights_(ps.getParameter<int>("nDccWeights")),
49  inputWeights_(ps.getParameter<vector<double> >("inputWeights")),
50  mode_(ps.getParameter<string>("mode")),
51  dccWeightsWithIntercalib_(ps.getParameter<bool>("dccWeightsWithIntercalib")),
52  writeToDB_(ps.getParameter<bool>("writeToDB")),
53  writeToAsciiFile_(ps.getParameter<bool>("writeToAsciiFile")),
54  writeToRootFile_(ps.getParameter<bool>("writeToRootFile")),
55  asciiOutputFileName_(ps.getParameter<string>("asciiOutputFileName")),
56  rootOutputFileName_(ps.getParameter<string>("rootOutputFileName")),
57  dbSid_(ps.getParameter<string>("dbSid")),
58  dbUser_(ps.getParameter<string>("dbUser")),
59  dbPassword_(ps.getUntrackedParameter<string>("dbPassword","")),
60  dbTag_(ps.getParameter<string>("dbTag")),
61  dbVersion_(ps.getParameter<int>("dbVersion")),
62  sqlMode_(ps.getParameter<bool>("sqlMode")),
63  calibMap_(emptyCalibMap_)
64 {
65  if(mode_=="weightsFromConfig"){
67  if(inputWeights_.size()!=(unsigned)nDccWeights_){
68  throw cms::Exception("Config")
69  << "Inconsistent configuration. 'nDccWeights' parameters indicated "
70  << nDccWeights_ << " weights while parameter 'inputWeights_' contains "
71  << inputWeights_.size() << " weight values!\n";
72  }
73  } else if(mode_=="computeWeights"){
75  } else{
76  throw cms::Exception("Config")
77  << "Invalid value ('" << mode_ << "') for parameter mode. "
78  << "Valid values are: 'weightsFromConfig' and 'computeWeights'\n";
79  }
80 }
81 
82 
83 void
85  const edm::EventSetup& es){
86 
88  es.get<EcalMappingRcd>().get(handle);
89  ecalElectronicsMap_ = handle.product();
90 
91  // Retrieval of intercalib constants
94  es.get<EcalIntercalibConstantsRcd>().get(hIntercalib) ;
95  const EcalIntercalibConstants* intercalib = hIntercalib.product();
96  calibMap_ = intercalib->getMap();
97  }
98 
99  //gets geometry
100  es.get<CaloGeometryRecord>().get(geom_);
101 
102 
103  //computes the weights:
105 
106  //Writing out weights.
110 }
111 
112 void EcalDccWeightBuilder::computeAllWeights(bool withIntercalib, const edm::EventSetup& es){
113  const int nw = nDccWeights_;
114  int iSkip0_ = sampleToSkip_>=0?(sampleToSkip_-dcc1stSample_):-1;
115 
116  EcalSimParameterMap parameterMap;
117  const vector<DetId>& ebDetIds
119 
120  // cout << __FILE__ << ":" << __LINE__ << ": "
121  // << "Number of EB det IDs: " << ebDetIds.size() << "\n";
122 
123  const vector<DetId>& eeDetIds
125 
126  // cout << __FILE__ << ":" << __LINE__ << ": "
127  // << "Number of EE det IDs: " << eeDetIds.size() << "\n";
128 
129 
130  vector<DetId> detIds(ebDetIds.size()+eeDetIds.size());
131  copy(ebDetIds.begin(), ebDetIds.end(), detIds.begin());
132  copy(eeDetIds.begin(), eeDetIds.end(), detIds.begin()+ebDetIds.size());
133 
134  vector<double> baseWeights(nw); //weight obtained from signal shape
135  vector<double> w(nw); //weight*intercalib
136  vector<int> W(nw); //weight in hw encoding (integrer)
137  double prevPhase = numeric_limits<double>::min();
138 
139 
141  assert(inputWeights_.size()==baseWeights.size());
142  copy(inputWeights_.begin(), inputWeights_.end(), baseWeights.begin());
143  }
144 
145  for(vector<DetId>::const_iterator it = detIds.begin();
146  it != detIds.end(); ++it){
147 
148  double phase = parameterMap.simParameters(*it).timePhase();
149  int binOfMax = parameterMap.simParameters(*it).binOfMaximum();
150 
151 #if 0
152  //for debugging...
153  cout << __FILE__ << ":" << __LINE__ << ": ";
154  if(it->subdetId()==EcalBarrel){
155  cout << "ieta = " << setw(4) << ((EBDetId)(*it)).ieta()
156  << " iphi = " << setw(4) << ((EBDetId)(*it)).iphi() << " ";
157  } else if(it->subdetId()==EcalEndcap){
158  cout << "ix = " << setw(3) << ((EEDetId)(*it)).ix()
159  << " iy = " << setw(3) << ((EEDetId)(*it)).iy()
160  << " iz = " << setw(1) << ((EEDetId)(*it)).iy() << " ";
161  } else{
162  throw cms::Exception("EcalDccWeightBuilder")
163  << "Bug found in " << __FILE__ << ":" << __LINE__ << ": "
164  << "Got a detId which is neither tagged as ECAL Barrel "
165  << "not ECAL endcap while looping on ECAL cell detIds\n";
166  }
167  cout << " -> phase: " << phase << "\n";
168  cout << " -> binOfMax: " << binOfMax << "\n";
169 #endif
170 
171  try{
172  bool useDBShape = true;
173  EBShape ebShape(useDBShape);
174  EEShape eeShape(useDBShape);
175  EcalShapeBase* pShape;
176 
177  if(it->subdetId()==EcalBarrel){
178  pShape = &ebShape;
179  } else if(it->subdetId()==EcalEndcap){
180  pShape = &eeShape;
181  } else{
182  throw cms::Exception("EcalDccWeightBuilder")
183  << "Bug found in " << __FILE__ << ":" << __LINE__ << ": "
184  << "Got a detId which is neither tagged as ECAL Barrel "
185  << "not ECAL endcap while looping on ECAL cell detIds\n";
186  }
187 
188  if(phase!=prevPhase){
189  if(imode_==COMPUTE_WEIGHTS){
190  if(it->subdetId()==EcalBarrel){
191  computeWeights(*pShape, binOfMax, phase,
192  dcc1stSample_-1, nDccWeights_, iSkip0_,
193  baseWeights);
194  }
195  prevPhase = phase;
196  }
197  }
198  for(int i = 0; i < nw; ++i){
199  w[i] = baseWeights[i];
200  if(withIntercalib) w[i]*= intercalib(*it);
201  }
202  unbiasWeights(w, &W);
203  encodedWeights_[*it] = W;
204  } catch(std::exception& e){
205  cout << __FILE__ << ":" << __LINE__ << ": ";
206  if(it->subdetId()==EcalBarrel){
207  cout << "ieta = " << setw(4) << ((EBDetId)(*it)).ieta()
208  << " iphi = " << setw(4) << ((EBDetId)(*it)).iphi() << " ";
209  } else if(it->subdetId()==EcalEndcap){
210  cout << "ix = " << setw(3) << ((EEDetId)(*it)).ix()
211  << " iy = " << setw(3) << ((EEDetId)(*it)).iy()
212  << " iz = " << setw(1) << ((EEDetId)(*it)).iy() << " ";
213  } else{
214  cout << "DetId " << (uint32_t) (*it);
215  }
216  cout << "phase: " << phase << "\n";
217  throw;
218  }
219  }
220 }
221 
222 void
224  int binOfMax,
225  double timePhase,
226  int iFirst,
227  int nWeights, int iSkip,
228  vector<double>& result){
229  double sum2 = 0.;
230  double sum = 0;
231  result.resize(nWeights);
232 
233  int nActualWeights = 0;
234 
235  const double tzero = -(binOfMax-1)*25+timePhase + shape.timeToRise();//ns
236 
237  for(int i=0; i<nWeights; ++i){
238  double t_ns = tzero+(iFirst+i)*25;
239  double s = shape(t_ns);
240  if(i==iSkip){
241  continue;
242  }
243  result[i] = s;
244  sum += s;
245  sum2 += s*s;
246  ++nActualWeights;
247  }
248  for(int i=0; i<nWeights; ++i){
249  if(i==iSkip){
250  result[i] = 0;
251  } else{
252  result[i] = (result[i]-sum/nActualWeights)/(sum2-sum*sum/nActualWeights);
253  }
254  }
255 }
256 
258  return lround(w * weightScale_);
259 }
260 
262  return ((double) W) / weightScale_;
263 }
264 
265 
266 template<class T>
267 void EcalDccWeightBuilder::sort(const std::vector<T>& a,
268  std::vector<int>& s,
269  bool decreasingOrder){
270  // cout << __FILE__ << ":" << __LINE__ << ": "
271  // << "sort input array:" ;
272  // for(unsigned i=0; i<a.size(); ++i){
273  // cout << "\t" << a[i];
274  // }
275  // cout << "\n";
276 
277  //performs a bubble sort: adjacent elements are successively swapped 2 by 2
278  //until the list is finally sorted.
279  bool changed = false;
280  s.resize(a.size());
281  for(unsigned i=0; i<a.size(); ++i) s[i] = i;
282  if(a.empty()) return;
283  do {
284  changed = false;
285  for(unsigned i = 0; i < a.size()-1; ++i){
286  const int j = s[i];
287  const int nextj = s[i+1];
288  if((decreasingOrder && (a[j] < a[nextj]))
289  || (!decreasingOrder && (a[j] > a[nextj]))){
290  std::swap(s[i], s[i+1]);
291  changed = true;
292  }
293  }
294  } while(changed);
295 
296  // cout << __FILE__ << ":" << __LINE__ << ": "
297  // << "sorted list of indices:" ;
298  // for(unsigned i=0; i < s.size(); ++i){
299  // cout << "\t" << s[i];
300  // }
301  // cout << "\n";
302 }
303 
305  std::vector<int>* encodedWeights){
306  const unsigned nw = weights.size();
307 
308  //computes integer weights, weights residuals and weight sum residual:
309  vector<double> dw(nw); //weight residuals due to interger encoding
310  vector<int> W(nw); //integer weights
311  int wsum = 0;
312  for(unsigned i = 0; i < nw; ++i){
313  W[i] = encodeWeight(weights[i]);
314  dw[i] = decodeWeight(W[i]) - weights[i];
315  wsum += W[i];
316  }
317 
318 // cout << __FILE__ << ":" << __LINE__ << ": "
319 // << "weights before bias correction: ";
320 // for(unsigned i=0; i<weights.size(); ++i){
321 // const double w = weights[i];
322 // cout << "\t" << encodeWeight(w) << "(" << w << ", dw = " << dw[i] << ")";
323 // }
324 // cout << "\t sum: " << wsum << "\n";
325 
326  //sorts weight residuals in decreasing order:
327  vector<int> iw(nw);
328  sort(dw, iw, true);
329 
330  //compensates weight sum residual by adding or substracting 1 to weights
331  //starting from:
332  // 1) the weight with the minimal signed residual if the correction
333  // is positive (wsum<0)
334  // 2) the weight with the maximal signed residual if the correction
335  // is negative (wsum>0)
336  int wsumSign = wsum>0?1:-1;
337  int i = wsum>0?0:(nw-1);
338  while(wsum!=0){
339  W[iw[i]] -= wsumSign;
340  wsum -= wsumSign;
341  i += wsumSign;
342  if(i<0 || i>=(int)nw){ //recompute the residuals if a second iteration is
343  // needed (in principle, it is not expected with usual input weights), :
344  for(unsigned i = 0; i < nw; ++i){
345  dw[i] = decodeWeight(W[i]) - weights[i];
346  sort(dw, iw, true);
347  }
348  }
349  if(i<0) i = nw-1;
350  if(i>=(int)nw) i = 0;
351  }
352 
353 // cout << __FILE__ << ":" << __LINE__ << ": "
354 // << "weights after bias correction: ";
355 // for(unsigned i=0; i<weights.size(); ++i){
356 // cout << "\t" << W[i] << "(" << decodeWeight(W[i]) << ", dw = "
357 // << (decodeWeight(W[i])-weights[i]) << ")";
358 // }
359 // cout << "\n";
360 
361  //copy result
362  if(encodedWeights!=nullptr) encodedWeights->resize(nw);
363  for(unsigned i = 0; i < nw; ++i){
364  weights[i] = decodeWeight(W[i]);
365  if(encodedWeights) (*encodedWeights)[i] = W[i];
366  }
367 }
368 
370  // get current intercalibration coeff
371  double coef;
373  = calibMap_.find(detId.rawId());
374  if(itCalib != calibMap_.end()){
375  coef = (*itCalib);
376  } else{
377  coef = 1.;
378  std::cout << (uint32_t) detId
379  << " not found in EcalIntercalibConstantMap"<<std::endl ;
380  }
381 #if 0
382  cout << __FILE__ << ":" << __LINE__ << ": ";
383  if(detId.subdetId()==EcalBarrel){
384  cout << "ieta = " << ((EBDetId)detId).ieta()
385  << " iphi = " << ((EBDetId)detId).iphi();
386  } else{
387  cout << "ix = " << ((EEDetId)detId).ix()
388  << " iy = " << ((EEDetId)detId).iy()
389  << " iz = " << ((EEDetId)detId).zside();
390  }
391  cout << " coef = " << coef << "\n";
392 #endif
393  return coef;
394 }
395 
397  string fName = !asciiOutputFileName_.empty()?
398  asciiOutputFileName_.c_str()
399  :"dccWeights.txt";
400  ofstream file(fName.c_str());
401  if(!file.good()){
402  throw cms::Exception("Output")
403  << "Failed to open file '"
404  << fName
405  << "'for writing DCC weights\n";
406  }
407 
408  const char* comment = sqlMode_?"-- ":"# ";
409 
410  file << comment << "List of weights for amplitude estimation to be used in DCC for\n"
411  << comment << "zero suppresssion.\n\n";
412  if(!sqlMode_){
413  file << comment << "Note: RU: trigger tower in EB, supercrystal in EE\n"
414  << comment << " xtl: crystal electronic channel id in RU, from 1 to 25\n\n"
415  << comment << " DetId SM FED RU xtl weights[0..5]...\n";
416  }
417 
418  if(sqlMode_){
419  file << "variable recid number;\n"
420  "exec select COND2CONF_INFO_SQ.NextVal into :recid from DUAL;\n"
421  "insert into weights_info (rec_id,tag,version) values (:recid,'"
422  << dbTag_ << "'," << dbVersion_ << ");\n";
423  file << "\n" << comment
424  << "index of first sample used in the weighting sum\n"
425  "begin\n"
426  " for fedid in " << ecalDccFedIdMin << ".." << ecalDccFedIdMax
427  << " loop\n"
428  " insert into dcc_weightsample_dat (rec_id, logic_id, sample_id, \n"
429  " weight_number)\n"
430  " values(:recid,fedid," << dcc1stSample_ << ",1);\n"
431  " end loop;\n"
432  "end;\n"
433  "/\n";
434  } else{
435  file << "1st DCC sample: " << dcc1stSample_ << "\n";
436  }
437 
438  file << "\n" << comment << "list of weights per crystal channel\n";
439 
440  for(map<DetId, std::vector<int32_t> >::const_iterator it
441  = encodedWeights_.begin();
442  it != encodedWeights_.end();
443  ++it){
444  const DetId& detId = it->first;
445 
446  int fedId;
447  int smId;
448  int ruId;
449  int xtalId;
450 
451  //detId -> fedId, smId, ruId, xtalId
452  dbId(detId, fedId, smId, ruId, xtalId);
453 
454  char delim = sqlMode_?',':' ';
455 
456  if(sqlMode_) file << "-- detId " << detId.rawId() << "\n"
457  << "insert into dcc_weights_dat(rec_id,sm_id,fed_id,"
458  "tt_id, cry_id,\n"
459  "weight_0,weight_1,weight_2,weight_3,weight_4,weight_5) \n"
460  "values ("
461  ":recid";
462 
463  const vector<int>& weights = it->second;
464  if(!sqlMode_) file << setw(10) << detId.rawId();
465  file << delim << setw(2) << smId;
466  file << delim << setw(3) << fedId;
467  file << delim << setw(2) << ruId;
468  file << delim << setw(2) << xtalId;
469 
470  for(unsigned i=0; i<weights.size(); ++i){
471  file << delim << setw(5) << weights[i];
472  }
473  if(sqlMode_) file << ");";
474  file << "\n";
475  }
476  if(!file.good()){
477  throw cms::Exception("Output") << "Error while writing DCC weights to '"
478  << fName << "' file.";
479  }
480 }
482  string fName = !rootOutputFileName_.empty()?
483  rootOutputFileName_.c_str()
484  :"dccWeights.root";
485  TFile file(fName.c_str(), "RECREATE");
486  if(file.IsZombie()){
487  throw cms::Exception("Output")
488  << "Failed to open file '"
489  << fName
490  << "'for writing DCC weights\n";
491  }
492  TTree t("dccWeights", "Weights for DCC ZS filter");
493  const int nWeightMax = 20; //normally n_weights = 6. A different might be used
494  // used for test purposes.
495  struct {
496  Int_t detId;
497  Int_t fedId;
498  Int_t smId;
499  Int_t ruId;
500  Int_t xtalId;
501  Int_t n_weights;
502  Int_t weights[nWeightMax];
503  } buf;
504  t.Branch("weights", &buf,
505  "rawDetId/I:"
506  "feId/I:"
507  "smSlotId/I:"
508  "ruId/I:"
509  "xtalInRuId/I:"
510  "n_weights/I:"
511  "weights[n_weights]/I");
512  for(map<DetId, std::vector<int32_t> >::const_iterator it
513  = encodedWeights_.begin();
514  it != encodedWeights_.end();
515  ++it){
516  buf.detId = it->first.rawId();
517  buf.n_weights = it->second.size();
518 
519  //detId -> fedId, smId, ruId, xtalId
520  dbId(buf.detId, buf.fedId, buf.smId, buf.ruId, buf.xtalId);
521 
522  if(buf.n_weights>nWeightMax){
523  throw cms::Exception("EcalDccWeight")
524  << "Number of weights (" << buf.n_weights
525  << ") for DetId " << buf.detId
526  << " exceeded maximum limit (" << nWeightMax
527  << ") of root output format. ";
528  }
529  copy(it->second.begin(), it->second.end(), buf.weights);
530  t.Fill();
531  }
532  t.Write();
533  file.Close();
534 }
535 
536 #ifndef DB_WRITE_SUPPORT
538  throw cms::Exception("DccWeight")
539  << "Code was compiled without support for writing dcc weights directly "
540  " into configuration DB. Configurable writeToDB must be set to False. "
541  "sqlMode can be used to produce an SQL*PLUS script to fill the DB\n";
542 }
543 #else //DB_WRITE_SUPPORT defined
545  cout << "going to write to the online DB "<<dbSid_<<" user "<<dbUser_<<endl;;
546  EcalCondDBInterface* econn;
547 
548  try {
549  cout << "Making connection..." << flush;
550  const string& filePrefix = string("file:");
551  if(dbPassword_.find(filePrefix)==0){ //password must be read for a file
552  string fileName = dbPassword_.substr(filePrefix.size());
553  //substitute dbPassword_ value by the password read from the file
555  pr.readPassword(fileName, dbUser_, dbPassword_);
556  }
557 
558  // cout << __FILE__ << ":" << __LINE__ << ": "
559  // << "Password: " << dbPassword_ << "\n";
560 
562  cout << "Done." << endl;
563  } catch (runtime_error &e) {
564  cerr << e.what() << endl;
565  exit(-1);
566  }
567 
568  ODFEWeightsInfo weight_info;
569  weight_info.setConfigTag(dbTag_);
570  weight_info.setVersion(dbVersion_);
571  cout << "Inserting in DB..." << endl;
572 
573  econn->insertConfigSet(&weight_info);
574 
575  int weight_id=weight_info.getId();
576  cout << "WeightInfo inserted with ID "<< weight_id<< endl;
577 
578  vector<ODWeightsDat> datadel;
579  datadel.reserve(encodedWeights_.size());
580 
581  vector<ODWeightsSamplesDat> dcc1stSampleConfig(nDccs);
582  for(int i = ecalDccFedIdMin; i <= ecalDccFedIdMax; ++i){
583  dcc1stSampleConfig[i].setId(weight_id);
584  dcc1stSampleConfig[i].setFedId(601+i);
585  dcc1stSampleConfig[i].setSampleId(dcc1stSample_);
586  dcc1stSampleConfig[i].setWeightNumber(-1); //not used.
587  }
588  econn->insertConfigDataArraySet(dcc1stSampleConfig, &weight_info);
589 
590  for(map<DetId, std::vector<int32_t> >::const_iterator it
591  = encodedWeights_.begin();
592  it != encodedWeights_.end();
593  ++it){
594  const DetId& detId = it->first;
595  const unsigned nWeights = 6;
596  vector<int> weights(nWeights);
597 
598  for(unsigned i=0; i<weights.size(); ++i){
599  //completing the weight vector with zeros in case it has
600  //less than 6 elements:
601  const vector<int>& w = it->second;
602  weights[i] = i<w.size()?w[i]:0;
603  }
604 
605  ODWeightsDat one_dat;
606  one_dat.setId(weight_id);
607 
608  int fedId;
609  int smId;
610  int ruId;
611  int xtalId;
612 
613  //detId -> fedId, smId, ruId, xtalId
614  dbId(detId, fedId, smId, ruId, xtalId);
615 
616  one_dat.setSMId(smId);
617  one_dat.setFedId(fedId);
618  one_dat.setTTId(ruId);
619  one_dat.setCrystalId(xtalId);
620 
621  one_dat.setWeight0(weights[0]);
622  one_dat.setWeight1(weights[1]);
623  one_dat.setWeight2(weights[2]);
624  one_dat.setWeight3(weights[3]);
625  one_dat.setWeight4(weights[4]);
626  one_dat.setWeight5(weights[5]);
627 
628  datadel.push_back(one_dat);
629  }
630  econn->insertConfigDataArraySet(datadel,&weight_info);
631  std::cout<< " .. done insertion in DB "<< endl;
632  delete econn;
633  cout<< "closed DB connection ... done" << endl;
634 }
635 #endif //DB_WRITE_SUPPORT not defined
636 
637 
638 void EcalDccWeightBuilder::dbId(const DetId& detId, int& fedId, int& smId,
639  int& ruId,
640  int& xtalId) const{
641  const EcalElectronicsId& elecId
643 
644  fedId = 600 + elecId.dccId();
646 
647  if(detId.subdetId()==EcalBarrel) {
648  smId=((EBDetId)detId).ism();
649  } else{
650  smId = 10000-fedId; //no SM in EE. Use some unique value to satisfy
651  // current DB PK constraints.
652  }
653  const int stripLength = 5; //1 strip = 5 crystals in a row
654  xtalId = (elecId.stripId()-1)*stripLength + elecId.xtalId();
655 
656 #if 0
657  cout << __FILE__ << ":" << __LINE__ << ": FED ID "
658  << fedId << "\n";
659 
660  cout << __FILE__ << ":" << __LINE__ << ": SM logical ID "
661  << smId << "\n";
662 
663  cout << __FILE__ << ":" << __LINE__ << ": RU ID (TT or SC): "
664  << ruId << "\n";
665 
666  cout << __FILE__ << ":" << __LINE__ << ": strip:"
667  << elecId.stripId() << "\n";
668 
669  cout << __FILE__ << ":" << __LINE__ << ": xtal in strip: "
670  << elecId.xtalId() << "\n";
671 
672  cout << __FILE__ << ":" << __LINE__ << ": xtalId in RU: "
673  << xtalId << "\n";
674 #endif
675 }
void setId(int dac)
Definition: ODWeightsDat.h:21
void setWeight3(float x)
Definition: ODWeightsDat.h:39
void setWeight2(float x)
Definition: ODWeightsDat.h:38
int xtalId() const
get the channel id
const double w
Definition: UKUtility.cc:23
std::map< DetId, std::vector< int > > encodedWeights_
def copy(args, dbName)
void analyze(const edm::Event &event, const edm::EventSetup &es) override
int stripId() const
get the tower id
void setSMId(int dac)
Definition: ODWeightsDat.h:24
const self & getMap() const
double intercalib(const DetId &detId)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::vector< double > inputWeights_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
edm::ESHandle< CaloGeometry > geom_
static const double weightScale_
void dbId(const DetId &detId, int &fedId, int &smId, int &ruId, int &xtalId) const
int towerId() const
get the tower id
void setWeight4(float x)
Definition: ODWeightsDat.h:40
void computeWeights(const EcalShapeBase &shape, int binOfMax, double timePhase, int iFirst0, int nWeights, int iSkip0, std::vector< double > &result)
double timePhase() const
the adjustment you need to apply to get the signal where you want it
void setVersion(int id)
void sort(const std::vector< T > &a, std::vector< int > &s, bool decreasingOrder=false)
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
void setWeight1(float x)
Definition: ODWeightsDat.h:37
void insertConfigDataArraySet(const std::vector< DATT > &data, ICONF *iconf) noexcept(false)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
EcalIntercalibConstantMap & calibMap_
void setTTId(int dac)
Definition: ODWeightsDat.h:30
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
void insertConfigSet(ICONF *iconf) noexcept(false)
void setWeight0(float x)
Definition: ODWeightsDat.h:36
const CaloSimParameters & simParameters(const DetId &id) const override
return the sim parameters relative to the right subdet
void setCrystalId(int dac)
Definition: ODWeightsDat.h:33
T min(T a, T b)
Definition: MathUtil.h:58
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EBShape.h:6
Definition: DetId.h:18
void readPassword(const std::string &fileName, const std::string &user, std::string &password)
std::vector< Item >::const_iterator const_iterator
void unbiasWeights(std::vector< double > &weights, std::vector< int32_t > *encodedWeigths)
EcalDccWeightBuilder(edm::ParameterSet const &ps)
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
int getId() const
void setConfigTag(std::string x)
Definition: IODConfig.h:31
HLT enums.
void setWeight5(float x)
Definition: ODWeightsDat.h:41
double a
Definition: hdecay.h:121
T get() const
Definition: EventSetup.h:62
void computeAllWeights(bool withIntercalib, const edm::EventSetup &es)
const_iterator find(uint32_t rawId) const
static const double tzero[3]
const_iterator end() const
static const int ecalDccFedIdMax
void setFedId(int dac)
Definition: ODWeightsDat.h:27
int binOfMaximum() const
T const * product() const
Definition: ESHandle.h:86
const EcalElectronicsMapping * ecalElectronicsMap_
static const int ecalDccFedIdMin
Definition: event.py:1
Definition: EEShape.h:6
double timeToRise() const override
#define comment(par)
Definition: vmac.h:163