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

#include <SimpleMetricsUpdator.h>

Inheritance diagram for SimpleMetricsUpdator:
KalmanAlignmentMetricsUpdator

Public Member Functions

virtual const std::vector
< Alignable * > 
additionalAlignables (const std::vector< Alignable * > &alignables)
 
virtual const std::map
< Alignable *, short int > 
additionalAlignablesWithDistances (const std::vector< Alignable * > &alignables)
 
virtual const std::vector
< Alignable * > 
alignables (void) const
 
 SimpleMetricsUpdator (const edm::ParameterSet &config)
 
virtual void update (const std::vector< Alignable * > &alignables)
 
virtual ~SimpleMetricsUpdator (void)
 
- Public Member Functions inherited from KalmanAlignmentMetricsUpdator
 KalmanAlignmentMetricsUpdator (const edm::ParameterSet &config)
 
virtual ~KalmanAlignmentMetricsUpdator (void)
 

Private Member Functions

bool additionalSelectionCriterion (Alignable *const &referenceAli, Alignable *const &additionalAli, short int metricalDist) const
 

Private Attributes

bool theASCFlag
 
std::vector< unsigned int > theExcludedSubdetIds
 
double theGeomDist
 
double theMaxDeltaPerp
 
double theMaxDeltaZ
 
short int theMetricalThreshold
 
KalmanAlignmentMetricsCalculator theMetricsCalculator
 
double theMinDeltaPerp
 
double theMinDeltaZ
 

Detailed Description

Definition at line 10 of file SimpleMetricsUpdator.h.

Constructor & Destructor Documentation

SimpleMetricsUpdator::SimpleMetricsUpdator ( const edm::ParameterSet config)

Definition at line 11 of file SimpleMetricsUpdator.cc.

References funct::false, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), KalmanAlignmentMetricsCalculator::setMaxDistance(), theASCFlag, theExcludedSubdetIds, theGeomDist, theMaxDeltaPerp, theMaxDeltaZ, theMetricalThreshold, theMetricsCalculator, theMinDeltaPerp, and theMinDeltaZ.

