2 // definition of c++ Class THerwig6 to be used in ROOT
3 // this is a c++ interface to the F77 Herwig6 program
4 // author: j. g. contreras jgcn@moni.mda.cinvestav.mx
5 // date: december 22, 2000
9 #include "TClonesArray.h"
10 #include "TParticle.h"
16 void* herwig6_common_block_address_(char*, int len);
17 void herwig6_open_fortran_file_ (int* lun, char* name, int);
18 void herwig6_close_fortran_file_(int* lun);
22 THerwig6::THerwig6() : TGenerator("Herwig6","Herwig6") {
24 // THerwig6 constructor: creates a TClonesArray in which it will store all
25 // particles. Note that there may be only one functional THerwig6 object
26 // at a time, so it's not use to create more than one instance of it.
28 delete fParticles; // was allocated as TObjArray in TGenerator
30 fParticles = new TClonesArray("TParticle",50);
32 // initialize common-blocks
33 fHepevt = (Hepevt_t*) herwig6_common_block_address_((char*)"HEPEVT",6);
34 fHwbeam = (Hwbeam_t*) herwig6_common_block_address_((char*)"HWBEAM",6);
35 fHwbmch = (Hwbmch_t*) herwig6_common_block_address_((char*)"HWBMCH",6);
36 fHwproc = (Hwproc_t*) herwig6_common_block_address_((char*)"HWPROC",6);
37 fHwpram = (Hwpram_t*) herwig6_common_block_address_((char*)"HWPRAM",6);
38 fHwprch = (Hwprch_t*) herwig6_common_block_address_((char*)"HWPRCH",6);
39 fHwpart = (Hwpart_t*) herwig6_common_block_address_((char*)"HWPART",6);
40 fHwparp = (Hwparp_t*) herwig6_common_block_address_((char*)"HWPARP",6);
41 fHwbosc = (Hwbosc_t*) herwig6_common_block_address_((char*)"HWBOSC",6);
42 fHwparc = (Hwparc_t*) herwig6_common_block_address_((char*)"HWPARC",6);
43 fHwbrch = (Hwbrch_t*) herwig6_common_block_address_((char*)"HWBRCH",6);
44 fHwevnt = (Hwevnt_t*) herwig6_common_block_address_((char*)"HWEVNT",6);
45 fHwhard = (Hwhard_t*) herwig6_common_block_address_((char*)"HWHARD",6);
46 fHwprop = (Hwprop_t*) herwig6_common_block_address_((char*)"HWPROP",6);
47 fHwunam = (Hwunam_t*) herwig6_common_block_address_((char*)"HWUNAM",6);
48 fHwupdt = (Hwupdt_t*) herwig6_common_block_address_((char*)"HWUPDT",6);
49 fHwuwts = (Hwuwts_t*) herwig6_common_block_address_((char*)"HWUWTS",6);
50 fHwuclu = (Hwuclu_t*) herwig6_common_block_address_((char*)"HWUCLU",6);
51 fHwdist = (Hwdist_t*) herwig6_common_block_address_((char*)"HWDIST",6);
52 fHwqdks = (Hwqdks_t*) herwig6_common_block_address_((char*)"HWQDKS",6);
53 fHwusud = (Hwusud_t*) herwig6_common_block_address_((char*)"HWUSUD",6);
54 fHwsusy = (Hwsusy_t*) herwig6_common_block_address_((char*)"HWSUSY",6);
55 fHwrpar = (Hwrpar_t*) herwig6_common_block_address_((char*)"HWRPAR",6);
56 fHwminb = (Hwminb_t*) herwig6_common_block_address_((char*)"HWMINB",6);
57 fHwclus = (Hwclus_t*) herwig6_common_block_address_((char*)"HWCLUS",6);
60 //------------------------------------------------------------------------------
63 // Destroys the object, deletes and disposes all TParticles currently on list.
72 //______________________________________________________________________________
73 void THerwig6::GenerateEvent()
78 // generate hard subprocess
80 // generate parton cascades
82 // do heavy objects decay
84 // do cluster formation
88 // do unstable particle decays
90 // do heavy flavor hadrons decay
92 // add soft underlying event
98 //______________________________________________________________________________
99 void THerwig6::OpenFortranFile(int lun, char* name) {
100 herwig6_open_fortran_file_(&lun, name, strlen(name));
103 //______________________________________________________________________________
104 void THerwig6::CloseFortranFile(int lun) {
105 herwig6_close_fortran_file_(&lun);
108 void THerwig6::Initialize(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc)
111 // perform the initialization for Herwig6
112 // sets correct title.
113 // after calling this method all parameters are set to their default
114 // values. If you want to modify any parameter you have to set the new
115 // value after calling Initialize and before PrepareRun.
118 strncpy(cbeam,beam,8);
120 strncpy(ctarget,target,8);
121 printf("\n Initializing Herwig !! \n");
122 if ( (!strncmp(beam, "E+" ,2)) &&
123 (!strncmp(beam, "E-" ,2)) &&
124 (!strncmp(beam, "MU+" ,3)) &&
125 (!strncmp(beam, "MU-" ,3)) &&
126 (!strncmp(beam, "NUE" ,3)) &&
127 (!strncmp(beam, "NUEB" ,4)) &&
128 (!strncmp(beam, "NUMU" ,4)) &&
129 (!strncmp(beam, "NMUB" ,4)) &&
130 (!strncmp(beam, "NTAU" ,4)) &&
131 (!strncmp(beam, "NTAB" ,4)) &&
132 (!strncmp(beam, "GAMA" ,4)) &&
133 (!strncmp(beam, "P ",8)) &&
134 (!strncmp(beam, "PBAR ",8)) &&
135 (!strncmp(beam, "N" ,1)) &&
136 (!strncmp(beam, "NBAR" ,4)) &&
137 (!strncmp(beam, "PI+" ,3)) &&
138 (!strncmp(beam, "PI-" ,3)) ) {
139 printf("WARNING! In THerwig6:Initialize():\n");
140 printf(" specified beam=%s is unrecognized .\n",beam);
141 printf(" resetting to \"P\" .");
145 if ( (!strncmp(target, "E+" ,2)) &&
146 (!strncmp(target, "E-" ,2)) &&
147 (!strncmp(target, "MU+" ,3)) &&
148 (!strncmp(target, "MU-" ,3)) &&
149 (!strncmp(target, "NUE" ,3)) &&
150 (!strncmp(target, "NUEB" ,4)) &&
151 (!strncmp(target, "NUMU" ,4)) &&
152 (!strncmp(target, "NMUB" ,4)) &&
153 (!strncmp(target, "NTAU" ,4)) &&
154 (!strncmp(target, "NTAB" ,4)) &&
155 (!strncmp(target, "GAMA" ,4)) &&
156 (!strncmp(target, "P ",8)) &&
157 (!strncmp(target, "PBAR ",8)) &&
158 (!strncmp(target, "N" ,1)) &&
159 (!strncmp(target, "NBAR" ,4)) &&
160 (!strncmp(target, "PI+" ,3)) &&
161 (!strncmp(target, "PI-" ,3)) ) {
162 printf("WARNING! In THerwig6:Initialize():\n");
163 printf(" specified target=%s is unrecognized .\n",target);
164 printf(" resetting to \"P\" .");
165 sprintf(ctarget,"P");
170 strncpy(fHwbmch->PART1,beam,8);
171 strncpy(fHwbmch->PART2,target,8);
173 fHwproc->PBEAM1=pbeam1;
174 fHwproc->PBEAM2=pbeam2;
175 // process to generate
176 fHwproc->IPROC=iproc;
177 // not used in the class definition
180 // reset all parameters
185 double win=pbeam1+pbeam2;
186 printf("\n %s - %s at %g GeV",beam,target,win);
187 sprintf(atitle,"%s-%s at %g GeV",cbeam,ctarget,win);
191 void THerwig6::PrepareRun()
193 // compute parameter dependent constants
195 // initialize elementary processes
199 //______________________________________________________________________________
200 TObjArray* THerwig6::ImportParticles(Option_t *option)
203 // Default primary creation method. It reads the /HEPEVT/ common block which
204 // has been filled by the GenerateEvent method. If the event generator does
205 // not use the HEPEVT common block, This routine has to be overloaded by
207 // The default action is to store only the stable particles (ISTHEP = 1)
208 // This can be demanded explicitly by setting the option = "Final"
209 // If the option = "All", all the particles are stored.
212 Int_t numpart = fHepevt->NHEP;
213 TClonesArray &a = *((TClonesArray*)fParticles);
214 if (!strcmp(option,"") || !strcmp(option,"Final")) {
215 for (Int_t i = 0; i<=numpart; i++) {
216 if (fHepevt->ISTHEP[i] == 1) {
218 // Use the common block values for the TParticle constructor
223 fHepevt->JMOHEP[i][0]-1,
224 fHepevt->JMOHEP[i][1]-1,
225 fHepevt->JDAHEP[i][0]-1,
226 fHepevt->JDAHEP[i][1]-1,
235 fHepevt->VHEP[i][3]);
239 else if (!strcmp(option,"All")) {
240 for (Int_t i = 0; i<=numpart; i++) {
244 fHepevt->JMOHEP[i][0]-1,
245 fHepevt->JMOHEP[i][1]-1,
246 fHepevt->JDAHEP[i][0]-1,
247 fHepevt->JDAHEP[i][1]-1,
256 fHepevt->VHEP[i][3]);
262 //______________________________________________________________________________
263 Int_t THerwig6::ImportParticles(TClonesArray *particles, Option_t *option)
266 // Default primary creation method. It reads the /HEPEVT/ common block which
267 // has been filled by the GenerateEvent method. If the event generator does
268 // not use the HEPEVT common block, This routine has to be overloaded by
270 // The function loops on the generated particles and store them in
271 // the TClonesArray pointed by the argument particles.
272 // The default action is to store only the stable particles (ISTHEP = 1)
273 // This can be demanded explicitly by setting the option = "Final"
274 // If the option = "All", all the particles are stored.
276 if (particles == 0) return 0;
277 TClonesArray &Particles = *particles;
279 Int_t numpart = fHepevt->NHEP;
280 if (!strcmp(option,"") || !strcmp(option,"Final")) {
281 for (Int_t i = 0; i< numpart; i++) {
282 if (fHepevt->ISTHEP[i] == 1) {
284 // Use the common block values for the TParticle constructor
286 new(Particles[i]) TParticle(
289 fHepevt->JMOHEP[i][0]-1,
290 fHepevt->JMOHEP[i][1]-1,
291 fHepevt->JDAHEP[i][0]-1,
292 fHepevt->JDAHEP[i][1]-1,
301 fHepevt->VHEP[i][3]);
305 else if (!strcmp(option,"All")) {
306 for (Int_t i = 0; i< numpart; i++) {
307 new(Particles[i]) TParticle(
310 fHepevt->JMOHEP[i][0]-1,
311 fHepevt->JMOHEP[i][1]-1,
312 fHepevt->JDAHEP[i][0]-1,
313 fHepevt->JDAHEP[i][1]-1,
322 fHepevt->VHEP[i][3]);
328 void THerwig6::Hwigin()
333 void THerwig6::Hwuinc()
338 void THerwig6::Hwusta(char* name)
344 void THerwig6::Hweini()
350 void THerwig6::Hwuine()
356 void THerwig6::Hwepro()
362 void THerwig6::Hwbgen()
368 void THerwig6::Hwdhob()
374 void THerwig6::Hwcfor()
380 void THerwig6::Hwcdec()
386 void THerwig6::Hwdhad()
392 void THerwig6::Hwdhvy()
398 void THerwig6::Hwmevt()
404 void THerwig6::Hwufne()
410 void THerwig6::Hwefin()
416 void THerwig6::SetupTest()
418 // exampe of running herwig and generating one event
419 // after changing some options
420 Initialize("P","PBAR",900.,900.,1500);
421 // here you can set some parameters
422 SetPTMIN(15.); // Min pt in hadronic jet production
423 SetYJMIN(-4.); // Min jet rapidity
424 SetYJMAX(4.); // Max jet rapidity
425 // after you set your wished parameters
426 // herwig can do its work
428 int n_ev_to_generate=1;
429 for (int i=0;i<n_ev_to_generate;i++)
432 // do your stuff. For ex:
433 int n_of_par=GetNumberOfParticles(); // from TGenerator
434 for (int j=0; j<n_of_par; j++)
436 TParticle* p=GetParticle(j);
437 // here you do whatever you want with the particle