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 Member Functions | Private Attributes
AlignmentParameterBuilder Class Reference

#include <AlignmentParameterBuilder.h>

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. More...
 
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. More...
 
void addAllSelections (const edm::ParameterSet &pSet)
 master initialisation method, PSet must have form as constructor wants it More...
 
unsigned int addSelections (const edm::ParameterSet &pset, AlignmentParametersFactory::ParametersType parType)
 
const align::Alignablesalignables () const
 Get list of alignables for which AlignmentParameters are built. More...
 
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableExtras *alignableExtras)
 Constructor from tracker only. More...
 
 AlignmentParameterBuilder (AlignableTracker *alignableTracker, AlignableMuon *alignableMuon, AlignableExtras *alignableExtras)
 Constructor from tracker and muon. More...
 
 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. More...
 
void fixAlignables (int n)
 Remove n Alignables from list. More...
 
virtual ~AlignmentParameterBuilder ()
 destructor More...
 

Private Member Functions

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

Private Attributes

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

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.

29  :
30  theAlignables(),
31  theAlignableTracker(alignableTracker),
33  theAlignableExtras(alignableExtras)
34 {
35 }
AlignableExtras * theAlignableExtras
extra Alignables
AlignableMuon * theAlignableMuon
Alignable muon.
align::Alignables theAlignables
Vector of alignables.
AlignableTracker * theAlignableTracker
Alignable tracker.
AlignmentParameterBuilder::AlignmentParameterBuilder ( AlignableTracker alignableTracker,
AlignableMuon alignableMuon,
AlignableExtras alignableExtras 
)

Constructor from tracker and muon.

Definition at line 38 of file AlignmentParameterBuilder.cc.

40  :
41  theAlignables(),
42  theAlignableTracker(alignableTracker),
43  theAlignableMuon(alignableMuon),
44  theAlignableExtras(alignableExtras)
45 {
46 }
AlignableExtras * theAlignableExtras
extra Alignables
AlignableMuon * theAlignableMuon
Alignable muon.
align::Alignables theAlignables
Vector of alignables.
AlignableTracker * theAlignableTracker
Alignable tracker.
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().

52  :
53  theAlignables(),
54  theAlignableTracker(alignableTracker),
56  theAlignableExtras(alignableExtras)
57 {
58  this->addAllSelections(pSet);
59 }
AlignableExtras * theAlignableExtras
extra Alignables
AlignableMuon * theAlignableMuon
Alignable muon.
align::Alignables theAlignables
Vector of alignables.
AlignableTracker * theAlignableTracker
Alignable tracker.
void addAllSelections(const edm::ParameterSet &pSet)
master initialisation method, PSet must have form as constructor wants it
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().

65  :
66  theAlignables(),
67  theAlignableTracker(alignableTracker),
68  theAlignableMuon(alignableMuon),
69  theAlignableExtras(alignableExtras)
70 {
71  this->addAllSelections(pSet);
72 }
AlignableExtras * theAlignableExtras
extra Alignables
AlignableMuon * theAlignableMuon
Alignable muon.
align::Alignables theAlignables
Vector of alignables.
AlignableTracker * theAlignableTracker
Alignable tracker.
void addAllSelections(const edm::ParameterSet &pSet)
master initialisation method, PSet must have form as constructor wants it
virtual AlignmentParameterBuilder::~AlignmentParameterBuilder ( )
inlinevirtual

destructor

Definition at line 48 of file AlignmentParameterBuilder.h.

48 {};

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().

148 {
149 
150  unsigned int nHigherLevel = 0;
151 
152  for (align::Alignables::const_iterator iAli = alignables.begin();
153  iAli != alignables.end(); ++iAli) {
154  if (this->add(*iAli, parType, sel)) ++nHigherLevel;
155  }
156 
157  return nHigherLevel;
158 }
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.
const align::Alignables & alignables() const
Get list of alignables for which AlignmentParameters are built.
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.

133 {
135  alignable->setAlignmentParameters(paras);
136  theAlignables.push_back(alignable);
137 
138  const int aliTypeId = alignable->alignableObjectId();
139  const bool isHigherLevel = (aliTypeId != align::AlignableDet
140  && aliTypeId != align::AlignableDetUnit);
141  return isHigherLevel;
142 }
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:81
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentParameters * createParameters(Alignable *ali, ParametersType parType, const std::vector< bool > &sel)
align::Alignables theAlignables
Vector of alignables.
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(), edm::hlt::Exception, edm::ParameterSet::getParameter(), i, and AlignmentParametersFactory::parametersType().

Referenced by AlignmentParameterBuilder().

