CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

AlignmentParameterBuilder Class Reference

#include <AlignmentParameterBuilder.h>

List of all members.

Public Member Functions

unsigned int add (const align::Alignables &alignables, AlignmentParametersFactory::ParametersType parType, const std::vector< bool > &sel)
 Add arbitrary selection of Alignables, return number of higher level Alignables.
bool add (Alignable *alignable, AlignmentParametersFactory::ParametersType parType, const std::vector< bool > &sel)
 Add a single Alignable, true if it is higher level, false if it is an AlignableDet.
void addAllSelections (const edm::ParameterSet &pSet)
 master initialisation method, PSet must have form as constructor wants it
unsigned int addSelections (const edm::ParameterSet &pset, AlignmentParametersFactory::ParametersType parType)
const align::Alignablesalignables () const
 Get list of alignables for which AlignmentParameters are built.
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableExtras *alignableExtras)
 Constructor from tracker only.
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableExtras *alignableExtras, const edm::ParameterSet &pSet)
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *alignableExtras, const edm::ParameterSet &pSet)
 Constructor from tracker and muon, plus selection.
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *alignableExtras)
 Constructor from tracker and muon.
void fixAlignables (int n)
 Remove n Alignables from list.
virtual ~AlignmentParameterBuilder ()
 destructor

Private Member Functions

bool addFullParamSel (AlignmentParameters *aliPar, const std::vector< char > &fullSel) const
 add SelectionUserVariables corresponding to fullSel
bool decodeParamSel (std::vector< char > &paramSelChar, std::vector< bool > &result) const

Private Attributes

AlignableExtrastheAlignableExtras
 extra Alignables
AlignableMuontheAlignableMuon
 Alignable muon.
align::Alignables theAlignables
 Vector of alignables.
AlignableTrackertheAlignableTracker
 Alignable tracker.

Detailed Description

Build Alignment Parameter Structure

Date:
2010/10/26 20:01:51
Revision:
1.11

(last update by

Author:
flucke

)

Definition at line 24 of file AlignmentParameterBuilder.h.


Constructor & Destructor Documentation

AlignmentParameterBuilder::AlignmentParameterBuilder ( AlignableTracker alignableTracker,
AlignableExtras alignableExtras 
) [explicit]

Constructor from tracker only.

Definition at line 28 of file AlignmentParameterBuilder.cc.

                                                                                       :
  theAlignables(),
  theAlignableTracker(alignableTracker),
  theAlignableMuon(0),
  theAlignableExtras(alignableExtras)
{
}
AlignmentParameterBuilder::AlignmentParameterBuilder ( AlignableTracker alignableTracker,
AlignableMuon alignableMuon,
AlignableExtras alignableExtras 
)

Constructor from tracker and muon.

Definition at line 38 of file AlignmentParameterBuilder.cc.

                                                                                       :
  theAlignables(), 
  theAlignableTracker(alignableTracker),
  theAlignableMuon(alignableMuon),
  theAlignableExtras(alignableExtras)
{
}
AlignmentParameterBuilder::AlignmentParameterBuilder ( AlignableTracker alignableTracker,
AlignableExtras alignableExtras,
const edm::ParameterSet pSet 
)

Constructor adding selections by passing the ParameterSet named 'AlignmentParameterSelector' (expected in pSet) to addSelections(..)

Definition at line 50 of file AlignmentParameterBuilder.cc.

References addAllSelections().

                                                                                  :
  theAlignables(), 
  theAlignableTracker(alignableTracker),
  theAlignableMuon(0),
  theAlignableExtras(alignableExtras)
{
  this->addAllSelections(pSet);
}
AlignmentParameterBuilder::AlignmentParameterBuilder ( AlignableTracker alignableTracker,
AlignableMuon alignableMuon,
AlignableExtras alignableExtras,
const edm::ParameterSet pSet 
)

Constructor from tracker and muon, plus selection.

Definition at line 62 of file AlignmentParameterBuilder.cc.

References addAllSelections().

                                                                                  :
  theAlignables(), 
  theAlignableTracker(alignableTracker),
  theAlignableMuon(alignableMuon),
  theAlignableExtras(alignableExtras)
{
  this->addAllSelections(pSet);
}
virtual AlignmentParameterBuilder::~AlignmentParameterBuilder ( ) [inline, virtual]

destructor

