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
MomentumDependentPedeLabeler Class Reference

#include <MomentumDependentPedeLabeler.h>

Inheritance diagram for MomentumDependentPedeLabeler:
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...
 
 MomentumDependentPedeLabeler (const PedeLabelerBase::TopLevelAlignables &alignables, const edm::ParameterSet &config)
 constructor from three Alignables (null pointers allowed ) 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...
 
 ~MomentumDependentPedeLabeler ()
 
- 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< Alignable
*, MomentumRangeParamMap
AlignableToMomentumRangeMap
 
typedef
AlignableToMomentumRangeMap::value_type 
AlignableToMomentumRangePair
 
typedef std::map< unsigned int,
Alignable * > 
IdToAlignableMap
 
typedef std::pair< float, float > MomentumRange
 
typedef std::map< unsigned int,
MomentumRangeVector
MomentumRangeParamMap
 
typedef std::vector
< MomentumRange
MomentumRangeVector
 
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 buildMomentumDependencyMap (AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras, const edm::ParameterSet &config)
 
unsigned int buildReverseMap ()
 returns size of map More...
 
std::vector< unsigned int > convertParamSel (const std::string &selString) const
 
std::vector< std::string > decompose (const std::string &s, std::string::value_type delimiter) const
 

Private Attributes

AlignableToIdMap theAlignableToIdMap
 
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
 providing unique ID for alignable, space for param IDs More...
 
IdToAlignableMap theIdToAlignableMap
 providing unique ID for alignable, space for param IDs More...
 
UintUintMap theLabelToLasBeamMap
 labels for las beams More...
 
UintUintMap theLasBeamToLabelMap
 reverse map More...
 
unsigned int theMaxNumberOfParameterInstances
 
const MomentumRange theOpenMomentumRange
 reverse of the above 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/03/05 20:12:23
Revision:
1.1

(last update by

Author:
mussgill

)

Definition at line 25 of file MomentumDependentPedeLabeler.h.

Member Typedef Documentation

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

Definition at line 72 of file MomentumDependentPedeLabeler.h.

typedef AlignableToIdMap::value_type MomentumDependentPedeLabeler::AlignableToIdPair
private

Definition at line 73 of file MomentumDependentPedeLabeler.h.

Definition at line 77 of file MomentumDependentPedeLabeler.h.

typedef AlignableToMomentumRangeMap::value_type MomentumDependentPedeLabeler::AlignableToMomentumRangePair
private

Definition at line 78 of file MomentumDependentPedeLabeler.h.

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

Definition at line 79 of file MomentumDependentPedeLabeler.h.

typedef std::pair<float,float> MomentumDependentPedeLabeler::MomentumRange
private

Definition at line 74 of file MomentumDependentPedeLabeler.h.

Definition at line 76 of file MomentumDependentPedeLabeler.h.

Definition at line 75 of file MomentumDependentPedeLabeler.h.

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

Definition at line 80 of file MomentumDependentPedeLabeler.h.

Constructor & Destructor Documentation

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

constructor from three Alignables (null pointers allowed )

Definition at line 27 of file MomentumDependentPedeLabeler.cc.

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

29  : PedeLabelerBase(alignables, config),
30  theOpenMomentumRange(std::pair<float,float>(0.0, 10000.0)),
32 {
33  std::vector<Alignable*> alis;
34  alis.push_back(alignables.aliTracker_);
35  alis.push_back(alignables.aliMuon_);
36 
37  if (alignables.aliExtras_) {
38  align::Alignables allExtras = alignables.aliExtras_->components();
39  for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
40  alis.push_back(*it);
41  }
42  }
43 
44  this->buildMomentumDependencyMap(alignables.aliTracker_,
45  alignables.aliMuon_,
46  alignables.aliExtras_,
47  config);
48  this->buildMap(alis);
49  this->buildReverseMap(); // needed already now to 'fill' theMaxNumberOfParameterInstances
50 }
unsigned int buildMap(const std::vector< Alignable * > &alis)
returns size of map
PedeLabelerBase(const TopLevelAlignables &alignables, const edm::ParameterSet &config)
constructor from three Alignables (null pointers allowed )
unsigned int buildReverseMap()
returns size of map
Alignables components() const
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
unsigned int buildMomentumDependencyMap(AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras, const edm::ParameterSet &config)
const MomentumRange theOpenMomentumRange
reverse of the above
MomentumDependentPedeLabeler::~MomentumDependentPedeLabeler ( )

non-virtual destructor: do not inherit from this class

