CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes

PedeLabeler Class Reference

#include <PedeLabeler.h>

List of all members.

Public Member Functions

AlignablealignableFromLabel (unsigned int label) const
unsigned int alignableLabel (Alignable *alignable) const
 Return 32-bit unique label for alignable, 0 indicates failure.
unsigned int alignableLabelFromLabel (unsigned int label) const
 alignable label from parameter label (works also for alignable label...)
unsigned int lasBeamIdFromLabel (unsigned int label) const
unsigned int lasBeamLabel (unsigned int lasBeamId) const
unsigned int parameterLabel (unsigned int aliLabel, unsigned int parNum) const
unsigned int paramNumFromLabel (unsigned int paramLabel) const
 parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label
 PedeLabeler (Alignable *ali1, Alignable *ali2, AlignableExtras *extras)
 constructor from two Alignables (null pointers allowed )
 PedeLabeler (const std::vector< Alignable * > &alis)
 constructor from array of Alignables
 ~PedeLabeler ()

Static Public Attributes

static const unsigned int theMaxNumParam = RigidBodyAlignmentParameters::N_PARAM + 14
 reverse of the above
static const unsigned int theMinLabel = 1

Private Types

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

Private Member Functions

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

Private Attributes

AlignableToIdMap myAlignableToIdMap
IdToAlignableMap myIdToAlignableMap
 providing unique ID for alignable, space for param IDs
UintUintMap myLabelToLasBeamMap
 labels for las beams
UintUintMap myLasBeamToLabelMap
 reverse map

Detailed Description

provides labels for AlignmentParameters for pede

Author:
: Gero Flucke date : September 2007
Date:
2010/10/26 20:52:23
Revision:
1.4

(last update by

Author:
flucke

)

Definition at line 25 of file PedeLabeler.h.


Member Typedef Documentation

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

Definition at line 54 of file PedeLabeler.h.

typedef AlignableToIdMap::value_type PedeLabeler::AlignableToIdPair [private]

Definition at line 55 of file PedeLabeler.h.

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

Definition at line 56 of file PedeLabeler.h.

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

Definition at line 57 of file PedeLabeler.h.


Constructor & Destructor Documentation

PedeLabeler::PedeLabeler ( const std::vector< Alignable * > &  alis)

constructor from array of Alignables

Definition at line 25 of file PedeLabeler.cc.

References buildMap().

{
  this->buildMap(alis);
}
PedeLabeler::PedeLabeler ( Alignable ali1,
Alignable ali2,
AlignableExtras extras 
)

constructor from two Alignables (null pointers allowed )

Definition at line 31 of file PedeLabeler.cc.

References buildMap(), and AlignableExtras::components().

{
  std::vector<Alignable*> alis;
  alis.push_back(ali1);
  alis.push_back(ali2);

  if (extras) {
    align::Alignables allExtras = extras->components();
    for ( std::vector<Alignable*>::iterator it = allExtras.begin(); it != allExtras.end(); ++it ) {
      alis.push_back(*it);
    }
  }

  this->buildMap(alis);
}
PedeLabeler::~PedeLabeler ( )

non-virtual destructor: do not inherit from this class

Definition at line 49 of file PedeLabeler.cc.

{
}

Member Function Documentation

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

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

Definition at line 116 of file PedeLabeler.cc.

References alignableLabelFromLabel(), myIdToAlignableMap, myLabelToLasBeamMap, position, and theMinLabel.

Referenced by PedeReader::setParameter().

{
  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
  if (aliLabel < theMinLabel) return 0; // error already given
  
  if (myIdToAlignableMap.empty()) const_cast<PedeLabeler*>(this)->buildReverseMap();
  IdToAlignableMap::const_iterator position = myIdToAlignableMap.find(aliLabel);
  if (position != myIdToAlignableMap.end()) {
    return position->second;
  } else {
    // error only if not in lasBeamMap:
    UintUintMap::const_iterator position = myLabelToLasBeamMap.find(aliLabel);
    if (position == myLabelToLasBeamMap.end()) {
      edm::LogError("LogicError") << "@SUB=PedeLabeler::alignableFromLabel"
                                  << "Alignable label " << aliLabel << " not in map.";
    }
    return 0;
  }
}
unsigned int PedeLabeler::alignableLabel ( Alignable alignable) const

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

