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  mutable unsigned int referenceCount_=0;
55  mutable unsigned int referenceMax_ =0;
56 };
57 #endif
58 
66  public:
67 
73 
74 public:
75 
76  // default constructor : to make root happy
78 
80  explicit BasicTrajectoryState(const SurfaceType& aSurface);
81 
82  virtual ~BasicTrajectoryState();
83 
84  virtual pointer clone() const=0;
85 
86  template<typename T, typename... Args>
87  static std::shared_ptr<BTSOS> build(Args && ...args){ return std::make_shared<T>(std::forward<Args>(args)...);}
88 
89  template<typename T, typename... Args>
90  static std::shared_ptr<BTSOS> churn(Args && ...args){ return std::allocate_shared<T>(churn_allocator<T>(),std::forward<Args>(args)...);}
91 
92 
93 
98  const SurfaceType& aSurface,
100 
101 
102 
108  const LocalTrajectoryError& err,
109  const SurfaceType& aSurface,
110  const MagneticField* field,
112 
113 
118  const SurfaceType& aSurface,
119  const MagneticField* field,
121  BasicTrajectoryState(par, InvalidError(), aSurface, field, side){}
122 
123 
124 
125 
130  const CartesianTrajectoryError& err,
131  const SurfaceType& aSurface,
133 
139  const CurvilinearTrajectoryError& err,
140  const SurfaceType& aSurface,
142  theFreeState(par, err),
146  theValid(true),
147  theSurfaceSide(side),
148  theSurfaceP( &aSurface),
149  theWeight(1.)
150  {}
151 
152 
157  const SurfaceType& aSurface,
159  BasicTrajectoryState(par, InvalidError(), aSurface, side){}
160 
161 
162  // as above, with explicit weight
163  template<typename... Args>
164  BasicTrajectoryState(double iweight, Args && ...args) : BasicTrajectoryState(std::forward<Args>(args)...) {
165  theWeight = iweight;
166  }
167 
168 
169 
170  bool isValid() const { return theValid; }
171 
172 
173 // access global parameters/errors
175  return theFreeState.parameters();
176  }
178  return theFreeState.position();
179  }
181  return theFreeState.momentum();
182  }
184  return theFreeState.momentum().unit();
185  }
186  TrackCharge charge() const {
187  return theFreeState.charge();
188  }
189  double signedInverseMomentum() const {
191  }
192  double transverseCurvature() const {
194  }
195 
197  if unlikely(!hasError()) {
198  missingError(" accesing cartesian error.");
199  return CartesianTrajectoryError();
200  }
201  return freeTrajectoryState(true)->cartesianError();
202  }
204  if unlikely(!hasError()) {
205  missingError(" accesing curvilinearerror.");
206  static const CurvilinearTrajectoryError crap;
207  return crap;
208  }
209  return freeTrajectoryState(true)->curvilinearError();
210  }
211 
212 
213 
214  FreeTrajectoryState const* freeTrajectoryState(bool withErrors=true) const {
215  if unlikely(!isValid()) notValid();
216  if(withErrors && hasError()) { // this is the right thing
218  }
219  return &theFreeState;
220  }
221 
222 
224 
225 // access local parameters/errors
227  if unlikely(!isValid()) notValid();
230  return theLocalParameters;
231  }
233  return localParameters().position();
234  }
236  return localParameters().momentum();
237  }
239  return localMomentum().unit();
240  }
241 
243  if unlikely(!hasError()) {
244  missingError(" accessing local error.");
245  return theLocalError;
246  }
248  return theLocalError;
249  }
250 
251  const SurfaceType& surface() const {
252  return *theSurfaceP;
253  }
254 
255  double weight() const {return theWeight;}
256 
257  void rescaleError(double factor);
258 
259 
260 
263  return theSurfaceSide;
264  }
265 
266  bool hasError() const {
268  }
269 
270 
271  virtual bool canUpdateLocalParameters() const { return true; }
272 
273  virtual void update( const LocalTrajectoryParameters& p,
274  const SurfaceType& aSurface,
275  const MagneticField* field,
276  const SurfaceSide side ) ;
277 
278  // update in place and in the very same place
279  virtual void update( const LocalTrajectoryParameters& p, const SurfaceSide side ) final;
280 
281 
282 
283  virtual void update( double weight,
285  const LocalTrajectoryError& err,
286  const SurfaceType& aSurface,
287  const MagneticField* field,
288  const SurfaceSide side);
289 
290  // update in place and in the very same place
291  virtual void update( const LocalTrajectoryParameters& p,
292  const LocalTrajectoryError& err,
293  const SurfaceSide side) final;
294 
297  }
298 
299 public:
300  virtual std::vector<TrajectoryStateOnSurface> components() const =0;
301 
302 private:
303 
304  static void notValid();
305 
306 
307  void missingError(char const * where) const; // dso_internal;
308 
309  // create global errors from local
310  void checkCurvilinError() const; // dso_internal;
311 
312  // create local parameters and errors from global
313  void createLocalParameters() const;
314  // create local errors from global
315  void createLocalError() const;
317 
318 private:
319 
321 
324 
326  mutable bool theValid;
327 
328 
331 
332  double theWeight=0.;
333 };
334 
335 #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
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.
BasicTrajectoryState(const GlobalTrajectoryParameters &par, const CurvilinearTrajectoryError &err, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
const CartesianTrajectoryError cartesianError() const
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
BasicTrajectoryState(double iweight, Args &&...args)
TrackCharge charge() const
TrackCharge charge() const
std::shared_ptr< T > pointer
Definition: ProxyBase11.h:24
const CurvilinearTrajectoryError & curvilinearError() const
void rescaleError(double factor)
#define unlikely(x)
BasicTrajectoryState(const LocalTrajectoryParameters &par, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
int TrackCharge
Definition: TrackCharge.h:4
GlobalVector globalDirection() const
static std::shared_ptr< BTSOS > build(Args &&...args)
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
static std::shared_ptr< BTSOS > churn(Args &&...args)
const GlobalTrajectoryParameters & globalParameters() const
double transverseCurvature() const
FreeTrajectoryState theFreeState
string const
Definition: compareJSON.py:14
CurvilinearTrajectoryError & setCurvilinearError()
double transverseCurvature() const
BasicTrajectoryState(const GlobalTrajectoryParameters &par, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
void missingError(char const *where) const
#define dso_internal
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