Definition at line 54 of file MomentumDependentPedeLabeler.cc.

55 {
56 }

Member Function Documentation

Alignable * MomentumDependentPedeLabeler::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 250 of file MomentumDependentPedeLabeler.cc.

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

251 {
252  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
253  if (aliLabel < theMinLabel) return 0; // error already given
254 
255  if (theIdToAlignableMap.empty()) const_cast<MomentumDependentPedeLabeler*>(this)->buildReverseMap();
256  IdToAlignableMap::const_iterator position = theIdToAlignableMap.find(aliLabel);
257  if (position != theIdToAlignableMap.end()) {
258  return position->second;
259  } else {
260  // error only if not in lasBeamMap:
261  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
262  if (position == theLabelToLasBeamMap.end()) {
263  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::alignableFromLabel"
264  << "Alignable label " << aliLabel << " not in map.";
265  }
266  return 0;
267  }
268 }
UintUintMap theLabelToLasBeamMap
labels for las beams
static const unsigned int theMinLabel
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::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 60 of file MomentumDependentPedeLabeler.cc.

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

61 {
62  if (!alignable) return 0;
63 
64  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
65  if (position != theAlignableToIdMap.end()) {
66  return position->second;
67  } else {
68  const DetId detId(alignable->id());
69  //throw cms::Exception("LogicError")
70  edm::LogError("LogicError")
71  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
72  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
73  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
74  return 0;
75  }
76 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Definition: DetId.h:18
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int MomentumDependentPedeLabeler::alignableLabelFromLabel ( unsigned int  label) const
virtual

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

Implements PedeLabelerBase.

Definition at line 244 of file MomentumDependentPedeLabeler.cc.

References paramNumFromLabel().

Referenced by alignableFromLabel(), and lasBeamIdFromLabel().

245 {
246  return paramLabel - this->paramNumFromLabel(paramLabel);
247 }
unsigned int paramNumFromLabel(unsigned int paramLabel) const
parameter number, 0 &lt;= .. &lt; theMaxNumParam, belonging to unique parameter label
unsigned int MomentumDependentPedeLabeler::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 80 of file MomentumDependentPedeLabeler.cc.

References Alignable::alignableObjectId(), Exception, Alignable::id(), position, theAlignableToIdMap, theAlignableToMomentumRangeMap, and PedeLabelerBase::theParamInstanceOffset.

83 {
84  if (!alignable) return 0;
85 
86  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
87  if (position != theAlignableToIdMap.end()) {
88  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
89  if (positionAli != theAlignableToMomentumRangeMap.end()) {
90  MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(param);
91  if (positionParam!=(*positionAli).second.end()) {
92  if (instance>=(*positionParam).second.size()) {
93  throw cms::Exception("Alignment") << "@SUB=MomentumDependentPedeLabeler::alignableLabelFromParamAndMomentum"
94  << "iovIdx out of bounds";
95  }
96  return position->second + instance * theParamInstanceOffset;
97  } else {
98  return position->second;
99  }
100  } else {
101  return position->second;
102  }
103  } else {
104  const DetId detId(alignable->id());
105  //throw cms::Exception("LogicError")
106  edm::LogError("LogicError")
107  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
108  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
109  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
110  return 0;
111  }
112 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
static PFTauRenderPlugin instance
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Definition: DetId.h:18
static const unsigned int theParamInstanceOffset
static int position[264][3]
Definition: ReadPGInfo.cc:509
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::buildMap ( const std::vector< Alignable * > &  alis)
private

returns size of map

Definition at line 412 of file MomentumDependentPedeLabeler.cc.

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

Referenced by MomentumDependentPedeLabeler().

413 {
414  theAlignableToIdMap.clear(); // just in case of re-use...
415 
416  std::vector<Alignable*> allComps;
417 
418  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
419  if (*iAli) {
420  allComps.push_back(*iAli);
421  (*iAli)->recursiveComponents(allComps);
422  }
423  }
424 
425  unsigned int id = theMinLabel;
426  for (std::vector<Alignable*>::const_iterator iter = allComps.begin();
427  iter != allComps.end(); ++iter) {
428  theAlignableToIdMap.insert(AlignableToIdPair(*iter, id));
429  id += theMaxNumParam;
430  }
431 
432  // also care about las beams
433  theLasBeamToLabelMap.clear(); // just in case of re-use...
434  // FIXME: Temporarily hard code values stolen from
435  // https://twiki.cern.ch/twiki/bin/view/CMS/TkLasTrackBasedInterface#Beam_identifier .
436  unsigned int beamIds[] = { 0, 10, 20, 30, 40, 50, 60, 70, // TEC+ R4
437  1, 11, 21, 31, 41, 51, 61, 71, // TEC+ R6
438  100, 110, 120, 130, 140, 150, 160, 170, // TEC- R4
439  101, 111, 121, 131, 141, 151, 161, 171, // TEC- R6
440  200, 210, 220, 230, 240, 250, 260, 270};// AT
441 
442  const size_t nBeams = sizeof(beamIds)/sizeof(beamIds[0]);
443  for (size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
444  //edm::LogInfo("Alignment") << "Las beam " << beamIds[iBeam] << " gets label " << id << ".";
445  theLasBeamToLabelMap[beamIds[iBeam]] = id;
446  id += theMaxNumParam;
447  }
448 
449  if (id > theParamInstanceOffset) { // 'overflow' per instance
450  throw cms::Exception("Alignment") << "@SUB=MomentumDependentPedeLabeler::buildMap: "
451  << "Too many labels per instance (" << id-1 << ") leading to double use, "
452  << "increase PedeLabelerBase::theParamInstanceOffset!\n";
453  }
454  // return combined size
455  return theAlignableToIdMap.size() + theLasBeamToLabelMap.size();
456 }
static const unsigned int theMinLabel
static const unsigned int theMaxNumParam
UintUintMap theLasBeamToLabelMap
reverse map
static const unsigned int theParamInstanceOffset
AlignableToIdMap::value_type AlignableToIdPair
unsigned int MomentumDependentPedeLabeler::buildMomentumDependencyMap ( AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras extras,
const edm::ParameterSet config 
)
private

Definition at line 317 of file MomentumDependentPedeLabeler.cc.

References AlignmentParameterSelector::addSelection(), AlignmentParameterSelector::clear(), convertParamSel(), decompose(), Exception, edm::ParameterSet::getParameter(), AlignableObjectId::idToString(), NULL, AlignmentParameterSelector::selectedAlignables(), AlignmentParameters::size(), theAlignableToMomentumRangeMap, edm::tokenize(), and pileupCalc::upper.

Referenced by MomentumDependentPedeLabeler().

321 {
323 
324  AlignmentParameterSelector selector(aliTracker, aliMuon, aliExtras);
325 
326  std::vector<char> paramSelDumthe(6, '1');
327 
328  const std::vector<edm::ParameterSet> parameterInstancesVPSet =
329  config.getParameter<std::vector<edm::ParameterSet> >("parameterInstances");
330 
331  for (std::vector<edm::ParameterSet>::const_iterator iter = parameterInstancesVPSet.begin();
332  iter != parameterInstancesVPSet.end();
333  ++iter) {
334 
335  const std::vector<std::string> tempMomentumRanges = (*iter).getParameter<std::vector<std::string> >("momentumRanges");
336  if (tempMomentumRanges.size()==0) {
337  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
338  << "MomentumRanges empty\n";
339  }
340 
341  MomentumRangeVector MomentumRanges;
342  float lower;
343  float upper;
344  for (unsigned int iMomentum=0;iMomentum<tempMomentumRanges.size();++iMomentum) {
345  std::vector<std::string> tokens = edm::tokenize(tempMomentumRanges[iMomentum], ":");
346 
347  lower = strtod(tokens[0].c_str(), 0);
348  upper = strtod(tokens[1].c_str(), 0);
349 
350  MomentumRanges.push_back(std::pair<float,float>(lower, upper));
351  }
352 
353  const std::vector<std::string> selStrings = (*iter).getParameter<std::vector<std::string> >("selector");
354  for (std::vector<std::string>::const_iterator iSel = selStrings.begin();
355  iSel != selStrings.end();
356  ++iSel) {
357  std::vector<std::string> decompSel(this->decompose(*iSel, ','));
358 
359  if (decompSel.size()!=2) {
360  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
361  << *iSel <<" should have at least 2 ','-separated parts\n";
362  }
363 
364  std::vector<unsigned int> selParam = this->convertParamSel(decompSel[1]);
365  selector.clear();
366  selector.addSelection(decompSel[0], paramSelDumthe);
367 
368  const std::vector<Alignable*> &alis = selector.selectedAlignables();
369  for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
370  iAli != alis.end();
371  ++iAli) {
372 
373  if((*iAli)->alignmentParameters() == NULL) {
374  throw cms::Exception("BadConfig")
375  << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
376  << "Momentum dependence configured for alignable of type "
377  << AlignableObjectId::idToString((*iAli)->alignableObjectId())
378  << " at (" << (*iAli)->globalPosition().x() << ","<< (*iAli)->globalPosition().y() << "," << (*iAli)->globalPosition().z()<< "), "
379  << "but that has no parameters. Please check that all run "
380  << "momentum parameters are also selected for alignment.\n";
381  }
382 
383  for (std::vector<unsigned int>::const_iterator iParam = selParam.begin();
384  iParam != selParam.end();
385  ++iParam) {
386  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(*iAli);
387  if (positionAli!=theAlignableToMomentumRangeMap.end()) {
388 
389  AlignmentParameters *AliParams = (*positionAli).first->alignmentParameters();
390  if (static_cast<int>(selParam[selParam.size()-1]) >= AliParams->size()) {
391  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
392  << "mismatch in number of parameters\n";
393  }
394 
395  MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(*iParam);
396  if (positionParam!=(*positionAli).second.end()) {
397  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
398  << "Momentum range for parameter specified twice\n";
399  }
400  }
401 
402  theAlignableToMomentumRangeMap[*iAli][*iParam] = MomentumRanges;
403  }
404  }
405  }
406  }
407 
408  return theAlignableToMomentumRangeMap.size();
409 }
T getParameter(std::string const &) const
std::vector< std::string > decompose(const std::string &s, std::string::value_type delimiter) const
#define NULL
Definition: scimark2.h:8
int size(void) const
Get number of parameters.
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
Definition: Parse.cc:57
std::vector< MomentumRange > MomentumRangeVector
static const char * idToString(align::StructureType type)
std::vector< unsigned int > convertParamSel(const std::string &selString) const
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::buildReverseMap ( )
private

