CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
KalmanAlignmentUserVariables Class Reference

#include <KalmanAlignmentUserVariables.h>

Inheritance diagram for KalmanAlignmentUserVariables:
AlignmentUserVariables

Public Member Functions

virtual
KalmanAlignmentUserVariables
clone (void) const
 
void fixAlignable (void)
 
void histogramParameters (std::string histoNamePrefix)
 Histogram current estimate of the alignment parameters wrt. the true values. More...
 
void hit (void)
 Call this function in case the associated Alignable was hit by a particle. More...
 
const std::string identifier (void) const
 
bool isAligned (void) const
 
 KalmanAlignmentUserVariables (Alignable *parent, int frequency=100)
 
 KalmanAlignmentUserVariables (void)
 
int numberOfHits (void) const
 Return the number of hits. More...
 
int numberOfUpdates (void) const
 Return the number of updates. More...
 
void setAlignmentFlag (bool flag)
 
void unfixAlignable (void)
 
void update (bool enforceUpdate=false)
 Call this function in case the associated Alignable was updated by the alignment algorithm. More...
 
void update (const AlignmentParameters *param)
 Update user variables with given alignment parameters. More...
 
virtual ~KalmanAlignmentUserVariables (void)
 

Protected Member Functions

const AlgebraicVector extractTrueParameters (void) const
 
const std::string selectedParameter (const int &selected) const
 
const float selectedScaling (const int &selected) const
 
const std::string toString (const int &i) const
 

Protected Attributes

bool theAlignmentFlag
 
bool theFirstUpdate
 
std::string theIdentifier
 
int theNumberOfHits
 
int theNumberOfUpdates
 
AlignabletheParentAlignable
 
std::string theTypeAndLayer
 
int theUpdateFrequency
 

Static Protected Attributes

static const TrackerAlignableIdtheAlignableId = new TrackerAlignableId
 
static const AlignableObjectIdtheObjectId = new AlignableObjectId
 

Detailed Description

User variables used by the KalmanAlignmentAlgorithm. The evolution of the estimated alignment parameters is stored in graphs using the DataCollector.

Definition at line 15 of file KalmanAlignmentUserVariables.h.

Constructor & Destructor Documentation

KalmanAlignmentUserVariables::KalmanAlignmentUserVariables ( Alignable parent,
int  frequency = 100 
)

Create new user variables by specifying the associated Alignable, the Alignable's Id and how often the evolution of the estimated parameters should be updated.

Definition at line 21 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignableObjectId(), Alignable::geomDetId(), Alignable::id(), theAlignableId, theIdentifier, theObjectId, theTypeAndLayer, toString(), TrackerAlignableId::typeAndLayerFromDetId(), and AlignableObjectId::typeToName().

22  :
23  theParentAlignable( parent ),
24  theNumberOfHits( 0 ),
25  theNumberOfUpdates( 0 ),
26  theUpdateFrequency( frequency ),
27  theFirstUpdate( true ),
28  theAlignmentFlag( false )
29 {
30  if ( parent )
31  {
32  pair< int, int > typeAndLayer = theAlignableId->typeAndLayerFromDetId( parent->geomDetId() );
33 
34  int iType = typeAndLayer.first;
35  int iLayer = typeAndLayer.second;
36  int iId = parent->id();
37 
38  string strName = theObjectId->typeToName( parent->alignableObjectId() ) + string( "_" );
39  string strType = string( "Type" ) + toString( iType ) + string( "_" );
40  string strLayer = string( "Layer" ) + toString( iLayer ) + string( "_" );
41  string strId = string( "Id" ) + toString( iId );
42 
43  theTypeAndLayer = strType + strLayer;
44  theIdentifier = theTypeAndLayer + strName + strId;
45 
46  }
47  else theIdentifier = string( "NoAlignable" );
48 }
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 TrackerAlignableId * theAlignableId
const std::string & typeToName(align::StructureType type) const
Convert type to name.
const std::string toString(const int &i) const
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
static const AlignableObjectId * theObjectId
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId) const
const DetId & geomDetId() const
Definition: Alignable.h:177
KalmanAlignmentUserVariables::KalmanAlignmentUserVariables ( void  )
inline
virtual KalmanAlignmentUserVariables::~KalmanAlignmentUserVariables ( void  )
inlinevirtual

