CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes
SimpleNavigableLayer Class Referenceabstract

#include <SimpleNavigableLayer.h>

Inheritance diagram for SimpleNavigableLayer:
NavigableLayer GCC11_FINAL< T, TOPO > GCC11_FINAL< T, TOPO >

Public Types

typedef std::vector
< BarrelDetLayer * > 
BDLC
 
typedef std::vector< const
DetLayer * > 
DLC
 
typedef std::vector
< ForwardDetLayer * > 
FDLC
 

Public Member Functions

virtual std::vector< const
DetLayer * > 
compatibleLayers (const FreeTrajectoryState &fts, PropagationDirection timeDirection, int &counter) const GCC11_FINAL
 
virtual void setAdditionalLink (DetLayer *, NavigationDirection direction=insideOut)=0
 
void setCheckCrossingSide (bool docheck)
 
virtual void setInwardLinks (const BDLC &, const FDLC &, TkLayerLess sorter=TkLayerLess(outsideIn))=0
 
 SimpleNavigableLayer (const MagneticField *field, float eps, bool checkCrossingSide=true)
 
- Public Member Functions inherited from NavigableLayer
virtual std::vector< const
DetLayer * > 
compatibleLayers (NavigationDirection direction) const =0
 
virtual std::vector< const
DetLayer * > 
compatibleLayers (const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
 
virtual DetLayerdetLayer () const =0
 
virtual std::vector< const
DetLayer * > 
nextLayers (NavigationDirection direction) const =0
 
virtual std::vector< const
DetLayer * > 
nextLayers (const FreeTrajectoryState &fts, PropagationDirection timeDirection) const =0
 
virtual void setDetLayer (DetLayer *dl)=0
 
virtual ~NavigableLayer ()
 

Public Attributes

bool theSelfSearch
 

Protected Types

typedef BDLC::iterator BDLI
 
typedef BDLC::const_iterator ConstBDLI
 
typedef FDLC::const_iterator ConstFDLI
 
typedef FDLC::iterator FDLI
 
typedef TrajectoryStateOnSurface TSOS
 

Protected Member Functions

TSOS crossingState (const FreeTrajectoryState &fts, PropagationDirection dir) const dso_internal
 
Propagatorpropagator (PropagationDirection dir) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const dso_internal
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const ForwardDetLayer *bl, DLC &result) const dso_internal
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, ConstBDLI begin, ConstBDLI end, DLC &result) const dso_internal
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const DLC &layers, DLC &result) const dso_internal
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, ConstFDLI begin, ConstFDLI end, DLC &result) const dso_internal
 

Protected Attributes

bool theCheckCrossingSide
 
float theEpsilon
 
AnalyticalPropagator thePropagator
 

Detailed Description

A partial implementation of the NavigableLayer

Definition at line 19 of file SimpleNavigableLayer.h.

Member Typedef Documentation

Definition at line 23 of file SimpleNavigableLayer.h.

typedef BDLC::iterator SimpleNavigableLayer::BDLI
protected

Definition at line 49 of file SimpleNavigableLayer.h.

typedef BDLC::const_iterator SimpleNavigableLayer::ConstBDLI
protected

Definition at line 51 of file SimpleNavigableLayer.h.

typedef FDLC::const_iterator SimpleNavigableLayer::ConstFDLI
protected

Definition at line 52 of file SimpleNavigableLayer.h.

typedef std::vector<const DetLayer*> SimpleNavigableLayer::DLC

Definition at line 22 of file SimpleNavigableLayer.h.

Definition at line 24 of file SimpleNavigableLayer.h.

typedef FDLC::iterator SimpleNavigableLayer::FDLI
protected

Definition at line 50 of file SimpleNavigableLayer.h.

Definition at line 53 of file SimpleNavigableLayer.h.

Constructor & Destructor Documentation

SimpleNavigableLayer::SimpleNavigableLayer ( const MagneticField field,
float  eps,
bool  checkCrossingSide = true 
)
inline

Definition at line 26 of file SimpleNavigableLayer.h.

26  :
27  thePropagator(field), theEpsilon(eps),theCheckCrossingSide(checkCrossingSide),theSelfSearch(false) {}
AnalyticalPropagator thePropagator

Member Function Documentation

std::vector< const DetLayer * > SimpleNavigableLayer::compatibleLayers ( const FreeTrajectoryState fts,
PropagationDirection  timeDirection,
int &  counter 
) const
virtual

Reimplemented from NavigableLayer.

Definition at line 216 of file SimpleNavigableLayer.cc.

References LogDebug.

Referenced by GCC11_FINAL< T, TOPO >::compatibleLayers().

