94 if (gMC->IsTrackEntering()) {
98 fTime = gMC->TrackTime() * 1.0e09;
99 fLength = gMC->TrackLength();
104 TLorentzVector PosIn;
105 gMC->TrackPosition(PosIn);
106 fPosIn.SetXYZ(PosIn.X(), PosIn.Y(), PosIn.Z());
107 gMC->TrackMomentum(fMom);
109 part = gMC->GetStack()->GetCurrentTrack();
111 fIsPrimary = (Int_t)part->IsPrimary();
112 fCharge = (Int_t)part->GetPDG()->Charge();
113 fPdgId = (Int_t)part->GetPdgCode();
116 fVolumeID = vol->getMCid();
118 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
122 fELoss += gMC->Edep();
125 if ((gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) && fELoss > 0) {
126 TLorentzVector PosOut;
127 gMC->TrackPosition(PosOut);
128 fPosOut.SetXYZ(PosOut.X(), PosOut.Y(), PosOut.Z());
131 TVector3 p1(0, 0, 0);
132 TVector3 p2(10, 0, 0);
135 p1 = LocalToGlobal(p1);
136 p2 = LocalToGlobal(p2);
137 Double_t phi = TMath::ATan2(p2.Y() - p1.Y(), p2.X() - p1.X());
140 TVector3 trackPosition(0, 0, 0);
144 DistAndPoints(fPosIn, fPosOut, fPos, trackPosition);
147 AddHit(fTrackID, fVolumeID, fPos, fPos.Perp(), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime,
148 (fLength + gMC->TrackLength()) / 2, fELoss, fIsPrimary, fCharge, fPdgId, trackPosition);
196 Int_t nEntries = cl1->GetEntriesFast();
197 cout <<
"-I- BmnMwpc: " << nEntries <<
" entries to add." << endl;
198 TClonesArray& clref = *cl2;
201 for (Int_t
i = 0;
i < nEntries;
i++) {
203 Int_t index = oldpoint->GetTrackID() + offset;
204 oldpoint->SetTrackID(index);
209 cout <<
"-I- BmnMwpc: " << cl2->GetEntriesFast() <<
" merged entries." << endl;
234 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
235 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
237 MWPCGeo->setGeomFile(GetGeometryFileName());
238 geoFace->addGeoModule(MWPCGeo);
240 Bool_t rc = geoFace->readSet(MWPCGeo);
242 MWPCGeo->create(geoLoad->getGeoBuilder());
243 TList* volList = MWPCGeo->getListOfVolumes();
245 FairRun* fRun = FairRun::Instance();
246 FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
251 TListIter iter(volList);
252 FairGeoNode* node = NULL;
253 FairGeoVolume* aVol = NULL;
255 while ((node = (FairGeoNode*)iter.Next())) {
256 aVol =
dynamic_cast<FairGeoVolume*
>(node);
257 if (node->isSensitive()) {
258 fSensNodes->AddLast(aVol);
260 fPassNodes->AddLast(aVol);
264 par->setInputVersion(fRun->GetRunId(), 1);
265 ProcessNodes(volList);
378 Int_t maxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
380 gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
386 Int_t j = gGeoManager->GetListOfMedia()->GetEntries() - 1;
390 m = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(j);
392 m->SetId(curId + maxInd);
399 Int_t newMaxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
401 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, 0);
402 ExpandNodeForGdml(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters() - 1));
404 for (Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
405 TGeoMedium* medToDel = (TGeoMedium*)(gGeoManager->GetListOfMedia()->At(maxInd + 1));
406 LOG(debug) <<
" removing media " << medToDel->GetName() <<
" with id " << medToDel->GetId() <<
" (k=" << k
408 gGeoManager->GetListOfMedia()->Remove(medToDel);
410 gGeoManager->SetAllIndex();
417 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->GetName();
419 TGeoVolume* curVol = node->GetVolume();
421 LOG(debug) <<
" volume: " << curVol->GetName();
423 if (curVol->IsAssembly()) {
424 LOG(debug) <<
" skipping volume-assembly";
426 TGeoMedium* curMed = curVol->GetMedium();
427 TGeoMaterial* curMat = curVol->GetMaterial();
428 TGeoMedium* curMedInGeoManager = gGeoManager->GetMedium(curMed->GetName());
429 TGeoMaterial* curMatOfMedInGeoManager = curMedInGeoManager->GetMaterial();
430 TGeoMaterial* curMatInGeoManager = gGeoManager->GetMaterial(curMat->GetName());
433 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->GetName() <<
"\t" << curMed->GetId();
434 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->GetName() <<
"\t" << curMat->GetIndex();
437 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->GetName()
438 <<
"\t" << curMedInGeoManager->GetId();
439 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
440 << curMatOfMedInGeoManager->GetName() <<
"\t" << curMatOfMedInGeoManager->GetIndex();
441 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->GetName()
442 <<
"\t" << curMatInGeoManager->GetIndex();
444 TString matName = curMat->GetName();
445 TString medName = curMed->GetName();
447 if (curMed->GetId() != curMedInGeoManager->GetId()) {
449 LOG(debug) <<
" Medium needs to be fixed";
451 Int_t ind = curMat->GetIndex();
452 gGeoManager->RemoveMaterial(ind);
453 LOG(debug) <<
" removing material " << curMat->GetName() <<
" with index " << ind;
454 for (Int_t
i = ind;
i < gGeoManager->GetListOfMaterials()->GetEntries();
i++) {
455 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
456 m->SetIndex(
m->GetIndex() - 1);
459 LOG(debug) <<
" Medium fixed";
461 LOG(debug) <<
" Already fixed medium found in the list ";
465 LOG(debug) <<
" There is no correct medium in the memory yet";
467 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
468 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
469 FairGeoMedia* geoMediaBase = geoFace->getMedia();
470 FairGeoBuilder* geobuild = geoLoad->getGeoBuilder();
472 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
473 if (curMedInGeo == 0) {
474 LOG(fatal) <<
" Media not found in Geo file: " << medName;
479 LOG(debug) <<
" Found media in Geo file" << medName;
480 geobuild->createMedium(curMedInGeo);
481 fFixedMedia[medName] = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last();
482 gGeoManager->RemoveMaterial(curMatOfMedInGeoManager->GetIndex());
483 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->GetName() <<
" with index "
484 << curMatOfMedInGeoManager->GetIndex();
485 for (Int_t
i = curMatOfMedInGeoManager->GetIndex();
486 i < gGeoManager->GetListOfMaterials()->GetEntries();
i++)
488 TGeoMaterial*
m = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(
i);
489 m->SetIndex(
m->GetIndex() - 1);
493 if (curMedInGeo->getSensitivityFlag()) {
494 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
495 AddSensitiveVolume(curVol);
498 LOG(debug) <<
" Already fixed medium found in the list";
499 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
501 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
502 AddSensitiveVolume(curVol);
508 gGeoManager->SetAllIndex();
515 if (curVol->GetNdaughters() != 0) {
516 TObjArray* NodeChildList = curVol->GetNodes();
517 TGeoNode* curNodeChild;
518 for (Int_t j = 0; j < NodeChildList->GetEntriesFast(); j++) {
519 curNodeChild = (TGeoNode*)NodeChildList->At(j);
559 BmnMwpcPoint(trackID, detID, pos, radius, mom, time, length, eLoss, isPrimary, charge, pdgId, trackPos);