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 == 4 ) { runType_ = sistrip::OPTO_SCAN; }
538  else if ( type == 5 ) { runType_ = sistrip::APV_TIMING; }
539  else if ( type == 6 ) { runType_ = sistrip::APV_LATENCY; }
540  else if ( type == 7 ) { runType_ = sistrip::FINE_DELAY_PLL; }
541  else if ( type == 8 ) { runType_ = sistrip::FINE_DELAY_TTC; }
542  else if ( type == 10 ) { runType_ = sistrip::MULTI_MODE; }
543  else if ( type == 12 ) { runType_ = sistrip::FED_TIMING; }
544  else if ( type == 13 ) { runType_ = sistrip::FED_CABLING; }
545  else if ( type == 14 ) { runType_ = sistrip::VPSP_SCAN; }
546  else if ( type == 15 ) { runType_ = sistrip::DAQ_SCOPE_MODE; }
547  else if ( type == 16 ) { runType_ = sistrip::QUITE_FAST_CABLING; }
548  else if ( type == 17 ) { runType_ = sistrip::FINE_DELAY; }
549  else if ( type == 18 ) { runType_ = sistrip::PHYSICS_ZS; }
550  else if ( type == 19 ) { runType_ = sistrip::CALIBRATION_SCAN; }
551  else if ( type == 20 ) { runType_ = sistrip::CALIBRATION_SCAN_DECO; }
552  else if ( type == 21 ) { runType_ = sistrip::FAST_CABLING; }
553  else if ( type == 22 ) { runType_ = sistrip::PEDS_ONLY; }
554  else if ( type == 23 ) { runType_ = sistrip::NOISE; }
555  else if ( type == 24 ) { runType_ = sistrip::PEDS_FULL_NOISE; }
556  else if ( type == 33 ) { runType_ = sistrip::CALIBRATION_DECO; }
557  else if ( type == 0 ) {
560  << "[SiStripPartition::" << __func__ << "]"
561  << " NULL run type returned!"
562  << " for partition \"" << partitionName_ << "\"";
563  } else {
566  << "[SiStripPartition::" << __func__ << "]"
567  << " UNKNOWN run type (" << type<< ") returned!"
568  << " for partition \"" << partitionName_ << "\"";
569  }
570 
571  // Retrieve global and local versions from state associated with given run
572  globalAnalysisV_ = run->getAnalysisVersionMapPointerId();
573  HashMapAnalysisVersions local_versions = df->getLocalAnalysisVersions( globalAnalysisV_ );
574  HashMapAnalysisVersions::const_iterator ivers = local_versions.begin();
575  HashMapAnalysisVersions::const_iterator jvers = local_versions.end();
576  for ( ; ivers != jvers; ++ivers ) {
577  if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
578  fastCablingV_.first = ivers->second.first;
579  fastCablingV_.second = ivers->second.second;
580  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
581  apvTimingV_.first = ivers->second.first;
582  apvTimingV_.second = ivers->second.second;
583  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
584  optoScanV_.first = ivers->second.first;
585  optoScanV_.second = ivers->second.second;
586  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
587  vpspScanV_.first = ivers->second.first;
588  vpspScanV_.second = ivers->second.second;
589  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
590  apvCalibV_.first = ivers->second.first;
591  apvCalibV_.second = ivers->second.second;
592  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
593  pedestalsV_.first = ivers->second.first;
594  pedestalsV_.second = ivers->second.second;
595  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
596  pedsFullNoiseV_.first = ivers->second.first;
597  pedsFullNoiseV_.second = ivers->second.second;
598  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
599  apvLatencyV_.first = ivers->second.first;
600  apvLatencyV_.second = ivers->second.second;
601  } else if ( ivers->first == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
602  fineDelayV_.first = ivers->second.first;
603  fineDelayV_.second = ivers->second.second;
604  } else if ( ivers->first == CommissioningAnalysisDescription::T_UNKNOWN ) {
605  std::stringstream ss;
607  << "[SiStripPartition::" << __func__ << "]"
608  << " Found UNKNOWN AnalysisType!";
609  edm::LogWarning(mlConfigDb_) << ss.str();
610  } else {
611  std::stringstream ss;
613  << "[SiStripPartition::" << __func__ << "]"
614  << " Unable to match content to any AnalysisType!";
615  edm::LogWarning(mlConfigDb_) << ss.str();
616  }
617  }
618 
619  // If commissioning run, override version of analysis type with version PRODUCED by run (from history)
620  if ( runType_ != sistrip::PHYSICS &&
623 
624  // Determine analysis type from run type
625  CommissioningAnalysisDescription::commissioningType type = CommissioningAnalysisDescription::T_UNKNOWN;
626  if ( runType_ == sistrip::FAST_CABLING ) { type = CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING; }
627  else if ( runType_ == sistrip::APV_TIMING ) { type = CommissioningAnalysisDescription::T_ANALYSIS_TIMING; }
628  else if ( runType_ == sistrip::OPTO_SCAN ) { type = CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN; }
629  else if ( runType_ == sistrip::VPSP_SCAN ) { type = CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN; }
630  else if ( runType_ == sistrip::CALIBRATION ) { type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION; }
631  else if ( runType_ == sistrip::CALIBRATION_SCAN ) { type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION; }
632  else if ( runType_ == sistrip::CALIBRATION_DECO ) { type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION; }
633  else if ( runType_ == sistrip::CALIBRATION_SCAN_DECO ) { type = CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION; }
634  else if ( runType_ == sistrip::PEDESTALS ) { type = CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS; }
635  else if ( runType_ == sistrip::PEDS_FULL_NOISE) { type = CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE; }
636  else if ( runType_ == sistrip::APV_LATENCY ) { type = CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY; }
637  else if ( runType_ == sistrip::FINE_DELAY_TTC ) { type = CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY; }
638 
639  // Retrieve local versions for COMMISSIONING runs from history
640  HashMapRunVersion local_versions = df->getAnalysisHistory( partitionName_, type );
641 
642  // Iterate through map< RunNumber, vector< pair<Major,Minor> > > to find appropriate run
643  HashMapRunVersion::const_iterator ivers = local_versions.end();
644  if ( runNumber_ == 0 ) { ivers = --(local_versions.end()); }
645  else { ivers = local_versions.find( runNumber_ ); }
646 
647  // Set appropriate versions
648  if ( ivers != local_versions.end() ) {
649  if ( type == CommissioningAnalysisDescription::T_ANALYSIS_FASTFEDCABLING ) {
651  fastCablingV_.first = ivers->second.back().first;
652  fastCablingV_.second = ivers->second.back().second;
653 
654  //@@
655 
656  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_TIMING ) {
658  apvTimingV_.first = ivers->second.back().first;
659  apvTimingV_.second = ivers->second.back().second;
660  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_OPTOSCAN ) {
662  optoScanV_.first = ivers->second.back().first;
663  optoScanV_.second = ivers->second.back().second;
664  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_VPSPSCAN ) {
666  vpspScanV_.first = ivers->second.back().first;
667  vpspScanV_.second = ivers->second.back().second;
668  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_CALIBRATION ) {
670  apvCalibV_.first = ivers->second.back().first;
671  apvCalibV_.second = ivers->second.back().second;
672  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_PEDESTALS ) {
674  pedestalsV_.first = ivers->second.back().first;
675  pedestalsV_.second = ivers->second.back().second;
676  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_PEDSFULLNOISE ) {
678  pedsFullNoiseV_.first = ivers->second.back().first;
679  pedsFullNoiseV_.second = ivers->second.back().second;
680  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_APVLATENCY ) {
682  apvLatencyV_.first = ivers->second.back().first;
683  apvLatencyV_.second = ivers->second.back().second;
684  } else if ( type == CommissioningAnalysisDescription::T_ANALYSIS_FINEDELAY ) {
686  fineDelayV_.first = ivers->second.back().first;
687  fineDelayV_.second = ivers->second.back().second;
688  } else if ( type == CommissioningAnalysisDescription::T_UNKNOWN ) {
689  std::stringstream ss;
691  << "[SiStripPartition::" << __func__ << "]"
692  << " Found UNKNOWN AnalysisType!";
693  edm::LogWarning(mlConfigDb_) << ss.str();
694  } else {
695  std::stringstream ss;
697  << "[SiStripPartition::" << __func__ << "]"
698  << " Unable to match content to any AnalysisType!";
699  edm::LogWarning(mlConfigDb_) << ss.str();
700  }
701  } else {
702  std::stringstream ss;
704  << "[SiStripPartition::" << __func__ << "]"
705  << " Unable to find run number " << runNumber_
706  << " in \"history\" hash map ";
707  edm::LogWarning(mlConfigDb_) << ss.str();
708  }
709 
710  }
711 
712  } else {
714  << "[SiStripPartition::" << __func__ << "]"
715  << " Mismatch of run number requested ("
716  << runNumber_
717  << ") and received ("
718  << run->getRunNumber() << ")"
719  << " to/from database for partition \""
720  << partitionName_ << "\"";
721  }
722 
723  } else {
725  << "[SiStripPartition::" << __func__ << "]"
726  << " NULL run number returned!"
727  << " for partition \"" << partitionName_ << "\"";
728  }
729 
730  } else {
732  << "[SiStripPartition::" << __func__ << "]"
733  << " NULL pointer to TkRun object!"
734  << " Unable to retrieve versions for run number "
735  << runNumber_
736  << ". Run number may not be consistent with partition \""
737  << partitionName_ << "\"!"; //@@ only using first here!!!
738  }
739 
740  }
741 
742  } catch (...) { db->handleException( __func__, "" ); }
743 
744 }
745 
746 // -----------------------------------------------------------------------------
747 //
748 void SiStripPartition::print( std::stringstream& ss, bool using_db ) const {
749 
750  ss << " Partition : \"" << partitionName_ << "\"" << std::endl;
751 
752  if ( using_db ) {
753 
754  ss << " Run number : ";
755  if ( forceCurrentState_ ) { ss << "Forced \"current state\"! (equivalent to versions below)"; }
756  else if ( forceVersions_ ) { ss << "Forced versions specified below!"; }
757  else /* use run number */ { ss << runNumber_; }
758 
759  ss << std::endl;
760  if ( !forceVersions_ ) {
761  ss << " Run type : " << SiStripEnumsAndStrings::runType( runType_ ) << std::endl;
762  }
763 
764  ss << " Cabling major/minor vers : " << cabVersion_.first << "." << cabVersion_.second << std::endl
765  << " FEC major/minor vers : " << fecVersion_.first << "." << fecVersion_.second << std::endl
766  << " FED major/minor vers : " << fedVersion_.first << "." << fedVersion_.second << std::endl
767  << " DCU-DetId map maj/min vers : " << dcuVersion_.first << "." << dcuVersion_.second << std::endl
768  //#ifdef USING_DATABASE_MASKING
769  << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl
770  << " Mask maj/min vers : " << maskVersion_.first << "." << maskVersion_.second << std::endl;
771  //#else
772  // << " DCU-PSU map maj/min vers : " << psuVersion_.first << "." << psuVersion_.second << std::endl;
773  //#endif
774 
775  ss << " Global analysis version : " << globalAnalysisV_ << std::endl;
776 
777 
778  if ( runType_ == sistrip::PHYSICS ||
781 
782  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
783  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
784  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
785  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
786  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
787  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
788  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second << std::endl;
789  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
790  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
791 
792  } else {
793 
794  if ( runType_ != sistrip::FAST_CABLING ) {
795  ss << " FED cabling maj/min vers : " << fastCablingV_.first << "." << fastCablingV_.second << std::endl;
796  } else {
797  ss << " FED cabling maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
798  << " <= This \"state\" version overriden by \"history\" version "
799  << fastCablingV_.first << "." << fastCablingV_.second
800  << " for this FED cabling run!" << std::endl;
801  }
802 
803  if ( runType_ != sistrip::APV_TIMING ) {
804  ss << " APV timing maj/min vers : " << apvTimingV_.first << "." << apvTimingV_.second << std::endl;
805  } else {
806  ss << " APV timing maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
807  << " <= This \"state\" version overriden by \"history\" version "
808  << apvTimingV_.first << "." << apvTimingV_.second
809  << " for this APV timing run!" << std::endl;
810  }
811 
812  if ( runType_ != sistrip::OPTO_SCAN ) {
813  ss << " Opto scan maj/min vers : " << optoScanV_.first << "." << optoScanV_.second << std::endl;
814  } else {
815  ss << " Opto scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
816  << " <= This \"state\" version overriden by \"history\" version "
817  << optoScanV_.first << "." << optoScanV_.second
818  << " for this opto scan run!" << std::endl;
819  }
820 
821  if ( runType_ != sistrip::VPSP_SCAN ) {
822  ss << " VPSP scan maj/min vers : " << vpspScanV_.first << "." << vpspScanV_.second << std::endl;
823  } else {
824  ss << " VPSP scan maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
825  << " <= This \"state\" version overriden by \"history\" version "
826  << vpspScanV_.first << "." << vpspScanV_.second
827  << " for this VPSP scan run!" << std::endl;
828  }
829 
830  if ( runType_ != sistrip::CALIBRATION and
834  ss << " APV calib maj/min vers : " << apvCalibV_.first << "." << apvCalibV_.second << std::endl;
835  } else {
836  ss << " APV calib maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
837  << " <= This \"state\" version overriden by \"history\" version "
838  << apvCalibV_.first << "." << apvCalibV_.second
839  << " for this APV calib run!" << std::endl;
840  }
841 
842  if ( runType_ != sistrip::PEDESTALS ) {
843  ss << " Pedestals maj/min vers : " << pedestalsV_.first << "." << pedestalsV_.second << std::endl;
844  } else {
845  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
846  << " <= This \"state\" version overriden by \"history\" version "
847  << pedestalsV_.first << "." << pedestalsV_.second
848  << " for this pedestals run!" << std::endl;
849  }
850 
852  ss << " PedsFullNoise maj/min vers : " << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second << std::endl;
853  } else {
854  ss << " Pedestals maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
855  << " <= This \"state\" version overriden by \"history\" version "
856  << pedsFullNoiseV_.first << "." << pedsFullNoiseV_.second
857  << " for this pedestals run!" << std::endl;
858  }
859 
860  if ( runType_ != sistrip::APV_LATENCY ) {
861  ss << " APV latency maj/min vers : " << apvLatencyV_.first << "." << apvLatencyV_.second << std::endl;
862  } else {
863  ss << " APV latency maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
864  << " <= This \"state\" version overriden by \"history\" version "
865  << apvLatencyV_.first << "." << apvLatencyV_.second
866  << " for this APV latency run!" << std::endl;
867  }
868 
869  if ( runType_ != sistrip::FINE_DELAY_TTC ) {
870  ss << " Fine delay maj/min vers : " << fineDelayV_.first << "." << fineDelayV_.second << std::endl;
871  } else {
872  ss << " Fine delay maj/min vers : " << runTableVersion_.first << "." << runTableVersion_.second
873  << " <= This \"state\" version overriden by \"history\" version "
874  << fineDelayV_.first << "." << fineDelayV_.second
875  << " for this fine delay run!" << std::endl;
876  }
877 
878  }
879 
880  } else {
881 
882  ss << " Input \"module.xml\" file : " << inputModuleXml_ << std::endl
883  << " Input \"dcuinfo.xml\" file : " << inputDcuInfoXml_ << std::endl
884  << " Input \"fec.xml\" file(s) : ";
885  std::vector<std::string>::const_iterator ifec = inputFecXml_.begin();
886  for ( ; ifec != inputFecXml_.end(); ifec++ ) { ss << *ifec << ", "; }
887  ss << std::endl;
888  ss << " Input \"fed.xml\" file(s) : ";
889  std::vector<std::string>::const_iterator ifed = inputFedXml_.begin();
890  for ( ; ifed != inputFedXml_.end(); ifed++ ) { ss << *ifed << ", "; }
891  ss << std::endl;
892 
893  }
894 
895 }
896 
897 // -----------------------------------------------------------------------------
898 //
899 std::ostream& operator<< ( std::ostream& os, const SiStripPartition& params ) {
900  std::stringstream ss;
901  params.print(ss);
902  os << ss.str();
903  return os;
904 }
905 
906 // -----------------------------------------------------------------------------
907 //
908 SiStripPartition::Versions SiStripPartition::versions( const std::vector<uint32_t>& _input ) {
909  std::vector<uint32_t> input = _input;
910  if ( input.size() != 2 ) {
912  << "[SiStripPartition::" << __func__ << "]"
913  << " Unexpected size (" << input.size()
914  << ") for vector containing version numbers (major,minor)!"
915  << " Resizing to 2 elements (default values will be 0,0)...";
916  input.resize(2,0);
917  }
918  return std::make_pair( input[0], input[1] );
919 }
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:48
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