CbmRoot
alignment/CbmRichUtil.h
Go to the documentation of this file.
1 
2 #ifndef RICH_CbmRichUtil
3 #define RICH_CbmRichUtil
4 
5 #include "CbmGlobalTrack.h"
6 #include "FairLogger.h"
7 #include "FairRootManager.h"
8 #include "FairTrackParam.h"
9 #include "TCanvas.h"
10 #include "TClonesArray.h"
11 #include "TH2.h"
12 #include "TObject.h"
13 #include <string>
14 
15 using namespace std;
16 
17 class CbmRichUtil {
18 
19 public:
20  static Double_t GetRingTrackDistance(Int_t globalTrackId) {
21  vector<Double_t> v = GetRingTrackDistanceImpl(globalTrackId);
22  return v[0];
23  }
24 
25  static Double_t GetRingTrackDistanceX(Int_t globalTrackId) {
26  vector<Double_t> v = GetRingTrackDistanceImpl(globalTrackId);
27  return v[1];
28  }
29 
30  static Double_t GetRingTrackDistanceY(Int_t globalTrackId) {
31  vector<Double_t> v = GetRingTrackDistanceImpl(globalTrackId);
32  return v[2];
33  }
34 
35 private:
39  static vector<Double_t> GetRingTrackDistanceImpl(Int_t globalTrackId) {
40  vector<Double_t> errorVec = {999., 999., 999.};
41  FairRootManager* ioman = FairRootManager::Instance();
42  if (ioman == NULL) return errorVec;
43  // Do we really need static here, depends on ioman->GetObject() method
44  static TClonesArray* globalTracks = NULL;
45  static TClonesArray* richRings = NULL;
46  static TClonesArray* richProjections = NULL;
47 
48  if (globalTracks == NULL || richRings == NULL || richProjections == NULL) {
49  //cout << "globalTracks == NULL || richRings == NULL || richProjections == NULL" << endl;
50  globalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
51  richRings = (TClonesArray*) ioman->GetObject("RichRing");
52  richProjections = (TClonesArray*) ioman->GetObject("RichProjection");
53  } else {
54  //cout << "globalTracks, richRings, richProjections NOT NULL" << endl;
55  }
56 
57  if (globalTracks == NULL || richRings == NULL || richProjections == NULL) {
58  LOG(error) << "CbmRichUtil::GetRingTrackDistance globalTracks, "
59  "richRings, richProjections NOT INITIALIZED"
60  << endl;
61  return errorVec;
62  }
63 
64  const CbmGlobalTrack* globalTrack =
65  static_cast<const CbmGlobalTrack*>(globalTracks->At(globalTrackId));
66  if (globalTrack == NULL) return errorVec;
67 
68  Int_t stsId = globalTrack->GetStsTrackIndex();
69  if (stsId < 0) return errorVec;
70 
71  const FairTrackParam* pTrack =
72  static_cast<const FairTrackParam*>(richProjections->At(stsId));
73  if (pTrack == NULL) return errorVec;
74 
75  if (pTrack->GetX() == 0 && pTrack->GetY() == 0) return errorVec;
76 
77  Int_t richId = globalTrack->GetRichRingIndex();
78  if (richId < 0) return errorVec;
79 
80  const CbmRichRing* richRing =
81  static_cast<const CbmRichRing*>(richRings->At(richId));
82  if (richRing == NULL) return errorVec;
83 
84  Double_t xRing = richRing->GetCenterX();
85  Double_t yRing = richRing->GetCenterY();
86  Double_t dx = richRing->GetCenterX() - pTrack->GetX();
87  Double_t dy = richRing->GetCenterY() - pTrack->GetY();
88 
89  Double_t dist = TMath::Sqrt(dx * dx + dy * dy);
90 
91  vector<Double_t> v = {dist, dx, dy};
92  }
93 };
94 
95 #endif
CbmRichUtil::GetRingTrackDistanceImpl
static vector< Double_t > GetRingTrackDistanceImpl(Int_t globalTrackId)
Return a vector with total distance and x, y components. [0] - total distance, [1] - x component,...
Definition: alignment/CbmRichUtil.h:39
CbmRichUtil
Definition: alignment/CbmRichUtil.h:17
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
CbmGlobalTrack.h
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichUtil::GetRingTrackDistance
static Double_t GetRingTrackDistance(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:20
CbmGlobalTrack::GetStsTrackIndex
Int_t GetStsTrackIndex() const
Definition: CbmGlobalTrack.h:38
CbmRichUtil::GetRingTrackDistanceX
static Double_t GetRingTrackDistanceX(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:25
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
CbmRichRing::GetCenterY
Float_t GetCenterY() const
Definition: CbmRichRing.h:81
CbmRichUtil::GetRingTrackDistanceY
static Double_t GetRingTrackDistanceY(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:30
CbmRichRing::GetCenterX
Float_t GetCenterX() const
Definition: CbmRichRing.h:80