CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripCondObjBuilderFromDb.cc
Go to the documentation of this file.
1 
19 
20 #include <cstdlib>
21 #include <iostream>
22 #include <sstream>
23 #include <iomanip>
24 #include "Fed9UUtils.hh"
25 
26 using namespace std;
27 using namespace sistrip;
28 
29 
30 // -----------------------------------------------------------------------------
33  const edm::ActivityRegistry&):
34  m_gaincalibrationfactor(static_cast<float>(pset.getUntrackedParameter<double>("GainNormalizationFactor",690.))),
35  m_defaultpedestalvalue(static_cast<float>(pset.getUntrackedParameter<double>("DefaultPedestal",0.))),
36  m_defaultnoisevalue(static_cast<float>(pset.getUntrackedParameter<double>("DefaultNoise",0.))),
37  m_defaultthresholdhighvalue(static_cast<float>(pset.getUntrackedParameter<double>("DefaultThresholdHigh",0.))),
38  m_defaultthresholdlowvalue(static_cast<float>(pset.getUntrackedParameter<double>("DefaultThresholdLow",0.))),
39  m_defaultapvmodevalue(static_cast<uint16_t>(pset.getUntrackedParameter<uint32_t>("DefaultAPVMode",37))),
40  m_defaultapvlatencyvalue(static_cast<uint16_t>(pset.getUntrackedParameter<uint32_t>("DefaultAPVLatency",142))),
41  m_defaulttickheightvalue(static_cast<float>(pset.getUntrackedParameter<double>("DefaultTickHeight",690.))),
42  m_useanalysis(static_cast<bool>(pset.getUntrackedParameter<bool>("UseAnalysis",false))),
43  m_usefed(static_cast<bool>(pset.getUntrackedParameter<bool>("UseFED",false))),
44  m_usefec(static_cast<bool>(pset.getUntrackedParameter<bool>("UseFEC",false))),
45  m_debug(static_cast<bool>(pset.getUntrackedParameter<bool>("DebugMode",false))),
46  tTopo(buildTrackerTopology())
47 {
49  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
50  << " Constructing object...";
51 }
52 
53 // -----------------------------------------------------------------------------
56 {
58  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
59  << " Constructing object...";
60 }
61 
62 // -----------------------------------------------------------------------------
66  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
67  << " Destructing object...";
68  delete tTopo;
69 }
70 
71 // -----------------------------------------------------------------------------
72 
75  if (!(dbParams_==dbParams())){
77  buildCondObj();
78  }
79 }
80 // -----------------------------------------------------------------------------
88 
89  pxbVals_.layerStartBit_ = 16;
90  pxbVals_.ladderStartBit_ = 8;
91  pxbVals_.moduleStartBit_ = 2;
92  pxbVals_.layerMask_ = 0xF;
93  pxbVals_.ladderMask_ = 0xFF;
94  pxbVals_.moduleMask_ = 0x3F;
95  pxfVals_.sideStartBit_ = 23;
96  pxfVals_.diskStartBit_ = 16;
97  pxfVals_.bladeStartBit_ = 10;
98  pxfVals_.panelStartBit_ = 8;
99  pxfVals_.moduleStartBit_ = 2;
100  pxfVals_.sideMask_ = 0x3;
101  pxfVals_.diskMask_ = 0xF;
102  pxfVals_.bladeMask_ = 0x3F;
103  pxfVals_.panelMask_ = 0x3;
104  pxfVals_.moduleMask_ = 0x3F;
105  tecVals_.sideStartBit_ = 18;
106  tecVals_.wheelStartBit_ = 14;
107  tecVals_.petal_fw_bwStartBit_ = 12;
108  tecVals_.petalStartBit_ = 8;
109  tecVals_.ringStartBit_ = 5;
110  tecVals_.moduleStartBit_ = 2;
111  tecVals_.sterStartBit_ = 0;
112  tecVals_.sideMask_ = 0x3;
113  tecVals_.wheelMask_ = 0xF;
114  tecVals_.petal_fw_bwMask_ = 0x3;
115  tecVals_.petalMask_ = 0xF;
116  tecVals_.ringMask_ = 0x7;
117  tecVals_.moduleMask_ = 0x7;
118  tecVals_.sterMask_ = 0x3;
119  tibVals_.layerStartBit_ = 14;
120  tibVals_.str_fw_bwStartBit_ = 12;
121  tibVals_.str_int_extStartBit_ = 10;
122  tibVals_.strStartBit_ = 4;
123  tibVals_.moduleStartBit_ = 2;
124  tibVals_.sterStartBit_ = 0;
125  tibVals_.layerMask_ = 0x7;
126  tibVals_.str_fw_bwMask_ = 0x3;
127  tibVals_.str_int_extMask_ = 0x3;
128  tibVals_.strMask_ = 0x3F;
129  tibVals_.moduleMask_ = 0x3;
130  tibVals_.sterMask_ = 0x3;
131  tidVals_.sideStartBit_ = 13;
132  tidVals_.wheelStartBit_ = 11;
133  tidVals_.ringStartBit_ = 9;
134  tidVals_.module_fw_bwStartBit_ = 7;
135  tidVals_.moduleStartBit_ = 2;
136  tidVals_.sterStartBit_ = 0;
137  tidVals_.sideMask_ = 0x3;
138  tidVals_.wheelMask_ = 0x3;
139  tidVals_.ringMask_ = 0x3;
140  tidVals_.module_fw_bwMask_ = 0x3;
141  tidVals_.moduleMask_ = 0x1F;
142  tidVals_.sterMask_ = 0x3;
143  tobVals_.layerStartBit_ = 14;
144  tobVals_.rod_fw_bwStartBit_ = 12;
145  tobVals_.rodStartBit_ = 5;
146  tobVals_.moduleStartBit_ = 2;
147  tobVals_.sterStartBit_ = 0;
148  tobVals_.layerMask_ = 0x7;
149  tobVals_.rod_fw_bwMask_ = 0x3;
150  tobVals_.rodMask_ = 0x7F;
151  tobVals_.moduleMask_ = 0x7;
152  tobVals_.sterMask_ = 0x3;
153 
154  return new TrackerTopology(pxbVals_, pxfVals_, tecVals_, tibVals_, tidVals_, tobVals_);
155 }
156 // -----------------------------------------------------------------------------
159 
160 
161  //get current config DB parameter
162 
164 
165  SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
166  SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
167  for ( ; ipart != ipartEnd; ++ipart ) {
168  SiStripPartition partition=ipart->second;
169  output << "@ "
170  << " Partition " << partition.partitionName() ;
171  if (label!="Cabling" && label !="ApvLatency")
172  output << " FedVer " << partition.fedVersion().first << "." << partition.fedVersion().second;
173  if(label=="Cabling")
174  output << " CabVer " << partition.cabVersion().first << "." << partition.cabVersion().second
175  << " MaskVer " << partition.maskVersion().first << "." << partition.maskVersion().second;
176  if(label=="ApvTiming")
177  output<< " ApvTimingVer " << partition.apvTimingVersion().first << "." << partition.apvTimingVersion().second;
178  if(label=="ApvLatency")
179  output<< " FecVersion " << partition.fecVersion().first << "." << partition.fecVersion().second;
180  }
181 
182  if (!strcmp(output.str().c_str(),input.str().c_str()))
183  return false;
184 
185  return true;
186 }
187 
188 // -----------------------------------------------------------------------------
192  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]";
193 
194  // Check if DB connection is made
195  if ( db_ ) {
196 
197  // Check if DB connection is made
198  if ( db_->deviceFactory() ||
199  db_->databaseCache() ) {
200 
201  // Build FEC cabling object
202  SiStripFecCabling fec_cabling;
203 
205  fec_cabling,
208 
210  SiStripDetCabling det_cabling( *fed_cabling_, tTopo );
211  buildStripRelatedObjects( &*db_, det_cabling );
212 
213 
217 
218 
219 
220  } else {
222  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
223  << " NULL pointer to DeviceFactory returned by SiStripConfigDb!"
224  << " Cannot build Pedestals object!";
225  }
226  } else {
228  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
229  << " NULL pointer to SiStripConfigDb returned by DB \"service\"!"
230  << " Cannot build Pedestals object!";
231  }
232 }
233 
234 // -----------------------------------------------------------------------------
236 //Retrieve FedDescriptions from configuration database
239  if ( descriptions.empty() ) {
241  << "SiStripCondObjBuilderFromDb::" << __func__ << "]"
242  << " No FED descriptions found!";
243 
244  return false;
245  }
246  return true;
247 }
248 
249 // -----------------------------------------------------------------------------
251  // Retrieve gain from configuration database
253  SiStripConfigDb::AnalysisDescriptionsRange anal_descriptions =
254  db->getAnalysisDescriptions( CommissioningAnalysisDescription::T_ANALYSIS_TIMING );
255  if ( anal_descriptions.empty() ) {
257  << "SiStripCondObjBuilderFromDb::" << __func__ << "]"
258  << " Unable to build SiStripApvGain object!"
259  << " No timing-scan analysis descriptions found!";
260  return false;
261  }
262  return true;
263 }
264 
265 // -----------------------------------------------------------------------------
267  // Retrieve list of active DetIds
269  vector<uint32_t> det_ids;
270  det_cabling.addActiveDetectorsRawIds(det_ids);
271  if ( det_ids.empty() ) {
273  << "SiStripCondObjBuilderFromDb::" << __func__ << "]"
274  << " Unable to build Pedestals object!"
275  << " No DetIds found!";
276  return det_ids;
277  }
279  << "\n\nSiStripCondObjBuilderFromDb::" << __func__ << "]"
280  << " Found " << det_ids.size() << " active DetIds";
281  return det_ids;
282 }
283 
284 // -----------------------------------------------------------------------------
286  //build connections per DetId
287 vector<const FedChannelConnection *> SiStripCondObjBuilderFromDb::buildConnections(const SiStripDetCabling& det_cabling, uint32_t det_id ){
288  vector<const FedChannelConnection *> conns = det_cabling.getConnections(det_id);
289  if (conns.size()==0){
291  << "SiStripCondObjBuilderFromDb::" << __func__ << "]"
292  << " Unable to build condition object!"
293  << " No FED channel connections found for detid "<< det_id;
294  }
295  return conns;
296 }
297 
298 // -----------------------------------------------------------------------------
300 //retrieve number of APV pairs per detid
302  uint16_t nApvPairs;
304  nApvPairs=fr->getNumberOfApvsAndStripLength(det_id).first/2;
305  return nApvPairs;
306 }
307 
308 // -----------------------------------------------------------------------------
310 //set default values for Cabling Objects Peds, Noise, thresh, Quality
312  uint16_t istrip = apvPair*sistrip::STRIPS_PER_FEDCH;
313  std::cout << "Found disabled FedConnection! APVPair: " << apvPair << " Strips: " << sistrip::STRIPS_PER_FEDCH << std::endl;
314  inputQuality.push_back(quality_->encode(istrip,sistrip::STRIPS_PER_FEDCH));
315  for ( ;istrip < (apvPair+1)*sistrip::STRIPS_PER_FEDCH; ++istrip ){
319  }
320 }
321 
322 // -----------------------------------------------------------------------------
327 }
328 
329 // -----------------------------------------------------------------------------
332  std::cout << "[SiStripCondObjBuilderFromDb::"<<__func__<<"]: Set Default Latency for Detid: " << detid << " ApvNr: " << apvnr << std::endl;
333  if(!latency_.put( detid, apvnr, m_defaultapvmodevalue, m_defaultapvlatencyvalue))
334  {
335  std::cout << "[SiStripCondObjBuilderFromDb::"<<__func__<<"]: Unable to fill Latency for Detid: " << detid << " ApvNr: " << apvnr << std::endl;
336  }
337  if(!latency_.put( detid, ++apvnr, m_defaultapvmodevalue, m_defaultapvlatencyvalue))
338  {
339  std::cout << "[SiStripCondObjBuilderFromDb::"<<__func__<<"]: Unable to fill Latency for Detid: " << detid << " ApvNr: " << apvnr << std::endl;
340  }
341 
342 }
343 
344 
345 
346 // -----------------------------------------------------------------------------
349  SiStripConfigDb::AnalysisDescriptionsRange anal_descriptions = db->getAnalysisDescriptions( CommissioningAnalysisDescription::T_ANALYSIS_TIMING );
350  SiStripConfigDb::AnalysisDescriptionsV::const_iterator iii = anal_descriptions.begin();
351  SiStripConfigDb::AnalysisDescriptionsV::const_iterator jjj = anal_descriptions.end();
352 
353  while ( iii != jjj ) {
354  CommissioningAnalysisDescription* tmp = *iii;
355  uint16_t fed_id = tmp->getFedId();
356  uint16_t fed_ch = SiStripFedKey::fedCh( tmp->getFeUnit(), tmp->getFeChan() );
357  if ( fed_id == ipair.fedId() && fed_ch == ipair.fedCh() ) { break; }
358  iii++;
359  }
360 
361  TimingAnalysisDescription *anal=0;
362  if ( iii != jjj ) { anal = dynamic_cast<TimingAnalysisDescription*>(*iii); }
363  if ( anal ) {
364  float tick_height = (anal->getHeight() / m_gaincalibrationfactor);
365  inputApvGain.push_back( tick_height ); // APV0
366  inputApvGain.push_back( tick_height); // APV1
367  } else {
370  return false;
371  }
372 
373  return true;
374 }
375 
376 // -----------------------------------------------------------------------------
381 
382  SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv = apvs.begin();
383  SiStripConfigDb::DeviceDescriptionsV::const_iterator japv = apvs.end();
384  if(iapv==japv) return false;
385  for ( ; iapv != japv; ++iapv ) {
386  apvDescription* apv = dynamic_cast<apvDescription*>( *iapv );
387  if ( !apv ) { continue; }
388  if((apv->getCrateId()) != (ipair.fecCrate())) continue;
389  if((apv->getFecSlot()) != (ipair.fecSlot())) continue;
390  if((apv->getRingSlot()) != (ipair.fecRing())) continue;
391  if((apv->getCcuAddress()) != (ipair.ccuAddr())) continue;
392  if((apv->getChannel()) != (ipair.ccuChan())) continue;
393  // Insert latency values into latency object
394  if((apv->getAddress()) == (ipair.i2cAddr(0))) {
395  if(!latency_.put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
396  std::cout << "UNABLE APVLatency Put: Detid "<< dec<<detid
397  << " APVNr.: " << apvnr
398  << " Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
399  << " APV Mode: " << dec<< static_cast<uint16_t>(apv->getApvMode())
400  << std::endl;
401  return false;
402  }else{++apvnr;}
403  }
404  if((apv->getAddress()) == (ipair.i2cAddr(1))) {
405  if(!latency_.put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
406  std::cout << "UNABLE APVLatency Put: Detid "<<dec<< detid
407  << " APVNr.: " << apvnr
408  << " Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
409  << " APV Mode: " << dec <<static_cast<uint16_t>(apv->getApvMode())
410  << std::endl;
411  continue;
412  return false;
413  }else{++apvnr;}
414  }
415  }
416  return true;
417 }
418 
419 // -----------------------------------------------------------------------------
421 //bool SiStripCondObjBuilderFromDb::setValuesCabling(SiStripConfigDb* const db, FedChannelConnection &ipair, uint32_t detid){
423  //SiStripConfigDb::FedDescriptionsRange descriptions = db->getFedDescriptions();
424  SiStripConfigDb::FedDescriptionsV::const_iterator description = descriptions.begin();
425  while ( description != descriptions.end() ) {
426  if ( (*description)->getFedId() ==ipair.fedId() ) { break; }
427  description++;
428  }
429  if ( description == descriptions.end() ) {return false;}
430  // Retrieve Fed9UStrips object from FED description
431  const Fed9U::Fed9UStrips& strips = (*description)->getFedStrips();
432 
433 
434  // Retrieve StripDescriptions for each APV
435  uint16_t jstrip = ipair.apvPairNumber()*sistrip::STRIPS_PER_FEDCH;
436  for ( uint16_t iapv = 2*ipair.fedCh(); iapv < 2*ipair.fedCh()+2; iapv++ ) {
437 
438  // Get StripDescriptions for the given APV
439  Fed9U::Fed9UAddress addr;
440  addr.setFedApv(iapv);
441  vector<Fed9U::Fed9UStripDescription> strip = strips.getApvStrips(addr);
442 
443  vector<Fed9U::Fed9UStripDescription>::const_iterator istrip = strip.begin();
444 
445  for ( ; istrip != strip.end(); istrip++ ) {
446  pedestals_->setData( istrip->getPedestal() , inputPedestals);
447  noises_ ->setData( istrip->getNoise() , inputNoises );
448  threshold_->setData( jstrip, istrip->getLowThresholdFactor(),
449  istrip->getHighThresholdFactor(), inputThreshold );
450  if(istrip->getDisable()){
451  std::cout << "Found disabled strip! Detid: " << detid << " APVNr: " << iapv << " Strips: " << jstrip << std::endl;
452 
453  inputQuality.push_back(quality_->encode(jstrip,1));
454  }
455  jstrip++;
456  }
457  }
458  return true;
459 }
460 
461 
462 // -----------------------------------------------------------------------------
464 //store objects
466  if ( !pedestals_->put(det_id, inputPedestals ) ) {
467  std::cout
468  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
469  << " Unable to insert values into SiStripPedestals object!"
470  << " DetId already exists!" << std::endl;
471  }
472  inputPedestals.clear();
473 
474  }
475 
476 
477 
478 // -----------------------------------------------------------------------------
481  // Insert noise values into Noises object
482 
483  if ( !noises_->put(det_id, inputNoises ) ) {
484  std::cout
485  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
486  << " Unable to insert values into SiStripNoises object!"
487  << " DetId already exists!" << std::endl;
488  }
489  inputNoises.clear();
490 
491  }
492 
493 // -----------------------------------------------------------------------------
496  // Insert threshold values into Threshold object
497  if ( !threshold_->put(det_id, inputThreshold ) ) {
498  std::cout
499  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
500  << " Unable to insert values into SiStripThreshold object!"
501  << " DetId already exists!" << std::endl;
502  }
503  inputThreshold.clear();
504 }
505 
506 // -----------------------------------------------------------------------------
509  // Insert quality values into Quality object
510  if (inputQuality.size()){
511  quality_->compact(det_id,inputQuality);
512  if ( !quality_->put(det_id, inputQuality ) ) {
513  std::cout
514  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
515  << " Unable to insert values into SiStripQuality object!"
516  << " DetId already exists!" << std::endl;
517  }
518  }
519  inputQuality.clear();
520 }
521 
522 // -----------------------------------------------------------------------------
525  // Insert tick height values into Gain object
526  SiStripApvGain::Range range( inputApvGain.begin(), inputApvGain.end() );
527  if ( !gain_->put( det_id, range ) ) {
529  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
530  << " Unable to insert values into SiStripApvGain object!"
531  << " DetId already exists!";
532  }
533  inputApvGain.clear();
534 }
535 
536 // -----------------------------------------------------------------------------
539  const SiStripDetCabling& det_cabling){
540  //variables needed in this function
541  uint16_t nApvPairs;
542  vector<uint32_t>::const_iterator det_id;
543  vector<uint32_t> det_ids;
544 
546  << "\n[SiStripCondObjBuilderFromDb::" << __func__ << "] first call to this method";
547 
548  //Check if FedDescriptions exist, if not return
549  if (!retrieveFedDescriptions(db)) {std::cout<< "Found no FedDescription!" << std::endl;return;}
550  // Retrieve list of active DetIds
551  det_cabling.addActiveDetectorsRawIds(det_ids);
552  if ( det_ids.empty() ) {
553  std::cout
554  << "SiStripCondObjBuilderFromDb::" << __func__ << "]"
555  << " Unable to build Pedestals object!"
556  << " No DetIds found!" << std::endl;
557  return;
558  }
559  std::cout << "\n\nSiStripCondObjBuilderFromDb::" << __func__ << "]"
560  << " Found " << det_ids.size() << " active DetIds";
561 
562  // Loop Active DetIds
563  det_id = det_ids.begin();
564  for ( ; det_id != det_ids.end(); det_id++ ) {
565  std::stringstream ssMessage;
566 
567  // Ignore NULL DetIds
568  if ( !(*det_id) ) { continue; }
569  if ( *det_id == sistrip::invalid32_ ) { continue; }
570 
571 
572  //build connections per DetId
573  const vector<const FedChannelConnection *>& conns=buildConnections(det_cabling, *det_id);
574 
575  vector<const FedChannelConnection *>::const_iterator ipair = conns.begin();
576  if(conns.size() ==0 ) continue;
577 
578  //retrieve number of APV pairs per detid
579  nApvPairs=retrieveNumberAPVPairs(*det_id);
580 
581 
582  //loop connections and check if APVPair is connected
583  vector< vector<const FedChannelConnection *>::const_iterator > listConns(nApvPairs,conns.end());
584 
585  for ( ; ipair != conns.end(); ++ipair ){
586  // Check if the ApvPair is connected
587  if ((*ipair)->fedId()!=sistrip::invalid_ && (*ipair)->apvPairNumber()<3){
588  // (*ipair)->print(ssMessage);
589  // ssMessage<< std::endl;
590  listConns[ipair-conns.begin()]=ipair;
591  } else {
592  std::cout
593  << "\n impossible to assign connection position in listConns " << std::endl;
594  // (*ipair)->print(ssMessage);
595  // ssMessage << std::endl;
596  }
597  }
598 
599  // get data
600  // vector< vector<const FedChannelConnection *>::const_iterator >::const_iterator ilistConns=listConns.begin();
601  for (uint16_t apvPair=0;apvPair<listConns.size();++apvPair){
602  ipair=listConns[apvPair];
603  if ( ipair == conns.end() ) {
604  // Fill object with default values
605  std::cout
606  << "\n "
607  << " Unable to find FED connection for detid : " << std::dec << *det_id << " APV pair number " << apvPair
608  << " Writing default values" << std::endl;
609  (*ipair)->print(ssMessage);
610  //If no connection was found, add 100 to apvpair
611  apvPair+=100;
612  std::cout << " Put apvPair+100:" << apvPair << " into vector!" << std::endl;
613  p_apvpcon=std::make_pair(apvPair,**ipair);
614  v_apvpcon.push_back(p_apvpcon);
615  apvPair=apvPair-100;
616  continue;
617  }
618  p_apvpcon=std::make_pair(apvPair,**ipair);
619  v_apvpcon.push_back(p_apvpcon);
620  } //conns loop
621  p_detcon=std::make_pair(*det_id,v_apvpcon);
622  v_trackercon.push_back(p_detcon);
623  v_apvpcon.clear();
624  } // det id loop
625 }
626 
627 // -----------------------------------------------------------------------------
630  trackercon tc = _tc;
631  std::cout << "Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<"]"<<std::endl;
632  //data container
633  gain_= new SiStripApvGain();
634 
635  //check if Timing analysis description is found, otherwise quit
638  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
639  << " NULL pointer to AnalysisDescriptions returned by SiStripConfigDb!"
640  << " Cannot build Analysis object! QUIT";
641  // some values have to be set, otherwise PopCon will crash
643  storeTiming(4711);
644  return;
645  }
646 
647  i_trackercon detids_end=tc.end();
648 
649  //loop detids
650  for(i_trackercon detids=tc.begin();detids!=detids_end;detids++){
651  uint32_t detid = (*detids).first;
652  i_apvpairconn connections_end=((*detids).second).end();
653 
654  //loop connections
655  for(i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
656  uint32_t apvPair =(*connections).first;
657  FedChannelConnection ipair =(*connections).second;
658 
659 
660  //no connection for apvPair found
661  if(apvPair>=100){
663  continue;
664  }
665 
666  //fill data
667  if(!setValuesApvTiming(db, ipair)){
668  std::cout
669  << "\n "
670  << " Unable to find Timing Analysis Description"
671  << " Writing default values for DetId: " << detid
672  << " Value: " << m_defaulttickheightvalue/m_gaincalibrationfactor << std::endl;
674  }
675  }//connections
676  storeTiming(detid);
677  }//detids
678 
679 }
680 
681 // -----------------------------------------------------------------------------
684  trackercon tc = _tc;
685  std::cout << "Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<"]"<<std::endl;
686  //data container
687  latency_ = new SiStripLatency();
688 
689  i_trackercon detids_end=tc.end();
690 
691  // get APV DeviceDescriptions
693 
694 
695  //loop detids
696  for(i_trackercon detids=tc.begin();detids!=detids_end;detids++){
697  uint32_t detid = (*detids).first;
698  uint16_t apvnr=1;
699  i_apvpairconn connections_end=((*detids).second).end();
700 
701 
702  //loop connections
703  for(i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
704  uint32_t apvPair =(*connections).first;
705  FedChannelConnection ipair =(*connections).second;
706 
707  //no connection for apvPair found
708  if(apvPair>=100){
709  //setDefaultValuesApvLatency((*latency_),ipair, detid, apvnr);
710  std::cout << "[SiStripCondObjBuilderFromDb::" << __func__ << "] No FEDConnection for DetId " << detid << " ApvPair " << apvPair-100 << " found, skipping Latency Insertion!" << std::endl;
711  continue;
712  }
713 
714  //fill data
715  if(!setValuesApvLatency((*latency_),db, ipair, detid, apvnr, apvs)){
716  std::cout
717  << "\n "
718  << " Unable to find FEC Description"
719  << " Skipping Insertion for DetId: " << detid << std::endl;
720  //setDefaultValuesApvLatency((*latency_),ipair, detid, apvnr);
721  }
722  apvnr+=2;
723  }//connections
724  // compact Latency Object
725 
726  }//detids
727  latency_->compress();
728  std::stringstream ss;
729  // latency debug output
730  latency_->printSummary(ss);
731  latency_->printDebug(ss);
732  std::cout << ss.str() << std::endl;
733 }
734 
735 // -----------------------------------------------------------------------------
738  trackercon tc = _tc;
739  std::cout << "Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<"]"<<std::endl;
740 
741  //data containers
743  noises_ = new SiStripNoises();
745  quality_ = new SiStripQuality();
746 
747  i_trackercon detids_end=tc.end();
748 
749  //Build FED Descriptions out of db object
751 
752  //loop detids
753  for(i_trackercon detids=tc.begin();detids!=detids_end;detids++){
754  uint32_t detid = (*detids).first;
755  i_apvpairconn connections_end=((*detids).second).end();
756 
757  //loop connections
758  for(i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
759  uint32_t apvPair =(*connections).first;
760  FedChannelConnection ipair =(*connections).second;
761 
762  //no connection for apvPair found
763  if(apvPair>=100){
764  std::cout
765  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
766  << " Unable to find FED description for FED id: " << ipair.fedId()
767  << " detid : " << detid << " APV pair number " << apvPair
768  << " Writing default values"<< std::endl;
769  setDefaultValuesCabling((apvPair-100));
770  continue;
771  }
772  // if(!setValuesCabling(db, ipair, detid)){
773  if(!setValuesCabling(descriptions, ipair, detid)){
774  std::cout
775  << "[SiStripCondObjBuilderFromDb::" << __func__ << "]"
776  << " Unable to find FED description for FED id: " << ipair.fedId()
777  << " detid : " << detid << " APV pair number " << apvPair
778  << " Writing default values"<< std::endl;
779  setDefaultValuesCabling(apvPair);
780  }
781  }//connections
782  storePedestals(detid);
783  storeNoise(detid);
784  storeThreshold(detid);
785  storeQuality(detid);
786  }//detids
787 }
788 
789 
const uint16_t & fecSlot() const
bool put(const uint32_t &detID, const InputVector &vect)
vector< uint32_t > retrieveActiveDetIds(const SiStripDetCabling &det_cabling)
SiStripPedestals::InputVector inputPedestals
const uint16_t & fecCrate() const
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
Versions maskVersion() const
const uint16_t & fedCh() const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void buildAnalysisRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
DeviceFactory *const deviceFactory(std::string method_name="") const
static const uint32_t invalid32_
Definition: Constants.h:15
SiStripQuality::InputVector inputQuality
FedDescriptionsRange getFedDescriptions(std::string partition="")
std::string partitionName() const
uint16_t apvPairNumber() const
tuple db
Definition: EcalCondDB.py:151
FedDescriptions::range FedDescriptionsRange
SiStripThreshold::InputVector inputThreshold
const uint16_t & fedId() const
void setDefaultValuesCabling(uint16_t apvPair)
static std::string const input
Definition: EdmProvDump.cc:43
edm::Service< SiStripConfigDb > db_
bool put(const uint32_t &detID, Range input)
void buildFECRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
const_iterator_range partitions() const
bool setValuesApvLatency(SiStripLatency &latency_, SiStripConfigDb *const db, FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr, SiStripConfigDb::DeviceDescriptionsRange apvs)
bool retrieveFedDescriptions(SiStripConfigDb *const db)
Versions apvTimingVersion() const
void buildStripRelatedObjects(SiStripConfigDb *const db, const SiStripDetCabling &det_cabling)
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
const uint16_t & fecRing() const
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
Class containning control, module, detector and connection information, at the level of a FED channel...
DeviceDescriptions::range DeviceDescriptionsRange
void compact(unsigned int &, std::vector< unsigned int > &)
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
void buildFEDRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
std::pair< ContainerIterator, ContainerIterator > Range
uint16_t retrieveNumberAPVPairs(uint32_t det_id)
std::vector< pair_detcon > trackercon
Container class for database partition parameters.
#define end
Definition: vmac.h:37
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
const uint16_t & ccuAddr() const
vector< const FedChannelConnection * > buildConnections(const SiStripDetCabling &det_cabling, uint32_t det_id)
SiStripNoises::InputVector inputNoises
#define LogTrace(id)
void printSummary(std::stringstream &ss) const
Prints the number of ranges as well as the value of singleLatency and singleMode. ...
bool put(const uint32_t &detID, const InputVector &input)
DbClient *const databaseCache(std::string method_name="") const
const SiStripDbParams & dbParams() const
tuple description
Definition: idDealer.py:66
bool setValuesCabling(SiStripConfigDb::FedDescriptionsRange &descriptions, FedChannelConnection &ipair, uint32_t detid)
static void getFedCabling(const SiStripFecCabling &in, SiStripFedCabling &out)
static const uint16_t STRIPS_PER_FEDCH
bool put(const uint32_t &detID, InputVector &input)
bool retrieveTimingAnalysisDescriptions(SiStripConfigDb *const db)
AnalysisDescriptions::range AnalysisDescriptionsRange
unsigned int module_fw_bwStartBit_
static const uint16_t invalid_
Definition: Constants.h:16
void setDefaultValuesApvLatency(SiStripLatency &latency_, const FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr)
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::iterator_range< SiStripPartitions::const_iterator > const_iterator_range
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SiStripApvGain::InputVector inputApvGain
void printDebug(std::stringstream &ss) const
Prints the full list of all ranges and corresponding values of latency and mode.
void setData(float ped, InputVector &vped)
tuple cout
Definition: gather_cfg.py:121
static uint16_t fedCh(const uint16_t &fe_unit, const uint16_t &fe_chan)
volatile std::atomic< bool > shutdown_flag false
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
static const char mlESSources_[]
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
bool put(const uint32_t &detID, const InputVector &vect)
std::vector< pair_detcon >::iterator i_trackercon
Versions fecVersion() const
Versions cabVersion() const
std::vector< pair_apvpairconn >::iterator i_apvpairconn
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
Versions fedVersion() const
void setData(float noise_, InputVector &vped)
bool setValuesApvTiming(SiStripConfigDb *const db, FedChannelConnection &ipair)