returns size of map

Definition at line 459 of file MomentumDependentPedeLabeler.cc.

References relval_steps::key, bookConverter::max, numberOfParameterInstances(), theAlignableToIdMap, theIdToAlignableMap, theLabelToLasBeamMap, theLasBeamToLabelMap, theMaxNumberOfParameterInstances, and PedeLabelerBase::theParamInstanceOffset.

Referenced by MomentumDependentPedeLabeler().

460 {
461  // alignables
462  theIdToAlignableMap.clear(); // just in case of re-use...
463 
464  for (AlignableToIdMap::iterator it = theAlignableToIdMap.begin();
465  it != theAlignableToIdMap.end(); ++it) {
466  const unsigned int key = (*it).second;
467  Alignable *ali = (*it).first;
468  const unsigned int nInstances = this->numberOfParameterInstances(ali, -1);
470  for (unsigned int iInstance=0;iInstance<nInstances;++iInstance) {
471  theIdToAlignableMap[key+iInstance*theParamInstanceOffset] = ali;
472  }
473  }
474 
475  // las beams
476  theLabelToLasBeamMap.clear(); // just in case of re-use...
477 
478  for (UintUintMap::const_iterator it = theLasBeamToLabelMap.begin();
479  it != theLasBeamToLabelMap.end(); ++it) {
480  theLabelToLasBeamMap[it->second] = it->first; //revert key/value
481  }
482 
483  // return combined size
484  return theIdToAlignableMap.size() + theLabelToLasBeamMap.size();
485 }
UintUintMap theLabelToLasBeamMap
labels for las beams
unsigned int numberOfParameterInstances(Alignable *alignable, int param=-1) const
returns the number of instances for a given parameter
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
UintUintMap theLasBeamToLabelMap
reverse map
static const unsigned int theParamInstanceOffset
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs
std::vector< unsigned int > MomentumDependentPedeLabeler::convertParamSel ( const std::string &  selString) const
private

