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 22 of file SimpleNavigableLayer.h.

typedef BDLC::iterator SimpleNavigableLayer::BDLI
protected

Definition at line 48 of file SimpleNavigableLayer.h.

typedef BDLC::const_iterator SimpleNavigableLayer::ConstBDLI
protected

Definition at line 50 of file SimpleNavigableLayer.h.

typedef FDLC::const_iterator SimpleNavigableLayer::ConstFDLI
protected

Definition at line 51 of file SimpleNavigableLayer.h.

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

Definition at line 21 of file SimpleNavigableLayer.h.

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

Definition at line 23 of file SimpleNavigableLayer.h.

typedef FDLC::iterator SimpleNavigableLayer::FDLI
protected

Definition at line 49 of file SimpleNavigableLayer.h.

Definition at line 52 of file SimpleNavigableLayer.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file SimpleNavigableLayer.h.

References insideOut, and outsideIn.

26  : 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 215 of file SimpleNavigableLayer.cc.

References LogDebug.

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

217  {
218  typedef std::vector<const DetLayer*> Lvect;
219  typedef std::set<const DetLayer*> Lset;
220 
221  //initiate the first iteration
222  const Lvect& someLayers = nextLayers(fts, timeDirection);
223  if (someLayers.empty()) {
224  LogDebug("SimpleNavigableLayer") << "Number of compatible layers: " << 0;
225  return someLayers;
226  }
227 
228  Lset collect; //a container of unique instances. to avoid duplicates
229  Lset layerToTry, nextLayerToTry; //set used for iterations
230  layerToTry.insert(someLayers.begin(), someLayers.end());
231 
232  while (!layerToTry.empty() && (counter++) <= 150) {
233  LogDebug("SimpleNavigableLayer") << counter << "] going to check on : " << layerToTry.size() << " next layers.";
234  //clear this set first, it will be swaped with layerToTry
235  nextLayerToTry.clear();
236  for (auto toTry : layerToTry) {
237  //add the layer you tried.
238  LogDebug("SimpleNavigableLayer") << counter << "] adding layer with pointer: " << (toTry)
239  << " first detid: " << (toTry)->basicComponents().front()->geographicalId();
240  if (!collect.insert(toTry).second)
241  continue;
242 
243  //find the next layers from it
244  Lvect&& nextLayers = school->nextLayers(*toTry, fts, timeDirection);
245  LogDebug("SimpleNavigableLayer") << counter << "] this layer has : " << nextLayers.size() << " next layers.";
246  nextLayerToTry.insert(nextLayers.begin(), nextLayers.end());
247  } // layerToTry
248  //swap now that you where to go next.
249  layerToTry.swap(nextLayerToTry);
250  }
251  if (counter >= 150) {
252  edm::LogWarning("SimpleNavigableLayer") << "WARNING: compatibleLayers() more than 150 iterations!!! Bailing out..";
253  counter = -1;
254  return Lvect();
255  }
256 
257  LogDebug("SimpleNavigableLayer") << "Number of compatible layers: " << collect.size();
258 
259  return Lvect(collect.begin(), collect.end());
260 }
#define LogDebug(id)
NavigationSchool const * school
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
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, DeadROC_duringRun::dir, MillePedeFileConverter_cfg::e, TransverseImpactPointExtrapolator::extrapolate(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::isValid(), LogDebug, mag2(), FreeTrajectoryState::position(), TrackCandidateProducer_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())
22  return TrajectoryStateOnSurface();
23 
24  FreeTrajectoryState const& dest = *propState.freeState();
25  GlobalPoint middlePoint = dest.position();
26  const float toCloseToEachOther2 = 1e-4 * 1e-4;
27  if
28  UNLIKELY((middlePoint - initialPoint).mag2() < toCloseToEachOther2) {
29  LogDebug("SimpleNavigableLayer")
30  << "initial state and PCA are identical. Things are bound to fail. Do not add the link.";
31  return TrajectoryStateOnSurface();
32  }
33 
34  /*
35  std::string dirS;
36  if (dir==alongMomentum) dirS = "alongMomentum";
37  else if (dir==oppositeToMomentum) dirS = "oppositeToMomentum";
38  else dirS = "anyDirection";
39  */
40 
41  LogDebug("SimpleNavigableLayer") << "self propagating(" << dir << ") from:\n"
42  << fts << "\n"
43  << dest << "\n"
44  << " and the direction is: " << dir;
45 
46  //second propagation to go on the other side of the barrel
47  //propState = propagator(dir).propagate( dest, detLayer()->specificSurface());
48  propState = propagator(dir).propagate(dest, detLayer()->surface());
49  if (!propState.isValid())
50  return TrajectoryStateOnSurface();
51 
52  const FreeTrajectoryState& dest2 = *propState.freeState();
53  GlobalPoint finalPoint = dest2.position();
54  LogDebug("SimpleNavigableLayer") << "second propagation(" << dir << ") to: \n" << dest2;
55  double finalDot = (middlePoint - initialPoint).basicVector().dot((finalPoint - middlePoint).basicVector());
56  if
57  UNLIKELY(finalDot < 0) { // check that before and after are in different side.
58  LogDebug("SimpleNavigableLayer") << "switch side back: ABORT.";
59  return TrajectoryStateOnSurface();
60  }
61  return propState;
62 }
#define LogDebug(id)
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
#define UNLIKELY(x)
Definition: Likely.h:21
AnalyticalPropagator SimpleNavigableLayer::propagator ( PropagationDirection  dir) const
inlineprotected

Definition at line 81 of file SimpleNavigableLayer.h.

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

