FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
PndGiBuuGenerator Class Reference

#include <PndGiBuuGenerator.h>

Inheritance diagram for PndGiBuuGenerator:

Public Member Functions

 PndGiBuuGenerator (const Char_t *fileName, const Char_t *pidDataFileName)
 
virtual ~PndGiBuuGenerator ()
 
virtual Bool_t ReadEvent (FairPrimaryGenerator *primGen)
 
void RegisterDecayer (Int_t pdgCode, PndGiBuuDecayerAbs *decayer)
 

Protected Member Functions

Bool_t Init ()
 

Private Member Functions

 PndGiBuuGenerator ()
 
void FillPidMap ()
 
Int_t GetPdgParticleId (Int_t GiBuuId, Int_t charge)
 
void WriteoutDecayParticle (Int_t oldEventNr, Int_t oldRunId, FairPrimaryGenerator *primGen)
 
void CloseInput ()
 PDG code of particle. More...
 
 ClassDef (PndGiBuuGenerator, 1)
 

Private Attributes

std::map< std::pair< Int_t,
Int_t >, Int_t > 
fMapGiBuuToPdg
 
Int_t fEvent
 
Int_t fRunId
 Event number. More...
 
TString fFileName
 Run number in GiBuu. More...
 
TString fPidDataFileName
 Input file name. More...
 
std::ifstream * fInputAsciiFile
 Input Pid data file name. More...
 
std::map< Int_t,
PndGiBuuDecayerAbs * > 
fDecayerMap
 
Double_t fPx
 
Double_t fPy
 
Double_t fPz
 
Int_t fPdg
 Momentum of particle. More...
 

Detailed Description

Definition at line 30 of file PndGiBuuGenerator.h.

Constructor & Destructor Documentation

PndGiBuuGenerator::PndGiBuuGenerator ( const Char_t *  fileName,
const Char_t *  pidDataFileName 
)

Standard constructor

Parameters
fileNameThe input root file name
pidDataFileNameTranslation between GiBuu particle Id and Pdg particle Id file

Definition at line 11 of file PndGiBuuGenerator.cxx.

11  :
12  fEvent(0), fRunId(0), fFileName(fileName), fPidDataFileName(pidDataFileName), fInputAsciiFile(0), fPx(0), fPy(0), fPz(0), fPdg(0)
13 {
14  std::cout << "Constructor Called!" << std::endl;
15 }
TString fFileName
Run number in GiBuu.
Int_t fPdg
Momentum of particle.
Int_t fRunId
Event number.
TString fPidDataFileName
Input file name.
std::ifstream * fInputAsciiFile
Input Pid data file name.
PndGiBuuGenerator::~PndGiBuuGenerator ( )
virtual

Destructor

Definition at line 20 of file PndGiBuuGenerator.cxx.

References CloseInput(), and fDecayerMap.

20  {
21  CloseInput();
22  for (std::map<Int_t, PndGiBuuDecayerAbs*>::const_iterator iter = fDecayerMap.begin(); iter != fDecayerMap.end(); iter++){
23  delete(iter->second);
24  }
25 }
void CloseInput()
PDG code of particle.
std::map< Int_t, PndGiBuuDecayerAbs * > fDecayerMap
PndGiBuuGenerator::PndGiBuuGenerator ( )
inlineprivate

Default constructor (should not be used)

Definition at line 60 of file PndGiBuuGenerator.h.

60 {};

Member Function Documentation

PndGiBuuGenerator::ClassDef ( PndGiBuuGenerator  ,
 
)
private
void PndGiBuuGenerator::CloseInput ( )
private

PDG code of particle.

Definition at line 137 of file PndGiBuuGenerator.cxx.

References fInputAsciiFile.

Referenced by ~PndGiBuuGenerator().

137  {
138 
139  fInputAsciiFile->close();
140  //delete fInputAsciiFile;
141  fInputAsciiFile = NULL;
142 
143 }
std::ifstream * fInputAsciiFile
Input Pid data file name.
void PndGiBuuGenerator::FillPidMap ( )
private

Definition at line 103 of file PndGiBuuGenerator.cxx.

References fMapGiBuuToPdg, fPidDataFileName, and PidFile.

Referenced by Init().

