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 "AliGenStarLight.h"
24 AliGenStarLight::AliGenStarLight()
28 , fSLgenerator(NULL) {
30 //----------------------------------------------------------------------
31 AliGenStarLight::AliGenStarLight(Int_t npart)
35 , fSLgenerator(NULL) {
36 fSLgenerator = new TStarLight("TStarLight",
37 "StarLight UPC Event Generator",
38 ""); // no config file name
40 //----------------------------------------------------------------------
41 AliGenStarLight::~AliGenStarLight() {
45 void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
46 if (NULL == fSLgenerator) {
47 AliFatal("AliGenStarLight class not constructed properly. ");
50 fSLgenerator->ImportConfigurationFromFile(filename);
52 void AliGenStarLight::SetParameter(const char* line) {
53 if (NULL == fSLgenerator) {
54 AliFatal("AliGenStarLight class not constructed properly. ");
57 fSLgenerator->SetParameter(line);
59 //----------------------------------------------------------------------
60 void AliGenStarLight::Init() {
61 if (NULL == fSLgenerator) {
62 AliFatal("AliGenStarLight class not constructed properly. ");
65 fSLgenerator->InitStarLight();
67 //----------------------------------------------------------------------
68 void AliGenStarLight::Generate() {
69 Float_t origin0[4] = {0,0,0,0};
70 if (fVertexSmear == kPerEvent) {
71 Vertex(); // get vertex
72 for (Int_t i=0; i<3; ++i)
73 origin0[i] = fVertex[i];
77 Int_t nt(0); // number of tracks
78 const Int_t itp(1); // transport all partiles.
79 const Double_t weight(1.0);
82 do { // simulate one event passing all requirements
84 fSLgenerator->GenerateEvent();
85 fSLgenerator->BoostEvent();
86 fSLgenerator->ImportParticles(&fParticles, "ALL");
88 for (size_t i(0), n(fParticles.GetEntries()); i!=n; ++i) {
89 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
90 const Int_t iparent(-1); //iparent = part->getParent();
91 //ifDaugh = part->getFirstDaughter();
92 //ilDaugh = part->getLastDaughter();
93 const Double_t pol[3] = {0,0,0};
97 part->Px(), part->Py(), part->Pz(), part->Energy(),
98 origin0[0], origin0[1], origin0[2], origin0[3],
99 pol[0], pol[1], pol[2],
103 part->GetStatusCode());
105 //cout<<"AliGenStarLight::Generate: fTrials="<<fTrials
106 // <<" iparent="<<iparent<<" ipdg="<<ipdg
107 // <<" p="<<px<<","<<py<<","<<pz<<","<<E
108 // <<" origin="<<origin0[0]<<","<<origin0[1]<<","<<origin0[2]<<","<<origin0[2]
113 MakeHeader(nt, origin0);
114 SetHighWaterMark(nt);
116 //----------------------------------------------------------------------
117 void AliGenStarLight::MakeHeader(Int_t np, Float_t orn[4]) {
118 fHeader.SetInputParameters(fSLgenerator->GetInputParameters());
119 fHeader.SetTrials(fTrials);
120 fHeader.SetEventWeight(1.0);
121 fHeader.SetInteractionTime(orn[3]);
122 fHeader.SetNProduced(np);
124 const TArrayF vertexPosition(3, orn);
125 fHeader.SetPrimaryVertex(vertexPosition);
129 //----------------------------------------------------------------------