X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=TFluka%2FTFluka.cxx;h=e8aa67a429d2b07c3818e5732d4b7689747657d4;hp=2d6cd10ee2f408e889d91308e1c69f9f4e0d35fa;hb=b8b430a9a072693b0546718568a08ea8a4d371a6;hpb=27b2f7fe10b56aad9c239ea5b48dffda549c5645 diff --git a/TFluka/TFluka.cxx b/TFluka/TFluka.cxx index 2d6cd10ee2f..e8aa67a429d 100644 --- a/TFluka/TFluka.cxx +++ b/TFluka/TFluka.cxx @@ -15,6 +15,18 @@ /* $Log$ +Revision 1.9 2002/12/06 12:41:29 morsch +Mess from last merge cleaned up. + +Revision 1.8 2002/12/06 12:28:44 morsch +Region to media mapping corrected and improved. + +Revision 1.7 2002/12/06 12:21:32 morsch +User stepping methods added (E. Futo) + +Revision 1.6 2002/11/21 18:40:06 iglez2 +Media handling added + Revision 1.5 2002/11/07 17:59:10 iglez2 Included the geometry through geant4_vmc/FLUGG @@ -60,18 +72,26 @@ First commit of Fluka interface. #include +#include "TClonesArray.h" #include "TFluka.h" #include "TCallf77.h" //For the fortran calls #include "Fdblprc.h" //(DBLPRC) fluka common -#include "Fiounit.h" //(IOUNIT) fluka common #include "Fepisor.h" //(EPISOR) fluka common +#include "Ffinuc.h" //(FINUC) fluka common +#include "Fiounit.h" //(IOUNIT) fluka common +#include "Fpaprop.h" //(PAPROP) fluka common #include "Fpart.h" //(PART) fluka common -#include "TVirtualMC.h" +#include "Ftrackr.h" //(TRACKR) fluka common +#include "Fpaprop.h" //(PAPROP) fluka common +#include "Ffheavy.h" //(FHEAVY) fluka common +#include "TVirtualMC.h" #include "TG4GeometryManager.h" //For the geometry management #include "TG4DetConstruction.h" //For the detector construction #include "FGeometryInit.hh" +#include "TLorentzVector.h" +#include "FlukaVolume.h" // Fluka methods that may be needed. #ifndef WIN32 @@ -150,6 +170,10 @@ TFluka::TFluka(const char *title, Int_t verbosity) if (fVerbosityLevel >=3) cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl; + + fVolumeMediaMap = new TClonesArray("FlukaVolume",1000); + fNVolumes = 0; + fMediaByRegion = 0; } TFluka::~TFluka() { @@ -157,6 +181,9 @@ TFluka::~TFluka() { cout << "==> TFluka::~TFluka() destructor called." << endl; delete fGeometryManager; + fVolumeMediaMap->Delete(); + delete fVolumeMediaMap; + if (fVerbosityLevel >=3) cout << "<== TFluka::~TFluka() destructor called." << endl; @@ -190,22 +217,37 @@ void TFluka::Init() { if (fVerbosityLevel >=3) cout << "<== TFluka::Init() called." << endl; + + FinishGeometry(); + } void TFluka::FinishGeometry() { +// +// Build-up table with region to medium correspondance +// + char tmp[5]; + if (fVerbosityLevel >=3) cout << "==> TFluka::FinishGeometry() called." << endl; - fGeometryManager->Ggclos(); +// fGeometryManager->Ggclos(); - FGeometryInit* flugg = FGeometryInit::GetInstance(); - map >::iterator i; - for (fVolumeMediaMap.begin(); i != fVolumeMediaMap.end(); i++) { - TString volName = (*i).first; - Int_t media = (*i).second; - Int_t region = flugg->GetRegionFromName(volName); - fMediaByRegion[region] = media; + FGeometryInit* flugg = FGeometryInit::GetInstance(); + + fMediaByRegion = new Int_t[fNVolumes+2]; + for (Int_t i = 0; i < fNVolumes; i++) + { + FlukaVolume* vol = dynamic_cast((*fVolumeMediaMap)[i]); + TString volName = vol->GetName(); + Int_t media = vol->GetMedium(); + printf("Finish Geometry: volName, media %d %s %d \n", i, volName.Data(), media); + strcpy(tmp, volName.Data()); + tmp[4] = '\0'; + flugg->SetMediumFromName(tmp, media); } + + flugg->BuildMediaMap(); if (fVerbosityLevel >=3) cout << "<== TFluka::FinishGeometry() called." << endl; @@ -330,37 +372,53 @@ void TFluka::Gstpar(Int_t itmed, const char *param, Double_t parval) { Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t np) { // - fVolumeMediaMap[TString(name)] = nmed; - return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); +// fVolumeMediaMap[TString(name)] = nmed; + TClonesArray &lvols = *fVolumeMediaMap; + new(lvols[fNVolumes++]) + FlukaVolume(name, nmed); + return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); } Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t np) { // - return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); + TClonesArray &lvols = *fVolumeMediaMap; + new(lvols[fNVolumes++]) + FlukaVolume(name, nmed); + + return fGeometryManager->Gsvolu(name, shape, nmed, upar, np); } void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis) { // - fGeometryManager->Gsdvn(name, mother, ndiv, iaxis); + fGeometryManager->Gsdvn(name, mother, ndiv, iaxis); } void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed) { // - fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); + TClonesArray &lvols = *fVolumeMediaMap; + new(lvols[fNVolumes++]) + FlukaVolume(name, numed); + fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); } void TFluka::Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx) { -// - fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx); +// + TClonesArray &lvols = *fVolumeMediaMap; + new(lvols[fNVolumes++]) + FlukaVolume(name, numed); + fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx); } void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) { // - fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); + TClonesArray &lvols = *fVolumeMediaMap; + new(lvols[fNVolumes++]) + FlukaVolume(name, numed); + fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); } void TFluka::Gsord(const char *name, Int_t iax) { @@ -416,8 +474,10 @@ void TFluka::WriteEuclid(const char* fileName, const char* topVol, //_____________________________________________________________________________ // methods needed by the stepping //____________________________________________________________________________ + Int_t TFluka::GetMedium() const { - return fMediaByRegion[fCurrentFlukaRegion]; + FGeometryInit* flugg = FGeometryInit::GetInstance(); + return flugg->GetMedium(fCurrentFlukaRegion); } @@ -445,5 +505,551 @@ Int_t TFluka::PDGFromId(Int_t id) const Int_t intfluka = GetFlukaIPTOKP(id); //MPKDHA() goes from internal to PDG return mpdgha(intfluka); - } + +//_____________________________________________________________________________ +// methods for step management +//____________________________________________________________________________ +// +// set methods +// +void TFluka::SetMaxStep(Double_t) +{ +// SetMaxStep is dummy procedure in TFluka ! + cout << "SetMaxStep is dummy procedure in TFluka !" << endl; +} + +void TFluka::SetMaxNStep(Int_t) +{ +// SetMaxNStep is dummy procedure in TFluka ! + cout << "SetMaxNStep is dummy procedure in TFluka !" << endl; +} + +void TFluka::SetUserDecay(Int_t) +{ +// SetUserDecay is dummy procedure in TFluka ! + cout << "SetUserDecay is dummy procedure in TFluka !" << endl; +} + +// +// dynamic properties +// +void TFluka::TrackPosition(TLorentzVector& position) const +{ +// Return the current position in the master reference frame of the +// track being transported +// TRACKR.atrack = age of the particle +// TRACKR.xtrack = x-position of the last point +// TRACKR.ytrack = y-position of the last point +// TRACKR.ztrack = z-position of the last point + position.SetX(TRACKR.xtrack[TRACKR.ntrack]); + position.SetY(TRACKR.ytrack[TRACKR.ntrack]); + position.SetZ(TRACKR.ztrack[TRACKR.ntrack]); + position.SetT(TRACKR.atrack); +} + +void TFluka::TrackMomentum(TLorentzVector& momentum) const +{ +// Return the direction and the momentum (GeV/c) of the track +// currently being transported +// TRACKR.ptrack = momentum of the particle (not always defined, if +// < 0 must be obtained from etrack) +// TRACKR.cx,y,ztrck = direction cosines of the current particle +// TRACKR.etrack = total energy of the particle +// TRACKR.jtrack = identity number of the particle +// PAPROP.am[TRACKR.jtrack] = particle mass in gev + if (TRACKR.ptrack >= 0) { + momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck); + momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck); + momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck); + momentum.SetE(TRACKR.etrack); + return; + } + else { + Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]); + momentum.SetPx(p*TRACKR.cxtrck); + momentum.SetPy(p*TRACKR.cytrck); + momentum.SetPz(p*TRACKR.cztrck); + momentum.SetE(TRACKR.etrack); + return; + } +} + +Double_t TFluka::TrackStep() const +{ +// Return the length in centimeters of the current step +// TRACKR.ctrack = total curved path + return TRACKR.ctrack; +} + +Double_t TFluka::TrackLength() const +{ +// Still wrong !!! +// This is the sum of substeps !!! +// TRACKR.ctrack = total curved path of the current step +// Sum of the substeps is identical to TRACKR.ctrack if the is no mag. field +// The sum of all step length starting from the beginning of the track +// for the time being returns only the length in centimeters of the current step + Double_t sum = 0; + for ( Int_t j=0;jlocal energy deposition (the value and the point are not recorded in TRACKR) +// but in the variable "rull" of the procedure "endraw.cxx" +// if TRACKR.ntrack > 0, TRACKR.mtrack = 0: +// -->no energy loss along the track +// if TRACKR.ntrack > 0, TRACKR.mtrack > 0: +// -->energy loss distributed along the track +// TRACKR.dtrack = energy deposition of the jth deposition even + if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0) + return fRull; + else { + Double_t sum = 0; + for ( Int_t j=0;j= 0 && isec < FINUC.np) { + // more fine condition depending on icode + // icode = 100 ? + // icode = 101 OK + // icode = 102 OK + // icode = 103 ? + // icode = 104 ? + // icode = 105 ? + // icode = 208 ? + // icode = 210 ? + // icode = 212 ? + // icode = 214 OK + // icode = 215 OK + // icode = 219 ? + // icode = 221 OK + // icode = 225 ? + // icode = 300 ? + // icode = 400 ? + + particleId = PDGFromId(FINUC.kpart[isec]); + position.SetX(fXsco); + position.SetY(fYsco); + position.SetZ(fZsco); + position.SetT(TRACKR.atrack); +// position.SetT(TRACKR.atrack+FINUC.agesec[isec]); //not yet implem. + momentum.SetPx(FINUC.plr[isec]*FINUC.cxr[isec]); + momentum.SetPy(FINUC.plr[isec]*FINUC.cyr[isec]); + momentum.SetPz(FINUC.plr[isec]*FINUC.czr[isec]); + momentum.SetE(FINUC.tki[isec] + PAPROP.am[FINUC.kpart[isec]+6]); + } + if (isec >= FINUC.np && isec < FINUC.np + FHEAVY.npheav) { + Int_t jsec = isec - FINUC.np; + particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!! + position.SetX(fXsco); + position.SetY(fYsco); + position.SetZ(fZsco); + position.SetT(TRACKR.atrack); +// position.SetT(TRACKR.atrack+FHEAVY.agheav[jsec]); //not yet implem. + momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]); + momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]); + momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]); + if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6) + momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]); + else if (FHEAVY.tkheav[jsec] > 6) + momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!! + } +} + +TMCProcess TFluka::ProdProcess(Int_t isec) const +// Name of the process that has produced the secondary particles +// in the current step +{ + const TMCProcess kIpNoProc = kPNoProcess; + const TMCProcess kIpPDecay = kPDecay; + const TMCProcess kIpPPair = kPPair; +//const TMCProcess kIpPPairFromPhoton = kPPairFromPhoton; +//const TMCProcess kIpPPairFromVirtualPhoton = kPPairFromVirtualPhoton; + const TMCProcess kIpPCompton = kPCompton; + const TMCProcess kIpPPhotoelectric = kPPhotoelectric; + const TMCProcess kIpPBrem = kPBrem; +//const TMCProcess kIpPBremFromHeavy = kPBremFromHeavy; +//const TMCProcess kIpPBremFromElectronOrPositron = kPBremFromElectronOrPositron; + const TMCProcess kIpPDeltaRay = kPDeltaRay; +//const TMCProcess kIpPMoller = kPMoller; +//const TMCProcess kIpPBhabha = kPBhabha; + const TMCProcess kIpPAnnihilation = kPAnnihilation; +//const TMCProcess kIpPAnnihilInFlight = kPAnnihilInFlight; +//const TMCProcess kIpPAnnihilAtRest = kPAnnihilAtRest; + const TMCProcess kIpPHadronic = kPHadronic; + const TMCProcess kIpPMuonNuclear = kPMuonNuclear; + const TMCProcess kIpPPhotoFission = kPPhotoFission; + const TMCProcess kIpPRayleigh = kPRayleigh; + const TMCProcess kIpPCerenkov = kPCerenkov; + const TMCProcess kIpPSynchrotron = kPSynchrotron; + + Int_t mugamma = TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11; + if (fIcode == 102) return kIpPDecay; + else if (fIcode == 104 || fIcode == 217) return kIpPPair; +//else if (fIcode == 104) return kIpPairFromPhoton; +//else if (fIcode == 217) return kIpPPairFromVirtualPhoton; + else if (fIcode == 219) return kIpPCompton; + else if (fIcode == 221) return kIpPPhotoelectric; + else if (fIcode == 105 || fIcode == 208) return kIpPBrem; +//else if (fIcode == 105) return kIpPBremFromHeavy; +//else if (fIcode == 208) return kPBremFromElectronOrPositron; + else if (fIcode == 103 || fIcode == 400) return kIpPDeltaRay; + else if (fIcode == 210 || fIcode == 212) return kIpPDeltaRay; +//else if (fIcode == 210) return kIpPMoller; +//else if (fIcode == 212) return kIpPBhabha; + else if (fIcode == 214 || fIcode == 215) return kIpPAnnihilation; +//else if (fIcode == 214) return kIpPAnnihilInFlight; +//else if (fIcode == 215) return kIpPAnnihilAtRest; + else if (fIcode == 101) return kIpPHadronic; + else if (fIcode == 101) { + if (!mugamma) return kIpPHadronic; + else if (TRACKR.jtrack == 7) return kIpPPhotoFission; + else return kIpPMuonNuclear; + } + else if (fIcode == 225) return kIpPRayleigh; +// Fluka codes 100, 300 and 400 still to be investigasted + else return kIpNoProc; +} + +//Int_t StepProcesses(TArrayI &proc) const +// Return processes active in the current step +//{ +//ck = total energy of the particl ???????????????? +//} + + +// =============================================================== +void TFluka::FutoTest() +{ + Int_t icode, mreg, newreg, particleId; +// Int_t medium; + Double_t rull, xsco, ysco, zsco; + TLorentzVector position, momentum; + icode = GetIcode(); + if (icode == 0) { + cout << " icode=" << icode << endl; + /* + cout << "TLorentzVector positionX=" << position.X() + << "positionY=" << position.Y() + << "positionZ=" << position.Z() + << "timeT=" << position.T() << endl; + cout << "TLorentzVector momentumX=" << momentum.X() + << "momentumY=" << momentum.Y() + << "momentumZ=" << momentum.Z() + << "energyE=" << momentum.E() << endl; + cout << "TrackPid=" << TrackPid() << endl; + */ + } + + else if (icode > 0 && icode <= 5) { +// mgdraw + mreg = GetMreg(); +// medium = GetMedium(); + cout << " icode=" << icode + << " mreg=" << mreg +// << " medium=" << medium + << endl; + TrackPosition(position); + TrackMomentum(momentum); + cout << "TLorentzVector positionX=" << position.X() + << "positionY=" << position.Y() + << "positionZ=" << position.Z() + << "timeT=" << position.T() << endl; + cout << "TLorentzVector momentumX=" << momentum.X() + << "momentumY=" << momentum.Y() + << "momentumZ=" << momentum.Z() + << "energyE=" << momentum.E() << endl; + cout << "TrackStep=" << TrackStep() << endl; + cout << "TrackLength=" << TrackLength() << endl; + cout << "TrackTime=" << TrackTime() << endl; + cout << "Edep=" << Edep() << endl; + cout << "TrackPid=" << TrackPid() << endl; + cout << "TrackCharge=" << TrackCharge() << endl; + cout << "TrackMass=" << TrackMass() << endl; + cout << "Etot=" << Etot() << endl; + cout << "IsNewTrack=" << IsNewTrack() << endl; + cout << "IsTrackInside=" << IsTrackInside() << endl; + cout << "IsTrackEntering=" << IsTrackEntering() << endl; + cout << "IsTrackExiting=" << IsTrackExiting() << endl; + cout << "IsTrackOut=" << IsTrackOut() << endl; + cout << "IsTrackDisappeared=" << IsTrackDisappeared() << endl; + cout << "IsTrackAlive=" << IsTrackAlive() << endl; + } + + else if((icode >= 10 && icode <= 15) || + (icode >= 20 && icode <= 24) || + (icode >= 30 && icode <= 33) || + (icode >= 40 && icode <= 41) || + (icode >= 50 && icode <= 52)) { +// endraw + mreg = GetMreg(); +// medium = GetMedium(); + rull = GetRull(); + xsco = GetXsco(); + ysco = GetYsco(); + zsco = GetZsco(); + cout << " icode=" << icode + << " mreg=" << mreg +// << " medium=" << medium + << " rull=" << rull + << " xsco=" << xsco + << " ysco=" << ysco + << " zsco=" << zsco << endl; + TrackPosition(position); + TrackMomentum(momentum); + cout << "Edep=" << Edep() << endl; + cout << "Etot=" << Etot() << endl; + cout << "TrackPid=" << TrackPid() << endl; + cout << "TrackCharge=" << TrackCharge() << endl; + cout << "TrackMass=" << TrackMass() << endl; + cout << "IsTrackOut=" << IsTrackOut() << endl; + cout << "IsTrackDisappeared=" << IsTrackDisappeared() << endl; + cout << "IsTrackStop=" << IsTrackStop() << endl; + cout << "IsTrackAlive=" << IsTrackAlive() << endl; + } + + else if((icode >= 100 && icode <= 105) || + (icode == 208) || + (icode == 210) || + (icode == 212) || + (icode >= 214 && icode <= 215) || + (icode == 217) || + (icode == 219) || + (icode == 221) || + (icode == 225) || + (icode == 300) || + (icode == 400)) { +// usdraw + mreg = GetMreg(); +// medium = GetMedium(); + xsco = GetXsco(); + ysco = GetYsco(); + zsco = GetZsco(); + cout << " icode=" << icode + << " mreg=" << mreg +// << " medium=" << medium + << " xsco=" << xsco + << " ysco=" << ysco + << " zsco=" << zsco << endl; + cout << "TrackPid=" << TrackPid() << endl; + cout << "NSecondaries=" << NSecondaries() << endl; + for (Int_t isec=0; isec< NSecondaries(); isec++) { + TFluka::GetSecondary(isec, particleId, position, momentum); + cout << "TLorentzVector positionX=" << position.X() + << "positionY=" << position.Y() + << "positionZ=" << position.Z() + << "timeT=" << position.T() << endl; + cout << "TLorentzVector momentumX=" << momentum.X() + << "momentumY=" << momentum.Y() + << "momentumZ=" << momentum.Z() + << "energyE=" << momentum.E() << endl; + cout << "TrackPid=" << particleId << endl; + + } + } + + else if((icode == 19) || + (icode == 29) || + (icode == 39) || + (icode == 49) || + (icode == 59)) { + mreg = GetMreg(); +// medium = GetMedium(); + newreg = GetNewreg(); + xsco = GetXsco(); + ysco = GetYsco(); + zsco = GetZsco(); + cout << " icode=" << icode + << " mreg=" << mreg +// << " medium=" << medium + << " newreg=" << newreg + << " xsco=" << xsco + << " ysco=" << ysco + << " zsco=" << zsco << endl; + } +// +// ==================================================================== +// + + + +} // end of FutoTest