104 {
105  std::ifstream* PidFile = new std::ifstream(fPidDataFileName.Data(), std::ifstream::in);
106  if (0 == PidFile){
107  Fatal("PndGiBuuGenerator::FillPidMap", "No pid file!");
108  }
109  Int_t giPid = 0;
110  Int_t giCharge = 0;
111  Int_t pdgPid = 0;
112 
113 // std::cout << "Reading In PidFile: " << fPidDataFileName.Data() << " " << PidFile << " " << PidFile->eof() << std::endl;
114 
115  while (!(PidFile->eof())){
116  *PidFile >> giPid >> giCharge >> pdgPid;
117  std::pair<Int_t, Int_t> GiBuuPid(giPid, giCharge);
118  fMapGiBuuToPdg[GiBuuPid] = pdgPid;
119 // std::cout << giPid << " " << giCharge << " = " << pdgPid << std::endl;
120  }
121  PidFile->close();
122  PidFile = 0;
123 
124 }
std::map< std::pair< Int_t, Int_t >, Int_t > fMapGiBuuToPdg
TString PidFile
TString fPidDataFileName
Input file name.
Int_t PndGiBuuGenerator::GetPdgParticleId ( Int_t  GiBuuId,
Int_t  charge 
)
private

Definition at line 126 of file PndGiBuuGenerator.cxx.

References fMapGiBuuToPdg.

Referenced by ReadEvent().

127 {
128  std::pair<Int_t, Int_t> GiBuuPid(GiBuuId, charge);
129  if (fMapGiBuuToPdg.count(GiBuuPid) > 0){
130  return fMapGiBuuToPdg[GiBuuPid];
131  } else {
132  return 0;
133  }
134 }
std::map< std::pair< Int_t, Int_t >, Int_t > fMapGiBuuToPdg
Bool_t PndGiBuuGenerator::Init ( )
protected

Definition at line 28 of file PndGiBuuGenerator.cxx.

References fFileName, FillPidMap(), and fInputAsciiFile.

29 {
30 
31  fInputAsciiFile = new std::ifstream(fFileName.Data(), std::ifstream::in);
32  if (0 == fInputAsciiFile) {
33  Fatal("PndGiBuuGenerator", "Cannot open ASCII input file.");
34  }
35 
36  FillPidMap();
37 
38  return kTRUE;
39 }
TString fFileName
Run number in GiBuu.
std::ifstream * fInputAsciiFile
Input Pid data file name.
Bool_t PndGiBuuGenerator::ReadEvent ( FairPrimaryGenerator *  primGen)
virtual

Reads on event from the input file and pushes the tracks onto the stack. Abstract method in base class.

Parameters
primGenpointer to the FairPrimaryGenerator

Definition at line 46 of file PndGiBuuGenerator.cxx.

References Double_t, energy, fEvent, fInputAsciiFile, fPdg, fPx, fPy, fPz, fRunId, GetPdgParticleId(), and WriteoutDecayParticle().

47 {
48 
49  Int_t GiBuuPid = 0, GiBuuCharge = 0;
50  //Int_t runId = 0; //[R.K. 01/2017] unused variable?
51  Int_t motherId1 = 0;
52  Int_t motherId2 = 0;
53  Int_t dummyInt = 0;
54  Double_t mass = 0.;
55  Double_t energy = 0.;
56  Int_t oldEventNr = fEvent;
57  Int_t oldRunId = fRunId;
58 
59  Double_t dummyDouble = 0.;
60 
61  std::cout << "ReadEvent: " << fEvent << std::endl;
62 
63  if (fEvent > 0){
64  WriteoutDecayParticle(oldEventNr, oldRunId, primGen);
65  } else {
66  oldEventNr = 0;
67  oldRunId = 0;
68  fEvent = 0;
69  fRunId = 0;
70  }
71 
72  while (fEvent == oldEventNr && !(fInputAsciiFile->eof())){
73  *fInputAsciiFile >> GiBuuPid >> GiBuuCharge >> motherId1 >> motherId2 >> dummyInt >> mass >> dummyInt >> energy >> fPx >> fPy >> fPz >> dummyDouble >> fEvent >> fRunId >> dummyDouble;
74  if (0 == oldEventNr){
75  oldEventNr = fEvent;
76  oldRunId = fRunId;
77  }
78  fPdg = GetPdgParticleId(GiBuuPid, GiBuuCharge);
79  WriteoutDecayParticle(oldEventNr, oldRunId, primGen);
80  }
81 
82  return kTRUE;
83 }
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Int_t fPdg
Momentum of particle.
Double_t
Int_t fRunId
Event number.
void WriteoutDecayParticle(Int_t oldEventNr, Int_t oldRunId, FairPrimaryGenerator *primGen)
Int_t GetPdgParticleId(Int_t GiBuuId, Int_t charge)
std::ifstream * fInputAsciiFile
Input Pid data file name.
Double_t energy
Definition: plot_dirc.C:15
void PndGiBuuGenerator::RegisterDecayer ( Int_t  pdgCode,
PndGiBuuDecayerAbs decayer 
)
inline

