12 #include "FairLogger.h"
13 #include "FairRootManager.h"
14 #include "TClonesArray.h"
15 #include "TStopwatch.h"
32 : FairTask(
"CbmBuildEventsFromTracksIdeal")
39 , fStsTrackMatchArray(nullptr)
40 , fEventList(nullptr) {}
55 FairRootManager* ioman = FairRootManager::Instance();
64 if (mcManager ==
nullptr) LOG(fatal) << GetName() <<
": No CbmMCDataManager!";
67 if (
fMCTracks ==
nullptr) LOG(fatal) << GetName() <<
": No MCTrack data!";
71 Error(
"CbmKFParticleFinderQA::Init",
"MC Event List not found!");
76 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
81 Error(
"CbmKFParticleFinderQA::Init",
"track match array not found!");
85 fStsHits = (TClonesArray*) ioman->GetObject(
"StsHit");
88 fMcPoints = (TClonesArray*) ioman->GetObject(
"StsPoint");
93 fEvents =
new TClonesArray(
"CbmEvent", 100);
95 "Event",
"CbmEvent",
fEvents, IsOutputBranchPersistent(
"Event"));
106 std::map<Int_t, CbmEvent*> eventMap;
111 UInt_t nTracks =
fStsTracks->GetEntriesFast();
114 vector<vector<UInt_t>> vKFPTrack1;
118 vKFPTrack1.resize(nMCEvents);
121 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
128 Float_t bestWeight = 0.f;
129 Float_t totalWeight = 0.f;
130 Int_t mcTrackId = -1;
133 for (
int iLink = 0; iLink < stsTrackMatch->
GetNofLinks(); iLink++) {
138 link = stsTrackMatch->
GetLink(iLink);
142 mcTrackId = iMCTrack;
145 if (bestWeight / totalWeight < 0.7 || mcTrackId < 0)
continue;
149 vKFPTrack1[mcEvent].push_back(iTrack);
153 for (
unsigned int iEvent = 0; iEvent < vKFPTrack1.size(); iEvent++) {
155 Int_t nEvents =
fEvents->GetEntriesFast();
157 if (vKFPTrack1[iEvent].size() > 1) {
159 event =
new ((*fEvents)[nEvents])
CbmEvent(iEvent);