]> git.uio.no Git - u/mrichter/AliRoot.git/blob - DIME/TDime.cxx
setters added
[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   fProcess("rho       "),
50   fEcut(0),
51   fRmin(-1.8),
52   fRmax(1.8)
53 {
54 // Default constructor 
55 }
56
57 //______________________________________________________________________________
58 TDime::TDime(Double_t efrm) :
59     TGenerator("Dime","Dime"),
60     fEfrm(efrm),
61     fProcess("rho      "),
62     fEcut(0.),
63     fRmin(-1.8),
64     fRmax(1.8)
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 //______________________________________________________________________________
72 TDime::~TDime()
73 {
74 // Destructor
75 }
76
77   void  TDime::Initialize()
78 {
79     VARS.rts = fEfrm;  
80     CUTS.rmax = fRmax; 
81     CUTS.rmin = fRmin;
82     CUTS.ecut = fEcut;
83     Int_t len = 10;
84     //    strncpy(FLAGS.pflag,     "rho       ", len);
85     strncpy(FLAGS.pflag,     fProcess.Data(), len);
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;
92     dimeinit();
93 }
94
95 void  TDime::GenerateEvent()
96 {
97    dimegenerate();
98    //for (Int_t i = 0; i < HEPEUP.NUP; i++) {
99    //printf("%5d %5d %5d %5d %5d %13.3f %13.3f\n", i, 
100    //    HEPEUP.IDUP[i], HEPEUP.ISTUP[i], HEPEUP.MOTHUP[i][0],
101    //    HEPEUP.ICOLUP[i][0], HEPEUP.PUP[i][2], HEPEUP.VTIMUP[i]);
102    //}
103
104 }
105
106 TObjArray* TDime::ImportParticles(Option_t *option)
107 {
108 //
109 //  Default primary creation method. It reads the /HEPEVT/ common block which
110 //  has been filled by the GenerateEvent method. If the event generator does
111 //  not use the HEPEVT common block, This routine has to be overloaded by
112 //  the subclasses.
113 //  The function loops on the generated particles and store them in
114 //  the TClonesArray pointed by the argument particles.
115 //  The default action is to store only the stable particles (ISTHEP = 1)
116 //  This can be demanded explicitly by setting the option = "Final"
117 //  If the option = "All", all the particles are stored.
118 //
119     fParticles->Clear();
120     Int_t nump = 0;
121
122     Int_t numpart = HEPEUP.NUP;
123     printf("\n TDime: DIME stack contains %d particles.", numpart);
124
125     if (!strcmp(option,"") || !strcmp(option,"Final")) {
126         for (Int_t i = 0; i < numpart; i++) {
127           
128             if (HEPEUP.ISTUP[i] == 1) {
129 //
130 //  Use the common block values for the TParticle constructor
131 //
132                 nump++;
133                 TParticle* p = new TParticle(
134                                              HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
135                     -1, -1, -1,
136                     HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
137                     0., 0., 0., 0.0);
138                 fParticles->Add(p);
139             }
140         }
141     }
142     else if (!strcmp(option,"All")) {
143         nump = numpart; 
144         for (Int_t i = 0; i < numpart; i++) {
145            Int_t iParent = HEPEUP.MOTHUP[i][0]-1;
146             if (iParent >= 0) {
147                 TParticle *mother = (TParticle*) (fParticles->UncheckedAt(iParent));       
148                 mother->SetLastDaughter(i);
149                 if (mother->GetFirstDaughter()==-1)
150                     mother->SetFirstDaughter(i);
151             }
152             
153             TParticle* p = new TParticle(
154                                          HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0]-1, HEPEUP.MOTHUP[i][1]-1 ,
155                     -1, -1, -1,
156                     HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
157                     0., 0., 0., 0.);
158             fParticles->Add(p);
159         }
160     }
161     return fParticles;
162 }
163
164 Int_t TDime::ImportParticles(TClonesArray *particles, Option_t *option)
165 {
166 //
167 //  Default primary creation method. It reads the /HEPEVT/ common block which
168 //  has been filled by the GenerateEvent method. If the event generator does
169 //  not use the HEPEVT common block, This routine has to be overloaded by
170 //  the subclasses.
171 //  The function loops on the generated particles and store them in
172 //  the TClonesArray pointed by the argument particles.
173 //  The default action is to store only the stable particles (ISTHEP = 1)
174 //  This can be demanded explicitly by setting the option = "Final"
175 //  If the option = "All", all the particles are stored.
176 //
177   if (particles == 0) return 0;
178   TClonesArray &particlesR = *particles;
179   particlesR.Clear();
180   Int_t nump = 0;
181
182   Int_t numpart = HEPEUP.NUP;
183   printf("\n TDime: DIME stack contains %d particles.", numpart);
184  
185   if (!strcmp(option,"") || !strcmp(option,"Final")) {
186       for (Int_t i = 0; i < numpart; i++) {
187         if (HEPEUP.ISTUP[i] == 1) {
188 //
189 //  Use the common block values for the TParticle constructor
190 //
191             nump++;
192             new(particlesR[i]) 
193               TParticle(
194                         HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
195                         -1, -1, -1,
196                         HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
197                         0., 0., 0., 0.0);
198           }
199       }
200   }
201   else if (!strcmp(option,"All")) {
202       nump = numpart; 
203       for (Int_t i = 0; i < numpart; i++) {
204
205         Int_t iParent = HEPEUP.MOTHUP[i][0]-1;
206         
207         if (iParent >= 0) {
208           TParticle *mother = (TParticle*) (particlesR.UncheckedAt(iParent));      
209           mother->SetLastDaughter(i);
210           if (mother->GetFirstDaughter()==-1)
211             mother->SetFirstDaughter(i);
212         }
213
214           new(particlesR[i]) TParticle(
215                                        HEPEUP.IDUP[i], HEPEUP.MOTHUP[i][0], HEPEUP.MOTHUP[i][1] ,
216                                        -1, -1, -1,
217                                        HEPEUP.PUP[i][0], HEPEUP.PUP[i][1], HEPEUP.PUP[i][2], HEPEUP.PUP[i][3] ,
218                                        0., 0., 0., 0.0
219                                        );
220       }
221   }
222   return nump;
223 }
224