49CbmRich::CbmRich(
const char* name, Bool_t active, Double_t px, Double_t py, Double_t pz, Double_t rx, Double_t ry,
53 , fRegisterPhotonsOnSensitivePlane(true)
54 , fRichPoints(new TClonesArray(
"CbmRichPoint"))
55 , fRichRefPlanePoints(new TClonesArray(
"CbmRichPoint"))
56 , fRichMirrorPoints(new TClonesArray(
"CbmRichPoint"))
57 , fRotation(new TGeoRotation(
"", rx, ry, rz))
58 , fPositionRotation(new TGeoCombiTrans(px, py, pz, fRotation))
101 Int_t pdgCode = gMC->TrackPid();
102 Int_t iVol = vol->getMCid();
103 TString volName = TString(vol->GetName());
106 if (volName.Contains(
"pmt_pixel")) {
107 if (gMC->IsTrackEntering()) {
108 TParticle* part = gMC->GetStack()->GetCurrentTrack();
109 Double_t charge = part->GetPDG()->Charge() / 3.;
110 Int_t trackID = gMC->GetStack()->GetCurrentTrackNumber();
111 Double_t time = gMC->TrackTime() * 1.0e09;
112 Double_t length = gMC->TrackLength();
113 Double_t eLoss = gMC->Edep();
116 const std::string path = std::string(gMC->CurrentVolPath());
118 if (pixelAddress == -1) {
119 LOG(error) <<
"CbmRich::ProcessHits() Pixel address is not found for path " << path;
123 TLorentzVector tPos, tMom;
124 gMC->TrackPosition(tPos);
125 gMC->TrackMomentum(tMom);
127 if (pdgCode == 50000050) {
128 AddHit(trackID, pixelAddress, TVector3(tPos.X(), tPos.Y(), tPos.Z()), TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
129 time, length, eLoss);
141 AddHit(trackID, pixelAddress, TVector3(tPos.X(), tPos.Y(), tPos.Z()),
142 TVector3(tMom.Px(), tMom.Py(), tMom.Pz()), time, length, eLoss);
159 if (volName.Contains(
"sens_plane")) {
160 if (gMC->IsTrackEntering()) {
161 TParticle* part = gMC->GetStack()->GetCurrentTrack();
162 Double_t charge = part->GetPDG()->Charge() / 3.;
166 Int_t trackID = gMC->GetStack()->GetCurrentTrackNumber();
167 Double_t time = gMC->TrackTime() * 1.0e09;
168 Double_t length = gMC->TrackLength();
169 Double_t eLoss = gMC->Edep();
171 TLorentzVector tPos, tMom;
172 gMC->TrackPosition(tPos);
173 gMC->TrackMomentum(tMom);
175 AddRefPlaneHit(trackID, iVol, TVector3(tPos.X(), tPos.Y(), tPos.Z()), TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
176 time, length, eLoss);
190 if (volName.Contains(
"mirror_tile_type")) {
191 if (gMC->IsTrackEntering()) {
192 TParticle* part = gMC->GetStack()->GetCurrentTrack();
193 Double_t charge = part->GetPDG()->Charge() / 3.;
195 Int_t trackID = gMC->GetStack()->GetCurrentTrackNumber();
196 Double_t time = gMC->TrackTime() * 1.0e09;
197 Double_t length = gMC->TrackLength();
198 Double_t eLoss = gMC->Edep();
200 TLorentzVector tPos, tMom;
201 gMC->TrackPosition(tPos);
202 gMC->TrackMomentum(tMom);
204 AddMirrorHit(trackID, iVol, TVector3(tPos.X(), tPos.Y(), tPos.Z()), TVector3(tMom.Px(), tMom.Py(), tMom.Pz()),
205 time, length, eLoss);
301 FairRun* run = FairRun::Instance();
302 Bool_t isGeant4 = std::string(run->GetName()) ==
"TGeant4";
303 LOG(info) <<
"CbmRich::SetRichGlassPropertiesForGeant4() Transport engine:" << std::string(run->GetName());
307 LOG(info) <<
"CbmRich::SetRichGlassPropertiesForGeant4() fIsGeant4 is "
308 "false. No need to set RICH glass properties. Return.";
312 LOG(info) <<
"CbmRich::SetRichGlassPropertiesForGeant4() fIsGeant4 is "
313 "true. RICH glass properties will be set.";
316 std::vector<Double_t> energyAr = {
317 1.5499, 1.5695, 1.5897, 1.6103, 1.6315, 1.6533, 1.6756, 1.6985, 1.7221, 1.7464, 1.7713, 1.7970, 1.8234,
318 1.8507, 1.8787, 1.9076, 1.9374, 1.9682, 1.9999, 2.0327, 2.0666, 2.1016, 2.1378, 2.1753, 2.2142, 2.2544,
319 2.2962, 2.3395, 2.3845, 2.4313, 2.4799, 2.5305, 2.5832, 2.6382, 2.6955, 2.7554, 2.8180, 2.8836, 2.9522,
320 3.0242, 3.0998, 3.1793, 3.2630, 3.3512, 3.4443, 3.5427, 3.6469, 3.7574, 3.8748, 3.9998, 4.1331, 4.2757,
321 4.4284, 4.5924, 4.7690, 4.9598, 5.1664, 5.3910, 5.6361, 5.9045, 6.1997};
323 for (Double_t& energy : energyAr) {
327 std::vector<Double_t> reflectivityAr = {
328 0.15719, 0.15315, 0.15218, 0.14953, 0.14761, 0.14416, 0.13753, 0.13844, 0.13705, 0.13307, 0.13136, 0.12569, 0.12284,
329 0.12089, 0.13101, 0.12494, 0.12199, 0.12150, 0.12257, 0.11783, 0.11909, 0.12021, 0.12080, 0.11712, 0.11935, 0.12015,
330 0.11385, 0.11364, 0.11526, 0.11908, 0.12109, 0.12011, 0.12193, 0.12681, 0.12622, 0.12601, 0.12824, 0.13084, 0.13182,
331 0.13287, 0.13463, 0.13513, 0.13665, 0.13826, 0.13960, 0.14072, 0.14205, 0.13977, 0.14090, 0.14073, 0.14031, 0.13951,
332 0.13868, 0.13622, 0.13762, 0.13898, 0.13963, 0.14713, 0.15901, 0.18620, 0.22529};
334 for (Double_t& reflectivity : reflectivityAr) {
335 reflectivity = 1. - reflectivity;
338 gMC->DefineOpSurface(
"RICHglassSurf", kGlisur, kDielectric_metal, kPolished, 0.0);
339 gMC->SetMaterialProperty(
"RICHglassSurf",
"REFLECTIVITY",
static_cast<Int_t
>(energyAr.size()), energyAr.data(),
340 reflectivityAr.data());
342 for (
int i = 0; i < 10; i++) {
343 if (gGeoManager->FindVolumeFast((
"mirror_tile_type" + std::to_string(i)).c_str()) ==
nullptr)
continue;
344 gMC->SetSkinSurface((
"RICHglassSkin" + std::to_string(i)).c_str(), (
"mirror_tile_type" + std::to_string(i)).c_str(),
353 TGeoVolume* gdmlTop {
nullptr};
356 Int_t maxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
358 gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
364 Int_t j = gGeoManager->GetListOfMedia()->GetEntries() - 1;
366 TGeoMedium* m {
nullptr};
368 m =
static_cast<TGeoMedium*
>(gGeoManager->GetListOfMedia()->At(j));
370 m->SetId(curId + maxInd);
377 Int_t newMaxInd = gGeoManager->GetListOfMedia()->GetEntries() - 1;
379 gGeoManager->GetTopVolume()->AddNode(gdmlTop, 1, geoMatrix);
380 ExpandNodeForGdml(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters() - 1));
382 for (Int_t k = maxInd + 1; k < newMaxInd + 1; k++) {
383 TGeoMedium* medToDel =
static_cast<TGeoMedium*
>(gGeoManager->GetListOfMedia()->At(maxInd + 1));
384 LOG(debug) <<
" removing media " << medToDel->GetName() <<
" with id " << medToDel->GetId() <<
" (k=" << k
386 gGeoManager->GetListOfMedia()->Remove(medToDel);
388 gGeoManager->SetAllIndex();
395 LOG(debug) <<
"----------------------------------------- ExpandNodeForGdml for node " << node->GetName();
397 TGeoVolume* curVol = node->GetVolume();
399 LOG(debug) <<
" volume: " << curVol->GetName();
401 if (curVol->IsAssembly()) { LOG(debug) <<
" skipping volume-assembly"; }
404 TGeoMedium* curMed = curVol->GetMedium();
405 TGeoMaterial* curMat = curVol->GetMaterial();
406 TGeoMedium* curMedInGeoManager = gGeoManager->GetMedium(curMed->GetName());
407 TGeoMaterial* curMatOfMedInGeoManager = curMedInGeoManager->GetMaterial();
408 TGeoMaterial* curMatInGeoManager = gGeoManager->GetMaterial(curMat->GetName());
411 LOG(debug2) <<
" curMed\t\t\t\t" << curMed <<
"\t" << curMed->GetName() <<
"\t" << curMed->GetId();
412 LOG(debug2) <<
" curMat\t\t\t\t" << curMat <<
"\t" << curMat->GetName() <<
"\t" << curMat->GetIndex();
415 LOG(debug2) <<
" curMedInGeoManager\t\t" << curMedInGeoManager <<
"\t" << curMedInGeoManager->GetName() <<
"\t"
416 << curMedInGeoManager->GetId();
417 LOG(debug2) <<
" curMatOfMedInGeoManager\t\t" << curMatOfMedInGeoManager <<
"\t"
418 << curMatOfMedInGeoManager->GetName() <<
"\t" << curMatOfMedInGeoManager->GetIndex();
419 LOG(debug2) <<
" curMatInGeoManager\t\t" << curMatInGeoManager <<
"\t" << curMatInGeoManager->GetName() <<
"\t"
420 << curMatInGeoManager->GetIndex();
422 TString matName = curMat->GetName();
423 TString medName = curMed->GetName();
425 if (curMed->GetId() != curMedInGeoManager->GetId()) {
427 LOG(debug) <<
" Medium needs to be fixed";
429 Int_t ind = curMat->GetIndex();
430 gGeoManager->RemoveMaterial(ind);
431 LOG(debug) <<
" removing material " << curMat->GetName() <<
" with index " << ind;
432 for (Int_t i = ind; i < gGeoManager->GetListOfMaterials()->GetEntries(); i++) {
433 TGeoMaterial* m =
static_cast<TGeoMaterial*
>(gGeoManager->GetListOfMaterials()->At(i));
434 m->SetIndex(m->GetIndex() - 1);
437 LOG(debug) <<
" Medium fixed";
440 LOG(debug) <<
" Already fixed medium found in the list ";
445 LOG(debug) <<
" There is no correct medium in the memory yet";
447 FairGeoLoader* geoLoad = FairGeoLoader::Instance();
448 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
449 FairGeoMedia* geoMediaBase = geoFace->getMedia();
452 FairGeoMedium* curMedInGeo = geoMediaBase->getMedium(medName);
453 if (curMedInGeo ==
nullptr) {
454 LOG(fatal) << medName <<
" Media not found in Geo file.";
460 LOG(debug) <<
" Found media in Geo file" << medName;
462 fFixedMedia[medName] =
static_cast<TGeoMedium*
>(gGeoManager->GetListOfMedia()->Last());
463 gGeoManager->RemoveMaterial(curMatOfMedInGeoManager->GetIndex());
464 LOG(debug) <<
" removing material " << curMatOfMedInGeoManager->GetName() <<
" with index "
465 << curMatOfMedInGeoManager->GetIndex();
466 for (Int_t i = curMatOfMedInGeoManager->GetIndex(); i < gGeoManager->GetListOfMaterials()->GetEntries();
468 TGeoMaterial* m =
static_cast<TGeoMaterial*
>(gGeoManager->GetListOfMaterials()->At(i));
469 m->SetIndex(m->GetIndex() - 1);
473 if (curMedInGeo->getSensitivityFlag()) {
474 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
475 AddSensitiveVolume(curVol);
479 LOG(debug) <<
" Already fixed medium found in the list";
480 LOG(debug) <<
"!!! Sensitivity: " <<
fFixedMedia[medName]->GetParam(0);
482 LOG(debug) <<
" Adding sensitive " << curVol->GetName();
483 AddSensitiveVolume(curVol);
489 gGeoManager->SetAllIndex();
496 if (curVol->GetNdaughters() != 0) {
497 TObjArray* NodeChildList = curVol->GetNodes();
498 TGeoNode* curNodeChild {
nullptr};
499 for (Int_t j = 0; j < NodeChildList->GetEntriesFast(); j++) {
500 curNodeChild =
static_cast<TGeoNode*
>(NodeChildList->At(j));