23#include <TGeoManager.h>
34 for (
int part = 0; part < m_kPart; part++) {
35 for (
int phi = 0; phi < m_kPhiBr; phi++) {
36 for (
int theta = 0; theta < m_kThetaBr; theta++) {
37 m_NodeTheta[part][phi][theta] = 0;
38 m_PhysicalCrystal[part][phi][theta] = 0;
43 string GdmlManagementPath = getenv(
"GDMLMANAGEMENTROOT");
44 if (GdmlManagementPath ==
"") cout <<
"EmcROOTGeo::GdmlManagementPath not set!" << endl;
45 string GdmlFile = GdmlManagementPath + string(
"/dat/Emc.gdml");
46 cout <<
"Construct Emc from GdmlFile " << GdmlFile << endl;
70 if(!m_Emc) std::cout <<
"m_Emc = 0" << std::endl;
71 else cout<<
"Find logicalEMC!"<<endl;
73 for (
int part = 0; part < m_kPart; part++) {
76 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
78 for (
int phi = 0; phi <
nPhi; phi++) {
80 int nTheta = (part == 1 ? 219 : m_kThetaEc);
81 TGeoNode *nodePhi =
GetPhi(part,phi);
84 for (
int theta = 0; theta < nTheta; theta++) {
85 string name = nodePhi->GetDaughter(theta)->GetName();
88 if(name.find(
"BSCCasing",0)==7) {
89 strthe = name.substr(16,2);
90 }
else if(name.find(
"EndCasing",0)==7) {
91 strthe = name.substr(19,2);
94 istringstream thetaBuf(strthe);
98 m_NodeTheta[part][phi][nthe] = nodePhi->GetDaughter(theta);
114 int brCrystalColor = 4;
115 int ecCrystalColor = 7;
117 m_Emc->SetLineColor(emcColor);
118 m_Emc->SetVisibility(0);
120 for (
int part = 0; part < m_kPart-1; part++) {
122 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
123 for (
int phi = 0; phi <
nPhi; phi++) {
128 for (
int theta = 0; theta < m_kThetaBr; theta++) {
135 else if (part == 0) {
136 int iPhi[4] = {0,6,8,7};
137 for (
int i = 0; i < 4; i++) {
139 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
140 for (
int theta = 0; theta < nTheta; theta++) {
150 for (
int part = 0; part < m_kPart; part++) {
151 GetPart(part)->SetVisibility(0);
152 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
153 for (
int phi = 0; phi <
nPhi; phi++) {
154 GetPhi(part, phi)->SetVisibility(0);
155 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
156 for (
int theta = 0; theta < nTheta; theta++) {
157 GetTheta(part, phi, theta)->SetVisibility(0);
158 GetCrystal(part, phi, theta)->SetVisibility(0);
193 for (
int part = 0; part < m_kPart; part++) {
194 GetPart(part)->SetVisibility(0);
195 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
196 for (
int phi = 0; phi <
nPhi; phi++) {
197 GetPhi(part, phi)->SetVisibility(0);
198 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
199 for (
int theta = 0; theta < nTheta; theta++) {
200 GetTheta(part, phi, theta)->SetVisibility(0);
201 GetCrystal(part, phi, theta)->SetVisibility(1);
233 for (
int part = 0; part < m_kPart; part++) {
234 GetPart(part)->SetVisibility(0);
235 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
236 for (
int phi = 0; phi <
nPhi; phi++) {
237 GetPhi(part, phi)->SetVisibility(0);
238 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
239 for (
int theta = 0; theta < nTheta; theta++) {
240 GetTheta(part, phi, theta)->SetVisibility(0);
241 if ( (part == 1 && (phi >= 0 && phi <
nPhi/4)) ||
243 GetCrystal(part, phi, theta)->SetVisibility(1);
246 GetCrystal(part, phi, theta)->SetVisibility(0);
260 if (gGeoManager == 0) std::cout <<
"Create gGeoManager first" << std::endl;
261 else cout<<
"gGeoManager success!"<<endl;
264 if(!volEmc) std::cout <<
"logicalEMC not found !" << std::endl;
269 TGeoIdentity *identity =
new TGeoIdentity();
271 TGeoMaterial *mat =
new TGeoMaterial(
"VOID",0,0,0);
272 TGeoMedium *med =
new TGeoMedium(
"MED",1,mat);
273 TGeoVolume *m_Bes = gGeoManager->MakeBox(
"volBes", med,
274 0.5*m_BesR, 0.5*m_BesR, 0.5*m_BesZ);
275 gGeoManager->SetTopVolume(m_Bes);
276 m_Bes->AddNode(volEmc, 0, identity);
280 gGeoManager->SetDrawExtraPaths();
281 gGeoManager->CloseGeometry();
282 gGeoManager->SetNsegments(20);
285 TGeoNode *
bes = gGeoManager->GetTopNode();
286 TGeoNode *emc =
bes->GetDaughter(0);
288 for (
int part = 0; part < m_kPart; part++) {
289 TGeoNode *nodePart =
GetPart(part);
290 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
291 for (
int phi = 0; phi <
nPhi; phi++) {
292 TGeoNode *nodePhi =
GetPhi(part, phi);
293 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
294 for (
int theta = 0; theta < nTheta; theta++) {
296 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
297 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
298 TString strPath = TString(
"/") +
bes->GetName() +
299 TString(
"/") + emc->GetName() +
300 TString(
"/") + nodePart->GetName() +
301 TString(
"/") + nodePhi->GetName() +
302 TString(
"/") + nodeTheta->GetName() +
303 TString(
"/") + nodeCrystal->GetName();
304 m_PhysicalCrystal[part][phi][theta] = gGeoManager->MakePhysicalNode(strPath);
326 int thetaNb = m_kThetaBr;
327 if (part != 1) thetaNb = m_kThetaEc;
335 int phiNb = m_kPhiBr;
336 if (part != 1) phiNb = m_kPhiEc;
345 std::stringstream osname;
346 osname <<
"logical" <<
"Emc" <<
"Part" << part;
347 if (part == 0 || part == 1) {
351 std::cout <<
"No volume " << osname.str() << std::endl;
360 std::stringstream osname;
361 osname <<
"logical" <<
"Emc" <<
"Part" << part <<
"Phi" << phi;
362 if ( (part == 0 && phi >= 0 && phi < 16) ||
363 (part == 1 && phi >= 0 && phi < 120) ) {
367 std::cout <<
"No volume " << osname.str() << std::endl;
377 std::stringstream osname;
378 if (part == 1 && theta >= 0 && theta < 44) {
379 osname <<
"logical" <<
"Emc" <<
"Part" << part <<
"Theta" << theta;
382 else if ( part == 0 && theta >= 0 && theta < 35 &&
383 (phi == 0 || phi == 6 || phi == 8 || phi == 7) ) {
384 osname <<
"logical" <<
"Emc" <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta;
388 std::cout <<
"No volume " << osname.str() << std::endl;
398 std::stringstream osname;
399 if (part == 1 && theta >= 0 && theta < 44) {
400 osname <<
"logical" <<
"Emc" <<
"Part" << part <<
"Theta" << theta <<
"Crystal";
403 else if ( part == 0 && theta >= 0 && theta < 35 &&
404 (phi == 0 || phi == 6 || phi == 8 || phi == 7) ) {
405 osname <<
"logical" <<
"Emc" <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
"Crystal";
409 std::cout <<
"No volume " << osname.str() << std::endl;
417 std::stringstream osname;
419 osname <<
"pv_logicalBSCWorld_2";
421 osname <<
"pv_logicalEndWorld_" << 1-part/2;
425 return GetNode( osname.str() );
432 std::stringstream osname;
435 osname <<
"pv_logicalBSCPhi_" << phiNb;
438 osname <<
"pv_logicalEndPhi0_" << 15-phi;
439 }
else if(phi>=8&&phi<14) {
440 osname <<
"pv_logicalEndPhi0_" << 17-phi;
441 }
else if(phi==6||phi==14) {
442 osname <<
"pv_logicalEndPhi1_" << (30-phi)/8;
443 }
else if(phi==7||phi==15) {
444 osname <<
"pv_logicalEndPhi2_" << (15-phi)/8;
449 return GetNode( osname.str() );
455 if (m_NodeTheta[part][phi][theta] != 0) {
456 return m_NodeTheta[part][phi][theta];
459 std::cout <<
"Node: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
468 return GetTheta(part, phi, theta)->GetDaughter(0);
474 if (m_PhysicalCrystal[part][phi][theta] != 0) {
475 return m_PhysicalCrystal[part][phi][theta];
478 std::cout <<
"PhysicalNode: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
TGeoVolume * GetVolumeCrystal(int part, int phi, int theta)
Get crystal volume;.
TGeoNode * GetCrystal(int part, int phi, int theta)
Get crystal one;.
void InitFromGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
TGeoVolume * GetVolumeTheta(int part, int phi, int theta)
Get theta volume;.
TGeoNode * GetTheta(int part, int phi, int theta)
Get theta node;.
int GetPartNb()
Get number of part;.
TGeoVolume * GetVolumePart(int part)
Get part volume;.
TGeoNode * GetPart(int part)
Get part node;.
void SetDefaultVis()
Set default visual attributes;.
int GetPhiNb(int part)
Get number of phi on part;.
void SetAllVisible()
Set all visible;.
TGeoVolume * GetVolumePhi(int part, int phi)
Get phi volume;
void SetPhysicalNode()
Set the pointers to the physical nodes;.
void SetNode()
Set the pointers to theirs nodes;.
int GetThetaNb(int part)
Get number of theta on part;.
TGeoNode * GetPhi(int part, int phi)
Get phi node;.
TGeoPhysicalNode * GetPhysicalCrystal(int part, int phi, int theta)
Get crystal physical node;.
void SetQuarterVisible()
Set quater visible;.
TGeoNode * GetNode(const std::string &nn)
Get a node(physical volume) by name;.
TGeoVolume * GetTopVolume()
Get the top(world) volume;.
TGeoVolume * GetLogicalVolume(const std::string &vn)
Get a logical volume by name;.
void ReadGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
void SetChildNo(int childNo)