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 #include <Riostream.h>
19 #include "TStarLight.h"
20 #include "starlight.h"
22 #include "AliRunLoader.h"
23 #include "AliGenEventHeader.h"
24 #include "AliGenStarLight.h"
26 ClassImp(AliGenStarLight);
28 AliGenStarLight::AliGenStarLight()
31 , fSLgenerator(NULL) {
33 //----------------------------------------------------------------------
34 AliGenStarLight::AliGenStarLight(Int_t npart)
37 , fSLgenerator(new TStarLight("TStarLight",
38 "StarLight UPC Event Generator",
39 "")) // no config file name
43 //----------------------------------------------------------------------
44 AliGenStarLight::~AliGenStarLight() {
45 if (NULL != fSLgenerator) delete fSLgenerator;
48 void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
49 if (NULL == fSLgenerator) {
50 AliFatal("AliGenStarLight class not constructed properly. ");
53 fSLgenerator->ImportConfigurationFromFile(filename);
55 void AliGenStarLight::SetParameter(const char* line) {
56 if (NULL == fSLgenerator) {
57 AliFatal("AliGenStarLight class not constructed properly. ");
60 fSLgenerator->SetParameter(line);
62 //----------------------------------------------------------------------
63 void AliGenStarLight::Init() {
64 if (NULL == fSLgenerator) {
65 AliFatal("AliGenStarLight class not constructed properly. ");
68 fSLgenerator->InitStarLight();
70 //----------------------------------------------------------------------
71 void AliGenStarLight::Generate() {
72 Float_t vpos[4] = { 0, 0, 0, 0 };
73 if (fVertexSmear == kPerEvent) {
74 Vertex(); // get vertex
75 for (Int_t i=0; i<3; ++i)
80 Int_t nt(0); // number of tracks
83 // generate events until all constraints are fulfilled
84 for (fTrials=0; !genOK && fTrials < 100*1000; ++fTrials) {
85 fSLgenerator->GenerateEvent();
86 fSLgenerator->BoostEvent();
87 fSLgenerator->ImportParticles(&fParticles, "ALL");
90 for (Long64_t i(0), n(fParticles.GetEntries()); i<n && genOK; ++i) {
91 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
93 AliFatal("NULL == part");
97 (part->Theta() >= fThetaMin) && (part->Theta() < fThetaMax) &&
98 (part->Phi() >= fPhiMin) && (part->Phi() < fPhiMax) &&
99 (part->Y() >= fYMin) && (part->Y() < fYMax) &&
100 (part->P() >= fPMin) && (part->P() < fPMax) &&
101 (part->Pt() >= fPtMin) && (part->Pt() < fPtMax);
103 if (kFALSE == genOK) continue;
106 for (Long64_t i(0), n(fParticles.GetEntries()); i<n; ++i) {
107 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
109 AliFatal("NULL == part");
113 Float_t polar[3] = { 0, 0, 0 };
114 PushTrack(fTrackIt, iparent, part->GetPdgCode(),
115 part->Px(), part->Py(), part->Pz(), part->Energy(),
116 vpos[0], vpos[1], vpos[2], vpos[3],
117 polar[0], polar[1], polar[2],
118 kPPrimary, nt, weight, part->GetStatusCode());
119 AliInfo(Form("fTrials=%d nt=%d fTrackIt=%d statusCode=%d",
120 fTrials, nt, fTrackIt, part->GetStatusCode()));
127 AliFatal("Maximum number of trials reached");
129 AliGenEventHeader* header = new AliGenEventHeader("SL");
130 const TArrayF vertexPosition(3, vpos);
131 header->SetPrimaryVertex(vertexPosition);
132 header->SetInteractionTime(vpos[3]);
133 header->SetNProduced(nt);
135 SetHighWaterMark(nt);
136 AliRunLoader::Instance()->CdGAFile();