Definition at line 308 of file MomentumDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildMomentumDependencyMap().

309 {
310  std::vector<unsigned int> result;
311  for (std::string::size_type pos = 0; pos < selString.size(); ++pos) {
312  if (selString[pos]=='1') result.push_back(pos);
313  }
314  return result;
315 }
uint16_t size_type
tuple result
Definition: mps_fire.py:84
std::vector< std::string > MomentumDependentPedeLabeler::decompose ( const std::string &  s,
std::string::value_type  delimiter 
) const
private

Definition at line 288 of file MomentumDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildMomentumDependencyMap().

290 {
291  std::vector<std::string> result;
292 
293  std::string::size_type previousPos = 0;
294  while (true) {
295  const std::string::size_type delimiterPos = s.find(delimiter, previousPos);
296  if (delimiterPos == std::string::npos) {
297  result.push_back(s.substr(previousPos)); // until end
298  break;
299  }
300  result.push_back(s.substr(previousPos, delimiterPos - previousPos));
301  previousPos = delimiterPos + 1; // +1: skip delimiter
302  }
303 
304  return result;
305 }
uint16_t size_type
tuple result
Definition: mps_fire.py:84
bool MomentumDependentPedeLabeler::hasSplitParameters ( Alignable alignable) const
virtual

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

