53 if (gMC->IsTrackEntering()) {
57 fTime = gMC->TrackTime() * 1.0e09;
58 fLength = gMC->TrackLength();
64 gMC->TrackPosition(PosIn);
65 fPosIn.SetXYZ(PosIn.X(), PosIn.Y(), PosIn.Z());
68 gMC->TrackMomentum(MomIn);
69 fMomIn.SetXYZ(MomIn.X(), MomIn.Y(), MomIn.Z());
72 part = gMC->GetStack()->GetCurrentTrack();
74 fIsPrimary = (Int_t)part->IsPrimary();
75 fCharge = (Int_t)part->GetPDG()->Charge();
76 fPdgId = (Int_t)part->GetPdgCode();
79 fVolumeID = vol->getMCid();
80 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
84 fELoss += gMC->Edep();
87 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && fELoss > 0) {
89 TLorentzVector PosOut;
90 gMC->TrackPosition(PosOut);
91 fPosOut.SetXYZ(PosOut.X(), PosOut.Y(), PosOut.Z());
93 TLorentzVector MomOut;
94 gMC->TrackMomentum(MomOut);
95 fMomOut.SetXYZ(MomOut.X(), MomOut.Y(), MomOut.Z());
98 TVector3 diff_pos = fPosIn - fPosOut;
100 if (diff_pos.Mag() < 0.001)
102 if (fMomOut.Mag() == 0)
105 TVector3 corr_step = fMomOut;
106 corr_step.SetMag(0.001);
107 TVector3 pos = fPosOut;
108 fPosOut = pos - corr_step;
109 gGeoManager->FindNode(fPosOut[0], fPosOut[1], fPosOut[2]);
111 if (gGeoManager->GetCurrentNode()->GetMotherVolume() == 0)
115 Int_t stationNum = -1;
116 Int_t moduleNum = -1;
118 TGeoVolume* motherVolume = gGeoManager->GetCurrentNode()->GetMotherVolume();
119 TString moduleVolumeName = motherVolume->GetName();
121 TRegexp expr =
"^moduleV_module[0-9]+_station[0-9]+_VSP$";
122 if (moduleVolumeName.Contains(expr)) {
123 TRegexp mod_expr =
"module[0-9]+";
124 TRegexp stat_expr =
"station[0-9]+";
125 moduleNum = TString(TString(moduleVolumeName(mod_expr))(TRegexp(
"[0-9]+"))).Atoi();
126 stationNum = TString(TString(moduleVolumeName(stat_expr))(TRegexp(
"[0-9]+"))).Atoi();
129 if (stationNum == -1 || moduleNum == -1)
132 BmnVSPPoint* p = AddHit(fTrackID, fVolumeID, fPosIn, fPosOut, fMomIn, fMomOut, fTime, fLength, fELoss,
133 fIsPrimary, fCharge, fPdgId);
238 Int_t maxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
240 gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
246 Int_t j = gGeoManager->GetListOfMedia()->GetEntries() - 1;
250 m = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(j);
252 m->SetId(curId + maxInd);
260 Int_t newMaxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
262 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
263 ExpandNodeForGdml(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters() - 1));
265 for (Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
266 TGeoMedium* medToDel = (TGeoMedium*)(gGeoManager->GetListOfMedia()->At(maxInd + 1));
267 LOG(debug) <<
" removing media " << medToDel->GetName() <<
" with id " << medToDel->GetId() <<
" (k=" << k
269 gGeoManager->GetListOfMedia()->Remove(medToDel);
271 gGeoManager->SetAllIndex();
278 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->GetName();
280 TGeoVolume* curVol = node->GetVolume();
282 LOG(debug) <<
" volume: " << curVol->GetName();
284 if (curVol->IsAssembly()) {
285 LOG(debug) <<
" skipping volume-assembly";
287 TGeoMedium* curMed = curVol->GetMedium();
288 TGeoMaterial* curMat = curVol->GetMaterial();
289 TGeoMedium* curMedInGeoManager = gGeoManager->GetMedium(curMed->GetName());
290 TGeoMaterial* curMatOfMedInGeoManager = curMedInGeoManager->GetMaterial();
291 TGeoMaterial* curMatInGeoManager = gGeoManager->GetMaterial(curMat->GetName());
294 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->GetName() <<
"\t" << curMed->GetId();
295 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->GetName() <<
"\t" << curMat->GetIndex();
298 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->GetName()
299 <<
"\t" << curMedInGeoManager->GetId();
300 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
301 << curMatOfMedInGeoManager->GetName() <<
"\t" << curMatOfMedInGeoManager->GetIndex();
302 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->GetName()
303 <<
"\t" << curMatInGeoManager->GetIndex();
305 TString matName = curMat->GetName();
306 TString medName = curMed->GetName();
308 if (curMed->GetId() != curMedInGeoManager->GetId()) {
309 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
310 LOG(debug) <<
" Medium needs to be fixed";
311 fFixedMedia[medName] = curMedInGeoManager;
312 Int_t ind = curMat->GetIndex();
313 gGeoManager->RemoveMaterial(ind);
314 LOG(debug) <<
" removing material " << curMat->GetName() <<
" with index " << ind;
315 for (Int_t
i = ind;
i < gGeoManager->GetListOfMaterials()->GetEntries();
i++) {
316 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
317 m->SetIndex(
m->GetIndex() - 1);
320 LOG(debug) <<
" Medium fixed";
322 LOG(debug) <<
" Already fixed medium found in the list ";
325 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
326 LOG(debug) <<
" There is no correct medium in the memory yet";
328 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
329 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
330 FairGeoMedia* geoMediaBase = geoFace->getMedia();
331 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
333 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
334 if (curMedInGeo == 0) {
335 LOG(fatal) <<
" Media not found in Geo file: " << medName;
340 LOG(debug) <<
" Found media in Geo file" << medName;
341 geobuild->createMedium(curMedInGeo);
342 fFixedMedia[medName] = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last();
343 gGeoManager->RemoveMaterial(curMatOfMedInGeoManager->GetIndex());
344 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->GetName() <<
" with index "
345 << curMatOfMedInGeoManager->GetIndex();
346 for (Int_t
i = curMatOfMedInGeoManager->GetIndex();
347 i < gGeoManager->GetListOfMaterials()->GetEntries();
i++)
349 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
350 m->SetIndex(
m->GetIndex() - 1);
354 if (curMedInGeo->getSensitivityFlag()) {
355 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
356 AddSensitiveVolume(curVol);
359 LOG(debug) <<
" Already fixed medium found in the list";
360 LOG(debug) <<
"!!! Sensitivity: " << fFixedMedia[medName]->GetParam(0);
361 if (fFixedMedia[medName]->GetParam(0) == 1) {
362 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
363 AddSensitiveVolume(curVol);
368 curVol->SetMedium(fFixedMedia[medName]);
369 gGeoManager->SetAllIndex();
376 if (curVol->GetNdaughters() != 0) {
377 TObjArray* NodeChildList = curVol->GetNodes();
378 TGeoNode* curNodeChild;
379 for (Int_t j = 0; j < NodeChildList->GetEntriesFast(); j++) {
380 curNodeChild = (TGeoNode*)NodeChildList->At(j);
416 BmnVSPPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss, isPrimary, charge, pdgId);