Definition at line 48 of file AlignmentParameterBuilder.h.

{};

Member Function Documentation

unsigned int AlignmentParameterBuilder::add ( const align::Alignables alignables,
AlignmentParametersFactory::ParametersType  parType,
const std::vector< bool > &  sel 
)

Add arbitrary selection of Alignables, return number of higher level Alignables.

Definition at line 146 of file AlignmentParameterBuilder.cc.

Referenced by addSelections().

{

  unsigned int nHigherLevel = 0;

  for (align::Alignables::const_iterator iAli = alignables.begin();
       iAli != alignables.end(); ++iAli) {
    if (this->add(*iAli, parType, sel)) ++nHigherLevel;
  }

  return nHigherLevel;
}
bool AlignmentParameterBuilder::add ( Alignable alignable,
AlignmentParametersFactory::ParametersType  parType,
const std::vector< bool > &  sel 
)

Add a single Alignable, true if it is higher level, false if it is an AlignableDet.

Definition at line 130 of file AlignmentParameterBuilder.cc.

References align::AlignableDet, align::AlignableDetUnit, Alignable::alignableObjectId(), AlignmentParametersFactory::createParameters(), Alignable::setAlignmentParameters(), and theAlignables.

{ 
  AlignmentParameters *paras = AlignmentParametersFactory::createParameters(alignable, parType, sel);
  alignable->setAlignmentParameters(paras);
  theAlignables.push_back(alignable);

  const int aliTypeId = alignable->alignableObjectId();
  const bool isHigherLevel = (aliTypeId != align::AlignableDet
                              && aliTypeId != align::AlignableDetUnit);
  return isHigherLevel;
}
void AlignmentParameterBuilder::addAllSelections ( const edm::ParameterSet pSet)

master initialisation method, PSet must have form as constructor wants it

Definition at line 75 of file AlignmentParameterBuilder.cc.

References addSelections(), AlignmentParameterSelector::decompose(), Exception, edm::ParameterSet::getParameter(), i, and AlignmentParametersFactory::parametersType().

Referenced by AlignmentParameterBuilder().

{
  AlignmentParameterSelector selector(0);
  std::vector<std::string> selsTypes(pSet.getParameter<std::vector<std::string> >("parameterTypes"));
  
  for (unsigned int i = 0; i < selsTypes.size(); ++i) {
    std::vector<std::string> selSetType(selector.decompose(selsTypes[i], ','));
    if (selSetType.size() != 2) {
      throw cms::Exception("BadConfig") << "AlignmentParameterBuilder"
                                        << "parameterTypes should contain 2 comma separated strings"
                                        << ", but found '" << selsTypes[i] << "'.";
    }
    this->addSelections(pSet.getParameter<edm::ParameterSet>(selSetType[0]),
                        AlignmentParametersFactory::parametersType(selSetType[1]));
  }
}
bool AlignmentParameterBuilder::addFullParamSel ( AlignmentParameters aliPar,
const std::vector< char > &  fullSel 
) const [private]

add SelectionUserVariables corresponding to fullSel

Definition at line 222 of file AlignmentParameterBuilder.cc.

References AlignmentParameters::setUserVariables().

Referenced by addSelections().

{
  if (!aliParams) return false;

  aliParams->setUserVariables(new SelectionUserVariables(fullSel));

  return true;
}
unsigned int AlignmentParameterBuilder::addSelections ( const edm::ParameterSet pset,
AlignmentParametersFactory::ParametersType  parType 
)

Add selections of Alignables, using AlignmenParameterSelector::addSelections. For each Alignable, AlignmentParameters of type parType will be attached using the selection of active parameters done in AlignmenParameterSelector, e.g. for RigidBody a selection string '11100' selects the degrees of freedom in (x,y,z), but not (alpha,beta,gamma). Returns number of added selections

Definition at line 93 of file AlignmentParameterBuilder.cc.

References add(), addFullParamSel(), AlignmentParameterSelector::addSelections(), alignables(), decodeParamSel(), AlignmentParametersFactory::parametersTypeName(), AlignmentParameterSelector::selectedAlignables(), AlignmentParameterSelector::selectedParameters(), theAlignableExtras, theAlignableMuon, theAlignables, and theAlignableTracker.

Referenced by addAllSelections().

