CbmRoot
Loading...
Searching...
No Matches
CbmUnigenGenerator.h
Go to the documentation of this file.
1/* Copyright (C) 2006-2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dmytro Kresan [committer], Volker Friese */
4
10#ifndef CBMUNIGENGENERATOR
11#define CBMUNIGENGENERATOR
12
13
14#include "FairGenerator.h"
15
16#include "TMath.h"
17#include "TString.h"
18#include "TVector3.h"
19
20#include <map>
21
22#include "UEvent.h"
23
24class TFile;
25class TTree;
26class UParticle;
27class FairIon;
28class FairPrimaryGenerator;
29
30
51class CbmUnigenGenerator : public FairGenerator {
52
53public:
62
63
70 CbmUnigenGenerator(const char* fileName = "", EMode mode = kStandard);
71
72
78 CbmUnigenGenerator(const char* fileName, EMode mode, Double_t phi);
79
80
82 virtual ~CbmUnigenGenerator();
83
84
95 virtual Bool_t ReadEvent(FairPrimaryGenerator* primGen);
96
101
102private:
103 TString fFileName = "";
105 Double_t fPhi = 0.;
106 Bool_t fIsInit = kFALSE;
107 TFile* fFile = nullptr;
108 TTree* fTree = nullptr;
109 Int_t fCurrentEntry = -1;
111 Int_t fNofPrimaries = 0;
112 Int_t fNofEvents = 0;
113 Double_t fBetaCM = 0;
114 Double_t fGammaCM = 0;
116 std::map<TString, FairIon*> fIonMap {};
117
118 // Constants for decimal decomposition of ion PDG.
119 // For ions the PDG code is +-10LZZZAAAI, with L = number of Lambdas,
120 // ZZZ = charge (number of protons), AAA = mass (sum of numbers
121 // of Lambdas, protons and neutrons, I = isomer level
122 static const Int_t kPdgLambda = 10000000;
123 static const Int_t kPdgCharge = 10000;
124 static const Int_t kPdgMass = 10;
125
126
132 void AddPrimary(FairPrimaryGenerator* primGen, Int_t pdgCode, const TVector3& momentum);
133
134
136 void CloseInput();
137
138
145 Int_t GetIonCharge(Int_t pdgCode) const { return (pdgCode % kPdgLambda) / kPdgCharge; }
146
147
154 Int_t GetIonLambdas(Int_t pdgCode) const { return (pdgCode % (10 * kPdgLambda)) / kPdgLambda; }
155
156
163 Int_t GetIonMass(Int_t pdgCode) const { return (pdgCode % kPdgCharge) / kPdgMass; }
164
165
169 Bool_t GetNextEntry();
170
171
178 Bool_t Init();
179
180
191 void ProcessIon(FairPrimaryGenerator* primGen, Int_t pdgCode, const TVector3& momentum);
192
193
202 Int_t RegisterIons();
203
204
207
208
211
212
214};
215
216#endif
Generates input to transport simulation from files in Unigen format.
Double_t fPhi
Event plane rotation angle.
Int_t fNofEvents
Number of processed events.
void ProcessIon(FairPrimaryGenerator *primGen, Int_t pdgCode, const TVector3 &momentum)
Treat a composite particle (ion)
static const Int_t kPdgMass
Decomposition of ion PDG code.
CbmUnigenGenerator & operator=(const CbmUnigenGenerator &)=delete
Assignment operator forbidden.
TString fFileName
Input file name.
CbmUnigenGenerator(const char *fileName="", EMode mode=kStandard)
Default constructor.
UEvent * fEvent
Current input event.
void AddPrimary(FairPrimaryGenerator *primGen, Int_t pdgCode, const TVector3 &momentum)
Add a primary particle to the event generator.
TFile * fFile
Input ROOT file.
EMode fMode
Rotation mode.
std::map< TString, FairIon * > fIonMap
Map from ion name to FairIon.
Int_t GetIonCharge(Int_t pdgCode) const
Charge number of an ion.
Double_t fGammaCM
Gamma factor of CM in lab frame.
Bool_t GetNextEntry()
Get next entry from input tree.
Int_t GetIonLambdas(Int_t pdgCode) const
Number of Lambdas in an ion.
TTree * fTree
Input ROOT tree.
Double_t fBetaCM
CM velocity in the lab frame.
virtual ~CbmUnigenGenerator()
Destructor.
Int_t GetNumAvailableEvents()
Get the maximum number of events available in the input file.
Int_t fCurrentEntry
Current entry number.
void CloseInput()
Close the input file.
Int_t RegisterIons()
Register ions to the simulation.
EMode
Mode enumerator.
@ kNoRotation
No event rotation.
@ kStandard
Rotate events to zero event plane (default)
@ kRotateFixed
Rotate events around z by a fixed angle.
@ kReuseEvents
Reuse events if more are requested than present.
Bool_t Init()
Initialisation.
Bool_t fIsInit
Flag whether generator is initialised.
static const Int_t kPdgLambda
Decomposition of ion PDG code.
Int_t fAvailableEvents
Maximum number of events in the input file.
ClassDef(CbmUnigenGenerator, 5)
CbmUnigenGenerator(const CbmUnigenGenerator &)=delete
Copy constructor forbidden.
Int_t GetIonMass(Int_t pdgCode) const
Mass number of an ion.
static const Int_t kPdgCharge
Decomposition of ion PDG code.
Int_t fNofPrimaries
Number of primaries registered in current event.
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Read one event from the input file.