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

#include <PndFlukaGenerator.h>

Inheritance diagram for PndFlukaGenerator:

Public Member Functions

 PndFlukaGenerator ()
 
 PndFlukaGenerator (const Char_t *fileName)
 
virtual ~PndFlukaGenerator ()
 
virtual Bool_t ReadEvent (FairPrimaryGenerator *primGen)
 

Protected Member Functions

Bool_t ReadRootEvent (FairPrimaryGenerator *primGen)
 
Bool_t Init ()
 

Private Member Functions

Bool_t SetBranchAddresses ()
 
void CloseInput ()
 number of particles in event More...
 
 ClassDef (PndFlukaGenerator, 2)
 

Private Attributes

Int_t iEvent
 
Int_t iEntry
 Event number. More...
 
TString fFileName
 Root tree entry number. More...
 
TFile * fInputRootFile
 Input file name. More...
 
TTree * fInputTree
 Pointer to input file. More...
 
Double_t fpx
 Pointer to input tree. More...
 
Double_t fpy
 
Double_t fpz
 
Double_t fvx
 Momentum of particle. More...
 
Double_t fvy
 
Double_t fvz
 
Int_t fpid
 Start Vertex of particle. More...
 
Int_t fnpart
 PDG code of particle. More...
 

Detailed Description

Definition at line 31 of file PndFlukaGenerator.h.

Constructor & Destructor Documentation

PndFlukaGenerator::PndFlukaGenerator ( )

Default constructor (should not be used)

Definition at line 29 of file PndFlukaGenerator.cxx.

References fInputRootFile, fInputTree, iEntry, and iEvent.

29  {
30  iEvent = 0;
31  iEntry = 0;
32  fInputRootFile = NULL;
33  fInputTree = NULL;
34 }
TFile * fInputRootFile
Input file name.
TTree * fInputTree
Pointer to input file.
Int_t iEntry
Event number.
PndFlukaGenerator::PndFlukaGenerator ( const Char_t *  fileName)

Standard constructor

Parameters
fileNameThe input root file name

Definition at line 38 of file PndFlukaGenerator.cxx.

References fFileName, Init(), and TString.

38  {
39 
40  fFileName = TString(fileName);
41  Init();
42 
43 }
TString fFileName
Root tree entry number.
PndFlukaGenerator::~PndFlukaGenerator ( )
virtual

Destructor

Definition at line 46 of file PndFlukaGenerator.cxx.

References CloseInput().

46  {
47  CloseInput();
48 
49 }
void CloseInput()
number of particles in event

Member Function Documentation

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

number of particles in event

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

Definition at line 170 of file PndFlukaGenerator.cxx.

References fFileName, and fInputRootFile.

Referenced by ReadRootEvent(), and ~PndFlukaGenerator().

170  {
171  if (fInputRootFile)
172  {
173  cout << "-I PndFlukaGenerator: Closing ROOT input file " << fFileName.Data() << endl;
174  fInputRootFile->Close();
175  delete fInputRootFile;
176  fInputRootFile = NULL;
177  }
178 }
TFile * fInputRootFile
Input file name.
TString fFileName
Root tree entry number.
Bool_t PndFlukaGenerator::Init ( )
protected

Definition at line 52 of file PndFlukaGenerator.cxx.

References fFileName, fInputRootFile, fInputTree, iEntry, iEvent, and SetBranchAddresses().

Referenced by PndFlukaGenerator().

53 {
54  iEvent = 0;
55  iEntry = 0;
56 
57  cout << "-I PndFlukaGenerator: Opening input file " << fFileName.Data() << endl;
58 
59  // open ROOT input file
60 
61  fInputRootFile = new TFile(fFileName,"READ");
62  if (fInputRootFile->IsZombie())
63  Fatal("PndFlukaGenerator","Cannot open ROOT input file.");
64 
65  fInputTree = (TTree*) fInputRootFile->Get("ResultsTree");
66  if (!SetBranchAddresses())
67  Fatal("PndFlukaGenerator","Incompatible ROOT input file!");
68  return kTRUE;
69 }
TFile * fInputRootFile
Input file name.
TTree * fInputTree
Pointer to input file.
TString fFileName
Root tree entry number.
Int_t iEntry
Event number.
Bool_t PndFlukaGenerator::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 110 of file PndFlukaGenerator.cxx.

References fInputRootFile, and ReadRootEvent().

111 {
112  if ( ! fInputRootFile ) {
113  cout << "-E PndFlukaGenerator: Input ROOT file not open!" << endl;
114  return kFALSE;
115  }
116 
117  return ReadRootEvent(primGen);
118 
119 
120 }
TFile * fInputRootFile
Input file name.
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Bool_t ReadRootEvent(FairPrimaryGenerator *primGen)
Bool_t PndFlukaGenerator::ReadRootEvent ( FairPrimaryGenerator *  primGen)
protected

Definition at line 125 of file PndFlukaGenerator.cxx.

References CloseInput(), fInputRootFile, fInputTree, fnpart, fpid, fpx, fpy, fpz, fvx, fvy, fvz, g, and iEntry.

Referenced by ReadEvent().

