1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // Class to read events from external (TNtupla) file
18 // Events -> neutron removal by EM dissociation of Pb nuclei
19 // Data from RELDIS code (by I. Pshenichov)
22 #include <TParticle.h>
24 #include <TVirtualMC.h>
25 #include <TDatabasePDG.h>
28 #include "AliGenReaderEMD.h"
30 ClassImp(AliGenReaderEMD)
32 AliGenReaderEMD::AliGenReaderEMD():
48 // Default constructor
51 AliGenReaderEMD::AliGenReaderEMD(const AliGenReaderEMD &reader):
71 // -----------------------------------------------------------------------------------
72 AliGenReaderEMD::~AliGenReaderEMD()
77 // -----------------------------------------------------------------------------------
78 AliGenReaderEMD& AliGenReaderEMD::operator=(const AliGenReaderEMD& rhs)
80 // Assignment operator
85 // -----------------------------------------------------------------------------------
86 void AliGenReaderEMD::Copy(TObject&) const
91 Fatal("Copy","Not implemented!\n");
94 // -----------------------------------------------------------------------------------
95 void AliGenReaderEMD::Init()
98 // Reset the existing file environment and open a new root file
102 pFile = new TFile(fFileName);
104 printf("\n %s file opened\n\n", fFileName);
106 fTreeNtuple = (TTree*)gDirectory->Get("h2032");
107 fNcurrent = fStartEvent;
109 TTree *Ntu=fTreeNtuple;
111 // Set branch addresses
113 Ntu->SetBranchAddress("Nleft",&fNnLeft);
114 Ntu->SetBranchAddress("Eleft",&fEnLeft);
115 Ntu->SetBranchAddress("Pxl", fPxnLeft);
116 Ntu->SetBranchAddress("Pyl", fPynLeft);
117 Ntu->SetBranchAddress("Pzl", fPznLeft);
118 Ntu->SetBranchAddress("Nright",&fNnRight);
119 Ntu->SetBranchAddress("Eright",&fEnRight);
120 Ntu->SetBranchAddress("Pxr", fPxnRight);
121 Ntu->SetBranchAddress("Pyr", fPynRight);
122 Ntu->SetBranchAddress("Pzr", fPznRight);
124 Ntu->SetBranchAddress("Nleft_p",&fNpLeft);
125 Ntu->SetBranchAddress("Etaleft_p",&fEtapLeft);
126 Ntu->SetBranchAddress("Pxl_p", fPxpLeft);
127 Ntu->SetBranchAddress("Pyl_p", fPypLeft);
128 Ntu->SetBranchAddress("Pzl_p", fPzpLeft);
129 Ntu->SetBranchAddress("Nright_p",&fNpRight);
130 Ntu->SetBranchAddress("Etaright_p",&fEtapRight);
131 Ntu->SetBranchAddress("Pxr_p", fPxpRight);
132 Ntu->SetBranchAddress("Pyr_p", fPypRight);
133 Ntu->SetBranchAddress("Pzr_p", fPzpRight);
136 // -----------------------------------------------------------------------------------
137 Int_t AliGenReaderEMD::NextEvent()
139 // Read the next event
142 TFile* pFile = fTreeNtuple->GetCurrentFile();
146 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
147 if(fNcurrent < nentries) {
148 fTreeNtuple->GetEvent(fNcurrent);
149 printf("\n *** Event %d read ***\n\n",fNcurrent);
151 //printf("\n \t \t LEFT-> %d neutrons and %d protons emitted\n", fNnLeft, fNpLeft);
152 //printf("\t \t RIGHT-> %d neutrons and %d protons emitted\n\n", fNnRight, fNpRight);
154 // **** IPSIde =0->RIGHT side, =1->LEFT side
155 // #### fPcToTrack =0->neutrons, =1->protons
158 printf("\n \t \t Tracking %d neutrons emitted on RIGHT side\n\n", fNnRight);
161 else if(fPcToTrack==1){
162 printf("\n \t \t Tracking %d protons emitted on RIGHT side\n\n", fNpRight);
168 printf("\n \t \t Tracking %d neutrons emitted on LEFT side\n", fNnLeft);
171 else if(fPcToTrack==1){
172 printf("\n \t \t Tracking %d protons emitted on LEFT side\n", fNpLeft);
183 // -----------------------------------------------------------------------------------
184 TParticle* AliGenReaderEMD::NextParticle()
186 // Read the next particle
188 Int_t ipart = kNeutron;
189 Double_t amass = TDatabasePDG::Instance()->GetParticle(kNeutron)->Mass();
190 p[0] = fPxnRight[fNparticle];
191 p[1] = fPynRight[fNparticle];
192 p[2] = fPznRight[fNparticle];
193 Float_t ptot = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
194 p[3] = TMath::Sqrt(ptot*ptot+amass*amass);
195 //printf("\t Nucleon momentum: px = %f, py = %f, pz = %f\n", p[0],p[1],p[2]);
198 Warning("Generate","Particle %d E = %f mass = %f \n",ipart,p[3],amass);
200 TParticle* particle = new TParticle(ipart, 0, -1, -1, -1, -1,
201 p[0], p[1], p[2], p[3], 0., 0., 0., 0.);