9 #include "FairMCPoint.h"
10 #include "FairRootManager.h"
12 #include "TClonesArray.h"
19 : FairTask(
"CbmMuchMatchTracks")
24 , fPixelDigiMatches(NULL)
35 FairRootManager* ioman = FairRootManager::Instance();
37 Fatal(
"CbmMuchMatchTracks::Init",
"RootManager not instantised!");
39 fPixelHits = (TClonesArray*) ioman->GetObject(
"MuchPixelHit");
41 Fatal(
"CbmMuchMatchTracks::Init",
"No MuchPixelHit array!");
43 fTracks = (TClonesArray*) ioman->GetObject(
"MuchTrack");
44 if (
fTracks == NULL) Fatal(
"CbmMuchMatchTracks::Init",
"No MuchTrack array!");
46 fPoints = (TClonesArray*) ioman->GetObject(
"MuchPoint");
47 if (
fPoints == NULL) Fatal(
"CbmMuchMatchTracks::Init",
"No MuchPoint array!");
51 Fatal(
"CbmMuchMatchTracks::Init",
"No MuchDigiMatch array!");
53 fClusters = (TClonesArray*) ioman->GetObject(
"MuchCluster");
55 Info(
"CbmMuchMatchTracks::Init",
56 "No cluster array -- simple hit to digi matching will be used");
58 fMatches =
new TClonesArray(
"CbmTrackMatch", 100);
59 ioman->Register(
"MuchTrackMatch",
62 IsOutputBranchPersistent(
"MuchTrackMatch"));
71 Int_t nofTracks =
fTracks->GetEntriesFast();
72 for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
74 std::map<Int_t, Int_t> matchMap;
77 if (pTrack == NULL)
continue;
80 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
85 TObject::Fatal(
"CbmMuchMatchTracks::Exec",
"Hit type not supported!");
90 Int_t bestMcTrackId = -1;
92 for (std::map<Int_t, Int_t>::iterator it = matchMap.begin();
95 if (it->first != -1 && it->second >= nofTrue) {
96 bestMcTrackId = it->first;
99 nPoints += it->second;
103 Int_t nofWrong = nofHits - nofTrue - nofFake;
104 Int_t nofMcTracks = matchMap.size() - 1;
106 new ((*fMatches)[iTrack])
107 CbmTrackMatch(bestMcTrackId, nofTrue, nofWrong, nofFake, nofMcTracks);
115 std::cout <<
"iTrack=" << iTrack <<
" mcTrack=" << bestMcTrackId
116 <<
" nPoints=" << nPoints <<
" nofTrue=" << nofTrue
117 <<
" nofWrong=" << nofWrong <<
" nofFake=" << nofFake
118 <<
" nofMcTracks=" << nofMcTracks << std::endl;
128 std::cout <<
"=================================================" << std::endl;
129 std::cout <<
"===== " << GetName() <<
": Run summary " << std::endl;
130 std::cout <<
"True hits: " << trueHits <<
"%" << std::endl;
131 std::cout <<
"Wrong hits: " << wrongHits <<
"%" << std::endl;
132 std::cout <<
"Fake hits: " << fakeHits <<
"%" << std::endl;
133 std::cout <<
"=================================================" << std::endl;
139 std::set<Int_t> mcIdHit;
141 if (hit == NULL)
return;
146 if (cluster == NULL)
return;
148 for (Int_t iDigi = 0; iDigi < cluster->
GetNofDigis(); iDigi++) {
149 Int_t digiId = cluster->
GetDigi(iDigi);
152 if (digiMatch == NULL)
continue;
153 for (Int_t iPoint = 0; iPoint < digiMatch->
GetNofLinks(); iPoint++) {
155 if (pointIndex < 0) {
159 FairMCPoint* point =
static_cast<FairMCPoint*
>(
fPoints->At(pointIndex));
160 if (point == NULL)
continue;
161 mcIdHit.insert(point->GetTrackID());
165 for (std::set<Int_t>::iterator it = mcIdHit.begin(); it != mcIdHit.end();