1 #include "AliGenExtFile.h"
2 #include "AliGenMUONlib.h"
5 #include <TDirectory.h>
9 ClassImp(AliGenExtFile)
10 AliGenExtFile::AliGenExtFile()
15 fTitle="Primaries from ext. File";
16 fFileName="dtujet93.root";
24 AliGenExtFile::AliGenExtFile(Int_t npart)
29 fTitle="Primaries from ext. File";
30 fFileName="dtujet93.root";
35 //____________________________________________________________
36 AliGenExtFile::~AliGenExtFile()
41 //____________________________________________________________
42 void AliGenExtFile::NtupleInit()
45 // reset the existing file environment and open a new root file if
46 // the pointer to the Fluka tree is null
51 File = new TFile(fFileName);
53 cout<<"I have opened "<<fFileName<<" file "<<endl;
55 // get the tree address in the Fluka boundary source file
56 fTreeNtuple = (TTree*)gDirectory->Get("h888");
58 File = fTreeNtuple->GetCurrentFile();
62 TTree *h2=fTreeNtuple;
63 //Set branch addresses
64 //Set branch addresses
65 h2->SetBranchAddress("Nihead",&Nihead);
66 h2->SetBranchAddress("Ihead",Ihead);
67 h2->SetBranchAddress("Nrhead",&Nrhead);
68 h2->SetBranchAddress("Rhead",Rhead);
69 h2->SetBranchAddress("Idpart",&Idpart);
70 h2->SetBranchAddress("Theta",&Theta);
71 h2->SetBranchAddress("Phi",&Phi);
72 h2->SetBranchAddress("P",&P);
73 h2->SetBranchAddress("E",&E);
77 //____________________________________________________________
78 void AliGenExtFile::Generate()
81 Float_t polar[3]= {0,0,0};
83 Float_t origin[3]={0,0,0};
88 Float_t amass, charge, tlife;
90 Int_t i, j, nt, Ntracks=0;
93 TTree *h2=fTreeNtuple;
94 Int_t nentries = (Int_t) h2->GetEntries();
95 // loop over number of particles
96 Int_t nb = (Int_t)h2->GetEvent(fNcurrent);
100 for (j=0;j<3;j++) origin[j]=fOrigin[j];
101 if(fVertexSmear==perEvent) {
104 origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
105 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
109 if (fNcurrent >= nentries) {
110 printf("\n No more entries !!! !\n");
116 printf("\n This should never happen !\n");
118 printf("\n Next event contains %d tracks! \n", i6);
121 for (i=0; i<Ntracks; i++) {
123 gMC->Gfpart(Idpart, name, itrtyp,amass, charge, tlife);
124 prwn=sqrt((E+amass)*(E-amass));
126 Theta *= TMath::Pi()/180.;
127 Phi = (Phi-180)*TMath::Pi()/180.;
128 if(Theta<fThetaMin || Theta>fThetaMax ||
129 Phi<fPhiMin || Phi>fPhiMax ||
130 prwn<fPMin || prwn>fPMax)
134 p[0]=prwn*TMath::Sin(Theta)*TMath::Cos(Phi);
135 p[1]=prwn*TMath::Sin(Theta)*TMath::Sin(Phi);
136 p[2]=prwn*TMath::Cos(Theta);
138 if(fVertexSmear==perTrack) {
142 +fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
143 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
146 gAlice->SetTrack(fTrackIt,-1,Idpart,p,origin,polar,0,"Primary",nt);
149 nb = (Int_t)h2->GetEvent(fNcurrent);
153 // Get AliRun object or create it
155 gAlice = (AliRun*)File->Get("gAlice");
156 if (gAlice) printf("AliRun object found on file\n");
157 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
159 TTree *fAli=gAlice->TreeK();
160 if (fAli) File =fAli->GetCurrentFile();