+ //
+ // Calls stepping in order to signal cerenkov production
+ //
+ TFluka *fluka = (TFluka*)gMC;
+ fluka->SetMreg(mreg, TRACKR.lt1trk); //LTCLCM.mlatm1);
+ fluka->SetXsco(x);
+ fluka->SetYsco(y);
+ fluka->SetZsco(z);
+ fluka->SetNCerenkov(nphot);
+ fluka->SetCaller(kUSTCKV);
+ if (fluka->GetVerbosityLevel() >= 3)
+ printf("ustckv: %10d mreg=%d lattc=%d newlat=%d (%f, %f, %f) edep=%f vol=%s\n",
+ nphot, mreg, TRACKR.lt1trk, LTCLCM.newlat, x, y, z, fluka->Edep(), fluka->CurrentVolName());
+
+ // check region lattice consistency (debug Ernesto)
+ // *****************************************************
+ Int_t nodeId;
+ Int_t volId = fluka->CurrentVolID(nodeId);
+ Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
+
+ if( mreg != volId && !gGeoManager->IsOutside() ) {
+ cout << " ustckv: track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
+ << " icode=" << fluka->GetIcode() << " gNstep=" << fluka->GetNstep() << endl
+ << " fluka mreg=" << mreg << " mlttc=" << TRACKR.lt1trk << endl
+ << " TGeo volId=" << volId << " crtlttc=" << crtlttc << endl
+ << " common TRACKR lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
+ << " common LTCLCM newlat=" << LTCLCM.newlat << " mlatld=" << LTCLCM.mlatld << endl
+ << " mlatm1=" << LTCLCM.mlatm1 << " mltsen=" << LTCLCM.mltsen << endl
+ << " mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
+ if( TRACKR.lt1trk == crtlttc ) cout << " *************************************************************" << endl;
+ }
+ // *****************************************************
+
+
+
+ (TVirtualMCApplication::Instance())->Stepping();
+ }
+}
+
+//______________________________________________________________________________
+void TFluka::AddParticlesToPdgDataBase() const
+{
+
+//
+// Add particles to the PDG data base
+
+ TDatabasePDG *pdgDB = TDatabasePDG::Instance();
+
+ const Double_t kAu2Gev = 0.9314943228;
+ const Double_t khSlash = 1.0545726663e-27;
+ const Double_t kErg2Gev = 1/1.6021773349e-3;
+ const Double_t khShGev = khSlash*kErg2Gev;
+ const Double_t kYear2Sec = 3600*24*365.25;
+//
+// Ions
+//
+ pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
+ 0,3,"Ion",TFlukaIon::GetIonPdg(1,2));
+ pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
+ khShGev/(12.33*kYear2Sec),3,"Ion",TFlukaIon::GetIonPdg(1,3));
+ pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
+ khShGev/(12.33*kYear2Sec),6,"Ion",TFlukaIon::GetIonPdg(2,4));
+ pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
+ 0,6,"Ion",TFlukaIon::GetIonPdg(2,3));
+
+//
+//
+//
+// Special particles
+//
+ pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
+ 0,0,"Special",GetSpecialPdg(50));
+ pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
+ 0,0,"Special",GetSpecialPdg(51));
+}
+
+
+//
+// Info about primary ionization electrons
+//
+
+//______________________________________________________________________________
+Int_t TFluka::GetNPrimaryElectrons()
+{
+ // Get number of primary electrons
+ return ALLDLT.nalldl;
+}
+
+//______________________________________________________________________________
+Double_t TFluka::GetPrimaryElectronKineticEnergy(Int_t i) const
+{
+ // Returns kinetic energy of primary electron i
+
+ Double_t ekin = -1.;
+
+ if (i >= 0 && i < ALLDLT.nalldl) {
+ ekin = ALLDLT.talldl[i];
+ } else {
+ Warning("GetPrimaryElectronKineticEnergy",
+ "Primary electron index out of range %d %d \n",
+ i, ALLDLT.nalldl);
+ }
+ return ekin;
+}
+
+void TFluka::GetPrimaryElectronPosition(Int_t i, Double_t& x, Double_t& y, Double_t& z, Double_t& t) const
+{
+ // Returns position of primary electron i
+ if (i >= 0 && i < ALLDLT.nalldl) {
+ x = ALLDLT.xalldl[i];
+ y = ALLDLT.yalldl[i];
+ z = ALLDLT.zalldl[i];
+ t = ALLDLT.talldl[i];
+ return;
+ } else {
+ Warning("GetPrimaryElectronPosition",
+ "Primary electron index out of range %d %d \n",
+ i, ALLDLT.nalldl);
+ return;
+ }
+ return;
+}
+
+
+//__________________________________________________________________
+Int_t TFluka::GetSpecialPdg(Int_t number) const
+{
+// Numbering for special particles
+
+ return 50000000 + number;
+}
+
+
+void TFluka::PrimaryIonisationStepping(Int_t nprim)
+{
+// Call Stepping for primary ionisation electrons
+// Protection against nprim > mxalld
+// Multiple steps for nprim > 0
+ Int_t i;
+ fNPI = nprim;
+ if (nprim > 0) {
+ CalcPrimaryIonisationTime();
+ for (i = 0; i < nprim; i++) {
+ SetCurrentPrimaryElectronIndex(i);
+ (TVirtualMCApplication::Instance())->Stepping();
+ if (i == 0) SetTrackIsNew(kFALSE);
+ }
+ } else {
+ // No primary electron ionisation
+ // Call Stepping anyway but flag nprim = 0 as index = -2
+ SetCurrentPrimaryElectronIndex(-2);