test
CMS 3D CMS Logo

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