test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BasicTrajectoryState.h
Go to the documentation of this file.
1 #ifndef BasicTrajectoryState_H
2 #define BasicTrajectoryState_H
3 
5 
12 
13 #include <vector>
14 
15 
19 
24 
26 
28 // #include <iostream>
29 
30 class MagneticField;
32 
33 
34 #ifdef DO_BTSCount
35 class BTSCount {
36 public:
37  BTSCount(){}
38  virtual ~BTSCount();
39  BTSCount(BTSCount const &){}
40 
41  static unsigned int maxReferences;
42  static unsigned long long aveReferences;
43  static unsigned long long toteReferences;
44 
45  void addReference() const { ++referenceCount_ ; referenceMax_ = std::max(referenceMax_, referenceCount_); }
46  void removeReference() const {
47  if( 0 == --referenceCount_ ) {
48  delete const_cast<BTSCount*>(this);
49  }
50  }
51 
52  unsigned int references() const {return referenceCount_;}
53 private :
54 #ifdef CMS_NOCXX11
55  mutable unsigned int referenceCount_;
56  mutable unsigned int referenceMax_;
57 #else
58  mutable unsigned int referenceCount_=0;
59  mutable unsigned int referenceMax_ =0;
60 #endif
61 };
62 #endif
63 
71  public:
72 
78 
79 public:
80 
81  // default constructor : to make root happy
83 
85  explicit BasicTrajectoryState(const SurfaceType& aSurface);
86 
87  virtual ~BasicTrajectoryState();
88 
89  virtual pointer clone() const=0;
90 
91 #ifndef CMS_NOCXX11
92 
93  template<typename T, typename... Args>
94  static std::shared_ptr<BTSOS> build(Args && ...args){ return std::make_shared<T>(std::forward<Args>(args)...);}
95 
96  template<typename T, typename... Args>
97  static std::shared_ptr<BTSOS> churn(Args && ...args){ return std::allocate_shared<T>(churn_allocator<T>(),std::forward<Args>(args)...);}
98 
99 
100 
105  const SurfaceType& aSurface,
107 
108 
109 
115  const LocalTrajectoryError& err,
116  const SurfaceType& aSurface,
117  const MagneticField* field,
119 
120 
125  const SurfaceType& aSurface,
126  const MagneticField* field,
128  BasicTrajectoryState(par, InvalidError(), aSurface, field, side){}
129 
130 
131 
132 
137  const CartesianTrajectoryError& err,
138  const SurfaceType& aSurface,
140 
146  const CurvilinearTrajectoryError& err,
147  const SurfaceType& aSurface,
149  theFreeState(par, err),
153  theValid(true),
154  theSurfaceSide(side),
155  theSurfaceP( &aSurface),
156  theWeight(1.)
157  {}
158 
159 
164  const SurfaceType& aSurface,
166  BasicTrajectoryState(par, InvalidError(), aSurface, side){}
167 
168 
169  // as above, with explicit weight
170  template<typename... Args>
171  BasicTrajectoryState(double iweight, Args && ...args) : BasicTrajectoryState(std::forward<Args>(args)...) {
172  theWeight = iweight;
173  }
174 
175 
176 #endif
177 
178  /*
179  virtual void update( const GlobalTrajectoryParameters& par,
180  const SurfaceType& aSurface,
181  SurfaceSide side) GCC11_FINAL {
182  theFreeState = FreeTrajectoryState(par);
183  theLocalError = InvalidError();
184  theLocalParametersValid=false;
185  theValid=true;
186  theSurfaceSide=side;
187  theSurfaceP = &aSurface;
188  theWeight = 1.;
189  }
190  virtual void update( const GlobalTrajectoryParameters& par,
191  const CurvilinearTrajectoryError& err,
192  const SurfaceType& aSurface,
193  SurfaceSide side) GCC11_FINAL {
194  theFreeState = FreeTrajectoryState(par,err);
195  theLocalError = InvalidError();
196  theLocalParametersValid=false;
197  theValid=true;
198  theSurfaceSide=side;
199  theSurfaceP = &aSurface;
200  theWeight = 1.;
201  }
202  */
203 
204  bool isValid() const { return theValid; }
205 
206 
207 // access global parameters/errors
209  return theFreeState.parameters();
210  }
212  return theFreeState.position();
213  }
215  return theFreeState.momentum();
216  }
218  return theFreeState.momentum().unit();
219  }
220  TrackCharge charge() const {
221  return theFreeState.charge();
222  }
223  double signedInverseMomentum() const {
225  }
226  double transverseCurvature() const {
228  }
229 
231  if unlikely(!hasError()) {
232  missingError(" accesing cartesian error.");
233  return CartesianTrajectoryError();
234  }
235  return freeTrajectoryState(true)->cartesianError();
236  }
238  if unlikely(!hasError()) {
239  missingError(" accesing curvilinearerror.");
240  static const CurvilinearTrajectoryError crap;
241  return crap;
242  }
243  return freeTrajectoryState(true)->curvilinearError();
244  }
245 
246 
247 
248  FreeTrajectoryState const* freeTrajectoryState(bool withErrors=true) const {
249  if unlikely(!isValid()) notValid();
250  if(withErrors && hasError()) { // this is the right thing
252  }
253  return &theFreeState;
254  }
255 
256 
258 
259 // access local parameters/errors
261  if unlikely(!isValid()) notValid();
264  return theLocalParameters;
265  }
267  return localParameters().position();
268  }
270  return localParameters().momentum();
271  }
273  return localMomentum().unit();
274  }
275 
277  if unlikely(!hasError()) {
278  missingError(" accessing local error.");
279  return theLocalError;
280  }
282  return theLocalError;
283  }
284 
285  const SurfaceType& surface() const {
286  return *theSurfaceP;
287  }
288 
289  double weight() const {return theWeight;}
290 
291  void rescaleError(double factor);
292 
293 
294 
297  return theSurfaceSide;
298  }
299 
300  bool hasError() const {
302  }
303 
304 
305  virtual bool canUpdateLocalParameters() const { return true; }
306 
307  virtual void update( const LocalTrajectoryParameters& p,
308  const SurfaceType& aSurface,
309  const MagneticField* field,
310  const SurfaceSide side ) ;
311 
312  // update in place and in the very same place
313  virtual void update( const LocalTrajectoryParameters& p, const SurfaceSide side ) GCC11_FINAL;
314 
315 
316 
317  virtual void update( double weight,
319  const LocalTrajectoryError& err,
320  const SurfaceType& aSurface,
321  const MagneticField* field,
322  const SurfaceSide side);
323 
324  // update in place and in the very same place
325  virtual void update( const LocalTrajectoryParameters& p,
326  const LocalTrajectoryError& err,
327  const SurfaceSide side) GCC11_FINAL;
328 
331  }
332 
333 public:
334  virtual std::vector<TrajectoryStateOnSurface> components() const =0;
335 
336 private:
337 
338  static void notValid();
339 
340 
341  void missingError(char const * where) const; // dso_internal;
342 
343  // create global errors from local
344  void checkCurvilinError() const; // dso_internal;
345 
346  // create local parameters and errors from global
347  void createLocalParameters() const;
348  // create local errors from global
349  void createLocalError() const;
351 
352 private:
353 
355 
358 
360  mutable bool theValid;
361 
362 
365 
366 #ifdef CMS_NOCXX11
367  double theWeight;
368 #else
369  double theWeight=0.;
370 #endif
371 };
372 
373 #endif
GlobalPoint globalPosition() const
ConstReferenceCountingPointer< SurfaceType > theSurfaceP
CurvilinearTrajectoryError & setCurvilinearError()
LocalPoint localPosition() const
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
virtual std::vector< TrajectoryStateOnSurface > components() const =0
#define GCC11_FINAL
CartesianTrajectoryError cartesianError() const
const MagneticField * magneticField() const
SurfaceSideDefinition::SurfaceSide SurfaceSide
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
const GlobalTrajectoryParameters & parameters() const
virtual pointer clone() const =0
LocalPoint position() const
Local x and y position coordinates.
const CartesianTrajectoryError cartesianError() const
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
TrackCharge charge() const
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
void rescaleError(double factor)
#define unlikely(x)
int TrackCharge
Definition: TrackCharge.h:4
GlobalVector globalDirection() const
void createLocalErrorFromCurvilinearError() const
const LocalTrajectoryError & localError() const
double signedInverseMomentum() const
void createLocalParameters() const
LocalVector momentum() const
Momentum vector in the local frame.
GlobalVector momentum() const
Vector3DBase unit() const
Definition: Vector3DBase.h:57
GlobalPoint position() const
const SurfaceType & surface() const
const GlobalTrajectoryParameters & globalParameters() const
double transverseCurvature() const
FreeTrajectoryState theFreeState
string const
Definition: compareJSON.py:14
CurvilinearTrajectoryError & setCurvilinearError()
double transverseCurvature() const
void missingError(char const *where) const
#define dso_internal
#define private
Definition: FWFileEntry.h:17
GlobalVector globalMomentum() const
const LocalTrajectoryParameters & localParameters() const
LocalTrajectoryParameters theLocalParameters
virtual bool canUpdateLocalParameters() const
LocalVector localDirection() const
const MagneticField & magneticField() const
LocalVector localMomentum() const
const CurvilinearTrajectoryError & curvilinearError() const
volatile std::atomic< bool > shutdown_flag false
long double T
LocalTrajectoryError theLocalError
ProxyBase11< BTSOS > Proxy
double signedInverseMomentum() const
BasicTrajectoryState BTSOS