CMS 3D CMS Logo

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