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