1 // definition of c++ Class THerwig6 to be used in ROOT
2 // this is a c++ interface to the F77 Herwig6 program
3 // author: j. g. contreras jgcn@moni.mda.cinvestav.mx
4 // date: december 22, 2000
5 // Class THerwig6 is an interface to the Herwig program
7 // C-----------------------------------------------------------------------
10 // C a Monte Carlo event generator for simulating
11 // C +---------------------------------------------------+
12 // C | Hadron Emission Reactions With Interfering Gluons |
13 // C +---------------------------------------------------+
14 // C I.G. Knowles(*), G. Marchesini(+), M.H. Seymour($) and B.R. Webber(#)
15 // C-----------------------------------------------------------------------
16 // C with Minimal Supersymmetric Standard Model Matrix Elements by
17 // C S. Moretti($) and K. Odagiri($)
18 // C-----------------------------------------------------------------------
19 // C R parity violating Supersymmetric Decays and Matrix Elements by
21 // C-----------------------------------------------------------------------
22 // C matrix element corrections to top decay and Drell-Yan type processes
23 // C by G. Corcella(+)
24 // C-----------------------------------------------------------------------
25 // C Deep Inelastic Scattering and Heavy Flavour Electroproduction by
26 // C G. Abbiendi(@) and L. Stanco(%)
27 // C-----------------------------------------------------------------------
28 // C and Jet Photoproduction in Lepton-Hadron Collisions by J. Chyla(~)
29 // C-----------------------------------------------------------------------
30 // C(*) Department of Physics & Astronomy, University of Edinburgh
31 // C(+) Dipartimento di Fisica, Universita di Milano
32 // C($) Rutherford Appleton Laboratory
33 // C(#) Cavendish Laboratory, Cambridge
34 // C(&) Department of Physics, University of Oxford
35 // C(@) Dipartimento di Fisica, Universita di Bologna
36 // C(%) Dipartimento di Fisica, Universita di Padova
37 // C(~) Institute of Physics, Prague
38 // C-----------------------------------------------------------------------
39 // C Version 6.100 - 16th December 1999
40 // C-----------------------------------------------------------------------
42 // C G.Marchesini, B.R.Webber, G.Abbiendi, I.G.Knowles, M.H.Seymour,
43 // C and L.Stanco, Computer Physics Communications 67 (1992) 465.
44 // C-----------------------------------------------------------------------
45 // C Please send e-mail about this program to one of the authors at the
46 // C following Internet addresses:
47 // C I.Knowles@ed.ac.uk Giuseppe.Marchesini@mi.infn.it
48 // C M.Seymour@rl.ac.uk webber@hep.phy.cam.ac.uk
49 // C-----------------------------------------------------------------------
54 #include "TClonesArray.h"
55 #include "TParticle.h"
56 #include "TObjArray.h"
62 void herwig6_open_fortran_file_ (int* lun, char* name, int);
63 void herwig6_close_fortran_file_(int* lun);
67 THerwig6::THerwig6() : TGenerator("Herwig6","Herwig6")
70 // THerwig6 constructor: creates a TClonesArray in which it will store all
71 // particles. Note that there may be only one functional THerwig6 object
72 // at a time, so it's not use to create more than one instance of it.
74 delete fParticles; // was allocated as TObjArray in TGenerator
75 fParticles = new TClonesArray("TParticle",50);
77 // initialize common-blocks
80 THerwig6::THerwig6(const THerwig6 & source): TGenerator(source)
82 Fatal("THerwig6","Copy constructor not implemented yet");
84 //------------------------------------------------------------------------------
87 // Destructor. The data members of TGenerator are delete by itself
90 //______________________________________________________________________________
91 void THerwig6::GenerateEvent()
96 // generate hard subprocess
98 // generate parton cascades
100 // do heavy objects decay
102 // do cluster formation
106 // do unstable particle decays
108 // do heavy flavor hadrons decay
110 // add soft underlying event
115 //______________________________________________________________________________
116 void THerwig6::OpenFortranFile(int lun, char* name) {
117 herwig6_open_fortran_file_(&lun, name, strlen(name));
120 //______________________________________________________________________________
121 void THerwig6::CloseFortranFile(int lun) {
122 herwig6_close_fortran_file_(&lun);
125 void THerwig6::Initialize(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc)
128 // perform the initialization for Herwig6
129 // sets correct title.
130 // after calling this method all parameters are set to their default
131 // values. If you want to modify any parameter you have to set the new
132 // value after calling Initialize and before PrepareRun.
135 strncpy(cbeam,beam,8);
137 strncpy(ctarget,target,8);
138 printf("\n Initializing Herwig !! \n");
139 if ( (!strncmp(beam, "E+" ,2)) &&
140 (!strncmp(beam, "E-" ,2)) &&
141 (!strncmp(beam, "MU+" ,3)) &&
142 (!strncmp(beam, "MU-" ,3)) &&
143 (!strncmp(beam, "NUE" ,3)) &&
144 (!strncmp(beam, "NUEB" ,4)) &&
145 (!strncmp(beam, "NUMU" ,4)) &&
146 (!strncmp(beam, "NMUB" ,4)) &&
147 (!strncmp(beam, "NTAU" ,4)) &&
148 (!strncmp(beam, "NTAB" ,4)) &&
149 (!strncmp(beam, "GAMA" ,4)) &&
150 (!strncmp(beam, "P ",8)) &&
151 (!strncmp(beam, "PBAR ",8)) &&
152 (!strncmp(beam, "N" ,1)) &&
153 (!strncmp(beam, "NBAR" ,4)) &&
154 (!strncmp(beam, "PI+" ,3)) &&
155 (!strncmp(beam, "PI-" ,3)) ) {
156 printf("WARNING! In THerwig6:Initialize():\n");
157 printf(" specified beam=%s is unrecognized .\n",beam);
158 printf(" resetting to \"P\" .");
162 if ( (!strncmp(target, "E+" ,2)) &&
163 (!strncmp(target, "E-" ,2)) &&
164 (!strncmp(target, "MU+" ,3)) &&
165 (!strncmp(target, "MU-" ,3)) &&
166 (!strncmp(target, "NUE" ,3)) &&
167 (!strncmp(target, "NUEB" ,4)) &&
168 (!strncmp(target, "NUMU" ,4)) &&
169 (!strncmp(target, "NMUB" ,4)) &&
170 (!strncmp(target, "NTAU" ,4)) &&
171 (!strncmp(target, "NTAB" ,4)) &&
172 (!strncmp(target, "GAMA" ,4)) &&
173 (!strncmp(target, "P ",8)) &&
174 (!strncmp(target, "PBAR ",8)) &&
175 (!strncmp(target, "N" ,1)) &&
176 (!strncmp(target, "NBAR" ,4)) &&
177 (!strncmp(target, "PI+" ,3)) &&
178 (!strncmp(target, "PI-" ,3)) ) {
179 printf("WARNING! In THerwig6:Initialize():\n");
180 printf(" specified target=%s is unrecognized .\n",target);
181 printf(" resetting to \"P\" .");
182 sprintf(ctarget,"P");
187 strncpy(HWBMCH.PART1,beam,8);
188 strncpy(HWBMCH.PART2,target,8);
190 HWPROC.PBEAM1=pbeam1;
191 HWPROC.PBEAM2=pbeam2;
192 // process to generate
194 // not used in the class definition
197 // reset all parameters
202 double win=pbeam1+pbeam2;
203 printf("\n %s - %s at %g GeV \n",beam,target,win);
204 //sprintf(atitle,"%s-%s at %g GeV",cbeam,ctarget,win);
208 void THerwig6::InitializeJimmy(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc)
211 // perform the initialization for Herwig6
212 // sets correct title.
213 // after calling this method all parameters are set to their default
214 // values. If you want to modify any parameter you have to set the new
215 // value after calling Initialize and before PrepareRun.
218 strncpy(cbeam,beam,8);
220 strncpy(ctarget,target,8);
221 printf("\n Initializing Herwig !! \n");
222 if ( (!strncmp(beam, "E+" ,2)) &&
223 (!strncmp(beam, "E-" ,2)) &&
224 (!strncmp(beam, "MU+" ,3)) &&
225 (!strncmp(beam, "MU-" ,3)) &&
226 (!strncmp(beam, "NUE" ,3)) &&
227 (!strncmp(beam, "NUEB" ,4)) &&
228 (!strncmp(beam, "NUMU" ,4)) &&
229 (!strncmp(beam, "NMUB" ,4)) &&
230 (!strncmp(beam, "NTAU" ,4)) &&
231 (!strncmp(beam, "NTAB" ,4)) &&
232 (!strncmp(beam, "GAMA" ,4)) &&
233 (!strncmp(beam, "P ",8)) &&
234 (!strncmp(beam, "PBAR ",8)) &&
235 (!strncmp(beam, "N" ,1)) &&
236 (!strncmp(beam, "NBAR" ,4)) &&
237 (!strncmp(beam, "PI+" ,3)) &&
238 (!strncmp(beam, "PI-" ,3)) ) {
239 printf("WARNING! In THerwig6:Initialize():\n");
240 printf(" specified beam=%s is unrecognized .\n",beam);
241 printf(" resetting to \"P\" .");
245 if ( (!strncmp(target, "E+" ,2)) &&
246 (!strncmp(target, "E-" ,2)) &&
247 (!strncmp(target, "MU+" ,3)) &&
248 (!strncmp(target, "MU-" ,3)) &&
249 (!strncmp(target, "NUE" ,3)) &&
250 (!strncmp(target, "NUEB" ,4)) &&
251 (!strncmp(target, "NUMU" ,4)) &&
252 (!strncmp(target, "NMUB" ,4)) &&
253 (!strncmp(target, "NTAU" ,4)) &&
254 (!strncmp(target, "NTAB" ,4)) &&
255 (!strncmp(target, "GAMA" ,4)) &&
256 (!strncmp(target, "P ",8)) &&
257 (!strncmp(target, "PBAR ",8)) &&
258 (!strncmp(target, "N" ,1)) &&
259 (!strncmp(target, "NBAR" ,4)) &&
260 (!strncmp(target, "PI+" ,3)) &&
261 (!strncmp(target, "PI-" ,3)) ) {
262 printf("WARNING! In THerwig6:Initialize():\n");
263 printf(" specified target=%s is unrecognized .\n",target);
264 printf(" resetting to \"P\" .");
265 sprintf(ctarget,"P");
270 strncpy(HWBMCH.PART1,beam,8);
271 strncpy(HWBMCH.PART2,target,8);
273 HWPROC.PBEAM1=pbeam1;
274 HWPROC.PBEAM2=pbeam2;
275 // process to generate
277 // not used in the class definition
280 // reset all parameters
282 // JIMMY initialization
287 double win=pbeam1+pbeam2;
288 printf("\n %s - %s at %g GeV",beam,target,win);
289 // sprintf(atitle,"%s-%s at %g GeV",cbeam,ctarget,win);
293 void THerwig6::PrepareRun()
295 // compute parameter dependent constants
297 // initialize elementary processes
301 void THerwig6::PrepareRunJimmy()
303 // compute parameter dependent constants
305 // initialize elementary processes
307 // more initializations for JIMMY
310 //______________________________________________________________________________
311 TObjArray* THerwig6::ImportParticles(Option_t *option)
314 // Default primary creation method. It reads the /HEPEVT/ common block which
315 // has been filled by the GenerateEvent method. If the event generator does
316 // not use the HEPEVT common block, This routine has to be overloaded by
318 // The default action is to store only the stable particles (ISTHEP = 1)
319 // This can be demanded explicitly by setting the option = "Final"
320 // If the option = "All", all the particles are stored.
323 Int_t numpart = HEPEVT.NHEP;
324 TClonesArray &a = *((TClonesArray*)fParticles);
325 if (!strcmp(option,"") || !strcmp(option,"Final")) {
326 for (Int_t i = 0; i < numpart; i++) {
327 if (HEPEVT.ISTHEP[i] == 1) {
329 // Use the common block values for the TParticle constructor
334 HEPEVT.JMOHEP[i][0]-1,
335 HEPEVT.JMOHEP[i][1]-1,
336 HEPEVT.JDAHEP[i][0]-1,
337 HEPEVT.JDAHEP[i][1]-1,
350 else if (!strcmp(option,"All")) {
351 for (Int_t i = 0; i < numpart; i++) {
355 HEPEVT.JMOHEP[i][0]-1,
356 HEPEVT.JMOHEP[i][1]-1,
357 HEPEVT.JDAHEP[i][0]-1,
358 HEPEVT.JDAHEP[i][1]-1,
373 //______________________________________________________________________________
374 Int_t THerwig6::ImportParticles(TClonesArray *particles, Option_t *option)
377 // Default primary creation method. It reads the /HEPEVT/ common block which
378 // has been filled by the GenerateEvent method. If the event generator does
379 // not use the HEPEVT common block, This routine has to be overloaded by
381 // The function loops on the generated particles and store them in
382 // the TClonesArray pointed by the argument particles.
383 // The default action is to store only the stable particles (ISTHEP = 1)
384 // This can be demanded explicitly by setting the option = "Final"
385 // If the option = "All", all the particles are stored.
387 if (particles == 0) return 0;
388 TClonesArray &refParticles = *particles;
389 refParticles.Clear();
390 Int_t numpart = HEPEVT.NHEP;
391 if (!strcmp(option,"") || !strcmp(option,"Final")) {
392 for (Int_t i = 0; i < numpart; i++) {
393 if (HEPEVT.ISTHEP[i] == 1) {
395 // Use the common block values for the TParticle constructor
397 new(refParticles[i]) TParticle(
400 HEPEVT.JMOHEP[i][0]-1,
401 HEPEVT.JMOHEP[i][1]-1,
402 HEPEVT.JDAHEP[i][0]-1,
403 HEPEVT.JDAHEP[i][1]-1,
416 else if (!strcmp(option,"All")) {
417 for (Int_t i = 0; i< numpart; i++) {
418 new(refParticles[i]) TParticle(
421 HEPEVT.JMOHEP[i][0]-1,
422 HEPEVT.JMOHEP[i][1]-1,
423 HEPEVT.JDAHEP[i][0]-1,
424 HEPEVT.JDAHEP[i][1]-1,
433 HEPEVT.VHEP[i][3]); //
439 void THerwig6::Hwigin()
444 void THerwig6::Hwuinc()
449 void THerwig6::Hwusta(const char* name)
455 void THerwig6::Hweini()
461 void THerwig6::Hwuine()
467 void THerwig6::Hwepro()
473 void THerwig6::Hwbgen()
479 void THerwig6::Hwdhob()
485 void THerwig6::Hwcfor()
491 void THerwig6::Hwcdec()
497 void THerwig6::Hwdhad()
503 void THerwig6::Hwdhvy()
509 void THerwig6::Hwmevt()
515 void THerwig6::Hwufne()
521 void THerwig6::Hwefin()
527 void THerwig6::Hwiodk(int iopt)
533 void THerwig6::SetupTest()
535 // exampe of running herwig and generating one event
536 // after changing some options
537 Initialize("P","PBAR",900.,900.,1500);
538 // here you can set some parameters
539 SetPTMIN(15.); // Min pt in hadronic jet production
540 SetYJMIN(-4.); // Min jet rapidity
541 SetYJMAX(4.); // Max jet rapidity
542 // after you set your wished parameters
543 // herwig can do its work
546 for (int i=0;i<nEvToGenerate;i++)
549 // do your stuff. For ex:
550 int nOfPar=GetNumberOfParticles(); // from TGenerator
551 for (int j=0; j<nOfPar; j++)
553 TParticle* p=GetParticle(j);
554 // here you do whatever you want with the particle
562 void THerwig6::Jminit()
567 void THerwig6::Jimmin()
572 void THerwig6::Jmefin()
577 void THerwig6::PrintEvt()
583 // acces to hep common block
584 int THerwig6::GetNEVHEP () const { return HEPEVT.NEVHEP; }
585 int THerwig6::GetNhep () const { return HEPEVT.NHEP; }
586 int THerwig6::GetISTHEP (int i)const { return HEPEVT.ISTHEP[i-1]; }
587 int THerwig6::GetIDHEP (int i)const { return HEPEVT.IDHEP[i-1]; }
588 int THerwig6::GetJMOHEP (int i, int j) const
589 { return HEPEVT.JMOHEP[i-1][j-1]; }
590 int THerwig6::GetJDAHEP (int i, int j) const
591 { return HEPEVT.JDAHEP[i-1][j-1]; }
592 double THerwig6::GetPHEP (int i, int j) const
593 { return HEPEVT.PHEP[i-1][j-1]; }
594 double THerwig6::GetVHEP (int i, int j) const
595 { return HEPEVT.VHEP[i-1][j-1]; }
597 // access to Herwig6 common-blocks
598 // WARNING: Some arrays start in 1, others in 0. Look up the manual!
602 int THerwig6::GetIPART1 () const { return HWBEAM.IPART1; }
603 int THerwig6::GetIPART2 () const { return HWBEAM.IPART2; }
606 char* THerwig6::GetPART1 () const { return HWBMCH.PART1; }
607 char* THerwig6::GetPART2 () const { return HWBMCH.PART2; }
611 double THerwig6::GetEBEAM1 () const { return HWPROC.EBEAM1; }
612 double THerwig6::GetEBEAM2 () const { return HWPROC.EBEAM2; }
613 double THerwig6::GetPBEAM1 () const { return HWPROC.PBEAM1; }
614 double THerwig6::GetPBEAM2 () const { return HWPROC.PBEAM2; }
615 int THerwig6::GetIPROC () const { return HWPROC.IPROC; }
616 int THerwig6::GetMAXEV () const { return HWPROC.MAXEV; }
619 double THerwig6::GetQCDLAM () const { return HWPRAM.QCDLAM; }
620 void THerwig6::SetQCDLAM (double q) { HWPRAM.QCDLAM = q; }
621 double THerwig6::GetVQCUT () const { return HWPRAM.VQCUT; }
622 void THerwig6::SetVQCUT (double v) { HWPRAM.VQCUT = v; }
623 double THerwig6::GetVGCUT () const { return HWPRAM.VGCUT; }
624 void THerwig6::SetVGCUT (double v) { HWPRAM.VGCUT = v; }
625 double THerwig6::GetVPCUT () const { return HWPRAM.VPCUT; }
626 void THerwig6::SetVPCUT (double v) { HWPRAM.VPCUT = v; }
627 double THerwig6::GetCLMAX () const { return HWPRAM.CLMAX; }
628 void THerwig6::SetCLMAX (double c) { HWPRAM.CLMAX = c; }
629 double THerwig6::GetCLPOW () const { return HWPRAM.CLPOW; }
630 void THerwig6::SetCLPOW (double c) { HWPRAM.CLPOW = c; }
631 double THerwig6::GetPSPLT (int i) const { return HWPRAM.PSPLT[i-1];}
632 void THerwig6::SetPSPLT (int i, double p) { HWPRAM.PSPLT[i-1] = p;}
633 double THerwig6::GetQDIQK () const { return HWPRAM.QDIQK; }
634 void THerwig6::SetQDIQK (double q) { HWPRAM.QDIQK = q; }
635 double THerwig6::GetPDIQK () const { return HWPRAM.PDIQK; }
636 void THerwig6::SetPDIQK (double p) { HWPRAM.PDIQK = p; }
637 double THerwig6::GetQSPAC () const { return HWPRAM.QSPAC; }
638 void THerwig6::SetQSPAC (double q) { HWPRAM.QSPAC = q; }
639 double THerwig6::GetPTRMS () const { return HWPRAM.PTRMS; }
640 void THerwig6::SetPTRMS (double p) { HWPRAM.PTRMS = p; }
641 double THerwig6::GetENSOF () const { return HWPRAM.ENSOF; }
642 void THerwig6::SetENSOF (double e) { HWPRAM.ENSOF = e; }
643 int THerwig6::GetIPRINT () const { return HWPRAM.IPRINT; }
644 void THerwig6::SetIPRINT (int i) { HWPRAM.IPRINT = i; }
645 int THerwig6::GetMODPDF (int i) const { return HWPRAM.MODPDF[i-1];}
646 void THerwig6::SetMODPDF (int i, int j) { HWPRAM.MODPDF[i-1] = j; }
647 int THerwig6::GetNSTRU () const { return HWPRAM.NSTRU; }
648 void THerwig6::SetNSTRU (int i) { HWPRAM.NSTRU = i; }
651 char* THerwig6::GetAUTPDF (int i) { return HWPRCH.AUTPDF[i-1]; }
652 void THerwig6::SetAUTPDF(int i,const char* s){ strncpy(HWPRCH.AUTPDF[i-1],s,20);}
653 char* THerwig6::GetBDECAY () { return HWPRCH.BDECAY; }
656 double THerwig6::GetAVWGT () const { return HWEVNT.AVWGT; }
657 int THerwig6::GetMAXPR () const { return HWEVNT.MAXPR; }
658 void THerwig6::SetMAXPR (int i) { HWEVNT.MAXPR = i; }
659 int THerwig6::GetMAXER () const { return HWEVNT.MAXER; }
660 void THerwig6::SetMAXER (int i) { HWEVNT.MAXER = i; }
661 int THerwig6::GetNRN (int i) const { return HWEVNT.NRN[i-1]; }
662 void THerwig6::SetNRN (int i, int j) { HWEVNT.NRN[i-1] = j; }
663 double THerwig6::GetEVWGT () const { return HWEVNT.EVWGT; }
665 int THerwig6::GetIDHW (int i) const { return HWEVNT.IDHW[i]; }
667 int THerwig6::GetIERROR () const { return HWEVNT.IERROR; }
670 double THerwig6::GetPTMIN () const { return HWHARD.PTMIN; }
671 void THerwig6::SetPTMIN (double d) { HWHARD.PTMIN = d; }
672 double THerwig6::GetPTMAX () const { return HWHARD.PTMAX; }
673 void THerwig6::SetPTMAX (double d) { HWHARD.PTMAX = d; }
674 double THerwig6::GetPTPOW () const { return HWHARD.PTPOW; }
675 void THerwig6::SetPTPOW (double d) { HWHARD.PTPOW = d; }
676 double THerwig6::GetYJMIN () const { return HWHARD.YJMIN; }
677 void THerwig6::SetYJMIN (double d) { HWHARD.YJMIN = d; }
678 double THerwig6::GetYJMAX () const { return HWHARD.YJMAX; }
679 void THerwig6::SetYJMAX (double d) { HWHARD.YJMAX = d; }
680 double THerwig6::GetQ2MIN () const { return HWHARD.Q2MIN; }
681 void THerwig6::SetQ2MIN (double d) { HWHARD.Q2MIN = d; }
682 double THerwig6::GetQ2MAX () const { return HWHARD.Q2MAX; }
683 void THerwig6::SetQ2MAX (double d) { HWHARD.Q2MAX = d; }
684 double THerwig6::GetYBMIN () const { return HWHARD.YBMIN; }
685 void THerwig6::SetYBMIN (double d) { HWHARD.YBMIN = d; }
686 double THerwig6::GetYBMAX () const { return HWHARD.YBMAX; }
687 void THerwig6::SetYBMAX (double d) { HWHARD.YBMAX = d; }
688 double THerwig6::GetZJMAX () const { return HWHARD.ZJMAX; }
689 void THerwig6::SetZJMAX (double d) { HWHARD.ZJMAX = d; }
692 double THerwig6::GetRMASS (int i) const { return HWPROP.RMASS[i]; }
693 void THerwig6::SetRMASS (int i, double r) { HWPROP.RMASS[i] = r; }
696 void THerwig6::GetRNAME (int i, char a[9]) { for (int j=0;j<8;j++) a[j] = HWUNAM.RNAME[i][j]; a[8] = '\0';}