CMS 3D CMS Logo

PedeLabelerBase.cc
Go to the documentation of this file.
1 
13 
16 
18 
19 // NOTE: Changing '+14' makes older binary files unreadable...
21 // NOTE: Changing the offset of '700000' makes older binary files unreadable...
22 const unsigned int PedeLabelerBase::theParamInstanceOffset = 700000;
23 const unsigned int PedeLabelerBase::theMinLabel = 1; // must be > 0
24 
26  const edm::ParameterSet &config) :
27  theOpenRunRange(std::make_pair<RunNumber,RunNumber>(RunNumber(cond::timeTypeSpecs[cond::runnumber].beginValue), // since we know we have a runnumber here, we can
28  RunNumber(cond::timeTypeSpecs[cond::runnumber].endValue))), // simply convert the Time_t to make the compiler happy
29  topLevelAlignables_(alignables),
30  alignableObjectId_{AlignableObjectId::commonObjectIdProvider(alignables.aliTracker_,
31  alignables.aliMuon_)}
32 {
33 
34 }
35 
36 //___________________________________________________________________________
37 std::pair<IntegratedCalibrationBase*, unsigned int>
39 {
40  // Quick check whether label is in range of calibration labels:
41  if (!theCalibrationLabels.empty() && label >= theCalibrationLabels.front().second) {
42  // Loop on all known IntegratedCalibration's:
43  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
44  if (label >= iCal->second && label < iCal->second + iCal->first->numParameters()) {
45  // Label fits in range for this calibration, so return calibration
46  // and subtract first label of this calibration from label.
47  return std::make_pair(iCal->first, label - iCal->second);
48  }
49  }
50  edm::LogError("LogicError") << "@SUB=PedeLabelerBase::calibrationParamFromLabel"
51  << "Label " << label << "larger than first calibration's label, "
52  << "but no calibration fits!";
53  }
54 
55  // Return that nothing fits:
56  return std::pair<IntegratedCalibrationBase*, unsigned int>(nullptr,0);
57 }
58 
59 //___________________________________________________________________________
60 unsigned int PedeLabelerBase::firstFreeLabel() const
61 {
62  unsigned int nextId = this->firstNonAlignableLabel();
63 
64  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
65  nextId += iCal->first->numParameters();
66  }
67 
68  return nextId;
69 }
70 
71 //___________________________________________________________________________
73 {
74 
75  return this->parameterInstanceOffset() * this->maxNumberOfParameterInstances() + 1;
76 }
77 
78 //___________________________________________________________________________
80  unsigned int paramNum) const
81 {
82  if (!calib) {
83  throw cms::Exception("LogicError") << "PedeLabelerBase::calibrationLabel: "
84  << "nullPtr passed!\n";
85  }
86 
87  // loop on all known IntegratedCalibration's
88  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
89  if (iCal->first == calib) { // found IntegratedCalibrationBase
90  if (paramNum < iCal->first->numParameters()) {
91  return iCal->second + paramNum;
92  } else { // paramNum out of range!
93  edm::LogError("LogicError")
94  << "@SUB=PedeLabelerBase::calibrationLabel" << "IntegratedCalibration "
95  << calib->name() << " has only " << iCal->first->numParameters()
96  << " parameters, but " << paramNum << "requested!";
97  }
98  }
99  }
100 
101  edm::LogError("LogicError")
102  << "@SUB=PedeLabelerBase::calibrationLabel" << "IntegratedCalibration "
103  << calib->name() << " not known or too few parameters.";
104 
105  return 0;
106 }
107 
108 //___________________________________________________________________________
109 void PedeLabelerBase::addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals)
110 {
111  unsigned int nextId = this->firstFreeLabel(); // so far next free label
112 
113  // Now foresee labels for new calibrations:
114  for (auto iCal = iCals.begin(); iCal != iCals.end(); ++iCal) {
115  if (*iCal) {
116  theCalibrationLabels.push_back(std::make_pair(*iCal, nextId));
117  nextId += (*iCal)->numParameters();
118  } else {
119  edm::LogError("LogicError")
120  << "@SUB=PedeLabelerBase::addCalibrations" << "Ignoring nullPtr.";
121  }
122  }
123 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
std::vector< std::pair< IntegratedCalibrationBase *, unsigned int > > theCalibrationLabels
pairs of calibrations and their first label
static AlignableObjectId commonObjectIdProvider(const AlignableObjectId &, const AlignableObjectId &)
static const unsigned int theMinLabel
const std::string & name() const
name of this calibration
virtual unsigned int firstNonAlignableLabel() const
Definition: config.py:1
virtual unsigned int maxNumberOfParameterInstances() const =0
returns the maximum number of instances for any parameter of an Alignable*
static const unsigned int theMaxNumParam
PedeLabelerBase(const TopLevelAlignables &alignables, const edm::ParameterSet &config)
constructor from three Alignables (null pointers allowed )
U second(std::pair< T, U > const &p)
align::RunNumber RunNumber
unsigned int parameterInstanceOffset() const
offset in labels between consecutive parameter instances of Alignable*s
static const unsigned int theParamInstanceOffset
virtual unsigned int calibrationLabel(const IntegratedCalibrationBase *calib, unsigned int paramNum) const
label for parameter &#39;paramNum&#39; (counted from 0) of an integrated calibration
virtual unsigned int firstFreeLabel() const
Definition: plugin.cc:24
virtual void addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals)
tell labeler to treat also integrated calibrations
virtual std::pair< IntegratedCalibrationBase *, unsigned int > calibrationParamFromLabel(unsigned int label) const