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, const TrackerTopology *tTopo, 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)
 
- Public Member Functions inherited from AlignmentUserVariables
virtual ~AlignmentUserVariables ()
 

Protected Member Functions

const AlgebraicVector extractTrueParameters (void) const
 
const std::string selectedParameter (const int &selected) 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
 

Detailed Description

Definition at line 17 of file KalmanAlignmentUserVariables.h.

Constructor & Destructor Documentation

KalmanAlignmentUserVariables::KalmanAlignmentUserVariables ( Alignable parent,
const TrackerTopology tTopo,
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 19 of file KalmanAlignmentUserVariables.cc.

References Alignable::alignableObjectId(), Alignable::geomDetId(), Alignable::id(), AlignableObjectId::idToString(), AlCaHLTBitMon_QueryRunRegistry::string, theAlignableId, theIdentifier, theTypeAndLayer, toString(), and TrackerAlignableId::typeAndLayerFromDetId().

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

Definition at line 37 of file KalmanAlignmentUserVariables.h.

37 {}

Member Function Documentation

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

Definition at line 298 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().

299 {
300 
301 #ifdef USE_LOCAL_PARAMETERS
302 
303  // get surface of alignable
304  const AlignableSurface& surface = theParentAlignable->surface();
305 
306  // get global rotation
307  const align::RotationType& globalRotation = theParentAlignable->rotation();
308  // get local rotation
309  align::RotationType localRotation = surface.toLocal( globalRotation );
310  // get euler angles (local frame)
311  align::EulerAngles localEulerAngles = align::toAngles( localRotation );
312 
313  // get global shifts
314  align::GlobalVector globalShifts( globalRotation.multiplyInverse( theParentAlignable->displacement().basicVector() ) );
315  // get local shifts
316  align::LocalVector localShifts = surface.toLocal( globalShifts );
317 
318  AlgebraicVector trueParameters( 6 );
319  trueParameters[0] = -localShifts.x();
320  trueParameters[1] = -localShifts.y();
321  trueParameters[2] = -localShifts.z();
322  trueParameters[3] = -localEulerAngles[0];
323  trueParameters[4] = -localEulerAngles[1];
324  trueParameters[5] = -localEulerAngles[2];
325 
326 #else
327 
328  // get global rotation
329  const align::RotationType& globalRotation = theParentAlignable->rotation();
330  // get euler angles (global frame)
331  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
332 
333  // get global shifts
334  align::GlobalVector globalShifts( globalRotation.multiplyInverse( theParentAlignable->displacement().basicVector() ) );
335 
336  AlgebraicVector trueParameters( 6 );
337  trueParameters[0] = -globalShifts.x();
338  trueParameters[1] = -globalShifts.y();
339  trueParameters[2] = -globalShifts.z();
340  trueParameters[3] = -globalEulerAngles[0];
341  trueParameters[4] = -globalEulerAngles[1];
342  trueParameters[5] = -globalEulerAngles[2];
343 
344 #endif
345 
346  return trueParameters;
347 }
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:63
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:64
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:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
void KalmanAlignmentUserVariables::fixAlignable ( void  )

Definition at line 280 of file KalmanAlignmentUserVariables.cc.

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

281 {
283  AlgebraicSymMatrix fixedCovariance = 1e-6*oldParameters->covariance();
284  AlignmentParameters* newParameters = oldParameters->clone( oldParameters->parameters(), fixedCovariance );
285  theParentAlignable->setAlignmentParameters( newParameters );
286 }
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:81
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 178 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(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), theParentAlignable, theTypeAndLayer, align::toAngles(), AlignableSurface::toGlobal(), align::toMatrix(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by KalmanAlignmentAlgorithm::terminate().

179 {
180  if ( theParentAlignable )
181  {
182 
183 #ifdef USE_LOCAL_PARAMETERS
184 
187  vector< bool > selector = theParentAlignable->alignmentParameters()->selector();
188 
189  AlgebraicVector trueParameters = extractTrueParameters();
190 
191  const int nParameter = 6;
192  int selected = 0;
193 
194  //histoNamePrefix += theTypeAndLayer;
195 
196  for ( int i = 0; i < nParameter; ++i )
197  {
198  if ( selector[i] )
199  {
200  string startHistoName = histoNamePrefix + theTypeAndLayer + string( "_Start" ) + selectedParameter( i );
201  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
202 
203  string deltaHistoName = histoNamePrefix + theTypeAndLayer + string( "_Delta" ) + selectedParameter( i );
204  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
205 
206  string pullsHistoName = histoNamePrefix + theTypeAndLayer + string( "_Pulls" ) + selectedParameter( i );
207  KalmanAlignmentDataCollector::fillHistogram( pullsHistoName, (parameters[selected]-trueParameters[i])/sqrt(covariance[selected][selected]) );
208 
209  startHistoName = histoNamePrefix + string( "_Start" ) + selectedParameter( i );
210  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
211 
212  deltaHistoName = histoNamePrefix + string( "_Delta" ) + selectedParameter( i );
213  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
214 
215  pullsHistoName = histoNamePrefix + string( "_Pulls" ) + selectedParameter( i );
216  KalmanAlignmentDataCollector::fillHistogram( pullsHistoName, (parameters[selected]-trueParameters[i])/sqrt(covariance[selected][selected]) );
217 
218  selected++;
219  }
220  }
221 
222 #else
223 
225 
226  const AlignableSurface& surface = theParentAlignable->surface();
227 
228  // Get global euler angles.
229  align::EulerAngles localEulerAngles( parameters.sub( 4, 6 ) );
230  const align::RotationType localRotation = align::toMatrix( localEulerAngles );
231  const align::RotationType globalRotation = surface.toGlobal( localRotation );
232  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
233 
234  // Get global shifts.
235  align::LocalVector localShifts( parameters[0], parameters[1], parameters[2] );
236  align::GlobalVector globalShifts( surface.toGlobal( localShifts ) );
237 
238  const int nParameter = 6;
239  AlgebraicVector globalParameters( nParameter );
240  globalParameters[0] = globalShifts.x();
241  globalParameters[1] = globalShifts.y();
242  globalParameters[2] = globalShifts.z();
243  globalParameters[3] = globalEulerAngles[0];
244  globalParameters[4] = globalEulerAngles[1];
245  globalParameters[5] = globalEulerAngles[2];
246 
247  AlgebraicVector trueParameters( extractTrueParameters() );
248 
249  KalmanAlignmentDataCollector::fillGraph( "y_vs_dx", theParentAlignable->globalPosition().y(), trueParameters[0]-globalParameters[0] );
250  KalmanAlignmentDataCollector::fillGraph( "r_vs_dx", theParentAlignable->globalPosition().perp(), trueParameters[0]-globalParameters[0] );
251  KalmanAlignmentDataCollector::fillGraph( "y_vs_dx_true", theParentAlignable->globalPosition().y(), trueParameters[0] );
252 
253  for ( int i = 0; i < nParameter; ++i )
254  {
255  string startHistoName = histoNamePrefix + string( "_Start" ) + selectedParameter( i );
256  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
257 
258  string deltaHistoName = histoNamePrefix + string( "_Delta" ) + selectedParameter( i );
259  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
260 
261  string valueHistoName = histoNamePrefix + string( "_Value" ) + selectedParameter( i );
262  KalmanAlignmentDataCollector::fillHistogram( valueHistoName, globalParameters[i]/selectedScaling(i) );
263 
264  startHistoName = histoNamePrefix + theTypeAndLayer + string( "_Start" ) + selectedParameter( i );
265  KalmanAlignmentDataCollector::fillHistogram( startHistoName, -trueParameters[i]/selectedScaling(i) );
266 
267  deltaHistoName = histoNamePrefix + theTypeAndLayer + string( "_Delta" ) + selectedParameter( i );
268  KalmanAlignmentDataCollector::fillHistogram( deltaHistoName, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
269 
270  valueHistoName = histoNamePrefix + theTypeAndLayer + string( "_Value" ) + selectedParameter( i );
271  KalmanAlignmentDataCollector::fillHistogram( valueHistoName, globalParameters[i]/selectedScaling(i) );
272  }
273 
274 #endif
275 
276  }
277 }
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:72
static void fillHistogram(std::string histo_name, float data)
AlgebraicVector selectedParameters(void) const
Get selected parameters.
T y() const
Definition: PV3DBase.h:63
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
float selectedScaling(const int &selected) const
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:48
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
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 44 of file KalmanAlignmentUserVariables.h.

References theNumberOfHits.

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

Definition at line 55 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 42 of file KalmanAlignmentUserVariables.h.

References theNumberOfHits.

int KalmanAlignmentUserVariables::numberOfUpdates ( void  ) const
inline

Return the number of updates.

Definition at line 47 of file KalmanAlignmentUserVariables.h.

References theNumberOfUpdates.

Referenced by KalmanAlignmentAlgorithm::terminate().

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

Definition at line 350 of file KalmanAlignmentUserVariables.cc.

References edm::hlt::Exception, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by histogramParameters(), and update().

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

Definition at line 379 of file KalmanAlignmentUserVariables.cc.

References alignCSCRings::e, and edm::hlt::Exception.

Referenced by histogramParameters(), and update().

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

Definition at line 405 of file KalmanAlignmentUserVariables.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by KalmanAlignmentUserVariables().

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

Definition at line 289 of file KalmanAlignmentUserVariables.cc.

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

290 {
292  AlgebraicSymMatrix fixedCovariance = 1e6*oldParameters->covariance();
293  AlignmentParameters* newParameters = oldParameters->clone( oldParameters->parameters(), fixedCovariance );
294  theParentAlignable->setAlignmentParameters( newParameters );
295 }
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:81
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 53 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(), AlCaHLTBitMon_QueryRunRegistry::string, Alignable::surface(), theFirstUpdate, theIdentifier, theNumberOfUpdates, theParentAlignable, theUpdateFrequency, align::toAngles(), AlignableSurface::toGlobal(), and align::toMatrix().

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

54 {
55  if ( theParentAlignable )
56  {
58 
59  if ( ( ( theNumberOfUpdates % theUpdateFrequency == 0 ) || enforceUpdate ) )
60  {
61 
62 #ifdef USE_LOCAL_PARAMETERS
63 
66  const vector< bool >& selector = theParentAlignable->alignmentParameters()->selector();
67 
68  AlgebraicVector trueParameters( extractTrueParameters() );
69 
70  const int nParameter = 6;
71  int selected = 0;
72 
73  for ( int i = 0; i < nParameter; ++i )
74  {
75  if ( selector[i] )
76  {
77  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
78 
79  if ( theFirstUpdate )
80  {
81  KalmanAlignmentDataCollector::fillGraph( string("LocalDelta") + parameterId, 0, -trueParameters[i]/selectedScaling(i) );
82  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, 0, sqrt(covariance[selected][selected])/selectedScaling(i) );
83  }
84 
85  KalmanAlignmentDataCollector::fillGraph( string("LocalDelta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
86  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[selected][selected])/selectedScaling(i) );
87 
88  selected++;
89  }
90  }
91 
92  if ( theFirstUpdate ) theFirstUpdate = false;
93 
94 #else
95 
98 
99  const AlignableSurface& surface = theParentAlignable->surface();
100 
101  // Get global euler angles.
102  align::EulerAngles localEulerAngles( parameters.sub( 4, 6 ) );
103  const align::RotationType localRotation = align::toMatrix( localEulerAngles );
104  const align::RotationType globalRotation = surface.toGlobal( localRotation );
105  align::EulerAngles globalEulerAngles = align::toAngles( globalRotation );
106 
107  // Get global shifts.
108  align::LocalVector localShifts( parameters[0], parameters[1], parameters[2] );
109  align::GlobalVector globalShifts( surface.toGlobal( localShifts ) );
110 
111  const int nParameter = 6;
112  AlgebraicVector globalParameters( nParameter );
113  globalParameters[0] = globalShifts.x();
114  globalParameters[1] = globalShifts.y();
115  globalParameters[2] = globalShifts.z();
116  globalParameters[3] = globalEulerAngles[0];
117  globalParameters[4] = globalEulerAngles[1];
118  globalParameters[5] = globalEulerAngles[2];
119 
120  AlgebraicVector trueParameters( extractTrueParameters() );
121 
122  for ( int i = 0; i < nParameter; ++i )
123  {
124  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
125 
126  if ( theFirstUpdate )
127  {
128  KalmanAlignmentDataCollector::fillGraph( string("GlobalDelta") + parameterId, 0, -trueParameters[i]/selectedScaling(i) );
129  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, 0, sqrt(covariance[i][i])/selectedScaling(i) );
130  }
131 
132  KalmanAlignmentDataCollector::fillGraph( string("GlobalDelta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (globalParameters[i]-trueParameters[i])/selectedScaling(i) );
133  KalmanAlignmentDataCollector::fillGraph( string("LocalSigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[i][i])/selectedScaling(i) );
134  }
135 
136  if ( theFirstUpdate ) theFirstUpdate = false;
137 
138 #endif
139 
140  }
141  }
142 }
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.
float selectedScaling(const int &selected) const
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:48
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
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 145 of file KalmanAlignmentUserVariables.cc.

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

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

146 {
147  if ( theParentAlignable )
148  {
150 
152  const AlgebraicSymMatrix& covariance = param->selectedCovariance();
153  const vector< bool >& selector = param->selector();
154 
155  AlgebraicVector trueParameters( extractTrueParameters() );
156 
157  const int nParameter = 6;
158  int selected = 0;
159 
160  for ( int i = 0; i < nParameter; ++i )
161  {
162  if ( selector[i] )
163  {
164  string parameterId = selectedParameter( i ) + string( "_" ) + theIdentifier;
165 
166  KalmanAlignmentDataCollector::fillGraph( string("Delta") + parameterId, theNumberOfUpdates/theUpdateFrequency, (parameters[selected]-trueParameters[i])/selectedScaling(i) );
167  KalmanAlignmentDataCollector::fillGraph( string("Sigma") + parameterId, theNumberOfUpdates/theUpdateFrequency, sqrt(covariance[selected][selected])/selectedScaling(i) );
168 
169  selected++;
170  }
171  }
172 
173  if ( theFirstUpdate ) theFirstUpdate = false;
174  }
175 }
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.
float selectedScaling(const int &selected) const
T sqrt(T t)
Definition: SSEVec.h:48
AlgebraicSymMatrix selectedCovariance(void) const
Get covariance matrix of selected parameters.
CLHEP::HepVector AlgebraicVector
const AlgebraicVector extractTrueParameters(void) 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 84 of file KalmanAlignmentUserVariables.h.

Referenced by KalmanAlignmentUserVariables().

bool KalmanAlignmentUserVariables::theAlignmentFlag
protected

Definition at line 79 of file KalmanAlignmentUserVariables.h.

Referenced by isAligned(), and setAlignmentFlag().

bool KalmanAlignmentUserVariables::theFirstUpdate
protected

Definition at line 78 of file KalmanAlignmentUserVariables.h.

Referenced by update().

std::string KalmanAlignmentUserVariables::theIdentifier
protected

Definition at line 81 of file KalmanAlignmentUserVariables.h.

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

int KalmanAlignmentUserVariables::theNumberOfHits
protected

Definition at line 74 of file KalmanAlignmentUserVariables.h.

Referenced by hit(), and numberOfHits().

int KalmanAlignmentUserVariables::theNumberOfUpdates
protected

Definition at line 75 of file KalmanAlignmentUserVariables.h.

Referenced by numberOfUpdates(), and update().

const AlignableObjectId* KalmanAlignmentUserVariables::theObjectId
staticprotected

Definition at line 85 of file KalmanAlignmentUserVariables.h.

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

Definition at line 76 of file KalmanAlignmentUserVariables.h.

Referenced by update().