CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PedeLabeler Class Reference

#include <PedeLabeler.h>

Inheritance diagram for PedeLabeler:
PedeLabelerBase

Public Member Functions

AlignablealignableFromLabel (unsigned int label) const
 
unsigned int alignableLabel (Alignable *alignable) const
 Return 32-bit unique label for alignable, 0 indicates failure. More...
 
unsigned int alignableLabelFromLabel (unsigned int label) const
 alignable label from parameter label (works also for alignable label...) More...
 
unsigned int alignableLabelFromParamAndInstance (Alignable *alignable, unsigned int param, unsigned int instance) const
 
bool hasSplitParameters (Alignable *alignable) const
 returns true if the alignable has parameters that are split into various bins More...
 
unsigned int lasBeamIdFromLabel (unsigned int label) const
 
unsigned int lasBeamLabel (unsigned int lasBeamId) const
 
unsigned int maxNumberOfParameterInstances () const
 returns the maximum number of instances for any parameter of an Alignable* More...
 
unsigned int numberOfParameterInstances (Alignable *alignable, int param=-1) const
 returns the number of instances for a given parameter More...
 
unsigned int parameterLabel (unsigned int aliLabel, unsigned int parNum) const
 returns the label for a given alignable parameter number combination More...
 
unsigned int parameterLabel (Alignable *alignable, unsigned int parNum, const AlignmentAlgorithmBase::EventInfo &eventInfo, const TrajectoryStateOnSurface &tsos) const
 
unsigned int paramNumFromLabel (unsigned int paramLabel) const
 parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label More...
 
 PedeLabeler (const PedeLabelerBase::TopLevelAlignables &alignables, const edm::ParameterSet &config)
 constructor from three Alignables (null pointers allowed ) More...
 
 ~PedeLabeler ()
 destructor More...
 
- Public Member Functions inherited from PedeLabelerBase
virtual void addCalibrations (const std::vector< IntegratedCalibrationBase * > &iCals)
 tell labeler to treat also integrated calibrations More...
 
virtual unsigned int calibrationLabel (const IntegratedCalibrationBase *calib, unsigned int paramNum) const
 label for parameter 'paramNum' (counted from 0) of an integrated calibration More...
 
virtual std::pair
< IntegratedCalibrationBase
*, unsigned int > 
calibrationParamFromLabel (unsigned int label) const
 
virtual unsigned int firstFreeLabel () const
 
unsigned int parameterInstanceOffset () const
 offset in labels between consecutive parameter instances of Alignable*s More...
 
 PedeLabelerBase (const TopLevelAlignables &alignables, const edm::ParameterSet &config)
 constructor from three Alignables (null pointers allowed ) More...
 
virtual const RunRangerunRangeFromLabel (unsigned int label) const
 
virtual ~PedeLabelerBase ()
 

Private Types

typedef std::map< Alignable
*, unsigned int > 
AlignableToIdMap
 
typedef
AlignableToIdMap::value_type 
AlignableToIdPair
 
typedef std::map< unsigned int,
Alignable * > 
IdToAlignableMap
 
typedef std::map< unsigned int,
unsigned int > 
UintUintMap
 

Private Member Functions

unsigned int buildMap (const std::vector< Alignable * > &alis)
 returns size of map More...
 
unsigned int buildReverseMap ()
 returns size of map More...
 

Private Attributes

AlignableToIdMap theAlignableToIdMap
 
IdToAlignableMap theIdToAlignableMap
 providing unique ID for alignable, space for param IDs More...
 
UintUintMap theLabelToLasBeamMap
 labels for las beams More...
 
UintUintMap theLasBeamToLabelMap
 reverse map More...
 

Additional Inherited Members

- Public Types inherited from PedeLabelerBase
typedef
AlignmentAlgorithmBase::RunNumber 
RunNumber
 
typedef
AlignmentAlgorithmBase::RunRange 
RunRange
 
typedef std::vector< RunRangeRunRanges
 
- Static Public Attributes inherited from PedeLabelerBase
static const unsigned int theMaxNumParam = RigidBodyAlignmentParameters::N_PARAM + 14
 
