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
8 #include "TClonesArray.h"
15 void* herwig6_common_block_address_(char*, int len);
16 void herwig6_open_fortran_file_ (int* lun, char* name, int);
17 void herwig6_close_fortran_file_(int* lun);
21 THerwig6::THerwig6() : TGenerator("Herwig6","Herwig6") {
23 // THerwig6 constructor: creates a TClonesArray in which it will store all
24 // particles. Note that there may be only one functional THerwig6 object
25 // at a time, so it's not use to create more than one instance of it.
27 delete fParticles; // was allocated as TObjArray in TGenerator
29 fParticles = new TClonesArray("TParticle",50);
31 // initialize common-blocks
32 fHepevt = (Hepevt_t*) herwig6_common_block_address_((char*)"HEPEVT",6);
33 fHwbeam = (Hwbeam_t*) herwig6_common_block_address_((char*)"HWBEAM",6);
34 fHwbmch = (Hwbmch_t*) herwig6_common_block_address_((char*)"HWBMCH",6);
35 fHwproc = (Hwproc_t*) herwig6_common_block_address_((char*)"HWPROC",6);
36 fHwpram = (Hwpram_t*) herwig6_common_block_address_((char*)"HWPRAM",6);
37 fHwprch = (Hwprch_t*) herwig6_common_block_address_((char*)"HWPRCH",6);
38 fHwpart = (Hwpart_t*) herwig6_common_block_address_((char*)"HWPART",6);
39 fHwparp = (Hwparp_t*) herwig6_common_block_address_((char*)"HWPARP",6);
40 fHwbosc = (Hwbosc_t*) herwig6_common_block_address_((char*)"HWBOSC",6);
41 fHwparc = (Hwparc_t*) herwig6_common_block_address_((char*)"HWPARC",6);
42 fHwbrch = (Hwbrch_t*) herwig6_common_block_address_((char*)"HWBRCH",6);
43 fHwevnt = (Hwevnt_t*) herwig6_common_block_address_((char*)"HWEVNT",6);
44 fHwhard = (Hwhard_t*) herwig6_common_block_address_((char*)"HWHARD",6);
45 fHwprop = (Hwprop_t*) herwig6_common_block_address_((char*)"HWPROP",6);
46 fHwunam = (Hwunam_t*) herwig6_common_block_address_((char*)"HWUNAM",6);
47 fHwupdt = (Hwupdt_t*) herwig6_common_block_address_((char*)"HWUPDT",6);
48 fHwuwts = (Hwuwts_t*) herwig6_common_block_address_((char*)"HWUWTS",6);
49 fHwuclu = (Hwuclu_t*) herwig6_common_block_address_((char*)"HWUCLU",6);
50 fHwdist = (Hwdist_t*) herwig6_common_block_address_((char*)"HWDIST",6);
51 fHwqdks = (Hwqdks_t*) herwig6_common_block_address_((char*)"HWQDKS",6);
52 fHwusud = (Hwusud_t*) herwig6_common_block_address_((char*)"HWUSUD",6);
53 fHwsusy = (Hwsusy_t*) herwig6_common_block_address_((char*)"HWSUSY",6);
54 fHwrpar = (Hwrpar_t*) herwig6_common_block_address_((char*)"HWRPAR",6);
55 fHwminb = (Hwminb_t*) herwig6_common_block_address_((char*)"HWMINB",6);
56 fHwclus = (Hwclus_t*) herwig6_common_block_address_((char*)"HWCLUS",6);
59 //------------------------------------------------------------------------------
62 // Destroys the object, deletes and disposes all TParticles currently on list.
71 //______________________________________________________________________________
72 void THerwig6::GenerateEvent()
77 // generate hard subprocess
79 // generate parton cascades
81 // do heavy objects decay
83 // do cluster formation
87 // do unstable particle decays
89 // do heavy flavor hadrons decay
91 // add soft underlying event
97 //______________________________________________________________________________
98 void THerwig6::OpenFortranFile(int lun, char* name) {
99 herwig6_open_fortran_file_(&lun, name, strlen(name));
102 //______________________________________________________________________________
103 void THerwig6::CloseFortranFile(int lun) {
104 herwig6_close_fortran_file_(&lun);
107 void THerwig6::Initialize(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc)
110 // perform the initialization for Herwig6
111 // sets correct title.
112 // after calling this method all parameters are set to their default
113 // values. If you want to modify any parameter you have to set the new
114 // value after calling Initialize and before PrepareRun.
117 strncpy(cbeam,beam,8);
119 strncpy(ctarget,target,8);
120 printf("\n Initializing Herwig !! \n");
121 if ( (!strncmp(beam, "E+" ,2)) &&
122 (!strncmp(beam, "E-" ,2)) &&
123 (!strncmp(beam, "MU+" ,3)) &&
124 (!strncmp(beam, "MU-" ,3)) &&
125 (!strncmp(beam, "NUE" ,3)) &&
126 (!strncmp(beam, "NUEB" ,4)) &&
127 (!strncmp(beam, "NUMU" ,4)) &&
128 (!strncmp(beam, "NMUB" ,4)) &&
129 (!strncmp(beam, "NTAU" ,4)) &&
130 (!strncmp(beam, "NTAB" ,4)) &&
131 (!strncmp(beam, "GAMA" ,4)) &&
132 (!strncmp(beam, "P ",8)) &&
133 (!strncmp(beam, "PBAR ",8)) &&
134 (!strncmp(beam, "N" ,1)) &&
135 (!strncmp(beam, "NBAR" ,4)) &&
136 (!strncmp(beam, "PI+" ,3)) &&
137 (!strncmp(beam, "PI-" ,3)) ) {
138 printf("WARNING! In THerwig6:Initialize():\n");
139 printf(" specified beam=%s is unrecognized .\n",beam);
140 printf(" resetting to \"P\" .");
144 if ( (!strncmp(target, "E+" ,2)) &&
145 (!strncmp(target, "E-" ,2)) &&
146 (!strncmp(target, "MU+" ,3)) &&
147 (!strncmp(target, "MU-" ,3)) &&
148 (!strncmp(target, "NUE" ,3)) &&
149 (!strncmp(target, "NUEB" ,4)) &&
150 (!strncmp(target, "NUMU" ,4)) &&
151 (!strncmp(target, "NMUB" ,4)) &&
152 (!strncmp(target, "NTAU" ,4)) &&
153 (!strncmp(target, "NTAB" ,4)) &&
154 (!strncmp(target, "GAMA" ,4)) &&
155 (!strncmp(target, "P ",8)) &&
156 (!strncmp(target, "PBAR ",8)) &&
157 (!strncmp(target, "N" ,1)) &&
158 (!strncmp(target, "NBAR" ,4)) &&
159 (!strncmp(target, "PI+" ,3)) &&
160 (!strncmp(target, "PI-" ,3)) ) {
161 printf("WARNING! In THerwig6:Initialize():\n");
162 printf(" specified target=%s is unrecognized .\n",target);
163 printf(" resetting to \"P\" .");
164 sprintf(ctarget,"P");
169 strncpy(fHwbmch->PART1,beam,8);
170 strncpy(fHwbmch->PART2,target,8);
172 fHwproc->PBEAM1=pbeam1;
173 fHwproc->PBEAM2=pbeam2;
174 // process to generate
175 fHwproc->IPROC=iproc;
176 // not used in the class definition
179 // reset all parameters
184 double win=pbeam1+pbeam2;
185 printf("\n %s - %s at %g GeV",beam,target,win);
186 sprintf(atitle,"%s-%s at %g GeV",cbeam,ctarget,win);
190 void THerwig6::PrepareRun()
192 // compute parameter dependent constants
194 // initialize elementary processes
198 //______________________________________________________________________________
199 TObjArray* THerwig6::ImportParticles(Option_t *option)
202 // Default primary creation method. It reads the /HEPEVT/ common block which
203 // has been filled by the GenerateEvent method. If the event generator does
204 // not use the HEPEVT common block, This routine has to be overloaded by
206 // The default action is to store only the stable particles (ISTHEP = 1)
207 // This can be demanded explicitly by setting the option = "Final"
208 // If the option = "All", all the particles are stored.
211 Int_t numpart = fHepevt->NHEP;
212 TClonesArray &a = *((TClonesArray*)fParticles);
213 if (!strcmp(option,"") || !strcmp(option,"Final")) {
214 for (Int_t i = 0; i<=numpart; i++) {
215 if (fHepevt->ISTHEP[i] == 1) {
217 // Use the common block values for the TParticle constructor
222 fHepevt->JMOHEP[i][0]-1,
223 fHepevt->JMOHEP[i][1]-1,
224 fHepevt->JDAHEP[i][0]-1,
225 fHepevt->JDAHEP[i][1]-1,
234 fHepevt->VHEP[i][3]);
238 else if (!strcmp(option,"All")) {
239 for (Int_t i = 0; i<=numpart; i++) {
243 fHepevt->JMOHEP[i][0]-1,
244 fHepevt->JMOHEP[i][1]-1,
245 fHepevt->JDAHEP[i][0]-1,
246 fHepevt->JDAHEP[i][1]-1,
255 fHepevt->VHEP[i][3]);
261 //______________________________________________________________________________
262 Int_t THerwig6::ImportParticles(TClonesArray *particles, Option_t *option)
265 // Default primary creation method. It reads the /HEPEVT/ common block which
266 // has been filled by the GenerateEvent method. If the event generator does
267 // not use the HEPEVT common block, This routine has to be overloaded by
269 // The function loops on the generated particles and store them in
270 // the TClonesArray pointed by the argument particles.
271 // The default action is to store only the stable particles (ISTHEP = 1)
272 // This can be demanded explicitly by setting the option = "Final"
273 // If the option = "All", all the particles are stored.
275 if (particles == 0) return 0;
276 TClonesArray &Particles = *particles;
278 Int_t numpart = fHepevt->NHEP;
279 if (!strcmp(option,"") || !strcmp(option,"Final")) {
280 for (Int_t i = 0; i< numpart; i++) {
281 if (fHepevt->ISTHEP[i] == 1) {
283 // Use the common block values for the TParticle constructor
285 new(Particles[i]) TParticle(
288 fHepevt->JMOHEP[i][0]-1,
289 fHepevt->JMOHEP[i][1]-1,
290 fHepevt->JDAHEP[i][0]-1,
291 fHepevt->JDAHEP[i][1]-1,
300 fHepevt->VHEP[i][3]);
304 else if (!strcmp(option,"All")) {
305 for (Int_t i = 0; i< numpart; i++) {
306 new(Particles[i]) TParticle(
309 fHepevt->JMOHEP[i][0]-1,
310 fHepevt->JMOHEP[i][1]-1,
311 fHepevt->JDAHEP[i][0]-1,
312 fHepevt->JDAHEP[i][1]-1,
321 fHepevt->VHEP[i][3]);
327 void THerwig6::Hwigin()
332 void THerwig6::Hwuinc()
337 void THerwig6::Hwusta(char* name)
343 void THerwig6::Hweini()
349 void THerwig6::Hwuine()
355 void THerwig6::Hwepro()
361 void THerwig6::Hwbgen()
367 void THerwig6::Hwdhob()
373 void THerwig6::Hwcfor()
379 void THerwig6::Hwcdec()
385 void THerwig6::Hwdhad()
391 void THerwig6::Hwdhvy()
397 void THerwig6::Hwmevt()
403 void THerwig6::Hwufne()
409 void THerwig6::Hwefin()
415 void THerwig6::SetupTest()
417 // exampe of running herwig and generating one event
418 // after changing some options
419 Initialize("P","PBAR",900.,900.,1500);
420 // here you can set some parameters
421 SetPTMIN(15.); // Min pt in hadronic jet production
422 SetYJMIN(-4.); // Min jet rapidity
423 SetYJMAX(4.); // Max jet rapidity
424 // after you set your wished parameters
425 // herwig can do its work
427 int n_ev_to_generate=1;
428 for (int i=0;i<n_ev_to_generate;i++)
431 // do your stuff. For ex:
432 int n_of_par=GetNumberOfParticles(); // from TGenerator
433 for (int j=0; j<n_of_par; j++)
435 TParticle* p=GetParticle(j);
436 // here you do whatever you want with the particle