comment printouts
[u/mrichter/AliRoot.git] / STARLIGHT / AliGenStarLight.cxx
CommitLineData
da32329d
AM
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id: $ */
17#include <Riostream.h>
18#include "AliLog.h"
19#include "TStarLight.h"
20#include "starlight.h"
21#include "upcevent.h"
22#include "AliGenStarLight.h"
23
24AliGenStarLight::AliGenStarLight()
25 : AliGenMC()
26 , fTrials(0)
27 , fHeader()
28 , fSLgenerator(NULL) {
29}
30//----------------------------------------------------------------------
31AliGenStarLight::AliGenStarLight(Int_t npart)
32 : AliGenMC(npart)
33 , fTrials(0)
34 , fHeader()
35 , fSLgenerator(NULL) {
36 fSLgenerator = new TStarLight("TStarLight",
37 "StarLight UPC Event Generator",
38 ""); // no config file name
39}
40//----------------------------------------------------------------------
41AliGenStarLight::~AliGenStarLight() {
42 delete fSLgenerator;
43 fSLgenerator = NULL;
44}
45void AliGenStarLight::ImportConfigurationFromFile(const char* filename) {
46 if (NULL == fSLgenerator) {
47 AliFatal("AliGenStarLight class not constructed properly. ");
48 return;
49 }
50 fSLgenerator->ImportConfigurationFromFile(filename);
51}
52void AliGenStarLight::SetParameter(const char* line) {
53 if (NULL == fSLgenerator) {
54 AliFatal("AliGenStarLight class not constructed properly. ");
55 return;
56 }
57 fSLgenerator->SetParameter(line);
58}
59//----------------------------------------------------------------------
60void AliGenStarLight::Init() {
61 if (NULL == fSLgenerator) {
62 AliFatal("AliGenStarLight class not constructed properly. ");
63 return;
64 }
65 fSLgenerator->InitStarLight();
66}
67//----------------------------------------------------------------------
68void 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];
74 origin0[3] = fTime;
75 }
76
77 Int_t nt(0); // number of tracks
78 const Int_t itp(1); // transport all partiles.
79 const Double_t weight(1.0);
80 Bool_t genOK(kFALSE);
81 fTrials = 0;
82 do { // simulate one event passing all requirements
83 fTrials++;
84 fSLgenerator->GenerateEvent();
85 fSLgenerator->BoostEvent();
86 fSLgenerator->ImportParticles(&fParticles, "ALL");
87
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};
94 PushTrack(itp,
95 iparent,
96 part->GetPdgCode(),
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],
100 kPNoProcess,
101 nt,
102 weight,
103 part->GetStatusCode());
104 KeepTrack(nt);
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]
109 // <<endl;
110 }
111 genOK = kTRUE;
112 } while (!genOK);
113 MakeHeader(nt, origin0);
114 SetHighWaterMark(nt);
115}
116//----------------------------------------------------------------------
117void 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);
123
124 const TArrayF vertexPosition(3, orn);
125 fHeader.SetPrimaryVertex(vertexPosition);
126
127 AddHeader(&fHeader);
128}
129//----------------------------------------------------------------------