static const unsigned int theMinLabel = 1
 
static const unsigned int theParamInstanceOffset = 700000
 
- Protected Member Functions inherited from PedeLabelerBase
virtual unsigned int firstNonAlignableLabel () const
 
- Protected Attributes inherited from PedeLabelerBase
const RunRange theOpenRunRange
 

Detailed Description

provides labels for AlignmentParameters for pede

Author
: Gero Flucke date : September 2007
Date:
2011/02/16 12:52:46
Revision:
1.5

(last update by

Author:
mussgill

)

Definition at line 25 of file PedeLabeler.h.

Member Typedef Documentation

typedef std::map<Alignable*, unsigned int> PedeLabeler::AlignableToIdMap
private

Definition at line 66 of file PedeLabeler.h.

typedef AlignableToIdMap::value_type PedeLabeler::AlignableToIdPair
private

Definition at line 67 of file PedeLabeler.h.

typedef std::map<unsigned int, Alignable*> PedeLabeler::IdToAlignableMap
private

Definition at line 68 of file PedeLabeler.h.

typedef std::map<unsigned int, unsigned int> PedeLabeler::UintUintMap
private

Definition at line 69 of file PedeLabeler.h.

Constructor & Destructor Documentation

PedeLabeler::PedeLabeler ( const PedeLabelerBase::TopLevelAlignables alignables,
const edm::ParameterSet config 
)

constructor from three Alignables (null pointers allowed )

Definition at line 22 of file PedeLabeler.cc.

References PedeLabelerBase::TopLevelAlignables::aliExtras_, PedeLabelerBase::TopLevelAlignables::aliMuon_, PedeLabelerBase::TopLevelAlignables::aliTracker_, buildMap(), and AlignableExtras::components().

24  :PedeLabelerBase(alignables, config)
25 {
26  std::vector<Alignable*> alis;
27  alis.push_back(alignables.aliTracker_);
28  alis.push_back(alignables.aliMuon_);
29 
30  if (alignables.aliExtras_) {
31  align::Alignables allExtras = alignables.aliExtras_->components();
32  for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
33  alis.push_back(*it);
34  }
35  }
36 
37  this->buildMap(alis);
38 }
PedeLabelerBase(const TopLevelAlignables &alignables, const edm::ParameterSet &config)
constructor from three Alignables (null pointers allowed )
Alignables components() const
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
unsigned int buildMap(const std::vector< Alignable * > &alis)
returns size of map
Definition: PedeLabeler.cc:155
PedeLabeler::~PedeLabeler ( )

destructor

Definition at line 41 of file PedeLabeler.cc.

42 {
43 }

Member Function Documentation

Alignable * PedeLabeler::alignableFromLabel ( unsigned int  label) const
virtual

Alignable from alignable or parameter label, null if no alignable (but error only if not las beam, either!)

Implements PedeLabelerBase.

Definition at line 117 of file PedeLabeler.cc.

References alignableLabelFromLabel(), position, theIdToAlignableMap, theLabelToLasBeamMap, and PedeLabelerBase::theMinLabel.

118 {
119  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
120  if (aliLabel < theMinLabel) return 0; // error already given
121 
122  if (theIdToAlignableMap.empty()) const_cast<PedeLabeler*>(this)->buildReverseMap();
123  IdToAlignableMap::const_iterator position = theIdToAlignableMap.find(aliLabel);
124  if (position != theIdToAlignableMap.end()) {
125  return position->second;
126  } else {
127  // error only if not in lasBeamMap:
128  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
129  if (position == theLabelToLasBeamMap.end()) {
130  edm::LogError("LogicError") << "@SUB=PedeLabeler::alignableFromLabel"
131  << "Alignable label " << aliLabel << " not in map.";
132  }
133  return 0;
134  }
135 }
static const unsigned int theMinLabel
UintUintMap theLabelToLasBeamMap
labels for las beams
Definition: PedeLabeler.h:80
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs
Definition: PedeLabeler.h:78
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
Definition: PedeLabeler.cc:111
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int PedeLabeler::alignableLabel ( Alignable alignable) const
virtual

