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)
33 // -----------------------------------------------------------------------------------
34 AliGenReaderEMD::AliGenReaderEMD()
36 // Default constructor
43 // -----------------------------------------------------------------------------------
44 AliGenReaderEMD::~AliGenReaderEMD()
49 // -----------------------------------------------------------------------------------
50 AliGenReaderEMD& AliGenReaderEMD::operator=(const AliGenReaderEMD& rhs)
52 // Assignment operator
57 // -----------------------------------------------------------------------------------
58 void AliGenReaderEMD::Copy(TObject&) const
63 Fatal("Copy","Not implemented!\n");
66 // -----------------------------------------------------------------------------------
67 void AliGenReaderEMD::Init()
70 // Reset the existing file environment and open a new root file
74 pFile = new TFile(fFileName);
76 printf("\n %s file opened\n\n", fFileName);
78 fTreeNtuple = (TTree*)gDirectory->Get("h2032");
79 fNcurrent = fStartEvent;
81 TTree *Ntu=fTreeNtuple;
83 // Set branch addresses
85 Ntu->SetBranchAddress("Nleft",&fNnLeft);
86 Ntu->SetBranchAddress("Eleft",&fEnLeft);
87 Ntu->SetBranchAddress("Pxl", fPxnLeft);
88 Ntu->SetBranchAddress("Pyl", fPynLeft);
89 Ntu->SetBranchAddress("Pzl", fPznLeft);
90 Ntu->SetBranchAddress("Nright",&fNnRight);
91 Ntu->SetBranchAddress("Eright",&fEnRight);
92 Ntu->SetBranchAddress("Pxr", fPxnRight);
93 Ntu->SetBranchAddress("Pyr", fPynRight);
94 Ntu->SetBranchAddress("Pzr", fPznRight);
96 Ntu->SetBranchAddress("Nleft_p",&fNpLeft);
97 Ntu->SetBranchAddress("Etaleft_p",&fEtapLeft);
98 Ntu->SetBranchAddress("Pxl_p", fPxpLeft);
99 Ntu->SetBranchAddress("Pyl_p", fPypLeft);
100 Ntu->SetBranchAddress("Pzl_p", fPzpLeft);
101 Ntu->SetBranchAddress("Nright_p",&fNpRight);
102 Ntu->SetBranchAddress("Etaright_p",&fEtapRight);
103 Ntu->SetBranchAddress("Pxr_p", fPxpRight);
104 Ntu->SetBranchAddress("Pyr_p", fPypRight);
105 Ntu->SetBranchAddress("Pzr_p", fPzpRight);
108 // -----------------------------------------------------------------------------------
109 Int_t AliGenReaderEMD::NextEvent()
111 // Read the next event
114 TFile* pFile = fTreeNtuple->GetCurrentFile();
118 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
119 if(fNcurrent < nentries) {
120 fTreeNtuple->GetEvent(fNcurrent);
121 printf("\n *** Event %d read ***\n\n",fNcurrent);
123 //printf("\n \t \t LEFT-> %d neutrons and %d protons emitted\n", fNnLeft, fNpLeft);
124 //printf("\t \t RIGHT-> %d neutrons and %d protons emitted\n\n", fNnRight, fNpRight);
126 // **** IPSIde =0->RIGHT side, =1->LEFT side
127 // #### fPcToTrack =0->neutrons, =1->protons
130 printf("\n \t \t Tracking %d neutrons emitted on RIGHT side\n\n", fNnRight);
133 else if(fPcToTrack==1){
134 printf("\n \t \t Tracking %d protons emitted on RIGHT side\n\n", fNpRight);
140 printf("\n \t \t Tracking %d neutrons emitted on LEFT side\n", fNnLeft);
143 else if(fPcToTrack==1){
144 printf("\n \t \t Tracking %d protons emitted on LEFT side\n", fNpLeft);
155 // -----------------------------------------------------------------------------------
156 TParticle* AliGenReaderEMD::NextParticle()
158 // Read the next particle
160 Int_t ipart = kNeutron;
161 Double_t amass = TDatabasePDG::Instance()->GetParticle(kNeutron)->Mass();
162 p[0] = fPxnRight[fNparticle];
163 p[1] = fPynRight[fNparticle];
164 p[2] = fPznRight[fNparticle];
165 Float_t ptot = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
166 p[3] = TMath::Sqrt(ptot*ptot+amass*amass);
167 //printf("\t Nucleon momentum: px = %f, py = %f, pz = %f\n", p[0],p[1],p[2]);
170 Warning("Generate","Particle %d E = %f mass = %f \n",ipart,p[3],amass);
172 TParticle* particle = new TParticle(ipart, 0, -1, -1, -1, -1,
173 p[0], p[1], p[2], p[3], 0., 0., 0., 0.);