BmnRoot
Loading...
Searching...
No Matches
FairPlutoReactionGenerator.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- FairPlutoReactionGenerator header file -----
3// ----- Created 05/07/08 by I. Froehlich -----
4// -------------------------------------------------------------------------
5
6
7
9
10#include "FairPrimaryGenerator.h"
11
12#include "TClonesArray.h"
13#include "TDatabasePDG.h"
14#include "TFile.h"
15#include "TLorentzVector.h"
16#include "TTree.h"
17#include "TVector3.h"
18
19#include <iostream>
20
21
22// ----- Default constructor ------------------------------------------
24{
25 iEvent = 0;
26 fReaction = NULL;
27#ifdef PLUTOVERSION_FOR_FAIR
28 fPlutoFairGenerator = NULL;
29#endif
30}
31// ------------------------------------------------------------------------
32
33
34
35// ----- Standard constructor -----------------------------------------
37{
38 iEvent = 0;
39 fReaction = reaction;
40#ifdef PLUTOVERSION_FOR_FAIR
41 fPlutoFairGenerator = new PFairGenerator();
42 if (!reaction) {
43 std::cout << "-E FairPlutoReactionGenerator: No PReaction!" << std::endl;
44 } else {
45 reaction->AddBulk(fPlutoFairGenerator);
46 reaction->IsInline();
47 }
48#else
49 std::cout << "-E FairPlutoReactionGenerator: You are using the wrong Pluto version" << std::endl;
50#endif
51}
52// ------------------------------------------------------------------------
53
54
55
56// ----- Destructor ---------------------------------------------------
58{
59#ifdef PLUTOVERSION_FOR_FAIR
60 if (fPlutoFairGenerator) { delete fPlutoFairGenerator; }
61#endif
62}
63// ------------------------------------------------------------------------
64
65
66
67// ----- Public method ReadEvent --------------------------------------
68Bool_t FairPlutoReactionGenerator::ReadEvent(FairPrimaryGenerator* primGen)
69{
70#ifdef PLUTOVERSION_FOR_FAIR
71
72 // Check for input file
73 if ( ! fReaction ) {
74 cout << "-E FairPlutoReactionGenerator: No PReaction!" << endl;
75 return kFALSE;
76 }
77
78 fReaction->InitChannels();
79 fReaction->DisableWeightReset();
80 if (!fReaction->loop(1,0,0)) { return kFALSE; }
81
82
83 Double_t px, py, pz, vx, vy, vz;
84 Int_t pdgType;
85
86 while (fPlutoFairGenerator->GetNextParticle(&pdgType, &px, &py, &pz, &vx, &vy, &vz)) {
87
88 if (pdgType) {
89 primGen->AddTrack(pdgType, px, py, pz, vx, vy, vz);
90 }
91 }
92
93 return kTRUE;
94#else
95
96 return kFALSE;
97#endif
98}
99// ------------------------------------------------------------------------
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)