Return 32-bit unique label for alignable, 0 indicates failure.

uniqueId of Alignable, 0 if alignable not known between this ID and the next there is enough 'space' to add parameter numbers 0...nPar-1 to make unique IDs for the labels of active parameters

Implements PedeLabelerBase.

Definition at line 47 of file PedeLabeler.cc.

References Alignable::alignableObjectId(), Alignable::id(), position, and theAlignableToIdMap.

Referenced by alignableLabelFromParamAndInstance(), and parameterLabel().

48 {
49  if (!alignable) return 0;
50 
51  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
52  if (position != theAlignableToIdMap.end()) {
53  return position->second;
54  } else {
55  const DetId detId(alignable->id());
56  //throw cms::Exception("LogicError")
57  edm::LogError("LogicError")
58  << "@SUB=PedeLabeler::alignableLabel" << "Alignable "
59  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
60  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
61  return 0;
62  }
63 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignableToIdMap theAlignableToIdMap
Definition: PedeLabeler.h:77
Definition: DetId.h:18
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int PedeLabeler::alignableLabelFromLabel ( unsigned int  label) const
virtual

alignable label from parameter label (works also for alignable label...)

Implements PedeLabelerBase.

Definition at line 111 of file PedeLabeler.cc.

References paramNumFromLabel().

Referenced by alignableFromLabel(), and lasBeamIdFromLabel().

112 {
113  return paramLabel - this->paramNumFromLabel(paramLabel);
114 }
unsigned int paramNumFromLabel(unsigned int paramLabel) const
parameter number, 0 &lt;= .. &lt; theMaxNumParam, belonging to unique parameter label
Definition: PedeLabeler.cc:100
unsigned int PedeLabeler::alignableLabelFromParamAndInstance ( Alignable alignable,
unsigned int  param,
unsigned int  instance 
) const
virtual

uniqueId of Alignable for a given parameter index and instance, 0 if alignable not known between this ID and the next there is enough 'space' to add parameter numbers 0...nPar-1 to make unique IDs for the labels of active parameters

Implements PedeLabelerBase.

Definition at line 67 of file PedeLabeler.cc.

References alignableLabel().

70 {
71  return this->alignableLabel(alignable);
72 }
unsigned int alignableLabel(Alignable *alignable) const
Return 32-bit unique label for alignable, 0 indicates failure.
Definition: PedeLabeler.cc:47
unsigned int PedeLabeler::buildMap ( const std::vector< Alignable * > &  alis)
private

returns size of map

Definition at line 155 of file PedeLabeler.cc.

References theAlignableToIdMap, theLasBeamToLabelMap, PedeLabelerBase::theMaxNumParam, and PedeLabelerBase::theMinLabel.

Referenced by PedeLabeler().

156 {
157  theAlignableToIdMap.clear(); // just in case of re-use...
158 
159  std::vector<Alignable*> allComps;
160 
161  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
162  if (*iAli) {
163  allComps.push_back(*iAli);
164  (*iAli)->recursiveComponents(allComps);
165  }
166  }
167 
168  unsigned int id = theMinLabel;
169  for (std::vector<Alignable*>::const_iterator iter = allComps.begin();
170  iter != allComps.end(); ++iter) {
171  theAlignableToIdMap.insert(AlignableToIdPair(*iter, id));
172  id += theMaxNumParam;
173  }
174 
175  // also care about las beams
176  theLasBeamToLabelMap.clear(); // just in case of re-use...
177  // FIXME: Temporarily hard code values stolen from
178  // https://twiki.cern.ch/twiki/bin/view/CMS/TkLasTrackBasedInterface#Beam_identifier .
179  unsigned int beamIds[] = { 0, 10, 20, 30, 40, 50, 60, 70, // TEC+ R4
180  1, 11, 21, 31, 41, 51, 61, 71, // TEC+ R6
181  100, 110, 120, 130, 140, 150, 160, 170, // TEC- R4
182  101, 111, 121, 131, 141, 151, 161, 171, // TEC- R6
183  200, 210, 220, 230, 240, 250, 260, 270};// AT
184 
185  const size_t nBeams = sizeof(beamIds)/sizeof(beamIds[0]);
186  for (size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
187  //edm::LogInfo("Alignment") << "Las beam " << beamIds[iBeam] << " gets label " << id << ".";
188  theLasBeamToLabelMap[beamIds[iBeam]] = id;
189  id += theMaxNumParam;
190  }
191 
192  // return combined size
193  return theAlignableToIdMap.size() + theLasBeamToLabelMap.size();
194 }
static const unsigned int theMinLabel
static const unsigned int theMaxNumParam
AlignableToIdMap::value_type AlignableToIdPair
Definition: PedeLabeler.h:67
AlignableToIdMap theAlignableToIdMap
Definition: PedeLabeler.h:77
UintUintMap theLasBeamToLabelMap
reverse map
Definition: PedeLabeler.h:79
unsigned int PedeLabeler::buildReverseMap ( )
private

