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