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
CompositeAlignmentDerivativesExtractor Class Reference

#include <CompositeAlignmentDerivativesExtractor.h>

Public Member Functions

 CompositeAlignmentDerivativesExtractor (const std::vector< Alignable * > &alignables, const std::vector< AlignableDet * > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 deprecated constructor for backward compatibility (use mor general AlignableDetOrUnitPtr) More...
 
 CompositeAlignmentDerivativesExtractor (const std::vector< Alignable * > &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 constructor More...
 
const AlgebraicVectorcorrectionTerm (void) const
 
const AlgebraicMatrixderivatives (void) const
 
 ~CompositeAlignmentDerivativesExtractor (void)
 destructor More...
 

Private Member Functions

void extractCurrentAlignment (const std::vector< Alignable * > &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
 
void extractWithMultipleHits (const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives, const std::vector< Alignable * > &alignables)
 
void extractWithoutMultipleHits (const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives)
 

Private Attributes

AlgebraicVector theCorrectionTerm
 
AlgebraicMatrix theDerivatives
 

Detailed Description

A helper class to extract derivatives from composite alignable objects

Date:
2007/10/08 15:55:59
Revision:
1.8

(last update by

Author:
cklae

)

Definition at line 19 of file CompositeAlignmentDerivativesExtractor.h.

Constructor & Destructor Documentation

CompositeAlignmentDerivativesExtractor::CompositeAlignmentDerivativesExtractor ( const std::vector< Alignable * > &  alignables,
const std::vector< AlignableDet * > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)

deprecated constructor for backward compatibility (use mor general AlignableDetOrUnitPtr)

Definition at line 12 of file CompositeAlignmentDerivativesExtractor.cc.

References extractCurrentAlignment().

15 {
16  std::vector<AlignableDetOrUnitPtr> detOrUnits;
17  detOrUnits.reserve(alignableDets.size());
18 
19  std::vector<AlignableDet*>::const_iterator it, itEnd;
20  for (it = alignableDets.begin(), itEnd = alignableDets.end(); it != itEnd; ++it)
21  detOrUnits.push_back(AlignableDetOrUnitPtr(*it));
22 
23  extractCurrentAlignment( alignables, detOrUnits, tsos );
24 }
void extractCurrentAlignment(const std::vector< Alignable * > &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
CompositeAlignmentDerivativesExtractor::CompositeAlignmentDerivativesExtractor ( const std::vector< Alignable * > &  alignables,
const std::vector< AlignableDetOrUnitPtr > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)

constructor

Definition at line 28 of file CompositeAlignmentDerivativesExtractor.cc.

References extractCurrentAlignment().

31 {
32  extractCurrentAlignment( alignables, alignableDets, tsos );
33 }
void extractCurrentAlignment(const std::vector< Alignable * > &alignables, const std::vector< AlignableDetOrUnitPtr > &alignableDets, const std::vector< TrajectoryStateOnSurface > &tsos)
CompositeAlignmentDerivativesExtractor::~CompositeAlignmentDerivativesExtractor ( void  )
inline

destructor

Definition at line 34 of file CompositeAlignmentDerivativesExtractor.h.

34 {};

Member Function Documentation

const AlgebraicVector& CompositeAlignmentDerivativesExtractor::correctionTerm ( void  ) const
inline
const AlgebraicMatrix& CompositeAlignmentDerivativesExtractor::derivatives ( void  ) const
inline
void CompositeAlignmentDerivativesExtractor::extractCurrentAlignment ( const std::vector< Alignable * > &  alignables,
const std::vector< AlignableDetOrUnitPtr > &  alignableDets,
const std::vector< TrajectoryStateOnSurface > &  tsos 
)
private

Definition at line 38 of file CompositeAlignmentDerivativesExtractor.cc.

References prof2calltree::count, extractWithMultipleHits(), extractWithoutMultipleHits(), theCorrectionTerm, and theDerivatives.

Referenced by CompositeAlignmentDerivativesExtractor().

41 {
42 
43  // sanity check
44  if ( alignables.size() != alignableDets.size() )
45  {
46  edm::LogError("CompositeAlignmentDerivativesExtractor")
47  << "Inconsistent length of arguments: alignables=" << alignables.size()
48  << ", alignableDets=" << alignableDets.size();
49  return;
50  }
51 
52  if ( alignables.size() != tsos.size() )
53  {
54  edm::LogError("CompositeAlignmentDerivativesExtractor")
55  << "Inconsistent length of arguments: alignables=" << alignables.size()
56  << ", tsos=" << tsos.size();
57  return;
58  }
59 
60  std::vector< Alignable* >::const_iterator itAlignable = alignables.begin();
61  std::vector< AlignableDetOrUnitPtr >::const_iterator itAlignableDet = alignableDets.begin();
62  std::vector< TrajectoryStateOnSurface >::const_iterator itTsos = tsos.begin();
63 
64  int nRow = 0;
65  int nCollumn = 0;
66  unsigned int nAlignables = 0;
67 
68  std::vector< AlgebraicMatrix > subDerivatives;
69  std::vector< AlgebraicVector > subCorrectionTerm;
70 
71 
72  // get the individual derivatives and correction term and determine the dimension
73  while ( itAlignable != alignables.end() )
74  {
75  // Get the current estimate on the alignment parameters
76  AlgebraicVector subAlignmentParameters =
77  ( *itAlignable )->alignmentParameters()->selectedParameters();
78 
79  // Get the derivatives or the local coordinates w.r.t. the corresponding alignment parameters
80  AlgebraicMatrix subAlignmentDerivatives =
81  ( *itAlignable )->alignmentParameters()->selectedDerivatives( *itTsos, *itAlignableDet );
82 
83  subDerivatives.push_back( subAlignmentDerivatives.T() );
84  subCorrectionTerm.push_back( subAlignmentDerivatives.T()*subAlignmentParameters );
85 
86  nRow += 2;
87  // check if it is the first occurrence of this Alignable
88  if ( count( alignables.begin(), itAlignable, *itAlignable ) == 0 )
89  {
90  // matrix is transposed -> num_row() instead of num_col()
91  nCollumn += subAlignmentDerivatives.num_row();
92  nAlignables++;
93  }
94 
95  itAlignable++;
96  itAlignableDet++;
97  itTsos++;
98  }
99 
100  // construct derivatives and correction term with the right dimension
101  theDerivatives = AlgebraicMatrix( nRow, nCollumn, 0 );
102  theCorrectionTerm = AlgebraicVector( nRow, 0 );
103 
104  if ( alignables.size() == nAlignables )
105  // One hit per alignable
106  extractWithoutMultipleHits( subCorrectionTerm, subDerivatives );
107  else
108  // At least one alignable has two hits
109  extractWithMultipleHits( subCorrectionTerm, subDerivatives, alignables );
110 
111  return;
112 
113 }
void extractWithMultipleHits(const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives, const std::vector< Alignable * > &alignables)
CLHEP::HepMatrix AlgebraicMatrix
void extractWithoutMultipleHits(const std::vector< AlgebraicVector > &subCorrectionTerm, const std::vector< AlgebraicMatrix > &subDerivatives)
CLHEP::HepVector AlgebraicVector
void CompositeAlignmentDerivativesExtractor::extractWithMultipleHits ( const std::vector< AlgebraicVector > &  subCorrectionTerm,
const std::vector< AlgebraicMatrix > &  subDerivatives,
const std::vector< Alignable * > &  alignables 
)
private

Definition at line 146 of file CompositeAlignmentDerivativesExtractor.cc.

References prof2calltree::count, spr::find(), theCorrectionTerm, and theDerivatives.

Referenced by extractCurrentAlignment().

149 {
150 
151  std::vector< AlgebraicVector >::const_iterator itSubCorrectionTerm = subCorrectionTerm.begin();
152  std::vector< AlgebraicMatrix >::const_iterator itSubDerivatives = subDerivatives.begin();
153  std::vector< Alignable* >::const_iterator itAlignables = alignables.begin();
154  std::vector< Alignable* >::const_iterator itPosition;
155  std::vector< Alignable* >::const_iterator itLastPosition;
156 
157  int iRow = 1;
158 
159  // Fill in the individual terms
160  while ( itAlignables != alignables.end() )
161  {
162  theCorrectionTerm.sub( iRow, *itSubCorrectionTerm );
163 
164  int iCollumn = 1;
165  int iAlignable = 0;
166 
167  itLastPosition = find( alignables.begin(), itAlignables, *itAlignables );
168 
169  for ( itPosition = alignables.begin(); itPosition != itLastPosition; itPosition++ )
170  {
171  if ( count( alignables.begin(), itPosition, *itPosition ) == 0 )
172  iCollumn += subDerivatives[iAlignable].num_col();
173  iAlignable++;
174  }
175 
176  theDerivatives.sub( iRow, iCollumn, *itSubDerivatives );
177 
178  iRow += 2;
179 
180  itAlignables++;
181  itSubCorrectionTerm++;
182  itSubDerivatives++;
183  }
184 
185  return;
186 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void CompositeAlignmentDerivativesExtractor::extractWithoutMultipleHits ( const std::vector< AlgebraicVector > &  subCorrectionTerm,
const std::vector< AlgebraicMatrix > &  subDerivatives 
)
private

Definition at line 118 of file CompositeAlignmentDerivativesExtractor.cc.

References theCorrectionTerm, and theDerivatives.

Referenced by extractCurrentAlignment().

120 {
121  std::vector< AlgebraicVector >::const_iterator itSubCorrectionTerm = subCorrectionTerm.begin();
122  std::vector< AlgebraicMatrix >::const_iterator itSubDerivatives = subDerivatives.begin();
123 
124  int iRow = 1;
125  int iCollumn = 1;
126 
127  // Fill in the individual terms
128  while ( itSubCorrectionTerm != subCorrectionTerm.end() )
129  {
130  theCorrectionTerm.sub( iRow, *itSubCorrectionTerm );
131  theDerivatives.sub( iRow, iCollumn, *itSubDerivatives );
132 
133  iRow += 2;
134  iCollumn += ( *itSubDerivatives ).num_col();
135 
136  itSubCorrectionTerm++;
137  itSubDerivatives++;
138  }
139 
140  return;
141 }

Member Data Documentation

AlgebraicVector CompositeAlignmentDerivativesExtractor::theCorrectionTerm
private
AlgebraicMatrix CompositeAlignmentDerivativesExtractor::theDerivatives
private