54 if (gMC->IsTrackEntering()) {
58 fTime = gMC->TrackTime() * 1.0e09;
59 fLength = gMC->TrackLength();
65 gMC->TrackPosition(PosIn);
66 fPosIn.SetXYZ(PosIn.X(), PosIn.Y(), PosIn.Z());
69 gMC->TrackMomentum(MomIn);
70 fMomIn.SetXYZ(MomIn.X(), MomIn.Y(), MomIn.Z());
73 part = gMC->GetStack()->GetCurrentTrack();
75 fIsPrimary = (Int_t)part->IsPrimary();
76 fCharge = (Int_t)part->GetPDG()->Charge();
77 fPdgId = (Int_t)part->GetPdgCode();
80 fVolumeID = vol->getMCid();
82 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
86 fELoss += gMC->Edep();
89 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && fELoss > 0) {
91 TLorentzVector PosOut;
92 gMC->TrackPosition(PosOut);
93 fPosOut.SetXYZ(PosOut.X(), PosOut.Y(), PosOut.Z());
95 TLorentzVector MomOut;
96 gMC->TrackMomentum(MomOut);
97 fMomOut.SetXYZ(MomOut.X(), MomOut.Y(), MomOut.Z());
100 TVector3 diff_pos = fPosIn - fPosOut;
102 if (diff_pos.Mag() < 0.001)
104 if (fMomOut.Mag() == 0)
107 TVector3 corr_step = fMomOut;
108 corr_step.SetMag(0.001);
109 TVector3 pos = fPosOut;
110 fPosOut = pos - corr_step;
111 gGeoManager->FindNode(fPosOut[0], fPosOut[1], fPosOut[2]);
114 Int_t stationNum = -1;
115 Int_t moduleNum = -1;
117 TGeoVolume* currentVolume = gGeoManager->GetCurrentVolume();
118 TString currentVolumeName = currentVolume->GetName();
119 TRegexp expr =
"^SiProfSensor_module[0-9]+_station[0-9]+$";
120 if (currentVolumeName.Contains(expr)) {
121 TRegexp mod_expt =
"module[0-9]+";
122 TRegexp stat_expt =
"station[0-9]+";
124 moduleNum = TString(TString(currentVolumeName(mod_expt))(TRegexp(
"[0-9]+"))).Atoi();
125 stationNum = TString(TString(currentVolumeName(stat_expt))(TRegexp(
"[0-9]+"))).Atoi();
128 if (stationNum == -1 || moduleNum == -1)
131 AddHit(fTrackID, fVolumeID, fPosIn, fPosOut, fMomIn, fMomOut, fTime, fLength, fELoss,
132 fIsPrimary, fCharge, fPdgId, stationNum, moduleNum);
225 Int_t maxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
227 gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
233 Int_t j = gGeoManager->GetListOfMedia()->GetEntries() - 1;
237 m = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(j);
239 m->SetId(curId + maxInd);
247 Int_t newMaxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
249 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
250 ExpandNodeForGdml(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters() - 1));
252 for (Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
253 TGeoMedium* medToDel = (TGeoMedium*)(gGeoManager->GetListOfMedia()->At(maxInd + 1));
254 LOG(debug) <<
" removing media " << medToDel->GetName() <<
" with id " << medToDel->GetId() <<
" (k=" << k
256 gGeoManager->GetListOfMedia()->Remove(medToDel);
258 gGeoManager->SetAllIndex();
265 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->GetName();
267 TGeoVolume* curVol = node->GetVolume();
269 LOG(debug) <<
" volume: " << curVol->GetName();
271 if (curVol->IsAssembly()) {
272 LOG(debug) <<
" skipping volume-assembly";
274 TGeoMedium* curMed = curVol->GetMedium();
275 TGeoMaterial* curMat = curVol->GetMaterial();
276 TGeoMedium* curMedInGeoManager = gGeoManager->GetMedium(curMed->GetName());
277 TGeoMaterial* curMatOfMedInGeoManager = curMedInGeoManager->GetMaterial();
278 TGeoMaterial* curMatInGeoManager = gGeoManager->GetMaterial(curMat->GetName());
281 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->GetName() <<
"\t" << curMed->GetId();
282 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->GetName() <<
"\t" << curMat->GetIndex();
285 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->GetName()
286 <<
"\t" << curMedInGeoManager->GetId();
287 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
288 << curMatOfMedInGeoManager->GetName() <<
"\t" << curMatOfMedInGeoManager->GetIndex();
289 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->GetName()
290 <<
"\t" << curMatInGeoManager->GetIndex();
292 TString matName = curMat->GetName();
293 TString medName = curMed->GetName();
295 if (curMed->GetId() != curMedInGeoManager->GetId()) {
296 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
297 LOG(debug) <<
" Medium needs to be fixed";
298 fFixedMedia[medName] = curMedInGeoManager;
299 Int_t ind = curMat->GetIndex();
300 gGeoManager->RemoveMaterial(ind);
301 LOG(debug) <<
" removing material " << curMat->GetName() <<
" with index " << ind;
302 for (Int_t
i = ind;
i < gGeoManager->GetListOfMaterials()->GetEntries();
i++) {
303 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
304 m->SetIndex(
m->GetIndex() - 1);
307 LOG(debug) <<
" Medium fixed";
309 LOG(debug) <<
" Already fixed medium found in the list ";
312 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
313 LOG(debug) <<
" There is no correct medium in the memory yet";
315 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
316 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
317 FairGeoMedia* geoMediaBase = geoFace->getMedia();
318 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
320 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
321 if (curMedInGeo == 0) {
322 LOG(fatal) <<
" Media not found in Geo file: " << medName;
327 LOG(debug) <<
" Found media in Geo file" << medName;
328 geobuild->createMedium(curMedInGeo);
329 fFixedMedia[medName] = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last();
330 gGeoManager->RemoveMaterial(curMatOfMedInGeoManager->GetIndex());
331 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->GetName() <<
" with index "
332 << curMatOfMedInGeoManager->GetIndex();
333 for (Int_t
i = curMatOfMedInGeoManager->GetIndex();
334 i < gGeoManager->GetListOfMaterials()->GetEntries();
i++)
336 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
337 m->SetIndex(
m->GetIndex() - 1);
341 if (curMedInGeo->getSensitivityFlag()) {
342 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
343 AddSensitiveVolume(curVol);
346 LOG(debug) <<
" Already fixed medium found in the list";
347 LOG(debug) <<
"!!! Sensitivity: " << fFixedMedia[medName]->GetParam(0);
348 if (fFixedMedia[medName]->GetParam(0) == 1) {
349 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
350 AddSensitiveVolume(curVol);
355 curVol->SetMedium(fFixedMedia[medName]);
356 gGeoManager->SetAllIndex();
363 if (curVol->GetNdaughters() != 0) {
364 TObjArray* NodeChildList = curVol->GetNodes();
365 TGeoNode* curNodeChild;
366 for (Int_t j = 0; j < NodeChildList->GetEntriesFast(); j++) {
367 curNodeChild = (TGeoNode*)NodeChildList->At(j);
405 BmnSiProfPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss, isPrimary, charge, pdgId);