CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
RunRangeDependentPedeLabeler Class Reference

#include <RunRangeDependentPedeLabeler.h>

Inheritance diagram for RunRangeDependentPedeLabeler:
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...
 
 RunRangeDependentPedeLabeler (const PedeLabelerBase::TopLevelAlignables &alignables, const edm::ParameterSet &config)
 constructor from three Alignables (null pointers allowed ) More...
 
const RunRangerunRangeFromLabel (unsigned int label) const
 
 ~RunRangeDependentPedeLabeler ()
 
- Public Member Functions inherited from PedeLabelerBase
virtual void addCalibrations (const std::vector< IntegratedCalibrationBase * > &iCals)
 tell labeler to treat also integrated calibrations More...
 
const AlignableExtrasalignableExtras () const
 
const AlignableMuonalignableMuon () const
 
const AlignableTrackeralignableTracker () const
 
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 ~PedeLabelerBase ()
 

Private Types

typedef std::map< Alignable *, unsigned int > AlignableToIdMap
 
typedef AlignableToIdMap::value_type AlignableToIdPair
 
typedef std::map< Alignable *, RunRangeParamMapAlignableToRunRangeRangeMap
 
typedef AlignableToRunRangeRangeMap::value_type AlignableToRunRangeRangePair
 
typedef std::map< unsigned int, Alignable * > IdToAlignableMap
 
typedef std::map< unsigned int, RunRangeVectorRunRangeParamMap
 
typedef std::vector< RunRangeRunRangeVector
 
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...
 
unsigned int buildRunRangeDependencyMap (AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras, const edm::ParameterSet &config)
 
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
 
unsigned int runRangeIndexFromLabel (unsigned int label) const
 

Private Attributes

AlignableToIdMap theAlignableToIdMap
 
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
 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
 reverse of the above More...
 

Additional Inherited Members

- Public Types inherited from PedeLabelerBase
using RunNumber = align::RunNumber
 
using RunRange = align::RunRange
 
using RunRanges = align::RunRanges
 
- 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
 
const AlignableObjectIdobjectIdProvider () const
 Return tracker alignable object ID provider derived from the tracker's geometry. More...
 
- 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 13:12:41
Revision
1.1

(last update by

Author
mussgill

)

Definition at line 31 of file RunRangeDependentPedeLabeler.h.

Member Typedef Documentation

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

Definition at line 80 of file RunRangeDependentPedeLabeler.h.

typedef AlignableToIdMap::value_type RunRangeDependentPedeLabeler::AlignableToIdPair
private

Definition at line 81 of file RunRangeDependentPedeLabeler.h.

Definition at line 84 of file RunRangeDependentPedeLabeler.h.

typedef AlignableToRunRangeRangeMap::value_type RunRangeDependentPedeLabeler::AlignableToRunRangeRangePair
private

Definition at line 85 of file RunRangeDependentPedeLabeler.h.

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

Definition at line 86 of file RunRangeDependentPedeLabeler.h.

typedef std::map<unsigned int, RunRangeVector> RunRangeDependentPedeLabeler::RunRangeParamMap
private

Definition at line 83 of file RunRangeDependentPedeLabeler.h.

Definition at line 82 of file RunRangeDependentPedeLabeler.h.

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

Definition at line 87 of file RunRangeDependentPedeLabeler.h.

Constructor & Destructor Documentation

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

constructor from three Alignables (null pointers allowed )

Definition at line 28 of file RunRangeDependentPedeLabeler.cc.

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

