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()
30 , fSLgenerator(NULL) {
32 //----------------------------------------------------------------------
33 AliGenStarLight::AliGenStarLight(Int_t npart)
35 , fSLgenerator(new TStarLight("TStarLight",
36 "StarLight UPC Event Generator",
37 "")) // no config file name
41 //----------------------------------------------------------------------
42 AliGenStarLight::~AliGenStarLight() {
43 if (NULL != fSLgenerator) delete fSLgenerator;
46 void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
47 if (NULL == fSLgenerator) {
48 AliFatal("AliGenStarLight class not constructed properly. ");
51 fSLgenerator->ImportConfigurationFromFile(filename);
53 void AliGenStarLight::SetParameter(const char* line) {
54 if (NULL == fSLgenerator) {
55 AliFatal("AliGenStarLight class not constructed properly. ");
58 fSLgenerator->SetParameter(line);
60 //----------------------------------------------------------------------
61 void AliGenStarLight::Init() {
62 if (NULL == fSLgenerator) {
63 AliFatal("AliGenStarLight class not constructed properly. ");
66 fSLgenerator->InitStarLight();
68 //----------------------------------------------------------------------
69 void AliGenStarLight::Generate() {
70 Float_t vpos[4] = { 0, 0, 0, 0 };
71 if (fVertexSmear == kPerEvent) {
72 Vertex(); // get vertex
73 for (Int_t i=0; i<3; ++i)
78 Int_t nt(0); // number of tracks
80 // generate events until all constraints are fulfilled
81 for (Int_t trials=0; !genOK && trials < 100*1000; ++trials) {
82 fSLgenerator->GenerateEvent();
83 fSLgenerator->BoostEvent();
84 fSLgenerator->ImportParticles(&fParticles, "ALL");
87 for (Long64_t i(0), n(fParticles.GetEntries()); i<n && genOK; ++i) {
88 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
90 AliFatal("NULL == part");
94 (part->Theta() >= fThetaMin) && (part->Theta() < fThetaMax) &&
95 (part->Phi() >= fPhiMin) && (part->Phi() < fPhiMax) &&
96 (part->Y() >= fYMin) && (part->Y() < fYMax) &&
97 (part->P() >= fPMin) && (part->P() < fPMax) &&
98 (part->Pt() >= fPtMin) && (part->Pt() < fPtMax);
100 if (kFALSE == genOK) continue;
103 for (Long64_t i(0), n(fParticles.GetEntries()); i<n; ++i) {
104 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
106 AliFatal("NULL == part");
109 const Int_t iparent(-1);
110 const Float_t polar[3] = { 0, 0, 0 };
111 const Float_t weight(trials+1);
112 PushTrack(fTrackIt, iparent, part->GetPdgCode(),
113 part->Px(), part->Py(), part->Pz(), part->Energy(),
114 vpos[0], vpos[1], vpos[2], vpos[3],
115 polar[0], polar[1], polar[2],
116 kPPrimary, nt, weight, part->GetStatusCode());
117 AliInfo(Form("weight=%.0f nt=%d fTrackIt=%d statusCode=%d",
118 weight, nt, fTrackIt, part->GetStatusCode()));
126 AliFatal("Maximum number of trials reached");
128 AliGenEventHeader* header = new AliGenEventHeader("SL");
129 const TArrayF vertexPosition(3, vpos);
130 header->SetPrimaryVertex(vertexPosition);
131 header->SetInteractionTime(vpos[3]);
132 header->SetNProduced(nt);
134 SetHighWaterMark(nt);
135 AliRunLoader::Instance()->CdGAFile();