EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingTrackAssignIdeal.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingTrackAssignIdeal.cxx
1 
9 
10 #include "TClonesArray.h"
11 
12 #include "CbmRichRing.h"
13 
14 #include "CbmMCTrack.h"
15 #include "FairRootManager.h"
16 #include "FairTrackParam.h"
17 #include "CbmGlobalTrack.h"
18 #include "CbmTrackMatch.h"
19 #include "CbmTrackMatch.h"
20 
21 #include <iostream>
22 
23 using std::cout;
24 using std::endl;
25 
27  fMcTracks(NULL),
28  fGlobalTracks(NULL),
29  fRingMatches(NULL),
30  fStsTrackMatches(NULL)
31 {
32 
33 }
34 
36 {
37 }
38 
40 {
42  if (NULL == ioman) { Fatal("CbmRichRingTrackAssignIdeal::Init", "RootManager not instantised!");}
43 
44  fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
45  if ( NULL == fMcTracks) {Fatal("CbmRichRingTrackAssignIdeal::Init", "No MCTrack array!");}
46 
47  fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
48  if ( NULL == fGlobalTracks) {Fatal("CbmRichRingTrackAssignIdeal::Init", "No GlobalTrack array!");}
49 
50  fRingMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
51  if ( NULL == fRingMatches) {Fatal("CbmRichRingTrackAssignIdeal::Init", "No RichRingMatch array!");}
52 
53  fStsTrackMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
54  if ( NULL == fStsTrackMatches) {Fatal("CbmRichRingTrackAssignIdeal::Init", "No StsTrackMatch array!");}
55 }
56 
58  TClonesArray *rings,
59  TClonesArray* richProj)
60 {
61  Int_t nofTracks = richProj->GetEntriesFast();
62  Int_t nofRings = rings->GetEntriesFast();
63 
64  for (Int_t iRing=0; iRing < nofRings; iRing++){
65  CbmRichRing* pRing = (CbmRichRing*) rings->At(iRing);
66  if (NULL == pRing) continue;
67  if (pRing->GetNofHits() < fMinNofHitsInRing) continue;
68 
69  CbmTrackMatch* pRingMatch = (CbmTrackMatch*) fRingMatches->At(iRing);
70  if (NULL == pRingMatch) continue;
71  Int_t ringID = pRingMatch->GetMCTrackId();
72  Double_t xRing = pRing->GetCenterX();
73  Double_t yRing = pRing->GetCenterY();
74 
75  for (Int_t iTrack=0; iTrack < nofTracks; iTrack++){
76  FairTrackParam* pTrack = (FairTrackParam*) richProj->At(iTrack);
77  if (NULL == pTrack) continue;
78  Double_t xTrack = pTrack->GetX();
79  Double_t yTrack = pTrack->GetY();
80 
81  // no projection to photodetector plane
82  if (xTrack == 0 && yTrack == 0) continue;
83 
84  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(iTrack);
85  if (NULL == gTrack) continue;
86  if (gTrack->GetStsTrackIndex() == -1) continue;
87  CbmTrackMatch* pTrackMatch = (CbmTrackMatch*) fStsTrackMatches->At(gTrack->GetStsTrackIndex());
88  if (NULL == pTrackMatch) continue;
89 
90  if (pTrackMatch->GetMCTrackId() == ringID){
91  gTrack -> SetRichRingIndex(iRing);
92  pRing -> SetTrackID(iTrack);
93  Double_t dist = TMath::Sqrt( (xRing-xTrack)*(xRing-xTrack)+(yRing-yTrack)*(yRing-yTrack) );
94  pRing->SetDistance(dist);
95  } // ideal assignement
96  } // loop tracks
97  } // loop rings
98 }