30  : PedeLabelerBase(alignables, config),
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->buildRunRangeDependencyMap(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 theMaxNumberOfParameterInstances
reverse of the above
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:31
unsigned int buildRunRangeDependencyMap(AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras, const edm::ParameterSet &config)
unsigned int buildMap(const std::vector< Alignable * > &alis)
returns size of map
RunRangeDependentPedeLabeler::~RunRangeDependentPedeLabeler ( )

non-virtual destructor: do not inherit from this class

Definition at line 54 of file RunRangeDependentPedeLabeler.cc.

55 {
56 }

Member Function Documentation

Alignable * RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

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

Referenced by runRangeFromLabel(), and runRangeIndexFromLabel().

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<RunRangeDependentPedeLabeler*>(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=RunRangeDependentPedeLabeler::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
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
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

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

Referenced by runRangeFromLabel(), and runRangeIndexFromLabel().

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=RunRangeDependentPedeLabeler::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:189
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 RunRangeDependentPedeLabeler::alignableLabelFromLabel ( unsigned int  label) const
virtual

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

Implements PedeLabelerBase.

Definition at line 244 of file RunRangeDependentPedeLabeler.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 <= .. < theMaxNumParam, belonging to unique parameter label
unsigned int RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

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

83 {
84  if (!alignable) return 0;
85 
86  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
87  if (position != theAlignableToIdMap.end()) {
88  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
89  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
90  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(param);
91  if (positionParam!=(*positionAli).second.end()) {
92  if (instance>=(*positionParam).second.size()) {
93  throw cms::Exception("Alignment") << "RunRangeDependentPedeLabeler::alignableLabelFromParamAndRunRange: "
94  << "RunRangeIdx out of bounds.\n";
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=RunRangeDependentPedeLabeler::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:189
static PFTauRenderPlugin instance
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
Definition: DetId.h:18
static const unsigned int theParamInstanceOffset
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int RunRangeDependentPedeLabeler::buildMap ( const std::vector< Alignable * > &  alis)
private

returns size of map

Definition at line 471 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by RunRangeDependentPedeLabeler().

472 {
473  theAlignableToIdMap.clear(); // just in case of re-use...
474 
475  std::vector<Alignable*> allComps;
476 
477  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
478  if (*iAli) {
479  allComps.push_back(*iAli);
480  (*iAli)->recursiveComponents(allComps);
481  }
482  }
483 
484  unsigned int id = theMinLabel;
485  for (std::vector<Alignable*>::const_iterator iter = allComps.begin();
486  iter != allComps.end(); ++iter) {
487  theAlignableToIdMap.insert(AlignableToIdPair(*iter, id));
488  id += theMaxNumParam;
489  }
490 
491  // also care about las beams
492  theLasBeamToLabelMap.clear(); // just in case of re-use...
493  // FIXME: Temporarily hard code values stolen from
494  // https://twiki.cern.ch/twiki/bin/view/CMS/TkLasTrackBasedInterface#Beam_identifier .
495  unsigned int beamIds[] = { 0, 10, 20, 30, 40, 50, 60, 70, // TEC+ R4
496  1, 11, 21, 31, 41, 51, 61, 71, // TEC+ R6
497  100, 110, 120, 130, 140, 150, 160, 170, // TEC- R4
498  101, 111, 121, 131, 141, 151, 161, 171, // TEC- R6
499  200, 210, 220, 230, 240, 250, 260, 270};// AT
500 
501  const size_t nBeams = sizeof(beamIds)/sizeof(beamIds[0]);
502  for (size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
503  //edm::LogInfo("Alignment") << "Las beam " << beamIds[iBeam] << " gets label " << id << ".";
504  theLasBeamToLabelMap[beamIds[iBeam]] = id;
505  id += theMaxNumParam;
506  }
507 
508  if (id > theParamInstanceOffset) { // 'overflow' per instance
509  throw cms::Exception("Alignment") << "@SUB=RunRangeDependentPedeLabeler::buildMap: "
510  << "Too many labels per instance (" << id-1 << ") leading to double use, "
511  << "increase PedeLabelerBase::theParamInstanceOffset!\n";
512  }
513  // return combined size
514  return theAlignableToIdMap.size() + theLasBeamToLabelMap.size();
515 }
AlignableToIdMap::value_type AlignableToIdPair
static const unsigned int theMinLabel
static const unsigned int theMaxNumParam
UintUintMap theLasBeamToLabelMap
reverse map
static const unsigned int theParamInstanceOffset
unsigned int RunRangeDependentPedeLabeler::buildReverseMap ( )
private

returns size of map

Definition at line 518 of file RunRangeDependentPedeLabeler.cc.

References DEFINE_EDM_PLUGIN, crabWrapper::key, hpstanc_transforms::max, numberOfParameterInstances(), theAlignableToIdMap, theIdToAlignableMap, theLabelToLasBeamMap, theLasBeamToLabelMap, theMaxNumberOfParameterInstances, and PedeLabelerBase::theParamInstanceOffset.

Referenced by RunRangeDependentPedeLabeler().

519 {
520 
521  // alignables
522  theIdToAlignableMap.clear(); // just in case of re-use...
523 
524  for (AlignableToIdMap::iterator it = theAlignableToIdMap.begin();
525  it != theAlignableToIdMap.end(); ++it) {
526  const unsigned int key = (*it).second;
527  Alignable *ali = (*it).first;
528  const unsigned int nInstances = this->numberOfParameterInstances(ali, -1);
530  for (unsigned int iInstance=0;iInstance<nInstances;++iInstance) {
531  theIdToAlignableMap[key+iInstance*theParamInstanceOffset] = ali;
532  }
533  }
534 
535  // las beams
536  theLabelToLasBeamMap.clear(); // just in case of re-use...
537 
538  for (UintUintMap::const_iterator it = theLasBeamToLabelMap.begin();
539  it != theLasBeamToLabelMap.end(); ++it) {
540  theLabelToLasBeamMap[it->second] = it->first; //revert key/value
541  }
542 
543  // return combined size
544  return theIdToAlignableMap.size() + theLabelToLasBeamMap.size();
545 }
UintUintMap theLabelToLasBeamMap
labels for las beams
unsigned int numberOfParameterInstances(Alignable *alignable, int param=-1) const
returns the number of instances for a given parameter
unsigned int theMaxNumberOfParameterInstances
reverse of the above
IdToAlignableMap theIdToAlignableMap
providing unique ID for alignable, space for param IDs
UintUintMap theLasBeamToLabelMap
reverse map
static const unsigned int theParamInstanceOffset
unsigned int RunRangeDependentPedeLabeler::buildRunRangeDependencyMap ( AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras extras,
const edm::ParameterSet config 
)
private

Definition at line 345 of file RunRangeDependentPedeLabeler.cc.

References AlignmentParameterSelector::addSelection(), cond::TimeTypeSpecs::beginValue, AlignmentParameterSelector::clear(), convertParamSel(), decompose(), Exception, plotBeamSpotDB::first, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, AlignableObjectId::idToString(), NULL, PedeLabelerBase::objectIdProvider(), cond::runnumber, edm::second(), AlignmentParameterSelector::selectedAlignables(), AlignmentParameters::size(), groupFilesInBlocks::temp, theAlignableToRunRangeRangeMap, cond::timeTypeSpecs, and edm::tokenize().

Referenced by RunRangeDependentPedeLabeler().

349 {
350  static std::atomic<bool> oldRunRangeSelectionWarning{ false };
351 
353 
354  AlignmentParameterSelector selector(aliTracker, aliMuon, aliExtras);
355 
356  std::vector<char> paramSelDummy(6, '1');
357 
358  const std::vector<edm::ParameterSet> RunRangeSelectionVPSet =
359  config.getUntrackedParameter<std::vector<edm::ParameterSet> >("RunRangeSelection");
360 
361  for (std::vector<edm::ParameterSet>::const_iterator iter = RunRangeSelectionVPSet.begin();
362  iter != RunRangeSelectionVPSet.end();
363  ++iter) {
364 
365  const std::vector<std::string> tempRunRanges = (*iter).getParameter<std::vector<std::string> >("RunRanges");
366  if (tempRunRanges.size()==0) {
367  throw cms::Exception("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
368  << "RunRanges empty\n";
369  }
370 
373  long int temp;
374  for (std::vector<std::string>::const_iterator iRunRange = tempRunRanges.begin();
375  iRunRange != tempRunRanges.end();
376  ++iRunRange) {
377  if ((*iRunRange).find(':')==std::string::npos) {
378 
380  temp = strtol((*iRunRange).c_str(), 0, 0);
381  if (temp!=-1) first = temp;
382 
383  } else {
384 
385  bool expected = false;
386  if (oldRunRangeSelectionWarning.compare_exchange_strong(expected,true)) {
387  edm::LogWarning("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap"
388  << "Config file contains old format for 'RunRangeSelection'. Only the start run\n"
389  << "number is used internally. The number of the last run is ignored and can be\n"
390  << "safely removed from the config file.\n";
391  }
392 
393  std::vector<std::string> tokens = edm::tokenize(*iRunRange, ":");
395  temp = strtol(tokens[0].c_str(), 0, 0);
396  if (temp!=-1) first = temp;
397 
398  }
399 
400  RunRanges.push_back(std::pair<cond::Time_t,cond::Time_t>(first, cond::timeTypeSpecs[cond::runnumber].endValue));
401  }
402 
403  for (unsigned int i = 0;i<RunRanges.size()-1;++i) {
404  RunRanges[i].second = RunRanges[i+1].first - 1;
405  if (RunRanges[i].first > RunRanges[i].second) {
406  throw cms::Exception("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
407  << "Inconsistency in 'RunRangeSelection' parameter set.";
408  }
409  }
410 
411  const std::vector<std::string> selStrings = (*iter).getParameter<std::vector<std::string> >("selector");
412  for (std::vector<std::string>::const_iterator iSel = selStrings.begin();
413  iSel != selStrings.end();
414  ++iSel) {
415  std::vector<std::string> decompSel(this->decompose(*iSel, ','));
416 
417  if (decompSel.size()!=2) {
418  throw cms::Exception("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
419  << *iSel <<" should have at least 2 ','-separated parts\n";
420  }
421 
422  std::vector<unsigned int> selParam = this->convertParamSel(decompSel[1]);
423  selector.clear();
424  selector.addSelection(decompSel[0], paramSelDummy);
425 
426  const std::vector<Alignable*> &alis = selector.selectedAlignables();
427 
428  for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
429  iAli != alis.end();
430  ++iAli) {
431 
432  if((*iAli)->alignmentParameters() == NULL) {
433  throw cms::Exception("BadConfig")
434  << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
435  << "Run dependence configured for alignable of type "
436  << objectIdProvider().idToString((*iAli)->alignableObjectId())
437  << " at (" << (*iAli)->globalPosition().x() << ","<< (*iAli)->globalPosition().y() << "," << (*iAli)->globalPosition().z()<< "), "
438  << "but that has no parameters. Please check that all run "
439  << "dependent parameters are also selected for alignment.\n";
440  }
441 
442  for (std::vector<unsigned int>::const_iterator iParam = selParam.begin();
443  iParam != selParam.end();
444  ++iParam) {
445  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(*iAli);
446  if (positionAli!=theAlignableToRunRangeRangeMap.end()) {
447 
448  AlignmentParameters *AliParams = (*positionAli).first->alignmentParameters();
449  if (static_cast<int>(selParam[selParam.size()-1]) >= AliParams->size()) {
450  throw cms::Exception("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
451  << "mismatch in number of parameters\n";
452  }
453 
454  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(*iParam);
455  if (positionParam!=(*positionAli).second.end()) {
456  throw cms::Exception("BadConfig") << "@SUB=RunRangeDependentPedeLabeler::buildRunRangeDependencyMap\n"
457  << "RunRange range for parameter specified twice\n";
458  }
459  }
460 
461  theAlignableToRunRangeRangeMap[*iAli][*iParam] = RunRanges;
462  }
463  }
464  }
465  }
466 
467  return theAlignableToRunRangeRangeMap.size();
468 }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
T getUntrackedParameter(std::string const &, T const &) const
Time_t beginValue
Definition: Time.h:45
#define NULL
Definition: scimark2.h:8
U second(std::pair< T, U > const &p)
unsigned long long Time_t
Definition: Time.h:16
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
int size(void) const
Get number of parameters.
const char * idToString(align::StructureType type) const
std::vector< unsigned int > convertParamSel(const std::string &selString) const
align::RunRanges RunRanges
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker&#39;s geometry.
std::vector< std::string > decompose(const std::string &s, std::string::value_type delimiter) const
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
std::vector< unsigned int > RunRangeDependentPedeLabeler::convertParamSel ( const std::string &  selString) const
private

Definition at line 336 of file RunRangeDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildRunRangeDependencyMap().

337 {
338  std::vector<unsigned int> result;
339  for (std::string::size_type pos = 0; pos < selString.size(); ++pos) {
340  if (selString[pos]=='1') result.push_back(pos);
341  }
342  return result;
343 }
uint16_t size_type
std::vector< std::string > RunRangeDependentPedeLabeler::decompose ( const std::string &  s,
std::string::value_type  delimiter 
) const
private

Definition at line 316 of file RunRangeDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildRunRangeDependencyMap().

318 {
319  std::vector<std::string> result;
320 
321  std::string::size_type previousPos = 0;
322  while (true) {
323  const std::string::size_type delimiterPos = s.find(delimiter, previousPos);
324  if (delimiterPos == std::string::npos) {
325  result.push_back(s.substr(previousPos)); // until end
326  break;
327  }
328  result.push_back(s.substr(previousPos, delimiterPos - previousPos));
329  previousPos = delimiterPos + 1; // +1: skip delimiter
330  }
331 
332  return result;
333 }
uint16_t size_type
bool RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

References theAlignableToRunRangeRangeMap.

199 {
200  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
201  if (positionAli != theAlignableToRunRangeRangeMap.end()) return true;
202  return false;
203 }
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
unsigned int RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.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<RunRangeDependentPedeLabeler*>(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=RunRangeDependentPedeLabeler::lasBeamIdFromLabel"
282  << "Alignable label " << aliLabel << " not in map.";
283  return 0;
284  }
285 }
UintUintMap theLabelToLasBeamMap
labels for las beams
static const unsigned int theMinLabel
unsigned int alignableLabelFromLabel(unsigned int label) const
alignable label from parameter label (works also for alignable label...)
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int RunRangeDependentPedeLabeler::lasBeamLabel ( unsigned int  lasBeamId) const
virtual

Implements PedeLabelerBase.

Definition at line 115 of file RunRangeDependentPedeLabeler.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=RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler::maxNumberOfParameterInstances ( ) const
inlinevirtual

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

Implements PedeLabelerBase.

Definition at line 64 of file RunRangeDependentPedeLabeler.h.

References diffTwoXMLs::label.

unsigned int theMaxNumberOfParameterInstances
reverse of the above
unsigned int RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

References hpstanc_transforms::max, and theAlignableToRunRangeRangeMap.

Referenced by buildReverseMap().

207 {
208  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
209  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
210 
211  size_t nRunRanges = 1;
212  if (param==-1) {
213  for (RunRangeParamMap::const_iterator iParam = (*positionAli).second.begin();
214  iParam != (*positionAli).second.end();
215  ++iParam) {
216  nRunRanges = std::max(nRunRanges, iParam->second.size());
217  }
218  return nRunRanges;
219  } else {
220  RunRangeParamMap::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 }
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
unsigned int RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

References Exception, and PedeLabelerBase::theMaxNumParam.

130 {
131  if (parNum >= theMaxNumParam) {
132  throw cms::Exception("Alignment") << "@SUB=RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler::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 RunRangeDependentPedeLabeler.cc.

References Alignable::alignableObjectId(), AlignmentAlgorithmBase::EventInfo::eventId(), Exception, Alignable::id(), PFRecoTauDiscriminationByIsolation_cfi::offset, position, edm::EventID::run(), theAlignableToIdMap, theAlignableToRunRangeRangeMap, PedeLabelerBase::theMaxNumParam, and PedeLabelerBase::theParamInstanceOffset.

143 {
144  if (!alignable) return 0;
145 
146  if (parNum >= theMaxNumParam) {
147  throw cms::Exception("Alignment") << "@SUB=RunRangeDependentPedeLabeler::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  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
156  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
157 
158  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(parNum);
159  if (positionParam!=(*positionAli).second.end()) {
160 
161  int offset = 0;
162  const RunRangeVector & runRanges = (*positionParam).second;
163  for (RunRangeVector::const_iterator iRunRange = runRanges.begin();
164  iRunRange != runRanges.end();
165  ++iRunRange) {
166  if (eventInfo.eventId().run() >= iRunRange->first &&
167  eventInfo.eventId().run() <= iRunRange->second) {
168  return position->second + offset * theParamInstanceOffset + parNum;
169  }
170  offset++;
171  }
172  const DetId detId(alignable->id());
173  edm::LogError("LogicError")
174  << "@SUB=RunRangeDependentPedeLabeler::parameterLabel" << "Instance for Alignable "
175  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
176  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId()
177  << " for run " << eventInfo.eventId().run();
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=RunRangeDependentPedeLabeler::parameterLabel" << "Alignable "
191  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
192  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
193  return 0;
194  }
195 }
RunNumber_t run() const
Definition: EventID.h:39
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
const edm::EventID eventId() const
static const unsigned int theMaxNumParam
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
Definition: DetId.h:18
static const unsigned int theParamInstanceOffset
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int RunRangeDependentPedeLabeler::paramNumFromLabel ( unsigned int  paramLabel) const
virtual

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

Implements PedeLabelerBase.

Definition at line 233 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by alignableLabelFromLabel(), and runRangeFromLabel().

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

Reimplemented from PedeLabelerBase.

Definition at line 295 of file RunRangeDependentPedeLabeler.cc.

References alignableFromLabel(), alignableLabel(), paramNumFromLabel(), theAlignableToRunRangeRangeMap, PedeLabelerBase::theOpenRunRange, and PedeLabelerBase::theParamInstanceOffset.

296 {
298 
299  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(ali);
300  if (positionAli==theAlignableToRunRangeRangeMap.end())
301  return theOpenRunRange;
302 
303  unsigned int firstLabel = alignableLabel(ali);
304  unsigned int runRangeIndex = (label-firstLabel)/theParamInstanceOffset;
305  unsigned int paramNum = this->paramNumFromLabel(label);
306 
307  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(paramNum);
308  if (positionParam==(*positionAli).second.end()) {
309  return theOpenRunRange;
310  }
311 
312  return positionParam->second[runRangeIndex];
313 }
unsigned int alignableLabel(Alignable *alignable) const
Return 32-bit unique label for alignable, 0 indicates failure.
Alignable * alignableFromLabel(unsigned int label) const
const RunRange theOpenRunRange
AlignableToRunRangeRangeMap theAlignableToRunRangeRangeMap
providing unique ID for alignable, space for param IDs
static const unsigned int theParamInstanceOffset
unsigned int paramNumFromLabel(unsigned int paramLabel) const
parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label
unsigned int RunRangeDependentPedeLabeler::runRangeIndexFromLabel ( unsigned int  label) const
private

Definition at line 287 of file RunRangeDependentPedeLabeler.cc.

References alignableFromLabel(), alignableLabel(), and PedeLabelerBase::theMaxNumParam.

288 {
290  unsigned int firstLabel = alignableLabel(ali);
291  return (label-firstLabel)/theMaxNumParam;
292 }
unsigned int alignableLabel(Alignable *alignable) const
Return 32-bit unique label for alignable, 0 indicates failure.
Alignable * alignableFromLabel(unsigned int label) const
static const unsigned int theMaxNumParam

Member Data Documentation

AlignableToIdMap RunRangeDependentPedeLabeler::theAlignableToIdMap
private
AlignableToRunRangeRangeMap RunRangeDependentPedeLabeler::theAlignableToRunRangeRangeMap
private
IdToAlignableMap RunRangeDependentPedeLabeler::theIdToAlignableMap
private

providing unique ID for alignable, space for param IDs

Definition at line 105 of file RunRangeDependentPedeLabeler.h.

Referenced by alignableFromLabel(), and buildReverseMap().

UintUintMap RunRangeDependentPedeLabeler::theLabelToLasBeamMap
private

labels for las beams

Definition at line 107 of file RunRangeDependentPedeLabeler.h.

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

UintUintMap RunRangeDependentPedeLabeler::theLasBeamToLabelMap
private

reverse map

Definition at line 106 of file RunRangeDependentPedeLabeler.h.

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

unsigned int RunRangeDependentPedeLabeler::theMaxNumberOfParameterInstances
private

reverse of the above

Definition at line 108 of file RunRangeDependentPedeLabeler.h.

Referenced by buildReverseMap().