3#include "BmnGlobalTrack.h"
4#include "FairRootManager.h"
8static Double_t workTime = 0.0;
18 , fGlobalTracks(nullptr)
19 , fGlobalTrackMatches(nullptr)
20 , fInnerTrackBranchName(
"StsTrack")
25 if (fGlobalTrackMatches) {
26 fGlobalTrackMatches->Delete();
27 delete fGlobalTrackMatches;
33 ReadAndCreateDataBranches();
42 if (fGlobalTrackMatches)
43 fGlobalTrackMatches->Delete();
47 workTime += sw.RealTime();
52 printf(
"Work time of BmnMatchRecoToMC: %4.2f sec.\n", workTime);
55void BmnMatchRecoToMC::ReadAndCreateDataBranches()
57 FairRootManager* ioman = FairRootManager::Instance();
59 LOG(fatal) <<
"BmnMatchRecoToMC::ReadAndCreateDataBranches() nullptr FairRootManager.";
61 fGlobalTracks = (TClonesArray*)ioman->GetObject(
"BmnGlobalTrack");
64 fGemPoints = (TClonesArray*)ioman->GetObject(
"StsPoint");
65 fGemTracks = (TClonesArray*)ioman->GetObject(
"BmnGemTrack");
68 fSilPoints = (TClonesArray*)ioman->GetObject(
"SiliconPoint");
69 fSilTracks = (TClonesArray*)ioman->GetObject(
"BmnSiliconTrack");
72 fStsHits = (TClonesArray*)ioman->GetObject(
"StsHit");
73 fStsTracks = (TClonesArray*)ioman->GetObject(fInnerTrackBranchName);
75 fGlobalTrackMatches =
new TClonesArray(
"BmnTrackMatch", 100);
76 ioman->Register(
"BmnGlobalTrackMatch",
"GLOBAL", fGlobalTrackMatches, kTRUE);
79void BmnMatchRecoToMC::MatchGlobalTracks(
const TClonesArray* gemHitMatches,
80 const TClonesArray* silHitMatches,
81 const TClonesArray* ssdHitMatches,
82 const TClonesArray* gemPoints,
83 const TClonesArray* silPoints,
84 const TClonesArray* ssdPoints,
85 const TClonesArray* gemTracks,
86 const TClonesArray* silTracks,
87 const TClonesArray* ssdTracks,
88 const TClonesArray* globTracks,
89 TClonesArray* trackMatches)
92 for (Int_t iTrack = 0; iTrack < globTracks->GetEntriesFast(); ++iTrack) {
95 Int_t trueCounter = 0;
96 Int_t wrongCounter = 0;
100 for (Int_t iHit = 0; iHit < gemTr->
GetNHits(); ++iHit)
101 LinkToMC(gemHitMatches, gemPoints, gemTr->
GetHitIndex(iHit), trackMatch);
104 CalculateTrackQuality(gemTr, trackMatch, gemHitMatches, gemPoints, trueCounter, wrongCounter);
109 for (Int_t iHit = 0; iHit < silTr->
GetNHits(); ++iHit)
110 LinkToMC(silHitMatches, silPoints, silTr->
GetHitIndex(iHit), trackMatch);
113 CalculateTrackQuality(silTr, trackMatch, silHitMatches, silPoints, trueCounter, wrongCounter);
118 for (Int_t iHit = 0; iHit < ssdTr->
GetNHits(); ++iHit)
119 LinkToMC(ssdHitMatches, ssdPoints, ssdTr->
GetHitIndex(iHit), trackMatch);
122 CalculateTrackQuality(ssdTr, trackMatch, ssdHitMatches, ssdPoints, trueCounter, wrongCounter);
130void BmnMatchRecoToMC::CalculateTrackQuality(
BmnGemTrack* locTr,
132 const TClonesArray* hitMatches,
133 const TClonesArray* points,
138 for (Int_t iHit = 0; iHit < locTr->
GetNHits(); iHit++) {
141 Bool_t hasTrue = kFALSE;
142 for (Int_t iLink = 0; iLink < nofLinks; iLink++) {
143 const FairMCPoint* point = (
const FairMCPoint*)(points->At(hitMatch->
GetLink(iLink).
GetIndex()));
158BmnStatus BmnMatchRecoToMC::LinkToMC(
const TClonesArray* hitMatchArr,
159 const TClonesArray* points,
167 if (hitMatch ==
nullptr)
169 for (Int_t iLink = 0; iLink < hitMatch->
GetNofLinks(); ++iLink) {
170 const FairMCPoint* point = (
const FairMCPoint*)(points->At(hitMatch->
GetLink(iLink).
GetIndex()));
171 if (
nullptr == point)
187 FairMCPoint* point =
nullptr;
188 for (Int_t iLink = 0; iLink < hit->GetNLinks(); ++iLink) {
190 point = (FairMCPoint*)(fGemPoints->At(hit->GetLink(iLink).GetIndex()));
192 point = (FairMCPoint*)(fSilPoints->At(hit->GetLink(iLink).GetIndex()));
202void BmnMatchRecoToMC::MatchGlobalTracks()
206 for (Int_t iTrack = 0; iTrack < fGlobalTracks->GetEntriesFast(); ++iTrack) {
217 for (Int_t iHit = 0; iHit < stsTr->
GetNStsHits(); ++iHit)
221 CalculateTrackQuality(stsTr, trackMatch);
232 Int_t trueCounter = 0;
233 Int_t wrongCounter = 0;
234 for (Int_t iHit = 0; iHit < locTr->
GetNStsHits(); iHit++) {
236 Bool_t hasTrue = kFALSE;
237 for (Int_t iLink = 0; iLink < hit->GetNLinks(); iLink++) {
238 FairMCPoint* point =
nullptr;
240 point = (FairMCPoint*)(fGemPoints->At(hit->GetLink(iLink).GetIndex()));
242 point = (FairMCPoint*)(fSilPoints->At(hit->GetLink(iLink).GetIndex()));
Int_t GetSsdTrackIndex() const
Int_t GetGemTrackIndex() const
Int_t GetSilTrackIndex() const
void SetRefIndex(Int_t idx)
virtual void Exec(Option_t *opt)
virtual ~BmnMatchRecoToMC()
virtual InitStatus Init()
const BmnLink & GetLink(Int_t i) const
void AddLink(const BmnMatch &match)
const BmnLink & GetMatchedLink() const
Int_t GetNofLinks() const
void SetNofTrueHits(Int_t nofTrueHits)
void SetNofWrongHits(Int_t nofWrongHits)
Double_t GetTrueOverAllHitsRatio() const
Int_t GetHitIndex(Int_t iHit) const
Int_t GetSystemId() const
Int_t GetNStsHits() const
Int_t GetStsHitIndex(Int_t iHit) const