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() {
49 void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
50 if (NULL == fSLgenerator) {
51 AliFatal("AliGenStarLight class not constructed properly. ");
54 fSLgenerator->ImportConfigurationFromFile(filename);
56 void AliGenStarLight::SetParameter(const char* line) {
57 if (NULL == fSLgenerator) {
58 AliFatal("AliGenStarLight class not constructed properly. ");
61 fSLgenerator->SetParameter(line);
63 //----------------------------------------------------------------------
64 void AliGenStarLight::Init() {
65 if (NULL == fSLgenerator) {
66 AliFatal("AliGenStarLight class not constructed properly. ");
69 fSLgenerator->InitStarLight();
71 //----------------------------------------------------------------------
72 void AliGenStarLight::Generate() {
73 Float_t origin0[4] = {0,0,0,0};
74 if (fVertexSmear == kPerEvent) {
75 Vertex(); // get vertex
76 for (Int_t i=0; i<3; ++i)
77 origin0[i] = fVertex[i];
81 Int_t nt(0); // number of tracks
82 const Int_t itp(1); // transport all partiles.
83 const Double_t weight(1.0);
86 do { // simulate one event passing all requirements
88 fSLgenerator->GenerateEvent();
89 fSLgenerator->BoostEvent();
90 fSLgenerator->ImportParticles(&fParticles, "ALL");
92 for (size_t i(0), n(fParticles.GetEntries()); i!=n; ++i) {
93 const TParticle *part(dynamic_cast<TParticle*>(fParticles.At(i)));
94 const Int_t iparent(-1); //iparent = part->getParent();
95 //ifDaugh = part->getFirstDaughter();
96 //ilDaugh = part->getLastDaughter();
97 const Double_t pol[3] = {0,0,0};
101 part->Px(), part->Py(), part->Pz(), part->Energy(),
102 origin0[0], origin0[1], origin0[2], origin0[3],
103 pol[0], pol[1], pol[2],
107 part->GetStatusCode());
109 //cout<<"AliGenStarLight::Generate: fTrials="<<fTrials
110 // <<" iparent="<<iparent<<" ipdg="<<ipdg
111 // <<" p="<<px<<","<<py<<","<<pz<<","<<E
112 // <<" origin="<<origin0[0]<<","<<origin0[1]<<","<<origin0[2]<<","<<origin0[2]
117 MakeHeader(nt, origin0);
118 SetHighWaterMark(nt);
120 //----------------------------------------------------------------------
121 void AliGenStarLight::MakeHeader(Int_t np, Float_t orn[4]) {
123 fHeader = new AliGenStarLightEventHeader;
125 fHeader->SetInputParameters(fSLgenerator->GetInputParameters());
126 fHeader->SetTrials(fTrials);
127 fHeader->SetEventWeight(1.0);
128 fHeader->SetInteractionTime(orn[3]);
129 fHeader->SetNProduced(np);
131 const TArrayF vertexPosition(3, orn);
132 fHeader->SetPrimaryVertex(vertexPosition);
136 //----------------------------------------------------------------------