]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4PhysicsManager.cxx
removed unnecessary includes
[u/mrichter/AliRoot.git] / TGeant4 / TG4PhysicsManager.cxx
1 // $Id$
2 // Category: physics
3 //
4 // See the class description in the header file.
5
6 #include "TG4PhysicsManager.h"
7 #include "TG4PhysicsList.h"
8 #include "TG4CutVector.h"
9 #include "TG4FlagVector.h"
10 #include "TG4G3Defaults.h"
11
12 #include <G4ParticleDefinition.hh>
13
14 #include <TDatabasePDG.h>
15
16 TG4PhysicsManager* TG4PhysicsManager::fgInstance = 0;
17
18 TG4PhysicsManager::TG4PhysicsManager()
19   : fLock(false),
20     fPhysicsList(0),
21     fCutVector(0),
22     fFlagVector(0) 
23
24 //
25   if (fgInstance) {
26     TG4Globals::Exception(
27       "TG4PhysicsManager: attempt to create two instances of singleton.");
28   }
29       
30   fgInstance = this;  
31       
32   // initialize fIsCutVector 
33   fIsCutVector = new TG4boolVector;
34   G4int i;
35   //for (i=0; i<kNofParticlesWSP; i++) fIsCutVector->insert(false);  
36   for (i=0; i<kNofParticlesWSP; i++) fIsCutVector->push_back(false);
37
38   // initialize fIsFlagVector 
39   fIsFlagVector = new TG4boolVector;
40   //for (i=0; i<kNofParticlesWSP; i++) fIsFlagVector->insert(false);
41   for (i=0; i<kNofParticlesWSP; i++) fIsFlagVector->push_back(false);
42
43   // define fCutNameVector
44   fG3CutNameVector.insert("CUTGAM");
45   fG3CutNameVector.insert("CUTELE");
46   fG3CutNameVector.insert("CUTNEU");
47   fG3CutNameVector.insert("CUTHAD");
48   fG3CutNameVector.insert("CUTMUO");
49   fG3CutNameVector.insert("BCUTE");
50   fG3CutNameVector.insert("BCUTM"); 
51   fG3CutNameVector.insert("DCUTE");
52   fG3CutNameVector.insert("DCUTM");
53   fG3CutNameVector.insert("PPCUTM");
54
55   // define fFlagNameVector
56   fG3FlagNameVector.insert("PAIR");
57   fG3FlagNameVector.insert("COMP");
58   fG3FlagNameVector.insert("PHOT");
59   fG3FlagNameVector.insert("PFIS");
60   fG3FlagNameVector.insert("DRAY");
61   fG3FlagNameVector.insert("ANNI");
62   fG3FlagNameVector.insert("BREM");
63   fG3FlagNameVector.insert("HADR");
64   fG3FlagNameVector.insert("MUNU");
65   fG3FlagNameVector.insert("DCAY");
66   fG3FlagNameVector.insert("LOSS");
67   fG3FlagNameVector.insert("MULS");
68 }
69
70 TG4PhysicsManager::TG4PhysicsManager(const TG4PhysicsManager& right) {
71 // 
72   TG4Globals::Exception(
73     "Attempt to copy TG4PhysicsManager singleton.");
74 }
75
76 TG4PhysicsManager::~TG4PhysicsManager() {
77 //
78   delete fIsCutVector;
79   delete fIsFlagVector;
80 }
81
82 // operators
83
84 TG4PhysicsManager& 
85 TG4PhysicsManager::operator=(const TG4PhysicsManager& right)
86 {
87   // check assignement to self
88   if (this == &right) return *this;
89
90   TG4Globals::Exception(
91     "Attempt to assign TG4PhysicsManager singleton.");
92     
93   return *this;  
94 }    
95           
96 // private methods
97
98 void TG4PhysicsManager::LockException() const
99 {
100 // Gives exception in case of attempt to modified physics
101 // setup after physics manager was locked.
102 // ---
103
104   G4String text = "TG4PhysicsManager: \n";
105   text = text + "    It is too late to change physics setup. \n";
106   text = text + "    PhysicsManager has been already locked.";
107   TG4Globals::Exception(text);
108 }
109
110 G4int TG4PhysicsManager::GetPDGEncoding(G4ParticleDefinition* particle)
111 {
112 // Returns the PDG code of particle;
113 // if standard PDG code is not defined the TDatabasePDG
114 // is used.
115 // ---
116
117   // get PDG encoding from G4 particle definition
118   G4int pdgEncoding = particle->GetPDGEncoding();
119
120   if (pdgEncoding == 0) {
121     // get PDG encoding from TDatabasePDG
122   
123     // get particle name from the name map
124     G4String g4name = particle->GetParticleName();
125     G4String tname = fParticleNameMap.GetSecond(g4name);
126     if (tname == "Undefined") {
127       G4String text = "TG4PhysicsManager::GetPDGEncoding: \n";
128       text = text + "    Particle " + g4name;
129       text = text + " was not found in the name map.";
130       TG4Globals::Exception(text);
131     }  
132   
133     // get particle from TDatabasePDG
134     TDatabasePDG* pdgDB = TDatabasePDG::Instance();
135     TParticlePDG* particle = pdgDB->GetParticle(tname);
136     if (!particle) {
137       G4String text = "TG4PhysicsManager::GetPDGEncoding: \n";
138       text = text + "    Particle " + tname;
139       text = text + " was not found in TDatabasePDG.";
140       TG4Globals::Exception(text);
141     }  
142     
143     // get PDG encoding
144     pdgEncoding = particle->PdgCode();
145   }
146     
147   return pdgEncoding;  
148 }  
149      
150 G4int TG4PhysicsManager::GetPDGEncoding(G4String particleName)
151 {
152 // Returns the PDG code of particle sepcified by name.
153 // ---
154
155   G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
156
157   G4ParticleDefinition* particle = 0;  
158   particle = particleTable->FindParticle(particleName);
159   if (!particle) {    
160     G4String text = "TG4PhysicsManager::GetPDGEncoding:\n";
161     text = text + "   G4ParticleTable::FindParticle() " + particleName;
162     text = text + " failed.";
163     TG4Globals::Exception(text);
164   }     
165
166   return GetPDGEncoding(particle);
167 }  
168   
169 void TG4PhysicsManager::SetCut(TG3Cut cut, G4double cutValue)
170 {  
171 // Sets kinetic energy cut (in a G3-like way).
172 // ---
173
174   if (!fCutVector) {
175     // create vector of kinetic energy cut values  
176     fCutVector = new TG4CutVector();
177   }  
178   fCutVector->SetG3Cut(cut, cutValue);
179   SwitchIsCutVector(cut);
180 }  
181
182 void TG4PhysicsManager::SetProcess(TG3Flag flag, G4int flagValue)
183 {
184 // Sets control process flag (in a G3-like way).
185 // ---
186
187   if (!fFlagVector) {
188     // create vector of control process flag values
189     fFlagVector = new TG4FlagVector;
190   }  
191   fFlagVector->SetG3Flag(flag, flagValue);
192
193
194
195 Float_t TG4PhysicsManager::Xsec(char* ch, Float_t p1, Int_t i1, Int_t i2)
196 {
197 // Not yet implemented -> gives exception.
198 // ---
199
200   TG4Globals::Exception(
201     "TG4PhysicsManager::Xsec: not yet implemented.");
202
203   return 0.;
204 }    
205   
206 Int_t TG4PhysicsManager::IdFromPDG(Int_t pdgID) const
207 {
208 // G4 does not use the integer particle identifiers
209 // Id <-> PDG is identity.
210 // ---
211
212   return pdgID;
213 }  
214
215 Int_t TG4PhysicsManager::PDGFromId(Int_t mcID) const
216 {
217 // G4 does not use integer particle identifiers
218 // Id <-> PDG is identity.
219 // ---
220
221   return mcID;
222 }  
223
224 void  TG4PhysicsManager::DefineParticles()
225 {
226   // ======
227   // Taken from TGeant3
228   //
229   // Use ENDF-6 mapping for ions = 10000*z+10*a+iso
230   // and add 1 000 000
231   // and numbers above 5 000 000 for special applications
232   //
233
234   const Int_t kion=10000000;
235   const Int_t kspe=50000000;
236
237   const Double_t kGeV=0.9314943228;
238   const Double_t kHslash = 1.0545726663e-27;
239   const Double_t kErgGeV = 1/1.6021773349e-3;
240   const Double_t kHshGeV = kHslash*kErgGeV;
241   const Double_t kYearsToSec = 3600*24*365.25;
242
243   TDatabasePDG *pdgDB = TDatabasePDG::Instance();
244
245   pdgDB->AddParticle("Deuteron","Deuteron",2*kGeV+8.071e-3,kTRUE,
246                      0,1,"Ion",kion+10020);
247                      
248   pdgDB->AddParticle("Triton","Triton",3*kGeV+14.931e-3,kFALSE,
249                      kHshGeV/(12.33*kYearsToSec),1,"Ion",kion+10030);
250
251   pdgDB->AddParticle("Alpha","Alpha",4*kGeV+2.424e-3,kTRUE,
252                      kHshGeV/(12.33*kYearsToSec),2,"Ion",kion+20040);
253
254   pdgDB->AddParticle("HE3","HE3",3*kGeV+14.931e-3,kFALSE,
255                      0,2,"Ion",kion+20030);
256
257   pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
258                      0,0,"Special",kspe+50);
259
260   pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
261                      0,0,"Special",kspe+51);
262
263
264   // To do: define the PDG database extension
265   // in a common part.
266   //
267   // AliMC::ExtendPDGDatabase(); 
268   //
269   // end of "common" implementation
270   // ======
271
272   // map G4 particle names to TDatabasePDG names
273   // (the map is built only for particles that have not
274   //  defined standard PDG encoding)
275   
276   fParticleNameMap.Add("deuteron","Deuteron");
277   fParticleNameMap.Add("triton",  "Triton");
278   fParticleNameMap.Add("alpha",   "Alpha");
279   fParticleNameMap.Add("He3",     "HE3");
280   fParticleNameMap.Add("opticalphoton","Cherenkov");
281   // fParticleNameMap.Add("???","FeedbackPhoton");
282   fParticleNameMap.Add("geantino", "Rootino");
283   
284   // map G4 particle names to TDatabasePDG encodings
285   fParticlePDGMap.Add("deuteron", GetPDGEncoding("deuteron"));
286   fParticlePDGMap.Add("triton", GetPDGEncoding("triton"));
287   fParticlePDGMap.Add("alpha", GetPDGEncoding("alpha"));
288   fParticlePDGMap.Add("He3", GetPDGEncoding("He3") );
289   fParticlePDGMap.Add("opticalphoton", GetPDGEncoding("opticalphoton"));
290   // fParticlePDGMap.Add("???","FeedbackPhoton");
291   fParticleNameMap.Add("geantino", GetPDGEncoding("geantino"));
292
293   // add verbose
294   G4cout << "Particle maps have been filled." << G4endl;
295   //fParticleNameMap.PrintAll();
296   //fParticlePDGMap.PrintAll();
297 }    
298
299 void TG4PhysicsManager::SwitchIsCutVector(TG3Cut cut)
300 {
301 // Updates the vector of booleans (fIsCutVector) for the specified cut.
302 // ---
303
304   switch (cut) {
305     case kCUTGAM: 
306            (*fIsCutVector)[kGamma] = true; 
307            break;
308     case kBCUTE:
309            (*fIsCutVector)[kGamma] = true; 
310            break;
311     case kBCUTM:
312            (*fIsCutVector)[kGamma] = true; 
313            break;
314     case kCUTELE:
315            (*fIsCutVector)[kElectron] = true; 
316            break;
317     case kDCUTE:
318            (*fIsCutVector)[kElectron] = true; 
319            break;
320     case kDCUTM:
321            (*fIsCutVector)[kElectron] = true; 
322            break;
323     case kCUTNEU:
324            (*fIsCutVector)[kNeutralHadron] = true; 
325            break;
326     case kCUTHAD:
327            (*fIsCutVector)[kChargedHadron] = true; 
328            break;
329     case kCUTMUO:
330            (*fIsCutVector)[kMuon] = true; 
331            break;
332     default:
333            break;
334   }
335 }
336
337 void TG4PhysicsManager::SwitchIsFlagVector(TG3Flag flag)
338 {
339 // Updates the vector of booleans (fIsFlagVector) for the specified flag.
340 // ---
341
342   switch (flag) {
343     case kPAIR: 
344            // gamma
345            (*fIsFlagVector)[kGamma] = true; 
346            break;
347     case kCOMP:
348            // gamma
349            (*fIsFlagVector)[kGamma] = true; 
350            break;
351     case kPHOT:
352            // gamma
353            (*fIsFlagVector)[kGamma] = true; 
354            break;
355     case kPFIS:
356            // gamma
357            (*fIsFlagVector)[kGamma] = true; 
358            break;
359     case kDRAY: 
360            // all charged particles
361            (*fIsFlagVector)[kElectron] = true; 
362            (*fIsFlagVector)[kEplus] = true; 
363            (*fIsFlagVector)[kChargedHadron] = true; 
364            (*fIsFlagVector)[kMuon] = true; 
365            break;
366     case kANNI:
367            // e+ only
368            (*fIsFlagVector)[kEplus] = true; 
369            break;
370     case kBREM:
371            // e-/e+, muons
372            (*fIsFlagVector)[kElectron] = true; 
373            (*fIsFlagVector)[kEplus] = true; 
374            (*fIsFlagVector)[kMuon] = true; 
375            break;
376     case kHADR:
377            // hadrons
378            (*fIsFlagVector)[kNeutralHadron] = true; 
379            (*fIsFlagVector)[kChargedHadron] = true; 
380            break;
381     case kMUNU:
382            // muons
383            (*fIsFlagVector)[kMuon] = true; 
384            break;
385     case kDCAY:
386            // any
387            (*fIsFlagVector)[kAny] = true; 
388            break;
389     case kLOSS:
390            // all charged particles
391            (*fIsFlagVector)[kElectron] = true; 
392            (*fIsFlagVector)[kEplus] = true; 
393            (*fIsFlagVector)[kChargedHadron] = true; 
394            (*fIsFlagVector)[kMuon] = true; 
395            break;
396     case kMULS:
397            // all charged particles
398            (*fIsFlagVector)[kElectron] = true; 
399            (*fIsFlagVector)[kEplus] = true; 
400            (*fIsFlagVector)[kChargedHadron] = true; 
401            (*fIsFlagVector)[kMuon] = true; 
402            break;
403     default:
404           break;
405   }
406 }
407
408 TG3Cut TG4PhysicsManager::GetG3Cut(G4String cutName)
409 {
410 // Retrieves corresponding TG3Cut constant from the cutName.
411 // ---
412
413   if      (cutName == fG3CutNameVector[kCUTGAM]) return kCUTGAM; 
414   else if (cutName == fG3CutNameVector[kBCUTE])  return kBCUTE; 
415   else if (cutName == fG3CutNameVector[kBCUTM])  return kBCUTM; 
416   else if (cutName == fG3CutNameVector[kCUTELE]) return kCUTELE;
417   else if (cutName == fG3CutNameVector[kDCUTE])  return kDCUTE;
418   else if (cutName == fG3CutNameVector[kDCUTM])  return kDCUTM;
419   else if (cutName == fG3CutNameVector[kCUTNEU]) return kCUTNEU;
420   else if (cutName == fG3CutNameVector[kCUTHAD]) return kCUTHAD;
421   else if (cutName == fG3CutNameVector[kCUTMUO]) return kCUTMUO;
422   else return kNoG3Cuts;
423 }
424
425 TG3Flag TG4PhysicsManager::GetG3Flag(G4String flagName)
426 {
427 // Retrieves corresponding TG3Flag constant from the flagName.
428 // ---
429
430   if      (flagName == fG3FlagNameVector[kPAIR]) return kPAIR;
431   else if (flagName == fG3FlagNameVector[kCOMP]) return kCOMP;
432   else if (flagName == fG3FlagNameVector[kPHOT]) return kPHOT;
433   else if (flagName == fG3FlagNameVector[kPFIS]) return kPFIS;
434   else if (flagName == fG3FlagNameVector[kDRAY]) return kDRAY;
435   else if (flagName == fG3FlagNameVector[kANNI]) return kANNI;
436   else if (flagName == fG3FlagNameVector[kBREM]) return kBREM;
437   else if (flagName == fG3FlagNameVector[kHADR]) return kHADR;
438   else if (flagName == fG3FlagNameVector[kMUNU]) return kMUNU;
439   else if (flagName == fG3FlagNameVector[kDCAY]) return kDCAY;
440   else if (flagName == fG3FlagNameVector[kLOSS]) return kLOSS;
441   else if (flagName == fG3FlagNameVector[kMULS]) return kMULS;
442   else return kNoG3Flags;
443 }
444
445 // public methods
446
447 void TG4PhysicsManager::BuildPhysics()
448 {
449 // Empty function - not needed in G4.
450 // (Physics is built within /run/initialize.)
451
452   TG4Globals::Warning(
453     "TG4PhysicsManager::BuildPhysics: is empty function in G4 MC.");
454 }    
455
456 void TG4PhysicsManager::SetCut(const char* cutName, Float_t cutValue)
457 {
458 // Sets the specified cut.
459 // ---
460
461   if (fLock) LockException();
462   TG3Cut g3Cut = GetG3Cut(cutName);
463   if (g3Cut != kNoG3Cuts)
464     SetCut(g3Cut, cutValue);
465   else {   
466     G4String text = "TG4PhysicsManager::SetCut:\n";
467     text = text + "    Parameter " + cutName;
468     text = text + " is not implemented.";
469     TG4Globals::Warning(text);
470   }  
471 }  
472   
473 void TG4PhysicsManager::SetProcess(const char* flagName, Int_t flagValue)
474 {
475 // Sets the specified process control.
476 // ---
477
478   if (fLock) LockException();
479   TG3Flag g3Flag = GetG3Flag(flagName);
480   if (g3Flag != kNoG3Flags)
481     SetProcess(g3Flag, flagValue);
482   else {   
483     G4String text = "TG4PhysicsManager::SetProcess:\n";
484     text = text + "    Parameter " + flagName;
485     text = text + " is not implemented.";
486     TG4Globals::Warning(text);
487   }  
488 }  
489
490 void TG4PhysicsManager::SetProcessActivation()
491 {
492 // (In)Activates built processes according
493 // to the setup in fFlagVector.
494 // ---
495
496   if (fPhysicsList) {
497     // temporarily excluded
498     // fPhysicsList->SetProcessActivation();
499   }  
500   else {
501     G4String text = "TG4PhysicsManager::SetProcessActivation:\n";
502     text = text +   "   There is no physics list set.";
503     TG4Globals::Exception(text);
504   }
505 }       
506
507 G4int TG4PhysicsManager::GetPDGEncodingFast(G4ParticleDefinition* particle)
508 {
509 // Returns the PDG code of particle;
510 // if standard PDG code is not defined the preregistred
511 // fParticlePDGMap is used.
512 // ---
513
514   // get PDG encoding from G4 particle definition
515   G4int pdgEncoding = particle->GetPDGEncoding();
516
517   if (pdgEncoding == 0) {
518     // use FParticlePDGMap if standard PDG code is not defined
519     G4String name = particle->GetParticleName();
520     pdgEncoding = fParticlePDGMap.GetSecond(name);
521   }
522     
523   return pdgEncoding;  
524 }  
525      
526 G4bool TG4PhysicsManager::CheckCutWithCutVector(G4String name, 
527                              G4double value, TG3Cut& cut)
528 {
529 // Retrieves corresponding TG3Cut from the name and 
530 // in case the value is different from the value in cutVector
531 // sets true the value of the fIsCutVector element 
532 // corresponding to this cut and returns true; 
533 // returns false otherwise.
534 // ---
535
536   // convert cut name -> TG3Cut
537   cut = GetG3Cut(name);
538
539   // set switch vector element only if the value
540   // is different from the value in cutVector
541   if (cut !=kNoG3Cuts) {
542     // get tolerance from TG4G3Defaults in GeV
543     G4double tolerance = TG4G3Defaults::CutTolerance()/GeV;
544     if (!(fCutVector) || (abs(value - (*fCutVector)[cut]) > tolerance)) {
545       SwitchIsCutVector(cut);      
546       return true;
547     }  
548     else return false;  
549   }                      
550   return false;
551 }
552
553 G4bool TG4PhysicsManager::CheckFlagWithFlagVector(G4String name, 
554                               G4double value, TG3Flag& flag)
555 {
556 // Retrieves corresponding TG3Flag from the name and 
557 // in case the value is different from the value in flagVector
558 // sets true the value of the fIsFlagVector element 
559 // corresponding to this flag and returns true; 
560 // returns false otherwise.
561 // ---
562
563   // convert flag name -> TG3Flag
564   flag = GetG3Flag(name);
565
566   // set switch vector element only if the value
567   // is different from the value in flagVector
568   if (flag !=kNoG3Flags) {
569     if (!(fFlagVector) || (abs(value - (*fFlagVector)[flag]) > 0.01)) {
570       SwitchIsFlagVector(flag);      
571       return true;
572     }  
573     else return false;  
574   }                      
575   return false;
576 }
577
578 G4bool TG4PhysicsManager::CheckCutWithG3Defaults(G4String name, 
579                               G4double value, TG3Cut& cut)
580 {
581 // Retrieves corresponding TG3Cut from the name and 
582 // in case the value is different from the G3 default value
583 // sets true the value of the SwitchCutVector element 
584 // corresponding to this cut and returns true; 
585 // returns false otherwise.
586 // ---
587
588   // convert cut name -> TG3Cut
589   cut = GetG3Cut(name);
590
591   // set switch vector element only if the value
592   // is different from G3 default
593   if (cut !=kNoG3Cuts) {
594     if (!TG4G3Defaults::IsDefaultCut(cut, value)) {
595       SwitchIsCutVector(cut);      
596       return true;
597     }  
598     else return false;  
599   }                      
600   return false;
601 }
602
603 G4bool TG4PhysicsManager::CheckFlagWithG3Defaults(G4String name, 
604                               G4double value, TG3Flag& flag)
605 {
606 // Retrieves corresponding TG3Flag from the name and 
607 // in case the value is different from the G3 default value
608 // sets true the value of the SwitchFlagVector element 
609 // corresponding to this flag and returns true; 
610 // returns false otherwise.
611 // ---
612
613   // convert flag name -> TG3Flag
614   flag = GetG3Flag(name);
615
616   // set switch vector element only if the value
617   // is different from G3 default
618   if (flag !=kNoG3Flags) {
619     if (!TG4G3Defaults::IsDefaultFlag(flag, value)) {
620       SwitchIsFlagVector(flag);      
621       return true;
622     }  
623     else return false;  
624   }                      
625   return false;
626 }
627
628 void TG4PhysicsManager::SetG3DefaultCuts() 
629 {
630 // Sets G3 default values of kinetic energy cuts.
631 // ---
632
633   if (fLock) LockException();
634   if (!fCutVector) {
635     // create vector of kinetic energy cut values  
636     fCutVector = new TG4CutVector();
637   }  
638   fCutVector->SetG3Defaults();
639 }
640
641 void TG4PhysicsManager::SetG3DefaultProcesses()
642 {
643 // Sets G3 default values of control process flags.
644 // ---
645
646   if (fLock) LockException();
647   if (!fFlagVector) {
648     // create vector of control process flag values
649     fFlagVector = new TG4FlagVector;
650   }  
651   fFlagVector->SetG3Defaults();
652 }  
653
654 G4bool TG4PhysicsManager::IsSpecialCuts() const
655 {
656 // Returns true if any special cut value is set.
657 // ---
658
659   for (G4int i=0; i<kNofParticlesWSP; i++)
660   {  if ((*fIsCutVector)[i]) return true; }
661
662   return false;
663 }
664
665 G4bool TG4PhysicsManager::IsSpecialFlags() const
666 {
667 // Returns true if any special flag value is set.
668 // ---
669
670   for (G4int i=0; i<kNofParticlesWSP; i++)
671   {  if ((*fIsFlagVector)[i]) return true; }
672
673   return false;
674 }
675
676 TG3ParticleWSP TG4PhysicsManager::GetG3ParticleWSP(
677                                   G4ParticleDefinition* particle) const 
678 {
679 // Returns TG3ParticleWSP constant for the specified particle.
680 // (See TG3ParticleWSP.h, too.)
681 // ---
682
683   G4String name = particle->GetParticleName();     
684   G4String pType = particle->GetParticleType();
685     
686   if (name == "gamma") {
687     return kGamma;
688   }  
689   else if (name == "e-") {    
690     return kElectron;
691   }  
692   else if (name == "e+") {   
693     return kEplus;
694   }  
695   else if (( pType == "baryon" || pType == "meson" || pType == "nucleus" )) {
696     if (particle->GetPDGCharge() == 0) { 
697       return kNeutralHadron;
698     }
699     else  
700       return kChargedHadron;
701   }    
702   else if ( name == "mu-" || name == "mu+" ) {
703     return kMuon;
704   }  
705   else {
706     return kNofParticlesWSP;
707   }    
708 }  
709
710 void TG4PhysicsManager::GetG3ParticleWSPName(G4int particleWSP,
711                                              G4String& name) const 
712 {
713 // Fills the passed name with the name/type of particle specified
714 // by TG3ParticleWSP constant.
715 // (See TG3ParticleWSP.h, too.)
716 // ---
717
718   switch (particleWSP) {
719     case kGamma:
720       name = "Gamma";
721       break;
722     case kElectron:
723       name = "Electron";
724       break;
725     case kEplus:
726       name = "Eplus";
727       break;
728     case kNeutralHadron:
729       name = "NeutralHadron";
730       break;
731     case kChargedHadron:
732       name = "ChargedHadron";
733       break;
734     case kMuon:
735       name = "Muon";
736       break;
737     case kAny:
738       name = "Any";
739       break;
740     case kNofParticlesWSP:
741       name = "NoSP";
742       break;
743     default:
744       G4String text = "TG4PhysicsList::GetG3ParticleWSPName:\n";
745       text = text + "   Wrong particleWSP."; 
746       TG4Globals::Exception(text);
747       break;      
748   }
749 }  
750