]> git.uio.no Git - u/mrichter/AliRoot.git/blame - DIME/TDime.cxx
Merge branch 'MyDevBranch'
[u/mrichter/AliRoot.git] / DIME / TDime.cxx
CommitLineData
de4b745b 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
18#include <TROOT.h>
19#include <TObjArray.h>
20#include <TParticle.h>
21#include <TClonesArray.h>
ce0b9758 22#include "DCommon.h"
de4b745b 23#include "TDime.h"
24
25#ifndef WIN32
26# define dimeinit dimeinit_
27# define dimegenerate dimegenerate_
28# define type_of_call
29#else
30# define dimeinit DIMEINIT
31# define dimegenerate DIMEGENERATE
32# define type_of_call _stdcall
33#endif
34
35#ifndef WIN32
36extern "C" void type_of_call dimeinit();
fdcbffd2 37extern "C" void type_of_call dimegenerate(int& success);
de4b745b 38#else
39#endif
40
41
42
43ClassImp(TDime)
44
45
46TDime::TDime():
47 TGenerator("Dime","Dime"),
b3660a2b 48 fEfrm(5500.),
49 fProcess("rho "),
50 fEcut(0),
51 fRmin(-1.8),
52 fRmax(1.8)
de4b745b 53{
54// Default constructor
55}
56
57//______________________________________________________________________________
58TDime::TDime(Double_t efrm) :
59 TGenerator("Dime","Dime"),
b3660a2b 60 fEfrm(efrm),
61 fProcess("rho "),
62 fEcut(0.),
63 fRmin(-1.8),
64 fRmax(1.8)
de4b745b 65{
66// TDime constructor:
67// Note that there may be only one functional TDime object
68// at a time, so it's not use to create more than one instance of it.
69}
70
71//______________________________________________________________________________
72TDime::~TDime()
73{
74// Destructor
75}
76
77 void TDime::Initialize()
78{
79 VARS.rts = fEfrm;
b3660a2b 80 CUTS.rmax = fRmax;
81 CUTS.rmin = fRmin;
82 CUTS.ecut = fEcut;
651c8c13 83 Int_t len = 10;
b3660a2b 84 // strncpy(FLAGS.pflag, "rho ", len);
85 strncpy(FLAGS.pflag, fProcess.Data(), len);
651c8c13 86 strncpy(FLAGS.fsi, "true ", len);
87 strncpy(FLAGS.ppbar, "false ", len);
88 strncpy(FLAGS.cuts, "true ", len);
89 strncpy(FLAGS.unw, "true ", len);
90 strncpy(FF.formf, "orexp ", len);
91 VARS.iin = 1;
de4b745b 92 dimeinit();
93}
94
95void TDime::GenerateEvent()
96{
fdcbffd2 97 Int_t ok = 0;
98 while(!ok)
99 dimegenerate(ok);
de4b745b 100 //for (Int_t i = 0; i < HEPEUP.NUP; i++) {
101 //printf("%5d %5d %5d %5d %5d %13.3f %13.3f\n", i,
102 // HEPEUP.IDUP[i], HEPEUP.ISTUP[i], HEPEUP.MOTHUP[i][0],
103 // HEPEUP.ICOLUP[i][0], HEPEUP.PUP[i][2], HEPEUP.VTIMUP[i]);
104 //}
105
106}
107
108TObjArray* TDime::ImportParticles(Option_t *option)
109{
110//
111// Default primary creation method. It reads the /HEPEVT/ common block which
112// has been filled by the GenerateEvent method. If the event generator does
113// not use the HEPEVT common block, This routine has to be overloaded by
114// the subclasses.
115// The function loops on the generated particles and store them in
116// the TClonesArray pointed by the argument particles.
117// The default action is to store only the stable particles (ISTHEP = 1)
118// This can be demanded explicitly by setting the option = "Final"
119// If the option = "All", all the particles are stored.
120//
121 fParticles->Clear();
122 Int_t nump = 0;
123
124 Int_t numpart = HEPEUP.NUP;
125 printf("\n TDime: DIME stack contains %d particles.", numpart);
126
127 if (!strcmp(option,"") || !strcmp(option,"Final")) {
128 for (Int_t i = 0; i < numpart; i++) {
129
130 if (HEPEUP.ISTUP[i] == 1) {
131//
132// Use the common block values for the TParticle constructor
133//
134 nump++;
135 TParticle* p = new TParticle(
136 HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
137 -1, -1, -1,
138 HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
139 0., 0., 0., 0.0);
140 fParticles->Add(p);
141 }
142 }
143 }
144 else if (!strcmp(option,"All")) {
145 nump = numpart;
146 for (Int_t i = 0; i < numpart; i++) {
147 Int_t iParent = HEPEUP.MOTHUP[i][0]-1;
148 if (iParent >= 0) {
149 TParticle *mother = (TParticle*) (fParticles->UncheckedAt(iParent));
150 mother->SetLastDaughter(i);
151 if (mother->GetFirstDaughter()==-1)
152 mother->SetFirstDaughter(i);
153 }
154
155 TParticle* p = new TParticle(
156 HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0]-1, HEPEUP.MOTHUP[i][1]-1 ,
157 -1, -1, -1,
158 HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
159 0., 0., 0., 0.);
160 fParticles->Add(p);
161 }
162 }
163 return fParticles;
164}
165
166Int_t TDime::ImportParticles(TClonesArray *particles, Option_t *option)
167{
168//
169// Default primary creation method. It reads the /HEPEVT/ common block which
170// has been filled by the GenerateEvent method. If the event generator does
171// not use the HEPEVT common block, This routine has to be overloaded by
172// the subclasses.
173// The function loops on the generated particles and store them in
174// the TClonesArray pointed by the argument particles.
175// The default action is to store only the stable particles (ISTHEP = 1)
176// This can be demanded explicitly by setting the option = "Final"
177// If the option = "All", all the particles are stored.
178//
179 if (particles == 0) return 0;
180 TClonesArray &particlesR = *particles;
181 particlesR.Clear();
182 Int_t nump = 0;
183
184 Int_t numpart = HEPEUP.NUP;
185 printf("\n TDime: DIME stack contains %d particles.", numpart);
186
187 if (!strcmp(option,"") || !strcmp(option,"Final")) {
188 for (Int_t i = 0; i < numpart; i++) {
189 if (HEPEUP.ISTUP[i] == 1) {
190//
191// Use the common block values for the TParticle constructor
192//
193 nump++;
194 new(particlesR[i])
195 TParticle(
196 HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
197 -1, -1, -1,
198 HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
199 0., 0., 0., 0.0);
200 }
201 }
202 }
203 else if (!strcmp(option,"All")) {
204 nump = numpart;
205 for (Int_t i = 0; i < numpart; i++) {
206
207 Int_t iParent = HEPEUP.MOTHUP[i][0]-1;
208
209 if (iParent >= 0) {
210 TParticle *mother = (TParticle*) (particlesR.UncheckedAt(iParent));
211 mother->SetLastDaughter(i);
212 if (mother->GetFirstDaughter()==-1)
213 mother->SetFirstDaughter(i);
214 }
215
216 new(particlesR[i]) TParticle(
217 HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
218 -1, -1, -1,
219 HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
220 0., 0., 0., 0.0
221 );
222 }
223 }
224 return nump;
225}
226