]>
Commit | Line | Data |
---|---|---|
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 | ||
24 | AliGenStarLight::AliGenStarLight() | |
25 | : AliGenMC() | |
26 | , fTrials(0) | |
45d54d9a | 27 | , fHeader(NULL) |
da32329d AM |
28 | , fSLgenerator(NULL) { |
29 | } | |
30 | //---------------------------------------------------------------------- | |
31 | AliGenStarLight::AliGenStarLight(Int_t npart) | |
32 | : AliGenMC(npart) | |
33 | , fTrials(0) | |
45d54d9a | 34 | , fHeader(NULL) |
da32329d AM |
35 | , fSLgenerator(NULL) { |
36 | fSLgenerator = new TStarLight("TStarLight", | |
37 | "StarLight UPC Event Generator", | |
38 | ""); // no config file name | |
39 | } | |
40 | //---------------------------------------------------------------------- | |
41 | AliGenStarLight::~AliGenStarLight() { | |
42 | delete fSLgenerator; | |
43 | fSLgenerator = NULL; | |
45d54d9a | 44 | |
45 | if (NULL != fHeader) | |
46 | delete fHeader; | |
47 | fHeader = NULL; | |
da32329d AM |
48 | } |
49 | void AliGenStarLight::ImportConfigurationFromFile(const char* filename) { | |
50 | if (NULL == fSLgenerator) { | |
51 | AliFatal("AliGenStarLight class not constructed properly. "); | |
52 | return; | |
53 | } | |
54 | fSLgenerator->ImportConfigurationFromFile(filename); | |
55 | } | |
56 | void AliGenStarLight::SetParameter(const char* line) { | |
57 | if (NULL == fSLgenerator) { | |
58 | AliFatal("AliGenStarLight class not constructed properly. "); | |
59 | return; | |
60 | } | |
61 | fSLgenerator->SetParameter(line); | |
62 | } | |
63 | //---------------------------------------------------------------------- | |
64 | void AliGenStarLight::Init() { | |
65 | if (NULL == fSLgenerator) { | |
66 | AliFatal("AliGenStarLight class not constructed properly. "); | |
67 | return; | |
68 | } | |
69 | fSLgenerator->InitStarLight(); | |
70 | } | |
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]; | |
78 | origin0[3] = fTime; | |
79 | } | |
80 | ||
81 | Int_t nt(0); // number of tracks | |
82 | const Int_t itp(1); // transport all partiles. | |
83 | const Double_t weight(1.0); | |
84 | Bool_t genOK(kFALSE); | |
85 | fTrials = 0; | |
86 | do { // simulate one event passing all requirements | |
87 | fTrials++; | |
88 | fSLgenerator->GenerateEvent(); | |
89 | fSLgenerator->BoostEvent(); | |
90 | fSLgenerator->ImportParticles(&fParticles, "ALL"); | |
91 | ||
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}; | |
98 | PushTrack(itp, | |
99 | iparent, | |
100 | part->GetPdgCode(), | |
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], | |
104 | kPNoProcess, | |
105 | nt, | |
106 | weight, | |
107 | part->GetStatusCode()); | |
108 | KeepTrack(nt); | |
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] | |
113 | // <<endl; | |
114 | } | |
115 | genOK = kTRUE; | |
116 | } while (!genOK); | |
117 | MakeHeader(nt, origin0); | |
118 | SetHighWaterMark(nt); | |
119 | } | |
120 | //---------------------------------------------------------------------- | |
121 | void AliGenStarLight::MakeHeader(Int_t np, Float_t orn[4]) { | |
45d54d9a | 122 | if (NULL == fHeader) |
123 | fHeader = new AliGenStarLightEventHeader; | |
124 | ||
125 | fHeader->SetInputParameters(fSLgenerator->GetInputParameters()); | |
126 | fHeader->SetTrials(fTrials); | |
127 | fHeader->SetEventWeight(1.0); | |
128 | fHeader->SetInteractionTime(orn[3]); | |
129 | fHeader->SetNProduced(np); | |
da32329d AM |
130 | |
131 | const TArrayF vertexPosition(3, orn); | |
45d54d9a | 132 | fHeader->SetPrimaryVertex(vertexPosition); |
da32329d | 133 | |
45d54d9a | 134 | AddHeader(fHeader); |
da32329d AM |
135 | } |
136 | //---------------------------------------------------------------------- |