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

#include <PndJRGenerator.h>

Inheritance diagram for PndJRGenerator:

Public Member Functions

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

Private Member Functions

void CloseInput ()
 Particle array from PLUTO. More...
 
 ClassDef (PndJRGenerator, 1)
 

Private Attributes

Int_t iEvent
 
const Char_t * fFileName
 Event number. More...
 
TFile * fInputFile
 Input file name. More...
 
TTree * fInputTree
 Pointer to input file. More...
 
TClonesArray * fParticles
 Pointer to input tree. More...
 

Detailed Description

Definition at line 29 of file PndJRGenerator.h.

Constructor & Destructor Documentation

PndJRGenerator::PndJRGenerator ( )

Default constructor (should not be used)

Definition at line 22 of file PndJRGenerator.cxx.

22  {
23  iEvent = 0;
24  fInputFile = NULL;
25  fInputTree = NULL;
26 }
TTree * fInputTree
Pointer to input file.
TFile * fInputFile
Input file name.
PndJRGenerator::PndJRGenerator ( const Char_t *  fileName)

Standard constructor

Parameters
fileNameThe input (PLUTO) file name

Definition at line 32 of file PndJRGenerator.cxx.

References fParticles.

32  {
33  iEvent = 0;
34  fFileName = fileName;
35  fInputFile = new TFile(fFileName);
36  fInputTree = (TTree*) fInputFile->Get("data");
37  fParticles = new TClonesArray("TParticle",100);
38  fInputTree->SetBranchAddress("Particles", &fParticles);
39 }
TTree * fInputTree
Pointer to input file.
const Char_t * fFileName
Event number.
TClonesArray * fParticles
Pointer to input tree.
TFile * fInputFile
Input file name.
PndJRGenerator::~PndJRGenerator ( )
virtual

Destructor

Definition at line 45 of file PndJRGenerator.cxx.

45  {
46  CloseInput();
47 }
void CloseInput()
Particle array from PLUTO.

Member Function Documentation

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

Particle array from PLUTO.

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

Definition at line 109 of file PndJRGenerator.cxx.

109  {
110  if ( fInputFile ) {
111  cout << "-I PndJRGenerator: Closing input file " << fFileName
112  << endl;
113  fInputFile->Close();
114  delete fInputFile;
115  }
116  fInputFile = NULL;
117 }
const Char_t * fFileName
Event number.
TFile * fInputFile
Input file name.
Bool_t PndJRGenerator::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 53 of file PndJRGenerator.cxx.

References Double_t, fParticles, g, and pz.

53  {
54 
55  // Check for input file
56  if ( ! fInputFile ) {
57  cout << "-E PndJRGenerator: Input file nor open!" << endl;
58  return kFALSE;
59  }
60 
61  // Check for number of events in input file
62  if ( iEvent > fInputTree->GetEntries() ) {
63  cout << "-E PndJRGenerator: No more events in input file!" << endl;
64  CloseInput();
65  return kFALSE;
66  }
67  TFile *g=gFile;
68  fInputFile->cd();
69  fInputTree->GetEntry(iEvent++);
70  g->cd();
71 
72  // Get number of particle in TClonesrray
73  Int_t nParts = fParticles->GetEntriesFast();
74 
75  // Loop over particles in TClonesArray
76  for (Int_t iPart=0; iPart < nParts; iPart++) {
77  TParticle* part = (TParticle*) fParticles->At(iPart);
78  Int_t pdgType = part->GetPdgCode();
79 
80  // Check if particle type is known to database
81  if ( ! pdgType ) {
82  cout << "-W PndJRGenerator: Unknown type " << part->GetPdgCode()
83  << ", skipping particle." << endl;
84  continue;
85  }
86 
87  Double_t px = part->Px();
88  Double_t py = part->Py();
89  Double_t pz = part->Pz();
90 
91  Double_t vx = part->Vx();
92  Double_t vy = part->Vy();
93  Double_t vz = part->Vz();
94 
95  // Give track to PrimaryGenerator
96  primGen->AddTrack(pdgType, px, py, pz, vx, vy, vz);
97 
98  } // Loop over particle in event
99 
100  return kTRUE;
101 
102 }
TFile * g
TTree * fInputTree
Pointer to input file.
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
Double_t
TClonesArray * fParticles
Pointer to input tree.
void CloseInput()
Particle array from PLUTO.
TFile * fInputFile
Input file name.
double pz[39]
Definition: pipisigmas.h:14

Member Data Documentation

const Char_t* PndJRGenerator::fFileName
private

Event number.

Definition at line 59 of file PndJRGenerator.h.

TFile* PndJRGenerator::fInputFile
private

Input file name.

Definition at line 60 of file PndJRGenerator.h.

TTree* PndJRGenerator::fInputTree
private

Pointer to input file.

Definition at line 61 of file PndJRGenerator.h.

TClonesArray* PndJRGenerator::fParticles
private

Pointer to input tree.

Definition at line 62 of file PndJRGenerator.h.

Int_t PndJRGenerator::iEvent
private

Definition at line 58 of file PndJRGenerator.h.


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