CbmRoot
utils/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  static uint16_t GetDirichId(Int_t Address) {
36  return ((Address >> 16) & 0xFFFF);
37  }
38 
39  static uint16_t GetDirichChannel(Int_t Address) { return (Address & 0xFFFF); }
40 
41 private:
45  static vector<Double_t> GetRingTrackDistanceImpl(Int_t globalTrackId) {
46  vector<Double_t> errorVec = {999., 999., 999.};
47  FairRootManager* ioman = FairRootManager::Instance();
48  if (ioman == NULL) return errorVec;
49  // Do we really need static here, depends on ioman->GetObject() method
50  static TClonesArray* globalTracks = NULL;
51  static TClonesArray* richRings = NULL;
52  static TClonesArray* richProjections = NULL;
53 
54  if (globalTracks == NULL || richRings == NULL || richProjections == NULL) {
55  //cout << "globalTracks == NULL || richRings == NULL || richProjections == NULL" << endl;
56  globalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
57  richRings = (TClonesArray*) ioman->GetObject("RichRing");
58  richProjections = (TClonesArray*) ioman->GetObject("RichProjection");
59  } else {
60  //cout << "globalTracks, richRings, richProjections NOT NULL" << endl;
61  }
62 
63  if (globalTracks == NULL || richRings == NULL || richProjections == NULL) {
64  LOG(error) << "CbmRichUtil::GetRingTrackDistance globalTracks, "
65  "richRings, richProjections NOT INITIALIZED"
66  << endl;
67  return errorVec;
68  }
69 
70  const CbmGlobalTrack* globalTrack =
71  static_cast<const CbmGlobalTrack*>(globalTracks->At(globalTrackId));
72  if (globalTrack == NULL) return errorVec;
73 
74  Int_t stsId = globalTrack->GetStsTrackIndex();
75  if (stsId < 0) return errorVec;
76 
77  const FairTrackParam* pTrack =
78  static_cast<const FairTrackParam*>(richProjections->At(stsId));
79  if (pTrack == NULL) return errorVec;
80 
81  if (pTrack->GetX() == 0 && pTrack->GetY() == 0) return errorVec;
82 
83  Int_t richId = globalTrack->GetRichRingIndex();
84  if (richId < 0) return errorVec;
85 
86  const CbmRichRing* richRing =
87  static_cast<const CbmRichRing*>(richRings->At(richId));
88  if (richRing == NULL) return errorVec;
89 
90  // Double_t xRing = richRing->GetCenterX();
91  // Double_t yRing = richRing->GetCenterY();
92  Double_t dx = richRing->GetCenterX() - pTrack->GetX();
93  Double_t dy = richRing->GetCenterY() - pTrack->GetY();
94 
95  Double_t dist = TMath::Sqrt(dx * dx + dy * dy);
96 
97  vector<Double_t> v = {dist, dx, dy};
98  return v;
99  }
100 };
101 
102 #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: utils/CbmRichUtil.h:45
CbmRichUtil
Definition: alignment/CbmRichUtil.h:17
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
CbmRichUtil::GetDirichId
static uint16_t GetDirichId(Int_t Address)
Definition: utils/CbmRichUtil.h:35
CbmGlobalTrack.h
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichUtil::GetRingTrackDistance
static Double_t GetRingTrackDistance(Int_t globalTrackId)
Definition: utils/CbmRichUtil.h:20
CbmGlobalTrack::GetStsTrackIndex
Int_t GetStsTrackIndex() const
Definition: CbmGlobalTrack.h:38
CbmRichUtil::GetDirichChannel
static uint16_t GetDirichChannel(Int_t Address)
Definition: utils/CbmRichUtil.h:39
CbmRichUtil::GetRingTrackDistanceX
static Double_t GetRingTrackDistanceX(Int_t globalTrackId)
Definition: utils/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: utils/CbmRichUtil.h:30
CbmRichRing::GetCenterX
Float_t GetCenterX() const
Definition: CbmRichRing.h:80