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
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...
 
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
*, RunRangeParamMap
AlignableToRunRangeRangeMap
 
typedef
AlignableToRunRangeRangeMap::value_type 
AlignableToRunRangeRangePair
 
typedef std::map< unsigned int,
Alignable * > 
IdToAlignableMap
 
typedef std::map< unsigned int,
RunRangeVector
RunRangeParamMap
 
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
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 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 27 of file RunRangeDependentPedeLabeler.cc.

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

29  : PedeLabelerBase(alignables, config),
31 {
32  std::vector<Alignable*> alis;
33  alis.push_back(alignables.aliTracker_);
34  alis.push_back(alignables.aliMuon_);
35 
36  if (alignables.aliExtras_) {
37  align::Alignables allExtras = alignables.aliExtras_->components();
38  for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
39  alis.push_back(*it);
40  }
41  }
42 
43  this->buildRunRangeDependencyMap(alignables.aliTracker_,
44  alignables.aliMuon_,
45  alignables.aliExtras_,
46  config);
47  this->buildMap(alis);
48  this->buildReverseMap(); // needed already now to 'fill' theMaxNumberOfParameterInstances
49 }
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:28
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 53 of file RunRangeDependentPedeLabeler.cc.

54 {
55 }

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 249 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by runRangeFromLabel(), and runRangeIndexFromLabel().

250 {
251  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
252  if (aliLabel < theMinLabel) return 0; // error already given
253 
254  if (theIdToAlignableMap.empty()) const_cast<RunRangeDependentPedeLabeler*>(this)->buildReverseMap();
255  IdToAlignableMap::const_iterator position = theIdToAlignableMap.find(aliLabel);
256  if (position != theIdToAlignableMap.end()) {
257  return position->second;
258  } else {
259  // error only if not in lasBeamMap:
260  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
261  if (position == theLabelToLasBeamMap.end()) {
262  edm::LogError("LogicError") << "@SUB=RunRangeDependentPedeLabeler::alignableFromLabel"
263  << "Alignable label " << aliLabel << " not in map.";
264  }
265  return 0;
266  }
267 }
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 59 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by runRangeFromLabel(), and runRangeIndexFromLabel().

60 {
61  if (!alignable) return 0;
62 
63  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
64  if (position != theAlignableToIdMap.end()) {
65  return position->second;
66  } else {
67  const DetId detId(alignable->id());
68  //throw cms::Exception("LogicError")
69  edm::LogError("LogicError")
70  << "@SUB=RunRangeDependentPedeLabeler::alignableLabel" << "Alignable "
71  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
72  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
73  return 0;
74  }
75 }
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 RunRangeDependentPedeLabeler::alignableLabelFromLabel ( unsigned int  label) const
virtual

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

Implements PedeLabelerBase.

Definition at line 243 of file RunRangeDependentPedeLabeler.cc.

References paramNumFromLabel().

Referenced by alignableFromLabel(), and lasBeamIdFromLabel().

244 {
245  return paramLabel - this->paramNumFromLabel(paramLabel);
246 }
unsigned int paramNumFromLabel(unsigned int paramLabel) const
parameter number, 0 &lt;= .. &lt; 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 79 of file RunRangeDependentPedeLabeler.cc.

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

82 {
83  if (!alignable) return 0;
84 
85  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
86  if (position != theAlignableToIdMap.end()) {
87  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
88  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
89  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(param);
90  if (positionParam!=(*positionAli).second.end()) {
91  if (instance>=(*positionParam).second.size()) {
92  throw cms::Exception("Alignment") << "RunRangeDependentPedeLabeler::alignableLabelFromParamAndRunRange: "
93  << "RunRangeIdx out of bounds.\n";
94  }
95  return position->second + instance * theParamInstanceOffset;
96  } else {
97  return position->second;
98  }
99  } else {
100  return position->second;
101  }
102  } else {
103  const DetId detId(alignable->id());
104  //throw cms::Exception("LogicError")
105  edm::LogError("LogicError")
106  << "@SUB=RunRangeDependentPedeLabeler::alignableLabel" << "Alignable "
107  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
108  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
109  return 0;
110  }
111 }
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.
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 470 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by RunRangeDependentPedeLabeler().

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

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

