23#include <TGeoManager.h>
44 for (
int part = 0; part < m_kPart; part++) {
45 for (
int phi = 0; phi < m_kPhiBr; phi++) {
46 m_NodePhi[part][phi] = 0;
47 for (
int theta = 0; theta < m_kThetaBr; theta++) {
48 m_NodeTheta[part][phi][theta] = 0;
49 m_NodeTheta2[part][phi][theta] = 0;
50 m_PhysicalCrystal[part][phi][theta] = 0;
51 m_PhysicalCrystal2[part][phi][theta] = 0;
52 m_Emc2DCrystal[part][phi][theta] = 0;
56 m_PhyNodeOrgArray =
new TObjArray();
62 m_brCrystalColor = 861;
63 m_ecCrystalColor = 866;
69 cout <<
"delete old EmcROOTGeo" << endl;
70 for (
int part = 0; part <
GetPartNb(); part++)
72 for (
int theta = 0; theta <
GetThetaNb(part); theta++)
74 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++)
76 delete m_Emc2DCrystal[part][phi][theta];
80 delete m_PhyNodeOrgArray;
105 cout <<
"EmcROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
110 Double_t local[3] = {0.0, 0.0, 0.0};
111 Double_t master[3] = {0.0, 0.0, 0.0};
119 for (
int part = 0; part <
GetPartNb(); part++) {
120 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
121 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
122 TGeoPhysicalNode *phyNode = 0;
124 if (part == 1) name = TString(
"Barrel");
126 if (part == 0) name = TString(
"EastEc");
127 else if (part == 2) name = TString(
"WestEc");
129 name = TString(
"Emc Part");
132 if (part == 1) name += m_kThetaBr - 1 - theta;
138 sprintf(data,
"Emc part %i, #theta %i, #phi %i", part, theta, phi);
139 title = TString( data );
141 TGeoArb8 *crystalShape = (TGeoArb8*)phyNode->GetShape();
142 Double_t *localArb8Point, masterArb8Point[24*2];
143 localArb8Point = crystalShape->GetVertices();
144 for (Int_t i = 0; i < 8; i++) {
145 local[0] = localArb8Point[2*i];
146 local[1] = localArb8Point[2*i+1];
147 if (i < 4) local[2] = crystalShape->GetDz() * (-1.0);
148 else local[2] = crystalShape->GetDz();
150 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
152 for (Int_t j = 0; j < 3; j++) {
153 masterArb8Point[3*i+j] = master[j];
157 TGeoPhysicalNode *phyNode2 = 0;
160 crystalShape = (TGeoArb8*)phyNode2->GetShape();
161 localArb8Point = crystalShape->GetVertices();
162 for (Int_t i = 0; i < 8; i++) {
163 local[0] = localArb8Point[2*i];
164 local[1] = localArb8Point[2*i+1];
165 if (i < 4) local[2] = crystalShape->GetDz() * (-1.0);
166 else local[2] = crystalShape->GetDz();
167 phyNode2->GetMatrix(-1*phyNode->GetLevel())
168 ->LocalToMaster(local, &master[0]);
169 for (Int_t j = 0; j < 3; j++) {
170 masterArb8Point[24+3*i+j] = master[j];
176 m_Emc2DCrystal[part][phi][theta] =
179 m_Emc2DCrystal[part][phi][theta] =
193 if (!m_Emc) std::cout <<
"m_Emc = 0" << std::endl;
198 for (
int part = 0; part < m_kPart; part++) {
200 if (part == 1) ipart = 2;
201 if (part == 0) ipart = 1;
203 m_NodePart[part] = m_Emc->GetNode(ipart);
206 for (
int phi = 0; phi < m_kPhiBr; phi++) {
210 m_NodePhi[part][phi] =
GetPart(part)->GetVolume()->GetNode(iphi);
214 int endphilist[16]= {15,7,14,6,13,12,11,10,9,8,5,4,3,2,1,0};
215 int endphipos[16] = {15,14,13,12,11,10,3,1,9,8,7,6,5,4,2,0};
217 for (
int sector = 0; sector < m_kSectorEc; sector++) {
218 m_NodePhi[part][sector] =
219 GetPart(part)->GetVolume()->GetNode(endphipos[sector]);
226 for (
int phi = 0; phi < m_kPhiBr; phi++) {
228 for (
int idaughter = 0; idaughter<
GetPhi(1, phi)->GetNdaughters(); idaughter++) {
229 TString name =
GetPhi(1, phi)->GetDaughter(idaughter)->GetName();
230 if (name.Contains(
"logicalBSCCasing")){
232 m_NodeTheta[1][phi][theta] =
GetPhi(1, phi)->GetDaughter(idaughter);
238 for (
int part = 0; part < m_kPart; part++) {
239 if (part == 1)
continue;
240 for (
int sector = 0; sector < m_kSectorEc; sector++) {
241 for (
int nb = 0; nb < m_kNbEc; nb++) {
243 if (nb < m_kRealNbEc) {
245 m_NodeTheta[part][phi][theta] =
GetPhi(part, sector)->GetDaughter(nb);
252 m_NodeTheta2[part][phi][theta] =
GetPhi(part, sector)->GetDaughter(nb);
271 TGeoVolume *logicRear,*logicOrgGlass,*logicRearCasing,*logicAlPlate,*logicPD,*logicPreAmpBox,*logicAirInPABox,*logicHangingPlate,*logicWaterPipe;
272 TGeoVolume *logicCable,*logicOCGirder,*logicSupportBar,*logicSupportBar1,*logicEndRing,*logicGear,*logicTaperRing1,*logicTaperRing2,*logicTaperRing3;
285 for (
int i = 0; i < 44; i++){
287 std::ostringstream osnameBSCCable1;
288 osnameBSCCable1 <<
"logicalBSCCable_1_"<<i;
291 logicCable->SetVisibility(0);
293 std::ostringstream osnameBSCCable2;
294 osnameBSCCable2 <<
"logicalBSCCable_2_"<<i;
297 logicCable->SetVisibility(0);
299 std::ostringstream osnameOCGirder1;
300 osnameOCGirder1 <<
"logicalOpenningCutGirder_1_"<<i;
303 logicOCGirder->SetVisibility(0);
305 std::ostringstream osnameOCGirder2;
306 osnameOCGirder2 <<
"logicalOpenningCutGirder_2_"<<i;
309 logicOCGirder->SetVisibility(0);
311 std::ostringstream osnameOCGirder3;
312 osnameOCGirder3 <<
"logicalOpenningCutGirder_3_"<<i;
315 logicOCGirder->SetVisibility(0);
317 std::ostringstream osnameOCGirder4;
318 osnameOCGirder4 <<
"logicalOpenningCutGirder_4_"<<i;
321 logicOCGirder->SetVisibility(0);
335 logicRear->SetVisibility(0);
337 logicOrgGlass->SetVisibility(0);
339 logicRearCasing->SetVisibility(0);
341 logicAlPlate->SetVisibility(0);
343 logicPD->SetVisibility(0);
345 logicPreAmpBox->SetVisibility(0);
347 logicAirInPABox->SetVisibility(0);
348 if (logicHangingPlate)
349 logicHangingPlate->SetVisibility(0);
351 logicWaterPipe->SetVisibility(0);
353 logicGear->SetVisibility(0);
355 logicTaperRing1->SetVisibility(0);
357 logicTaperRing2->SetVisibility(0);
359 logicTaperRing3->SetVisibility(0);
361 logicSupportBar->SetVisibility(0);
362 if (logicSupportBar1)
363 logicSupportBar1->SetVisibility(0);
365 logicEndRing->SetVisibility(0);
376 m_Emc->SetLineColor(m_EmcColor);
377 m_Emc->SetVisibility(0);
379 for (
int part = 0; part < m_kPart-1; part++) {
381 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
382 for (
int phi = 0; phi <
nPhi; phi++) {
387 for (
int theta = 0; theta < m_kThetaBr; theta++) {
394 else if (part == 0) {
395 int iPhi[3] = {0,1,2};
396 for (
int i = 0; i < 3; i++) {
398 int nTheta = (part == 1 ? m_kThetaBr : m_kNbEc);
399 for (
int theta = 0; theta < nTheta; theta++) {
410 for (
int part = 0; part < m_kPart; part++) {
411 GetPart(part)->SetVisibility(0);
412 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
413 for (
int phi = 0; phi <
nPhi; phi++) {
414 GetPhi(part, phi)->SetVisibility(0);
419 for (
int part = 0; part < m_kPart; part++) {
420 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
421 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
423 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
424 if (nodeTheta) nodeTheta->SetVisibility(0);
425 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
426 if (nodeCrystal) nodeCrystal->SetVisibility(0);
428 TGeoNode *nodeTheta2 =
GetTheta2(part, phi, theta);
429 if (nodeTheta2) nodeTheta2->SetVisibility(0);
430 TGeoNode *nodeCrystal2 =
GetCrystal2(part, phi, theta);
431 if (nodeCrystal2) nodeCrystal2->SetVisibility(0);
447 m_Emc->SetLineColor(m_EmcColor);
448 m_Emc->SetVisibility(0);
450 for (
int part = 0; part < m_kPart-1; part++) {
452 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
453 for (
int phi = 0; phi <
nPhi; phi++) {
458 for (
int theta = 0; theta < m_kThetaBr; theta++) {
465 else if (part == 0) {
466 int iPhi[3] = {0,1,2};
467 for (
int i = 0; i < 3; i++) {
469 int nTheta = (part == 1 ? m_kThetaBr : m_kNbEc);
470 for (
int theta = 0; theta < nTheta; theta++) {
481 for (
int part = 0; part < m_kPart; part++) {
482 GetPart(part)->SetVisibility(1);
483 int nPhi = (part == 1 ? m_kPhiBr : m_kSectorEc);
484 for (
int phi = 0; phi <
nPhi; phi++) {
485 GetPhi(part, phi)->SetVisibility(1);
490 for (
int part = 0; part < m_kPart; part++) {
491 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
492 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
494 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
495 if (nodeTheta) nodeTheta->SetVisibility(1);
496 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
497 if (nodeCrystal) nodeCrystal->SetVisibility(1);
499 TGeoNode *nodeTheta2 =
GetTheta2(part, phi, theta);
500 if (nodeTheta2) nodeTheta2->SetVisibility(1);
501 TGeoNode *nodeCrystal2 =
GetCrystal2(part, phi, theta);
502 if (nodeCrystal2) nodeCrystal2->SetVisibility(1);
611 if (gGeoManager == 0) std::cout <<
"Create gGeoManager first" << std::endl;
612 TGeoNode *
bes = gGeoManager->GetTopNode();
613 std::cout <<
"Emc m_childNo " <<
m_childNo << std::endl;
614 TGeoNode *emc =
bes->GetDaughter(2);
618 TGeoNode *nodePart =
GetPart(part);
619 for (
int phi = 0; phi <
GetPhiNb(part, 0); phi++) {
620 TGeoNode *nodePhi =
GetPhi(part, phi);
621 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
622 TGeoNode *nodeTheta =
GetTheta(part, phi, theta);
623 TGeoNode *nodeCrystal =
GetCrystal(part, phi, theta);
624 m_PhysicalCrystal[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
625 TString(
"/") + emc->GetName() +
626 TString(
"/") + nodePart->GetName() +
627 TString(
"/") + nodePhi->GetName() +
628 TString(
"/") + nodeTheta->GetName() +
629 TString(
"/") + nodeCrystal->GetName() );
630 m_PhysicalCrystal[part][phi][theta]->SetVisibility(0);
631 m_PhysicalCrystal[part][phi][theta]->SetIsVolAtt(kFALSE);
632 m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_brCrystalColor);
638 for (part = 0; part < m_kPart; part++) {
639 if (part == 1)
continue;
641 for (
int sector = 0; sector < m_kSectorEc; sector++) {
642 TGeoNode *nodeSector =
GetPhi(part, sector);
643 for (
int nb = 0; nb < m_kNbEc; nb++) {
644 TGeoNode *nodeNb = nodeSector->GetDaughter(nb);
645 TGeoNode *nodeCrystal = nodeNb->GetDaughter(0);
648 if (nb < m_kRealNbEc) {
650 m_PhysicalCrystal[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
651 TString(
"/") + emc->GetName() +
652 TString(
"/") + nodePart->GetName() +
653 TString(
"/") + nodeSector->GetName() +
654 TString(
"/") + nodeNb->GetName() +
655 TString(
"/") + nodeCrystal->GetName() );
656 m_PhysicalCrystal[part][phi][theta]->SetVisibility(0);
657 m_PhysicalCrystal[part][phi][theta]->SetIsVolAtt(kFALSE);
658 m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_ecCrystalColor);
663 m_PhysicalCrystal2[part][phi][theta] = gGeoManager->MakePhysicalNode( TString(
"/") +
bes->GetName() +
664 TString(
"/") + emc->GetName() +
665 TString(
"/") + nodePart->GetName() +
666 TString(
"/") + nodeSector->GetName() +
667 TString(
"/") + nodeNb->GetName() +
668 TString(
"/") + nodeCrystal->GetName() );
669 m_PhysicalCrystal2[part][phi][theta]->SetVisibility(0);
670 m_PhysicalCrystal2[part][phi][theta]->SetIsVolAtt(kFALSE);
671 m_PhysicalCrystal2[part][phi][theta]->SetLineColor(m_ecCrystalColor);
685 for (
int part = 0; part < m_kPart; part++)
687 for (
int theta = 0; theta <
GetThetaNb(part); theta++)
689 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++)
697 phyCrystal->SetIsVolAtt(kFALSE);
698 phyCrystal->SetLineColor(m_brCrystalColor);
705 phyCrystal->SetIsVolAtt(kFALSE);
706 phyCrystal->SetLineColor(m_ecCrystalColor);
710 phyCrystal2->SetIsVolAtt(kFALSE);
711 phyCrystal2->SetLineColor(m_ecCrystalColor);
725 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
732 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
733 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
736 phyNode->SetVisibility(0);
737 if ( phi >= 0 && phi < m_kPhiBr*4/4
750 for (
int part = 0; part < m_kPart; part++) {
751 if (part == 1)
continue;
752 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
753 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
756 phyNode->SetVisibility(0);
757 if (part == 2 && phi <=
GetPhiNb(part, theta)||
758 part == 0 && phi <=
GetPhiNb(part, theta) ) {
769 phyNode->SetVisibility(0);
770 if (part == 2 && phi <=
GetPhiNb(part, theta)||
771 part == 0 && phi <=
GetPhiNb(part, theta) ) {
792 for (
int i = 0; i <
m_HitsArray->GetEntries(); i++) {
793 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)
m_HitsArray->At(i);
795 int color = m_brCrystalColor;
797 if (part == 0 || part == 2)
798 color = m_ecCrystalColor;
800 phyNode->SetLineColor(color);
801 phyNode->SetVisibility(0);
805 m_PhyNodeOrgArray->Clear(
"C");
812 aCrystal->
AddInfo(aCrystal->GetTitle());
824 if (m_EmcDigiCol) NDigiCol = m_EmcDigiCol->GetEntries();
828 for (
int i = 0; i < NDigiCol; i++) {
839 TGeoPhysicalNode *phyNode = 0;
842 m_PhyNodeOrgArray->Add ( phyNode->GetNode() );
862 m_PhyNodeOrgArray->Add ( phyNode->GetNode() );
881 aCrystal = m_Emc2DCrystal[part][phi][theta];
887 aCrystal->
AddInfo(aCrystal->GetTitle());
890 sprintf(data,
"time = %-.3f ns, charge = %-.3f MeV", time,
charge);
891 aCrystal->
AddInfo( TString(data) );
893 aCrystal->
AddInfo( TString(data) );
906 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
910 phyNode->SetVisibility(0);
916 phyNode->SetVisibility(1);
925 if (gPad) view =
dynamic_cast<BesView*
>(gPad->GetView());
927 for (
int i = 0; i <
m_HitsArray->GetEntries(); i++) {
928 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)
m_HitsArray->At(i);
934 phyNode->SetVisibility(1);
935 phyNode->SetLineColor(881);
941 if (part == 1) phyNode->SetLineColor(m_brCrystalColor);
942 else phyNode->SetLineColor(m_ecCrystalColor);
956 if (part == 1)
return m_kThetaBr;
957 else return m_kThetaEc;
963 int phiNb = m_kPhiBr;
965 if (theta < 2) phiNb = 4*m_kSectorEc;
966 else if (theta >= 2 && theta < 4) phiNb = 5*m_kSectorEc;
967 else if (theta >= 4 && theta < m_kThetaEc) phiNb = 6*m_kSectorEc;
977 std::stringstream osname;
978 if (part != 1) osname <<
"logicalEndWorld";
979 else osname <<
"logicalBSCWorld";
982 if (part == 0 || part == 1) {
986 std::cout <<
"No volume " << osname.str() << std::endl;
995 std::stringstream osname;
997 if (part == 1) osname <<
"logicalBSCPhi" ;
999 if (phi == 15 || phi == 7) osname <<
"logicalEndPhi2" ;
1000 else if (phi == 14 || phi == 6) osname <<
"logicalEndPhi1" ;
1001 else osname <<
"logicalEndPhi0" ;
1005 if ( (part == 0 && phi >= 0 && phi < 16) ||
1006 (part == 1 && phi >= 0 && phi < 120) ) {
1010 std::cout <<
"No volume " << osname.str() << std::endl;
1020 std::stringstream osname;
1021 if (part == 1 && theta >= 0 && theta < 44) {
1023 osname <<
"logicalBSCCasing" << theta;
1026 else if ( part != 1 && theta >= 0 && theta < 35 &&
1029 osname <<
"logicalEndCasing_" << phi <<
"_" << theta;
1033 std::cout <<
"No volume " << osname.str() << std::endl;
1043 std::stringstream osname;
1044 if (part == 1 && theta >= 0 && theta < 44) {
1046 osname <<
"logicalCrystal";
1049 else if ( part == 0 && theta >= 0 && theta < 35 &&
1052 osname <<
"logicalEndCrystal_" << phi <<
"_" << theta;
1056 std::cout <<
"No volume " << osname.str() << std::endl;
1065 std::stringstream osname;
1067 if (part == 1) osname <<
"pv_logicalBSCWorld_2";
1068 if (part == 0) osname <<
"pv_logicalEndWorld_1";
1069 if (part == 2) osname <<
"pv_logicalEndWorld_0";
1071 return GetNode( osname.str() );
1074 if (m_NodePart[part] != 0) {
1075 return m_NodePart[part];
1078 std::cout <<
"Node: " <<
"Part" << part <<
" not found" << std::endl;
1090 int endphilist[16]= {15,7,14,6,13,12,11,10,9,8,5,4,3,2,1,0};
1091 int endphipos[16] = {15,14,13,12,11,10,3,1,9,8,7,6,5,4,2,0};
1094 if (phi==15||phi==7) realphi = 2;
1095 if (phi==14||phi==6) realphi = 1;
1097 std::stringstream osname;
1099 if (part == 1) osname <<
"pv_logicalBSCPhi" <<
"_" << 308-phi;
1100 else osname <<
"pv_logicalEndPhi"<<realphi<<
"_" <<endphipos[phi];
1101 return GetNode( osname.str() );
1104 if (m_NodePhi[part][phi] != 0) {
1105 return m_NodePhi[part][phi];
1108 std::cout <<
"Node: " <<
"Part" << part <<
"Phi" << phi <<
" not found" << std::endl;
1119 if (m_NodeTheta[part][phi][theta] != 0) {
1120 return m_NodeTheta[part][phi][theta];
1123 std::cout <<
"Node: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
1131 if (m_NodeTheta2[part][phi][theta] != 0) {
1132 return m_NodeTheta2[part][phi][theta];
1143 return GetTheta(part, phi, theta)->GetDaughter(0);
1150 if (
GetTheta2(part, phi, theta) == 0)
return 0;
1151 else return GetTheta2(part, phi, theta)->GetDaughter(0);
1157 if (m_PhysicalCrystal[part][phi][theta] != 0) {
1158 return m_PhysicalCrystal[part][phi][theta];
1161 std::cout <<
"PhysicalNode: " <<
"Part" << part <<
"Phi" << phi <<
"Theta" << theta <<
" not found" << std::endl;
1169 return m_PhysicalCrystal2[part][phi][theta];
1175 if (part == 1)
return false;
1183 if ((sector>=0)&&(sector<3))
1185 if ((sector!=7)&&(sector!=15))
1187 if ((nb>=0)&&(nb<4))
1190 CryNumberPhi = (sector-3)*4+nb;
1192 else if ((nb>=4)&&(nb<8))
1195 CryNumberPhi = (sector-3)*4+nb-4;
1197 else if ((nb>=8)&&(nb<13))
1200 CryNumberPhi = (sector-3)*5+nb-8;
1202 else if ((nb>=13)&&(nb<18))
1205 CryNumberPhi = (sector-3)*5+nb-13;
1207 else if ((nb>=18)&&(nb<24))
1210 CryNumberPhi = (sector-3)*6+nb-18;
1212 else if ((nb>=24)&&(nb<30))
1215 CryNumberPhi = (sector-3)*6+nb-24;
1220 if ((nb>=0)&&(nb<4))
1223 CryNumberPhi = (sector-3)*4+3-nb;
1225 else if ((nb>=4)&&(nb<8))
1228 CryNumberPhi = (sector-3)*4+7-nb;
1230 else if ((nb>=8)&&(nb<13))
1233 CryNumberPhi = (sector-3)*5+12-nb;
1235 else if ((nb>=13)&&(nb<18))
1238 CryNumberPhi = (sector-3)*5+17-nb;
1240 else if ((nb>=18)&&(nb<24))
1243 CryNumberPhi = (sector-3)*6+23-nb;
1245 else if ((nb>=24)&&(nb<30))
1248 CryNumberPhi = (sector-3)*6+29-nb;
1254 switch (CryNumberTheta)
1257 if (CryNumberPhi<32)
1258 CryNumberPhi = 31-CryNumberPhi;
1260 CryNumberPhi = 95-CryNumberPhi;
1263 if (CryNumberPhi<32)
1264 CryNumberPhi = 31-CryNumberPhi;
1266 CryNumberPhi = 95-CryNumberPhi;
1269 if (CryNumberPhi<40)
1270 CryNumberPhi = 39-CryNumberPhi;
1272 CryNumberPhi = 119-CryNumberPhi;
1275 if (CryNumberPhi<40)
1276 CryNumberPhi = 39-CryNumberPhi;
1278 CryNumberPhi = 119-CryNumberPhi;
1281 if (CryNumberPhi<48)
1282 CryNumberPhi = 47-CryNumberPhi;
1284 CryNumberPhi = 143-CryNumberPhi;
1287 if (CryNumberPhi<48)
1288 CryNumberPhi = 47-CryNumberPhi;
1290 CryNumberPhi = 143-CryNumberPhi;
1326 if (m_Emc2DCrystal[part][phi][theta])
return m_Emc2DCrystal[part][phi][theta];
1333 for (
int part = 0; part <
GetPartNb(); part++) {
1334 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
1335 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
1348 cout <<
"EmcROOTGeo::GetPart, this crystal physical node does not exist!" << endl;
1355 TString opt = option;
1358 if (!
m_2DGeoInit) cout <<
"EmcROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
1360 if (!view) cout <<
"EmcROOTGeo::Draw(), BesView not found" << endl;
1367 for (Int_t part =
GetPartNb()-1; part >= 0; part--) {
1368 for (
int theta = 0; theta <
GetThetaNb(part); theta++) {
1369 for (
int phi = 0; phi <
GetPhiNb(part, theta); phi++) {
1371 if (m_Emc2DCrystal[part][phi][theta]) {
1373 m_Emc2DCrystal[part][phi][theta]->
SetFired(
false);
1377 m_Emc2DCrystal[part][phi][theta]->
Draw(crystalOpt);
1390 if (!view) cout <<
"EmcROOTGeo::DrawHits(), BesView not found" << endl;
1403 if (aCrystal && aCrystal->
GetCharge() > 5)
1459void EmcROOTGeo::Align(TGeoPhysicalNode *phyNode, TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check)
1463 if (!newmat && !newshape)
return;
1464 TGeoNode *node = phyNode->GetNode();
1466 Int_t fLevel=phyNode->GetLevel();
1467 TGeoNode *nnode = 0;
1468 TGeoVolume *vm = phyNode->GetVolume(fLevel-2);
1472 TGeoNode *nodeArray[30];
1473 TString orgName = phyNode->GetName();
1475 if (!phyNode->IsAligned()) {
1476 for (i=0; i<=fLevel-2; i++) {
1477 nodeArray[i] = phyNode->GetNode(i);
1483 for (i=fLevel-2; i<fLevel; i++) {
1485 node = phyNode->GetNode(i+1);
1486 id = vm->GetIndex(node);
1493 vd = node->GetVolume()->CloneVolume();
1494 nnode = node->MakeCopyNode();
1496 nnode->SetName(node->GetName());
1497 nnode->SetVolume(vd);
1498 nnode->SetMotherVolume(vm);
1500 vm->GetNodes()->RemoveAt(
id);
1501 vm->GetNodes()->AddAt(nnode,
id);
1502 nodeArray[i+1] = nnode;
1506 nnode = phyNode->GetNode();
1510 for (Int_t j = 0; j < phyNode->GetLevel()+1; j++) {
1512 name += nodeArray[j]->GetName();
1515 phyNode->SetName(name);
1519 TGeoNodeMatrix *aligned = (TGeoNodeMatrix*)nnode;
1520 vm = nnode->GetMotherVolume();
1521 vd = nnode->GetVolume();
1524 if (!newmat->IsRegistered()) newmat->RegisterYourself();
1525 aligned->SetMatrix(newmat);
1527 TGeoHMatrix *global = phyNode->GetMatrix();
1528 TGeoHMatrix *up = phyNode->GetMatrix(fLevel-1);
1530 global->Multiply(newmat);
1533 if (newshape) vd->SetShape(newshape);
1535 vm->SetVoxelFinder(0);
1536 vm->Voxelize(
"ALL");
1539 if (check) vm->CheckOverlaps();
1545 Align(phyNode, node->GetMatrix(), node->GetVolume()->GetShape());
R__EXTERN BesEvent * gEvent
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
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)