81  {
82  AnalyticalPropagator aPropagator(theField);
83  aPropagator.setPropagationDirection(dir);
84  return aPropagator;
85  }
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 64 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, HLTSiStripMonitoring_cff::nSigma, PV3DBase< T, PVType, FrameType >::perp(), CartesianTrajectoryError::position(), FreeTrajectoryState::position(), TrackCandidateProducer_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().

67  {
68  TSOS propState = (bl == detLayer()) ? crossingState(fts, dir) : propagator(dir).propagate(fts, bl->specificSurface());
69 
70  if (!propState.isValid())
71  return false;
72 
73  //if requested check that the layer is crossed on the right side
75  bool backTobackTransverse =
76  (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) (" << fts.position().x() << ","
81  << fts.position().y() << "," << fts.position().z() << "," << fts.position().perp()
82  << ") going to TSOS (x,y,z,r)" << propState.globalPosition().x() << ","
83  << propState.globalPosition().y() << "," << propState.globalPosition().z() << ","
84  << 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 
103  const Bounds& bounds(bl->specificSurface().bounds());
104  float length = bounds.length() * 0.5f;
105 
106  // take into account the thickness of the layer
107  float deltaZ =
108  0.5f * bounds.thickness() * std::abs(propState.globalDirection().z()) / propState.globalDirection().perp();
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)
120  result.push_back(bl);
121 
122  return std::abs(zpos) < length - deltaZ;
123 }
virtual float length() const =0
CartesianTrajectoryError cartesianError() const
T perp() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:60
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:19
T z() const
Definition: PV3DBase.h:61
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:20
T x() const
Definition: PV3DBase.h:59
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
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 125 of file SimpleNavigableLayer.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::basicVector(), Surface::bounds(), PbPb_ZMuSkimMuonDPG_cff::deltaR, Basic3DVector< T >::dot(), runTheMatrix::err, TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), LogDebug, LogTrace, HLTSiStripMonitoring_cff::nSigma, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), LocalTrajectoryError::positionError(), TrackCandidateProducer_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())
131  return false;
132 
133  if (fl == detLayer()) {
134  LogDebug("SimpleNavigableLayer") << "self propagating from:\n" << fts << "\n to \n" << *propState.freeState();
135  }
136 
137  //if requested avoids crossing over the tracker
138  if (theCheckCrossingSide) {
139  bool backTobackTransverse =
140  (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) (" << fts.position().x() << ","
145  << fts.position().y() << "," << fts.position().z() << "," << fts.position().perp()
146  << ") going to TSOS (x,y,z,r)" << propState.globalPosition().x() << ","
147  << propState.globalPosition().y() << "," << propState.globalPosition().z() << ","
148  << propState.globalPosition().perp() << ")";
149  ;
150  return false;
151 
152  // if (fts.position().z()*propState.globalPosition().z() < 0) return false;
153  }
154  }
155 
156  float rpos = propState.globalPosition().perp();
157  float innerR = fl->specificSurface().innerRadius();
158  float outerR = fl->specificSurface().outerRadius();
159 
160  // take into account the thickness of the layer
161  float deltaR = 0.5f * fl->surface().bounds().thickness() * propState.localDirection().perp() /
162  std::abs(propState.localDirection().z());
163 
164  // take into account the error on the predicted state
165  const float nSigma = theEpsilon;
166  if (propState.hasError()) {
167  LocalError err = propState.localError().positionError();
168  // ignore correlation for the moment...
169  deltaR += nSigma * sqrt(err.xx() + err.yy());
170  }
171 
172  // cout << "SimpleNavigableLayer BarrelDetLayer deltaR = " << deltaR << endl;
173 
174  if (innerR - deltaR < rpos && rpos < outerR + deltaR)
175  result.push_back(fl);
176  return (innerR + deltaR < rpos && rpos < outerR - deltaR);
177 }
#define LogDebug(id)
float xx() const
Definition: LocalError.h:22
T perp() const
Definition: PV3DBase.h:69
LocalVector localDirection() const
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
LocalError positionError() const
AnalyticalPropagator propagator(PropagationDirection dir) const
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LocalTrajectoryError & localError() const
#define LogTrace(id)
GlobalPoint position() const
virtual DetLayer const * detLayer() const =0
T x() const
Definition: PV3DBase.h:59
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
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 197 of file SimpleNavigableLayer.cc.

References end, and mps_fire::i.

198  {
199  for (ConstBDLI i = begin; i < end; i++) {
200  if (wellInside(fts, dir, *i, result))
201  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
BDLC::const_iterator ConstBDLI
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
const DLC layers,
DLC result 
) const
protected

Definition at line 179 of file SimpleNavigableLayer.cc.

References cmsLHEtoEOSManager::l.

182  {
183  for (auto l : layers) {
184  if (l->isBarrel()) {
185  const BarrelDetLayer* bl = reinterpret_cast<const BarrelDetLayer*>(l);
186  if (wellInside(fts, dir, bl, result))
187  return true;
188  } else {
189  const ForwardDetLayer* fl = reinterpret_cast<const ForwardDetLayer*>(l);
190  if (wellInside(fts, dir, fl, result))
191  return true;
192  }
193  }
194  return false;
195 }
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
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.

207  {
208  for (ConstFDLI i = begin; i < end; i++) {
209  if (wellInside(fts, dir, *i, result))
210  return true;
211  }
212  return false;
213 }
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

Member Data Documentation

bool SimpleNavigableLayer::theCheckCrossingSide
protected

Definition at line 42 of file SimpleNavigableLayer.h.

float SimpleNavigableLayer::theEpsilon
protected

Definition at line 41 of file SimpleNavigableLayer.h.

const MagneticField* SimpleNavigableLayer::theField
protected

Definition at line 40 of file SimpleNavigableLayer.h.

bool SimpleNavigableLayer::theSelfSearch