CbmRoot
NicaUnigenSource.cxx
Go to the documentation of this file.
1
/*
2
* NicaUnigenSource.cxx
3
*
4
* Created on: 27 mar 2017
5
* Author: Daniel Wielanek
6
* E-mail: daniel.wielanek@gmail.com
7
* Warsaw University of Technology, Faculty of Physics
8
*/
9
#include "
NicaUnigenSource.h
"
10
#include "FairLogger.h"
11
#include "FairRootManager.h"
12
#include "
UEvent.h
"
13
#include "
UParticle.h
"
14
#include <TBranch.h>
15
#include <fstream>
16
#include <iostream>
17
18
NicaUnigenSource::NicaUnigenSource
()
19
: fUnigenChain(NULL), fFileName(
"data.root"
), fEvent(NULL) {}
20
21
NicaUnigenSource::NicaUnigenSource
(TString inFile)
22
: fUnigenChain(NULL), fFileName(inFile), fEvent(NULL) {}
23
24
NicaUnigenSource::~NicaUnigenSource
() {
25
if
(
fUnigenChain
)
delete
fUnigenChain
;
26
}
27
28
Bool_t
NicaUnigenSource::Init
() {
29
FairRootManager* mngr = FairRootManager::Instance();
30
fUnigenChain
=
new
TChain(
"events"
);
31
if
(
fFileName
.EndsWith(
".root"
)) {
32
LOG(debug) <<
"NicaUnigenSource: opening single file"
<<
fFileName
;
33
fUnigenChain
->Add(
fFileName
);
34
}
else
{
// this is long list
35
std::ifstream list;
36
list.open(
fFileName
);
37
do
{
38
TString temp;
39
list >> temp;
40
if
(temp.Length() > 1) {
41
fUnigenChain
->Add(temp);
42
}
else
{
43
break
;
44
}
45
LOG(debug) <<
"Adding file "
<< temp <<
" to chain"
;
46
}
while
(!list.eof());
47
list.close();
48
}
49
50
fEvent
=
new
UEvent
();
51
if
(
fUnigenChain
->GetBranch(
"event"
)) {
52
fUnigenChain
->Print();
53
fUnigenChain
->SetBranchStatus(
"event"
, 1);
54
fUnigenChain
->SetBranchAddress(
"event"
, &
fEvent
);
55
}
else
{
56
std::cout <<
"Event read II"
<< std::endl;
57
fUnigenChain
->SetBranchStatus(
"UEvent."
, 1);
58
fUnigenChain
->SetBranchAddress(
"UEvent."
, &
fEvent
);
59
}
60
mngr->SetInChain(
fUnigenChain
, -1);
61
mngr->Register(
"UEvent."
,
"UEvent"
, (TNamed*)
fEvent
, kFALSE);
62
return
kTRUE;
63
}
64
65
Int_t
NicaUnigenSource::ReadEvent
(UInt_t unsignedInt) {
66
//std::cout<<"READING EVENT " <<unsignedInt<<std::endl;
67
fUnigenChain
->GetEntry(unsignedInt);
68
// std::cout<<"xxx"<<std::endl;
69
return
0;
70
}
71
72
void
NicaUnigenSource::Close
() {}
73
74
void
NicaUnigenSource::Boost
(Double_t vx, Double_t vy, Double_t vz) {
75
for
(
int
i
= 0;
i
<
fEvent
->
GetNpa
();
i
++) {
76
UParticle
* p =
fEvent
->
GetParticle
(
i
);
77
TLorentzVector mom = p->
GetMomentum
();
78
TLorentzVector
pos
= p->
GetPosition
();
79
mom.Boost(vx, vy, vz);
80
pos
.Boost(vx, vy, vz);
81
p->
SetMomentum
(mom);
82
p->
SetPosition
(
pos
);
83
}
84
}
85
86
Int_t
NicaUnigenSource::CheckMaxEventNo
(Int_t
/*int1*/
) {
87
return
fUnigenChain
->GetEntries();
88
}
NicaUnigenSource::CheckMaxEventNo
virtual Int_t CheckMaxEventNo(Int_t=0)
Definition:
NicaUnigenSource.cxx:86
UParticle
Definition:
UParticle.h:10
NicaUnigenSource::fEvent
UEvent * fEvent
Definition:
NicaUnigenSource.h:21
NicaUnigenSource::~NicaUnigenSource
virtual ~NicaUnigenSource()
Definition:
NicaUnigenSource.cxx:24
NicaUnigenSource::Close
virtual void Close()
Definition:
NicaUnigenSource.cxx:72
UEvent::GetNpa
Int_t GetNpa() const
Definition:
UEvent.h:37
i
int i
Definition:
L1/vectors/P4_F32vec4.h:25
UParticle::SetMomentum
void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)
Definition:
UParticle.h:115
NicaUnigenSource::fFileName
TString fFileName
Definition:
NicaUnigenSource.h:20
NicaUnigenSource.h
UParticle.h
UEvent
Definition:
UEvent.h:12
UEvent.h
UEvent::GetParticle
UParticle * GetParticle(Int_t index) const
Definition:
UEvent.cxx:92
NicaUnigenSource::Boost
virtual void Boost(Double_t vx, Double_t vy, Double_t vz)
Definition:
NicaUnigenSource.cxx:74
NicaUnigenSource::fUnigenChain
TChain * fUnigenChain
Definition:
NicaUnigenSource.h:19
UParticle::GetMomentum
TLorentzVector GetMomentum() const
Definition:
UParticle.h:81
NicaUnigenSource::ReadEvent
virtual Int_t ReadEvent(UInt_t=0)
Definition:
NicaUnigenSource.cxx:65
UParticle::GetPosition
TLorentzVector GetPosition() const
Definition:
UParticle.h:91
UParticle::SetPosition
void SetPosition(Double_t x, Double_t y, Double_t z, Double_t t)
Definition:
UParticle.h:131
pos
TVector3 pos
Definition:
CbmMvdSensorDigiToHitTask.cxx:60
NicaUnigenSource::NicaUnigenSource
NicaUnigenSource()
Definition:
NicaUnigenSource.cxx:18
NicaUnigenSource::Init
virtual Bool_t Init()
Definition:
NicaUnigenSource.cxx:28
analysis
PWGC2F
femtoscopy
nicafemto
format
unigen
NicaUnigenSource.cxx
Generated on Wed Oct 28 2020 15:11:51 for CbmRoot by
1.8.18