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
 
 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
 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...
 
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 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 71 of file MomentumDependentPedeLabeler.h.

typedef AlignableToIdMap::value_type MomentumDependentPedeLabeler::AlignableToIdPair
private

Definition at line 72 of file MomentumDependentPedeLabeler.h.

Definition at line 76 of file MomentumDependentPedeLabeler.h.

typedef AlignableToMomentumRangeMap::value_type MomentumDependentPedeLabeler::AlignableToMomentumRangePair
private

Definition at line 77 of file MomentumDependentPedeLabeler.h.

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

Definition at line 78 of file MomentumDependentPedeLabeler.h.

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

Definition at line 73 of file MomentumDependentPedeLabeler.h.

Definition at line 75 of file MomentumDependentPedeLabeler.h.

Definition at line 74 of file MomentumDependentPedeLabeler.h.

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

Definition at line 79 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 26 of file MomentumDependentPedeLabeler.cc.

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

28  :PedeLabelerBase(alignables, config),
29  theOpenMomentumRange(std::pair<float,float>(0.0, 10000.0))
30 {
31  std::vector<Alignable*> alis;
32  alis.push_back(alignables.aliTracker_);
33  alis.push_back(alignables.aliMuon_);
34 
35  if (alignables.aliExtras_) {
36  align::Alignables allExtras = alignables.aliExtras_->components();
37  for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
38  alis.push_back(*it);
39  }
40  }
41 
42  this->buildMomentumDependencyMap(alignables.aliTracker_,
43  alignables.aliMuon_,
44  alignables.aliExtras_,
45  config);
46  this->buildMap(alis);
47 }
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 )
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 51 of file MomentumDependentPedeLabeler.cc.

52 {
53 }

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 247 of file MomentumDependentPedeLabeler.cc.

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

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

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