218  {
219  typedef std::vector<const DetLayer*> Lvect;
220  typedef std::set<const DetLayer *> Lset;
221 
222  //initiate the first iteration
223  Lvect && someLayers = nextLayers(fts,timeDirection);
224  if (someLayers.empty()) {
225  LogDebug("SimpleNavigableLayer") <<"Number of compatible layers: "<< 0;
226  return someLayers;
227  }
228 
229 
230  Lset collect; //a container of unique instances. to avoid duplicates
231  Lset layerToTry, nextLayerToTry;//set used for iterations
232  layerToTry.insert(someLayers.begin(),someLayers.end());
233 
234  while (!layerToTry.empty() && (counter++)<=150){
235  LogDebug("SimpleNavigableLayer")
236  <<counter<<"] going to check on : "<<layerToTry.size()<<" next layers.";
237  //clear this set first, it will be swaped with layerToTry
238  nextLayerToTry.clear();
239  for (auto toTry : layerToTry){
240  //add the layer you tried.
241  LogDebug("SimpleNavigableLayer")
242  <<counter<<"] adding layer with pointer: "<<(toTry)
243  <<" first detid: "<< (toTry)->basicComponents().front()->geographicalId();
244  if (!collect.insert(toTry).second) continue;
245 
246  //find the next layers from it
247  Lvect && nextLayers = (toTry)->nextLayers(fts,timeDirection);
248  LogDebug("SimpleNavigableLayer")
249  <<counter<<"] this layer has : "<<nextLayers.size()<<" next layers.";
250  nextLayerToTry.insert(nextLayers.begin(),nextLayers.end());
251  } // layerToTry
252  //swap now that you where to go next.
253  layerToTry.swap(nextLayerToTry);
254  }
255  if(counter>=150) {
256  edm::LogWarning("SimpleNavigableLayer") << "WARNING: compatibleLayers() more than 150 iterations!!! Bailing out..";
257  counter = -1;
258  return Lvect();
259  }
260 
261  LogDebug("SimpleNavigableLayer")
262  <<"Number of compatible layers: "<< collect.size();
263 
264  return Lvect(collect.begin(),collect.end());
265 
266 }
#define LogDebug(id)
virtual std::vector< const DetLayer * > nextLayers(NavigationDirection direction) const =0
static std::atomic< unsigned int > counter
TrajectoryStateOnSurface SimpleNavigableLayer::crossingState ( const FreeTrajectoryState fts,
PropagationDirection  dir 
) const
protected

Definition at line 12 of file SimpleNavigableLayer.cc.

References alignCSCRings::dest, dir, alignCSCRings::e, TransverseImpactPointExtrapolator::extrapolate(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::isValid(), LogDebug, mag2(), FreeTrajectoryState::position(), LargeD0_PixelPairStep_cff::propagator, and unlikely.

13  {
14  //self propagating. step one: go close to the center
15  GlobalPoint initialPoint = fts.position();
17  GlobalPoint center(0,0,0);
18  TSOS propState = middle.extrapolate(fts, center, propagator(dir));
19  if ( !propState.isValid()) return TrajectoryStateOnSurface();
20 
21  FreeTrajectoryState const & dest = *propState.freeState();
22  GlobalPoint middlePoint = dest.position();
23  const float toCloseToEachOther2 = 1e-4*1e-4;
24  if unlikely( (middlePoint-initialPoint).mag2() < toCloseToEachOther2){
25  LogDebug("SimpleNavigableLayer")<<"initial state and PCA are identical. Things are bound to fail. Do not add the link.";
26  return TrajectoryStateOnSurface();
27  }
28 
29 
30  /*
31  std::string dirS;
32  if (dir==alongMomentum) dirS = "alongMomentum";
33  else if (dir==oppositeToMomentum) dirS = "oppositeToMomentum";
34  else dirS = "anyDirection";
35  */
36 
37  LogDebug("SimpleNavigableLayer")<<"self propagating("<< dir <<") from:\n"
38  <<fts<<"\n"
39  <<dest<<"\n"
40  <<" and the direction is: "<<dir;
41 
42  //second propagation to go on the other side of the barrel
43  //propState = propagator(dir).propagate( dest, detLayer()->specificSurface());
44  propState = propagator(dir).propagate( dest, detLayer()->surface());
45  if ( !propState.isValid()) return TrajectoryStateOnSurface();
46 
47  const FreeTrajectoryState & dest2 = *propState.freeState();
48  GlobalPoint finalPoint = dest2.position();
49  LogDebug("SimpleNavigableLayer")<<"second propagation("<< dir <<") to: \n"
50  <<dest2;
51  double finalDot = (middlePoint - initialPoint).basicVector().dot((finalPoint-middlePoint).basicVector());
52  if unlikely(finalDot<0){ // check that before and after are in different side.
53  LogDebug("SimpleNavigableLayer")<<"switch side back: ABORT.";
54  return TrajectoryStateOnSurface();
55  }
56  return propState;
57 }
#define LogDebug(id)
virtual DetLayer * detLayer() const =0
#define unlikely(x)
Definition: Likely.h:21
FreeTrajectoryState const * freeState(bool withErrors=true) const
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Propagator & propagator(PropagationDirection dir) const
GlobalPoint position() const
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
dbl *** dir
Definition: mlp_gen.cc:35
Propagator& SimpleNavigableLayer::propagator ( PropagationDirection  dir) const
inlineprotected

Definition at line 71 of file SimpleNavigableLayer.h.

References thePropagator.

71  {
72  thePropagator.setPropagationDirection(dir);
73  return thePropagator;
74  }
AnalyticalPropagator thePropagator
dbl *** dir
Definition: mlp_gen.cc:35
virtual void SimpleNavigableLayer::setAdditionalLink ( DetLayer ,
NavigationDirection  direction = insideOut 
)
pure virtual
void SimpleNavigableLayer::setCheckCrossingSide ( bool  docheck)
inline
virtual void SimpleNavigableLayer::setInwardLinks ( const BDLC ,
const FDLC ,
TkLayerLess  sorter = TkLayerLess(outsideIn) 
)
pure virtual
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
const BarrelDetLayer bl,
DLC result 
) const
protected