returns size of map

Definition at line 197 of file PedeLabeler.cc.

References relval_steps::key, theAlignableToIdMap, theIdToAlignableMap, theLabelToLasBeamMap, and theLasBeamToLabelMap.

198 {
199 
200  // alignables
201  theIdToAlignableMap.clear(); // just in case of re-use...
202 
203  for (AlignableToIdMap::iterator it = theAlignableToIdMap.begin();
204  it != theAlignableToIdMap.end(); ++it) {
205  const unsigned int key = (*it).second;
206  Alignable *ali = (*it).first;
207  theIdToAlignableMap[key] = ali;
208  }
209 
210  // las beams
211  theLabelToLasBeamMap.clear(); // just in case of re-use...
212 
213  for (UintUintMap::const_iterator it = theLasBeamToLabelMap.begin();
214  it != theLasBeamToLabelMap.end(); ++it) {
215  theLabelToLasBeamMap[it->second] = it->first; //revert key/value
216  }
217 
218  // return combined size
219  return theIdToAlignableMap.size() + theLabelToLasBeamMap.size();
220 }
UintUintMap theLabelToLasBeamMap
labels for las beams
Definition: PedeLabeler.h:80
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs
Definition: PedeLabeler.h:78
AlignableToIdMap theAlignableToIdMap
Definition: PedeLabeler.h:77
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
UintUintMap theLasBeamToLabelMap
reverse map
Definition: PedeLabeler.h:79
bool PedeLabeler::hasSplitParameters ( Alignable alignable) const
inlinevirtual

returns true if the alignable has parameters that are split into various bins

Implements PedeLabelerBase.

Definition at line 49 of file PedeLabeler.h.

49 { return false; }
unsigned int PedeLabeler::lasBeamIdFromLabel ( unsigned int  label) const
virtual

las beam id from las beam or parameter label zero and error if not a valid las beam label

Implements PedeLabelerBase.

Definition at line 138 of file PedeLabeler.cc.

References alignableLabelFromLabel(), position, theLabelToLasBeamMap, and PedeLabelerBase::theMinLabel.

139 {
140  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
141  if (aliLabel < theMinLabel) return 0; // error already given
142 
143  if (theLabelToLasBeamMap.empty()) const_cast<PedeLabeler*>(this)->buildReverseMap();
144  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
145  if (position != theLabelToLasBeamMap.end()) {
146  return position->second;
147  } else {
148  edm::LogError("LogicError") << "@SUB=PedeLabeler::lasBeamIdFromLabel"
149  << "Alignable label " << aliLabel << " not in map.";
150  return 0;
151  }
152 }
static const unsigned int theMinLabel
UintUintMap theLabelToLasBeamMap
labels for las beams
Definition: PedeLabeler.h:80
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
Definition: PedeLabeler.cc:111
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int PedeLabeler::lasBeamLabel ( unsigned int  lasBeamId) const
virtual

Implements PedeLabelerBase.

Definition at line 75 of file PedeLabeler.cc.

References position, and theLasBeamToLabelMap.