Implements PedeLabelerBase.

Definition at line 198 of file MomentumDependentPedeLabeler.cc.

References theAlignableToMomentumRangeMap.

199 {
200  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
201  if (positionAli != theAlignableToMomentumRangeMap.end()) return true;
202  return false;
203 }
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::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 271 of file MomentumDependentPedeLabeler.cc.

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

272 {
273  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
274  if (aliLabel < theMinLabel) return 0; // error already given
275 
276  if (theLabelToLasBeamMap.empty()) const_cast<MomentumDependentPedeLabeler*>(this)->buildReverseMap();
277  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
278  if (position != theLabelToLasBeamMap.end()) {
279  return position->second;
280  } else {
281  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::lasBeamIdFromLabel"
282  << "Alignable label " << aliLabel << " not in map.";
283  return 0;
284  }
285 }
UintUintMap theLabelToLasBeamMap
labels for las beams
static const unsigned int theMinLabel
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
unsigned int MomentumDependentPedeLabeler::lasBeamLabel ( unsigned int  lasBeamId) const
virtual

Implements PedeLabelerBase.

Definition at line 115 of file MomentumDependentPedeLabeler.cc.

References position, and theLasBeamToLabelMap.

116 {
117  UintUintMap::const_iterator position = theLasBeamToLabelMap.find(lasBeamId);
118  if (position != theLasBeamToLabelMap.end()) {
119  return position->second;
120  } else {
121  //throw cms::Exception("LogicError")
122  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::lasBeamLabel"
123  << "No label for beam Id " << lasBeamId;
124  return 0;
125  }
126 }
UintUintMap theLasBeamToLabelMap
reverse map
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int MomentumDependentPedeLabeler::maxNumberOfParameterInstances ( ) const
inlinevirtual

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

Implements PedeLabelerBase.

Definition at line 58 of file MomentumDependentPedeLabeler.h.

References theMaxNumberOfParameterInstances.

unsigned int MomentumDependentPedeLabeler::numberOfParameterInstances ( Alignable alignable,
int  param = -1 
) const
virtual

returns the number of instances for a given parameter

Implements PedeLabelerBase.

Definition at line 206 of file MomentumDependentPedeLabeler.cc.

References bookConverter::max, and theAlignableToMomentumRangeMap.

Referenced by buildReverseMap().

207 {
208  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
209  if (positionAli != theAlignableToMomentumRangeMap.end()) {
210 
211  size_t nMomentums = 1;
212  if (param==-1) {
213  for (MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.begin();
214  iParam != (*positionAli).second.end();
215  ++iParam) {
216  nMomentums = std::max(nMomentums, iParam->second.size());
217  }
218  return nMomentums;
219  } else {
220  MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.find(param);
221  if (iParam != (*positionAli).second.end()) {
222  return iParam->second.size();
223  } else {
224  return 1;
225  }
226  }
227  }
228 
229  return 1;
230 }
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::parameterLabel ( unsigned int  aliLabel,
unsigned int  parNum 
) const
virtual

returns the label for a given alignable parameter number combination

Implements PedeLabelerBase.

Definition at line 129 of file MomentumDependentPedeLabeler.cc.

References Exception, and PedeLabelerBase::theMaxNumParam.

130 {
131  if (parNum >= theMaxNumParam) {
132  throw cms::Exception("Alignment") << "@SUB=MomentumDependentPedeLabeler::parameterLabel"
133  << "Parameter number " << parNum
134  << " out of range 0 <= num < " << theMaxNumParam;
135  }
136  return aliLabel + parNum;
137 }
static const unsigned int theMaxNumParam
unsigned int MomentumDependentPedeLabeler::parameterLabel ( Alignable alignable,
unsigned int  parNum,
const AlignmentAlgorithmBase::EventInfo eventInfo,
const TrajectoryStateOnSurface tsos 
) const
virtual

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

Implements PedeLabelerBase.

Definition at line 140 of file MomentumDependentPedeLabeler.cc.

