MpdEmcGeoParams.cxx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ////////////////////////////////////////////////////////////////
  2. // //
  3. // MpdEmcGeoParams //
  4. // EMC geometry in MpdEmcHitCreation, v02 //
  5. // Author List : Martemianov M., 2019 //
  6. // //
  7. ////////////////////////////////////////////////////////////////
  8. #include "MpdEmcGeoParams.h"
  9. #include "FairParamList.h"
  10. #include "TObjArray.h"
  11. #include <iostream>
  12. #include "TGeoNode.h"
  13. #include "TGeoManager.h"
  14. #include "TGeoTube.h"
  15. #include "TGeoPgon.h"
  16. #include "TGeoPcon.h"
  17. #include "TGeoArb8.h"
  18. ClassImp(MpdEmcGeoParams)
  19. MpdEmcGeoParams ::MpdEmcGeoParams(const char* name, const char* title, const char* context)
  20. : FairParGenericSet(name,title,context) {
  21. fGeoSensNodes = new TObjArray();
  22. fGeoPassNodes = new TObjArray();
  23. }
  24. MpdEmcGeoParams::MpdEmcGeoParams() {
  25. TString pathCave= "/cave_1";
  26. TString pathChamber = pathCave + "/emcChamber_0";
  27. // New EMC version
  28. TString path1, path2, pathSector, pathRow, pathBox;
  29. TGeoNode *sectorNode, *rowNode, *modNode, *boxNode;
  30. path1 = pathChamber+"/emcChH_0"; path2 = pathChamber+"/emcChH_1";
  31. gGeoManager->cd(path1);
  32. // Total barell
  33. length = 2.*((TGeoTube*)gGeoManager->GetCurrentVolume()->GetShape())->GetDz();
  34. rMin = ((TGeoTube*)gGeoManager->GetCurrentVolume()->GetShape())->GetRmin();
  35. rMax = ((TGeoTube*)gGeoManager->GetCurrentVolume()->GetShape())->GetRmax();
  36. TGeoVolume* emcRow = (TGeoVolume*)gGeoManager->GetVolume("emcCrate");
  37. fAngleCrate = ((TGeoPgon*)emcRow->GetShape())->GetDphi();
  38. Double_t rotAngle;
  39. Int_t nSector = 0, nRow = 0, nBox = 0;
  40. TGeoVolume* emcChH = (TGeoVolume*)gGeoManager->GetCurrentVolume();
  41. TIterator* sectorIter = emcChH->GetNodes()->MakeIterator();
  42. const Double_t* fRotMatrix;
  43. const Double_t* fTransMatrix;
  44. Double_t master[3];
  45. TGeoMatrix *rowMatrix;
  46. TGeoShape* boxShape;
  47. while( (sectorNode = (TGeoNode*) sectorIter->Next()) )
  48. if ( ((TString)(sectorNode->GetName())).Contains("emcSector")) nSector++;
  49. fAngleSector = 360./nSector; nSec = nSector;
  50. nSector = 0; sectorIter->Reset();
  51. while( (sectorNode = (TGeoNode*)sectorIter->Next()) ) {
  52. pathSector = path1+"/"+sectorNode->GetName();
  53. if (((TString)(sectorNode->GetName())).Contains("emcSector")) { nSector++;
  54. gGeoManager->cd(pathSector);
  55. fRotMatrix = gGeoManager->GetCurrentMatrix()->GetRotationMatrix();
  56. rotAngle = ATan2(fRotMatrix[3],fRotMatrix[0])*RadToDeg();
  57. phiSector.push_back(rotAngle + 0.5*fAngleSector);
  58. if (phiSector[nSector-1] < 0) phiSector[nSector-1] += 360.;
  59. // Row level
  60. TIterator* rowIter = sectorNode->GetNodes()->MakeIterator();
  61. while( (rowNode = (TGeoNode*)rowIter->Next()) ) {
  62. pathRow = pathSector+"/"+rowNode->GetName();
  63. if (((TString)(rowNode->GetName())).Contains("emcCrate")){nRow++;
  64. gGeoManager->cd(pathRow);
  65. rowMatrix = gGeoManager->GetCurrentMatrix();
  66. rowMatrix->LocalToMaster(rowNode->GetMatrix()->GetTranslation(), master);
  67. fRotMatrix = rowMatrix->GetRotationMatrix();
  68. rotAngle = ATan2(fRotMatrix[3],fRotMatrix[0])*RadToDeg();
  69. if (rotAngle < 0) rotAngle += 360.;
  70. fTransMatrix = rowMatrix->GetTranslation();
  71. phiRow.push_back(rotAngle + 0.5*fAngleCrate);
  72. xRow.push_back(fTransMatrix[0]); yRow.push_back(fTransMatrix[1]);
  73. if (phiRow[nRow-1] < 0) phiRow[nRow-1] += 360.;
  74. // Box level
  75. TIterator* moduleIter = rowNode->GetNodes()->MakeIterator();
  76. while ( (modNode = (TGeoNode*)moduleIter->Next()) ) {
  77. if (((TString)(modNode->GetName())).Contains("emcModule")){
  78. TIterator* boxIter = modNode->GetNodes()->MakeIterator();
  79. while ( (boxNode = (TGeoNode*)boxIter->Next()) ) {nBox++;
  80. pathBox = pathRow+"/"+modNode->GetName()+"/"+boxNode->GetName();
  81. if (((TString)(boxNode->GetName())).Contains("emc_box")){
  82. gGeoManager->cd(pathBox);
  83. rowMatrix = gGeoManager->GetCurrentMatrix();
  84. rowMatrix->LocalToMaster(boxNode->GetMatrix()->GetTranslation(), master);
  85. fRotMatrix = rowMatrix->GetRotationMatrix();
  86. fTransMatrix = rowMatrix->GetTranslation();
  87. phiBox.push_back(ATan2(fRotMatrix[3],fRotMatrix[0])*RadToDeg());
  88. thetaBox.push_back(ACos(fRotMatrix[8])*RadToDeg());
  89. xBox.push_back(fTransMatrix[0]); yBox.push_back(fTransMatrix[1]);
  90. zBox.push_back(fTransMatrix[2]);
  91. rhoBox.push_back(sqrt(fTransMatrix[0]*fTransMatrix[0]+fTransMatrix[1]*fTransMatrix[1]));
  92. boxShape = boxNode->GetVolume()->GetShape();
  93. if (((TString)(boxShape->GetName())).Contains("TGeoArb8")) {
  94. Double_t *vertices = ((TGeoArb8*)boxShape)->GetVertices();
  95. sizeLowBox = 0.5*(vertices[4] - vertices[0]);
  96. sizeHighBox = 0.5*(vertices[12] - vertices[8]);
  97. lengthBox = ((TGeoArb8*)boxShape)->GetDz();
  98. }
  99. }
  100. }
  101. }
  102. }
  103. //// end box level
  104. }
  105. }
  106. }
  107. } nRows = nRow; nTowers = nBox;
  108. }
  109. MpdEmcGeoParams::~MpdEmcGeoParams(void) {
  110. }
  111. void MpdEmcGeoParams::clear(void) {
  112. if(fGeoSensNodes) delete fGeoSensNodes;
  113. if(fGeoPassNodes) delete fGeoPassNodes;
  114. }
  115. void MpdEmcGeoParams::putParams(FairParamList* l) {
  116. if (!l) return;
  117. l->addObject("FairGeoNodes Sensitive List", fGeoSensNodes);
  118. l->addObject("FairGeoNodes Passive List", fGeoPassNodes);
  119. }
  120. Bool_t MpdEmcGeoParams::getParams(FairParamList* l) {
  121. if (!l) return kFALSE;
  122. if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes)) return kFALSE;
  123. if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes)) return kFALSE;
  124. return kTRUE;
  125. }