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();
81 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
85 fELoss += gMC->Edep();
88 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && fELoss > 0) {
90 TLorentzVector PosOut;
91 gMC->TrackPosition(PosOut);
92 fPosOut.SetXYZ(PosOut.X(), PosOut.Y(), PosOut.Z());
94 TLorentzVector MomOut;
95 gMC->TrackMomentum(MomOut);
96 fMomOut.SetXYZ(MomOut.X(), MomOut.Y(), MomOut.Z());
99 TVector3 diff_pos = fPosIn - fPosOut;
101 if (diff_pos.Mag() < 0.001)
103 if (fMomOut.Mag() == 0)
106 TVector3 corr_step = fMomOut;
107 corr_step.SetMag(0.001);
108 TVector3 pos = fPosOut;
109 fPosOut = pos - corr_step;
110 gGeoManager->FindNode(fPosOut[0], fPosOut[1], fPosOut[2]);
113 Int_t stationNum = -1;
114 Int_t moduleNum = -1;
116 TGeoVolume* currentVolume = gGeoManager->GetCurrentVolume();
117 TString currentVolumeName = currentVolume->GetName();
118 TRegexp expr =
"^CSCSensor_module[0-9]+_station[0-9]+.*";
119 if (currentVolumeName.Contains(expr)) {
120 TRegexp mod_expt =
"module[0-9]+";
121 TRegexp stat_expt =
"station[0-9]+";
123 moduleNum = TString(TString(currentVolumeName(mod_expt))(TRegexp(
"[0-9]+"))).Atoi();
124 stationNum = TString(TString(currentVolumeName(stat_expt))(TRegexp(
"[0-9]+"))).Atoi();
127 if (stationNum == -1 || moduleNum == -1)
130 AddHit(fTrackID, fVolumeID, fPosIn, fPosOut, fMomIn, fMomOut, fTime, fLength, fELoss,
131 fIsPrimary, fCharge, fPdgId, stationNum, moduleNum);
224 Int_t maxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
226 gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
232 Int_t j = gGeoManager->GetListOfMedia()->GetEntries() - 1;
236 m = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(j);
238 m->SetId(curId + maxInd);
246 Int_t newMaxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
248 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
249 ExpandNodeForGdml(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters() - 1));
251 for (Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
252 TGeoMedium* medToDel = (TGeoMedium*)(gGeoManager->GetListOfMedia()->At(maxInd + 1));
253 LOG(debug) <<
" removing media " << medToDel->GetName() <<
" with id " << medToDel->GetId() <<
" (k=" << k
255 gGeoManager->GetListOfMedia()->Remove(medToDel);
257 gGeoManager->SetAllIndex();
264 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->GetName();
266 TGeoVolume* curVol = node->GetVolume();
268 LOG(debug) <<
" volume: " << curVol->GetName();
270 if (curVol->IsAssembly()) {
271 LOG(debug) <<
" skipping volume-assembly";
273 TGeoMedium* curMed = curVol->GetMedium();
274 TGeoMaterial* curMat = curVol->GetMaterial();
275 TGeoMedium* curMedInGeoManager = gGeoManager->GetMedium(curMed->GetName());
276 TGeoMaterial* curMatOfMedInGeoManager = curMedInGeoManager->GetMaterial();
277 TGeoMaterial* curMatInGeoManager = gGeoManager->GetMaterial(curMat->GetName());
280 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->GetName() <<
"\t" << curMed->GetId();
281 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->GetName() <<
"\t" << curMat->GetIndex();
284 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->GetName()
285 <<
"\t" << curMedInGeoManager->GetId();
286 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
287 << curMatOfMedInGeoManager->GetName() <<
"\t" << curMatOfMedInGeoManager->GetIndex();
288 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->GetName()
289 <<
"\t" << curMatInGeoManager->GetIndex();
291 TString matName = curMat->GetName();
292 TString medName = curMed->GetName();
294 if (curMed->GetId() != curMedInGeoManager->GetId()) {
295 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
296 LOG(debug) <<
" Medium needs to be fixed";
297 fFixedMedia[medName] = curMedInGeoManager;
298 Int_t ind = curMat->GetIndex();
299 gGeoManager->RemoveMaterial(ind);
300 LOG(debug) <<
" removing material " << curMat->GetName() <<
" with index " << ind;
301 for (Int_t
i = ind;
i < gGeoManager->GetListOfMaterials()->GetEntries();
i++) {
302 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
303 m->SetIndex(
m->GetIndex() - 1);
306 LOG(debug) <<
" Medium fixed";
308 LOG(debug) <<
" Already fixed medium found in the list ";
311 if (fFixedMedia.find(medName) == fFixedMedia.end()) {
312 LOG(debug) <<
" There is no correct medium in the memory yet";
314 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
315 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
316 FairGeoMedia* geoMediaBase = geoFace->getMedia();
317 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
319 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
320 if (curMedInGeo == 0) {
321 LOG(fatal) <<
" Media not found in Geo file: " << medName;
326 LOG(debug) <<
" Found media in Geo file" << medName;
327 geobuild->createMedium(curMedInGeo);
328 fFixedMedia[medName] = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last();
329 gGeoManager->RemoveMaterial(curMatOfMedInGeoManager->GetIndex());
330 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->GetName() <<
" with index "
331 << curMatOfMedInGeoManager->GetIndex();
332 for (Int_t
i = curMatOfMedInGeoManager->GetIndex();
333 i < gGeoManager->GetListOfMaterials()->GetEntries();
i++)
335 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
336 m->SetIndex(
m->GetIndex() - 1);
340 if (curMedInGeo->getSensitivityFlag()) {
341 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
342 AddSensitiveVolume(curVol);
345 LOG(debug) <<
" Already fixed medium found in the list";
346 LOG(debug) <<
"!!! Sensitivity: " << fFixedMedia[medName]->GetParam(0);
347 if (fFixedMedia[medName]->GetParam(0) == 1) {
348 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
349 AddSensitiveVolume(curVol);
354 curVol->SetMedium(fFixedMedia[medName]);
355 gGeoManager->SetAllIndex();
362 if (curVol->GetNdaughters() != 0) {
363 TObjArray* NodeChildList = curVol->GetNodes();
364 TGeoNode* curNodeChild;
365 for (Int_t j = 0; j < NodeChildList->GetEntriesFast(); j++) {
366 curNodeChild = (TGeoNode*)NodeChildList->At(j);
404 BmnCSCPoint(trackID, detID, posIn, posOut, momIn, momOut, time, length, eLoss, isPrimary, charge, pdgId);