76 {
77  AlignmentParameterSelector selector(0);
78  std::vector<std::string> selsTypes(pSet.getParameter<std::vector<std::string> >("parameterTypes"));
79 
80  for (unsigned int i = 0; i < selsTypes.size(); ++i) {
81  std::vector<std::string> selSetType(selector.decompose(selsTypes[i], ','));
82  if (selSetType.size() != 2) {
83  throw cms::Exception("BadConfig") << "AlignmentParameterBuilder"
84  << "parameterTypes should contain 2 comma separated strings"
85  << ", but found '" << selsTypes[i] << "'.";
86  }
87  this->addSelections(pSet.getParameter<edm::ParameterSet>(selSetType[0]),
89  }
90 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
unsigned int addSelections(const edm::ParameterSet &pset, AlignmentParametersFactory::ParametersType parType)
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
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().

224 {
225  if (!aliParams) return false;
226 
227  aliParams->setUserVariables(new SelectionUserVariables(fullSel));
228 
229  return true;
230 }
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().

95 {
96 
97  const unsigned int oldAliSize = theAlignables.size();
98 
100  const unsigned int addedSets = selector.addSelections(pSet);
101 
102  const align::Alignables &alignables = selector.selectedAlignables();
103  const std::vector<std::vector<char> > &paramSels = selector.selectedParameters();
104 
105  align::Alignables::const_iterator iAli = alignables.begin();
106  std::vector<std::vector<char> >::const_iterator iParamSel = paramSels.begin();
107  unsigned int nHigherLevel = 0;
108 
109  while (iAli != alignables.end() && iParamSel != paramSels.end()) {
110  std::vector<bool> boolParSel;
111  std::vector<char> parSel(*iParamSel); // copy, since decodeParamSel may manipulate
112  bool charSelIsGeneral = this->decodeParamSel(parSel, boolParSel);
113  if (this->add(*iAli, parType, boolParSel)) ++nHigherLevel;
114  if (charSelIsGeneral) this->addFullParamSel((*iAli)->alignmentParameters(), parSel);
115 
116  ++iAli;
117  ++iParamSel;
118  }
119 
120  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::addSelections"
121  << " Added " << addedSets << " set(s) of alignables with "
122  << theAlignables.size() - oldAliSize << " alignables in total,"
123  << " of which " << nHigherLevel << " are higher level "
124  << "(using " << parametersTypeName(parType) << "AlignmentParameters).";
125 
126  return addedSets;
127 }
std::string parametersTypeName(ParametersType parType)
convert ParametersType to string understood by parametersType(string &amp;typeString) ...
bool decodeParamSel(std::vector< char > &paramSelChar, std::vector< bool > &result) const
AlignableExtras * theAlignableExtras
extra Alignables
bool addFullParamSel(AlignmentParameters *aliPar, const std::vector< char > &fullSel) const
add SelectionUserVariables corresponding to fullSel
AlignableMuon * theAlignableMuon
Alignable muon.
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.
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
align::Alignables theAlignables
Vector of alignables.
AlignableTracker * theAlignableTracker
Alignable tracker.
const align::Alignables & alignables() const
Get list of alignables for which AlignmentParameters are built.
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().

70 { return theAlignables; };
align::Alignables theAlignables
Vector of alignables.
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().

195 {
196  result.clear();
197  // remove all spaces from paramSelChar - useful to group the parameters if they are many
198  paramSelChar.erase(std::remove(paramSelChar.begin(), paramSelChar.end(), ' '),
199  paramSelChar.end());
200 
201  bool anyNon01 = false;
202 
203  for (unsigned int pos = 0; pos < paramSelChar.size(); ++pos) {
204 
205  switch (paramSelChar[pos]) {
206  default:
207  anyNon01 = true;
208  // no break;
209  case '1':
210  result.push_back(true);
211  break;
212  case '0':
213  result.push_back(false);
214  break;
215  }
216  }
217 
218  return anyNon01;
219 }
tuple result
Definition: query.py:137
void AlignmentParameterBuilder::fixAlignables ( int  n)

Remove n Alignables from list.

Definition at line 162 of file AlignmentParameterBuilder.cc.

References i, and theAlignables.

163 {
164 
165  if (n<1 || n>3) {
166  edm::LogError("BadArgument") << " n = " << n << " is not in [1,3]";
167  return;
168  }
169 
170  align::Alignables theNewAlignables;
171  int i=0;
172  int imax = theAlignables.size();
173  for ( align::Alignables::const_iterator ia=theAlignables.begin();
174  ia!=theAlignables.end(); ia++ )
175  {
176  i++;
177  if ( n==1 && i>1 )
178  theNewAlignables.push_back(*ia);
179  else if ( n==2 && i>1 && i<imax )
180  theNewAlignables.push_back(*ia);
181  else if ( n==3 && i>2 && i<imax)
182  theNewAlignables.push_back(*ia);
183  }
184 
185  theAlignables = theNewAlignables;
186 
187  edm::LogInfo("Alignment") << "@SUB=AlignmentParameterBuilder::fixAlignables"
188  << "removing " << n << " alignables, so that "
189  << theAlignables.size() << " alignables left";
190 }
int i
Definition: DBlmapReader.cc:9
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
align::Alignables theAlignables
Vector of alignables.

Member Data Documentation

AlignableExtras* AlignmentParameterBuilder::theAlignableExtras
private

extra Alignables

Definition at line 95 of file AlignmentParameterBuilder.h.

Referenced by addSelections().

AlignableMuon* AlignmentParameterBuilder::theAlignableMuon
private

Alignable muon.

Definition at line 92 of file AlignmentParameterBuilder.h.

Referenced by addSelections().

align::Alignables AlignmentParameterBuilder::theAlignables
private

Vector of alignables.

Definition at line 86 of file AlignmentParameterBuilder.h.

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

AlignableTracker* AlignmentParameterBuilder::theAlignableTracker
private

Alignable tracker.

Definition at line 89 of file AlignmentParameterBuilder.h.

Referenced by addSelections().