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

#include <PndDpmGenerator.h>

Inheritance diagram for PndDpmGenerator:

Public Member Functions

 PndDpmGenerator ()
 
 PndDpmGenerator (const Char_t *fileName)
 
virtual ~PndDpmGenerator ()
 
virtual Bool_t ReadEvent (FairPrimaryGenerator *primGen)
 
void SetStartEvent (Int_t start)
 

Private Member Functions

void CloseInput ()
 Particle array from PLUTO. More...
 
 ClassDef (PndDpmGenerator, 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 PndDpmGenerator.h.

Constructor & Destructor Documentation

PndDpmGenerator::PndDpmGenerator ( )

Default constructor (should not be used)

Definition at line 22 of file PndDpmGenerator.cxx.

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

Standard constructor

Parameters
fileNameThe input (PLUTO) file name

Definition at line 32 of file PndDpmGenerator.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 }
TClonesArray * fParticles
Pointer to input tree.
TFile * fInputFile
Input file name.
const Char_t * fFileName
Event number.
TTree * fInputTree
Pointer to input file.
PndDpmGenerator::~PndDpmGenerator ( )
virtual

Destructor

Definition at line 45 of file PndDpmGenerator.cxx.

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

Member Function Documentation

PndDpmGenerator::ClassDef ( PndDpmGenerator  ,
 
)
private
void PndDpmGenerator::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 PndDpmGenerator.cxx.

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

References Double_t, fParticles, g, and pz.

53  {
54 
55  // Check for input file
56  if ( ! fInputFile ) {
57  cout << "-E PndDpmGenerator: 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 PndDpmGenerator: 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 PndDpmGenerator: 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 }
TClonesArray * fParticles
Pointer to input tree.
TFile * g
void CloseInput()
Particle array from PLUTO.
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
TFile * fInputFile
Input file name.
Double_t
TTree * fInputTree
Pointer to input file.
double pz[39]
Definition: pipisigmas.h:14
void PndDpmGenerator::SetStartEvent ( Int_t  start)
inline

Definition at line 54 of file PndDpmGenerator.h.

References iEvent.

54 { iEvent = start; };

Member Data Documentation

const Char_t* PndDpmGenerator::fFileName
private

Event number.

Definition at line 59 of file PndDpmGenerator.h.

TFile* PndDpmGenerator::fInputFile
private

Input file name.

Definition at line 60 of file PndDpmGenerator.h.

TTree* PndDpmGenerator::fInputTree
private

Pointer to input file.

Definition at line 61 of file PndDpmGenerator.h.

TClonesArray* PndDpmGenerator::fParticles
private

Pointer to input tree.

Definition at line 62 of file PndDpmGenerator.h.

Int_t PndDpmGenerator::iEvent
private

Definition at line 54 of file PndDpmGenerator.h.

Referenced by SetStartEvent().


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