Referenced by RunRangeDependentPedeLabeler().

518 {
519 
520  // alignables
521  theIdToAlignableMap.clear(); // just in case of re-use...
522 
523  for (AlignableToIdMap::iterator it = theAlignableToIdMap.begin();
524  it != theAlignableToIdMap.end(); ++it) {
525  const unsigned int key = (*it).second;
526  Alignable *ali = (*it).first;
527  const unsigned int nInstances = this->numberOfParameterInstances(ali, -1);
529  for (unsigned int iInstance=0;iInstance<nInstances;++iInstance) {
530  theIdToAlignableMap[key+iInstance*theParamInstanceOffset] = ali;
531  }
532  }
533 
534  // las beams
535  theLabelToLasBeamMap.clear(); // just in case of re-use...
536 
537  for (UintUintMap::const_iterator it = theLasBeamToLabelMap.begin();
538  it != theLasBeamToLabelMap.end(); ++it) {
539  theLabelToLasBeamMap[it->second] = it->first; //revert key/value
540  }
541 
542  // return combined size
543  return theIdToAlignableMap.size() + theLabelToLasBeamMap.size();
544 }
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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 344 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by RunRangeDependentPedeLabeler().

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

Definition at line 335 of file RunRangeDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildRunRangeDependencyMap().

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

Definition at line 315 of file RunRangeDependentPedeLabeler.cc.

References mps_fire::result.

Referenced by buildRunRangeDependencyMap().

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

References theAlignableToRunRangeRangeMap.

198 {
199  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
200  if (positionAli != theAlignableToRunRangeRangeMap.end()) return true;
201  return false;
202 }
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 270 of file RunRangeDependentPedeLabeler.cc.

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

271 {
272  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
273  if (aliLabel < theMinLabel) return 0; // error already given
274 
275  if (theLabelToLasBeamMap.empty()) const_cast<RunRangeDependentPedeLabeler*>(this)->buildReverseMap();
276  UintUintMap::const_iterator position = theLabelToLasBeamMap.find(aliLabel);
277  if (position != theLabelToLasBeamMap.end()) {
278  return position->second;
279  } else {
280  edm::LogError("LogicError") << "@SUB=RunRangeDependentPedeLabeler::lasBeamIdFromLabel"
281  << "Alignable label " << aliLabel << " not in map.";
282  return 0;
283  }
284 }
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 114 of file RunRangeDependentPedeLabeler.cc.

References position, and theLasBeamToLabelMap.

115 {
116  UintUintMap::const_iterator position = theLasBeamToLabelMap.find(lasBeamId);
117  if (position != theLasBeamToLabelMap.end()) {
118  return position->second;
119  } else {
120  //throw cms::Exception("LogicError")
121  edm::LogError("LogicError") << "@SUB=RunRangeDependentPedeLabeler::lasBeamLabel"
122  << "No label for beam Id " << lasBeamId;
123  return 0;
124  }
125 }
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 theMaxNumberOfParameterInstances.

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 205 of file RunRangeDependentPedeLabeler.cc.

References bookConverter::max, and theAlignableToRunRangeRangeMap.

Referenced by buildReverseMap().

206 {
207  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
208  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
209 
210  size_t nRunRanges = 1;
211  if (param==-1) {
212  for (RunRangeParamMap::const_iterator iParam = (*positionAli).second.begin();
213  iParam != (*positionAli).second.end();
214  ++iParam) {
215  nRunRanges = std::max(nRunRanges, iParam->second.size());
216  }
217  return nRunRanges;
218  } else {
219  RunRangeParamMap::const_iterator iParam = (*positionAli).second.find(param);
220  if (iParam != (*positionAli).second.end()) {
221  return iParam->second.size();
222  } else {
223  return 1;
224  }
225  }
226  }
227 
228  return 1;
229 }
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 128 of file RunRangeDependentPedeLabeler.cc.

