Pluto v6.3.0
Loading...
Searching...
No Matches
PUniGenInput.cc
Go to the documentation of this file.
1
2//
3//This class reads UniGen-files
4//see
5//http://www.gsi.de/forschung/helmholtz-vi/unigen/
6//for further information
7//
8//Parts of the source code have been taken from
9//the UniGen project.
10//
11//
12// Author: Ingo Froehlich
13// Written: 01/02/2011
14//
16
17#include "PUniGenInput.h"
18#include "PChannel.h"
20
21#include "UParticle.h"
22
24
26 unknown_pdg_pointer = 0;
27 reset_mass = 0;
28}
29
31
33 unknown_pdg_pointer = 0;
34 reset_mass = 0;
35
37}
38
40 //Copied from UManager
41 fInFile = new TFile(filename);
42 if(NULL == fInFile) {
43 Fatal("Input", "Input file <%s> does not exist",filename);
44 }
45
46 fRun = (URun*) fInFile->Get("run");
47
48 fInTree = (TTree*) fInFile->Get("events");
49 if(NULL == fInTree) {
50 Fatal("SetInputFile", "Input file <%s> has no events tree", filename);
51 }
52
53 Info("Input", "Input file has %lli events", fInTree->GetEntries());
54
55 nentries = fInTree->GetEntries();
56 centry = 0;
57
58 if(NULL == fEvent) {
59 fEvent = new UEvent();
60 }
61
62 fInTree->SetBranchAddress("event", &fEvent);
63
64 return kTRUE;
65
66};
67
68Bool_t PUniGenInput::Modify(PParticle **mstack, int *, int *num, int stacksize) {
69
70 if (centry == 0) {
71 //init before 1st event
72 makeDistributionManager()->Exec("pdg:init");
73 pdg_param = makeDataBase()->GetParamInt("pdg");
74 if (pdg_param < 0)
75 return kFALSE;
76 pid_param = makeDataBase()->GetParamInt("pid");
77 }
78
79 if (centry == nentries) {
80 Info("Modify", "Unigen file: number of events reached");
81 return kFALSE;
82 }
83
84 int cur = *num;
85 PParticle dummy("dummy");
86
87 fInTree->GetEntry(centry);
88 centry++;
89
90 Int_t npart = fEvent->GetNpa();
91#if 0
92 //not yet used....
93 Int_t evnr = fEvent->GetEventNr();
94 Int_t stepnr = fEvent->GetStepNr();
95#endif
96
97 for (int i=0; i<npart; i++) {
98
99 if (cur == stacksize) {
100 Warning("Modify", "Stack size too small, increase '_system_particle_stacksize'");
101 return kTRUE;
102 }
103
104 UParticle *part = fEvent->GetParticle(i);
105
106
107 if (!makeDataBase()->GetParamInt (pdg_param, part->GetPdg(), pid_param, &i_result)) {
108 bool found = kFALSE;
109 for (int i=0; i<unknown_pdg_pointer; i++) {
110 if (unknown_pdg[i] == part->GetPdg())
111 found=kTRUE;
112 }
113 if (!found) {
114 Warning("Modify",
115 "Particle with PDG code %i is not defined in Pluto, further particles will get the 'dummy' pid",
116 part->GetPdg());
117 if (unknown_pdg_pointer != MAX_UNIGENUNKNOWNPDG) {
118 unknown_pdg[unknown_pdg_pointer] = part->GetPdg();
119 unknown_pdg_pointer++;
120 }
121 }
122
123 } else {
124 dummy.SetID(*i_result);
125 }
126
127 dummy.SetVect4(part->GetMomentum());
128 Double_t x = part->GetPosition().X();
129 Double_t y = part->GetPosition().Y();
130 Double_t z = part->GetPosition().Z();
131 Double_t t = part->GetPosition().T();
132 dummy.SetVertex(x,y,z,t);
133 dummy.SetIndex(part->GetIndex());
134 dummy.SetParentIndex(part->GetParent());
135 dummy.SetSiblingIndex(part->GetMate());
136 dummy.SetSourceId(part->GetParentDecay());
137 dummy.SetW(part->GetWeight());
138
139 if (dummy.M() < PData::LMass(dummy.ID()) || dummy.M() > PData::UMass(dummy.ID())) {
140 if (reset_mass == 1) {
141 dummy.SetM(makeStaticData()->GetParticleMass(dummy.ID()));
142 } else if (reset_mass == 0) {
143 Warning("Modify", "Found a particle mass which is out of bounds, it is recommended to use ResetInvalidMass()");
144 Warning("Modify", "(following warnings will be skipped)");
145 reset_mass=-1;
146 }
147 }
148
149 *(mstack[cur]) = dummy;
150
151 cur++;
152 }
153
154 *num = cur;
155
156 return kTRUE;
157}
158
ClassImp(PBeamLineSimulation) PBeamLineSimulation
#define FILEINPUT_PRIORITY
PDataBase * makeDataBase()
PDistributionManager * makeDistributionManager()
PStaticData * makeStaticData()
#define MAX_UNIGENUNKNOWNPDG
Int_t GetParamInt(const char *paramname, Int_t length=-1)
static double LMass(const int &id)
Definition PData.h:32
static double UMass(const int &id)
Definition PData.h:70
Bool_t Exec(const char *command)
void SetParentIndex(Int_t pInd)
Definition PParticle.h:234
Int_t ID() const
Definition PParticle.h:80
void SetM(Double_t m=0.)
void SetID(const Int_t id)
Definition PParticle.h:91
void SetVect4(const TLorentzVector &v)
Definition PParticle.h:118
void SetW(Double_t w=1.)
Definition PParticle.h:93
void SetSiblingIndex(Int_t sInd)
Definition PParticle.h:254
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t t)
Definition PParticle.h:267
void SetSourceId(Int_t sId)
Definition PParticle.h:228
void SetIndex(Int_t Ind)
Definition PParticle.h:256
Bool_t Input(char *filename)
Bool_t Modify(PParticle **stack, int *decay_done, int *num, int stacksize)
Int_t GetPdg() const
Definition UParticle.h:53
TLorentzVector GetMomentum() const
Definition UParticle.h:65
Int_t GetIndex() const
Definition UParticle.h:52
Int_t GetMate() const
Definition UParticle.h:57
Double_t GetWeight() const
Definition UParticle.h:73
Int_t GetParent() const
Definition UParticle.h:55
TLorentzVector GetPosition() const
Definition UParticle.h:71
Int_t GetParentDecay() const
Definition UParticle.h:56
Definition URun.h:8
TString filename("eta_dalitz_a")