23#include <TGeoManager.h>
47 for (
int part = 0; part < m_kPart; part++) {
48 for (
int phi = 0; phi < m_kPhiBr; phi++) {
49 m_NodePhi[part][phi] = 0;
50 for (
int theta = 0; theta < m_kThetaBr; theta++) {
51 m_NodeTheta[part][phi][theta] = 0;
52 m_NodeTheta2[part][phi][theta] = 0;
53 m_PhysicalCrystal[part][phi][theta] = 0;
54 m_PhysicalCrystal2[part][phi][theta] = 0;
55 m_Emc2DCrystal[part][phi][theta] = 0;
59 m_PhyNodeOrgArray =
new TObjArray();
65 m_brCrystalColor = 861;
66 m_ecCrystalColor = 866;
72 cout <<
"delete old EmcROOTGeo" << endl;
73 for (
int part = 0; part <
GetPartNb(); part++)
75 for (
int theta = 0; theta <
GetThetaNb(part); theta++)
77 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++)
79 delete m_Emc2DCrystal[part][phi][theta];
83 delete m_PhyNodeOrgArray;
108 cout <<
"EmcROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
113 Double_t local[3] = {0.0, 0.0, 0.0};
114 Double_t master[3] = {0.0, 0.0, 0.0};
122 for (
int part = 0; part <
GetPartNb(); part++) {
123 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
124 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
125 TGeoPhysicalNode *phyNode = 0;
127 if (part == 1) name = TString(
"Barrel");
129 if (part == 0) name = TString(
"EastEc");
130 else if (part == 2) name = TString(
"WestEc");
132 name = TString(
"Emc Part");
135 if (part == 1) name += m_kThetaBr - 1 - theta;
141 sprintf(
data,
"Emc part %i, #theta %i, #phi %i", part, theta, phi);
144 TGeoArb8 *crystalShape = (TGeoArb8*)phyNode->GetShape();
145 Double_t *localArb8Point, masterArb8Point[24*2];
146 localArb8Point = crystalShape->GetVertices();
147 for (Int_t i = 0; i < 8; i++) {
148 local[0] = localArb8Point[2*i];
149 local[1] = localArb8Point[2*i+1];
150 if (i < 4) local[2] = crystalShape->GetDz() * (-1.0);
151 else local[2] = crystalShape->GetDz();
153 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
155 for (Int_t j = 0; j < 3; j++) {
156 masterArb8Point[3*i+j] = master[j];
160 TGeoPhysicalNode *phyNode2 = 0;
163 crystalShape = (TGeoArb8*)phyNode2->GetShape();
164 localArb8Point = crystalShape->GetVertices();
165 for (Int_t i = 0; i < 8; i++) {
166 local[0] = localArb8Point[2*i];
167 local[1] = localArb8Point[2*i+1];
168 if (i < 4) local[2] = crystalShape->GetDz() * (-1.0);
169 else local[2] = crystalShape->GetDz();
170 phyNode2->GetMatrix(-1*phyNode->GetLevel())
171 ->LocalToMaster(local, &master[0]);
172 for (Int_t j = 0; j < 3; j++) {
173 masterArb8Point[24+3*i+j] = master[j];
179 m_Emc2DCrystal[part][phi][theta] =
182 m_Emc2DCrystal[part][phi][theta] =
196 if (!m_Emc) std::cout <<
"m_Emc = 0" << std::endl;
201 for (
int part = 0; part < m_kPart; part++) {
203 if (part == 1) ipart = 2;
204 if (part == 0) ipart = 1;
206 m_NodePart[part] = m_Emc->GetNode(ipart);
209 for (
int phi = 0; phi < m_kPhiBr; phi++) {
213 m_NodePhi[part][phi] =
GetPart(part)->GetVolume()->GetNode(iphi);
217 int endphilist[16]= {15,7,14,6,13,12,11,10,9,8,5,4,3,2,1,0};
218 int endphipos[16] = {15,14,13,12,11,10,3,1,9,8,7,6,5,4,2,0};
220 for (
int sector = 0; sector < m_kSectorEc; sector++) {
221 m_NodePhi[part][sector] =
222 GetPart(part)->GetVolume()->GetNode(endphipos[sector]);
229 for (
int phi = 0; phi < m_kPhiBr; phi++) {
231 for (
int idaughter = 0; idaughter<
GetPhi(1, phi)->GetNdaughters(); idaughter++) {
232 TString name =
GetPhi(1, phi)->GetDaughter(idaughter)->GetName();
233 if (name.Contains(
"logicalBSCCasing")){
235 m_NodeTheta[1][phi][theta] =
GetPhi(1, phi)->GetDaughter(idaughter);
241 for (
int part = 0; part < m_kPart; part++) {
242 if (part == 1)
continue;
243 for (
int sector = 0; sector < m_kSectorEc; sector++) {
244 for (
int nb = 0; nb < m_kNbEc; nb++) {
246 if (nb < m_kRealNbEc) {
248 m_NodeTheta[part][phi][theta] =
GetPhi(part, sector)->GetDaughter(nb);
255 m_NodeTheta2[part][phi][theta] =
GetPhi(part, sector)->GetDaughter(nb);
274 TGeoVolume *logicRear,*logicOrgGlass,*logicRearCasing,*logicAlPlate,*logicPD,*logicPreAmpBox,*logicAirInPABox,*logicHangingPlate,*logicWaterPipe;
275 TGeoVolume *logicCable,*logicOCGirder,*logicSupportBar,*logicSupportBar1,*logicEndRing,*logicGear,*logicTaperRing1,*logicTaperRing2,*logicTaperRing3;
278 gErrorIgnoreLevel = kFatal;
290 for (
int i = 0; i < 44; i++){
292 std::ostringstream osnameBSCCable1;
293 osnameBSCCable1 <<
"logicalBSCCable_1_"<<i;
296 logicCable->SetVisibility(0);
298 std::ostringstream osnameBSCCable2;
299 osnameBSCCable2 <<
"logicalBSCCable_2_"<<i;
302 logicCable->SetVisibility(0);
304 std::ostringstream osnameOCGirder1;
305 osnameOCGirder1 <<
"logicalOpenningCutGirder_1_"<<i;
308 logicOCGirder->SetVisibility(0);
310 std::ostringstream osnameOCGirder2;
311 osnameOCGirder2 <<
"logicalOpenningCutGirder_2_"<<i;
314 logicOCGirder->SetVisibility(0);
316 std::ostringstream osnameOCGirder3;
317 osnameOCGirder3 <<
"logicalOpenningCutGirder_3_"<<i;
320 logicOCGirder->SetVisibility(0);
322 std::ostringstream osnameOCGirder4;
323 osnameOCGirder4 <<
"logicalOpenningCutGirder_4_"<<i;
326 logicOCGirder->SetVisibility(0);
340 logicRear->SetVisibility(0);
342 logicOrgGlass->SetVisibility(0);
344 logicRearCasing->SetVisibility(0);
346 logicAlPlate->SetVisibility(0);
348 logicPD->SetVisibility(0);
350 logicPreAmpBox->SetVisibility(0);
352 logicAirInPABox->SetVisibility(0);
353 if (logicHangingPlate)
354 logicHangingPlate->SetVisibility(0);
356 logicWaterPipe->SetVisibility(0);
358 logicGear->SetVisibility(0);
360 logicTaperRing1->SetVisibility(0);
362 logicTaperRing2->SetVisibility(0);
364 logicTaperRing3->SetVisibility(0);
366 logicSupportBar->SetVisibility(0);
367 if (logicSupportBar1)
368 logicSupportBar1->SetVisibility(0);
370 logicEndRing->SetVisibility(0);
381 m_Emc->SetLineColor(m_EmcColor);
382 m_Emc->SetVisibility(0);
384 for (
int part = 0; part < m_kPart-1; part++) {
386 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
387 for (
int phi = 0; phi <
nPhi; phi++) {
392 for (
int theta = 0; theta < m_kThetaBr; theta++) {
399 else if (part == 0) {
400 int iPhi[3] = {0,1,2};
401 for (
int i = 0; i < 3; i++) {
403 int nTheta = (part == 1 ? m_kThetaBr : m_kNbEc);
404 for (
int theta = 0; theta < nTheta; theta++) {
415 for (
int part = 0; part < m_kPart; part++) {
416 GetPart(part)->SetVisibility(0);
417 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
418 for (
int phi = 0; phi <
nPhi; phi++) {
419 GetPhi(part, phi)->SetVisibility(0);
424 for (
int part = 0; part < m_kPart; part++) {
425 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
426 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
428 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
429 if (nodeTheta) nodeTheta->SetVisibility(0);
430 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
431 if (nodeCrystal) nodeCrystal->SetVisibility(0);
433 TGeoNode *nodeTheta2 =
GetTheta2(part, phi, theta);
434 if (nodeTheta2) nodeTheta2->SetVisibility(0);
435 TGeoNode *nodeCrystal2 =
GetCrystal2(part, phi, theta);
436 if (nodeCrystal2) nodeCrystal2->SetVisibility(0);
452 m_Emc->SetLineColor(m_EmcColor);
453 m_Emc->SetVisibility(0);
455 for (
int part = 0; part < m_kPart-1; part++) {
457 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
458 for (
int phi = 0; phi <
nPhi; phi++) {
463 for (
int theta = 0; theta < m_kThetaBr; theta++) {
470 else if (part == 0) {
471 int iPhi[3] = {0,1,2};
472 for (
int i = 0; i < 3; i++) {
474 int nTheta = (part == 1 ? m_kThetaBr : m_kNbEc);
475 for (
int theta = 0; theta < nTheta; theta++) {
486 for (
int part = 0; part < m_kPart; part++) {
487 GetPart(part)->SetVisibility(1);
488 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
489 for (
int phi = 0; phi <
nPhi; phi++) {
490 GetPhi(part, phi)->SetVisibility(1);
495 for (
int part = 0; part < m_kPart; part++) {
496 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
497 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
499 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
500 if (nodeTheta) nodeTheta->SetVisibility(1);
501 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
502 if (nodeCrystal) nodeCrystal->SetVisibility(1);
504 TGeoNode *nodeTheta2 =
GetTheta2(part, phi, theta);
505 if (nodeTheta2) nodeTheta2->SetVisibility(1);
506 TGeoNode *nodeCrystal2 =
GetCrystal2(part, phi, theta);
507 if (nodeCrystal2) nodeCrystal2->SetVisibility(1);
616 if (gGeoManager == 0) std::cout <<
"Create gGeoManager first" << std::endl;
617 TGeoNode *
bes = gGeoManager->GetTopNode();
618 std::cout <<
"Emc m_childNo " <<
m_childNo << std::endl;
619 TGeoNode *emc =
bes->GetDaughter(2);
623 TGeoNode *nodePart =
GetPart(part);
624 for (
int phi = 0; phi <
GetPhiNb(part, 0); phi++) {
625 TGeoNode *nodePhi =
GetPhi(part, phi);
626 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
627 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
628 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
629 m_PhysicalCrystal[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
630 TString(
"/") + emc->GetName() +
631 TString(
"/") + nodePart->GetName() +
632 TString(
"/") + nodePhi->GetName() +
633 TString(
"/") + nodeTheta->GetName() +
634 TString(
"/") + nodeCrystal->GetName() );
635 m_PhysicalCrystal[part][phi][theta]->SetVisibility(0);
636 m_PhysicalCrystal[part][phi][theta]->SetIsVolAtt(kFALSE);
637 m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_brCrystalColor);
643 for (part = 0; part < m_kPart; part++) {
644 if (part == 1)
continue;
646 for (
int sector = 0; sector < m_kSectorEc; sector++) {
647 TGeoNode *nodeSector =
GetPhi(part, sector);
648 for (
int nb = 0; nb < m_kNbEc; nb++) {
649 TGeoNode *nodeNb = nodeSector->GetDaughter(nb);
650 TGeoNode *nodeCrystal = nodeNb->GetDaughter(0);
653 if (nb < m_kRealNbEc) {
655 m_PhysicalCrystal[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
656 TString(
"/") + emc->GetName() +
657 TString(
"/") + nodePart->GetName() +
658 TString(
"/") + nodeSector->GetName() +
659 TString(
"/") + nodeNb->GetName() +
660 TString(
"/") + nodeCrystal->GetName() );
661 m_PhysicalCrystal[part][phi][theta]->SetVisibility(0);
662 m_PhysicalCrystal[part][phi][theta]->SetIsVolAtt(kFALSE);
663 m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_ecCrystalColor);
668 m_PhysicalCrystal2[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
669 TString(
"/") + emc->GetName() +
670 TString(
"/") + nodePart->GetName() +
671 TString(
"/") + nodeSector->GetName() +
672 TString(
"/") + nodeNb->GetName() +
673 TString(
"/") + nodeCrystal->GetName() );
674 m_PhysicalCrystal2[part][phi][theta]->SetVisibility(0);
675 m_PhysicalCrystal2[part][phi][theta]->SetIsVolAtt(kFALSE);
676 m_PhysicalCrystal2[part][phi][theta]->SetLineColor(m_ecCrystalColor);
690 for (
int part = 0; part < m_kPart; part++)
692 for (
int theta = 0; theta <
GetThetaNb(part); theta++)
694 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++)
702 phyCrystal->SetIsVolAtt(kFALSE);
703 phyCrystal->SetLineColor(m_brCrystalColor);
710 phyCrystal->SetIsVolAtt(kFALSE);
711 phyCrystal->SetLineColor(m_ecCrystalColor);
715 phyCrystal2->SetIsVolAtt(kFALSE);
716 phyCrystal2->SetLineColor(m_ecCrystalColor);
730 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
737 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
738 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
741 phyNode->SetVisibility(0);
742 if ( phi >= 0 && phi < m_kPhiBr*4/4
755 for (
int part = 0; part < m_kPart; part++) {
756 if (part == 1)
continue;
757 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
758 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
761 phyNode->SetVisibility(0);
762 if (part == 2 && phi <=
GetPhiNb(part, theta)||
763 part == 0 && phi <=
GetPhiNb(part, theta) ) {
774 phyNode->SetVisibility(0);
775 if (part == 2 && phi <=
GetPhiNb(part, theta)||
776 part == 0 && phi <=
GetPhiNb(part, theta) ) {
797 for (
int i = 0; i <
m_HitsArray->GetEntries(); i++) {
798 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)
m_HitsArray->At(i);
800 int color = m_brCrystalColor;
802 if (part == 0 || part == 2)
803 color = m_ecCrystalColor;
805 phyNode->SetLineColor(color);
806 phyNode->SetVisibility(0);
810 m_PhyNodeOrgArray->Clear(
"C");
817 aCrystal->
AddInfo(aCrystal->GetTitle());
829 if (m_EmcDigiCol) NDigiCol = m_EmcDigiCol->GetEntries();
833 for (
int i = 0; i < NDigiCol; i++) {
844 TGeoPhysicalNode *phyNode = 0;
847 m_PhyNodeOrgArray->Add ( phyNode->GetNode() );
867 m_PhyNodeOrgArray->Add ( phyNode->GetNode() );
886 aCrystal = m_Emc2DCrystal[part][phi][theta];
892 aCrystal->
AddInfo(aCrystal->GetTitle());
911 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
915 phyNode->SetVisibility(0);
921 phyNode->SetVisibility(1);
930 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
932 for (
int i = 0; i <
m_HitsArray->GetEntries(); i++) {
933 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)
m_HitsArray->At(i);
939 phyNode->SetVisibility(1);
940 phyNode->SetLineColor(881);
946 if (part == 1) phyNode->SetLineColor(m_brCrystalColor);
947 else phyNode->SetLineColor(m_ecCrystalColor);
961 if (part == 1)
return m_kThetaBr;
962 else return m_kThetaEc;
968 int phiNb = m_kPhiBr;
970 if (theta < 2) phiNb = 4*m_kSectorEc;
971 else if (theta >= 2 && theta < 4) phiNb = 5*m_kSectorEc;
972 else if (theta >= 4 && theta < m_kThetaEc) phiNb = 6*m_kSectorEc;
982 std::stringstream osname;
983 if (part != 1) osname <<
"logicalEndWorld";
984 else osname <<
"logicalBSCWorld";
987 if (part == 0 || part == 1) {
991 std::cout <<
"No volume " << osname.str() << std::endl;
1000 std::stringstream osname;
1002 if (part == 1) osname <<
"logicalBSCPhi" ;
1004 if (phi == 15 || phi == 7) osname <<
"logicalEndPhi2" ;
1005 else if (phi == 14 || phi == 6) osname <<
"logicalEndPhi1" ;
1006 else osname <<
"logicalEndPhi0" ;
1010 if ( (part == 0 && phi >= 0 && phi < 16) ||
1011 (part == 1 && phi >= 0 && phi < 120) ) {
1015 std::cout <<
"No volume " << osname.str() << std::endl;
1025 std::stringstream osname;
1026 if (part == 1 && theta >= 0 && theta < 44) {
1028 osname <<
"logicalBSCCasing" << theta;
1031 else if ( part != 1 && theta >= 0 && theta < 35 &&
1034 osname <<
"logicalEndCasing_" << phi <<
"_" << theta;
1038 std::cout <<
"No volume " << osname.str() << std::endl;
1048 std::stringstream osname;
1049 if (part == 1 && theta >= 0 && theta < 44) {
1051 osname <<
"logicalCrystal";
1054 else if ( part == 0 && theta >= 0 && theta < 35 &&
1057 osname <<
"logicalEndCrystal_" << phi <<
"_" << theta;
1061 std::cout <<
"No volume " << osname.str() << std::endl;
1070 std::stringstream osname;
1072 if (part == 1) osname <<
"pv_logicalBSCWorld_2";
1073 if (part == 0) osname <<
"pv_logicalEndWorld_1";
1074 if (part == 2) osname <<
"pv_logicalEndWorld_0";
1076 return GetNode( osname.str() );
1079 if (m_NodePart[part] != 0) {
1080 return m_NodePart[part];
1083 std::cout <<
"Node: " <<
"Part" << part <<
" not found" << std::endl;
1095 int endphilist[16]= {15,7,14,6,13,12,11,10,9,8,5,4,3,2,1,0};
1096 int endphipos[16] = {15,14,13,12,11,10,3,1,9,8,7,6,5,4,2,0};
1099 if (phi==15||phi==7) realphi = 2;
1100 if (phi==14||phi==6) realphi = 1;
1102 std::stringstream osname;
1104 if (part == 1) osname <<
"pv_logicalBSCPhi" <<
"_" << 308-phi;
1105 else osname <<
"pv_logicalEndPhi"<<realphi<<
"_" <<endphipos[phi];
1106 return GetNode( osname.str() );
1109 if (m_NodePhi[part][phi] != 0) {
1110 return m_NodePhi[part][phi];
1113 std::cout <<
"Node: " <<
"Part" << part <<
"Phi" << phi <<
" not found" << std::endl;
1124 if (m_NodeTheta[part][phi][theta] != 0) {
1125 return m_NodeTheta[part][phi][theta];
1128 std::cout <<
"Node: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
1136 if (m_NodeTheta2[part][phi][theta] != 0) {
1137 return m_NodeTheta2[part][phi][theta];
1148 return GetTheta(part, phi, theta)->GetDaughter(0);
1155 if (
GetTheta2(part, phi, theta) == 0)
return 0;
1156 else return GetTheta2(part, phi, theta)->GetDaughter(0);
1162 if (m_PhysicalCrystal[part][phi][theta] != 0) {
1163 return m_PhysicalCrystal[part][phi][theta];
1166 std::cout <<
"PhysicalNode: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
1174 return m_PhysicalCrystal2[part][phi][theta];
1180 if (part == 1)
return false;
1188 if ((sector>=0)&&(sector<3))
1190 if ((sector!=7)&&(sector!=15))
1192 if ((nb>=0)&&(nb<4))
1195 CryNumberPhi = (sector-3)*4+nb;
1197 else if ((nb>=4)&&(nb<8))
1200 CryNumberPhi = (sector-3)*4+nb-4;
1202 else if ((nb>=8)&&(nb<13))
1205 CryNumberPhi = (sector-3)*5+nb-8;
1207 else if ((nb>=13)&&(nb<18))
1210 CryNumberPhi = (sector-3)*5+nb-13;
1212 else if ((nb>=18)&&(nb<24))
1215 CryNumberPhi = (sector-3)*6+nb-18;
1217 else if ((nb>=24)&&(nb<30))
1220 CryNumberPhi = (sector-3)*6+nb-24;
1225 if ((nb>=0)&&(nb<4))
1228 CryNumberPhi = (sector-3)*4+3-nb;
1230 else if ((nb>=4)&&(nb<8))
1233 CryNumberPhi = (sector-3)*4+7-nb;
1235 else if ((nb>=8)&&(nb<13))
1238 CryNumberPhi = (sector-3)*5+12-nb;
1240 else if ((nb>=13)&&(nb<18))
1243 CryNumberPhi = (sector-3)*5+17-nb;
1245 else if ((nb>=18)&&(nb<24))
1248 CryNumberPhi = (sector-3)*6+23-nb;
1250 else if ((nb>=24)&&(nb<30))
1253 CryNumberPhi = (sector-3)*6+29-nb;
1259 switch (CryNumberTheta)
1262 if (CryNumberPhi<32)
1263 CryNumberPhi = 31-CryNumberPhi;
1265 CryNumberPhi = 95-CryNumberPhi;
1268 if (CryNumberPhi<32)
1269 CryNumberPhi = 31-CryNumberPhi;
1271 CryNumberPhi = 95-CryNumberPhi;
1274 if (CryNumberPhi<40)
1275 CryNumberPhi = 39-CryNumberPhi;
1277 CryNumberPhi = 119-CryNumberPhi;
1280 if (CryNumberPhi<40)
1281 CryNumberPhi = 39-CryNumberPhi;
1283 CryNumberPhi = 119-CryNumberPhi;
1286 if (CryNumberPhi<48)
1287 CryNumberPhi = 47-CryNumberPhi;
1289 CryNumberPhi = 143-CryNumberPhi;
1292 if (CryNumberPhi<48)
1293 CryNumberPhi = 47-CryNumberPhi;
1295 CryNumberPhi = 143-CryNumberPhi;
1331 if (m_Emc2DCrystal[part][phi][theta])
return m_Emc2DCrystal[part][phi][theta];
1338 for (
int part = 0; part <
GetPartNb(); part++) {
1339 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
1340 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
1353 cout <<
"EmcROOTGeo::GetPart, this crystal physical node does not exist!" << endl;
1360 TString opt = option;
1363 if (!
m_2DGeoInit) cout <<
"EmcROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
1365 if (!view) cout <<
"EmcROOTGeo::Draw(), BesView not found" << endl;
1372 for (Int_t part =
GetPartNb()-1; part >= 0; part--) {
1373 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
1374 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
1376 if (m_Emc2DCrystal[part][phi][theta]) {
1378 m_Emc2DCrystal[part][phi][theta]->
SetFired(
false);
1382 m_Emc2DCrystal[part][phi][theta]->
Draw(crystalOpt);
1395 if (!view) cout <<
"EmcROOTGeo::DrawHits(), BesView not found" << endl;
1408 if (aCrystal && aCrystal->
GetCharge() > 5)
1464void EmcROOTGeo::Align(TGeoPhysicalNode *phyNode, TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check)
1468 if (!newmat && !newshape)
return;
1469 TGeoNode *node = phyNode->GetNode();
1471 Int_t fLevel=phyNode->GetLevel();
1472 TGeoNode *nnode = 0;
1473 TGeoVolume *vm = phyNode->GetVolume(fLevel-2);
1477 TGeoNode *nodeArray[30];
1478 TString orgName = phyNode->GetName();
1480 if (!phyNode->IsAligned()) {
1481 for (i=0; i<=fLevel-2; i++) {
1482 nodeArray[i] = phyNode->GetNode(i);
1488 for (i=fLevel-2; i<fLevel; i++) {
1490 node = phyNode->GetNode(i+1);
1491 id = vm->GetIndex(node);
1498 vd = node->GetVolume()->CloneVolume();
1499 nnode = node->MakeCopyNode();
1501 nnode->SetName(node->GetName());
1502 nnode->SetVolume(vd);
1503 nnode->SetMotherVolume(vm);
1505 vm->GetNodes()->RemoveAt(
id);
1506 vm->GetNodes()->AddAt(nnode,
id);
1507 nodeArray[i+1] = nnode;
1511 nnode = phyNode->GetNode();
1515 for (Int_t j = 0; j < phyNode->GetLevel()+1; j++) {
1517 name += nodeArray[j]->GetName();
1520 phyNode->SetName(name);
1524 TGeoNodeMatrix *aligned = (TGeoNodeMatrix*)nnode;
1525 vm = nnode->GetMotherVolume();
1526 vd = nnode->GetVolume();
1529 if (!newmat->IsRegistered()) newmat->RegisterYourself();
1530 aligned->SetMatrix(newmat);
1532 TGeoHMatrix *global = phyNode->GetMatrix();
1533 TGeoHMatrix *up = phyNode->GetMatrix(fLevel-1);
1535 global->Multiply(newmat);
1538 if (newshape) vd->SetShape(newshape);
1540 vm->SetVoxelFinder(0);
1541 vm->Voxelize(
"ALL");
1544 if (check) vm->CheckOverlaps();
1550 Align(phyNode, node->GetMatrix(), node->GetVolume()->GetShape());
R__EXTERN BesEvent * gEvent
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
const TObjArray * GetEmcDigiCol() const
Bool_t GetVisEmcHitsBarrel()
Bool_t GetVisEmcHitsGlobal()
Bool_t GetVisEmcHitsWest()
Bool_t GetVisEmcHitsEast()
virtual void SetFired(bool status=true)
virtual void SetTime(Double_t time)
virtual void Draw(Option_t *option="")
virtual void AddInfo(TString info)
virtual void SetCharge(Double_t charge)
virtual Double_t GetCharge()
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
TGeoVolume * GetVolumeCrystal(int part, int phi, int theta)
Get crystal volume;.
int ComputeEndCopyNb(int num)
Compute copyNb, copyNb 5,6,14,15,16 corresponding to two volume.
void SetVisEmcDetector()
Set Emc detector visibility;.
TGeoNode * GetCrystal(int part, int phi, int theta)
Get crystal one;.
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;.
void SetVisEmcHits()
Set Emc hits visibility;.
void SetPhysicalDefaultVis()
Set default physical node attributes;.
TGeoVolume * GetVolumePart(int part)
Get part volume;.
TGeoNode * GetCrystal2(int part, int phi, int theta)
Get crystal2 one;.
void Align(TGeoPhysicalNode *phyNode, TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE)
Align a physical node, change its position and shape.
void ComputeThetaPhi(int id, int sector, int nb, int &CryNumberTheta, int &CryNumberPhi)
Compute theta, phi from sector, nb.
TGeoNode * GetPart(int part)
Get part node;.
Emc2DCrystal * Get2DCrystal(Int_t part, Int_t phi, Int_t theta)
Get Emc2DCrystal;.
TGeoPhysicalNode * GetPhysicalCrystal2(int part, int phi, int theta)
Get crystal physical node2; EC nb 5,6,14,15,16 in any sector has two physicalNode.
void SetHalfVisible()
Set half visible;.
void Draw(Option_t *option)
Draw function.
int GetPhiNb(int part)
Get number of phi on part;.
void InitFromROOT(TGeoVolume *vol)
Initialize ROOTGeo from TGeoVolume logicalEmc.
void SetAllVisible()
Set all visible;.
TGeoVolume * GetVolumePhi(int part, int phi)
Get phi volume;
void InitFromGDML(const char *gdmlFile, const char *setupName)
Initialize ROOTGeo from GDML.
void SetNoEndVisible()
Set noend visible;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
void SetVolumeAppendInVis()
Set default visual attributes;.
void SetNode()
Set the pointers to theirs nodes;.
int GetThetaNb(int part)
Get number of theta on part;.
bool HasTwoNodes(int part, int phi, int theta)
Whether this id is combined of two nodes.
TGeoNode * GetPhi(int part, int phi)
Get phi node;.
void RestorePhyNode(TGeoPhysicalNode *phyNode, TGeoNode *node)
Restore the physical node to original shape.
void DrawHits(Option_t *option)
Draw 2D hits.
TGeoPhysicalNode * GetPhysicalCrystal(int part, int phi, int theta)
Get crystal physical node;.
TGeoNode * GetTheta2(int part, int phi, int theta)
Get theta2 node;.
void SetDetector()
Set Detecor (what is detector depends on you)
void Init2DGeometry()
Initialize 2D Geometry.
void SetVolumeEmc(TGeoVolume *vol)
Set Emc volume, while initializing from ROOT;.
void SetVolumeDefaultVis()
Set default visual attributes;.
void SetQuarterVisible()
Set quater visible;.
void SetHits()
Set all physicalNodes corresponding to digiCol;.
static double EmcTime(int timeChannel)
static double EmcCharge(int measure, int chargeChannel)
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.
TObjArray * m_DetectorsArray
TObjArray * m_2DHitsArray
UInt_t getMeasure() const
UInt_t getChargeChannel() const
UInt_t getTimeChannel() const