CMS 3D CMS Logo

BasicTrajectoryState.h
Go to the documentation of this file.
1 #ifndef BasicTrajectoryState_H
2 #define BasicTrajectoryState_H
3 
5 
12 
13 #include <vector>
14 
18 
24 
26 // #include <iostream>
27 
28 class MagneticField;
30 
31 #ifdef DO_BTSCount
32 class BTSCount {
33 public:
34  BTSCount() {}
35  virtual ~BTSCount();
36  BTSCount(BTSCount const&) {}
37 
38  static unsigned int maxReferences;
39  static unsigned long long aveReferences;
40  static unsigned long long toteReferences;
41 
42  void addReference() const {
43  ++referenceCount_;
44  referenceMax_ = std::max(referenceMax_, referenceCount_);
45  }
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 
54 private:
55  mutable unsigned int referenceCount_ = 0;
56  mutable unsigned int referenceMax_ = 0;
57 };
58 #endif
59 
67 public:
73 
74 public:
75  // default constructor : to make root happy
77 
79  explicit BasicTrajectoryState(const SurfaceType& aSurface);
80 
81  virtual ~BasicTrajectoryState();
82 
83  virtual pointer clone() const = 0;
84 
85  template <typename T, typename... Args>
86  static std::shared_ptr<BTSOS> build(Args&&... args) {
87  return std::make_shared<T>(std::forward<Args>(args)...);
88  }
89 
90  template <typename T, typename... Args>
91  static std::shared_ptr<BTSOS> churn(Args&&... args) {
92  return std::allocate_shared<T>(churn_allocator<T>(), std::forward<Args>(args)...);
93  }
94 
99  const SurfaceType& aSurface,
101  : theFreeState(fts),
105  theValid(true),
106  theSurfaceSide(side),
107  theSurfaceP(&aSurface),
108  theWeight(1.) {}
109 
113  : theFreeState(fts),
117  theValid(true),
118  theWeight(1.) {}
119 
125  const LocalTrajectoryError& err,
126  const SurfaceType& aSurface,
127  const MagneticField* field,
129 
134  const SurfaceType& aSurface,
135  const MagneticField* field,
137  : BasicTrajectoryState(par, InvalidError(), aSurface, field, side) {}
138 
144  const SurfaceType& aSurface,
146  : theFreeState(par, err),
150  theValid(true),
151  theSurfaceSide(side),
152  theSurfaceP(&aSurface),
153  theWeight(1.) {}
154 
161  const SurfaceType& aSurface,
163  : theFreeState(par, err),
167  theValid(true),
168  theSurfaceSide(side),
169  theSurfaceP(&aSurface),
170  theWeight(1.) {}
171 
176  const SurfaceType& aSurface,
178  : BasicTrajectoryState(par, InvalidError(), aSurface, side) {}
179 
180  // as above, with explicit weight
181  template <typename... Args>
182  BasicTrajectoryState(double iweight, Args&&... args) : BasicTrajectoryState(std::forward<Args>(args)...) {
183  theWeight = iweight;
184  }
185 
186  bool isValid() const { return theValid; }
187 
188  // access global parameters/errors
193  TrackCharge charge() const { return theFreeState.charge(); }
196 
198  if
199  UNLIKELY(!hasError()) {
200  missingError(" accesing cartesian error.");
201  return CartesianTrajectoryError();
202  }
203  return freeTrajectoryState(true)->cartesianError();
204  }
206  if
207  UNLIKELY(!hasError()) {
208  missingError(" accesing curvilinearerror.");
209  static const CurvilinearTrajectoryError crap;
210  return crap;
211  }
212  return freeTrajectoryState(true)->curvilinearError();
213  }
214 
215  FreeTrajectoryState const* freeTrajectoryState(bool withErrors = true) const {
216  if
217  UNLIKELY(!isValid()) notValid();
218  if (withErrors && hasError()) { // this is the right thing
220  }
221  return &theFreeState;
222  }
223 
225 
226  // access local parameters/errors
228  if
229  UNLIKELY(!isValid()) notValid();
230  if
233  return theLocalParameters;
234  }
238 
240  if
241  UNLIKELY(!hasError()) {
242  missingError(" accessing local error.");
243  return theLocalError;
244  }
245  if
247  return theLocalError;
248  }
249 
250  const SurfaceType& surface() const { return *theSurfaceP; }
251 
252  double weight() const { return theWeight; }
253 
254  void rescaleError(double factor);
255 
258 
259  bool hasError() const { return theFreeState.hasError() || theLocalError.valid(); }
260 
261  virtual bool canUpdateLocalParameters() const { return true; }
262 
263  virtual void update(const LocalTrajectoryParameters& p,
264  const SurfaceType& aSurface,
265  const MagneticField* field,
266  const SurfaceSide side);
267 
268  // update in place and in the very same place
269  virtual void update(const LocalTrajectoryParameters& p, const SurfaceSide side) final;
270 
271  virtual void update(double weight,
273  const LocalTrajectoryError& err,
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,
280  const LocalTrajectoryError& err,
281  const SurfaceSide side) final;
282 
284 
285 public:
286  using Components = std::vector<TrajectoryStateOnSurface>;
287  virtual Components const& components() const = 0;
288  virtual bool singleState() const = 0;
289 
290 private:
291  static void notValid();
292 
293  void missingError(char const* where) const; // dso_internal;
294 
295  // create global errors from local
296  void checkCurvilinError() const; // dso_internal;
297 
298  // create local parameters and errors from global
299  void createLocalParameters() const;
300  // create local errors from global
301  void createLocalError() const;
303 
304 private:
306 
309 
311  mutable bool theValid;
312 
315 
316  double theWeight = 0.;
317 };
318 
319 #endif
Vector3DBase
Definition: Vector3DBase.h:8
Likely.h
BasicTrajectoryState::magneticField
const MagneticField * magneticField() const
Definition: BasicTrajectoryState.h:224
writedatasetfile.args
args
Definition: writedatasetfile.py:18
BasicTrajectoryState::BTSOS
BasicTrajectoryState BTSOS
Definition: BasicTrajectoryState.h:68
BasicTrajectoryState::globalDirection
GlobalVector globalDirection() const
Definition: BasicTrajectoryState.h:192
churn_allocator
Definition: ChurnAllocator.h:6
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
LocalTrajectoryParameters.h
FreeTrajectoryState.h
BasicTrajectoryState::clone
virtual pointer clone() const =0
GlobalTrajectoryParameters.h
BasicTrajectoryState::freeTrajectoryState
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
Definition: BasicTrajectoryState.h:215
BasicTrajectoryState::SurfaceType
Surface SurfaceType
Definition: BasicTrajectoryState.h:72
BasicTrajectoryState::SurfaceSide
SurfaceSideDefinition::SurfaceSide SurfaceSide
Definition: BasicTrajectoryState.h:71
funct::false
false
Definition: Factorize.h:29
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
FreeTrajectoryState::hasError
bool hasError() const
Definition: FreeTrajectoryState.h:77
BasicTrajectoryState::weight
double weight() const
Definition: BasicTrajectoryState.h:252
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const FreeTrajectoryState &fts)
Definition: BasicTrajectoryState.h:112
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
BasicTrajectoryState::charge
TrackCharge charge() const
Definition: BasicTrajectoryState.h:193
BasicTrajectoryState::pointer
Proxy::pointer pointer
Definition: BasicTrajectoryState.h:70
ConstReferenceCountingPointer
Definition: ReferenceCounted.h:67
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const GlobalTrajectoryParameters &par, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Definition: BasicTrajectoryState.h:175
Surface
Definition: Surface.h:36
SurfaceSideDefinition::SurfaceSide
SurfaceSide
Definition: SurfaceSideDefinition.h:8
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const LocalTrajectoryParameters &par, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Definition: BasicTrajectoryState.h:133
FreeTrajectoryState::signedInverseMomentum
double signedInverseMomentum() const
Definition: FreeTrajectoryState.h:70
LocalTrajectoryError::valid
bool valid() const
Definition: LocalTrajectoryError.h:32
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
LocalTrajectoryError::invalid
bool invalid() const
Definition: LocalTrajectoryError.h:31
watchdog.const
const
Definition: watchdog.py:83
BasicTrajectoryState::rescaleError
void rescaleError(double factor)
Definition: BasicTrajectoryState.cc:222
SurfaceSideDefinition::atCenterOfSurface
Definition: SurfaceSideDefinition.h:8
TrajectoryStateExceptions.h
BasicTrajectoryState::theLocalParametersValid
bool theLocalParametersValid
Definition: BasicTrajectoryState.h:310
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
ProxyBase11.h
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
BasicTrajectoryState::localError
const LocalTrajectoryError & localError() const
Definition: BasicTrajectoryState.h:239
LocalTrajectoryError.h
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(double iweight, Args &&... args)
Definition: BasicTrajectoryState.h:182
FreeTrajectoryState::cartesianError
CartesianTrajectoryError cartesianError() const
Definition: FreeTrajectoryState.h:81
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState()
Definition: BasicTrajectoryState.h:76
LocalTrajectoryParameters::position
LocalPoint position() const
Local x and y position coordinates.
Definition: LocalTrajectoryParameters.h:85
BasicTrajectoryState::createLocalErrorFromCurvilinearError
void createLocalErrorFromCurvilinearError() const
Definition: BasicTrajectoryState.cc:154
Surface.h
CurvilinearTrajectoryError.h
FreeTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: FreeTrajectoryState.h:89
BasicTrajectoryState::globalParameters
const GlobalTrajectoryParameters & globalParameters() const
Definition: BasicTrajectoryState.h:189
ProxyBase11::pointer
std::shared_ptr< T > pointer
Definition: ProxyBase11.h:25
CartesianTrajectoryError.h
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
BasicTrajectoryState::surface
const SurfaceType & surface() const
Definition: BasicTrajectoryState.h:250
Point3DBase< float, GlobalTag >
BasicTrajectoryState::localMomentum
LocalVector localMomentum() const
Definition: BasicTrajectoryState.h:236
BasicTrajectoryState::theValid
bool theValid
Definition: BasicTrajectoryState.h:311
SurfaceSideDefinition.h
BasicTrajectoryState::canUpdateLocalParameters
virtual bool canUpdateLocalParameters() const
Definition: BasicTrajectoryState.h:261
BasicTrajectoryState::notValid
static void notValid()
Definition: BasicTrajectoryState.cc:82
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
funct::true
true
Definition: Factorize.h:173
BasicTrajectoryState::hasError
bool hasError() const
Definition: BasicTrajectoryState.h:259
BasicTrajectoryState::cartesianError
const CartesianTrajectoryError cartesianError() const
Definition: BasicTrajectoryState.h:197
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
BasicTrajectoryState::singleState
virtual bool singleState() const =0
dso_internal
#define dso_internal
Definition: Visibility.h:13
BasicTrajectoryState::createLocalParameters
void createLocalParameters() const
Definition: BasicTrajectoryState.cc:132
BasicTrajectoryState::theLocalError
LocalTrajectoryError theLocalError
Definition: BasicTrajectoryState.h:307
BasicTrajectoryState::localDirection
LocalVector localDirection() const
Definition: BasicTrajectoryState.h:237
BasicTrajectoryState::theWeight
double theWeight
Definition: BasicTrajectoryState.h:316
BasicTrajectoryState::missingError
void missingError(char const *where) const
Definition: BasicTrajectoryState.cc:103
FreeTrajectoryState::parameters
const GlobalTrajectoryParameters & parameters() const
Definition: FreeTrajectoryState.h:79
BasicTrajectoryState::update
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
Definition: BasicTrajectoryState.cc:175
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const GlobalTrajectoryParameters &par, const CartesianTrajectoryError &err, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Definition: BasicTrajectoryState.h:142
BasicTrajectoryState::globalPosition
GlobalPoint globalPosition() const
Definition: BasicTrajectoryState.h:190
BasicTrajectoryState
Definition: BasicTrajectoryState.h:66
RefreshWebPage.crap
crap
Definition: RefreshWebPage.py:17
BasicTrajectoryState::transverseCurvature
double transverseCurvature() const
Definition: BasicTrajectoryState.h:195
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
BasicTrajectoryState::Components
std::vector< TrajectoryStateOnSurface > Components
Definition: BasicTrajectoryState.h:286
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const FreeTrajectoryState &fts, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Definition: BasicTrajectoryState.h:98
BasicTrajectoryState::~BasicTrajectoryState
virtual ~BasicTrajectoryState()
Definition: BasicTrajectoryState.cc:38
BasicTrajectoryState::theLocalParameters
LocalTrajectoryParameters theLocalParameters
Definition: BasicTrajectoryState.h:308
CartesianTrajectoryError
Definition: CartesianTrajectoryError.h:15
ReferenceCounted.h
BasicTrajectoryState::surfaceSide
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
Definition: BasicTrajectoryState.h:257
BasicTrajectoryState::isValid
bool isValid() const
Definition: BasicTrajectoryState.h:186
std
Definition: JetResolutionObject.h:76
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
ProxyBase11
Definition: ProxyBase11.h:23
BasicTrajectoryState::churn
static std::shared_ptr< BTSOS > churn(Args &&... args)
Definition: BasicTrajectoryState.h:91
T
long double T
Definition: Basic3DVectorLD.h:48
LocalTrajectoryParameters::momentum
LocalVector momentum() const
Momentum vector in the local frame.
Definition: LocalTrajectoryParameters.h:88
BasicTrajectoryState::build
static std::shared_ptr< BTSOS > build(Args &&... args)
Definition: BasicTrajectoryState.h:86
BasicTrajectoryState::createLocalError
void createLocalError() const
Definition: BasicTrajectoryState.cc:147
BasicTrajectoryState::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: BasicTrajectoryState.h:227
GlobalTrajectoryParameters::magneticField
const MagneticField & magneticField() const
Definition: GlobalTrajectoryParameters.h:106
BasicTrajectoryState::Proxy
ProxyBase11< BTSOS > Proxy
Definition: BasicTrajectoryState.h:69
DeepCopyPointer.h
FreeTrajectoryState::setCurvilinearError
CurvilinearTrajectoryError & setCurvilinearError()
Definition: FreeTrajectoryState.h:100
BasicTrajectoryState::setCurvilinearError
CurvilinearTrajectoryError & setCurvilinearError()
Definition: BasicTrajectoryState.h:283
BasicTrajectoryState::components
virtual Components const & components() const =0
BasicTrajectoryState::theFreeState
FreeTrajectoryState theFreeState
Definition: BasicTrajectoryState.h:305
BasicTrajectoryState::localPosition
LocalPoint localPosition() const
Definition: BasicTrajectoryState.h:235
BasicTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: BasicTrajectoryState.h:205
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const GlobalTrajectoryParameters &par, const CurvilinearTrajectoryError &err, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
Definition: BasicTrajectoryState.h:159
MagneticField
Definition: MagneticField.h:19
BasicTrajectoryState::theSurfaceP
ConstReferenceCountingPointer< SurfaceType > theSurfaceP
Definition: BasicTrajectoryState.h:314
BasicTrajectoryState::signedInverseMomentum
double signedInverseMomentum() const
Definition: BasicTrajectoryState.h:194
BasicTrajectoryState::checkCurvilinError
void checkCurvilinError() const
Definition: BasicTrajectoryState.cc:114
FreeTrajectoryState::transverseCurvature
double transverseCurvature() const
Definition: FreeTrajectoryState.h:71
weight
Definition: weight.py:1
InvalidError
Definition: TrivialError.h:8
BasicTrajectoryState::theSurfaceSide
SurfaceSide theSurfaceSide
Definition: BasicTrajectoryState.h:313
BasicTrajectoryState::globalMomentum
GlobalVector globalMomentum() const
Definition: BasicTrajectoryState.h:191