Definition at line 55 of file PedeLabeler.cc.

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

Referenced by MillePedeAlignmentAlgorithm::addPxbSurvey(), MillePedeAlignmentAlgorithm::buildUserVariables(), PedeReader::checkAliParams(), PedeSteerer::fixParameter(), PedeSteerer::hierarchyConstraint(), and PedeSteerer::presigmasFile().

{
  if (!alignable) return 0;

  AlignableToIdMap::const_iterator position = myAlignableToIdMap.find(alignable);
  if (position != myAlignableToIdMap.end()) {
    return position->second;
  } else {
    const DetId detId(alignable->id());
    //throw cms::Exception("LogicError") 
    edm::LogError("LogicError")
      << "@SUB=PedeLabeler::alignableLabel" << "Alignable "
      << typeid(*alignable).name() << " not in map, det/subdet/alignableStructureType = "
      << detId.det() << "/" << detId.subdetId() << "/" << alignable->alignableObjectId();
    return 0;
  }
}
unsigned int PedeLabeler::alignableLabelFromLabel ( unsigned int  label) const

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

Definition at line 110 of file PedeLabeler.cc.

References paramNumFromLabel().

Referenced by alignableFromLabel(), lasBeamIdFromLabel(), and PedeReader::setParameter().

unsigned int PedeLabeler::buildMap ( const std::vector< Alignable * > &  alis) [private]

returns size of map

Definition at line 154 of file PedeLabeler.cc.

References ExpressReco_HICollisions_FallBack::id, myAlignableToIdMap, myLasBeamToLabelMap, theMaxNumParam, and theMinLabel.

Referenced by PedeLabeler().

{
  myAlignableToIdMap.clear(); // just in case of re-use...

  std::vector<Alignable*> allComps;

  for (std::vector<Alignable*>::const_iterator iAli = alis.begin(); iAli != alis.end(); ++iAli) {
    if (*iAli) {
      allComps.push_back(*iAli);
      (*iAli)->recursiveComponents(allComps);
    }
  }

  unsigned int id = theMinLabel;
  for (std::vector<Alignable*>::const_iterator iter = allComps.begin();
       iter != allComps.end(); ++iter) {
    myAlignableToIdMap.insert(AlignableToIdPair(*iter, id));
    id += theMaxNumParam;
  }
  
  // also care about las beams
  myLasBeamToLabelMap.clear(); // just in case of re-use...
  // FIXME: Temporarily hard code values stolen from 
  // https://twiki.cern.ch/twiki/bin/view/CMS/TkLasTrackBasedInterface#Beam_identifier .
  unsigned int beamIds[] = {  0,  10,  20,  30,  40,  50,  60,  70, // TEC+ R4
                              1,  11,  21,  31,  41,  51,  61,  71, // TEC+ R6
                            100, 110, 120, 130, 140, 150, 160, 170, // TEC- R4
                            101, 111, 121, 131, 141, 151, 161, 171, // TEC- R6
                            200, 210, 220, 230, 240, 250, 260, 270};// AT

  const size_t nBeams = sizeof(beamIds)/sizeof(beamIds[0]);
  for (size_t iBeam = 0; iBeam < nBeams; ++iBeam) {
    //edm::LogInfo("Alignment") << "Las beam " << beamIds[iBeam] << " gets label " << id << ".";
    myLasBeamToLabelMap[beamIds[iBeam]] = id;
    id += theMaxNumParam;
  }

  // return combined size
  return myAlignableToIdMap.size() + myLasBeamToLabelMap.size();
}
unsigned int PedeLabeler::buildReverseMap ( ) [private]

returns size of map

Definition at line 196 of file PedeLabeler.cc.

References combine::key, myAlignableToIdMap, myIdToAlignableMap, myLabelToLasBeamMap, and myLasBeamToLabelMap.