Definition at line 34 of file KalmanAlignmentUserVariables.h.

34 {}

Member Function Documentation

virtual KalmanAlignmentUserVariables* KalmanAlignmentUserVariables::clone ( void  ) const
inlinevirtual
const AlgebraicVector KalmanAlignmentUserVariables::extractTrueParameters ( void  ) const
protected

Definition at line 299 of file KalmanAlignmentUserVariables.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), Alignable::displacement(), TkRotation< T >::multiplyInverse(), Alignable::rotation(), Alignable::surface(), theParentAlignable, align::toAngles(), AlignableSurface::toLocal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by histogramParameters(), and update().

300 {
301 
302 #ifdef USE_LOCAL_PARAMETERS
303 
304  // get surface of alignable
305  const AlignableSurface& surface = theParentAlignable->surface();
306 
307  // get global rotation
308  const align::RotationType& globalRotation = theParentAlignable->rotation();
309  // get local rotation
310  align::RotationType localRotation = surface.toLocal( globalRotation );
311  // get euler angles (local frame)
312  align::EulerAngles localEulerAngles = align::toAngles( localRotation );
313 
314  // get global shifts
315  align::GlobalVector globalShifts( globalRotation.multiplyInverse( theParentAlignable->displacement().basicVector() ) );
316  // get local shifts
317  align::LocalVector localShifts = surface.toLocal( globalShifts );
318 
319  AlgebraicVector trueParameters( 6 );
320  trueParameters[0] = -localShifts.x();
321  trueParameters[1] = -localShifts.y();
322  trueParameters[2] = -localShifts.z();
323  trueParameters[3] = -localEulerAngles[0];
324  trueParameters[4] = -localEulerAngles[1];
325  trueParameters[5] = -localEulerAngles[2];
326 
327 #else
328 
329  // get global rotation
330  const align::RotationType& globalRotation = theParentAlignable->rotation();
331  // get euler angles (global frame)
332  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
333 
334  // get global shifts
335  align::GlobalVector globalShifts( globalRotation.multiplyInverse( theParentAlignable->displacement().basicVector() ) );
336 
337  AlgebraicVector trueParameters( 6 );
338  trueParameters[0] = -globalShifts.x();
339  trueParameters[1] = -globalShifts.y();
340  trueParameters[2] = -globalShifts.z();
341  trueParameters[3] = -globalEulerAngles[0];
342  trueParameters[4] = -globalEulerAngles[1];
343  trueParameters[5] = -globalEulerAngles[2];
344 
345 #endif
346 
347  return trueParameters;
348 }
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:135
T y() const
Definition: PV3DBase.h:57
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:138
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
T z() const
Definition: PV3DBase.h:58
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
T x() const
Definition: PV3DBase.h:56
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:54
void KalmanAlignmentUserVariables::fixAlignable ( void  )

Definition at line 281 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignmentParameters(), AlignmentParameters::clone(), AlignmentParameters::covariance(), AlignmentParameters::parameters(), Alignable::setAlignmentParameters(), and theParentAlignable.