126 {
127  // Check for number of events in input file
128 
129  //Int_t nentries = fInputTree->GetEntries(); //[R.K. 01/2017] unused variable?
130 
131  if ( iEntry > fInputTree->GetEntries() ) {
132  cout << "-E PndFlukaGenerator: No more events in input file!" << endl;
133  CloseInput();
134  return kFALSE;
135  }
136 
137  // preserve orginal TDirectory
138  TFile *g=gFile;
139  fInputRootFile->cd();
140  g->cd();
141 
142  Int_t evmul=0;
143 
144  do
145  {
146  fInputTree->GetEntry(iEntry);
147 
148  evmul++;
149 
150  if ( fnpart < evmul ){
151  break;
152  }
153 
154 // cout << "Pid= " << fpid << endl;
155 // cout << "momentum " << fpx << " " << fpy << " " << fpz <<endl;
156 // cout << "vertex " << fvx << " " << fvy << " " << fvz <<endl;
157 
158  primGen->AddTrack(fpid,fpx,fpy,fpz,fvx,fvy,fvz);
159 
160  iEntry++;
161 
162  } while (evmul <= fnpart);
163 
164  return kTRUE;
165 
166 }
void CloseInput()
number of particles in event
TFile * fInputRootFile
Input file name.
Double_t fpx
Pointer to input tree.
Int_t fnpart
PDG code of particle.
TFile * g
TTree * fInputTree
Pointer to input file.
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Double_t fvx
Momentum of particle.
Int_t fpid
Start Vertex of particle.
Int_t iEntry
Event number.
Bool_t PndFlukaGenerator::SetBranchAddresses ( )
private

Definition at line 73 of file PndFlukaGenerator.cxx.

References fInputTree, fnpart, fpid, fpx, fpy, fpz, fvx, fvy, and fvz.

Referenced by Init().

74 {
75  if (0==fInputTree) return false;
76 
77  fInputTree->SetMakeClass(1);
78 
79  fInputTree->SetBranchStatus("*",0);
80 
81  fInputTree->SetBranchStatus("Npart",1);
82  // fInputTree->SetBranchStatus("Weight",1);
83  fInputTree->SetBranchStatus("pid",1);
84  // fInputTree->SetBranchStatus("NofInt",1);
85  // fInputTree->SetBranchStatus("etot",1);
86  // fInputTree->SetBranchStatus("ptot",1);
87  fInputTree->SetBranchStatus("px",1);
88  fInputTree->SetBranchStatus("py",1);
89  fInputTree->SetBranchStatus("pz",1);
90  // fInputTree->SetBranchStatus("time",1);
91  fInputTree->SetBranchStatus("xx",1);
92  fInputTree->SetBranchStatus("yy",1);
93  fInputTree->SetBranchStatus("zz",1);
94 
95 
96  fInputTree->SetBranchAddress("Npart",&fnpart);
97  fInputTree->SetBranchAddress("pid",&fpid);
98  fInputTree->SetBranchAddress("px",&fpx);
99  fInputTree->SetBranchAddress("py",&fpy);
100  fInputTree->SetBranchAddress("pz",&fpz);
101  fInputTree->SetBranchAddress("xx",&fvx);
102  fInputTree->SetBranchAddress("yy",&fvy);
103  fInputTree->SetBranchAddress("zz",&fvz);
104 
105 
106  return true;
107 }
Double_t fpx
Pointer to input tree.
Int_t fnpart
PDG code of particle.
TTree * fInputTree
Pointer to input file.
Double_t fvx
Momentum of particle.
Int_t fpid
Start Vertex of particle.

Member Data Documentation

TString PndFlukaGenerator::fFileName
private

Root tree entry number.

Definition at line 64 of file PndFlukaGenerator.h.

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

TFile* PndFlukaGenerator::fInputRootFile
private

Input file name.

Definition at line 65 of file PndFlukaGenerator.h.

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

TTree* PndFlukaGenerator::fInputTree
private

Pointer to input file.

Definition at line 66 of file PndFlukaGenerator.h.

Referenced by Init(), PndFlukaGenerator(), ReadRootEvent(), and SetBranchAddresses().

Int_t PndFlukaGenerator::fnpart
private

PDG code of particle.

Definition at line 71 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Int_t PndFlukaGenerator::fpid
private

Start Vertex of particle.

Definition at line 70 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fpx
private

Pointer to input tree.

Definition at line 68 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fpy
private

Definition at line 68 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fpz
private

Definition at line 68 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fvx
private

Momentum of particle.

Definition at line 69 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fvy
private

Definition at line 69 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Double_t PndFlukaGenerator::fvz
private

Definition at line 69 of file PndFlukaGenerator.h.

Referenced by ReadRootEvent(), and SetBranchAddresses().

Int_t PndFlukaGenerator::iEntry
private

Event number.

Definition at line 63 of file PndFlukaGenerator.h.

Referenced by Init(), PndFlukaGenerator(), and ReadRootEvent().

Int_t PndFlukaGenerator::iEvent
private

Definition at line 62 of file PndFlukaGenerator.h.

Referenced by Init(), and PndFlukaGenerator().


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