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