//________________________________________________________________________________ Int_t StarMCHits::Init() { cout << "StarMCHits::Init() -I- Get Detectors" <<endl; if (! fDetectors ) delete fDetectors; fDetectors = 0; assert(StMaker::GetChain()); fDetectors = StMaker::GetChain()->GetDataBase("VmcGeometry/Index"); assert(fDetectors); // Make list of detector elements TDataSetIter next( fDetectors , 99); TDataSet *set = 0; if (fDetList) delete fDetList; fDetList = new THashList(100,0); Int_t N = 0; while ((set = next())) { StarVMCDetector *det = dynamic_cast<StarVMCDetector *>(set); if (! det ) continue; if (TString(det->GetName()) == "FPCT") continue; // ignore fpd if (TString(det->GetName()) == "BRSG") continue; // ignore tfr fDetList->Add(det); N++; } fDetList->Rehash(N); cout << "StarMCHits::Init() -I- Get Volume Info" << endl; // TObjArray *UniqueVolumes = gGeoManager->GetListOfUVolumes(); TObjArray *Volumes = gGeoManager->GetListOfUVolumes(); Int_t Nids = Volumes->GetEntriesFast(); if (! fVolUserInfo ) fVolUserInfo = new TObjArray(256); for (Int_t i = 0; i < Nids; i++) { TGeoVolume *vol = (TGeoVolume *) Volumes->At(i); if (! vol) continue; Int_t uid = vol->GetNumber(); #if 0 cout << "Volume:\t" << i << "\t" << vol->GetName() << "\t" << vol->GetTitle() << "\t" << uid; #endif TString title(vol->GetName(),4); TObject *det = fDetList->FindObject(title.Data()); #if 0 if (det) cout << "\tDetector: " << det->GetName();// << "\t" << det->GetTitle(); #endif fVolUserInfo->AddAtAndExpand(det,uid); #if 0 cout << endl; #endif } return 0; }
//________________________________________________________________________________ void StarMCHits::Step() { // static Int_t Idevt0 = -1; static Double_t Gold = 0; #if 0 if (Debug() && gMC->IsA()->InheritsFrom("TGeant3TGeo")) { TGeant3TGeo *geant3 = (TGeant3TGeo *)gMC; geant3->Gdebug(); } #endif // cout << "Call StarMCHits::Step" << endl; TGeoNode *nodeT = gGeoManager->GetCurrentNode(); assert(nodeT); TGeoVolume *volT = nodeT->GetVolume(); assert(volT); const TGeoMedium *med = volT->GetMedium(); /* fParams[0] = isvol; fParams[1] = ifield; fParams[2] = fieldm; fParams[3] = tmaxfd; fParams[4] = stemax; fParams[5] = deemax; fParams[6] = epsil; fParams[7] = stmin; */ Int_t Isvol = (Int_t) med->GetParam(0); fCurrentDetector = 0; if (Isvol <= 0) return; fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (! fCurrentDetector) { volT = nodeT->GetMotherVolume(); fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (! fCurrentDetector) { TString path(gGeoManager->GetPath()); TObjArray *obj = path.Tokenize("_/"); Int_t N = obj->GetEntries(); for (Int_t i = N-2; i >= 0; i -= 2) { TObjString *o = (TObjString *) obj->At(i); const Char_t *name = o->GetName(); volT = gGeoManager->GetVolume(name); assert (volT); fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (fCurrentDetector) break; } delete obj; } } if (Isvol && ! fCurrentDetector && Debug()) { cout << "Active medium:" << med->GetName() << "\t for volume " << volT->GetName() << " has no detector description" << endl; } // Int_t Idevt = gMC->CurrentEvent(); gMC->TrackPosition(fHit.Current.Global.xyzT); gMC->TrackMomentum(fHit.Current.Global.pxyzE); TGeoHMatrix *matrixC = gGeoManager->GetCurrentMatrix(); fHit.Current.Global2Local(matrixC); if (gMC->IsTrackEntering()) { fHit.Detector= fCurrentDetector; fHit.Entry = fHit.Current; fHit.Sleng = gMC->TrackLength(); fHit.Charge = (Int_t) gMC->TrackCharge(); fHit.Mass = gMC->TrackMass(); fHit.AdEstep = fHit.AStep = 0; return; } Double_t GeKin = fHit.Current.Global.pxyzE.E() - fHit.Mass; fHit.Sleng = gMC->TrackLength(); if (fHit.Sleng == 0.) Gold = GeKin; Double_t dEstep = gMC->Edep(); Double_t Step = gMC->TrackStep(); fHit.iPart = gMC->TrackPid(); fHit.iTrack = StarVMCApplication::Instance()->GetStack()->GetCurrentTrackId(); // GetCurrentTrackNumber() + 1 to be consistent with g2t // - - - - - - - - - - - - - energy correction - - - - - - - - - - if (gMC->IsTrackStop() && TMath::Abs(fHit.iPart) == kElectron) { TArrayI proc; Int_t Nproc = gMC->StepProcesses(proc); Int_t Mec = 0; for (Int_t i = 0; i < Nproc; i++) if (proc[i] == kPAnnihilation || proc[i] == kPStop) Mec = proc[i]; Int_t Ngkine = gMC->NSecondaries(); if (fHit.iPart == kElectron && Ngkine == 0 && Mec == kPStop) dEstep = Gold; else { if (fHit.iPart == kPositron && Ngkine < 2 && Mec == kPAnnihilation) { dEstep = Gold + 2*fHit.Mass; if (Ngkine == 1) { TLorentzVector x; TLorentzVector p; Int_t IpartSec; gMC->GetSecondary(0,IpartSec,x,p); dEstep -= p.E(); } } } } // - - - - - - - - - - - - - - - - user - - - - - - - - - - - - - - - // user step // - - - - - - - - - - - - - - - sensitive - - - - - - - - - - - - - fHit.AdEstep += dEstep; fHit.AStep += Step; if (fHit.AdEstep == 0) return; if (! gMC->IsTrackExiting() && ! gMC->IsTrackStop()) return; fHit.Exit = fHit.Current; fHit.Middle = fHit.Entry; fHit.Middle += fHit.Exit; fHit.Middle *= 0.5; if (! fCurrentDetector) return; fHit.VolumeId = fCurrentDetector->GetVolumeId(gGeoManager->GetPath()); FillG2Table(); }