Definition at line 59 of file SimpleNavigableLayer.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::basicVector(), FreeTrajectoryState::cartesianError(), GlobalErrorBase< T, ErrorWeightType >::czz(), Basic3DVector< T >::dot(), TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::isValid(), Bounds::length(), LogTrace, PV3DBase< T, PVType, FrameType >::perp(), CartesianTrajectoryError::position(), FreeTrajectoryState::position(), LargeD0_PixelPairStep_cff::propagator, BarrelDetLayer::specificSurface(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

63 {
64 
65  TSOS propState = (bl==detLayer()) ?
66  crossingState(fts,dir)
67  :
69 
70  if ( !propState.isValid()) return false;
71 
72  //if requested check that the layer is crossed on the right side
74  bool backTobackTransverse = (fts.position().x()*propState.globalPosition().x() + fts.position().y()*propState.globalPosition().y())<0;
75  bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector())<0;
76 
77  if (backTobackTransverse || backToback ){
78  LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) ("
79  << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
80  << ") going to TSOS (x,y,z,r)"
81  << propState.globalPosition().x()<<","<< propState.globalPosition().y()
82  <<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";
83  return false;
84 
85  /*
86  //we have to check the crossing side only if we are going to something smaller
87  if (fts.position().perp()>bl->specificSurface().radius() ||
88  fabs(fts.position().z())>bl->surface().bounds().length()/2. ){
89  if (propState.globalPosition().basicVector().dot(fts.position().basicVector())<0){
90  LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) ("
91  << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
92  << ") going to TSOS (x,y,z,r)"
93  << propState.globalPosition().x()<<","<< propState.globalPosition().y()<<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";;
94  return false;
95  }
96  }
97  */
98  }}
99 
100  const Bounds& bounds( bl->specificSurface().bounds());
101  float length = bounds.length()*0.5f;
102 
103  // take into account the thickness of the layer
104  float deltaZ = 0.5f*bounds.thickness() *
105  std::abs(propState.globalDirection().z())/propState.globalDirection().perp();
106 
107 
108  // take into account the error on the predicted state
109  const float nSigma = theEpsilon; // temporary reuse of epsilon
110  if (propState.hasError()) {
111  deltaZ += nSigma * sqrt( fts.cartesianError().position().czz());
112  }
113 
114  // cout << "SimpleNavigableLayer BarrelDetLayer deltaZ = " << deltaZ << endl;
115 
116  float zpos = propState.globalPosition().z();
117  if ( std::abs( zpos) < length + deltaZ) result.push_back( bl);
118 
119  return std::abs( zpos) < length - deltaZ;
120 }
virtual DetLayer * detLayer() const =0
CartesianTrajectoryError cartesianError() const
virtual float length() const =0
T perp() const
Definition: PV3DBase.h:72
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
TSOS crossingState(const FreeTrajectoryState &fts, PropagationDirection dir) const dso_internal
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define LogTrace(id)
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Propagator & propagator(PropagationDirection dir) const
GlobalPoint position() const
const GlobalError position() const
Position error submatrix.
Definition: Bounds.h:22
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
virtual const BoundCylinder & specificSurface() const GCC11_FINAL
Extension of the interface.
GlobalVector globalDirection() const
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
const ForwardDetLayer bl,
DLC result 
) const
protected

Definition at line 122 of file SimpleNavigableLayer.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::basicVector(), Surface::bounds(), deltaR(), Basic3DVector< T >::dot(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), LogDebug, LogTrace, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), LocalTrajectoryError::positionError(), LargeD0_PixelPairStep_cff::propagator, ForwardDetLayer::specificSurface(), mathSSE::sqrt(), ForwardDetLayer::surface(), Bounds::thickness(), PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().

