CbmRoot
Loading...
Searching...
No Matches
CbmUnigenSource.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 "
CbmUnigenSource.h
"
5
6
#include "
UEvent.h
"
7
#include "
UParticle.h
"
8
9
#include <FairLogger.h>
10
#include <FairRootManager.h>
11
12
#include <TBranch.h>
13
14
#include <fstream>
15
#include <iostream>
16
17
18
CbmUnigenSource::CbmUnigenSource
() : fUnigenChain(nullptr), fEvent(nullptr), fPrintTreeInfo(kFALSE) {}
19
20
CbmUnigenSource::CbmUnigenSource
(TString inFile) : fUnigenChain(nullptr), fEvent(nullptr), fPrintTreeInfo(kFALSE)
21
{
22
fFileName
.push_back(inFile);
23
}
24
25
CbmUnigenSource::~CbmUnigenSource
()
26
{
27
//if (fUnigenChain) delete fUnigenChain;
28
//is owned by FairRoot ?
29
}
30
31
Bool_t
CbmUnigenSource::Init
()
32
{
33
FairRootManager* mngr = FairRootManager::Instance();
34
fUnigenChain
=
new
TChain(
"events"
);
35
if
(
fFileName
[0].EndsWith(
".root"
)) {
36
for
(
auto
i :
fFileName
) {
37
LOG(debug) <<
"NicaUnigenSource: opening single file"
<< i;
38
fUnigenChain
->Add(i);
39
}
40
}
41
else
{
// this is long list
42
std::ifstream list;
43
list.open(
fFileName
[0]);
44
do
{
45
TString temp;
46
list >> temp;
47
if
(temp.Length() > 1) {
48
fUnigenChain
->Add(temp);
49
}
50
else
{
51
break
;
52
}
53
LOG(debug) <<
"Adding file "
<< temp <<
" to chain"
;
54
}
while
(!list.eof());
55
list.close();
56
}
57
58
fEvent
=
new
UEvent
();
59
if
(
fUnigenChain
->GetBranch(
"event"
)) {
60
if
(
fPrintTreeInfo
)
fUnigenChain
->Print();
61
fUnigenChain
->SetBranchStatus(
"event"
, 1);
62
fUnigenChain
->SetBranchAddress(
"event"
, &
fEvent
);
63
}
64
else
{
65
if
(
fPrintTreeInfo
) std::cout <<
"Event read II"
<< std::endl;
66
fUnigenChain
->SetBranchStatus(
"UEvent."
, 1);
67
fUnigenChain
->SetBranchAddress(
"UEvent."
, &
fEvent
);
68
}
69
mngr->SetInChain(
fUnigenChain
, -1);
70
mngr->Register(
"UEvent."
,
"UEvent"
, (TNamed*)
fEvent
, kFALSE);
71
return
kTRUE;
72
}
73
74
Int_t
CbmUnigenSource::ReadEvent
(UInt_t unsignedInt)
75
{
76
//std::cout<<"READING EVENT " <<unsignedInt<<std::endl;
77
fUnigenChain
->GetEntry(unsignedInt);
78
// std::cout<<"xxx"<<std::endl;
79
return
0;
80
}
81
82
void
CbmUnigenSource::Close
() {}
83
84
void
CbmUnigenSource::Boost
(Double_t vx, Double_t vy, Double_t vz)
85
{
86
for
(
int
i = 0; i <
fEvent
->
GetNpa
(); i++) {
87
UParticle
* p =
fEvent
->
GetParticle
(i);
88
TLorentzVector mom = p->
GetMomentum
();
89
TLorentzVector
pos
= p->
GetPosition
();
90
mom.Boost(vx, vy, vz);
91
pos
.Boost(vx, vy, vz);
92
p->
SetMomentum
(mom);
93
p->
SetPosition
(
pos
);
94
}
95
}
96
97
Int_t
CbmUnigenSource::CheckMaxEventNo
(Int_t
/*int1*/
) {
return
fUnigenChain
->GetEntries(); }
98
99
Bool_t
CbmUnigenSource::SpecifyRunId
() {
return
kFALSE; }
pos
TVector3 pos
Definition
CbmMvdSensorDigiToHitTask.cxx:56
CbmUnigenSource.h
UEvent.h
UParticle.h
CbmUnigenSource::fFileName
std::vector< TString > fFileName
Definition
CbmUnigenSource.h:19
CbmUnigenSource::ReadEvent
virtual Int_t ReadEvent(UInt_t=0)
Definition
CbmUnigenSource.cxx:74
CbmUnigenSource::Close
virtual void Close()
Definition
CbmUnigenSource.cxx:82
CbmUnigenSource::Boost
virtual void Boost(Double_t vx, Double_t vy, Double_t vz)
Definition
CbmUnigenSource.cxx:84
CbmUnigenSource::CheckMaxEventNo
virtual Int_t CheckMaxEventNo(Int_t=0)
Definition
CbmUnigenSource.cxx:97
CbmUnigenSource::~CbmUnigenSource
virtual ~CbmUnigenSource()
Definition
CbmUnigenSource.cxx:25
CbmUnigenSource::SpecifyRunId
virtual Bool_t SpecifyRunId()
Definition
CbmUnigenSource.cxx:99
CbmUnigenSource::CbmUnigenSource
CbmUnigenSource()
Definition
CbmUnigenSource.cxx:18
CbmUnigenSource::fEvent
UEvent * fEvent
Definition
CbmUnigenSource.h:20
CbmUnigenSource::fPrintTreeInfo
Bool_t fPrintTreeInfo
Definition
CbmUnigenSource.h:21
CbmUnigenSource::fUnigenChain
TChain * fUnigenChain
Definition
CbmUnigenSource.h:18
CbmUnigenSource::Init
virtual Bool_t Init()
Definition
CbmUnigenSource.cxx:31
UEvent
Definition
UEvent.h:17
UEvent::GetNpa
Int_t GetNpa() const
Definition
UEvent.h:42
UEvent::GetParticle
UParticle * GetParticle(Int_t index) const
Definition
UEvent.cxx:101
UParticle
Definition
UParticle.h:14
UParticle::SetMomentum
void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)
Definition
UParticle.h:89
UParticle::GetMomentum
TLorentzVector GetMomentum() const
Definition
UParticle.h:62
UParticle::GetPosition
TLorentzVector GetPosition() const
Definition
UParticle.h:68
UParticle::SetPosition
void SetPosition(Double_t x, Double_t y, Double_t z, Double_t t)
Definition
UParticle.h:107
analysis
PWGC2F
femtoscopy
hal
format
unigen
CbmUnigenSource.cxx
Generated on Sun Dec 22 2024 23:04:05 for CbmRoot by
1.12.0