References Exception, and PedeLabelerBase::theMaxNumParam.

129 {
130  if (parNum >= theMaxNumParam) {
131  throw cms::Exception("Alignment") << "@SUB=RunRangeDependentPedeLabeler::parameterLabel"
132  << "Parameter number " << parNum
133  << " out of range 0 <= num < " << theMaxNumParam;
134  }
135  return aliLabel + parNum;
136 }
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 139 of file RunRangeDependentPedeLabeler.cc.

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

142 {
143  if (!alignable) return 0;
144 
145  if (parNum >= theMaxNumParam) {
146  throw cms::Exception("Alignment") << "@SUB=RunRangeDependentPedeLabeler::parameterLabel"
147  << "Parameter number " << parNum
148  << " out of range 0 <= num < " << theMaxNumParam;
149  }
150 
151  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
152  if (position != theAlignableToIdMap.end()) {
153 
154  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(alignable);
155  if (positionAli != theAlignableToRunRangeRangeMap.end()) {
156 
157  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(parNum);
158  if (positionParam!=(*positionAli).second.end()) {
159 
160  int offset = 0;
161  const RunRangeVector & runRanges = (*positionParam).second;
162  for (RunRangeVector::const_iterator iRunRange = runRanges.begin();
163  iRunRange != runRanges.end();
164  ++iRunRange) {
165  if (eventInfo.eventId().run() >= iRunRange->first &&
166  eventInfo.eventId().run() <= iRunRange->second) {
167  return position->second + offset * theParamInstanceOffset + parNum;
168  }
169  offset++;
170  }
171  const DetId detId(alignable->id());
172  edm::LogError("LogicError")
173  << "@SUB=RunRangeDependentPedeLabeler::parameterLabel" << "Instance for Alignable "
174  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
175  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId()
176  << " for run " << eventInfo.eventId().run();
177  return 0;
178  } else {
179  return position->second + parNum;
180  }
181 
182  } else {
183  return position->second + parNum;
184  }
185  } else {
186  const DetId detId(alignable->id());
187  //throw cms::Exception("LogicError")
188  edm::LogError("LogicError")
189  << "@SUB=RunRangeDependentPedeLabeler::parameterLabel" << "Alignable "
190  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
191  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
192  return 0;
193  }
194 }
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:185
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 232 of file RunRangeDependentPedeLabeler.cc.

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

Referenced by alignableLabelFromLabel(), and runRangeFromLabel().

233 {
234  if (paramLabel < theMinLabel) {
235  edm::LogError("LogicError") << "@SUB=RunRangeDependentPedeLabeler::paramNumFromLabel"
236  << "Label " << paramLabel << " should be >= " << theMinLabel;
237  return 0;
238  }
239  return (paramLabel - theMinLabel) % theMaxNumParam;
240 }
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 294 of file RunRangeDependentPedeLabeler.cc.

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

295 {
297 
298  AlignableToRunRangeRangeMap::const_iterator positionAli = theAlignableToRunRangeRangeMap.find(ali);
299  if (positionAli==theAlignableToRunRangeRangeMap.end())
300  return theOpenRunRange;
301 
302  unsigned int firstLabel = alignableLabel(ali);
303  unsigned int runRangeIndex = (label-firstLabel)/theParamInstanceOffset;
304  unsigned int paramNum = this->paramNumFromLabel(label);
305 
306  RunRangeParamMap::const_iterator positionParam = (*positionAli).second.find(paramNum);
307  if (positionParam==(*positionAli).second.end()) {
308  return theOpenRunRange;
309  }
310 
311  return positionParam->second[runRangeIndex];
312 }
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 &lt;= .. &lt; theMaxNumParam, belonging to unique parameter label
unsigned int RunRangeDependentPedeLabeler::runRangeIndexFromLabel ( unsigned int  label) const
private

Definition at line 286 of file RunRangeDependentPedeLabeler.cc.

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

287 {
289  unsigned int firstLabel = alignableLabel(ali);
290  return (label-firstLabel)/theMaxNumParam;
291 }
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(), and maxNumberOfParameterInstances().