20#include <TGeoManager.h>
22#include "ROOTGeo/MdcROOTGeo.h"
25MdcROOTGeo::m_kReplica[m_kLayer] = { 40, 44, 48, 56, 64, 72, 80, 80,
26 76, 76, 88, 88, 100, 100, 112, 112, 128, 128, 140, 140,
27 160, 160, 160, 160, 192, 192, 192, 192, 208, 208, 208, 208, 240, 240, 240, 240,
28 256, 256, 256, 256, 288, 288, 288,
29 256, 256, 256, 256, 288, 288, 288 };
31MdcROOTGeo::m_kiCorrectLayer[m_kCorrectLayer] = {9, 11, 13, 15, 17, 19, 36, 38, 40, 42};
34MdcROOTGeo::m_kiCorrectReplica[m_kCorrectLayer] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
39 for (
int layer = 0; layer < m_kLayer; layer++) {
40 for (
int replica = 0; replica < m_kReplicaMax; replica++) {
41 m_NodeReplica[layer][replica] = 0;
42 m_PhysicalReplica[layer][replica] = 0;
46 for (
int i = 0; i < m_kCorrectLayer; i++) {
47 m_CorrectMap[m_kiCorrectLayer[i]] = m_kiCorrectReplica[i];
68 if(!m_Mdc) std::cout <<
"m_Mdc = 0" << std::endl;
70 for (
int layer = 0; layer < m_kLayer; layer++) {
72 for (
int replica = 0; replica < m_kReplica[layer]; replica++) {
73 std::stringstream osname;
75 if (layer >= 0 && layer < m_kStereoLayerIn) {
76 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"TwistedTubs" <<
"_" << rep;
78 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
80 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"Replica" <<
"_" << rep;
82 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
83 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
84 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"TwistedTubs" <<
"_" << rep;
86 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
87 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
89 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"_0" <<
"Replica" <<
"_" << rep;
91 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
94 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer - m_kAxialLayerOut <<
"_1" <<
"Replica" <<
"_" << rep;
97 m_NodeReplica[layer][replica] =
GetNode( osname.str() );
106 for (intMap::iterator
iter = m_CorrectMap.begin();
iter != m_CorrectMap.end();
iter++) {
107 if (layer == (*iter).first ||
108 (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
109 layer - m_kAxialLayerOut == (*iter).first)) {
110 rep -= (*iter).second;
111 if (rep < 0) rep += m_kReplica[layer];
124 int segmentColor = 0;
127 int twistedTubsColor = 3;
128 int replicaColor = 4;
130 m_Mdc->SetLineColor(mdcColor);
131 m_Mdc->SetVisibility(0);
133 for (
int segment = 1; segment <= m_kSegment; segment++) {
138 for (
int layer =0; layer < m_kLayer; layer++) {
139 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
140 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
141 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) ) {
153 for (
int segment = 1; segment <= m_kSegment; segment++) {
154 for (
int no = 0; no < 2; no++) {
159 for (
int layer = 0; layer < m_kLayer; layer++) {
161 for (
int replica = 0; replica < m_kReplica[layer]; replica++) {
172 for (
int segment = 1; segment <= m_kSegment; segment++) {
176 for (
int layer = 0; layer < m_kLayer; layer++) {
181 for (
int segment = 1; segment <= m_kSegment; segment++) {
182 for (
int no = 0; no < 2; no++) {
187 for (
int layer = 0; layer < m_kLayer; layer++) {
189 for (
int replica = 0; replica < m_kReplica[layer]; replica++) {
198 for (
int segment = 1; segment <= m_kSegment; segment++) {
202 for (
int layer = 0; layer < m_kLayer; layer++) {
207 for (
int segment = 1; segment <= m_kSegment; segment++) {
208 for (
int no = 0; no < 2; no++) {
213 for (
int layer = 0; layer < m_kLayer; layer++) {
215 for (
int replica = 0; replica < m_kReplica[layer]; replica++) {
216 if (replica < m_kReplica[layer]/4)
GetReplica(layer, replica)->SetVisibility(0);
217 else GetReplica(layer, replica)->SetVisibility(1);
225 int twistedTubsColor = 3;
226 int replicaColor = 4;
228 if (gGeoManager == 0) std::cout <<
"Create gGeoManager first" << std::endl;
229 TGeoNode *
bes = gGeoManager->GetTopNode();
235 for (
int layer = 0; layer < m_kLayer; layer++) {
236 TGeoNode *nodeLayer =
GetLayer(layer);
238 for (
int replica = 0; replica < m_kReplica[layer]; replica++) {
239 TGeoNode *nodeReplica =
GetReplica(layer, replica);
240 m_PhysicalReplica[layer][replica] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
241 TString(
"/") +
mdc->GetName() +
242 TString(
"/") + nodeLayer->GetName() +
243 TString(
"/") + nodeReplica->GetName());
244 m_PhysicalReplica[layer][replica]->SetVisibility(0);
245 m_PhysicalReplica[layer][replica]->SetIsVolAtt(kFALSE);
246 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
247 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
248 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) ) {
249 m_PhysicalReplica[layer][replica]->SetLineColor(twistedTubsColor);
252 m_PhysicalReplica[layer][replica]->SetLineColor(replicaColor);
262 std::stringstream osname;
263 osname <<
"logical" <<
"Mdc" <<
"Segment" << segment;
270 std::stringstream osname;
271 if (layer >= 0 && layer < m_kStereoLayerIn) {
272 osname <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer;
274 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
275 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer;
277 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
278 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
279 osname <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer;
281 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
282 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
283 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"_0";
285 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
287 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer - m_kAxialLayerOut <<
"_1";
296 std::stringstream osname;
297 if (layer >= 0 && layer < m_kStereoLayerIn) {
298 osname <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"TwistedTubs";
300 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
301 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"Replica";
303 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
304 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
305 osname <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"TwistedTubs";
307 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
308 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
309 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"_0" <<
"Replica";
311 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
313 osname <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer - m_kAxialLayerOut <<
"_1" <<
"Replica";
322 std::stringstream osname;
323 if (segment == 1 || segment == 2) {
324 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Segment" << segment <<
"_" << m_kLayer + segment - 1;
327 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Segment" << segment <<
"_" << m_kLayer + 2 + (segment - 3)*2 + no;
330 return GetNode( osname.str() );
336 std::stringstream osname;
337 if (layer >= 0 && layer < m_kStereoLayerIn) {
338 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"_" << layer;
340 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
341 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"_" << layer;
343 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
344 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
345 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Stereo" <<
"Layer" << layer <<
"_" << layer;
347 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
348 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
349 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer <<
"_0" <<
"_"
350 << 2*layer - m_kStereoLayerIn - m_kAxialLayerIn - m_kStereoLayerOut;
352 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
354 osname <<
"pv_" <<
"logical" <<
"Mdc" <<
"Axial" <<
"Layer" << layer - m_kAxialLayerOut <<
"_1" <<
"_"
355 << 2*(layer - m_kAxialLayerOut) - m_kStereoLayerIn - m_kAxialLayerIn - m_kStereoLayerOut + 1;
359 return GetNode( osname.str() );
365 if (m_NodeReplica[layer][replica] != 0) {
367 return m_NodeReplica[layer][replica];
370 std::cout <<
"Node: " <<
"Layer" << layer <<
"Replica" << replica <<
" not found" << std::endl;
378 if (m_PhysicalReplica[layer][replica] != 0) {
379 return m_PhysicalReplica[layer][replica];
382 std::cout <<
"PhysicalNode: " <<
"Layer" << layer <<
"Replica" << replica <<
" not found" << std::endl;
TGeoNode * GetSegment(int segment, int no)
Get segment node;.
int CorrectReplica(int layer, int replica)
Correct some axial layer id to copyNo;.
TGeoVolume * GetVolumeLayer(int layer)
Get layer volume;
void SetQuarterVisible()
Set quater visible;.
void SetNode()
Set the pointers to theirs nodes;.
TGeoNode * GetLayer(int layer)
Get layer node;
TGeoNode * GetReplica(int layer, int replica)
Get replica node;.
void SetDefaultVis()
Set default visual attributes;.
TGeoVolume * GetVolumeReplica(int layer)
Get replica volume;.
TGeoVolume * GetVolumeSegment(int segment)
Get segment volume;.
TGeoPhysicalNode * GetPhysicalReplica(int layer, int replica)
Get replica physical node;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
void SetAllVisible()
Set all visible;.
void InitFromGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
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.