CMS 3D CMS Logo

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 SimpleBarrelNavigableLayer SimpleForwardNavigableLayer

Public Types

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

Public Member Functions

std::vector< const DetLayer * > compatibleLayers (const FreeTrajectoryState &fts, PropagationDirection timeDirection, int &counter) const final
 
virtual void setAdditionalLink (const 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 DetLayer const * detLayer () 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 const *dl)=0
 
void setSchool (NavigationSchool const *sh)
 
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
 
AnalyticalPropagator propagator (PropagationDirection dir) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const ForwardDetLayer *bl, DLC &result) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, ConstBDLI begin, ConstBDLI end, DLC &result) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, const DLC &layers, DLC &result) const
 
bool wellInside (const FreeTrajectoryState &fts, PropagationDirection dir, ConstFDLI begin, ConstFDLI end, DLC &result) const
 

Protected Attributes

bool theCheckCrossingSide
 
float theEpsilon
 
const MagneticFieldtheField
 
- Protected Attributes inherited from NavigableLayer
NavigationSchool const * school = 0
 

Detailed Description

A partial implementation of the NavigableLayer

Definition at line 19 of file SimpleNavigableLayer.h.

Member Typedef Documentation

typedef std::vector<const BarrelDetLayer*> SimpleNavigableLayer::BDLC

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.

typedef std::vector<const ForwardDetLayer*> SimpleNavigableLayer::FDLC

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.

References insideOut, and outsideIn.

26  :
27  theField(field), theEpsilon(eps),theCheckCrossingSide(checkCrossingSide),theSelfSearch(false) {}
const MagneticField * theField

Member Function Documentation

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

Reimplemented from NavigableLayer.

Definition at line 218 of file SimpleNavigableLayer.cc.

References LogDebug.

Referenced by SimpleForwardNavigableLayer::compatibleLayers(), and SimpleBarrelNavigableLayer::compatibleLayers().

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

Definition at line 14 of file SimpleNavigableLayer.cc.

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

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

Definition at line 71 of file SimpleNavigableLayer.h.

References dir, dso_internal, and Propagator::setPropagationDirection().

71  {
72  AnalyticalPropagator aPropagator(theField);
73  aPropagator.setPropagationDirection(dir);
74  return aPropagator;
75  }
dbl *** dir
Definition: mlp_gen.cc:35
const MagneticField * theField
virtual void SimpleNavigableLayer::setAdditionalLink ( const 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 61 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, gsfElectronCkfTrackCandidateMaker_cff::nSigma, PV3DBase< T, PVType, FrameType >::perp(), CartesianTrajectoryError::position(), FreeTrajectoryState::position(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, BarrelDetLayer::specificSurface(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by SimpleForwardNavigableLayer::nextLayers(), and SimpleBarrelNavigableLayer::nextLayers().

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

128 {
129  TSOS propState = propagator(dir).propagate( fts, fl->specificSurface());
130  if ( !propState.isValid()) return false;
131 
132  if (fl==detLayer()){
133  LogDebug("SimpleNavigableLayer")<<"self propagating from:\n"
134  <<fts<<"\n to \n"
135  <<*propState.freeState();
136  }
137 
138  //if requested avoids crossing over the tracker
140  bool backTobackTransverse = (fts.position().x()*propState.globalPosition().x() + fts.position().y()*propState.globalPosition().y())<0;
141  bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector())<0;
142 
143  if (backTobackTransverse || backToback ){
144  LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) ("
145  << fts.position().x()<<","<< fts.position().y()<<","<< fts.position().z()<<","<<fts.position().perp()
146  << ") going to TSOS (x,y,z,r)"
147  << propState.globalPosition().x()<<","<< propState.globalPosition().y()
148  <<","<< propState.globalPosition().z()<<","<<propState.globalPosition().perp()<<")";;
149  return false;
150 
151  // if (fts.position().z()*propState.globalPosition().z() < 0) return false;
152  }}
153 
154 
155  float rpos = propState.globalPosition().perp();
156  float innerR = fl->specificSurface().innerRadius();
157  float outerR = fl->specificSurface().outerRadius();
158 
159  // take into account the thickness of the layer
160  float deltaR = 0.5f*fl->surface().bounds().thickness() *
161  propState.localDirection().perp()/std::abs(propState.localDirection().z());
162 
163  // take into account the error on the predicted state
164  const float nSigma = theEpsilon;
165  if (propState.hasError()) {
166  LocalError err = propState.localError().positionError();
167  // ignore correlation for the moment...
168  deltaR += nSigma * sqrt(err.xx() + err.yy());
169  }
170 
171  // cout << "SimpleNavigableLayer BarrelDetLayer deltaR = " << deltaR << endl;
172 
173  if ( innerR-deltaR < rpos && rpos < outerR+deltaR) result.push_back( fl);
174  return ( innerR+deltaR < rpos && rpos < outerR-deltaR);
175 }
#define LogDebug(id)
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
AnalyticalPropagator propagator(PropagationDirection dir) const
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LocalTrajectoryError & localError() const
#define LogTrace(id)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
GlobalPoint position() const
virtual DetLayer const * detLayer() const =0
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 "dot" 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 195 of file SimpleNavigableLayer.cc.

References end, and mps_fire::i.

199 {
200  for ( ConstBDLI i = begin; i < end; i++) {
201  if (wellInside( fts, dir, *i, result)) return true;
202  }
203  return false;
204 }
#define end
Definition: vmac.h:39
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
#define begin
Definition: vmac.h:32
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 177 of file SimpleNavigableLayer.cc.

References checklumidiff::l.

181 {
182  for (auto l : layers) {
183  if (l->isBarrel()) {
184  const BarrelDetLayer * bl = reinterpret_cast<const BarrelDetLayer *>(l);
185  if (wellInside( fts, dir, bl, result)) return true;
186  }
187  else {
188  const ForwardDetLayer* fl = reinterpret_cast<const ForwardDetLayer*>(l);
189  if (wellInside( fts, dir, fl, result)) return true;
190  }
191  }
192  return false;
193 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
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 206 of file SimpleNavigableLayer.cc.

References end, and mps_fire::i.

210 {
211  for ( ConstFDLI i = begin; i < end; i++) {
212  if (wellInside( fts, dir, *i, result)) return true;
213  }
214  return false;
215 }
FDLC::const_iterator ConstFDLI
#define end
Definition: vmac.h:39
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
#define begin
Definition: vmac.h:32
dbl *** dir
Definition: mlp_gen.cc:35

Member Data Documentation

bool SimpleNavigableLayer::theCheckCrossingSide
protected

Definition at line 44 of file SimpleNavigableLayer.h.

float SimpleNavigableLayer::theEpsilon
protected

Definition at line 43 of file SimpleNavigableLayer.h.

const MagneticField* SimpleNavigableLayer::theField
protected

Definition at line 42 of file SimpleNavigableLayer.h.

bool SimpleNavigableLayer::theSelfSearch