References Alignable::alignableObjectId(), Exception, TrajectoryStateOnSurface::globalMomentum(), Alignable::id(), PV3DBase< T, PVType, FrameType >::mag(), hltrates_dqm_sourceclient-live_cfg::offset, position, edm::second(), theAlignableToIdMap, theAlignableToMomentumRangeMap, PedeLabelerBase::theMaxNumParam, and PedeLabelerBase::theParamInstanceOffset.

143 {
144  if (!alignable) return 0;
145 
146  if (parNum >= theMaxNumParam) {
147  throw cms::Exception("Alignment") << "@SUB=MomentumDependentPedeLabeler::parameterLabel"
148  << "Parameter number " << parNum
149  << " out of range 0 <= num < " << theMaxNumParam;
150  }
151 
152  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
153  if (position != theAlignableToIdMap.end()) {
154 
155  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
156  if (positionAli != theAlignableToMomentumRangeMap.end()) {
157 
158  MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(parNum);
159  if (positionParam!=(*positionAli).second.end()) {
160 
161  int offset = 0;
162  float mom = tsos.globalMomentum().mag();
163  const MomentumRangeVector & momentumRanges = (*positionParam).second;
164  for (MomentumRangeVector::const_iterator iMomentum = momentumRanges.begin();
165  iMomentum != momentumRanges.end();
166  ++iMomentum) {
167 
168  if (iMomentum->first<=mom && mom<iMomentum->second) {
169  return position->second + offset * theParamInstanceOffset + parNum;
170  }
171  offset++;
172  }
173  const DetId detId(alignable->id());
174  edm::LogError("LogicError")
175  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
176  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
177  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
178  return 0;
179  } else {
180  return position->second + parNum;
181  }
182 
183  } else {
184  return position->second + parNum;
185  }
186  } else {
187  const DetId detId(alignable->id());
188  //throw cms::Exception("LogicError")
189  edm::LogError("LogicError")
190  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
191  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
192  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
193  return 0;
194  }
195 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
static const unsigned int theMaxNumParam
U second(std::pair< T, U > const &p)
T mag() const
Definition: PV3DBase.h:67
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Definition: DetId.h:18
static const unsigned int theParamInstanceOffset
std::vector< MomentumRange > MomentumRangeVector
GlobalVector globalMomentum() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
AlignableToMomentumRangeMap theAlignableToMomentumRangeMap
providing unique ID for alignable, space for param IDs
unsigned int MomentumDependentPedeLabeler::paramNumFromLabel ( unsigned int  paramLabel) const
virtual

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

Implements PedeLabelerBase.

Definition at line 233 of file MomentumDependentPedeLabeler.cc.

References PedeLabelerBase::theMinLabel, and PedeLabelerBase::theParamInstanceOffset.

Referenced by alignableLabelFromLabel().

234 {
235  if (paramLabel < theMinLabel) {
236  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::paramNumFromLabel"
237  << "Label " << paramLabel << " should be >= " << theMinLabel;
238  return 0;
239  }
240  return (paramLabel - theMinLabel) % theParamInstanceOffset;
241 }
static const unsigned int theMinLabel
static const unsigned int theParamInstanceOffset

Member Data Documentation

AlignableToIdMap MomentumDependentPedeLabeler::theAlignableToIdMap
private
AlignableToMomentumRangeMap MomentumDependentPedeLabeler::theAlignableToMomentumRangeMap
private

providing unique ID for alignable, space for param IDs

Definition at line 95 of file MomentumDependentPedeLabeler.h.

Referenced by alignableLabelFromParamAndInstance(), buildMomentumDependencyMap(), hasSplitParameters(), numberOfParameterInstances(), and parameterLabel().

IdToAlignableMap MomentumDependentPedeLabeler::theIdToAlignableMap
private

providing unique ID for alignable, space for param IDs

Definition at line 96 of file MomentumDependentPedeLabeler.h.

Referenced by alignableFromLabel(), and buildReverseMap().

UintUintMap MomentumDependentPedeLabeler::theLabelToLasBeamMap
private

labels for las beams

Definition at line 98 of file MomentumDependentPedeLabeler.h.

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

UintUintMap MomentumDependentPedeLabeler::theLasBeamToLabelMap
private

reverse map

Definition at line 97 of file MomentumDependentPedeLabeler.h.

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

unsigned int MomentumDependentPedeLabeler::theMaxNumberOfParameterInstances
private
const MomentumRange MomentumDependentPedeLabeler::theOpenMomentumRange
private

reverse of the above

Definition at line 99 of file MomentumDependentPedeLabeler.h.