CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 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 = nullptr
 

Detailed Description

A partial implementation of the NavigableLayer

Definition at line 20 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.

27  : theField(field), theEpsilon(eps), theCheckCrossingSide(checkCrossingSide), theSelfSearch(false) {}
WorkSpace int float eps
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 214 of file SimpleNavigableLayer.cc.

References LogDebug.

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

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

Definition at line 15 of file SimpleNavigableLayer.cc.

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

16  {
17  //self propagating. step one: go close to the center
18  GlobalPoint initialPoint = fts.position();
20  GlobalPoint center(0, 0, 0);
21  TSOS propState = middle.extrapolate(fts, center, propagator(dir));
22  if (!propState.isValid())
23  return TrajectoryStateOnSurface();
24 
25  FreeTrajectoryState const& dest = *propState.freeState();
26  GlobalPoint middlePoint = dest.position();
27  const float toCloseToEachOther2 = 1e-4 * 1e-4;
28  if 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 UNLIKELY (finalDot < 0) { // check that before and after are in different side.
57  LogDebug("SimpleNavigableLayer") << "switch side back: ABORT.";
58  return TrajectoryStateOnSurface();
59  }
60  return propState;
61 }
virtual DetLayer const * detLayer() const =0
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
#define UNLIKELY(x)
Definition: Likely.h:21
#define LogDebug(id)
AnalyticalPropagator SimpleNavigableLayer::propagator ( PropagationDirection  dir) const
inlineprotected

Definition at line 82 of file SimpleNavigableLayer.h.

References Propagator::setPropagationDirection().

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

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

References funct::abs(), PV3DBase< T, PVType, FrameType >::basicVector(), Surface::bounds(), HLT_FULL_cff::deltaR, Basic3DVector< T >::dot(), submitPVValidationJobs::err, TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), LogDebug, LogTrace, HLT_FULL_cff::nSigma, PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), LocalTrajectoryError::positionError(), HLT_FULL_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().

127  {
128  TSOS propState = propagator(dir).propagate(fts, fl->specificSurface());
129  if (!propState.isValid())
130  return false;
131 
132  if (fl == detLayer()) {
133  LogDebug("SimpleNavigableLayer") << "self propagating from:\n" << fts << "\n to \n" << *propState.freeState();
134  }
135 
136  //if requested avoids crossing over the tracker
137  if (theCheckCrossingSide) {
138  bool backTobackTransverse =
139  (fts.position().x() * propState.globalPosition().x() + fts.position().y() * propState.globalPosition().y()) < 0;
140  bool backToback = propState.globalPosition().basicVector().dot(fts.position().basicVector()) < 0;
141 
142  if (backTobackTransverse || backToback) {
143  LogTrace("TkNavigation") << "Crossing over prevented!\nStaring from (x,y,z,r) (" << fts.position().x() << ","
144  << fts.position().y() << "," << fts.position().z() << "," << fts.position().perp()
145  << ") going to TSOS (x,y,z,r)" << propState.globalPosition().x() << ","
146  << propState.globalPosition().y() << "," << propState.globalPosition().z() << ","
147  << propState.globalPosition().perp() << ")";
148  ;
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() * propState.localDirection().perp() /
161  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)
174  result.push_back(fl);
175  return (innerR + deltaR < rpos && rpos < outerR - deltaR);
176 }
float xx() const
Definition: LocalError.h:22
T perp() const
Definition: PV3DBase.h:69
LocalVector localDirection() const
virtual DetLayer const * detLayer() const =0
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
LocalError positionError() const
#define LogTrace(id)
tuple result
Definition: mps_fire.py:311
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
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
#define LogDebug(id)
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 196 of file SimpleNavigableLayer.cc.

References dataset::end, and mps_fire::i.

197  {
198  for (ConstBDLI i = begin; i < end; i++) {
199  if (wellInside(fts, dir, *i, result))
200  return true;
201  }
202  return false;
203 }
tuple result
Definition: mps_fire.py:311
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
string end
Definition: dataset.py:937
BDLC::const_iterator ConstBDLI
bool SimpleNavigableLayer::wellInside ( const FreeTrajectoryState fts,
PropagationDirection  dir,
const DLC layers,
DLC result 
) const
protected

Definition at line 178 of file SimpleNavigableLayer.cc.

References cmsLHEtoEOSManager::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))
186  return true;
187  } else {
188  const ForwardDetLayer* fl = reinterpret_cast<const ForwardDetLayer*>(l);
189  if (wellInside(fts, dir, fl, result))
190  return true;
191  }
192  }
193  return false;
194 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
tuple result
Definition: mps_fire.py:311
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 205 of file SimpleNavigableLayer.cc.

References dataset::end, and mps_fire::i.

206  {
207  for (ConstFDLI i = begin; i < end; i++) {
208  if (wellInside(fts, dir, *i, result))
209  return true;
210  }
211  return false;
212 }
tuple result
Definition: mps_fire.py:311
FDLC::const_iterator ConstFDLI
bool wellInside(const FreeTrajectoryState &fts, PropagationDirection dir, const BarrelDetLayer *bl, DLC &result) const
string end
Definition: dataset.py:937

Member Data Documentation

bool SimpleNavigableLayer::theCheckCrossingSide
protected

Definition at line 43 of file SimpleNavigableLayer.h.

float SimpleNavigableLayer::theEpsilon
protected

Definition at line 42 of file SimpleNavigableLayer.h.

const MagneticField* SimpleNavigableLayer::theField
protected

Definition at line 41 of file SimpleNavigableLayer.h.

bool SimpleNavigableLayer::theSelfSearch