Definition at line 53 of file PndGiBuuGenerator.h.

References fDecayerMap.

53 { fDecayerMap[pdgCode] = decayer; }
std::map< Int_t, PndGiBuuDecayerAbs * > fDecayerMap
void PndGiBuuGenerator::WriteoutDecayParticle ( Int_t  oldEventNr,
Int_t  oldRunId,
FairPrimaryGenerator *  primGen 
)
private

Definition at line 85 of file PndGiBuuGenerator.cxx.

References fDecayerMap, fEvent, fPdg, fPx, fPy, fPz, fRunId, i, X, Y, and Z.

Referenced by ReadEvent().

86 {
87  if (fEvent == oldEventNr && fRunId == oldRunId) {
88  if (fDecayerMap.count(fPdg) > 0) {
89  std::vector<PndGiBuuTrack> tracks = fDecayerMap[fPdg]->DecayTrack(PndGiBuuTrack(fPdg, fPx, fPy, fPz, 0., 0., 0.));
90  for (size_t i = 0; i < tracks.size(); i++) {
91  std::cout << "Writing decayed particles: " << tracks[i].GetPdgId() << std::endl;
92  primGen->AddTrack(tracks[i].GetPdgId(),
93  tracks[i].GetMomentum().X(), tracks[i].GetMomentum().Y(), tracks[i].GetMomentum().Z(),
94  tracks[i].GetVertex().X(), tracks[i].GetVertex().Y(), tracks[i].GetVertex().Z());
95  }
96  } else {
97  std::cout << "Writing particle direct: " << fPdg << std::endl;
98  primGen->AddTrack(fPdg, fPx, fPy, fPz, 0., 0., 0.);
99  }
100  }
101 }
Int_t i
Definition: run_full.C:25
double Y
Definition: anaLmdDigi.C:68
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Int_t fPdg
Momentum of particle.
Int_t fRunId
Event number.
double X
Definition: anaLmdDigi.C:68
double Z
Definition: anaLmdDigi.C:68
std::map< Int_t, PndGiBuuDecayerAbs * > fDecayerMap

Member Data Documentation

std::map<Int_t, PndGiBuuDecayerAbs*> PndGiBuuGenerator::fDecayerMap
private

Definition at line 74 of file PndGiBuuGenerator.h.

Referenced by RegisterDecayer(), WriteoutDecayParticle(), and ~PndGiBuuGenerator().

Int_t PndGiBuuGenerator::fEvent
private

Definition at line 68 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().

TString PndGiBuuGenerator::fFileName
private

Run number in GiBuu.

Definition at line 70 of file PndGiBuuGenerator.h.

Referenced by Init().

std::ifstream* PndGiBuuGenerator::fInputAsciiFile
private

Input Pid data file name.

Definition at line 72 of file PndGiBuuGenerator.h.

Referenced by CloseInput(), Init(), and ReadEvent().

std::map<std::pair<Int_t, Int_t>, Int_t > PndGiBuuGenerator::fMapGiBuuToPdg
private

Definition at line 66 of file PndGiBuuGenerator.h.

Referenced by FillPidMap(), and GetPdgParticleId().

Int_t PndGiBuuGenerator::fPdg
private

Momentum of particle.

Definition at line 77 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().

TString PndGiBuuGenerator::fPidDataFileName
private

Input file name.

Definition at line 71 of file PndGiBuuGenerator.h.

Referenced by FillPidMap().

Double_t PndGiBuuGenerator::fPx
private

Definition at line 76 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().

Double_t PndGiBuuGenerator::fPy
private

Definition at line 76 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().

Double_t PndGiBuuGenerator::fPz
private

Definition at line 76 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().

Int_t PndGiBuuGenerator::fRunId
private

Event number.

Definition at line 69 of file PndGiBuuGenerator.h.

Referenced by ReadEvent(), and WriteoutDecayParticle().


The documentation for this class was generated from the following files: