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 }
PedeLabelerBase::parameterInstanceOffset
unsigned int parameterInstanceOffset() const
offset in labels between consecutive parameter instances of Alignable*s
Definition: PedeLabelerBase.h:81
PedeLabelerBase::firstNonAlignableLabel
virtual unsigned int firstNonAlignableLabel() const
Definition: PedeLabelerBase.cc:70
MessageLogger.h
PedeLabelerBase::theCalibrationLabels
std::vector< std::pair< IntegratedCalibrationBase *, unsigned int > > theCalibrationLabels
pairs of calibrations and their first label
Definition: PedeLabelerBase.h:127
IntegratedCalibrationBase
Definition: IntegratedCalibrationBase.h:40
AlignableObjectId::commonObjectIdProvider
static AlignableObjectId commonObjectIdProvider(const AlignableObjectId &, const AlignableObjectId &)
Definition: AlignableObjectId.cc:320
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
PedeLabelerBase::TopLevelAlignables::aliTracker_
AlignableTracker * aliTracker_
Definition: PedeLabelerBase.h:43
dqmdumpme.first
first
Definition: dqmdumpme.py:55
PedeLabelerBase.h
RigidBodyAlignmentParameters.h
RigidBodyAlignmentParameters::N_PARAM
Definition: RigidBodyAlignmentParameters.h:24
config
Definition: config.py:1
cond::timeTypeSpecs
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
PedeLabelerBase::maxNumberOfParameterInstances
virtual unsigned int maxNumberOfParameterInstances() const =0
returns the maximum number of instances for any parameter of an Alignable*
PedeLabelerBase::TopLevelAlignables
Definition: PedeLabelerBase.h:39
calib
Definition: CalibElectron.h:12
cond
Definition: plugin.cc:23
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
AlignableMuon.h
cond::runnumber
Definition: Time.h:19
PedeLabelerBase::theMaxNumParam
static const unsigned int theMaxNumParam
Definition: PedeLabelerBase.h:108
PedeLabelerBase::PedeLabelerBase
PedeLabelerBase(const TopLevelAlignables &alignables, const edm::ParameterSet &config)
constructor from three Alignables (null pointers allowed )
Definition: PedeLabelerBase.cc:28
PedeLabelerBase::addCalibrations
virtual void addCalibrations(const std::vector< IntegratedCalibrationBase * > &iCals)
tell labeler to treat also integrated calibrations
Definition: PedeLabelerBase.cc:101
PedeLabelerBase::TopLevelAlignables::aliMuon_
AlignableMuon * aliMuon_
Definition: PedeLabelerBase.h:44
PedeLabelerBase::theParamInstanceOffset
static const unsigned int theParamInstanceOffset
Definition: PedeLabelerBase.h:109
std
Definition: JetResolutionObject.h:76
PedeLabelerBase::theMinLabel
static const unsigned int theMinLabel
Definition: PedeLabelerBase.h:110
Exception
Definition: hltDiff.cc:246
IntegratedCalibrationBase.h
AlignableTracker.h
PedeLabelerBase::RunNumber
align::RunNumber RunNumber
Definition: PedeLabelerBase.h:35
PedeLabelerBase::calibrationParamFromLabel
virtual std::pair< IntegratedCalibrationBase *, unsigned int > calibrationParamFromLabel(unsigned int label) const
Definition: PedeLabelerBase.cc:37
PedeLabelerBase::calibrationLabel
virtual unsigned int calibrationLabel(const IntegratedCalibrationBase *calib, unsigned int paramNum) const
label for parameter 'paramNum' (counted from 0) of an integrated calibration
Definition: PedeLabelerBase.cc:75
label
const char * label
Definition: PFTauDecayModeTools.cc:11
PedeLabelerBase::firstFreeLabel
virtual unsigned int firstFreeLabel() const
Definition: PedeLabelerBase.cc:59