76 {
77  UintUintMap::const_iterator position = theLasBeamToLabelMap.find(lasBeamId);
78  if (position != theLasBeamToLabelMap.end()) {
79  return position->second;
80  } else {
81  //throw cms::Exception("LogicError")
82  edm::LogError("LogicError") << "@SUB=PedeLabeler::lasBeamLabel"
83  << "No label for beam Id " << lasBeamId;
84  return 0;
85  }
86 }
UintUintMap theLasBeamToLabelMap
reverse map
Definition: PedeLabeler.h:79
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int PedeLabeler::maxNumberOfParameterInstances ( ) const
inlinevirtual

returns the maximum number of instances for any parameter of an Alignable*

Implements PedeLabelerBase.

Definition at line 52 of file PedeLabeler.h.

52 { return 1; }
unsigned int PedeLabeler::numberOfParameterInstances ( Alignable alignable,
int  param = -1 
) const
inlinevirtual

returns the number of instances for a given parameter

Implements PedeLabelerBase.

Definition at line 50 of file PedeLabeler.h.

51  { return 1; }
unsigned int PedeLabeler::parameterLabel ( unsigned int  aliLabel,
unsigned int  parNum 
) const
virtual

returns the label for a given alignable parameter number combination

Implements PedeLabelerBase.

Definition at line 89 of file PedeLabeler.cc.

References Exception, and PedeLabelerBase::theMaxNumParam.

Referenced by parameterLabel().

90 {
91  if (parNum >= theMaxNumParam) {
92  throw cms::Exception("Alignment") << "@SUB=PedeLabeler::parameterLabel"
93  << "Parameter number " << parNum
94  << " out of range 0 <= num < " << theMaxNumParam;
95  }
96  return aliLabel + parNum;
97 }
static const unsigned int theMaxNumParam
unsigned int PedeLabeler::parameterLabel ( Alignable alignable,
unsigned int  parNum,
const AlignmentAlgorithmBase::EventInfo eventInfo,
const TrajectoryStateOnSurface tsos 
) const
inlinevirtual

returns the label for a given alignable parameter number combination in case the parameters are split into various instances

Implements PedeLabelerBase.

Definition at line 44 of file PedeLabeler.h.

References alignableLabel(), and parameterLabel().

46  {
47  return parameterLabel(alignableLabel(alignable), parNum);
48  }
unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const
returns the label for a given alignable parameter number combination
Definition: PedeLabeler.cc:89
unsigned int alignableLabel(Alignable *alignable) const
Return 32-bit unique label for alignable, 0 indicates failure.
Definition: PedeLabeler.cc:47
unsigned int PedeLabeler::paramNumFromLabel ( unsigned int  paramLabel) const
virtual

parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label

Implements PedeLabelerBase.

Definition at line 100 of file PedeLabeler.cc.

References PedeLabelerBase::theMaxNumParam, and PedeLabelerBase::theMinLabel.

Referenced by alignableLabelFromLabel().

101 {
102  if (paramLabel < theMinLabel) {
103  edm::LogError("LogicError") << "@SUB=PedeLabeler::paramNumFromLabel"
104  << "Label " << paramLabel << " should be >= " << theMinLabel;
105  return 0;
106  }
107  return (paramLabel - theMinLabel) % theMaxNumParam;
108 }
static const unsigned int theMinLabel
static const unsigned int theMaxNumParam

Member Data Documentation

AlignableToIdMap PedeLabeler::theAlignableToIdMap
private

Definition at line 77 of file PedeLabeler.h.

Referenced by alignableLabel(), buildMap(), and buildReverseMap().

IdToAlignableMap PedeLabeler::theIdToAlignableMap
private

providing unique ID for alignable, space for param IDs

Definition at line 78 of file PedeLabeler.h.

Referenced by alignableFromLabel(), and buildReverseMap().

UintUintMap PedeLabeler::theLabelToLasBeamMap
private

labels for las beams

Definition at line 80 of file PedeLabeler.h.

Referenced by alignableFromLabel(), buildReverseMap(), and lasBeamIdFromLabel().

UintUintMap PedeLabeler::theLasBeamToLabelMap
private

reverse map

Definition at line 79 of file PedeLabeler.h.

Referenced by buildMap(), buildReverseMap(), and lasBeamLabel().