CbmRoot
CbmMuchTrackFinderIdeal.cxx
Go to the documentation of this file.
1 
6 
7 #include "CbmMuchCluster.h"
8 #include "CbmMuchDigiMatch.h"
9 #include "CbmMuchPixelHit.h"
10 #include "CbmMuchTrack.h"
11 
12 #include "CbmMCTrack.h"
13 #include "FairMCPoint.h"
14 #include "FairRootManager.h"
15 #include "FairTrackParam.h"
16 
17 #include "TClonesArray.h"
18 
19 #include <cmath>
20 #include <iostream>
21 #include <map>
22 
25  , fMCTracks(NULL)
26  , fMCPoints(NULL)
27  , fPixelHits(NULL)
28  , fTracks(NULL)
29  , fPixelDigiMatches(NULL)
30  , fClusters(NULL)
31  , fTrackMap()
32  , fVerbose(1)
33  , fEvents(0) {}
34 
36 
38  FairRootManager* ioman = FairRootManager::Instance();
39  if (ioman == NULL)
40  Fatal("CbmMuchTrackFinderIdeal::Init", "No FairRootManager!");
41 
42  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
43  if (fMCTracks == NULL)
44  Fatal("CbmMuchTrackFinderIdeal::Init", "No MCTrack array!");
45 
46  fMCPoints = (TClonesArray*) ioman->GetObject("MuchPoint");
47  if (fMCPoints == NULL)
48  Fatal("CbmMuchTrackFinderIdeal::Init", "No MuchPoint array!");
49 
50  fPixelHits = (TClonesArray*) ioman->GetObject("MuchPixelHit");
51  if (fPixelHits == NULL)
52  Fatal("CbmMuchTrackFinderIdeal::Init", "No MuchPixelHit array!");
53 
54  fPixelDigiMatches = (TClonesArray*) ioman->GetObject("MuchDigiMatch");
55  if (fPixelDigiMatches == NULL)
56  Fatal("CbmMuchTrackFinderIdeal::Init", "No MuchDigiMatch array!");
57 
58  fClusters = (TClonesArray*) ioman->GetObject("MuchCluster");
59  if (fClusters == NULL)
60  Info("CbmMuchTrackFinderIdeal::Init",
61  "No cluster array -- simple hit to digi matching will be used");
62 }
63 
64 Int_t CbmMuchTrackFinderIdeal::DoFind(TClonesArray* trackArray) {
65  fTracks = trackArray;
66 
67  fTrackMap.clear();
68  Int_t nofTracks = 0;
69  Int_t nofMCTracks = fMCTracks->GetEntriesFast();
70  for (Int_t iMCTrack = 0; iMCTrack < nofMCTracks; iMCTrack++) {
71  CbmMCTrack* mcTrack = (CbmMCTrack*) fMCTracks->At(iMCTrack);
72  if (mcTrack == NULL) continue;
73  if (std::abs(mcTrack->GetPdgCode()) != 13) continue;
74  if (mcTrack->GetMotherId() != -1) continue;
75 
76  new ((*fTracks)[nofTracks]) CbmMuchTrack();
77  fTrackMap[iMCTrack] = nofTracks;
78  nofTracks++;
79  }
80 
81  // Process MUCH pixel hits
82  for (Int_t iHit = 0; iHit < fPixelHits->GetEntriesFast(); iHit++) {
83  CbmMuchPixelHit* hit = (CbmMuchPixelHit*) fPixelHits->At(iHit);
84  if (!hit) continue;
85  Int_t clusterId = hit->GetRefId();
86  CbmMuchCluster* cluster = (CbmMuchCluster*) fClusters->At(clusterId);
87  for (Int_t iDigi = 0; iDigi < cluster->GetNofDigis(); iDigi++) {
89  fPixelDigiMatches, cluster->GetDigi(iDigi), iHit, kMUCHPIXELHIT);
90  } // loop over digis in cluster
91  } // loop over hits
92 
93  std::cout << "Event: " << fEvents++ << std::endl;
94  return nofTracks;
95 }
96 
98  const TClonesArray* digiMatches,
99  Int_t digiIndex,
100  Int_t hitIndex,
101  HitType hitType) {
102  CbmMuchDigiMatch* digiMatch = (CbmMuchDigiMatch*) digiMatches->At(digiIndex);
103  if (!digiMatch) return;
104 
105  for (Int_t iDigi = 0; iDigi < digiMatch->GetNofLinks(); iDigi++) {
106  Int_t pointIndex = digiMatch->GetLink(iDigi).GetIndex();
107  if (pointIndex < 0) return;
108  FairMCPoint* mcPoint = (FairMCPoint*) (fMCPoints->At(pointIndex));
109  if (mcPoint == NULL) return;
110  Int_t mcTrackIndex = mcPoint->GetTrackID();
111  if (mcTrackIndex < 0) return;
112  CbmMCTrack* mcTrack = (CbmMCTrack*) fMCTracks->At(mcTrackIndex);
113  if (mcTrack == NULL) return;
114 
115  if (fTrackMap.find(mcTrackIndex) == fTrackMap.end()) continue;
116 
117  Int_t trackIndex = fTrackMap[mcTrackIndex];
118  CbmMuchTrack* track = (CbmMuchTrack*) fTracks->At(trackIndex);
119  track->AddHit(hitIndex, hitType);
120 
121  if (track->GetNofHits() == 1) { SetTrackParam(mcTrack, mcPoint, track); }
122  } // loop over digis
123 }
124 
126  const FairMCPoint* mcPoint,
127  CbmMuchTrack* track) {
128  FairTrackParam par;
129  par.SetX(mcPoint->GetX());
130  par.SetY(mcPoint->GetY());
131  par.SetTx(mcPoint->GetPx() / mcPoint->GetPz());
132  par.SetTy(mcPoint->GetPy() / mcPoint->GetPz());
133  if (mcTrack->GetPdgCode() == 13)
134  par.SetQp(-1. / mcTrack->GetP());
135  else if (mcTrack->GetPdgCode() == -13)
136  par.SetQp(1. / mcTrack->GetP());
137  par.SetZ(mcPoint->GetZ());
138 
139  Double_t cov[15];
140  cov[0] = 1e-9;
141  cov[1] = 1e-9;
142  cov[2] = 1e-9;
143  cov[3] = 1e-9;
144  cov[4] = 1e-9;
145  cov[5] = 1e-9;
146  cov[6] = 1e-9;
147  cov[7] = 1e-9;
148  cov[8] = 1e-9;
149  cov[9] = 1e-9;
150  cov[10] = 1e-9;
151  cov[11] = 1e-9;
152  cov[12] = 1e-9;
153  cov[13] = 1e-9;
154  cov[14] = 1e-9;
155  par.SetCovMatrix(cov);
156  track->SetParamLast(&par);
157  track->SetParamFirst(&par);
158 }
159 
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMuchTrackFinderIdeal::fPixelHits
TClonesArray * fPixelHits
Definition: CbmMuchTrackFinderIdeal.h:44
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmTrack.h:53
CbmMuchTrackFinderIdeal
Definition: CbmMuchTrackFinderIdeal.h:23
CbmMuchCluster
Data container for MUCH clusters.
Definition: CbmMuchCluster.h:20
ClassImp
ClassImp(CbmMuchTrackFinderIdeal)
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
CbmMuchTrackFinderIdeal::fMCPoints
TClonesArray * fMCPoints
Definition: CbmMuchTrackFinderIdeal.h:43
CbmMuchTrackFinderIdeal::fTracks
TClonesArray * fTracks
Definition: CbmMuchTrackFinderIdeal.h:45
CbmMuchTrackFinderIdeal::Init
virtual void Init()
Definition: CbmMuchTrackFinderIdeal.cxx:37
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
CbmMuchTrack
Definition: CbmMuchTrack.h:16
CbmMuchDigiMatch
Definition: CbmMuchDigiMatch.h:17
CbmCluster::GetNofDigis
Int_t GetNofDigis() const
Number of digis in cluster.
Definition: CbmCluster.h:69
CbmMuchTrackFinderIdeal::fMCTracks
TClonesArray * fMCTracks
Definition: CbmMuchTrackFinderIdeal.h:42
CbmMuchCluster.h
Data container for MUCH clusters.
CbmMuchTrackFinderIdeal::CbmMuchTrackFinderIdeal
CbmMuchTrackFinderIdeal()
Definition: CbmMuchTrackFinderIdeal.cxx:23
CbmMuchTrackFinder
Definition: CbmMuchTrackFinder.h:15
CbmMuchTrackFinderIdeal::fClusters
TClonesArray * fClusters
Definition: CbmMuchTrackFinderIdeal.h:47
CbmMuchTrack.h
HitType
HitType
Definition: CbmHit.h:16
CbmMuchTrackFinderIdeal::fTrackMap
std::map< Int_t, Int_t > fTrackMap
Definition: CbmMuchTrackFinderIdeal.h:50
CbmMuchTrackFinderIdeal::~CbmMuchTrackFinderIdeal
virtual ~CbmMuchTrackFinderIdeal()
Definition: CbmMuchTrackFinderIdeal.cxx:35
CbmMuchTrackFinderIdeal::fEvents
Int_t fEvents
Definition: CbmMuchTrackFinderIdeal.h:53
CbmMuchTrackFinderIdeal::fPixelDigiMatches
TClonesArray * fPixelDigiMatches
Definition: CbmMuchTrackFinderIdeal.h:46
CbmMCTrack.h
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
CbmMuchTrackFinderIdeal.h
kMUCHPIXELHIT
@ kMUCHPIXELHIT
Definition: CbmHit.h:23
CbmMuchDigiMatch.h
CbmMuchPixelHit
Definition: CbmMuchPixelHit.h:17
CbmMuchTrackFinderIdeal::DoFind
Int_t DoFind(TClonesArray *trackArray)
Definition: CbmMuchTrackFinderIdeal.cxx:64
CbmCluster::GetDigi
Int_t GetDigi(Int_t index) const
Get digi at position index.
Definition: CbmCluster.h:76
CbmTrack::AddHit
void AddHit(Int_t index, HitType type)
Definition: CbmTrack.cxx:75
CbmMCTrack::GetP
Double_t GetP() const
Definition: CbmMCTrack.h:100
CbmMuchTrackFinderIdeal::SetTrackParam
void SetTrackParam(const CbmMCTrack *mcTrack, const FairMCPoint *mcPoint, CbmMuchTrack *track)
Definition: CbmMuchTrackFinderIdeal.cxx:125
CbmMuchTrackFinderIdeal::ProcessDigiMatches
void ProcessDigiMatches(const TClonesArray *digiMatches, Int_t digiIndex, Int_t hitIndex, HitType hitType)
Definition: CbmMuchTrackFinderIdeal.cxx:97