{

  // alignables
  myIdToAlignableMap.clear();  // just in case of re-use...

  for (AlignableToIdMap::iterator it = myAlignableToIdMap.begin();
       it != myAlignableToIdMap.end(); ++it) {
    const unsigned int key = (*it).second;
    Alignable *ali = (*it).first;
    myIdToAlignableMap[key] = ali;
  }

  // las beams
  myLabelToLasBeamMap.clear(); // just in case of re-use...

  for (UintUintMap::const_iterator it = myLasBeamToLabelMap.begin();
       it != myLasBeamToLabelMap.end(); ++it) {
    myLabelToLasBeamMap[it->second] = it->first; //revert key/value
  }

  // return combined size
  return myIdToAlignableMap.size() + myLabelToLasBeamMap.size();
}
unsigned int PedeLabeler::lasBeamIdFromLabel ( unsigned int  label) const

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

Definition at line 137 of file PedeLabeler.cc.

References alignableLabelFromLabel(), myLabelToLasBeamMap, position, and theMinLabel.

Referenced by PedeReader::setParameter().

{
  const unsigned int aliLabel = this->alignableLabelFromLabel(label);
  if (aliLabel < theMinLabel) return 0; // error already given
  
  if (myLabelToLasBeamMap.empty()) const_cast<PedeLabeler*>(this)->buildReverseMap();
  UintUintMap::const_iterator position = myLabelToLasBeamMap.find(aliLabel);
  if (position != myLabelToLasBeamMap.end()) {
    return position->second;
  } else {
    edm::LogError("LogicError") << "@SUB=PedeLabeler::lasBeamIdFromLabel"
                                << "Alignable label " << aliLabel << " not in map.";
    return 0;
  }
}
unsigned int PedeLabeler::lasBeamLabel ( unsigned int  lasBeamId) const

Definition at line 74 of file PedeLabeler.cc.

References myLasBeamToLabelMap, and position.

Referenced by MillePedeAlignmentAlgorithm::addLasBeam().

{
  UintUintMap::const_iterator position = myLasBeamToLabelMap.find(lasBeamId);
  if (position != myLasBeamToLabelMap.end()) {
    return position->second;
  } else {
    //throw cms::Exception("LogicError") 
    edm::LogError("LogicError") << "@SUB=PedeLabeler::lasBeamLabel"
                                << "No label for beam Id " << lasBeamId;
    return 0;
  }
}
unsigned int PedeLabeler::parameterLabel ( unsigned int  aliLabel,
unsigned int  parNum 
) const

Definition at line 88 of file PedeLabeler.cc.

References Exception, and theMaxNumParam.

Referenced by MillePedeAlignmentAlgorithm::addLasBeam(), PedeSteerer::fixParameter(), PedeSteerer::hierarchyConstraint(), and PedeSteerer::presigmasFile().

{
  if (parNum >= theMaxNumParam) {
    throw cms::Exception("Alignment") << "@SUB=PedeLabeler::parameterLabel" 
                                      << "Parameter number " << parNum 
                                      << " out of range 0 <= num < " << theMaxNumParam;
  }
  return aliLabel + parNum;
}
unsigned int PedeLabeler::paramNumFromLabel ( unsigned int  paramLabel) const

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

Definition at line 99 of file PedeLabeler.cc.

References theMaxNumParam, and theMinLabel.

Referenced by alignableLabelFromLabel(), and PedeReader::setParameter().

{
  if (paramLabel < theMinLabel) {
    edm::LogError("LogicError") << "@SUB=PedeLabeler::paramNumFromLabel"
                                << "Label " << paramLabel << " should be >= " << theMinLabel;
    return 0;
  }
  return (paramLabel - theMinLabel) % theMaxNumParam;
}

Member Data Documentation

Definition at line 66 of file PedeLabeler.h.

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

providing unique ID for alignable, space for param IDs

Definition at line 67 of file PedeLabeler.h.

Referenced by alignableFromLabel(), and buildReverseMap().

labels for las beams

Definition at line 69 of file PedeLabeler.h.

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

reverse map

Definition at line 68 of file PedeLabeler.h.

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

const unsigned int PedeLabeler::theMaxNumParam = RigidBodyAlignmentParameters::N_PARAM + 14 [static]

reverse of the above

Definition at line 72 of file PedeLabeler.h.

Referenced by buildMap(), MillePedeMonitor::fillDerivatives(), MillePedeMonitor::init(), parameterLabel(), and paramNumFromLabel().

const unsigned int PedeLabeler::theMinLabel = 1 [static]

Definition at line 73 of file PedeLabeler.h.

Referenced by alignableFromLabel(), buildMap(), lasBeamIdFromLabel(), and paramNumFromLabel().