58 {
59  if (!alignable) return 0;
60 
61  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
62  if (position != theAlignableToIdMap.end()) {
63  return position->second;
64  } else {
65  const DetId detId(alignable->id());
66  //throw cms::Exception("LogicError")
67  edm::LogError("LogicError")
68  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
69  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
70  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
71  return 0;
72  }
73 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Definition: DetId.h:20
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 241 of file MomentumDependentPedeLabeler.cc.

References paramNumFromLabel().

Referenced by alignableFromLabel(), and lasBeamIdFromLabel().

242 {
243  return paramLabel - this->paramNumFromLabel(paramLabel);
244 }
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 77 of file MomentumDependentPedeLabeler.cc.

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

80 {
81  if (!alignable) return 0;
82 
83  AlignableToIdMap::const_iterator position = theAlignableToIdMap.find(alignable);
84  if (position != theAlignableToIdMap.end()) {
85  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
86  if (positionAli != theAlignableToMomentumRangeMap.end()) {
87  MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(param);
88  if (positionParam!=(*positionAli).second.end()) {
89  if (instance>=(*positionParam).second.size()) {
90  throw cms::Exception("Alignment") << "@SUB=MomentumDependentPedeLabeler::alignableLabelFromParamAndMomentum"
91  << "iovIdx out of bounds";
92  }
93  return position->second + instance * theParamInstanceOffset;
94  } else {
95  return position->second;
96  }
97  } else {
98  return position->second;
99  }
100  } else {
101  const DetId detId(alignable->id());
102  //throw cms::Exception("LogicError")
103  edm::LogError("LogicError")
104  << "@SUB=MomentumDependentPedeLabeler::alignableLabel" << "Alignable "
105  << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
106  << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
107  return 0;
108  }
109 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
static PFTauRenderPlugin instance
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Definition: DetId.h:20
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 398 of file MomentumDependentPedeLabeler.cc.

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

Referenced by MomentumDependentPedeLabeler().

399 {
400  theAlignableToIdMap.clear(); // just in case of re-use...
401 
402  std::vector<Alignable*> allComps;
403 
404  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
405  if (*iAli) {
406  allComps.push_back(*iAli);
407  (*iAli)->recursiveComponents(allComps);
408  }
409  }
410 
411  unsigned int id = theMinLabel;
412  for (std::vector<Alignable*>::const_iterator iter = allComps.begin();
413  iter != allComps.end(); ++iter) {
414  theAlignableToIdMap.insert(AlignableToIdPair(*iter, id));
415  id += theMaxNumParam;
416  }
417 
418  // also care about las beams
419  theLasBeamToLabelMap.clear(); // just in case of re-use...
420  // FIXME: Temporarily hard code values stolen from
421  // https://twiki.cern.ch/twiki/bin/view/CMS/TkLasTrackBasedInterface#Beam_identifier .
422  unsigned int beamIds[] = { 0, 10, 20, 30, 40, 50, 60, 70, // TEC+ R4
423  1, 11, 21, 31, 41, 51, 61, 71, // TEC+ R6
424  100, 110, 120, 130, 140, 150, 160, 170, // TEC- R4
425  101, 111, 121, 131, 141, 151, 161, 171, // TEC- R6
426  200, 210, 220, 230, 240, 250, 260, 270};// AT
427 
428  const size_t nBeams = sizeof(beamIds)/sizeof(beamIds[0]);
429  for (size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
430  //edm::LogInfo("Alignment") << "Las beam " << beamIds[iBeam] << " gets label " << id << ".";
431  theLasBeamToLabelMap[beamIds[iBeam]] = id;
432  id += theMaxNumParam;
433  }
434 
435  // return combined size
436  return theAlignableToIdMap.size() + theLasBeamToLabelMap.size();
437 }
static const unsigned int theMinLabel
static const unsigned int theMaxNumParam
UintUintMap theLasBeamToLabelMap
reverse map
AlignableToIdMap::value_type AlignableToIdPair
unsigned int MomentumDependentPedeLabeler::buildMomentumDependencyMap ( AlignableTracker aliTracker,
AlignableMuon aliMuon,
AlignableExtras extras,
const edm::ParameterSet config 
)
private

Definition at line 314 of file MomentumDependentPedeLabeler.cc.

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

Referenced by MomentumDependentPedeLabeler().

318 {
320 
321  AlignmentParameterSelector selector(aliTracker, aliMuon, aliExtras);
322 
323  std::vector<char> paramSelDumthe(6, '1');
324 
325  const std::vector<edm::ParameterSet> parameterInstancesVPSet =
326  config.getParameter<std::vector<edm::ParameterSet> >("parameterInstances");
327 
328  for (std::vector<edm::ParameterSet>::const_iterator iter = parameterInstancesVPSet.begin();
329  iter != parameterInstancesVPSet.end();
330  ++iter) {
331 
332  const std::vector<std::string> tempMomentumRanges = (*iter).getParameter<std::vector<std::string> >("momentumRanges");
333  if (tempMomentumRanges.size()==0) {
334  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
335  << "MomentumRanges empty\n";
336  }
337 
338  MomentumRangeVector MomentumRanges;
339  float lower;
340  float upper;
341  for (unsigned int iMomentum=0;iMomentum<tempMomentumRanges.size();++iMomentum) {
342  std::vector<std::string> tokens = edm::tokenize(tempMomentumRanges[iMomentum], ":");
343 
344  lower = strtod(tokens[0].c_str(), 0);
345  upper = strtod(tokens[1].c_str(), 0);
346 
347  MomentumRanges.push_back(std::pair<float,float>(lower, upper));
348  }
349 
350  const std::vector<std::string> selStrings = (*iter).getParameter<std::vector<std::string> >("selector");
351  for (std::vector<std::string>::const_iterator iSel = selStrings.begin();
352  iSel != selStrings.end();
353  ++iSel) {
354  std::vector<std::string> decompSel(this->decompose(*iSel, ','));
355 
356  if (decompSel.size()!=2) {
357  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
358  << *iSel <<" should have at least 2 ','-separated parts\n";
359  }
360 
361  std::vector<unsigned int> selParam = this->convertParamSel(decompSel[1]);
362  selector.clear();
363  selector.addSelection(decompSel[0], paramSelDumthe);
364 
365  const std::vector<Alignable*> &alis = selector.selectedAlignables();
366  for (std::vector<Alignable*>::const_iterator iAli = alis.begin();
367  iAli != alis.end();
368  ++iAli) {
369  for (std::vector<unsigned int>::const_iterator iParam = selParam.begin();
370  iParam != selParam.end();
371  ++iParam) {
372  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(*iAli);
373  if (positionAli!=theAlignableToMomentumRangeMap.end()) {
374 
375  AlignmentParameters *AliParams = (*positionAli).first->alignmentParameters();
376  if (static_cast<int>(selParam[selParam.size()-1]) >= AliParams->size()) {
377  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
378  << "mismatch in number of parameters\n";
379  }
380 
381  MomentumRangeParamMap::const_iterator positionParam = (*positionAli).second.find(*iParam);
382  if (positionParam!=(*positionAli).second.end()) {
383  throw cms::Exception("BadConfig") << "@SUB=MomentumDependentPedeLabeler::buildMomentumDependencyMap\n"
384  << "Momentum range for parameter specified twice\n";
385  }
386  }
387 
388  theAlignableToMomentumRangeMap[*iAli][*iParam] = MomentumRanges;
389  }
390  }
391  }
392  }
393 
394  return theAlignableToMomentumRangeMap.size();
395 }
T getParameter(std::string const &) const
std::vector< std::string > decompose(const std::string &s, std::string::value_type delimiter) const
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
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 440 of file MomentumDependentPedeLabeler.cc.

References combine::key, numberOfParameterInstances(), theAlignableToIdMap, theIdToAlignableMap, theLabelToLasBeamMap, theLasBeamToLabelMap, and PedeLabelerBase::theParamInstanceOffset.

441 {
442  // alignables
443  theIdToAlignableMap.clear(); // just in case of re-use...
444 
445  for (AlignableToIdMap::iterator it = theAlignableToIdMap.begin();
446  it != theAlignableToIdMap.end(); ++it) {
447  const unsigned int key = (*it).second;
448  Alignable *ali = (*it).first;
449  const unsigned int nInstances = this->numberOfParameterInstances(ali, -1);
450  for (unsigned int iInstance=0;iInstance<nInstances;++iInstance) {
451  theIdToAlignableMap[key+iInstance*theParamInstanceOffset] = ali;
452  }
453  }
454 
455  // las beams
456  theLabelToLasBeamMap.clear(); // just in case of re-use...
457 
458  for (UintUintMap::const_iterator it = theLasBeamToLabelMap.begin();
459  it != theLasBeamToLabelMap.end(); ++it) {
460  theLabelToLasBeamMap[it->second] = it->first; //revert key/value
461  }
462 
463  // return combined size
464  return theIdToAlignableMap.size() + theLabelToLasBeamMap.size();
465 }
UintUintMap theLabelToLasBeamMap
labels for las beams
unsigned int numberOfParameterInstances(Alignable *alignable, int param=-1) const
returns the number of instances for a given parameter
UintUintMap theLasBeamToLabelMap
reverse map
static const unsigned int theParamInstanceOffset
list key
Definition: combine.py:13
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 305 of file MomentumDependentPedeLabeler.cc.

References pos, and query::result.

Referenced by buildMomentumDependencyMap().

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

Definition at line 285 of file MomentumDependentPedeLabeler.cc.

References query::result.

Referenced by buildMomentumDependencyMap().

287 {
288  std::vector<std::string> result;
289 
290  std::string::size_type previousPos = 0;
291  while (true) {
292  const std::string::size_type delimiterPos = s.find(delimiter, previousPos);
293  if (delimiterPos == std::string::npos) {
294  result.push_back(s.substr(previousPos)); // until end
295  break;
296  }
297  result.push_back(s.substr(previousPos, delimiterPos - previousPos));
298  previousPos = delimiterPos + 1; // +1: skip delimiter
299  }
300 
301  return result;
302 }
uint16_t size_type
tuple result
Definition: query.py:137
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 195 of file MomentumDependentPedeLabeler.cc.

References theAlignableToMomentumRangeMap.

196 {
197  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
198  if (positionAli != theAlignableToMomentumRangeMap.end()) return true;
199  return false;
200 }
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 268 of file MomentumDependentPedeLabeler.cc.

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

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

References position, and theLasBeamToLabelMap.

113 {
114  UintUintMap::const_iterator position = theLasBeamToLabelMap.find(lasBeamId);
115  if (position != theLasBeamToLabelMap.end()) {
116  return position->second;
117  } else {
118  //throw cms::Exception("LogicError")
119  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::lasBeamLabel"
120  << "No label for beam Id " << lasBeamId;
121  return 0;
122  }
123 }
UintUintMap theLasBeamToLabelMap
reverse map
static int position[264][3]
Definition: ReadPGInfo.cc:509
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 203 of file MomentumDependentPedeLabeler.cc.

References max(), and theAlignableToMomentumRangeMap.

Referenced by buildReverseMap().

204 {
205  AlignableToMomentumRangeMap::const_iterator positionAli = theAlignableToMomentumRangeMap.find(alignable);
206  if (positionAli != theAlignableToMomentumRangeMap.end()) {
207 
208  size_t nMomentums = 1;
209  if (param==-1) {
210  for (MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.begin();
211  iParam != (*positionAli).second.end();
212  ++iParam) {
213  nMomentums = std::max(nMomentums, iParam->second.size());
214  }
215  return nMomentums;
216  } else {
217  MomentumRangeParamMap::const_iterator iParam = (*positionAli).second.find(param);
218  if (iParam != (*positionAli).second.end()) {
219  return iParam->second.size();
220  } else {
221  return 1;
222  }
223  }
224  }
225 
226  return 1;
227 }
const T & max(const T &a, const T &b)
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 126 of file MomentumDependentPedeLabeler.cc.

References edm::hlt::Exception, and PedeLabelerBase::theMaxNumParam.

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

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

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

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

Referenced by alignableLabelFromLabel().

231 {
232  if (paramLabel < theMinLabel) {
233  edm::LogError("LogicError") << "@SUB=MomentumDependentPedeLabeler::paramNumFromLabel"
234  << "Label " << paramLabel << " should be >= " << theMinLabel;
235  return 0;
236  }
237  return (paramLabel - theMinLabel) % theParamInstanceOffset;
238 }
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 94 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 95 of file MomentumDependentPedeLabeler.h.

Referenced by alignableFromLabel(), and buildReverseMap().

UintUintMap MomentumDependentPedeLabeler::theLabelToLasBeamMap
private

labels for las beams

Definition at line 97 of file MomentumDependentPedeLabeler.h.

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

UintUintMap MomentumDependentPedeLabeler::theLasBeamToLabelMap
private

reverse map

Definition at line 96 of file MomentumDependentPedeLabeler.h.

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

const MomentumRange MomentumDependentPedeLabeler::theOpenMomentumRange
private

reverse of the above

Definition at line 98 of file MomentumDependentPedeLabeler.h.