CbmRoot
Loading...
Searching...
No Matches
HalCbmFullEvent.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2023 Warsaw University of Technology, Warsaw
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Daniel Wielanek [committer] */
4#include "HalCbmFullEvent.h"
5
6#include "CbmMCEvent.h"
7#include "CbmTrackMatchNew.h"
8#include "HalCbmEvent.h"
10#include "HalCbmMCEvent.h"
12
13#include <AnalysisTree/Constants.hpp>
14
15#include <Hal/ComplexEvent.h>
16#include <Hal/ComplexEventInterface.h>
17#include <Hal/ComplexTrack.h>
18
19
21
22void HalCbmFullEvent::Update(Hal::EventInterface* interface)
23{
24 Hal::ComplexEventInterface* interf = static_cast<Hal::ComplexEventInterface*>(interface);
25 fImgEvent->Update(interf->GetImag());
26 fRealEvent->Update(interf->GetReal());
27 Hal::Event::ShallowCopyEvent(fRealEvent);
28 fTracks->Clear();
29 fTotalTracksNo = fRealEvent->GetTotalTrackNo();
30 fTracks->ExpandCreateFast(fTotalTracksNo);
31 HalCbmEventInterface* evInt = (HalCbmEventInterface*) interf->GetReal();
32 switch (evInt->GetFormatType()) {
34 UpdateAnalysisTree(interf);
35 } break;
37 UpdateDst(interf);
38 } break;
39
41 //Do nothing
42 } break;
43 }
44}
45
46Hal::Event* HalCbmFullEvent::GetNewEvent() const { return new HalCbmFullEvent(); }
47
49
50HalCbmFullEvent::HalCbmFullEvent(Hal::Event* re, Hal::Event* im) : Hal::ComplexEvent(re, im) {}
51
52void HalCbmFullEvent::UpdateAnalysisTree(Hal::ComplexEventInterface* interface)
53{
54 HalCbmEventInterface* s = (HalCbmEventInterface*) interface->GetReal();
56 auto vecToSim = reco->GetVtx2Sim();
57 for (Int_t i = 0; i < fTotalTracksNo; i++) {
58 Hal::ComplexTrack* track = (Hal::ComplexTrack*) fTracks->UncheckedAt(i);
59 track->ResetTrack(i, this);
60 track->SetRealTrack(fRealEvent->GetTrack(i));
61 track->Hal::Track::CopyData(fRealEvent->GetTrack(i));
62 Int_t match = vecToSim->GetMatchDirect(i);
63
64 if (match < 0 || match == AnalysisTree::UndefValueInt) {
65 track->SetImgTrack(nullptr);
66 }
67 else {
68 track->SetImgTrack(fImgEvent->GetTrack(match));
69 track->SetMatchID(match);
70 }
71 }
72}
73
74void HalCbmFullEvent::UpdateDst(Hal::ComplexEventInterface* interface)
75{
77 HalCbmMCEventInterface* ims = (HalCbmMCEventInterface*) interface->GetImag();
78 for (Int_t i = 0; i < fTotalTracksNo; i++) {
79 Hal::ComplexTrack* track = (Hal::ComplexTrack*) fTracks->UncheckedAt(i);
80 track->ResetTrack(i, this);
81 track->SetRealTrack(fRealEvent->GetTrack(i));
82 track->Hal::Track::CopyData(fRealEvent->GetTrack(i));
83 CbmGlobalTrack* glob = (CbmGlobalTrack*) s->fGlobalTracks->UncheckedAt(i);
84 Int_t sts_index = glob->GetStsTrackIndex();
85 if (sts_index >= 0) {
86 CbmTrackMatchNew* match = (CbmTrackMatchNew*) ims->fStsMatches->UncheckedAt(sts_index);
87 Int_t mcId = match->GetMatchedLink().GetIndex();
88 if (mcId > 0) {
89 track->SetImgTrack(fImgEvent->GetTrack(mcId));
90 track->SetMatchID(mcId);
91 }
92 }
93 }
94 //
95}
AnalysisTree::Matching * GetVtx2Sim() const
int32_t GetStsTrackIndex() const
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
CbmAnaTreeRecoSourceContainer * GetContainer() const
HalCbm::DataFormat GetFormatType() const
void UpdateDst(Hal::ComplexEventInterface *interface)
void UpdateAnalysisTree(Hal::ComplexEventInterface *interface)
virtual void Update(Hal::EventInterface *interface)
virtual ~HalCbmFullEvent()
virtual Hal::Event * GetNewEvent() const