12#include "FairMCPoint.h"
13#include "FairRootManager.h"
14#include "TClonesArray.h"
21 : FairTask(
"CbmMuchMatchTracks")
26 , fPixelDigiMatches(NULL)
40 FairRootManager* ioman = FairRootManager::Instance();
41 if (ioman == NULL) LOG(fatal) << GetName() <<
"::Init: RootManager not instantised!";
43 fPixelHits = (TClonesArray*) ioman->GetObject(
"MuchPixelHit");
44 if (
fPixelHits == NULL) LOG(fatal) << GetName() <<
"::Init: No MuchPixelHit array!";
46 fTracks = (TClonesArray*) ioman->GetObject(
"MuchTrack");
47 if (
fTracks == NULL) LOG(fatal) << GetName() <<
"::Init: No MuchTrack array!";
49 fPoints = (TClonesArray*) ioman->GetObject(
"MuchPoint");
50 if (
fPoints == NULL) LOG(fatal) << GetName() <<
"::Init: No MuchPoint array!";
53 if (
fPixelDigiMatches == NULL) LOG(fatal) << GetName() <<
"::Init: No MuchDigiMatch array!";
55 fClusters = (TClonesArray*) ioman->GetObject(
"MuchCluster");
57 Info(
"CbmMuchMatchTracks::Init",
"No cluster array -- simple hit to digi matching will be used");
59 fMatches =
new TClonesArray(
"CbmTrackMatch", 100);
60 ioman->Register(
"MuchTrackMatch",
"MUCH",
fMatches, IsOutputBranchPersistent(
"MuchTrackMatch"));
70 Int_t nofTracks =
fTracks->GetEntriesFast();
71 for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) {
73 std::map<Int_t, Int_t> matchMap;
76 if (pTrack == NULL)
continue;
79 for (Int_t iHit = 0; iHit < nofHits; iHit++) {
85 LOG(fatal) << GetName() <<
": Hit type not supported!";
90 Int_t bestMcTrackId = -1;
92 for (std::map<Int_t, Int_t>::iterator it = matchMap.begin(); it != matchMap.end(); it++) {
93 if (it->first != -1 && it->second >= nofTrue) {
94 bestMcTrackId = it->first;
97 nPoints += it->second;
101 Int_t nofWrong = nofHits - nofTrue - nofFake;
102 Int_t nofMcTracks = matchMap.size() - 1;
104 new ((*fMatches)[iTrack])
CbmTrackMatch(bestMcTrackId, nofTrue, nofWrong, nofFake, nofMcTracks);
112 std::cout <<
"iTrack=" << iTrack <<
" mcTrack=" << bestMcTrackId <<
" nPoints=" << nPoints
113 <<
" nofTrue=" << nofTrue <<
" nofWrong=" << nofWrong <<
" nofFake=" << nofFake
114 <<
" nofMcTracks=" << nofMcTracks << std::endl;
125 std::cout <<
"=================================================" << std::endl;
126 std::cout <<
"===== " << GetName() <<
": Run summary " << std::endl;
127 std::cout <<
"True hits: " << trueHits <<
"%" << std::endl;
128 std::cout <<
"Wrong hits: " << wrongHits <<
"%" << std::endl;
129 std::cout <<
"Fake hits: " << fakeHits <<
"%" << std::endl;
130 std::cout <<
"=================================================" << std::endl;
136 std::set<Int_t> mcIdHit;
138 if (hit == NULL)
return;
142 if (cluster == NULL)
return;
144 for (Int_t iDigi = 0; iDigi < cluster->
GetNofDigis(); iDigi++) {
145 Int_t digiId = cluster->
GetDigi(iDigi);
147 if (digiMatch == NULL)
continue;
148 for (Int_t iPoint = 0; iPoint < digiMatch->
GetNofLinks(); iPoint++) {
150 if (pointIndex < 0) {
154 FairMCPoint* point =
static_cast<FairMCPoint*
>(
fPoints->At(pointIndex));
155 if (point == NULL)
continue;
156 mcIdHit.insert(point->GetTrackID());
160 for (std::set<Int_t>::iterator it = mcIdHit.begin(); it != mcIdHit.end(); it++) {
Data container for MUCH clusters.
ClassImp(CbmMuchMatchTracks)
Class for pixel hits in MUCH detector.
int32_t GetDigi(int32_t index) const
Get digi at position index.
int32_t GetNofDigis() const
Number of digis in cluster.
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
Data container for MUCH clusters.
virtual ~CbmMuchMatchTracks()
virtual InitStatus Init()
TClonesArray * fPixelDigiMatches
TClonesArray * fPixelHits
virtual void Exec(Option_t *opt)
void ExecPixel(std::map< Int_t, Int_t > &matchMap, Int_t index)
virtual int32_t GetNofHits() const
int32_t GetHitIndex(int32_t iHit) const
HitType GetHitType(int32_t iHit) const