12 {
13  short int maxDistance = config.getUntrackedParameter< int >( "MaxMetricsDistance", 3 );
14  theMetricsCalculator.setMaxDistance( maxDistance );
15 
16  std::vector< unsigned int > dummy;
17  theExcludedSubdetIds = config.getUntrackedParameter< std::vector<unsigned int> >( "ExcludedSubdetIds", dummy );
18 
19  theASCFlag = config.getUntrackedParameter< bool >( "ApplyAdditionalSelectionCriterion", false );
20  if ( theASCFlag )
21  {
22  theMinDeltaPerp = config.getParameter< double >( "MinDeltaPerp" );
23  theMaxDeltaPerp = config.getParameter< double >( "MaxDeltaPerp" );
24  theMinDeltaZ = config.getParameter< double >( "MinDeltaZ" );
25  theMaxDeltaZ = config.getParameter< double >( "MaxDeltaZ" );
26  theGeomDist = config.getParameter< double >( "GeomDist" );
27  theMetricalThreshold = config.getParameter< unsigned int >( "MetricalThreshold" );
28  }
29 
30  edm::LogInfo("Alignment") << "@SUB=SimpleMetricsUpdator::SimpleMetricsUpdator "
31  << "\nInstance of MetricsCalculator created (MaxMetricsDistance = " << maxDistance << ").";
32 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setMaxDistance(short int maxDistance)
Set maximum distance to be stored.
KalmanAlignmentMetricsUpdator(const edm::ParameterSet &config)
std::vector< unsigned int > theExcludedSubdetIds
KalmanAlignmentMetricsCalculator theMetricsCalculator
virtual SimpleMetricsUpdator::~SimpleMetricsUpdator ( void  )
inlinevirtual

Definition at line 17 of file SimpleMetricsUpdator.h.

17 {}

Member Function Documentation

const std::vector< Alignable * > SimpleMetricsUpdator::additionalAlignables ( const std::vector< Alignable * > &  alignables)
virtual

Implements KalmanAlignmentMetricsUpdator.

Definition at line 55 of file SimpleMetricsUpdator.cc.

References additionalSelectionCriterion(), spr::find(), KalmanAlignmentMetricsCalculator::getDistances(), query::result, theASCFlag, and theMetricsCalculator.

56 {
57  std::vector< Alignable* > result;
58  std::vector< Alignable* >::const_iterator itAD;
59 
60  std::map< Alignable*, short int > updateList;
61  std::map< Alignable*, short int >::iterator itUL;
62 
63  std::set< Alignable* > alignablesFromUpdateList;
64  std::set< Alignable* >::iterator itAUL;
65 
66  // make union of all lists
67  for ( itAD = alignables.begin(); itAD != alignables.end(); itAD++ )
68  {
69  updateList = theMetricsCalculator.getDistances( *itAD );
70  for ( itUL = updateList.begin(); itUL != updateList.end(); itUL++ )
71  {
72  // extra selection criterion
73  if ( theASCFlag && !additionalSelectionCriterion( *itAD, itUL->first, itUL->second ) ) continue;
74 
75  alignablesFromUpdateList.insert( itUL->first );
76  }
77  updateList.clear();
78  }
79 
80  // make final list of modules for update
81  for ( itAUL = alignablesFromUpdateList.begin(); itAUL != alignablesFromUpdateList.end(); itAUL++ )
82  {
83  if ( find( alignables.begin(), alignables.end(), *itAUL ) == alignables.end() )
84  {
85  result.push_back( *itAUL );
86  }
87  }
88 
89  return result;
90 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual const std::vector< Alignable * > alignables(void) const
tuple result
Definition: query.py:137
bool additionalSelectionCriterion(Alignable *const &referenceAli, Alignable *const &additionalAli, short int metricalDist) const
KalmanAlignmentMetricsCalculator theMetricsCalculator
const SingleDistancesList & getDistances(Alignable *i) const
const std::map< Alignable *, short int > SimpleMetricsUpdator::additionalAlignablesWithDistances ( const std::vector< Alignable * > &  alignables)
virtual

Definition at line 94 of file SimpleMetricsUpdator.cc.

References KalmanAlignmentMetricsCalculator::getDistances(), query::result, and theMetricsCalculator.

95 {
96  std::map< Alignable*, short int > result;
97  std::map< Alignable*, short int > updateList;
98  std::map< Alignable*, short int >::iterator itUL;
99  std::map< Alignable*, short int >::iterator itFind;
100 
101  std::vector< Alignable* >::const_iterator itAD;
102 
103  // make union of all lists
104  for ( itAD = alignables.begin(); itAD != alignables.end(); itAD++ )
105  {
106  updateList = theMetricsCalculator.getDistances( *itAD );
107  for ( itUL = updateList.begin(); itUL != updateList.end(); itUL++ )
108  {
109  itFind = result.find( itUL->first );
110  if ( itFind == result.end() )
111  {
112  result[itUL->first] = itUL->second;
113  }
114  else if ( itFind->second < itUL->second )
115  {
116  itFind->second = itUL->second;
117  }
118  }
119  }
120 
121  for ( itAD = alignables.begin(); itAD != alignables.end(); itAD++ )
122  {
123  itFind = result.find( *itAD );
124  if ( itFind != result.end() ) result.erase( itFind );
125  }
126 
127  return result;
128 }
virtual const std::vector< Alignable * > alignables(void) const
tuple result
Definition: query.py:137
KalmanAlignmentMetricsCalculator theMetricsCalculator
const SingleDistancesList & getDistances(Alignable *i) const
bool SimpleMetricsUpdator::additionalSelectionCriterion ( Alignable *const &  referenceAli,
Alignable *const &  additionalAli,
short int  metricalDist 
) const
private

Definition at line 132 of file SimpleMetricsUpdator.cc.

References Alignable::geomDetId(), Alignable::globalPosition(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), perp2(), mathSSE::sqrt(), theGeomDist, theMaxDeltaPerp, theMaxDeltaZ, theMetricalThreshold, theMinDeltaPerp, theMinDeltaZ, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by additionalAlignables().

135 {
136  if ( metricalDist <= theMetricalThreshold ) return true;
137 
138  const DetId detId( referenceAli->geomDetId() );
139 
140  const align::PositionType& pos1 = referenceAli->globalPosition();
141  const align::PositionType& pos2 = additionalAli->globalPosition();
142 
143  bool barrelRegion = ( detId.subdetId()%2 != 0 );
144 
145  if ( barrelRegion )
146  {
147  double perp1 = pos1.perp();
148  double perp2 = pos2.perp();
149  double deltaPerp = perp2 - perp1;
150 
151  if ( ( deltaPerp < theMinDeltaPerp ) || ( deltaPerp > theMaxDeltaPerp ) ) return false;
152  }
153  else
154  {
155  double z1 = pos1.z();
156  double z2 = pos2.z();
157  double signZ = ( z1 > 0. ) ? 1. : -1;
158  double deltaZ = signZ*( z2 - z1 );
159 
160  if ( ( deltaZ < theMinDeltaZ ) || ( deltaZ > theMaxDeltaZ ) ) return false;
161  }
162 
163  double r1 = pos1.mag();
164  double r2 = pos2.mag();
165  double sp = pos1.x()*pos2.x() + pos1.y()*pos2.y() + pos1.z()*pos2.z();
166 
167  double dist = sqrt( r2*r2 - sp*sp/r1/r1 );
168  return ( dist < theGeomDist );
169 }
T perp() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:57
T mag() const
Definition: PV3DBase.h:61
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
Definition: DetId.h:20
T perp2() const
Squared magnitude of transverse component.
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
T x() const
Definition: PV3DBase.h:56
const DetId & geomDetId() const
Definition: Alignable.h:177
virtual const std::vector< Alignable* > SimpleMetricsUpdator::alignables ( void  ) const
inlinevirtual

Implements KalmanAlignmentMetricsUpdator.

Definition at line 25 of file SimpleMetricsUpdator.h.

References KalmanAlignmentMetricsCalculator::alignables(), and theMetricsCalculator.

25 { return theMetricsCalculator.alignables(); }
const std::vector< Alignable * > alignables(void) const
Return all known alignables.
KalmanAlignmentMetricsCalculator theMetricsCalculator
void SimpleMetricsUpdator::update ( const std::vector< Alignable * > &  alignables)
virtual

Implements KalmanAlignmentMetricsUpdator.

Definition at line 35 of file SimpleMetricsUpdator.cc.

References spr::find(), theExcludedSubdetIds, theMetricsCalculator, and KalmanAlignmentMetricsCalculator::updateDistances().

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

36 {
37  std::vector< Alignable* > alignablesForUpdate;
38  std::vector< Alignable* >::const_iterator it;
39 
40  for ( it = alignables.begin(); it != alignables.end(); ++it )
41  {
42  unsigned int subdetId = static_cast< unsigned int >( (*it)->geomDetId().subdetId() );
43 
44  if ( std::find( theExcludedSubdetIds.begin(), theExcludedSubdetIds.end(), subdetId ) == theExcludedSubdetIds.end() )
45  {
46  alignablesForUpdate.push_back( *it );
47  }
48  }
49 
50  theMetricsCalculator.updateDistances( alignablesForUpdate );
51 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual const std::vector< Alignable * > alignables(void) const
std::vector< unsigned int > theExcludedSubdetIds
void updateDistances(const std::vector< Alignable * > &alignables)
Update list of distances with a set Alignables.
KalmanAlignmentMetricsCalculator theMetricsCalculator

Member Data Documentation

bool SimpleMetricsUpdator::theASCFlag
private

Definition at line 37 of file SimpleMetricsUpdator.h.

Referenced by additionalAlignables(), and SimpleMetricsUpdator().

std::vector< unsigned int > SimpleMetricsUpdator::theExcludedSubdetIds
private

Definition at line 35 of file SimpleMetricsUpdator.h.

Referenced by SimpleMetricsUpdator(), and update().

double SimpleMetricsUpdator::theGeomDist
private

Definition at line 42 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().

double SimpleMetricsUpdator::theMaxDeltaPerp
private

Definition at line 39 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().

double SimpleMetricsUpdator::theMaxDeltaZ
private

Definition at line 41 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().

short int SimpleMetricsUpdator::theMetricalThreshold
private

Definition at line 43 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().

KalmanAlignmentMetricsCalculator SimpleMetricsUpdator::theMetricsCalculator
private
double SimpleMetricsUpdator::theMinDeltaPerp
private

Definition at line 38 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().

double SimpleMetricsUpdator::theMinDeltaZ
private

Definition at line 40 of file SimpleMetricsUpdator.h.

Referenced by additionalSelectionCriterion(), and SimpleMetricsUpdator().