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 
7 
14 
15 #include <vector>
16 
17 
21 
23 
27 
29 
31 // #include <iostream>
32 
33 class MagneticField;
35 
36 
37 #ifdef DO_BTSCount
38 class BTSCount {
39 public:
40  BTSCount(){}
41  virtual ~BTSCount();
42  BTSCount(BTSCount const &){}
43 
44  static unsigned int maxReferences;
45  static unsigned long long aveReferences;
46  static unsigned long long toteReferences;
47 
48  void addReference() const { ++referenceCount_ ; referenceMax_ = std::max(referenceMax_, referenceCount_); }
49  void removeReference() const {
50  if( 0 == --referenceCount_ ) {
51  delete const_cast<BTSCount*>(this);
52  }
53  }
54 
55  unsigned int references() const {return referenceCount_;}
56 private :
57 #ifdef CMS_NOCXX11
58  mutable unsigned int referenceCount_;
59  mutable unsigned int referenceMax_;
60 #else
61  mutable unsigned int referenceCount_=0;
62  mutable unsigned int referenceMax_ =0;
63 #endif
64 };
65 #else
67 #endif
68 
75 class BasicTrajectoryState : public BTSCount {
76  public:
77 
83 
84 private:
85  friend class ProxyBase< BTSOS, CopyUsingClone<BTSOS> >;
87 public:
88 
89  // default constructor : to make root happy
91 
93  explicit BasicTrajectoryState(const SurfaceType& aSurface);
94 
95  virtual ~BasicTrajectoryState();
96 
101  const SurfaceType& aSurface,
107  const SurfaceType& aSurface,
113  const CartesianTrajectoryError& err,
114  const SurfaceType& aSurface,
116 
122  const CurvilinearTrajectoryError& err,
123  const SurfaceType& aSurface,
125  double weight = 1.);
131  const CurvilinearTrajectoryError& err,
132  const SurfaceType& aSurface,
133  double weight);
138  const SurfaceType& aSurface,
139  const MagneticField* field,
146  const LocalTrajectoryError& err,
147  const SurfaceType& aSurface,
148  const MagneticField* field,
150  double weight = 1.);
156  const LocalTrajectoryError& err,
157  const SurfaceType& aSurface,
158  const MagneticField* field,
159  double weight);
160 
161  bool isValid() const { return theValid; }
162 
163 
164 // access global parameters/errors
166  return theFreeState.parameters();
167  }
169  return theFreeState.position();
170  }
172  return theFreeState.momentum();
173  }
175  return theFreeState.momentum().unit();
176  }
177  TrackCharge charge() const {
178  return theFreeState.charge();
179  }
180  double signedInverseMomentum() const {
182  }
183  double transverseCurvature() const {
185  }
186 
188  if unlikely(!hasError()) {
189  missingError(" accesing cartesian error.");
190  return CartesianTrajectoryError();
191  }
192  return freeTrajectoryState(true)->cartesianError();
193  }
195  if unlikely(!hasError()) {
196  missingError(" accesing curvilinearerror.");
197  static CurvilinearTrajectoryError crap;
198  return crap;
199  }
200  return freeTrajectoryState(true)->curvilinearError();
201  }
202 
203 
204 
205  FreeTrajectoryState const* freeTrajectoryState(bool withErrors=true) const {
206  if unlikely(!isValid()) notValid();
207  if(withErrors && hasError()) { // this is the right thing
209  }
210  return &theFreeState;
211  }
212 
213 
215 
216 // access local parameters/errors
218  if unlikely(!isValid()) notValid();
221  return theLocalParameters;
222  }
224  return localParameters().position();
225  }
227  return localParameters().momentum();
228  }
230  return localMomentum().unit();
231  }
232 
234  if unlikely(!hasError()) {
235  missingError(" accessing local error.");
236  return theLocalError;
237  }
239  return theLocalError;
240  }
241 
242  const SurfaceType& surface() const {
243  return *theSurfaceP;
244  }
245 
246  double weight() const {return theWeight;}
247 
248  void rescaleError(double factor);
249 
250 
251 
254  return theSurfaceSide;
255  }
256 
257  bool hasError() const {
259  }
260 
261 
262  virtual BasicTrajectoryState* clone() const=0;
263 
264  virtual bool canUpdateLocalParameters() const { return true; }
265 
266  virtual void update( const LocalTrajectoryParameters& p,
267  const SurfaceType& aSurface,
268  const MagneticField* field,
269  const SurfaceSide side ) ;
270 
271  virtual void update( const LocalTrajectoryParameters& p,
272  const LocalTrajectoryError& err,
273  const SurfaceType& aSurface,
274  const MagneticField* field,
275  const SurfaceSide side,
276  double weight ) ;
277 
278 public:
279  virtual std::vector<TrajectoryStateOnSurface> components() const;
280 
281 private:
282 
283  static void notValid();
284 
285 
286  void missingError(char const * where) const; // dso_internal;
287 
288  // create global errors from local
289  void checkCurvilinError() const; // dso_internal;
290 
291  // create local parameters and errors from global
292  void createLocalParameters() const;
293  // create local errors from global
294  void createLocalError() const;
296 
297 private:
298 
300 
303 
305  mutable bool theValid;
306 
307 
310 
311  double theWeight;
312 
313 };
314 
315 #endif
GlobalPoint globalPosition() const
ConstReferenceCountingPointer< SurfaceType > theSurfaceP
LocalPoint localPosition() const
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
CartesianTrajectoryError cartesianError() const
const MagneticField * magneticField() const
void createLocalErrorFromCurvilinearError() const dso_internal
SurfaceSideDefinition::SurfaceSide SurfaceSide
ReferenceCountedInEvent BTSCount
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
const GlobalTrajectoryParameters & parameters() const
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)
tuple field
Definition: statics.py:62
#define unlikely(x)
Definition: Likely.h:21
int TrackCharge
Definition: TrackCharge.h:4
GlobalVector globalDirection() const
const T & max(const T &a, const T &b)
const LocalTrajectoryError & localError() const
void removeReference() const
double signedInverseMomentum() const
void createLocalParameters() const
#define dso_internal
Definition: Visibility.h:13
LocalVector momentum() const
Momentum vector in the local frame.
std::atomic< unsigned int > referenceCount_
GlobalVector momentum() const
ReferenceCountingPointer< BasicTrajectoryState > RCPtr
Vector3DBase unit() const
Definition: Vector3DBase.h:57
GlobalPoint position() const
const SurfaceType & surface() const
ProxyBase< BTSOS, CopyUsingClone< BTSOS > > Proxy
const GlobalTrajectoryParameters & globalParameters() const
double transverseCurvature() const
FreeTrajectoryState theFreeState
string const
Definition: compareJSON.py:14
unsigned int references() const
double transverseCurvature() const
void missingError(char const *where) const
#define private
Definition: FWFileEntry.h:17
void addReference() const
GlobalVector globalMomentum() const
const LocalTrajectoryParameters & localParameters() const
virtual std::vector< TrajectoryStateOnSurface > components() const
LocalTrajectoryParameters theLocalParameters
virtual bool canUpdateLocalParameters() const
virtual BasicTrajectoryState * clone() const =0
LocalVector localDirection() const
const MagneticField & magneticField() const
LocalVector localMomentum() const
const CurvilinearTrajectoryError & curvilinearError() const
volatile std::atomic< bool > shutdown_flag false
LocalTrajectoryError theLocalError
double signedInverseMomentum() const
BasicTrajectoryState BTSOS