CMS 3D CMS Logo

SiStripPartition.cc
Go to the documentation of this file.
1 
6 #include <iostream>
7 #include <cmath>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
12 //
13 const std::string SiStripPartition::defaultPartitionName_ = "DefaultPartition";
14 
15 // -----------------------------------------------------------------------------
16 //
18  partitionName_(defaultPartitionName_),
19  runNumber_(0),
20  runType_(sistrip::UNDEFINED_RUN_TYPE),
21  forceVersions_(false),
22  forceCurrentState_(false),
23  cabVersion_(0,0),
24  fedVersion_(0,0),
25  fecVersion_(0,0),
26  dcuVersion_(0,0),
27  psuVersion_(0,0),
28  //#ifdef USING_DATABASE_MASKING
29  maskVersion_(0,0),
30  //#endif
31  globalAnalysisV_(0),
32  runTableVersion_(0,0),
33  fastCablingV_(0,0),
34  apvTimingV_(0,0),
35  optoScanV_(0,0),
36  vpspScanV_(0,0),
37  apvCalibV_(0,0),
38  pedestalsV_(0,0),
39  pedsFullNoiseV_(0,0),
40  apvLatencyV_(0,0),
41  fineDelayV_(0,0),
42  inputModuleXml_(""),
43  inputDcuInfoXml_(""),
44  inputFecXml_(),
45  inputFedXml_()
46 {;}
47 
48 // -----------------------------------------------------------------------------
49 //
51  partitionName_(partition),
52  runNumber_(0),
56  cabVersion_(0,0),
57  fedVersion_(0,0),
58  fecVersion_(0,0),
59  dcuVersion_(0,0),
60  psuVersion_(0,0),
61  //#ifdef USING_DATABASE_MASKING
62  maskVersion_(0,0),
63  //#endif
65  runTableVersion_(0,0),
66  fastCablingV_(0,0),
67  apvTimingV_(0,0),
68  optoScanV_(0,0),
69  vpspScanV_(0,0),
70  apvCalibV_(0,0),
71  pedestalsV_(0,0),
72  pedsFullNoiseV_(0,0),
73  apvLatencyV_(0,0),
74  fineDelayV_(0,0),
75  inputModuleXml_(""),
76  inputDcuInfoXml_(""),
77  inputFecXml_(),
78  inputFedXml_()
79 {
81 }
82 
83 // -----------------------------------------------------------------------------
84 //
86  partitionName_( input.partitionName() ),
87  runNumber_( input.runNumber() ),
88  runType_( input.runType() ),
89  forceVersions_( input.forceVersions() ),
91  cabVersion_( input.cabVersion() ),
92  fedVersion_( input.fedVersion() ),
93  fecVersion_( input.fecVersion() ),
94  dcuVersion_( input.dcuVersion() ),
95  psuVersion_( input.psuVersion() ),
96  //#ifdef USING_DATABASE_MASKING
97  maskVersion_( input.maskVersion() ),
98  //#endif
102  apvTimingV_( input.apvTimingVersion() ),
103  optoScanV_( input.optoScanVersion() ),
104  vpspScanV_( input.vpspScanVersion() ),
105  apvCalibV_( input.apvCalibVersion() ),
106  pedestalsV_( input.pedestalsVersion() ),
108  apvLatencyV_( input.apvLatencyVersion() ),
109  fineDelayV_( input.fineDelayVersion() ),
110  inputModuleXml_( input.inputModuleXml() ),
112  inputFecXml_( input.inputFecXml() ),
113  inputFedXml_( input.inputFedXml() )
114 {;}
115 
116 // -----------------------------------------------------------------------------
117 //
119  if ( this == &input ) { return *this; } // self-assignment
120  partitionName_ = input.partitionName();
121  runNumber_ = input.runNumber();
122  runType_ = input.runType();
123  forceVersions_ = input.forceVersions();
125  cabVersion_ = input.cabVersion();
126  fedVersion_ = input.fedVersion();
127  fecVersion_ = input.fecVersion();
128  dcuVersion_ = input.dcuVersion();
129  psuVersion_ = input.psuVersion();
130  //#ifdef USING_DATABASE_MASKING
131  maskVersion_ = input.maskVersion();
132  //#endif
136  apvTimingV_ = input.apvTimingVersion();
137  optoScanV_ = input.optoScanVersion();
138  vpspScanV_ = input.vpspScanVersion();
139  apvCalibV_ = input.apvCalibVersion();
140  pedestalsV_ = input.pedestalsVersion();
143  fineDelayV_ = input.fineDelayVersion();
146  inputFecXml_ = input.inputFecXml();
147  inputFedXml_ = input.inputFedXml();
148  return *this;
149 }
150 
151 // -----------------------------------------------------------------------------
152 //
154  return ( partitionName_ == input.partitionName() &&
155  runNumber_ == input.runNumber() &&
156  runType_ == input.runType() &&
157  forceVersions_ == input.forceVersions() &&
159  cabVersion_ == input.cabVersion() &&
160  fedVersion_ == input.fedVersion() &&
161  fecVersion_ == input.fecVersion() &&
162  dcuVersion_ == input.dcuVersion() &&
163  psuVersion_ == input.psuVersion() &&
164  //#ifdef USING_DATABASE_MASKING
165  maskVersion_ == input.maskVersion() &&
166  //#endif
168  runTableVersion_ == input.runTableVersion() &&
169  fastCablingV_ == input.fastCablingVersion() &&
170  apvTimingV_ == input.apvTimingVersion() &&
171  optoScanV_ == input.optoScanVersion() &&
172  vpspScanV_ == input.vpspScanVersion() &&
173  apvCalibV_ == input.apvCalibVersion() &&
174  pedestalsV_ == input.pedestalsVersion() &&
176  apvLatencyV_ == input.apvLatencyVersion() &&
177  fineDelayV_ == input.fineDelayVersion() &&
178  inputModuleXml_ == input.inputModuleXml() &&
179  inputDcuInfoXml_ == input.inputDcuInfoXml() &&
180  inputFecXml_ == input.inputFecXml() &&
181  inputFedXml_ == input.inputFedXml() );
182 }
183 
184 // -----------------------------------------------------------------------------
185 //
187  return !( *this == input );
188 }
189 
190 // -----------------------------------------------------------------------------
191 //
193  inputFecXml_.clear();
194  inputFedXml_.clear();
195 }
196 
197 // -----------------------------------------------------------------------------
198 //
200  partitionName_ = "";
201  runNumber_ = 0;
203  forceVersions_ = false;
204  forceCurrentState_ = false;
205 
206  cabVersion_ = std::make_pair(0,0);
207  fedVersion_ = std::make_pair(0,0);
208  fecVersion_ = std::make_pair(0,0);
209  dcuVersion_ = std::make_pair(0,0);
210  psuVersion_ = std::make_pair(0,0);
211  //#ifdef USING_DATABASE_MASKING
212  maskVersion_ = std::make_pair(0,0);
213  //#endif
214 
215  globalAnalysisV_ = 0;
216  runTableVersion_ = std::make_pair(0,0);
217  fastCablingV_ = std::make_pair(0,0);
218  apvTimingV_ = std::make_pair(0,0);
219  optoScanV_ = std::make_pair(0,0);
220  vpspScanV_ = std::make_pair(0,0);
221  apvCalibV_ = std::make_pair(0,0);
222  pedestalsV_ = std::make_pair(0,0);
223  pedsFullNoiseV_ = std::make_pair(0,0);
224  apvLatencyV_ = std::make_pair(0,0);
225  fineDelayV_ = std::make_pair(0,0);
226 
227  inputModuleXml_ = "";
228  inputDcuInfoXml_ = "";
229  inputFecXml_.clear(); inputFecXml_.push_back("");
230  inputFedXml_.clear(); inputFedXml_.push_back("");
231 }
232 
233 // -----------------------------------------------------------------------------
234 //
236 
237  partitionName_ = pset.getUntrackedParameter<std::string>( "PartitionName", "" );
238  runNumber_ = pset.getUntrackedParameter<unsigned int>( "RunNumber", 0 );
239  forceVersions_ = pset.getUntrackedParameter<bool>( "ForceVersions", false );
240  forceCurrentState_ = pset.getUntrackedParameter<bool>( "ForceCurrentState", false );
241 
242  std::vector<uint32_t> tmp1(2,0);
243  cabVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "CablingVersion", tmp1 ) );
244  fedVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "FedVersion", tmp1 ) );
245  fecVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "FecVersion", tmp1 ) );
246  dcuVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "DcuDetIdsVersion", tmp1 ) );
247  psuVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "DcuPsuMapVersion", tmp1 ) );
248  //#ifdef USING_DATABASE_MASKING
249  maskVersion_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "MaskVersion", tmp1 ) );
250  //#endif
251 
252  std::vector<uint32_t> tmp2(2,0);
253  globalAnalysisV_ = pset.getUntrackedParameter<uint32_t>( "GlobalAnalysisVersion", 0 );
254  fastCablingV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "FastCablingVersion", tmp2 ) );
255  apvTimingV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "ApvTimingVersion", tmp2 ) );
256  optoScanV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "OptoScanVersion", tmp2 ) );
257  vpspScanV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "VpspScanVersion", tmp2 ) );
258  apvCalibV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "ApvCalibVersion", tmp2 ) );
259  pedestalsV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "PedestalsVersion", tmp2 ) );
260  pedsFullNoiseV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "PedsFullNoiseVersion", tmp2 ) );
261  apvLatencyV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "ApvLatencyVersion", tmp2 ) );
262  fineDelayV_ = versions( pset.getUntrackedParameter< std::vector<uint32_t> >( "FineDelayVersion", tmp2 ) );
263 
264  std::vector<std::string> tmp3(1,"");
265  inputModuleXml_ = pset.getUntrackedParameter<std::string>( "InputModuleXml", "" );
266  inputDcuInfoXml_ = pset.getUntrackedParameter<std::string>( "InputDcuInfoXml", "" );
267  inputFecXml_ = pset.getUntrackedParameter< std::vector<std::string> >( "InputFecXml", tmp3 );
268  inputFedXml_ = pset.getUntrackedParameter< std::vector<std::string> >( "InputFedXml", tmp3 );
269 
270 }
271 
272 // -----------------------------------------------------------------------------
273 //
274 void SiStripPartition::update( const SiStripConfigDb* const db ) {
275 
276  // Check
277  if ( !db ) {
279  << "[SiStripPartition::" << __func__ << "]"
280  << " NULL pointer to SiStripConfigDb object!"
281  << " Aborting update...";
282  return;
283  }
284 
285  // Check
286  DeviceFactory* const df = db->deviceFactory(__func__);
287  if ( !df ) {
289  << "[SiStripPartition::" << __func__ << "]"
290  << " NULL pointer to DeviceFactory object!"
291  << " Aborting update...";
292  return;
293  }
294 
295  // Check partition name
296  if ( partitionName_ == defaultPartitionName_ ) { return; }
297 
298  // Debug
299  std::stringstream ss;
300  ss << "[SiStripPartition::" << __func__ << "]"
301  << " Updating description versions for partition \""
302  << partitionName_
303  << "\"...";
304  LogTrace(mlConfigDb_) << ss.str();
305 
306  try {
307 
308  // Reset container indicating state versions for commissioning runs
309  runTableVersion_ = Versions(0,0);
310 
311  // Update versions if using versions from "current state"
313 
314  // Find state for given partition
315  tkStateVector states;
316  states = df->getCurrentStates();
317  tkStateVector::const_iterator istate = states.begin();
318  tkStateVector::const_iterator jstate = states.end();
319  while ( istate != jstate ) {
320  if ( *istate && partitionName_ == (*istate)->getPartitionName() ) { break; }
321  istate++;
322  }
323 
324  // Set versions if state was found
325  if ( istate != states.end() ) {
326 
327  if ( !cabVersion_.first &&
328  !cabVersion_.second ) {
329  cabVersion_.first = (*istate)->getConnectionVersionMajorId();
330  cabVersion_.second = (*istate)->getConnectionVersionMinorId();
331  }
332  if ( !fecVersion_.first &&
333  !fecVersion_.second ) {
334  fecVersion_.first = (*istate)->getFecVersionMajorId();
335  fecVersion_.second = (*istate)->getFecVersionMinorId();
336  }
337  if ( !fedVersion_.first &&
338  !fedVersion_.second ) {
339  fedVersion_.first = (*istate)->getFedVersionMajorId();
340  fedVersion_.second = (*istate)->getFedVersionMinorId();
341  }
342  if ( !dcuVersion_.first &&
343  !dcuVersion_.second ) {
344  dcuVersion_.first = (*istate)->getDcuInfoVersionMajorId();
345  dcuVersion_.second = (*istate)->getDcuInfoVersionMinorId();
346  }
347  if ( !psuVersion_.first &&
348  !psuVersion_.second ) {
349  psuVersion_.first = (*istate)->getDcuPsuMapVersionMajorId();
350  psuVersion_.second = (*istate)->getDcuPsuMapVersionMinorId();
351  }
352  //#ifdef USING_DATABASE_MASKING
353  if ( !forceVersions_ &&
354  !maskVersion_.first &&
355  !maskVersion_.second ) {
356  maskVersion_.first = (*istate)->getMaskVersionMajorId();
357  maskVersion_.second = (*istate)->getMaskVersionMinorId();
358  }
359  //#endif
360 
361  // Retrieve global and local versions
362  if ( forceCurrentState_ || globalAnalysisV_ ) { // use global version (or current state)
363 
364  // Set global version
365  if ( forceCurrentState_ ) { globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId(); }
366 
367  // Retrieve local versions
368  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions( globalAnalysisV_ );
369 
370  // Iterate through map< AnalysisType, pair<Major,Minor> >
371  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
372  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
373  for ( ; ivers != jvers; ++ivers ) {
374  if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
375  fastCablingV_.first = ivers->second.first;
376  fastCablingV_.second = ivers->second.second;
377  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
378  apvTimingV_.first = ivers->second.first;
379  apvTimingV_.second = ivers->second.second;
380  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
381  optoScanV_.first = ivers->second.first;
382  optoScanV_.second = ivers->second.second;
383  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
384  vpspScanV_.first = ivers->second.first;
385  vpspScanV_.second = ivers->second.second;
386  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
387  apvCalibV_.first = ivers->second.first;
388  apvCalibV_.second = ivers->second.second;
389  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
390  pedestalsV_.first = ivers->second.first;
391  pedestalsV_.second = ivers->second.second;
392  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
393  pedsFullNoiseV_.first = ivers->second.first;
394  pedsFullNoiseV_.second = ivers->second.second;
395  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
396  apvLatencyV_.first = ivers->second.first;
397  apvLatencyV_.second = ivers->second.second;
398  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
399  fineDelayV_.first = ivers->second.first;
400  fineDelayV_.second = ivers->second.second;
401  } else if ( ivers->first == CommissioningAnalysisDescription::T_UNKNOWN ) {
402  std::stringstream ss;
404  << "[SiStripPartition::" << __func__ << "]"
405  << " Found UNKNOWN AnalysisType!";
406  edm::LogWarning(mlConfigDb_) << ss.str();
407  } else {
408  std::stringstream ss;
410  << "[SiStripPartition::" << __func__ << "]"
411  << " Unable to match content to any AnalysisType!";
412  edm::LogWarning(mlConfigDb_) << ss.str();
413  }
414  }
415 
416  } else if ( !globalAnalysisV_ ) { // use local versions
417 
418  // Retrieve local versions and set if necessary
419  globalAnalysisV_ = (*istate)->getAnalysisVersionMapPointerId();
420  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions( globalAnalysisV_ );
421 
422  // Iterate through map< AnalysisType, pair<Major,Minor> >
423  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
424  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
425  for ( ; ivers != jvers; ++ivers ) {
426  if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
427  if ( !fastCablingV_.first && !fastCablingV_.second ) {
428  fastCablingV_.first = ivers->second.first;
429  fastCablingV_.second = ivers->second.second;
430  }
431  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
432  if ( !apvTimingV_.first && !apvTimingV_.second ) {
433  apvTimingV_.first = ivers->second.first;
434  apvTimingV_.second = ivers->second.second;
435  }
436  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
437  if ( !optoScanV_.first && !optoScanV_.second ) {
438  optoScanV_.first = ivers->second.first;
439  optoScanV_.second = ivers->second.second;
440  }
441  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
442  if ( !vpspScanV_.first && !vpspScanV_.second ) {
443  vpspScanV_.first = ivers->second.first;
444  vpspScanV_.second = ivers->second.second;
445  }
446  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
447  if ( !apvCalibV_.first && !apvCalibV_.second ) {
448  apvCalibV_.first = ivers->second.first;
449  apvCalibV_.second = ivers->second.second;
450  }
451  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
452  if ( !pedestalsV_.first && !pedestalsV_.second ) {
453  pedestalsV_.first = ivers->second.first;
454  pedestalsV_.second = ivers->second.second;
455  }
456  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
457  if ( !pedsFullNoiseV_.first && !pedsFullNoiseV_.second ) {
458  pedsFullNoiseV_.first = ivers->second.first;
459  pedsFullNoiseV_.second = ivers->second.second;
460  }
461  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
462  if ( !apvLatencyV_.first && !apvLatencyV_.second ) {
463  apvLatencyV_.first = ivers->second.first;
464  apvLatencyV_.second = ivers->second.second;
465  }
466  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
467  if ( !fineDelayV_.first && !fineDelayV_.second ) {
468  fineDelayV_.first = ivers->second.first;
469  fineDelayV_.second = ivers->second.second;
470  }
471  } else if ( ivers->first == CommissioningAnalysisDescription::T_UNKNOWN ) {
472  std::stringstream ss;
474  << "[SiStripPartition::" << __func__ << "]"
475  << " Found UNKNOWN AnalysisType!";
476  edm::LogWarning(mlConfigDb_) << ss.str();
477  } else {
478  std::stringstream ss;
480  << "[SiStripPartition::" << __func__ << "]"
481  << " Unable to match content to any AnalysisType!";
482  edm::LogWarning(mlConfigDb_) << ss.str();
483  }
484  }
485 
486  }
487 
488  } else {
489  std::stringstream ss;
491  << "[SiStripPartition::" << __func__ << "]"
492  << " Unable to find \"current state\" for partition \""
493  << partitionName_ << "\"";
494  }
495 
496  } else { // ---------- USE RUN NUMBER ----------
497 
498  // Retrieve TkRun object for given run (0 means "latest run")
499  TkRun* run = nullptr;
500  if ( !runNumber_ ) { run = df->getLastRun( partitionName_ ); }
501  else { run = df->getRun( partitionName_, runNumber_ ); }
502 
503  // Retrieve versioning for given TkRun object
504  if ( run ) {
505 
506  if ( run->getRunNumber() ) {
507 
508  if ( !runNumber_ ) { runNumber_ = run->getRunNumber(); }
509 
510  if ( runNumber_ == run->getRunNumber() ) {
511 
512  cabVersion_.first = run->getConnectionVersionMajorId();
513  cabVersion_.second = run->getConnectionVersionMinorId();
514 
515  fecVersion_.first = run->getFecVersionMajorId();
516  fecVersion_.second = run->getFecVersionMinorId();
517 
518  fedVersion_.first = run->getFedVersionMajorId();
519  fedVersion_.second = run->getFedVersionMinorId();
520 
521  dcuVersion_.first = run->getDcuInfoVersionMajorId();
522  dcuVersion_.second = run->getDcuInfoVersionMinorId();
523 
524  psuVersion_.first = run->getDcuPsuMapVersionMajorId();
525  psuVersion_.second = run->getDcuPsuMapVersionMinorId();
526 
527  //#ifdef USING_DATABASE_MASKING
528  maskVersion_.first = run->getMaskVersionMajorId();
529  maskVersion_.second = run->getMaskVersionMinorId();
530  //#endif
531 
532  // Check run type
533  uint16_t type = run->getModeId( run->getMode() );
534  if ( type == 1 ) { runType_ = sistrip::PHYSICS; }
535  else if ( type == 2 ) { runType_ = sistrip::PEDESTALS; }
536  else if ( type == 3 ) { runType_ = sistrip::CALIBRATION; }
537  else if ( type == 33 ) { runType_ = sistrip::CALIBRATION_DECO; }
538  else if ( type == 4 ) { runType_ = sistrip::OPTO_SCAN; }
539  else if ( type == 5 ) { runType_ = sistrip::APV_TIMING; }
540  else if ( type == 6 ) { runType_ = sistrip::APV_LATENCY; }
541  else if ( type == 7 ) { runType_ = sistrip::FINE_DELAY_PLL; }
542  else if ( type == 8 ) { runType_ = sistrip::FINE_DELAY_TTC; }
543  else if ( type == 10 ) { runType_ = sistrip::MULTI_MODE; }
544  else if ( type == 12 ) { runType_ = sistrip::FED_TIMING; }
545  else if ( type == 13 ) { runType_ = sistrip::FED_CABLING; }
546  else if ( type == 14 ) { runType_ = sistrip::VPSP_SCAN; }
547  else if ( type == 15 ) { runType_ = sistrip::DAQ_SCOPE_MODE; }
548  else if ( type == 16 ) { runType_ = sistrip::QUITE_FAST_CABLING; }
549  else if ( type == 21 ) { runType_ = sistrip::FAST_CABLING; }
550  else if ( type == 0 ) {
553  << "[SiStripPartition::" << __func__ << "]"
554  << " NULL run type returned!"
555  << " for partition \"" << partitionName_ << "\"";
556  } else {
559  << "[SiStripPartition::" << __func__ << "]"
560  << " UNKNOWN run type (" << type<< ") returned!"
561  << " for partition \"" << partitionName_ << "\"";
562  }
563 
564  // Retrieve global and local versions from state associated with given run
565  globalAnalysisV_ = run->getAnalysisVersionMapPointerId();
566  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions( globalAnalysisV_ );
567  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
568  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
569  for ( ; ivers != jvers; ++ivers ) {
570  if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
571  fastCablingV_.first = ivers->second.first;
572  fastCablingV_.second = ivers->second.second;
573  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
574  apvTimingV_.first = ivers->second.first;
575  apvTimingV_.second = ivers->second.second;
576  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
577  optoScanV_.first = ivers->second.first;
578  optoScanV_.second = ivers->second.second;
579  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
580  vpspScanV_.first = ivers->second.first;
581  vpspScanV_.second = ivers->second.second;
582  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
583  apvCalibV_.first = ivers->second.first;
584  apvCalibV_.second = ivers->second.second;
585  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
586  pedestalsV_.first = ivers->second.first;
587  pedestalsV_.second = ivers->second.second;
588  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
589  pedsFullNoiseV_.first = ivers->second.first;
590  pedsFullNoiseV_.second = ivers->second.second;
591  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
592  apvLatencyV_.first = ivers->second.first;
593  apvLatencyV_.second = ivers->second.second;
594  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
595  fineDelayV_.first = ivers->second.first;
596  fineDelayV_.second = ivers->second.second;
597  } else if ( ivers->first == CommissioningAnalysisDescription::T_UNKNOWN ) {
598  std::stringstream ss;
600  << "[SiStripPartition::" << __func__ << "]"
601  << " Found UNKNOWN AnalysisType!";
602  edm::LogWarning(mlConfigDb_) << ss.str();
603  } else {
604  std::stringstream ss;
606  << "[SiStripPartition::" << __func__ << "]"
607  << " Unable to match content to any AnalysisType!";
608  edm::LogWarning(mlConfigDb_) << ss.str();
609  }
610  }
611 
612  // If commissioning run, override version of analysis type with version PRODUCED by run (from history)
613  if ( runType_ != sistrip::PHYSICS &&
616 
617  // Determine analysis type from run type
618  CommissioningAnalysisDescription::commissioningType type = CommissioningAnalysisDescription::T_UNKNOWN;
619  if ( runType_ == sistrip::FAST_CABLING ) { type = CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING; }
620  else if ( runType_ == sistrip::APV_TIMING ) { type = CommissioningAnalysisDescription::T_ANALYSIS_TIMING; }
621  else if ( runType_ == sistrip::OPTO_SCAN ) { type = CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN; }
622  else if ( runType_ == sistrip::VPSP_SCAN ) { type = CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN; }
623  else if ( runType_ == sistrip::CALIBRATION ) { type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION; }
624  else if ( runType_ == sistrip::PEDESTALS ) { type = CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS; }
625  else if ( runType_ == sistrip::PEDS_FULL_NOISE) { type = CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE; }
626  else if ( runType_ == sistrip::APV_LATENCY ) { type = CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY; }
627  else if ( runType_ == sistrip::FINE_DELAY_TTC ) { type = CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY; }
628 
629  // Retrieve local versions for COMMISSIONING runs from history
630  HashMapRunVersion local_versions = df->getAnalysisHistory( partitionName_, type );
631 
632  // Iterate through map< RunNumber, vector< pair<Major,Minor> > > to find appropriate run
633  HashMapRunVersion::const_iterator ivers = local_versions.end();
634  if ( runNumber_ == 0 ) { ivers = --(local_versions.end()); }
635  else { ivers = local_versions.find( runNumber_ ); }
636 
637  // Set appropriate versions
638  if ( ivers != local_versions.end() ) {
639  if ( type == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
641  fastCablingV_.first = ivers->second.back().first;
642  fastCablingV_.second = ivers->second.back().second;
643 
644  //@@
645 
646  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
648  apvTimingV_.first = ivers->second.back().first;
649  apvTimingV_.second = ivers->second.back().second;
650  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
652  optoScanV_.first = ivers->second.back().first;
653  optoScanV_.second = ivers->second.back().second;
654  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
656  vpspScanV_.first = ivers->second.back().first;
657  vpspScanV_.second = ivers->second.back().second;
658  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
660  apvCalibV_.first = ivers->second.back().first;
661  apvCalibV_.second = ivers->second.back().second;
662  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
664  pedestalsV_.first = ivers->second.back().first;
665  pedestalsV_.second = ivers->second.back().second;
666  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
668  pedsFullNoiseV_.first = ivers->second.back().first;
669  pedsFullNoiseV_.second = ivers->second.back().second;
670  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
672  apvLatencyV_.first = ivers->second.back().first;
673  apvLatencyV_.second = ivers->second.back().second;
674  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
676  fineDelayV_.first = ivers->second.back().first;
677  fineDelayV_.second = ivers->second.back().second;
678  } else if ( type == CommissioningAnalysisDescription::T_UNKNOWN ) {
679  std::stringstream ss;
681  << "[SiStripPartition::" << __func__ << "]"
682  << " Found UNKNOWN AnalysisType!";
683  edm::LogWarning(mlConfigDb_) << ss.str();
684  } else {
685  std::stringstream ss;
687  << "[SiStripPartition::" << __func__ << "]"
688  << " Unable to match content to any AnalysisType!";
689  edm::LogWarning(mlConfigDb_) << ss.str();
690  }
691  } else {
692  std::stringstream ss;
694  << "[SiStripPartition::" << __func__ << "]"
695  << " Unable to find run number " << runNumber_
696  << " in \"history\" hash map ";
697  edm::LogWarning(mlConfigDb_) << ss.str();
698  }
699 
700  }
701 
702  } else {
704  << "[SiStripPartition::" << __func__ << "]"
705  << " Mismatch of run number requested ("
706  << runNumber_
707  << ") and received ("
708  << run->getRunNumber() << ")"
709  << " to/from database for partition \""
710  << partitionName_ << "\"";
711  }
712 
713  } else {
715  << "[SiStripPartition::" << __func__ << "]"
716  << " NULL run number returned!"
717  << " for partition \"" << partitionName_ << "\"";
718  }
719 
720  } else {
722  << "[SiStripPartition::" << __func__ << "]"
723  << " NULL pointer to TkRun object!"
724  << " Unable to retrieve versions for run number "
725  << runNumber_
726  << ". Run number may not be consistent with partition \""
727  << partitionName_ << "\"!"; //@@ only using first here!!!
728  }
729 
730  }
731 
732  } catch (...) { db->handleException( __func__, "" ); }
733 
734 }
735 
736 // -----------------------------------------------------------------------------
737 //
738 void SiStripPartition::print( std::stringstream& ss, bool using_db ) const {
739 
740  ss << " Partition : \"" << partitionName_ << "\"" << std::endl;
741 
742  if ( using_db ) {
743 
744  ss << " Run number : ";
745  if ( forceCurrentState_ ) { ss << "Forced \"current state\"! (equivalent to versions below)"; }
746  else if ( forceVersions_ ) { ss << "Forced versions specified below!"; }
747  else /* use run number */ { ss << runNumber_; }
748 
749  ss << std::endl;
750  if ( !forceVersions_ ) {
751  ss << " Run type : " << SiStripEnumsAndStrings::runType( runType_ ) << std::endl;
752  }
753 
754  ss << " Cabling major/minor vers : " << cabVersion_.first << "." << cabVersion_.second << std::endl
755  << " FEC major/minor vers : " << fecVersion_.first << "." << fecVersion_.second << std::endl
756  << " FED major/minor vers : " << fedVersion_.first << "." << fedVersion_.second << std::endl
757  << " DCU-DetId map maj/min vers : " << dcuVersion_.first << "." << dcuVersion_.second << std::endl
758  //#ifdef USING_DATABASE_MASKING
759  << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl
760  << " Mask maj/min vers : " << maskVersion_.first << "." << maskVersion_.second << std::endl;
761  //#else
762  // << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl;
763  //#endif
764 
765  ss << " Global analysis version : " << globalAnalysisV_ << std::endl;
766 
767 
768  if ( runType_ == sistrip::PHYSICS ||
771 
772  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
773  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
774  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
775  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
776  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
777  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
778  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second << std::endl;
779  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
780  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
781 
782  } else {
783 
784  if ( runType_ != sistrip::FAST_CABLING ) {
785  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
786  } else {
787  ss << " FED cabling maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
788  << " <= This \"state\" version overriden by \"history\" version "
789  << fastCablingV_.first << "." << fastCablingV_.second
790  << " for this FED cabling run!" << std::endl;
791  }
792 
793  if ( runType_ != sistrip::APV_TIMING ) {
794  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
795  } else {
796  ss << " APV timing maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
797  << " <= This \"state\" version overriden by \"history\" version "
798  << apvTimingV_.first << "." << apvTimingV_.second
799  << " for this APV timing run!" << std::endl;
800  }
801 
802  if ( runType_ != sistrip::OPTO_SCAN ) {
803  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
804  } else {
805  ss << " Opto scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
806  << " <= This \"state\" version overriden by \"history\" version "
807  << optoScanV_.first << "." << optoScanV_.second
808  << " for this opto scan run!" << std::endl;
809  }
810 
811  if ( runType_ != sistrip::VPSP_SCAN ) {
812  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
813  } else {
814  ss << " VPSP scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
815  << " <= This \"state\" version overriden by \"history\" version "
816  << vpspScanV_.first << "." << vpspScanV_.second
817  << " for this VPSP scan run!" << std::endl;
818  }
819 
820  if ( runType_ != sistrip::CALIBRATION ) {
821  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
822  } else {
823  ss << " APV calib maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
824  << " <= This \"state\" version overriden by \"history\" version "
825  << apvCalibV_.first << "." << apvCalibV_.second
826  << " for this APV calib run!" << std::endl;
827  }
828 
829  if ( runType_ != sistrip::PEDESTALS ) {
830  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
831  } else {
832  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
833  << " <= This \"state\" version overriden by \"history\" version "
834  << pedestalsV_.first << "." << pedestalsV_.second
835  << " for this pedestals run!" << std::endl;
836  }
837 
839  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second << std::endl;
840  } else {
841  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
842  << " <= This \"state\" version overriden by \"history\" version "
843  << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
844  << " for this pedestals run!" << std::endl;
845  }
846 
847  if ( runType_ != sistrip::APV_LATENCY ) {
848  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
849  } else {
850  ss << " APV latency maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
851  << " <= This \"state\" version overriden by \"history\" version "
852  << apvLatencyV_.first << "." << apvLatencyV_.second
853  << " for this APV latency run!" << std::endl;
854  }
855 
856  if ( runType_ != sistrip::FINE_DELAY_TTC ) {
857  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
858  } else {
859  ss << " Fine delay maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
860  << " <= This \"state\" version overriden by \"history\" version "
861  << fineDelayV_.first << "." << fineDelayV_.second
862  << " for this fine delay run!" << std::endl;
863  }
864 
865  }
866 
867  } else {
868 
869  ss << " Input \"module.xml\" file : " << inputModuleXml_ << std::endl
870  << " Input \"dcuinfo.xml\" file : " << inputDcuInfoXml_ << std::endl
871  << " Input \"fec.xml\" file(s) : ";
872  std::vector<std::string>::const_iterator ifec = inputFecXml_.begin();
873  for ( ; ifec != inputFecXml_.end(); ifec++ ) { ss << *ifec << ", "; }
874  ss << std::endl;
875  ss << " Input \"fed.xml\" file(s) : ";
876  std::vector<std::string>::const_iterator ifed = inputFedXml_.begin();
877  for ( ; ifed != inputFedXml_.end(); ifed++ ) { ss << *ifed << ", "; }
878  ss << std::endl;
879 
880  }
881 
882 }
883 
884 // -----------------------------------------------------------------------------
885 //
886 std::ostream& operator<< ( std::ostream& os, const SiStripPartition& params ) {
887  std::stringstream ss;
888  params.print(ss);
889  os << ss.str();
890  return os;
891 }
892 
893 // -----------------------------------------------------------------------------
894 //
895 SiStripPartition::Versions SiStripPartition::versions( const std::vector<uint32_t>& _input ) {
896  std::vector<uint32_t> input = _input;
897  if ( input.size() != 2 ) {
899  << "[SiStripPartition::" << __func__ << "]"
900  << " Unexpected size (" << input.size()
901  << ") for vector containing version numbers (major,minor)!"
902  << " Resizing to 2 elements (default values will be 0,0)...";
903  input.resize(2,0);
904  }
905  return std::make_pair( input[0], input[1] );
906 }
static const char runNumber_[]
sistrip::RunType runType_
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
static const std::string defaultPartitionName_
Versions maskVersion() const
Versions pedestalsVersion() const
Versions vpspScanVersion() const
DeviceFactory *const deviceFactory(std::string method_name="") const
Versions fineDelayVersion() const
Versions optoScanVersion() const
std::string partitionName() const
void handleException(const std::string &method_name, const std::string &extra_info="") const
bool operator!=(const SiStripPartition &) const
std::string partitionName_
uint32_t runNumber() const
uint32_t globalAnalysisVersion() const
void print(std::stringstream &, bool using_db=false) const
std::pair< uint32_t, uint32_t > Versions
sistrip classes
static std::string const input
Definition: EdmProvDump.cc:44
static const char mlConfigDb_[]
std::ostream & operator<<(std::ostream &os, const SiStripPartition &params)
static std::string runType(const sistrip::RunType &)
Versions apvTimingVersion() const
Versions apvLatencyVersion() const
void pset(const edm::ParameterSet &)
Versions versions(const std::vector< uint32_t > &)
An interface class to the DeviceFactory.
Container class for database partition parameters.
std::vector< std::string > inputFedXml_
Versions runTableVersion() const
#define LogTrace(id)
std::vector< std::string > inputFecXml() const
bool forceCurrentState() const
Versions pedsFullNoiseVersion() const
std::string inputDcuInfoXml_
std::string inputModuleXml_
Versions apvCalibVersion() const
std::vector< std::string > inputFecXml_
void update(const SiStripConfigDb *const )
bool operator==(const SiStripPartition &) const
std::vector< std::string > inputFedXml() const
Versions dcuVersion() const
bool forceVersions() const
SiStripPartition & operator=(const SiStripPartition &)
Versions psuVersion() const
sistrip::RunType runType() const
Versions fecVersion() const
Versions cabVersion() const
Versions fedVersion() const
std::string inputDcuInfoXml() const
std::string inputModuleXml() const
Versions fastCablingVersion() const