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 , fRapidityMotherMin( 1) // Max < Min: no cut
31 , fRapidityMotherMax(-1)
32 , fEtaChildMin( 1) // Max < Min: no cut
37 //----------------------------------------------------------------------
38 AliGenStarLight::AliGenStarLight(Int_t npart)
40 , fRapidityMotherMin( 1) // Max < Min: no cut
41 , fRapidityMotherMax(-1)
42 , fEtaChildMin( 1) // Max < Min: no cut
44 , fSLgenerator(new TStarLight("TStarLight",
45 "StarLight UPC Event Generator",
46 "")) // no config file name
50 //----------------------------------------------------------------------
51 AliGenStarLight::~AliGenStarLight() {
52 if (NULL != fSLgenerator) delete fSLgenerator;
55 void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
56 if (NULL == fSLgenerator) {
57 AliFatal("AliGenStarLight class not constructed properly. ");
60 fSLgenerator->ImportConfigurationFromFile(filename);
62 void AliGenStarLight::SetParameter(const char* line) {
63 if (NULL == fSLgenerator) {
64 AliFatal("AliGenStarLight class not constructed properly. ");
67 fSLgenerator->SetParameter(line);
69 //----------------------------------------------------------------------
70 void AliGenStarLight::Init() {
71 if (NULL == fSLgenerator) {
72 AliFatal("AliGenStarLight class not constructed properly. ");
75 fSLgenerator->InitStarLight();
77 //----------------------------------------------------------------------
78 void AliGenStarLight::Generate() {
79 Float_t vpos[4] = { 0, 0, 0, 0 };
80 if (fVertexSmear == kPerEvent) {
81 Vertex(); // get vertex
82 for (Int_t i=0; i<3; ++i)
87 Int_t nt(0); // number of tracks
89 // generate events until all constraints are fulfilled
90 for (Int_t trials=0; !genOK && trials < 100*1000; ++trials) {
91 fSLgenerator->GenerateEvent();
92 fSLgenerator->BoostEvent();
93 fSLgenerator->ImportParticles(&fParticles, "ALL");
97 const Long64_t n(fParticles.GetEntries());
99 AliFatal("no particles generated");
102 for (Long64_t i(0); i<n; ++i) {
103 TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
105 AliFatal("NULL == part");
109 (part->Theta() >= fThetaMin) && (part->Theta() < fThetaMax) &&
110 (part->Phi() >= fPhiMin) && (part->Phi() < fPhiMax) &&
111 (part->Y() >= fYMin) && (part->Y() < fYMax) &&
112 (part->P() >= fPMin) && (part->P() < fPMax) &&
113 (part->Pt() >= fPtMin) && (part->Pt() < fPtMax);
114 if (fEtaChildMin <= fEtaChildMax) // no cut if Max < Min
115 genOK = genOK && (part->Eta() >= fEtaChildMin &&
116 part->Eta() < fEtaChildMax);
125 if (fRapidityMotherMin <= fRapidityMotherMax) // no cut if Max < Min
127 ? (vSum.Rapidity() > fRapidityMotherMin &&
128 vSum.Rapidity() < fRapidityMotherMax)
131 if (kFALSE == genOK) continue;
134 for (Long64_t i(0), n(fParticles.GetEntries()); i<n; ++i) {
135 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
137 AliFatal("NULL == part");
140 const Int_t iparent(-1);
141 const Float_t polar[3] = { 0, 0, 0 };
142 const Float_t weight(trials+1);
143 PushTrack(fTrackIt, iparent, part->GetPdgCode(),
144 part->Px(), part->Py(), part->Pz(), part->Energy(),
145 vpos[0], vpos[1], vpos[2], vpos[3],
146 polar[0], polar[1], polar[2],
147 kPPrimary, nt, weight, part->GetStatusCode());
148 AliInfo(Form("weight=%.0f nt=%d fTrackIt=%d statusCode=%d",
149 weight, nt, fTrackIt, part->GetStatusCode()));
157 AliFatal("Maximum number of trials reached");
159 AliGenEventHeader* header = new AliGenEventHeader("SL");
160 const TArrayF vertexPosition(3, vpos);
161 header->SetPrimaryVertex(vertexPosition);
162 header->SetInteractionTime(vpos[3]);
163 header->SetNProduced(nt);
165 SetHighWaterMark(nt);
166 AliRunLoader::Instance()->CdGAFile();