BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
Mpd3fdGenerator.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- Mpd3fdGenerator source file -----
3// ----- Created 24/06/04 by V. Friese -----
4// -------------------------------------------------------------------------
5#include "Mpd3fdGenerator.h"
6
7#include "FairMCEventHeader.h"
8#include "FairPrimaryGenerator.h"
9#include "TDatabasePDG.h"
10#include "TLorentzVector.h"
11#include "TMCProcess.h"
12#include "TMath.h"
13#include "TObjArray.h"
14#include "TPDGCode.h"
15#include "TParticle.h"
16#include "TParticlePDG.h"
17#include "TRandom.h"
18#include "TString.h"
19#include "TVirtualMCStack.h"
20#include "constants.h"
21
22#include <cstring>
23#include <iostream>
24#include <stdio.h>
25
26using namespace std;
27using namespace TMath;
28
29// ----- Default constructor ------------------------------------------
30
36// ------------------------------------------------------------------------
37
38// ----- Standard constructor -----------------------------------------
39
42 , fInputFile(NULL)
43 , fFileName(fileName)
44{
45 // fFileName = fileName;
46 cout << "-I Mpd3fdGenerator: Opening input file " << fFileName << endl;
47 fInputFile = new TFile(fFileName.Data());
48 if (!fInputFile) {
49 Fatal("Mpd3fdGenerator", "Cannot open input file.");
50 exit(1);
51 }
52 fDstTree = new TChain("out");
53 fDstTree->Add(fFileName);
54
55 // // Activate branches
56 fDstTree->SetBranchAddress("px", fPx);
57 fDstTree->SetBranchAddress("py", fPy);
58 fDstTree->SetBranchAddress("pz", fPz);
59 fDstTree->SetBranchAddress("x", fX);
60 fDstTree->SetBranchAddress("y", fY);
61 fDstTree->SetBranchAddress("z", fZ);
62 fDstTree->SetBranchAddress("E", fE);
63 fDstTree->SetBranchAddress("npart", &fNpart);
64 fDstTree->SetBranchAddress("id", fPID);
65
66 fEventNumber = 0;
67}
68// ------------------------------------------------------------------------
69
70// ----- Destructor ---------------------------------------------------
71
77// ------------------------------------------------------------------------
78
79// ----- Public method ReadEvent --------------------------------------
80
81Bool_t Mpd3fdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
82{
83
84 // ---> Check for input file
85 if (!fInputFile) {
86 cout << "-E Mpd3fdGenerator: Input file not open! " << endl;
87 return kFALSE;
88 }
89
90 // ---> Check for primary generator
91 if (!primGen) {
92 cout << "-E- Mpd3fdGenerator::ReadEvent: "
93 << "No PrimaryGenerator!" << endl;
94 return kFALSE;
95 }
96
97 fDstTree->GetEntry(fEventNumber);
98
99 // Int_t events = fDstTree->GetEntries();
100
101 // ---> Define event variables to be read from file
102 Int_t evnr = 0 /*, aProj = 0, zProj = 0, aTarg = 0, zTarg = 0*/;
103
104 // Char_t nucl1;
105 // Char_t nucl2;
106 Int_t energ;
107 TString name;
108
109 if (fFileName.Contains("Au")) {
110 // aProj = 197;
111 // zProj = 79;
112 // aTarg = 197;
113 // zTarg = 79;
114 sscanf(fFileName.Data(), "Au_%d_", &energ);
115 }
116
117 cout << fFileName << " " << energ << endl;
118
119 Float_t b = 0.0; // TMP!
120
121 // ---> Calculate beta and gamma for Lorentztransformation
122 /*TDatabasePDG* pdgDB = TDatabasePDG::Instance();
123 TParticlePDG* kProton = pdgDB->GetParticle(2212);
124 Double_t kProtonMass = kProton->Mass();
125
126 Double_t eBeam = energ + kProtonMass;
127 Double_t pBeam = TMath::Sqrt(eBeam * eBeam - kProtonMass * kProtonMass);
128 Double_t betaCM = pBeam / (eBeam + kProtonMass);
129 Double_t gammaCM = TMath::Sqrt(1. / (1. - betaCM * betaCM));
130 */
131 cout << "-I Mpd3fdGenerator: Event " << fEventNumber << ", b = " << b << " fm, multiplicity " << fNpart
132 << ", Elab: " << energ << endl;
133
134 // Set event id and impact parameter in MCEvent if not yet done
135 FairMCEventHeader* event = primGen->GetEvent();
136 if (event && (!event->IsSet())) {
137 event->SetEventID(evnr);
138 event->SetB(b);
139 event->MarkSet(kTRUE);
140 }
141
142 // ---> Loop over tracks in the current event
143 for (UInt_t itrack = 0; itrack < fNpart; itrack++) {
144
145 // Lorentztransformation to lab
146 // Double_t px = fPx[itrack];
147 // Double_t py = fPy[itrack];
148 // Double_t pz = fPz[itrack];
149 // Double_t e = fE[itrack];
150 // Double_t mass = Sqrt(e * e - px * px - py * py - pz * pz);
151 // if (gCoordinateSystem == sysLaboratory)
152 // pz = gammaCM * (pz + betaCM * e);
153 // Double_t ee = sqrt(mass * mass + px * px + py * py + pz * pz);
154
155 // Give track to PrimaryGenerator
156 primGen->AddTrack(fPID[itrack], fPx[itrack], fPy[itrack], fPz[itrack], fX[itrack], fY[itrack], fZ[itrack]);
157 }
158 fEventNumber++;
159
160 return kTRUE;
161}
bool Bool_t
int Int_t
float Float_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
void Fatal(const char *location, const char *msgfmt,...)
TChain * fDstTree
Input file name.
Bool_t ReadEvent(FairPrimaryGenerator *primGen)
TString fFileName
Input file.
Double_t fPy[kBatyukConst]
Mpd3fdGenerator()
Default constructor without arguments should not be used.
Double_t fX[kBatyukConst]
Double_t fPz[kBatyukConst]
Double_t fY[kBatyukConst]
Double_t fZ[kBatyukConst]
Double_t fPx[kBatyukConst]
~Mpd3fdGenerator()
Destructor.
Double_t fE[kBatyukConst]
Int_t fPID[kBatyukConst]
Definition json.hpp:4446