Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
SplitedTrackToStatusTask.cxx
1/*
2 * SplitedTrackToStatusTask.cxx
3 *
4 * Created on: 27 lis 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "SplitedTrackToStatusTask.h"
10
11#include "ComplexEvent.h"
12#include "ComplexTrack.h"
13#include "Cout.h"
14#include "DataFormatManager.h"
15#include "DataManager.h"
16#include "Event.h"
17#include "Link.h"
18#include "MemoryMapManager.h"
19#include "Track.h"
20
21namespace Hal {
22 SplitedTrackToStatusTask::SplitedTrackToStatusTask() {}
23
24 SplitedTrackToStatusTask::~SplitedTrackToStatusTask() {}
25
26 SplitedTrackToStatusTask::SplitedTrackToStatusTask(const SplitedTrackToStatusTask& other) : EventAna(other) {
27 fArrayReco = other.fArrayReco;
28 fArraySim = other.fArraySim;
29 }
30
31 Task::EInitFlag SplitedTrackToStatusTask::Init() {
32 Task::EInitFlag stat = EventAna::Init();
33 if (stat == Task::EInitFlag::kFATAL) return stat;
34 const Event* ev = DataFormatManager::Instance()->GetFormat(GetTaskID(), EFormatDepth::kNonBuffered);
35 if (ev->InheritsFrom("Hal::ComplexEvent")) {
36 fCurrentEvent = fMemoryMap->GetTemporaryEvent();
37 DataManager* ioManager = DataManager::Instance();
38 ioManager->Register(Form("%s.", fCurrentEvent->ClassName()), "HalEvents", fCurrentEvent, kFALSE);
39 return Task::EInitFlag::kSUCCESS;
40 }
41 Cout::PrintInfo(Form("Wrong format in %s", this->ClassName()), EInfo::kError);
42 return Task::EInitFlag::kFATAL;
43 }
44
45 void SplitedTrackToStatusTask::ProcessEvent() {
46 ComplexEvent* complex = (ComplexEvent*) fCurrentEvent;
47 Event* event_re = complex->GetRealEvent();
48 Event* event_im = complex->GetImgEvent();
49 const Int_t nTracksRe = event_re->GetTotalTrackNo();
50 const Int_t nTracksIm = event_im->GetTotalTrackNo();
51 fArrayReco.Resize(nTracksRe);
52 fArraySim.Resize(nTracksIm);
53 for (int i = 0; i < nTracksRe; i++) {
54 fArrayReco[i] = -1;
55 }
56 for (int i = 0; i < nTracksIm; i++) {
57 fArraySim[i] = -1;
58 }
59 // check status of MC-tracks
60 for (int i = 0; i < nTracksRe; i++) {
61 ComplexTrack* complex_track = (ComplexTrack*) complex->GetTrack(i);
62 Track* mc_track = complex_track->GetImgTrack();
63 if (mc_track != nullptr) {
64 Int_t mc_id = mc_track->GetThisID();
65 if (fArraySim[mc_id] == -1) {
66 fArraySim[mc_id] = 0; // good reconstructed mc-track
67 } else {
68 fArraySim[mc_id] = 1; // track reconstructed more than once
69 }
70 }
71 }
72 // fill status of MC-tracks
73 for (int i = 0; i < nTracksIm; i++) {
74 Track* mc_track = event_im->GetTrack(i);
75 mc_track->SetStatus(fArraySim[i]);
76 }
77 // check/fill status of reco tracks
78 for (int i = 0; i < nTracksRe; i++) {
79 ComplexTrack* complex_track = (ComplexTrack*) complex->GetTrack(i);
80 Track* mc_track = complex_track->GetImgTrack();
81 Track* reco_track = complex_track->GetRealTrack();
82 if (mc_track != nullptr) {
83 mc_track->SetStatus(0);
84 Int_t mc_id = mc_track->GetThisID();
85 if (fArraySim[mc_id] == 0) {
86 reco_track->SetStatus(0); // good reconstructed mc-track
87 } else {
88 reco_track->SetStatus(1); // track reconstructed more than once
89 }
90 } else {
91 reco_track->SetStatus(-1);
92 }
93 }
94 }
95
96 SplitedTrackToStatusTask& SplitedTrackToStatusTask::operator=(const SplitedTrackToStatusTask& other) {
97 if (this == &other) return *this;
98 EventAna::operator=(other);
99 fArrayReco = other.fArrayReco;
100 fArraySim = other.fArraySim;
101 return *this;
102 }
103} // namespace Hal
void Register(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)
Int_t GetTotalTrackNo() const
Definition Event.h:236
Track * GetTrack(Int_t i) const
Definition Event.h:208
Int_t GetThisID() const
Definition Track.h:83
void SetStatus(Int_t status)
Definition Track.h:144