10#include "UnigenEventInterface.h"
13#include "UnigenTrackInterface.h"
15#include "DataManager.h"
16#include "TrackInterface.h"
21#include <RtypesCore.h>
22#include <TCollection.h>
24#include <TLorentzVector.h>
26#include <TObjString.h>
30 UnigenEventInterface::UnigenEventInterface() :
Hal::EventInterfaceAdvanced(new UnigenTrackInterface()), fEvent(nullptr) {
34 void UnigenEventInterface::Compress(Int_t* map, Int_t map_size) {
36 for (
int i = 0; i < map_size; i++) {
37 Int_t good_track = map[i];
38 for (
int j = track_pos; j < good_track; j++) {
41 track_pos = good_track + 1;
47 CopyUnigen(((HalCbmUnigenEventInterface*) s)->fEvent, fEvent);
55 fEvent->SetB(ev->fEvent->GetB());
56 fEvent->SetPhi(ev->fEvent->GetPhi());
57 fEvent->SetNes(ev->fEvent->GetNes());
58 fEvent->SetStepNr(ev->fEvent->GetStepNr());
59 fEvent->SetStepT(ev->fEvent->GetStepT());
61 fEvent->GetParticleList()->Clear();
64 ev->fEvent->GetComment(comment);
65 fEvent->SetComment(comment);
68 for (
int i = 0; i < map_size; i++) {
69 fEvent->AddParticle(*ev->fEvent->GetParticle(map[i]));
73 void UnigenEventInterface::Boost(Double_t vx, Double_t vy, Double_t vz) {
74 for (
int i = 0; i < fEvent->GetNpa(); i++) {
76 TLorentzVector mom = p->GetMomentum();
77 TLorentzVector pos = p->GetPosition();
78 mom.Boost(vx, vy, vz);
79 pos.Boost(vx, vy, vz);
85 UnigenEventInterface::~UnigenEventInterface() {
86 if (fCanDeleteEvent && fEvent) {
87 if (fEvent)
delete fEvent;
91 void UnigenEventInterface::Register(Bool_t write) {
92 if (fEvent ==
nullptr) fEvent =
new UEvent();
94 manager->
Register(
"UEvent.",
"", (TNamed*) fEvent, write);
101 void UnigenEventInterface::ConnectToTreeInternal(eMode mode) {
105 case Hal::EventInterface::eMode::kRead: {
106 std::vector<TString> names;
107 names.push_back(
"UEvent.");
108 names.push_back(
"UEvent");
109 names.push_back(
"event");
110 names.push_back(
"events");
111 for (
auto i : names) {
112 fEvent =
dynamic_cast<UEvent*
>(manager->GetObject(i));
113 if (fEvent !=
nullptr) {
return; }
116 case Hal::EventInterface::eMode::kWrite: {
118 manager->
Register(
"UEvent.",
"unigen", (TNamed*) fEvent, kTRUE);
120 case Hal::EventInterface::eMode::kWriteVirtual: {
122 manager->
Register(
"UEvent.",
"unigen", (TNamed*) fEvent, kFALSE);
123 fCanDeleteEvent = kTRUE;
void Register(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)
void SetRawTrack(TObject *source, Int_t obj=0)