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 UNLIKELY (!hasError()) {
199  missingError(" accesing cartesian error.");
200  return CartesianTrajectoryError();
201  }
202  return freeTrajectoryState(true)->cartesianError();
203  }
205  if UNLIKELY (!hasError()) {
206  missingError(" accesing curvilinearerror.");
207  static const CurvilinearTrajectoryError crap;
208  return crap;
209  }
210  return freeTrajectoryState(true)->curvilinearError();
211  }
212 
213  FreeTrajectoryState const* freeTrajectoryState(bool withErrors = true) const {
214  if UNLIKELY (!isValid())
215  notValid();
216  if (withErrors && hasError()) { // this is the right thing
218  }
219  return &theFreeState;
220  }
221 
223 
224  // access local parameters/errors
226  if UNLIKELY (!isValid())
227  notValid();
230  return theLocalParameters;
231  }
235 
237  if UNLIKELY (!hasError()) {
238  missingError(" accessing local error.");
239  return theLocalError;
240  }
243  return theLocalError;
244  }
245 
246  const SurfaceType& surface() const { return *theSurfaceP; }
247 
248  double weight() const { return theWeight; }
249 
250  void rescaleError(double factor);
251 
254 
255  bool hasError() const { return theFreeState.hasError() || theLocalError.valid(); }
256 
257  virtual bool canUpdateLocalParameters() const { return true; }
258 
259  virtual void update(const LocalTrajectoryParameters& p,
260  const SurfaceType& aSurface,
261  const MagneticField* field,
262  const SurfaceSide side);
263 
264  // update in place and in the very same place
265  virtual void update(const LocalTrajectoryParameters& p, const SurfaceSide side) final;
266 
267  virtual void update(double weight,
269  const LocalTrajectoryError& err,
270  const SurfaceType& aSurface,
271  const MagneticField* field,
272  const SurfaceSide side);
273 
274  // update in place and in the very same place
275  virtual void update(const LocalTrajectoryParameters& p,
276  const LocalTrajectoryError& err,
277  const SurfaceSide side) final;
278 
280 
281 public:
282  using Components = std::vector<TrajectoryStateOnSurface>;
283  virtual Components const& components() const = 0;
284  virtual bool singleState() const = 0;
285 
286 private:
287  static void notValid();
288 
289  void missingError(char const* where) const; // dso_internal;
290 
291  // create global errors from local
292  void checkCurvilinError() const; // dso_internal;
293 
294  // create local parameters and errors from global
295  void createLocalParameters() const;
296  // create local errors from global
297  void createLocalError() const;
299 
300 private:
302 
305 
307  mutable bool theValid;
308 
311 
312  double theWeight = 0.;
313 };
314 
315 #endif
Vector3DBase
Definition: Vector3DBase.h:8
Likely.h
BasicTrajectoryState::magneticField
const MagneticField * magneticField() const
Definition: BasicTrajectoryState.h:222
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:213
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:248
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState(const FreeTrajectoryState &fts)
Definition: BasicTrajectoryState.h:112
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:220
SurfaceSideDefinition::atCenterOfSurface
Definition: SurfaceSideDefinition.h:8
TrajectoryStateExceptions.h
BasicTrajectoryState::theLocalParametersValid
bool theLocalParametersValid
Definition: BasicTrajectoryState.h:306
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:236
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:152
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:246
Point3DBase< float, GlobalTag >
BasicTrajectoryState::localMomentum
LocalVector localMomentum() const
Definition: BasicTrajectoryState.h:233
BasicTrajectoryState::theValid
bool theValid
Definition: BasicTrajectoryState.h:307
SurfaceSideDefinition.h
BasicTrajectoryState::canUpdateLocalParameters
virtual bool canUpdateLocalParameters() const
Definition: BasicTrajectoryState.h:257
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:255
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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:130
BasicTrajectoryState::theLocalError
LocalTrajectoryError theLocalError
Definition: BasicTrajectoryState.h:303
BasicTrajectoryState::localDirection
LocalVector localDirection() const
Definition: BasicTrajectoryState.h:234
BasicTrajectoryState::theWeight
double theWeight
Definition: BasicTrajectoryState.h:312
BasicTrajectoryState::missingError
void missingError(char const *where) const
Definition: BasicTrajectoryState.cc:101
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:173
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:282
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:304
CartesianTrajectoryError
Definition: CartesianTrajectoryError.h:15
ReferenceCounted.h
BasicTrajectoryState::surfaceSide
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
Definition: BasicTrajectoryState.h:253
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:145
BasicTrajectoryState::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: BasicTrajectoryState.h:225
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:279
BasicTrajectoryState::components
virtual Components const & components() const =0
BasicTrajectoryState::theFreeState
FreeTrajectoryState theFreeState
Definition: BasicTrajectoryState.h:301
BasicTrajectoryState::localPosition
LocalPoint localPosition() const
Definition: BasicTrajectoryState.h:232
BasicTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: BasicTrajectoryState.h:204
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:310
BasicTrajectoryState::signedInverseMomentum
double signedInverseMomentum() const
Definition: BasicTrajectoryState.h:194
BasicTrajectoryState::checkCurvilinError
void checkCurvilinError() const
Definition: BasicTrajectoryState.cc:112
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:309
BasicTrajectoryState::globalMomentum
GlobalVector globalMomentum() const
Definition: BasicTrajectoryState.h:191