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 
39 
40 
41 #ifdef DO_BTSCount
42 class BTSCount {
43 public:
44  BTSCount(){}
45  virtual ~BTSCount();
46  BTSCount(BTSCount const &){}
47 
48  static unsigned int maxReferences;
49  static unsigned long long aveReferences;
50  static unsigned long long toteReferences;
51 
52  void addReference() const { ++referenceCount_ ; referenceMax_ = std::max(referenceMax_, referenceCount_); }
53  void removeReference() const {
54  if( 0 == --referenceCount_ ) {
55  delete const_cast<BTSCount*>(this);
56  }
57  }
58 
59  unsigned int references() const {return referenceCount_;}
60 private :
61 #ifdef CMS_NOCXX11
62  mutable unsigned int referenceCount_;
63  mutable unsigned int referenceMax_;
64 #else
65  mutable unsigned int referenceCount_=0;
66  mutable unsigned int referenceMax_ =0;
67 #endif
68 };
69 #else
71 #endif
72 
79 class BasicTrajectoryState : public BTSCount {
80  public:
81 
87 
88 private:
89  friend class ProxyBase< BTSOS, CopyUsingClone<BTSOS> >;
91 public:
92 
93  // default constructor : to make root happy
95 
97  explicit BasicTrajectoryState(const SurfaceType& aSurface);
98 
99  virtual ~BasicTrajectoryState();
100 
105  const SurfaceType& aSurface,
111  const SurfaceType& aSurface,
117  const CartesianTrajectoryError& err,
118  const SurfaceType& aSurface,
120 
126  const CurvilinearTrajectoryError& err,
127  const SurfaceType& aSurface,
129  double weight = 1.);
135  const CurvilinearTrajectoryError& err,
136  const SurfaceType& aSurface,
137  double weight);
142  const SurfaceType& aSurface,
143  const MagneticField* field,
150  const LocalTrajectoryError& err,
151  const SurfaceType& aSurface,
152  const MagneticField* field,
154  double weight = 1.);
160  const LocalTrajectoryError& err,
161  const SurfaceType& aSurface,
162  const MagneticField* field,
163  double weight);
164 
165  bool isValid() const { return theValid; }
166 
167 
168 // access global parameters/errors
170  return theFreeState.parameters();
171  }
173  return theFreeState.position();
174  }
176  return theFreeState.momentum();
177  }
179  return theFreeState.momentum().unit();
180  }
181  TrackCharge charge() const {
182  return theFreeState.charge();
183  }
184  double signedInverseMomentum() const {
186  }
187  double transverseCurvature() const {
189  }
190 
192  if unlikely(!hasError()) {
193  missingError(" accesing cartesian error.");
194  return CartesianTrajectoryError();
195  }
196  return freeTrajectoryState(true)->cartesianError();
197  }
199  if unlikely(!hasError()) {
200  missingError(" accesing curvilinearerror.");
201  static CurvilinearTrajectoryError crap;
202  return crap;
203  }
204  return freeTrajectoryState(true)->curvilinearError();
205  }
206 
207 
208 
209  FreeTrajectoryState* freeTrajectoryState(bool withErrors=true) const {
210  if unlikely(!isValid()) notValid();
211  if(withErrors && hasError()) { // this is the right thing
213  }
214  return &theFreeState;
215  }
216 
217 
219 
220 // access local parameters/errors
222  if unlikely(!isValid()) notValid();
225  return theLocalParameters;
226  }
228  return localParameters().position();
229  }
231  return localParameters().momentum();
232  }
234  return localMomentum().unit();
235  }
236 
238  if unlikely(!hasError()) {
239  missingError(" accessing local error.");
240  return theLocalError;
241  }
243  return theLocalError;
244  }
245 
246  const SurfaceType& surface() const {
247  return *theSurfaceP;
248  }
249 
250  double weight() const {return theWeight;}
251 
252  void rescaleError(double factor);
253 
254 
255 
258  return theSurfaceSide;
259  }
260 
261  bool hasError() const {
263  }
264 
265 
266  virtual BasicTrajectoryState* clone() const=0;
267 
268  virtual bool canUpdateLocalParameters() const { return true; }
269 
270  virtual void update( const LocalTrajectoryParameters& p,
271  const SurfaceType& aSurface,
272  const MagneticField* field,
273  const SurfaceSide side ) ;
274 
275  virtual void update( const LocalTrajectoryParameters& p,
276  const LocalTrajectoryError& err,
277  const SurfaceType& aSurface,
278  const MagneticField* field,
279  const SurfaceSide side,
280  double weight ) ;
281 
282 public:
283  virtual std::vector<TrajectoryStateOnSurface> components() const;
284 
285 private:
286 
287  static void notValid();
288 
289 
290  void missingError(char const * where) const; // dso_internal;
291 
292  // create global errors from local
293  void checkCurvilinError() const; // dso_internal;
294 
295  // create local parameters and errors from global
296  void createLocalParameters() const;
297  // create local errors from global
298  void createLocalError() const;
300 
301 private:
302 
304 
307 
309  mutable bool theValid;
310 
311 
314 
315  double theWeight;
316 
317 };
318 
319 #endif
GlobalPoint globalPosition() const
FreeTrajectoryState * freeTrajectoryState(bool withErrors=true) const
ConstReferenceCountingPointer< SurfaceType > theSurfaceP
LocalPoint localPosition() 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)
#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)
unsigned int references() const
const LocalTrajectoryError & localError() const
double signedInverseMomentum() const
void createLocalParameters() const
#define dso_internal
Definition: Visibility.h:13
LocalVector momentum() const
Momentum vector in the local frame.
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
double transverseCurvature() const
void missingError(char const *where) const
#define private
Definition: FWFileEntry.h:18
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
LocalTrajectoryError theLocalError
double signedInverseMomentum() const
BasicTrajectoryState BTSOS