{

  const unsigned int oldAliSize = theAlignables.size();

  AlignmentParameterSelector selector( theAlignableTracker, theAlignableMuon, theAlignableExtras );
  const unsigned int addedSets = selector.addSelections(pSet);

  const align::Alignables &alignables = selector.selectedAlignables();
  const std::vector<std::vector<char> > &paramSels = selector.selectedParameters();

  align::Alignables::const_iterator iAli = alignables.begin();
  std::vector<std::vector<char> >::const_iterator iParamSel = paramSels.begin();
  unsigned int nHigherLevel = 0;

  while (iAli != alignables.end() && iParamSel != paramSels.end()) {
    std::vector<bool> boolParSel;
    std::vector<char> parSel(*iParamSel); // copy, since decodeParamSel may manipulate
    bool charSelIsGeneral = this->decodeParamSel(parSel, boolParSel);
    if (this->add(*iAli, parType, boolParSel)) ++nHigherLevel;
    if (charSelIsGeneral) this->addFullParamSel((*iAli)->alignmentParameters(), parSel);

    ++iAli;
    ++iParamSel;
  }

  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::addSelections"
                            << " Added " << addedSets << " set(s) of alignables with "
                            << theAlignables.size() - oldAliSize << " alignables in total,"
                            << " of which " << nHigherLevel << " are higher level "
                            << "(using " << parametersTypeName(parType) << "AlignmentParameters).";
   
  return addedSets;
}
const align::Alignables& AlignmentParameterBuilder::alignables ( ) const [inline]

Get list of alignables for which AlignmentParameters are built.

Definition at line 70 of file AlignmentParameterBuilder.h.

References theAlignables.

Referenced by addSelections().

{ return theAlignables; };
bool AlignmentParameterBuilder::decodeParamSel ( std::vector< char > &  paramSelChar,
std::vector< bool > &  result 
) const [private]

First remove all spaces (' ') from char selection 'paramSelChar' (coming from ParameterSelector) and then convert the selection to bool (for AlignmentParameters). True if (after removal of spaces) anything else than 0 and 1 is found in vector<char>.

Definition at line 193 of file AlignmentParameterBuilder.cc.

References pos, and python::multivaluedict::remove().

Referenced by addSelections().

{
  result.clear();
  // remove all spaces from paramSelChar - useful to group the parameters if they are many
  paramSelChar.erase(std::remove(paramSelChar.begin(), paramSelChar.end(), ' '),
                     paramSelChar.end());

  bool anyNon01 = false;

  for (unsigned int pos = 0; pos < paramSelChar.size(); ++pos) {

    switch (paramSelChar[pos]) {
    default:
      anyNon01 = true;
      // no break;
    case '1':
      result.push_back(true);
      break;
    case '0':
      result.push_back(false);
      break;
    }
  }

  return anyNon01;
}
void AlignmentParameterBuilder::fixAlignables ( int  n)

Remove n Alignables from list.

Definition at line 162 of file AlignmentParameterBuilder.cc.

References i, and theAlignables.

{

  if (n<1 || n>3) {
    edm::LogError("BadArgument") << " n = " << n << " is not in [1,3]";
    return;
  }

  align::Alignables theNewAlignables;
  int i=0;
  int imax = theAlignables.size();
  for ( align::Alignables::const_iterator ia=theAlignables.begin();
        ia!=theAlignables.end();  ia++ ) 
        {
          i++;
          if ( n==1 && i>1 ) 
                theNewAlignables.push_back(*ia);
          else if ( n==2 && i>1 && i<imax ) 
                theNewAlignables.push_back(*ia);
          else if ( n==3 && i>2 && i<imax) 
                theNewAlignables.push_back(*ia);
        }

  theAlignables = theNewAlignables;

  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::fixAlignables"
                            << "removing " << n << " alignables, so that " 
                            << theAlignables.size() << " alignables left";
}

Member Data Documentation

extra Alignables

Definition at line 95 of file AlignmentParameterBuilder.h.

Referenced by addSelections().

Alignable muon.

Definition at line 92 of file AlignmentParameterBuilder.h.

Referenced by addSelections().

Vector of alignables.

Definition at line 86 of file AlignmentParameterBuilder.h.

Referenced by add(), addSelections(), alignables(), and fixAlignables().

Alignable tracker.

Definition at line 89 of file AlignmentParameterBuilder.h.

Referenced by addSelections().