282 {
284  AlgebraicSymMatrix fixedCovariance = 1e-6*oldParameters->covariance();
285  AlignmentParameters* newParameters = oldParameters->clone( oldParameters->parameters(), fixedCovariance );
286  theParentAlignable->setAlignmentParameters( newParameters );
287 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
const AlgebraicVector & parameters(void) const
Get alignment parameters.
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:79
virtual AlignmentParameters * clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Enforce clone methods in derived classes.
CLHEP::HepSymMatrix AlgebraicSymMatrix
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
void KalmanAlignmentUserVariables::histogramParameters ( std::string  histoNamePrefix)

Histogram current estimate of the alignment parameters wrt. the true values.

Definition at line 179 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignmentParameters(), extractTrueParameters(), KalmanAlignmentDataCollector::fillGraph(), KalmanAlignmentDataCollector::fillHistogram(), Alignable::globalPosition(), i, Parameters::parameters, AlignmentParameters::parameters(), PV3DBase< T, PVType, FrameType >::perp(), AlignmentParameters::selectedCovariance(), selectedParameter(), AlignmentParameters::selectedParameters(), selectedScaling(), AlignmentParameters::selector(), mathSSE::sqrt(), Alignable::surface(), theParentAlignable, theTypeAndLayer, align::toAngles(), AlignableSurface::toGlobal(), align::toMatrix(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by KalmanAlignmentAlgorithm::terminate().

180 {
181  if ( theParentAlignable )
182  {
183 
184 #ifdef USE_LOCAL_PARAMETERS
185 
188  vector< bool > selector = theParentAlignable->alignmentParameters()->selector();
189 
190  AlgebraicVector trueParameters = extractTrueParameters();
191 
192  const int nParameter = 6;
193  int selected = 0;
194 
195  //histoNamePrefix += theTypeAndLayer;
196 
197  for ( int i = 0; i < nParameter; ++i )
198  {
199  if ( selector[i] )
200  {
201  string startHistoName = histoNamePrefix + theTypeAndLayer + string( "_Start" ) + selectedParameter( i );
202  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
203 
204  string deltaHistoName = histoNamePrefix + theTypeAndLayer + string( "_Delta" ) + selectedParameter( i );
205  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
206 
207  string pullsHistoName = histoNamePrefix + theTypeAndLayer + string( "_Pulls" ) + selectedParameter( i );
208  KalmanAlignmentDataCollector::fillHistogram( pullsHistoName, (parameters[selected]-trueParameters[i])/sqrt(covariance[selected][selected]) );
209 
210  startHistoName = histoNamePrefix + string( "_Start" ) + selectedParameter( i );
211  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
212 
213  deltaHistoName = histoNamePrefix + string( "_Delta" ) + selectedParameter( i );
214  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
215 
216  pullsHistoName = histoNamePrefix + string( "_Pulls" ) + selectedParameter( i );
217  KalmanAlignmentDataCollector::fillHistogram( pullsHistoName, (parameters[selected]-trueParameters[i])/sqrt(covariance[selected][selected]) );
218 
219  selected++;
220  }
221  }
222 
223 #else
224 
226 
227  const AlignableSurface& surface = theParentAlignable->surface();
228 
229  // Get global euler angles.
230  align::EulerAngles localEulerAngles( parameters.sub( 4, 6 ) );
231  const align::RotationType localRotation = align::toMatrix( localEulerAngles );
232  const align::RotationType globalRotation = surface.toGlobal( localRotation );
233  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
234 
235  // Get global shifts.
236  align::LocalVector localShifts( parameters[0], parameters[1], parameters[2] );
237  align::GlobalVector globalShifts( surface.toGlobal( localShifts ) );
238 
239  const int nParameter = 6;
240  AlgebraicVector globalParameters( nParameter );
241  globalParameters[0] = globalShifts.x();
242  globalParameters[1] = globalShifts.y();
243  globalParameters[2] = globalShifts.z();
244  globalParameters[3] = globalEulerAngles[0];
245  globalParameters[4] = globalEulerAngles[1];
246  globalParameters[5] = globalEulerAngles[2];
247 
248  AlgebraicVector trueParameters( extractTrueParameters() );
249 
250  KalmanAlignmentDataCollector::fillGraph( "y_vs_dx", theParentAlignable->globalPosition().y(), trueParameters[0]-globalParameters[0] );
251  KalmanAlignmentDataCollector::fillGraph( "r_vs_dx", theParentAlignable->globalPosition().perp(), trueParameters[0]-globalParameters[0] );
252  KalmanAlignmentDataCollector::fillGraph( "y_vs_dx_true", theParentAlignable->globalPosition().y(), trueParameters[0] );
253 
254  for ( int i = 0; i < nParameter; ++i )
255  {
256  string startHistoName = histoNamePrefix + string( "_Start" ) + selectedParameter( i );
257  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
258 
259  string deltaHistoName = histoNamePrefix + string( "_Delta" ) + selectedParameter( i );
260  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
261 
262  string valueHistoName = histoNamePrefix + string( "_Value" ) + selectedParameter( i );
263  KalmanAlignmentDataCollector::fillHistogram( valueHistoName, globalParameters[i]/selectedScaling(i) );
264 
265  startHistoName = histoNamePrefix + theTypeAndLayer + string( "_Start" ) + selectedParameter( i );
266  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
267 
268  deltaHistoName = histoNamePrefix + theTypeAndLayer + string( "_Delta" ) + selectedParameter( i );
269  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
270 
271  valueHistoName = histoNamePrefix + theTypeAndLayer + string( "_Value" ) + selectedParameter( i );
272  KalmanAlignmentDataCollector::fillHistogram( valueHistoName, globalParameters[i]/selectedScaling(i) );
273  }
274 
275 #endif
276 
277  }
278 }
const std::string selectedParameter(const int &selected) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:66
static void fillHistogram(std::string histo_name, float data)
AlgebraicVector selectedParameters(void) const
Get selected parameters.
T y() const
Definition: PV3DBase.h:57
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
const AlgebraicVector & parameters(void) const
Get alignment parameters.
T sqrt(T t)
Definition: SSEVec.h:28
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
const AlgebraicVector extractTrueParameters(void) const
const float selectedScaling(const int &selected) const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
CLHEP::HepSymMatrix AlgebraicSymMatrix
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
static void fillGraph(std::string graph_name, float x_data, float y_data)
void KalmanAlignmentUserVariables::hit ( void  )
inline

Call this function in case the associated Alignable was hit by a particle.

Definition at line 41 of file KalmanAlignmentUserVariables.h.

References theNumberOfHits.

const std::string KalmanAlignmentUserVariables::identifier ( void  ) const
inline

Definition at line 52 of file KalmanAlignmentUserVariables.h.

References theIdentifier.

bool KalmanAlignmentUserVariables::isAligned ( void  ) const
inline
int KalmanAlignmentUserVariables::numberOfHits ( void  ) const
inline

Return the number of hits.

Definition at line 39 of file KalmanAlignmentUserVariables.h.

References theNumberOfHits.

int KalmanAlignmentUserVariables::numberOfUpdates ( void  ) const
inline

Return the number of updates.

Definition at line 44 of file KalmanAlignmentUserVariables.h.

References theNumberOfUpdates.

Referenced by KalmanAlignmentAlgorithm::terminate().

const string KalmanAlignmentUserVariables::selectedParameter ( const int &  selected) const
protected

Definition at line 351 of file KalmanAlignmentUserVariables.cc.

References edm::hlt::Exception.

Referenced by histogramParameters(), and update().

352 {
353  switch ( selected )
354  {
355  case 0:
356  return string( "X" );
357  break;
358  case 1:
359  return string( "Y" );
360  break;
361  case 2:
362  return string( "Z" );
363  break;
364  case 3:
365  return string( "Alpha" );
366  break;
367  case 4:
368  return string( "Beta" );
369  break;
370  case 5:
371  return string( "Gamma" );
372  break;
373  default:
374  throw cms::Exception( "OutOfRange" ) << "[KalmanAlignmentUserVariables::selectedParameter] "
375  << "Index out of range (selector = " << selected << ")";
376  }
377 }
const float KalmanAlignmentUserVariables::selectedScaling ( const int &  selected) const
protected

Definition at line 380 of file KalmanAlignmentUserVariables.cc.

References edm::hlt::Exception.

Referenced by histogramParameters(), and update().

381 {
382  const float micron = 1e-4;
383  const float millirad = 1e-3;
384  //const float murad = 1e-6;
385 
386  switch ( selected )
387  {
388  case 0:
389  case 1:
390  case 2:
391  return micron;
392  break;
393  case 3:
394  case 4:
395  case 5:
396  return millirad;
397  //return murad;
398  break;
399  default:
400  throw cms::Exception( "LogicError" ) << "@SUB=KalmanAlignmentUserVariables::selectedScaling"
401  << "Index out of range (selector = " << selected << ")\n";
402  }
403 }
void KalmanAlignmentUserVariables::setAlignmentFlag ( bool  flag)
inline
const string KalmanAlignmentUserVariables::toString ( const int &  i) const
protected

Definition at line 406 of file KalmanAlignmentUserVariables.cc.

References cond::rpcobtemp::temp.

Referenced by KalmanAlignmentUserVariables().

407 {
408  char temp[10];
409  sprintf( temp, "%u", i );
410 
411  return string( temp );
412 }
int i
Definition: DBlmapReader.cc:9
void KalmanAlignmentUserVariables::unfixAlignable ( void  )

Definition at line 290 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignmentParameters(), AlignmentParameters::clone(), AlignmentParameters::covariance(), AlignmentParameters::parameters(), Alignable::setAlignmentParameters(), and theParentAlignable.

291 {
293  AlgebraicSymMatrix fixedCovariance = 1e6*oldParameters->covariance();
294  AlignmentParameters* newParameters = oldParameters->clone( oldParameters->parameters(), fixedCovariance );
295  theParentAlignable->setAlignmentParameters( newParameters );
296 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
const AlgebraicVector & parameters(void) const
Get alignment parameters.
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:79
virtual AlignmentParameters * clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Enforce clone methods in derived classes.
CLHEP::HepSymMatrix AlgebraicSymMatrix
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
void KalmanAlignmentUserVariables::update ( bool  enforceUpdate = false)

Call this function in case the associated Alignable was updated by the alignment algorithm.

Definition at line 54 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignmentParameters(), AlignmentParameters::covariance(), extractTrueParameters(), KalmanAlignmentDataCollector::fillGraph(), i, Parameters::parameters, AlignmentParameters::parameters(), AlignmentParameters::selectedCovariance(), selectedParameter(), AlignmentParameters::selectedParameters(), selectedScaling(), AlignmentParameters::selector(), mathSSE::sqrt(), Alignable::surface(), theFirstUpdate, theIdentifier, theNumberOfUpdates, theParentAlignable, theUpdateFrequency, align::toAngles(), AlignableSurface::toGlobal(), and align::toMatrix().

Referenced by python.seqvaluedict.seqdict::__setslice__(), python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.seqvaluedict.seqdict::extend(), KalmanAlignmentAlgorithm::initializeAlignmentParameters(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), KalmanAlignmentAlgorithm::terminate(), python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection(), and KalmanAlignmentUpdator::updateUserVariables().

55 {
56  if ( theParentAlignable )
57  {
59 
60  if ( ( ( theNumberOfUpdates % theUpdateFrequency == 0 ) || enforceUpdate ) )
61  {
62 
63 #ifdef USE_LOCAL_PARAMETERS
64 
67  const vector< bool >& selector = theParentAlignable->alignmentParameters()->selector();
68 
69  AlgebraicVector trueParameters( extractTrueParameters() );
70 
71  const int nParameter = 6;
72  int selected = 0;
73 
74  for ( int i = 0; i < nParameter; ++i )
75  {
76  if ( selector[i] )
77  {
78  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
79 
80  if ( theFirstUpdate )
81  {
82  KalmanAlignmentDataCollector::fillGraph( string("LocalDelta") + parameterId, 0, -trueParameters[i]/selectedScaling(i) );
83  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, 0, sqrt(covariance[selected][selected])/selectedScaling(i) );
84  }
85 
86  KalmanAlignmentDataCollector::fillGraph( string("LocalDelta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
87  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[selected][selected])/selectedScaling(i) );
88 
89  selected++;
90  }
91  }
92 
93  if ( theFirstUpdate ) theFirstUpdate = false;
94 
95 #else
96 
99 
100  const AlignableSurface& surface = theParentAlignable->surface();
101 
102  // Get global euler angles.
103  align::EulerAngles localEulerAngles( parameters.sub( 4, 6 ) );
104  const align::RotationType localRotation = align::toMatrix( localEulerAngles );
105  const align::RotationType globalRotation = surface.toGlobal( localRotation );
106  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
107 
108  // Get global shifts.
109  align::LocalVector localShifts( parameters[0], parameters[1], parameters[2] );
110  align::GlobalVector globalShifts( surface.toGlobal( localShifts ) );
111 
112  const int nParameter = 6;
113  AlgebraicVector globalParameters( nParameter );
114  globalParameters[0] = globalShifts.x();
115  globalParameters[1] = globalShifts.y();
116  globalParameters[2] = globalShifts.z();
117  globalParameters[3] = globalEulerAngles[0];
118  globalParameters[4] = globalEulerAngles[1];
119  globalParameters[5] = globalEulerAngles[2];
120 
121  AlgebraicVector trueParameters( extractTrueParameters() );
122 
123  for ( int i = 0; i < nParameter; ++i )
124  {
125  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
126 
127  if ( theFirstUpdate )
128  {
129  KalmanAlignmentDataCollector::fillGraph( string("GlobalDelta") + parameterId, 0, -trueParameters[i]/selectedScaling(i) );
130  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, 0, sqrt(covariance[i][i])/selectedScaling(i) );
131  }
132 
133  KalmanAlignmentDataCollector::fillGraph( string("GlobalDelta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
134  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[i][i])/selectedScaling(i) );
135  }
136 
137  if ( theFirstUpdate ) theFirstUpdate = false;
138 
139 #endif
140 
141  }
142  }
143 }
const std::string selectedParameter(const int &selected) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
AlgebraicVector selectedParameters(void) const
Get selected parameters.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
const AlgebraicVector & parameters(void) const
Get alignment parameters.
T sqrt(T t)
Definition: SSEVec.h:28
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
const AlgebraicVector extractTrueParameters(void) const
const float selectedScaling(const int &selected) const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
CLHEP::HepSymMatrix AlgebraicSymMatrix
static void fillGraph(std::string graph_name, float x_data, float y_data)
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
void KalmanAlignmentUserVariables::update ( const AlignmentParameters param)

Update user variables with given alignment parameters.

Definition at line 146 of file KalmanAlignmentUserVariables.cc.

References extractTrueParameters(), KalmanAlignmentDataCollector::fillGraph(), i, Parameters::parameters, AlignmentParameters::selectedCovariance(), selectedParameter(), AlignmentParameters::selectedParameters(), selectedScaling(), AlignmentParameters::selector(), mathSSE::sqrt(), theFirstUpdate, theIdentifier, theNumberOfUpdates, theParentAlignable, and theUpdateFrequency.

Referenced by python.seqvaluedict.seqdict::__setslice__(), python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.seqvaluedict.seqdict::extend(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

147 {
148  if ( theParentAlignable )
149  {
151 
153  const AlgebraicSymMatrix& covariance = param->selectedCovariance();
154  const vector< bool >& selector = param->selector();
155 
156  AlgebraicVector trueParameters( extractTrueParameters() );
157 
158  const int nParameter = 6;
159  int selected = 0;
160 
161  for ( int i = 0; i < nParameter; ++i )
162  {
163  if ( selector[i] )
164  {
165  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
166 
167  KalmanAlignmentDataCollector::fillGraph( string("Delta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
168  KalmanAlignmentDataCollector::fillGraph( string("Sigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[selected][selected])/selectedScaling(i) );
169 
170  selected++;
171  }
172  }
173 
174  if ( theFirstUpdate ) theFirstUpdate = false;
175  }
176 }
const std::string selectedParameter(const int &selected) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
AlgebraicVector selectedParameters(void) const
Get selected parameters.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
T sqrt(T t)
Definition: SSEVec.h:28
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
CLHEP::HepVector AlgebraicVector
const AlgebraicVector extractTrueParameters(void) const
const float selectedScaling(const int &selected) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
static void fillGraph(std::string graph_name, float x_data, float y_data)

Member Data Documentation

const TrackerAlignableId * KalmanAlignmentUserVariables::theAlignableId = new TrackerAlignableId
staticprotected

Definition at line 81 of file KalmanAlignmentUserVariables.h.

Referenced by KalmanAlignmentUserVariables().

bool KalmanAlignmentUserVariables::theAlignmentFlag
protected

Definition at line 76 of file KalmanAlignmentUserVariables.h.

Referenced by isAligned(), and setAlignmentFlag().

bool KalmanAlignmentUserVariables::theFirstUpdate
protected

Definition at line 75 of file KalmanAlignmentUserVariables.h.

Referenced by update().

std::string KalmanAlignmentUserVariables::theIdentifier
protected

Definition at line 78 of file KalmanAlignmentUserVariables.h.

Referenced by identifier(), KalmanAlignmentUserVariables(), and update().

int KalmanAlignmentUserVariables::theNumberOfHits
protected

Definition at line 71 of file KalmanAlignmentUserVariables.h.

Referenced by hit(), and numberOfHits().

int KalmanAlignmentUserVariables::theNumberOfUpdates
protected

Definition at line 72 of file KalmanAlignmentUserVariables.h.

Referenced by numberOfUpdates(), and update().

const AlignableObjectId * KalmanAlignmentUserVariables::theObjectId = new AlignableObjectId
staticprotected

Definition at line 82 of file KalmanAlignmentUserVariables.h.

Referenced by KalmanAlignmentUserVariables().

Alignable* KalmanAlignmentUserVariables::theParentAlignable
protected
std::string KalmanAlignmentUserVariables::theTypeAndLayer
protected
int KalmanAlignmentUserVariables::theUpdateFrequency
protected

Definition at line 73 of file KalmanAlignmentUserVariables.h.

Referenced by update().