LOGO

RestFrames  v1.0.0
RestFrames HEP Event Analysis Software Library
RestFrame.hh
Go to the documentation of this file.
1 // RestFrames: particle physics event analysis library
3 // --------------------------------------------------------------------
4 // Copyright (c) 2014-2016, Christopher Rogan
14 // This file is part of RestFrames.
15 //
16 // RestFrames is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // RestFrames is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with RestFrames. If not, see <http://www.gnu.org/licenses/>.
29 
30 #ifndef RestFrame_HH
31 #define RestFrame_HH
32 
33 #include "RestFrames/RFBase.hh"
34 #include "RestFrames/RFCharge.hh"
35 
36 namespace RestFrames {
37 
39  enum FrameType { kVanillaFrame, kVisibleFrame, kInvisibleFrame,
40  kDecayFrame, kLabFrame};
41 
43  enum AnaType { kRecoFrame, kGenFrame };
44 
45  class RestFrame : public RFBase {
46  public:
47 
52  RestFrame(const std::string& sname, const std::string& stitle);
53 
55  RestFrame();
56 
57  virtual ~RestFrame();
58 
64  static void SetAxis(const TVector3& axis);
65 
67  static TVector3 const& GetAxis();
68 
70  virtual void Clear();
71 
80 
82  FrameType GetType() const;
83 
85  bool IsVisibleFrame() const;
86 
88  bool IsInvisibleFrame() const;
89 
91  bool IsDecayFrame() const;
92 
94  bool IsLabFrame() const;
95 
97  bool IsRecoFrame() const;
98 
100  bool IsGenFrame() const;
101 
103  virtual std::string PrintString(LogType type) const;
104 
106 
114 
122  virtual void AddChildFrame(RestFrame& frame);
123 
127  void AddChildFrames(const RestFrameList& frames);
128 
135  virtual void SetParentFrame(RestFrame& frame =
136  RestFrame::Empty());
137 
144  void RemoveChildFrame(RestFrame& frame);
145 
150  void RemoveChildFrames();
151 
159 
161  int GetNChildren() const;
162 
164  int GetNDescendants() const;
165 
171  virtual RestFrame const& GetParentFrame() const;
172 
174  virtual RestFrame& GetChildFrame(int i = 0) const;
175 
177  RestFrameList const& GetChildFrames() const;
178 
184  virtual RestFrame const& GetLabFrame() const;
185 
187  virtual RestFrame const& GetProductionFrame() const;
188 
194  virtual RestFrame const& GetSiblingFrame() const;
195 
203  int GetFrameDepth(const RestFrame& frame) const;
204 
214  virtual RestFrame const& GetFrameAtDepth(int depth, const RestFrame& frame) const;
215 
222  virtual RestFrameList GetListFrames(FrameType type = kLabFrame) const;
223 
225  virtual RestFrameList GetListVisibleFrames() const;
226 
228  virtual RestFrameList GetListInvisibleFrames() const;
229 
231 
242 
248  RestFrameList operator + (RestFrame& frame);
249 
255  RestFrameList operator + (const RestFrameList& frames);
256 
258  virtual RFCharge GetCharge() const;
259 
261  virtual double GetMass() const;
262 
271  TLorentzVector GetFourVector(const RestFrame& frame =
272  RestFrame::Empty()) const;
273 
282  TLorentzVector GetVisibleFourVector(const RestFrame& frame =
283  RestFrame::Empty()) const;
284 
293  TLorentzVector GetInvisibleFourVector(const RestFrame& frame =
294  RestFrame::Empty()) const;
295 
303  double GetEnergy(const RestFrame& frame) const;
304 
312  double GetMomentum(const RestFrame& frame) const;
313 
316  TLorentzVector GetFourVector(const TLorentzVector& P,
317  const RestFrame& def_frame =
318  RestFrame::Empty()) const;
319 
329  double GetTransverseMomentum(const RestFrame& frame =
330  RestFrame::Empty(),
331  const TVector3& axis =
332  RestFrame::GetAxis(),
333  const RestFrame& axis_frame =
334  RestFrame::Empty()) const;
335 
338  double GetTransverseMomentum(const TLorentzVector& P,
339  const TVector3& axis =
340  RestFrame::GetAxis(),
341  const RestFrame& axis_frame =
342  RestFrame::Empty()) const;
343 
357  double GetVisibleShape() const;
358 
371 
372  // double GetVisibleShape(const vector<RFList<RestFrame> >& frames) const;
373 
380  double GetSumVisibleMomentum() const;
381 
388  double GetSumInvisibleMomentum() const;
389 
396  TVector3 GetBoostInParentFrame() const;
397 
399  double GetGammaInParentFrame() const;
400 
401 
423  TVector3 GetDecayPlaneNormalVector(const RestFrame& frame =
424  RestFrame::Empty()) const;
425 
433  double GetDeltaPhiDecayPlanes(const RestFrame& frame) const;
434 
443  double GetCosDecayAngle(const RestFrame& frame =
444  RestFrame::Empty()) const;
445 
446  double GetDeltaPhiDecayAngle(const TVector3& axis =
447  RestFrame::GetAxis(),
448  const RestFrame& frame =
449  RestFrame::Empty()) const;
450  double GetDeltaPhiBoostVisible(const TVector3& axis =
451  RestFrame::GetAxis(),
452  const RestFrame& frame =
453  RestFrame::Empty()) const;
454  double GetDeltaPhiDecayVisible(const TVector3& axis =
455  RestFrame::GetAxis(),
456  const RestFrame& frame =
457  RestFrame::Empty()) const;
458  double GetDeltaPhiVisible(const TVector3& axis =
459  RestFrame::GetAxis(),
460  const RestFrame& frame =
461  RestFrame::Empty()) const;
463 
465  static RestFrame& Empty();
466 
468  static ConstRestFrameList const& EmptyList();
469 
470  protected:
471  FrameType m_Type;
472  AnaType m_Ana;
473 
474  virtual bool IsSoundBody() const;
475 
476  TVector3 const& GetChildBoostVector(RestFrame& frame) const;
477  TVector3 const& GetParentBoostVector() const;
478 
480  virtual bool InitializeTreeRecursive();
481 
483  virtual bool InitializeAnalysisRecursive() = 0;
484 
486  virtual bool AnalyzeEventRecursive() = 0;
487 
489  virtual bool ClearEventRecursive() = 0;
490 
492  bool IsCircularTree(std::vector<RFKey>& keys) const;
493 
494  private:
496  static int m_class_key;
497 
499  static TVector3 m_Axis;
500 
501  // 4-vector of this state in the frame it's initialized
502  TLorentzVector m_P;
503 
504  // the reference frame where this four-vector is initialized
505  const RestFrame* m_ProdFramePtr;
506 
507  // list of child frames and boosts
508  RestFrameList m_ChildFrames;
509  mutable std::map<const RestFrame*, TVector3> m_ChildBoosts;
510 
511  // parent frame and boost
512  RestFrame* m_ParentFramePtr;
513  TVector3 m_ParentBoost;
514 
515  void SetFourVector(const TLorentzVector& V, const RestFrame& frame);
516  void SetChildBoostVector(RestFrame& frame, const TVector3& boost);
517  void SetParentBoostVector(const TVector3& boost);
518 
519  // Recursively get lists of frames
520  void FillListFramesRecursive(RestFrameList& frames,
521  FrameType type = kLabFrame) const;
522 
523  bool FindPathToFrame(const RestFrame& dest_frame,
524  const RestFrame& prev_frame,
525  std::vector<const TVector3*>& boosts) const;
526 
527  static const ConstRestFrameList m_EmptyList;
528 
529  friend class ReconstructionFrame;
530  friend class GeneratorFrame;
531 
532  };
533 
534 }
535 
536 #endif