FairShip
Loading...
Searching...
No Matches
Pythia6Generator Class Reference

#include <Pythia6Generator.h>

Inheritance diagram for Pythia6Generator:
Collaboration diagram for Pythia6Generator:

Public Member Functions

 Pythia6Generator ()
 
 Pythia6Generator (const char *fileName)
 
 ~Pythia6Generator () override
 
Bool_t ReadEvent (FairPrimaryGenerator *primGen) override
 
void SetVerbose (Int_t verb)
 
- Public Member Functions inherited from SHiP::Generator
 Generator ()
 
virtual ~Generator ()
 
virtual Bool_t Init (const char *, int)=0
 
virtual Bool_t Init (const char *)=0
 
virtual Bool_t Init (const std::vector< std::string > &inFiles, int startNumber)
 
virtual Bool_t Init (const std::vector< std::string > &inFiles)
 
virtual void UseExternalFile (std::string x, Int_t i)
 
virtual void UseExternalFile (std::vector< std::string > &inFiles, Int_t i)
 

Private Member Functions

void CloseInput ()
 Verbose Level.
 

Private Attributes

const Char_t * fFileName
 
FILE * fInputFile
 Input file Name.
 
Int_t fVerbose
 File.
 

Additional Inherited Members

- Protected Attributes inherited from SHiP::Generator
std::optional< std::string > fextFile
 
Int_t firstEvent = 0
 

Detailed Description

Definition at line 93 of file Pythia6Generator.h.

Constructor & Destructor Documentation

◆ Pythia6Generator() [1/2]

Pythia6Generator::Pythia6Generator ( )

Default constructor without arguments should not be used.

Definition at line 21 of file Pythia6Generator.cxx.

21{}

◆ Pythia6Generator() [2/2]

Pythia6Generator::Pythia6Generator ( const char *  fileName)
explicit

Standard constructor.

Parameters
fileNameThe input file name

Definition at line 25 of file Pythia6Generator.cxx.

25 {
26 fFileName = fileName;
27 fVerbose = 0;
28 cout << "-I Pythia6Generator: Opening input file " << fileName << endl;
29 fInputFile = fopen(fFileName, "r");
30 if (fInputFile == nullptr)
31 // fInputFile = new ifstream(fFileName);
32 // if ( ! fInputFile->is_open() )
33 Fatal("Pythia6Generator", "Cannot open input file.");
34
35 // fPDG=TDatabasePDG::Instance();
36}
FILE * fInputFile
Input file Name.
const Char_t * fFileName

◆ ~Pythia6Generator()

Pythia6Generator::~Pythia6Generator ( )
override

Destructor.

Definition at line 40 of file Pythia6Generator.cxx.

40{ CloseInput(); }
void CloseInput()
Verbose Level.

Member Function Documentation

◆ CloseInput()

void Pythia6Generator::CloseInput ( )
private

Verbose Level.

Private method CloseInput. Just for convenience. Closes the input file properly. Called from destructor and from ReadEvent.

Definition at line 103 of file Pythia6Generator.cxx.

103 {
104 if (fInputFile) {
105 // if ( fInputFile->is_open() ) {
106 {
107 cout << "-I Pythia6Generator: Closing input file " << fFileName << endl;
108 // fInputFile->close();
109
110 fclose(fInputFile);
111 }
112 delete fInputFile;
113 fInputFile = nullptr;
114 }
115}

◆ ReadEvent()

Bool_t Pythia6Generator::ReadEvent ( FairPrimaryGenerator *  primGen)
override

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

Parameters
primGenpointer to the CbmrimaryGenerator

Definition at line 44 of file Pythia6Generator.cxx.

44 {
45 // Check for input file
46 if (!fInputFile) {
47 // if ( ! fInputFile->is_open() ) {
48 cout << "-E Pythia6Generator: Input file not open!" << endl;
49 return kFALSE;
50 }
51
52 // Define event variable to be read from file
53 Int_t ntracks = 0, eventID = 0, ncols = 0;
54
55 // Define track variables to be read from file
56 Int_t nLev = 0, pdgID = 0, nM1 = -1, nM2 = -1, nDF = -1, nDL = -1;
57 Float_t fPx = 0., fPy = 0., fPz = 0., fM = 0., fE = 0.;
58 Float_t fVx = 0., fVy = 0., fVz = 0., fT = 0.;
59
60 // Read event header line from input file
61
62 ncols = fscanf(fInputFile, "%d\t%d", &eventID, &ntracks);
63
64 if (ncols && ntracks > 0) {
65 if (fVerbose > 0)
66 cout << "Event number: " << eventID << "\tNtracks: " << ntracks << endl;
67
68 for (Int_t ll = 0; ll < ntracks; ll++) {
69 (void)fscanf(fInputFile, "%d %d %d %d %d %d %f %f %f %f %f %f %f %f %f",
70 &nLev, &pdgID, &nM1, &nM2, &nDF, &nDL, &fPx, &fPy, &fPz, &fE,
71 &fM, &fVx, &fVy, &fVz, &fT);
72 if (fVerbose > 0)
73 cout << nLev << "\t" << pdgID << "\t" << nM1 << "\t" << nM2 << "\t"
74 << nDF << "\t" << nDL << "\t" << fPx << "\t" << fPy << "\t" << fPz
75 << "\t" << fE << "\t" << fM << "\t" << fVx << "\t" << fVy << "\t"
76 << fVz << "\t" << fT << endl;
77 if (nLev == 1) primGen->AddTrack(pdgID, fPx, fPy, fPz, fVx, fVy, fVz);
78 }
79 } else {
80 cout << "-I Pythia6Generator: End of input file reached " << endl;
81 CloseInput();
82 return kFALSE;
83 }
84
85 // If end of input file is reached : close it and abort run
86 if (feof(fInputFile)) {
87 cout << "-I Pythia6Generator: End of input file reached " << endl;
88 CloseInput();
89 return kFALSE;
90 }
91
92 /*
93 cout << "-I Pythia6Generator: Event " << eventID << ", vertex = ("
94 << vx << "," << vy << "," << vz << ") cm, multiplicity "
95 << ntracks << endl;
96 */
97
98 return kTRUE;
99}

◆ SetVerbose()

void Pythia6Generator::SetVerbose ( Int_t  verb)
inline

Definition at line 114 of file Pythia6Generator.h.

114{ fVerbose = verb; };

Member Data Documentation

◆ fFileName

const Char_t* Pythia6Generator::fFileName
private

Definition at line 118 of file Pythia6Generator.h.

◆ fInputFile

FILE* Pythia6Generator::fInputFile
private

Input file Name.

Definition at line 119 of file Pythia6Generator.h.

◆ fVerbose

Int_t Pythia6Generator::fVerbose
private

File.

Definition at line 120 of file Pythia6Generator.h.


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