11 #include "FairLogger.h"
12 #include "FairRootManager.h"
13 #include "TClonesArray.h"
14 #include "TStopwatch.h"
26 : FairTask(
"CbmBuildEventsFromTracksReal")
43 FairRootManager* ioman = FairRootManager::Instance();
46 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
51 fEvents =
new TClonesArray(
"CbmEvent", 100);
53 "Event",
"CbmEvent",
fEvents, IsOutputBranchPersistent(
"Event"));
64 std::map<Int_t, CbmEvent*> eventMap;
71 vector<CbmStsTrack> vRTracks_new;
75 vector<SortTracks> Tracks;
77 vector<vector<int>> timeClusters;
78 unsigned int nUsedTracks = 0;
81 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
84 Double_t time = track->
GetTime();
89 structure.
Track = *track;
90 structure.
index = iTrack;
93 if (timeEr > 0 && timeEr == timeEr && time == time)
94 Tracks.push_back(structure);
102 vector<vector<UInt_t>> clusters;
105 while (nUsedTracks < Tracks.size()) {
107 vector<UInt_t> cluster;
110 for (
unsigned int iTrack = 0; iTrack < Tracks.size(); iTrack++)
111 if (!Tracks[iTrack].used) {
112 cluster.push_back(Tracks[iTrack].index);
113 Tracks[iTrack].used =
true;
119 for (
unsigned int iTrack = 0; iTrack < Tracks.size(); iTrack++) {
120 if (Tracks[iTrack].used)
continue;
122 float time1 = Tracks[iTrack].Track.GetTime();
123 float timeC1 = Tracks[iTrack].Track.GetTimeError();
125 for (
unsigned int iClusterTrack = 0; iClusterTrack < cluster.size();
130 float time2 = stsTrack->
GetTime();
133 float dt =
fabs(time1 - time2);
134 float error =
sqrt(timeC1 + timeC2);
136 if ((dt < 4 * error) && (dt < 8.5)) {
137 cluster.push_back(Tracks[iTrack].index);
138 Tracks[iTrack].used =
true;
146 float time_min = 100000000000;
149 for (
unsigned int iClusterTrack = 0; iClusterTrack < cluster.size();
154 if (time_min > stsTrack->
GetTime()) time_min = stsTrack->
GetTime();
156 if (time_max < stsTrack->GetTime()) time_max = stsTrack->
GetTime();
159 if (cluster.size() > 1) clusters.push_back(cluster);
163 for (
unsigned int iEvent = 0; iEvent < clusters.size(); iEvent++) {
165 Int_t nEvents =
fEvents->GetEntriesFast();
170 event =
new ((*fEvents)[nEvents])
CbmEvent(iEvent);