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 **************************************************************************/
18 Revision 1.9 2000/06/14 15:20:09 morsch
21 Revision 1.8 2000/06/09 20:36:44 morsch
22 All coding rule violations except RS3 corrected
24 Revision 1.7 2000/02/16 14:56:27 morsch
25 Convert geant particle code into pdg code before putting particle on the stack.
27 Revision 1.6 1999/11/09 07:38:48 fca
28 Changes for compatibility with version 2.23 of ROOT
30 Revision 1.5 1999/09/29 09:24:12 fca
31 Introduction of the Copyright and cvs Log
37 #include "AliGenExtFile.h"
41 #include <TDirectory.h>
45 ClassImp(AliGenExtFile)
46 AliGenExtFile::AliGenExtFile()
51 fTitle="Primaries from ext. File";
52 fFileName="dtujet93.root";
60 AliGenExtFile::AliGenExtFile(Int_t npart)
65 fTitle="Primaries from ext. File";
66 fFileName="dtujet93.root";
71 AliGenExtFile::AliGenExtFile(const AliGenExtFile & ExtFile)
75 //____________________________________________________________
76 AliGenExtFile::~AliGenExtFile()
82 //____________________________________________________________
83 void AliGenExtFile::NtupleInit()
86 // reset the existing file environment and open a new root file if
87 // the pointer to the Fluka tree is null
92 pFile = new TFile(fFileName);
94 cout<<"I have opened "<<fFileName<<" file "<<endl;
96 // get the tree address in the Fluka boundary source file
97 fTreeNtuple = (TTree*)gDirectory->Get("h888");
99 pFile = fTreeNtuple->GetCurrentFile();
103 TTree *h2=fTreeNtuple;
104 //Set branch addresses
105 //Set branch addresses
106 h2->SetBranchAddress("Nihead",&fNihead);
107 h2->SetBranchAddress("Ihead",fIhead);
108 h2->SetBranchAddress("Nrhead",&fNrhead);
109 h2->SetBranchAddress("Rhead",fRhead);
110 h2->SetBranchAddress("Idpart",&fIdpart);
111 h2->SetBranchAddress("Theta",&fTheta);
112 h2->SetBranchAddress("Phi",&fPhi);
113 h2->SetBranchAddress("P",&fP);
114 h2->SetBranchAddress("E",&fE);
118 //____________________________________________________________
119 void AliGenExtFile::Generate()
121 // Generate particles
123 Float_t polar[3]= {0,0,0};
125 Float_t origin[3]={0,0,0};
129 Int_t i, j, nt, nTracks=0;
132 TTree *h2=fTreeNtuple;
133 Int_t nentries = (Int_t) h2->GetEntries();
134 // loop over number of particles
135 Int_t nb = (Int_t)h2->GetEvent(fNcurrent);
139 for (j=0;j<3;j++) origin[j]=fOrigin[j];
140 if(fVertexSmear==kPerTrack) {
143 origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
144 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
148 if (fNcurrent >= nentries) {
149 printf("\n No more entries !!! !\n");
155 printf("\n This should never happen !\n");
157 printf("\n Next event contains %d tracks! \n", i6);
160 for (i=0; i<nTracks; i++) {
161 fIdpart=gMC->PDGFromId(fIdpart);
162 Double_t amass = TDatabasePDG::Instance()->GetParticle(fIdpart)->Mass();
164 Warning("Generate","Particle %d no %d E = %f mass = %f\n",
168 prwn=sqrt((fE+amass)*(fE-amass));
171 fTheta *= TMath::Pi()/180.;
172 fPhi = (fPhi-180)*TMath::Pi()/180.;
173 if(fTheta<fThetaMin || fTheta>fThetaMax ||
174 fPhi<fPhiMin || fPhi>fPhiMax ||
175 prwn<fPMin || prwn>fPMax)
179 p[0]=prwn*TMath::Sin(fTheta)*TMath::Cos(fPhi);
180 p[1]=prwn*TMath::Sin(fTheta)*TMath::Sin(fPhi);
181 p[2]=prwn*TMath::Cos(fTheta);
183 if(fVertexSmear==kPerTrack) {
187 +fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
188 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
191 gAlice->SetTrack(fTrackIt,-1,fIdpart,p,origin,polar,0,"Primary",nt);
194 nb = (Int_t)h2->GetEvent(fNcurrent);
198 // Get AliRun object or create it
200 gAlice = (AliRun*)pFile->Get("gAlice");
201 if (gAlice) printf("AliRun object found on file\n");
202 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
204 TTree *fAli=gAlice->TreeK();
205 if (fAli) pFile =fAli->GetCurrentFile();
210 AliGenExtFile& AliGenExtFile::operator=(const AliGenExtFile& rhs)
212 // Assignment operator