StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StG3Particle.cxx
1 // @(#)root/eg:$Id: StG3Particle.cxx,v 1.6 2009/08/25 20:49:16 fine Exp $
2 // Author: Victor Perev 17/03/2009
3 
4 //______________________________________________________________________________
5 #include <stdlib.h>
6 #include <math.h>
7 #include <vector>
8 #include <cassert>
9 
10 #include "StG3Particle.h"
11 #include "StGimParticle.h"
12 
13 StG3ParticleMaster *StG3ParticleMaster::mgInst =0;
14 GFKINE_t StG3ParticleMaster::mgFK=0; //pointer to Geant routine GFKINE
15 GFVERT_t StG3ParticleMaster::mgFV=0; //pointer to Geant routine GFVERT
16 
17 static std::vector<StGimParticle*> myVec;
18 
19 //______________________________________________________________________________
20 StG3ParticleMaster::StG3ParticleMaster(GFKINE_t fk,GFVERT_t fv)
21 {
22  assert(!mgInst && "Never,Jamais");
23  mgInst = this;
24  mgFK = fk;
25  mgFV = fv;
26 }
27 //______________________________________________________________________________
28 StG3ParticleMaster::~StG3ParticleMaster()
29 {
30  mgInst = 0;
31  for (int i=0;i<(int)myVec.size();i++) { delete myVec[i]; }
32  myVec.resize(0);
33 }
34 //______________________________________________________________________________
35 const StG3ParticleMaster *StG3ParticleMaster::Instance()
36 {
37  assert(mgInst && "Never,Jamais");
38  return mgInst;
39 }
40 //______________________________________________________________________________
41 void StG3ParticleMaster::Update()
42 {
43 // SUBROUTINE GFKINE(ITRA,VERT,PVERT,IPART,NVERT,UBUF,NWBUF)
44 // SUBROUTINE GFVERT(NVTX,V,NTBEAM,NTTARG,TOFG,UBUF,NWBUF)
45  const double kC =2.99792458000000000e+10;
46 
47  int ITRA,IPART,NVERT,NWBUF,UBUF[100];
48  float VERT[4],PVERT[5];
49  int NVTX,NTBEAM,NTTARG;
50  float V[3],TOFG;
51  mNTk = 0;
52  int size0 = myVec.size();
53 
54  for (ITRA = 1; 2009; ITRA++)
55  {
56  (mgFK)(ITRA,VERT,PVERT,IPART,NVERT,UBUF,NWBUF);
57  if (!IPART) break;
58  mNTk = ITRA;
59  NVTX = NVERT;
60  TOFG = 0;NTBEAM=0,NTTARG=0;
61  if (NVTX) {
62  (mgFV)(NVTX,V,NTBEAM,NTTARG,TOFG,UBUF,NWBUF);
63  }
64  if (ITRA > size0) {myVec.push_back(new StGimParticle(ITRA-1));}
65  else {myVec[ITRA-1]->Clear() ;}
66  StGimParticle *tk = myVec[ITRA-1];
67  tk->Clear();
68  VERT[3] = TOFG*kC;
69  PVERT[4] = Gea2Mas(IPART);
70  tk->SetGea(IPART);
71  tk->SetPdg(Gea2Pdg(IPART));
72  tk->SetVert(VERT);
73  tk->SetMom(PVERT);
74  if (!NVTX) continue;
75  if (NTBEAM) {
76  assert(NTBEAM<ITRA && "Never,Jamais");
77  tk->SetMother(0,myVec[NTBEAM-1]);
78  myVec[NTBEAM-1]->AddDaughter(tk);
79  }
80  if (NTTARG>0 && NTTARG<ITRA) tk->SetMother(1,myVec[NTTARG-1]);
81  }
82 
83 }
84 //______________________________________________________________________________
85 const StGenParticle *StG3ParticleMaster::operator()(int idx) const
86 {
87  assert(idx>=0 && "Never,Jamais");
88  if (idx >= mNTk) return 0;
89  if (!myVec[idx]->GetStatusCode()) return 0;
90  return myVec[idx];
91 }
92 
Master class for StGimParticle filled from GEANT3 internal structures.
Definition: StG3Particle.h:26
Abstract base class for particles related to common /HEPEVT/.
Implementation of StGenParticle similar to ROOT TParticle.
Definition: StGimParticle.h:16