4 #include "TLorentzVector.h" 5 #include "TClonesArray.h" 9 #if defined(COLLECT_TRACKS) 10 #include "TGeoManager.h" 11 #include "TVirtualGeoTrack.h" 15 # define gudigi gudigi_ 16 # define guhadr guhadr_ 18 # define guphad guphad_ 19 # define gudcay gudcay_ 20 # define guiget guiget_ 21 # define guinme guinme_ 22 # define guinti guinti_ 23 # define gunear gunear_ 24 # define guskip guskip_ 25 # define guview guview_ 26 # define gupara gupara_ 27 # define gudtim gudtim_ 28 # define guplsh guplsh_ 29 # define gutrev gutrev_ 30 # define gutrak gutrak_ 31 # define guswim guswim_ 33 # define gustep gustep_ 34 # define gukine gukine_ 36 # define eustep eustep_ 38 # define calsig calsig_ 39 # define gcalor gcalor_ 41 # define gheish gheish_ 42 # define flufin flufin_ 43 # define gfmfin gfmfin_ 44 # define gpghei gpghei_ 45 # define fldist fldist_ 46 # define gfmdis gfmdis_ 47 # define g3helx3 g3helx3_ 48 # define g3helix g3helix_ 49 # define g3rkuta g3rkuta_ 50 # define g3track g3track_ 51 # define gtreveroot gtreveroot_ 52 # define g3last g3last_ 53 # define g3invol g3invol_ 54 # define g3tmedi g3tmedi_ 55 # define g3media g3media_ 56 # define g3tmany g3tmany_ 57 # define g3tnext g3tnext_ 58 # define ginvol ginvol_ 59 # define gtmedi gtmedi_ 60 # define gtmany gtmany_ 61 # define gtonly gtonly_ 62 # define gmedia gmedia_ 63 # define glvolu glvolu_ 64 # define gtnext gtnext_ 67 # define gudigi GUDIGI 68 # define guhadr GUHADR 70 # define guphad GUPHAD 71 # define gudcay GUDCAY 72 # define guiget GUIGET 73 # define guinme GUINME 74 # define guinti GUINTI 75 # define gunear GUNEAR 76 # define guskip GUSKIP 77 # define guview GUVIEW 78 # define gupara GUPARA 79 # define gudtim GUDTIM 80 # define guplsh GUPLSH 81 # define gutrev GUTREV 82 # define gutrak GUTRAK 83 # define guswim GUSWIM 85 # define gustep GUSTEP 86 # define gukine GUKINE 88 # define calsig CALSIG 89 # define gcalor GCALOR 91 # define gheish GHEISH 92 # define flufin FLUFIN 93 # define gfmfin GFMFIN 94 # define gpghei GPGHEI 95 # define fldist FLDIST 96 # define gfmdis GFMDIS 97 # define g3helx3 G3HELX3 98 # define g3helix G3HELIX 99 # define g3rkuta G3RKUTA 100 # define gtrack GTRACK 101 # define gtreveroot GTREVEROOT 103 # define ginvol GINVOL 104 # define gtmedi GTMEDI 105 # define gtmany GTMANY 106 # define gmedia GMEDIA 107 # define glvolu GLVOLU 108 # define gtnext GTNEXT 113 #if defined(COLLECT_TRACKS) 114 extern TGeoManager *gGeoManager;
143 extern "C" type_of_call void glvolu(Int_t &nlev, Int_t *lnam,Int_t *lnum, Int_t &ier);
181 else if (ihadr==4){
flufin();}
182 else if (ihadr==5){
gcalor();}
226 else if ( ihadr==4 ){
fldist();}
227 else if ( ihadr==5 ){
calsig();}
249 if (!gMC->GetDecayer())
return;
250 gMC->GetDecayer()->ForceDecay();
254 static TLorentzVector
p;
265 Int_t iplund=gMC->PDGFromId(ipart);
268 static TClonesArray *particles;
269 if(!particles) particles=
new TClonesArray(
"TParticle",1000);
271 gMC->GetDecayer()->Decay(iplund, &p);
274 Int_t np = geant3->GetDecayer()->ImportParticles(particles);
277 TParticle * iparticle = (TParticle *) particles->At(0);
278 Int_t ipF = 0, ipL = 0 ;
282 Int_t* pFlag =
new Int_t[np];
283 for (i=0; i<np; i++) pFlag[i]=0;
285 for (i=1; i < np; i++)
287 iparticle = (TParticle *) particles->At(i);
288 ipF = iparticle->GetFirstDaughter();
289 ipL = iparticle->GetLastDaughter();
290 Int_t kf = iparticle->GetPdgCode();
291 Int_t ks = iparticle->GetStatusCode();
296 if (ipF > 0)
for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
303 Double_t lifeTime = gMC->GetDecayer()->GetLifetime(kf);
304 if (lifeTime > (Double_t) 1.
e-15) {
305 if (ipF > 0)
for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
312 if (kf==12 || kf ==-12)
continue;
313 if (kf==14 || kf ==-14)
continue;
314 if (kf==16 || kf ==-16)
continue;
325 Int_t ilu = gMC->IdFromPDG(kf);
342 void guiget(Int_t&, Int_t&, Int_t&)
359 void guinme(Float_t*, Int_t&, Float_t*, Int_t& IYES)
397 void gunear(Int_t&, Int_t&, Float_t*, Int_t&)
440 void guswim(Float_t& CHARGE, Float_t& STEP, Float_t* VECT, Float_t* VOUT)
459 Float_t fldcharge = fieldm*CHARGE;
460 g3helx3(fldcharge,STEP,VECT,VOUT);
462 else if (ifield==2)
g3helix(CHARGE,STEP,VECT,VOUT);
463 else g3rkuta(CHARGE,STEP,VECT,VOUT);
504 Float_t
gudtim(Float_t&, Float_t&, Int_t&, Int_t&)
523 Float_t
guplsh(Int_t&, Int_t&)
556 TVirtualMCApplication::Instance()->PreTrack();
560 TVirtualMCApplication::Instance()->PostTrack();
583 void gufld(Float_t *
x, Float_t *
b)
587 for (Int_t i=0; i<3; i++) xdouble[i] = x[i];
589 void gufld(Double_t *xdouble, Double_t *bdouble)
592 if ( gMC->GetMagField() ) {
593 gMC->GetMagField()->Field(xdouble,bdouble);
596 static Bool_t warn =
true;
598 Warning(
"gufld",
"Using deprecated function TVirtualMCApplication::Field().");
599 Warning(
"gufld",
"New TVirtualMagField interface should be used instead.");
603 TVirtualMCApplication::Instance()->Field(xdouble,bdouble);
607 for (Int_t j=0; j<3; j++) b[j] = bdouble[j];
621 static Int_t icont=0;
623 static Float_t prdist2;
624 Float_t d2x,d2y,d2z,amodd;
631 if(icc==0) prdist2=geant3->
Gconst()->
big;
639 if((TMath::Sqrt(dist2)-TMath::Sqrt(prdist2)) < 1.e-3){
662 if(icc == 0) prdist2=geant3->
Gconst()->
big;
685 dist2 = (d2x*d2x + d2y*d2y + d2z*d2z)/amodd;
688 if((TMath::Sqrt(dist2)-TMath::Sqrt(prdist2)) < 1.
e-3) {
712 if (!gMC->IsTrackOut()) {
713 TVirtualMCApplication *app = TVirtualMCApplication::Instance();
714 app->GeaneStepping();
734 Float_t polar[3]={0,0,0};
736 static TMCProcess pProc;
738 TVirtualMCApplication *app = TVirtualMCApplication::Instance();
739 TVirtualMCStack* stack = gMC->GetStack();
741 Double_t
x,
y,
z, rmax;
744 #if defined(COLLECT_TRACKS) 745 if (gMC->IsRootGeometrySupported()) {
747 Int_t cpdg = gMC->PDGFromId(geant3->
Gckine()->
ipart);
748 Bool_t isnew = kFALSE;
749 if (nstep==0) isnew = kTRUE;
750 Int_t cid = stack->GetCurrentTrackNumber();
751 Int_t mid = stack->GetCurrentParentTrackNumber();
755 TVirtualGeoTrack *parent = 0;
757 parent = gGeoManager->GetTrackOfId(mid);
758 if (!parent) printf(
"Error: no parent track with id=%i\n",mid);
760 TVirtualGeoTrack *track;
764 track = parent->AddDaughter(cid, cpdg);
765 gGeoManager->SetCurrentTrack(track);
767 Int_t itrack = gGeoManager->AddTrack(cid, cpdg);
769 gGeoManager->SetCurrentTrack(itrack);
770 track = gGeoManager->GetCurrentTrack();
772 TDatabasePDG *pdgdb = TDatabasePDG::Instance();
774 TParticlePDG *part = pdgdb->GetParticle(cpdg);
776 track->SetName(part->GetName());
777 track->SetParticle(part);
781 track = gGeoManager->GetCurrentTrack();
783 Double_t xo,yo,zo,to;
784 Bool_t skippoint = kFALSE;
785 if (track->HasPoints()) {
786 track->GetLastPoint(xo,yo,zo,to);
787 Double_t rdist = TMath::Sqrt((xo-x)*(xo-x)+(yo-y)*(yo-y)+(zo-z)*(zo-z));
788 if (rdist<0.01) skippoint=kTRUE;
790 if (!skippoint) track->AddPoint(x,y,z,tofg);
794 rmax = app->TrackingRmax();
795 if (x*x+y*y > rmax*rmax ||
796 TMath::Abs(z) > app->TrackingZmax()) {
801 if (gMC->NSecondaries() > 0) {
802 pProc=gMC->ProdProcess(0);
804 ipp = Int_t (geant3->
Gcking()->
gkin[jk][4]+0.5);
807 geant3->
SetTrack(1,stack->GetCurrentTrackNumber(),gMC->PDGFromId(ipp), geant3->
Gcking()->
gkin[jk],
818 geant3->
SetTrack(1, stack->GetCurrentTrackNumber(), gMC->PDGFromId(50),
823 kPCerenkov, nt, 1., 0);
827 if (!gMC->IsTrackOut()) app->Stepping();
850 TVirtualMCApplication::Instance()->GeneratePrimaries();
Float_t xphot[MXPHOT][11]
void TrackPosition(TLorentzVector &xyz) const
virtual Gctmed_t * Gctmed() const
virtual Gckine_t * Gckine() const
virtual Gckin3_t * Gckin3() const
virtual Gcking_t * Gcking() const
virtual Gcmore_t * Gcmore() const
virtual Gckin2_t * Gckin2() const
virtual Gconst_t * Gconst() const
virtual Gctrak_t * Gctrak() const
void SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom, Float_t *vpos, Float_t *polar, Float_t tof, TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
virtual Gcphys_t * Gcphys() const
virtual Gcflag_t * Gcflag() const