126 {
127  TSOS propState = propagator(dir).propagate( fts, fl->specificSurface());
128  if ( !propState.isValid()) return false;
129 
130  if (fl==detLayer()){
131  LogDebug("SimpleNavigableLayer")<<"self propagating from:\n"
132  <<fts<<"\n to \n"
133  <<*propState.freeState();
134  }
135 
136  //if requested avoids crossing over the tracker
138  bool backTobackTransverse = (fts.position().x()*propState.globalPosition().x() + fts.position().y()*propState.globalPosition().y())<0;
139  bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector())<0;
140 
141  if (backTobackTransverse || backToback ){
142  LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) ("
143  << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
144  << ") going to TSOS (x,y,z,r)"
145  << propState.globalPosition().x()<<","<< propState.globalPosition().y()
146  <<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";;
147  return false;
148 
149  // if (fts.position().z()*propState.globalPosition().z() < 0) return false;
150  }}
151 
152 
153  float rpos = propState.globalPosition().perp();
154  float innerR = fl->specificSurface().innerRadius();
155  float outerR = fl->specificSurface().outerRadius();
156 
157  // take into account the thickness of the layer
158  float deltaR = 0.5f*fl->surface().bounds().thickness() *
159  propState.localDirection().perp()/std::abs(propState.localDirection().z());
160 
161  // take into account the error on the predicted state
162  const float nSigma = theEpsilon;
163  if (propState.hasError()) {
164  LocalError err = propState.localError().positionError();
165  // ignore correlation for the moment...
166  deltaR += nSigma * sqrt(err.xx() + err.yy());
167  }
168 
169  // cout << "SimpleNavigableLayer BarrelDetLayer deltaR = " << deltaR << endl;
170 
171  if ( innerR-deltaR < rpos && rpos < outerR+deltaR) result.push_back( fl);
172  return ( innerR+deltaR < rpos && rpos < outerR-deltaR);
173 }
#define LogDebug(id)
virtual DetLayer * detLayer() const =0
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
LocalVector localDirection() const
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
LocalError positionError() const
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:48
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LocalTrajectoryError & localError() const
#define LogTrace(id)
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Propagator & propagator(PropagationDirection dir) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
GlobalPoint position() const
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
ConstBDLI  begin,
ConstBDLI  end,
DLC result 
) const
protected

Definition at line 193 of file SimpleNavigableLayer.cc.

References end, and i.

197 {
198  for ( ConstBDLI i = begin; i < end; i++) {
199  if (wellInside( fts, dir, *i, result)) return true;
200  }
201  return false;
202 }
int i
Definition: DBlmapReader.cc:9
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const dso_internal
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
dbl *** dir
Definition: mlp_gen.cc:35
BDLC::const_iterator ConstBDLI
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
const DLC layers,
DLC result 
) const
protected

Definition at line 175 of file SimpleNavigableLayer.cc.

References ConfigFiles::l.

179 {
180  for (auto l : layers) {
181  if (l->isBarrel()) {
182  const BarrelDetLayer * bl = reinterpret_cast<const BarrelDetLayer *>(l);
183  if (wellInside( fts, dir, bl, result)) return true;
184  }
185  else {
186  const ForwardDetLayer* fl = reinterpret_cast<const ForwardDetLayer*>(l);
187  if (wellInside( fts, dir, fl, result)) return true;
188  }
189  }
190  return false;
191 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const dso_internal
tuple result
Definition: query.py:137
dbl *** dir
Definition: mlp_gen.cc:35
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
ConstFDLI  begin,
ConstFDLI  end,
DLC result 
) const
protected

Definition at line 204 of file SimpleNavigableLayer.cc.

References end, and i.

208 {
209  for ( ConstFDLI i = begin; i < end; i++) {
210  if (wellInside( fts, dir, *i, result)) return true;
211  }
212  return false;
213 }
int i
Definition: DBlmapReader.cc:9
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const dso_internal
tuple result
Definition: query.py:137
FDLC::const_iterator ConstFDLI
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
dbl *** dir
Definition: mlp_gen.cc:35

Member Data Documentation

bool SimpleNavigableLayer::theCheckCrossingSide
protected

Definition at line 44 of file SimpleNavigableLayer.h.

Referenced by setCheckCrossingSide().

float SimpleNavigableLayer::theEpsilon
protected

Definition at line 43 of file SimpleNavigableLayer.h.

AnalyticalPropagator SimpleNavigableLayer::thePropagator
mutableprotected

Definition at line 42 of file SimpleNavigableLayer.h.

Referenced by propagator().

bool SimpleNavigableLayer::theSelfSearch

Definition at line 46 of file SimpleNavigableLayer.h.

Referenced by CosmicNavigationSchool::build().