CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
27  :theOpenRunRange(std::make_pair<RunNumber,RunNumber>(cond::timeTypeSpecs[cond::runnumber].beginValue,
28  cond::timeTypeSpecs[cond::runnumber].endValue))
29 {
30 
31 }
32 
33 //___________________________________________________________________________
34 std::pair<IntegratedCalibrationBase*, unsigned int>
36 {
37  // Quick check whether label is in range of calibration labels:
38  if (!theCalibrationLabels.empty() && label >= theCalibrationLabels.front().second) {
39  // Loop on all known IntegratedCalibration's:
40  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
41  if (label >= iCal->second && label < iCal->second + iCal->first->numParameters()) {
42  // Label fits in range for this calibration, so return calibration
43  // and subtract first label of this calibration from label.
44  return std::make_pair(iCal->first, label - iCal->second);
45  }
46  }
47  edm::LogError("LogicError") << "@SUB=PedeLabelerBase::calibrationParamFromLabel"
48  << "Label " << label << "larger than first calibration's label, "
49  << "but no calibration fits!";
50  }
51 
52  // Return that nothing fits:
53  return std::pair<IntegratedCalibrationBase*, unsigned int>(0,0);
54 }
55 
56 //___________________________________________________________________________
57 unsigned int PedeLabelerBase::firstFreeLabel() const
58 {
59  unsigned int nextId = this->firstNonAlignableLabel();
60 
61  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
62  nextId += iCal->first->numParameters();
63  }
64 
65  return nextId;
66 }
67 
68 //___________________________________________________________________________
70 {
71 
72  return this->parameterInstanceOffset() * this->maxNumberOfParameterInstances() + 1;
73 }
74 
75 //___________________________________________________________________________
77  unsigned int paramNum) const
78 {
79  if (!calib) {
80  throw cms::Exception("LogicError") << "PedeLabelerBase::calibrationLabel: "
81  << "nullPtr passed!\n";
82  }
83 
84  // loop on all known IntegratedCalibration's
85  for (auto iCal = theCalibrationLabels.begin(); iCal != theCalibrationLabels.end(); ++iCal) {
86  if (iCal->first == calib) { // found IntegratedCalibrationBase
87  if (paramNum < iCal->first->numParameters()) {
88  return iCal->second + paramNum;
89  } else { // paramNum out of range!
90  edm::LogError("LogicError")
91  << "@SUB=PedeLabelerBase::calibrationLabel" << "IntegratedCalibration "
92  << calib->name() << " has only " << iCal->first->numParameters()
93  << " parameters, but " << paramNum << "requested!";
94  }
95  }
96  }
97 
98  edm::LogError("LogicError")
99  << "@SUB=PedeLabelerBase::calibrationLabel" << "IntegratedCalibration "
100  << calib->name() << " not known or too few parameters.";
101 
102  return 0;
103 }
104 
105 //___________________________________________________________________________
106 void PedeLabelerBase::addCalibrations(const std::vector<IntegratedCalibrationBase*> &iCals)
107 {
108  unsigned int nextId = this->firstFreeLabel(); // so far next free label
109 
110  // Now foresee labels for new calibrations:
111  for (auto iCal = iCals.begin(); iCal != iCals.end(); ++iCal) {
112  if (*iCal) {
113  theCalibrationLabels.push_back(std::make_pair(*iCal, nextId));
114  nextId += (*iCal)->numParameters();
115  } else {
116  edm::LogError("LogicError")
117  << "@SUB=PedeLabelerBase::addCalibrations" << "Ignoring nullPtr.";
118  }
119  }
120 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
AlignmentAlgorithmBase::RunNumber RunNumber
std::vector< std::pair< IntegratedCalibrationBase *, unsigned int > > theCalibrationLabels
pairs of calibrations and their first label
static const unsigned int theMinLabel
const std::string & name() const
name of this calibration
virtual unsigned int firstNonAlignableLabel() const
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)
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
unsigned int parameterInstanceOffset() const
offset in labels between consecutive parameter instances of Alignable*s
bool first
Definition: L1TdeRCT.cc:79
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
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
virtual unsigned int maxNumberOfParameterInstances() const =0
returns the maximum number of instances for any parameter of an Alignable*