StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarHerwig6.cxx
1 #include "StarHerwig6.h"
2 ClassImp(StarHerwig6);
3 
4 #include "StarCallf77.h"
5 #include "StarGenerator/EVENT/StarGenPPEvent.h"
6 #include "StarGenerator/EVENT/StarGenEPEvent.h"
7 #include "StarGenerator/EVENT/StarGenParticle.h"
8 
9 #include "StarGenerator/UTIL/StarRandom.h"
10 
11 #include <map>
12 #include <iostream>
13 
14 // ---------------------------------------------------------------------------
16 // JFN 9/10/12 7:58pm: In principle the '_' at the end of 'hwrgen_' shouldn't be necessary, but it seems to be. FYI
17 #define hwrgen F77_NAME(hwrgen, HWRGEN)
18 extern "C" {
19  Double_t hwrgen( Int_t *idummy ){
20  return StarRandom::Instance().flat();
21  };
22 };
23 
24 // ---------------------------------------------------------------------------
25 // ---------------------------------------------------------------------------
26 // ---------------------------------------------------------------------------
27 StarHerwig6::StarHerwig6( const Char_t *name ) : StarGenerator(name)
28 {
29 
31  mStatusCode[0] = StarGenParticle::kNull;
32  mStatusCode[1] = StarGenParticle::kFinal;
33  mStatusCode[2] = StarGenParticle::kDocumentation;
34  mStatusCode[3] = StarGenParticle::kDocumentation;
36  // First we set 100-201 to kDocumentation in bulk...
37  for ( UInt_t i=0; i<101; i++)
38  {
39  mStatusCode[i+100] = StarGenParticle::kDocumentation;
40  }
41  // ...then go back and fix the ones we know.
43  mStatusCode[101] = StarGenParticle::kIncident;
45  mStatusCode[102] = StarGenParticle::kIncident;
46 
47 
48 }
49 // ---------------------------------------------------------------------------
50 // ---------------------------------------------------------------------------
51 // ---------------------------------------------------------------------------
53 void StarHerwig6::SetProcess( Int_t proccess )
54 {
55  hwproc().iproc = proccess;
56 }
57 
59 {
60 
61  //
62  // Create a new event record for either pp or ep events
63  //
64  if ( ( mBlue == "proton" ) && ( mYell == "proton" ) ) mEvent = new StarGenPPEvent();
65  else mEvent = new StarGenEPEvent();
66 
68  std::map< TString, string > particle;
70  particle["proton"] = "P ";
71  particle["e-"] = "E- ";
72 
74  if ( mFrame=="COM" )
75  {
76  Fatal(GetName(),"COM is an invalid frame for Herwig. Exiting");
77  assert(0); // JFN 9/7/12: Note: if this wont compile use error(0);
78  }
79  if ( mFrame=="3MOM" || mFrame=="4MOM" || mFrame=="5MOM" )
80  {
81  // All Herwig asks for is the "momentum of the beams", so I am giving it p_z
82  hwproc().pbeam1 = mBlueMomentum.Pz();
83  hwproc().pbeam2 = -mYellMomentum.Pz();
84  }
85 
88  SetBeams( particle[mBlue], particle[mYell] );
89 
91  std::vector<string> StableParticles;
92  // PI0 111
93  StableParticles.push_back("PI0 ");
94  // PI+ 211
95  StableParticles.push_back("PI+ ");
96  // ETA 221
97  StableParticles.push_back("ETA ");
98  // K+ 321
99  StableParticles.push_back("K+ ");
100  // K_SHORT 310
101  StableParticles.push_back("K_S0 ");
102  // K_LONG 130
103  StableParticles.push_back("K_L0 ");
104  // LAMBDA0 3122
105  StableParticles.push_back("LAMBDA ");
106  // JFN 9/10/12: I looked up the particle names in herwig6520.F and I am 99.999% sure the following two are correct, but they make the code throw a fit and aren't recognized.
107  // SIGMA0 3212
108  //StableParticles.push_back("SIMGA0 ");
109  // SIGMA- 3112
110  //StableParticles.push_back("SIMGA- ");
111  // SIGMA+ 3222
112  StableParticles.push_back("SIGMA+ ");
113  // Xi- 3312
114  StableParticles.push_back("XI- ");
115  // Xi0 3322
116  StableParticles.push_back("XI0 ");
117  // OMEGA- 3334
118  StableParticles.push_back("OMEGA- ");
119 
120  HWInit( StableParticles );
121 
122  return StMaker::Init();
123 }
124 // ----------------------------------------------------------------------------
125 //
126 // ----------------------------------------------------------------------------
128 {
130  HWGenerate();
131 
132  // Blue beam is a proton, running PP
133  if ( ( mBlue == "proton" ) && ( mYell == "proton" ) ) FillPP( mEvent );
134  // Otherwise, runnin EP
135  else FillEP( mEvent );
136 
137  //Do Stuff with the particles
138  mNumberOfParticles = hepevt().nhep;
139  for ( Int_t idx=1; idx<=mNumberOfParticles; idx++ )
140  {
141 
142  Int_t id = hepevt().idhep(idx);
143  Int_t stat = mStatusCode[ hepevt().isthep(idx) ];
144  if ( !stat ) {
146  }
147  Int_t m1 = hepevt().jmohep(idx,1);
148  Int_t m2 = hepevt().jmohep(idx,2);
149  Int_t d1 = hepevt().jdahep(idx,1);
150  Int_t d2 = hepevt().jdahep(idx,2);
151  Double_t px = hepevt().phep(idx,1);
152  Double_t py = hepevt().phep(idx,2);
153  Double_t pz = hepevt().phep(idx,3);
154  Double_t E = hepevt().phep(idx,4);
155  Double_t M = hepevt().phep(idx,5);
156  Double_t vx = hepevt().vhep(idx,1);
157  Double_t vy = hepevt().vhep(idx,2);
158  Double_t vz = hepevt().vhep(idx,3);
159  Double_t vt = hepevt().vhep(idx,4);
160 
161  mEvent -> AddParticle( stat, id, m1, m2, d1, d2, px, py, pz, E, M, vx, vy, vz, vt );
162  }
163 
164  return kStOK;
165 }
166 // ----------------------------------------------------------------------------
167 //
168 // ----------------------------------------------------------------------------
169 void StarHerwig6::Clear( const Option_t *opts )
170 {
171 
173  HWFinish();
174  //.... may be better to move to Finalize() ?
175 
176  return;
177 }
178 // ----------------------------------------------------------------------------
179 //
180 // ----------------------------------------------------------------------------
182 {
183 
184  // Fill the event-wise information
185  StarGenPPEvent *myevent = (StarGenPPEvent *)event;
186  myevent -> idBlue = hwbeam().ipart1;
187  myevent -> idYell = hwbeam().ipart2;
188  myevent -> process = hwproc().iproc;
189  myevent -> subprocess = 0;
190 
191  myevent -> idParton1 = -999;
192  myevent -> idParton2 = -999;
193  myevent -> xParton1 = hwhard().xx(1);
194  myevent -> xParton2 = hwhard().xx(2);
195  myevent -> xPdf1 = -999;
196  myevent -> xPdf2 = -999;
197  myevent -> Q2fac = -999;
198  myevent -> Q2ren = -999;
199  myevent -> valence1 = 0;
200  myevent -> valence2 = 0;
201 
202  myevent -> sHat = custom().hwmans;
203  myevent -> tHat = custom().hwmant;
204  myevent -> uHat = custom().hwmanu;
205  myevent -> ptHat = -999;
206  myevent -> thetaHat = -999;
207  myevent -> phiHat = -999;
208 
209  myevent -> weight = -999;
210 
211 }
212 // ----------------------------------------------------------------------------
213 //
214 // ----------------------------------------------------------------------------
216 {
217 
218  // Fill the event-wise information
219  StarGenPPEvent *myevent = (StarGenPPEvent *)event;
220  myevent -> idBlue = hwbeam().ipart1;
221  myevent -> idYell = hwbeam().ipart2;
222  myevent -> process = hwproc().iproc;
223  myevent -> subprocess = 0;
224 
225  myevent -> idParton1 = -999;
226  myevent -> idParton2 = -999;
227  myevent -> xParton1 = hwhard().xx(1);
228  myevent -> xParton2 = hwhard().xx(2);
229  myevent -> xPdf1 = -999;
230  myevent -> xPdf2 = -999;
231  myevent -> Q2fac = -999;
232  myevent -> Q2ren = -999;
233  myevent -> valence1 = 0;
234  myevent -> valence2 = 0;
235 
236  myevent -> sHat = custom().hwmans;
237  myevent -> tHat = custom().hwmant;
238  myevent -> uHat = custom().hwmanu;
239  myevent -> ptHat = -999;
240  myevent -> thetaHat = -999;
241  myevent -> phiHat = -999;
242 
243  myevent -> weight = -999;
244 
245 }
StarHerwig6(const Char_t *name="Herwig6")
Definition: StarHerwig6.cxx:27
static StarRandom & Instance()
Obtain the single instance of the random number generator.
Definition: StarRandom.cxx:87
TString mYell
Name of the yellow beam particle (-z)
HEPEVT_t & hepevt()
HEPEVT Standard event common block.
Definition: StarHerwig6.h:27
void HWFinish()
HWFinish cleans up after Herwig.
Definition: StarHerwig6.h:53
Event record class tailored to PP kinematics.
Int_t Init()
Definition: StarHerwig6.cxx:58
TLorentzVector mYellMomentum
4-Momentum of the yellow beam
ABC for defining event generator interfaces.
Definition: StarGenerator.h:34
StarGenEvent * mEvent
Generated event.
void Clear(const Option_t *opts)
TLorentzVector mBlueMomentum
4-Momentum of the blue beam
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:68
void HWInit(std::vector< string > particles)
HWInit runs all of the fortan functions necessary to initialize Herwig and get it ready to generate e...
Definition: StarHerwig6.h:49
Base class for event records.
Definition: StarGenEvent.h:81
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237
void SetProcess(Int_t proccess)
SetProcess sets the Herwig process.
Definition: StarHerwig6.cxx:53
void SetBeams(std::string beam1, std::string beam2)
SetBeams reaches into a common block and sets the beam species.
Definition: StarHerwig6.h:43
Event record class tailored to DIS kinemaics.
Definition: Stypes.h:40
void FillEP(StarGenEvent *event)
(Optional) Method to fill a DIS event
TString mFrame
Frame of the collision, i.e. CMS, FIXT, 3MOM, 4MOM, 5MOM.
TString mBlue
Name of the blue beam particle (+z)
Int_t Generate()
void HWGenerate()
HWGenerate runs all of the fortran functions necessary to generate a Herwig event.
Definition: StarHerwig6.h:51
CUSTOM_t & custom()
Custom common block to make certain variables accessible.
Definition: StarHerwig6.h:38
void FillPP(StarGenEvent *event)
(Optional) Method to fill a PP event
HWBEAM_t & hwbeam()
HWBEAM, HWBMCH, HWPROC: Beams, process, and number of events.
Definition: StarHerwig6.h:29