00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 using namespace std;
00012
00013
00014 #include <string>
00015 #include <fstream>
00016 #include <iostream>
00017 #include <sstream>
00018 #include <vector>
00019 #include <iomanip>
00020
00021 #include <TGeoManager.h>
00022 #include <TGeoBoolNode.h>
00023 #include <TGeoBBox.h>
00024 #include <TGeoTube.h>
00025 #include <TGeoArb8.h>
00026 #include <TMath.h>
00027
00028 #include "BesVisLib/MucROOTGeo.h"
00029 #include "Identifier/MucID.h"
00030 #include "BesVisLib/BesEvent.h"
00031 #include "BesVisLib/BesView.h"
00032
00033 const int MucROOTGeo::m_kSeg[m_kPart] = {4, 8, 4};
00034 const int MucROOTGeo::m_kAbsorber[m_kPart] = {9, 9, 9};
00035 const int MucROOTGeo::m_kGap[m_kPart] = {8, 9, 8};
00036 const int MucROOTGeo::m_kPanel[m_kPart] = {3, 4, 3};
00037 const int MucROOTGeo::m_kBakelitePanel[m_kPart][m_kUpDown]= {3, 5, 4, 4, 3, 5};
00038
00039 MucROOTGeo::MucROOTGeo()
00040 : SubDetectorROOTGeo()
00041 {
00042
00043 for (int part = 0; part < m_kPart; part++) {
00044 for (int seg = 0; seg < m_kSegMax; seg++) {
00045 m_MucXY[part][seg] = 0;
00046 m_MucZR[part][seg] = 0;
00047
00048 for (int gap = 0; gap < m_kGapMax; gap++) {
00049 m_NodeGap[part][seg][gap] = 0;
00050 m_PhysicalGap[part][seg][gap] = 0;
00051 m_MucXYGap[part][seg][gap] = 0;
00052 m_MucZRGap[part][seg][gap] = 0;
00053
00054 for (int strip = 0; strip < m_kStripMax; strip++) {
00055 m_NodeStrip[part][seg][gap][strip] = 0;
00056 m_PhysicalStrip[part][seg][gap][strip] = 0;
00057
00058 }
00059 }
00060 for (int absorber = 0; absorber < m_kAbsorberMax; absorber++) {
00061 m_NodeAbsorber[part][seg][absorber] = 0;
00062 for (int panel = 0; panel < m_kPanelMax; panel++) {
00063 m_NodeAbsorberPanel[part][seg][absorber][panel] = 0;
00064 m_PhysicalAbsorber[part][seg][absorber][panel] = 0;
00065 }
00066 }
00067 }
00068 }
00069
00070 m_MucColor = 2;
00071 m_absorberColor = 2;
00072 m_gapColor = 16;
00073 m_gasChamberColor = 8;
00074 m_bakeliteColor = 8;
00075 m_stripColor = 2;
00076 }
00077
00078 MucROOTGeo::~MucROOTGeo()
00079 { }
00080
00081 void
00082 MucROOTGeo::InitFromGDML( const char *gdmlFile, const char *setupName )
00083 {
00084 m_ROOTGeoInit = 2;
00085
00086 ReadGdml(gdmlFile, setupName);
00087 SetNode();
00088 }
00089
00090 void
00091 MucROOTGeo::InitFromROOT( TGeoVolume *vol )
00092 {
00093 m_ROOTGeoInit = 1;
00094
00095 SetVolumeMuc(vol);
00096 SetNode();
00097 }
00098
00099 void
00100 MucROOTGeo::Init2DGeometry()
00101 {
00102 if (m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2) {
00103 cout << "MucROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
00104 return;
00105 }
00106 m_2DGeoInit = 1;
00107
00108 Int_t mucColor = 1002;
00109 Int_t mucLineColor = 15;
00110 Int_t mucXYStyle = 1001;
00111 Int_t mucZRStyle = 1001;
00112
00113 Int_t mucGapColor = 10;
00114 Int_t mucGapStyle = 1001;
00115 Int_t mucGapXYECStyle = 4000;
00116 Int_t mucGapLineColor = 15;
00117
00118 Double_t x = 0.0, y = 0.0, z = 0.0;
00119 Double_t r = 0.0, phi = 0.0;
00120 Double_t local[3] = {0.0, 0.0, 0.0};
00121 Double_t master[3] = {0.0, 0.0, 0.0};
00122
00123 Double_t P[300] = {0.0};
00124
00125 TString name;
00126
00127 Int_t part = 0, seg = 0, gap = 0, strip = 0;
00128
00129
00130
00131 TGeoCompositeShape *mucShape = (TGeoCompositeShape*)GetVolumeMuc()->GetShape();
00132 if (mucShape) ;
00133
00134 TGeoBoolNode *mucBoolNode = mucShape->GetBoolNode();
00135 TGeoBBox *mucOuterShape = (TGeoBBox*)mucBoolNode->GetLeftShape();
00136 TGeoTube *mucInnerShape = (TGeoTube*)mucBoolNode->GetRightShape();
00137 if (mucOuterShape) ;
00138
00139
00140
00141 Double_t mucOuterR = mucOuterShape->GetDX();
00142 Double_t mucInnerR = mucInnerShape->GetRmax() + 40.0;
00143
00144
00145
00146
00147 part = 1;
00148 Int_t xySegPointSeq[4] = {0,1,1,0};
00149 for (seg = 0; seg < GetSegNb(part); seg++) {
00150 name = TString("MucBarrelSeg");
00151 name += seg;
00152 for (Int_t iPoint = 0; iPoint < 4; iPoint++) {
00153 if (iPoint < 2) r = mucInnerR/TMath::Cos(TMath::Pi()/8.0);
00154 else r = mucOuterR/TMath::Cos(TMath::Pi()/8.0);
00155 phi = TMath::Pi()/8.0 * (2*seg-1 + 2*xySegPointSeq[iPoint]);
00156 x = r * TMath::Cos(phi);
00157 y = r * TMath::Sin(phi);
00158 z = 0.0;
00159 P[3*iPoint] = x;
00160 P[3*iPoint+1] = y;
00161 P[3*iPoint+2] = z;
00162 }
00163 m_MucXY[part][seg] = new BesPolygon2D(name, name, 4, &P[0]);
00164 m_MucXY[part][seg]->SetFillColor(mucColor);
00165 m_MucXY[part][seg]->SetFillStyle(mucXYStyle);
00166 m_MucXY[part][seg]->SetLineColor(mucLineColor);
00167 }
00168
00169
00170
00171 part = 1;
00172 for (seg = 0; seg < GetSegNb(part); seg++) {
00173 for (Int_t iPoint = 0; iPoint < 4; iPoint++) {
00174 if (iPoint == 0 || iPoint == 3 ) r = mucInnerR;
00175 else r = mucOuterR;
00176 phi = TMath::Pi()/4.0 * seg;
00177
00178 x = r * TMath::Cos(phi);
00179 y = r * TMath::Sin(phi);
00180
00181 TGeoVolume *volAbsorber = 0;
00182 volAbsorber= GetAbsorber(part, seg, 0)->GetVolume();
00183 TGeoBBox *absorberShape = (TGeoBBox*)volAbsorber->GetShape();
00184 if (seg == 2)cout<<"in MucROOTGeo::Init2DGeometry() x,y,z = "<<absorberShape->GetDX()<<" "<<absorberShape->GetDY()<<" "<<absorberShape->GetDZ()<<endl;
00185 Double_t dy = absorberShape->GetDY();
00186 z = dy;
00187 if (iPoint < 2) z = -dy;
00188
00189 P[3*iPoint] = x;
00190 P[3*iPoint+1] = y;
00191 P[3*iPoint+2] = z;
00192 }
00193
00194 if (seg == 2 || seg == 6) {
00195 if (seg == 2) name = TString("MucBarrelUpSeg");
00196 if (seg == 6) name = TString("MucBarrelDownSeg");
00197
00198 m_MucZR[part][seg] = new BesPolygon2D(name, name, 4, &P[0]);
00199 m_MucZR[part][seg]->SetFillColor(mucColor);
00200 m_MucZR[part][seg]->SetFillStyle(mucZRStyle);
00201 m_MucZR[part][seg]->SetLineColor(mucLineColor);
00202 }
00203 }
00204
00205
00206
00207 part = 1;
00208 for (seg = 0; seg < GetSegNb(part); seg++) {
00209 for (gap = 0; gap < GetGapNb(part); gap++) {
00210
00211 TGeoPhysicalNode *phyNode = 0;
00212 phyNode = GetPhysicalGap(part, seg, gap);
00213
00214 TGeoBBox *gapShape = (TGeoBBox*)phyNode->GetShape();
00215 Double_t dx = gapShape->GetDX();
00216 Double_t dy = gapShape->GetDY();
00217 Double_t dz = gapShape->GetDZ();
00218
00219
00220 for (Int_t i = 0; i < 4; i++) {
00221 local[1] = 0.0;
00222 switch (i) {
00223 case 0:
00224 local[0] = -dx;
00225 local[2] = -dz;
00226 break;
00227 case 1:
00228 local[0] = dx;
00229 local[2] = -dz;
00230 break;
00231 case 2:
00232 local[0] = dx;
00233 local[2] = dz;
00234 break;
00235 case 3:
00236 local[0] = -dx;
00237 local[2] = dz;
00238 break;
00239 }
00240 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
00241 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
00242 }
00243
00244 name = TString("MucBarrelSeg");
00245 name += seg;
00246 name += TString("Gap");
00247 name += gap;
00248
00249 m_MucXYGap[part][seg][gap] = new BesPolygon2D(name, name, 4, &P[0]);
00250 m_MucXYGap[part][seg][gap]->SetFillColor(mucGapColor);
00251 m_MucXYGap[part][seg][gap]->SetFillStyle(mucGapStyle);
00252 m_MucXYGap[part][seg][gap]->SetLineColor(mucGapLineColor);
00253
00254
00255 for (Int_t i = 0; i < 4; i++) {
00256 local[0] = 0.0;
00257 switch (i) {
00258 case 0:
00259 local[1] = -dy;
00260 local[2] = -dz;
00261 break;
00262 case 1:
00263 local[1] = -dy;
00264 local[2] = dz;
00265 break;
00266 case 2:
00267 local[1] = dy;
00268 local[2] = dz;
00269 break;
00270 case 3:
00271 local[1] = dy;
00272 local[2] = -dz;
00273 break;
00274 }
00275 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
00276 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
00277 }
00278
00279 if (seg == 2 || seg == 6) {
00280 if (seg == 2) {
00281 name = TString("MucBarrelUpSegGap");
00282 name += gap;
00283 }
00284 else if (seg == 6) {
00285 name = TString("MucBarrelDownSegGap");
00286 name += gap;
00287 }
00288
00289 m_MucZRGap[part][seg][gap] = new BesPolygon2D(name, name, 4, &P[0]);
00290 m_MucZRGap[part][seg][gap]->SetFillColor(mucGapColor);
00291 m_MucZRGap[part][seg][gap]->SetFillStyle(mucGapStyle);
00292 m_MucZRGap[part][seg][gap]->SetLineColor(mucGapLineColor);
00293 }
00294 }
00295 }
00296
00297 for (part = 0; part < GetPartNb(); part++) {
00298 if (part == 1) continue;
00299 for (seg = 0; seg < GetSegNb(part); seg++) {
00300 Double_t segP[100];
00301 Int_t iSegPoint = 0;
00302
00303 for (gap = 0; gap < GetGapNb(part); gap++) {
00304 TGeoPhysicalNode *phyNode = 0;
00305 phyNode = GetPhysicalGap(part, seg, gap);
00306
00307 Int_t ixyPoint = 0, izrPoint = 0;
00308 Int_t nPanel = 3;
00309
00310
00311 TGeoCompositeShape *addPanelShape[4];
00312 TGeoTrap *panelShape[4];
00313
00314
00315 for (Int_t panel = nPanel-1; panel >= 0; panel--) {
00316 if (panel == nPanel-1) addPanelShape[panel] = (TGeoCompositeShape*)GetGap(part, seg, gap)->GetVolume()->GetShape();
00317 else addPanelShape[panel] = (TGeoCompositeShape*)addPanelShape[panel+1]->GetBoolNode()->GetLeftShape();
00318
00319 panelShape[panel] = (TGeoTrap*)addPanelShape[panel]->GetBoolNode()->GetRightShape();
00320
00321 Double_t *localArb8Point, masterArb8Point[3*8];
00322 localArb8Point = panelShape[panel]->GetVertices();
00323 for (Int_t i = 0; i < 8; i++) {
00324 local[0] = localArb8Point[2*i];
00325 local[1] = localArb8Point[2*i+1];
00326 if (i < 4) local[2] = panelShape[panel]->GetDz() * (-1.0);
00327 else local[2] = panelShape[panel]->GetDz();
00328
00329 addPanelShape[panel]->GetBoolNode()->GetRightMatrix()->LocalToMaster(local, &master[0]);
00330
00331 for (Int_t j = 0; j < 3; j++) local[j] = master[j];
00332 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
00333 for (Int_t j = 0; j < 3; j++) {
00334 masterArb8Point[3*i+j] = master[j];
00335 }
00336 }
00337
00338
00339 if (panel == 2) {
00340 Int_t xyPanelPointSeq[4] = {0, 3, 7, 4};
00341 for (Int_t i = 0; i < 4; i++) {
00342 for (Int_t j = 0; j < 3; j++) {
00343 P[3*ixyPoint+j] = masterArb8Point[3*xyPanelPointSeq[i]+j];
00344 }
00345 ixyPoint++;
00346 }
00347 }
00348 if (panel == 0) {
00349 Int_t xyPanelPointSeq[4] = {7, 4, 0, 3};
00350 for (Int_t i = 0; i < 4; i++) {
00351 for (Int_t j = 0; j < 3; j++) {
00352 P[3*ixyPoint+j] = masterArb8Point[3*xyPanelPointSeq[i]+j];
00353 }
00354 ixyPoint++;
00355 }
00356 }
00357
00358
00359 if (panel == 2) {
00360 Int_t zrPanelPointSeq[4] = {4, 7, 6, 5};
00361 for (Int_t i = 0; i < 4; i++) {
00362 for (Int_t j = 0; j < 3; j++) {
00363 P[100+3*izrPoint+j] = masterArb8Point[3*zrPanelPointSeq[i]+j];
00364 }
00365 izrPoint++;
00366 }
00367 }
00368 if (panel == 0) {
00369 Int_t zrPanelPointSeq[4] = {6, 5, 4, 7};
00370 for (Int_t i = 0; i < 4; i++) {
00371 for (Int_t j = 0; j < 3; j++) {
00372 P[100+3*izrPoint+j] = masterArb8Point[3*zrPanelPointSeq[i]+j];
00373 }
00374 izrPoint++;
00375 }
00376 }
00377 }
00378
00379 if (part == 0) name = TString("MucEastEc");
00380 else if (part == 2) name = TString("MucWestEc");
00381 name += TString("Seg");
00382 name += seg;
00383 name += TString("Gap");
00384 name += gap;
00385
00386
00387 m_MucXYGap[part][seg][gap] = new BesPolygon2D(name, name, ixyPoint, &P[0]);
00388 m_MucXYGap[part][seg][gap]->SetFillColor(mucGapColor);
00389 m_MucXYGap[part][seg][gap]->SetFillStyle(mucGapXYECStyle);
00390 m_MucXYGap[part][seg][gap]->SetLineColor(mucGapLineColor);
00391
00392 m_MucZRGap[part][seg][gap] = new BesPolygon2D(name, name, izrPoint, &P[100]);
00393 m_MucZRGap[part][seg][gap]->SetFillColor(mucGapColor);
00394 m_MucZRGap[part][seg][gap]->SetFillStyle(mucGapStyle);
00395 m_MucZRGap[part][seg][gap]->SetLineColor(mucGapLineColor);
00396
00397
00398
00399 if (gap == 0) {
00400 Double_t zrFirstAbsorberHeight = ((TGeoBBox*)GetAbsorber(part, seg, 0)->GetVolume()->GetShape())->GetDZ()*2.0;
00401 for (Int_t i = 0; i < 4; i++) {
00402 for (Int_t j = 0; j < 3; j++) {
00403 if ( (part == 0 && (seg == 0 || seg == 2)) || (part == 2 && (seg == 1 || seg == 3)) ) {
00404 Int_t zrSegPointSeq[4] = {6, 7, 0, 1};
00405 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
00406 }
00407 else {
00408 Int_t zrSegPointSeq[4] = {5, 4, 3, 2};
00409 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
00410 }
00411
00412 if (j == 2) {
00413 if (part == 0) segP[3*iSegPoint+j] -= zrFirstAbsorberHeight;
00414 else if (part == 2) segP[3*iSegPoint+j] += zrFirstAbsorberHeight;
00415 }
00416 }
00417 iSegPoint++;
00418 }
00419 }
00420 else if (gap == 7) {
00421 Double_t zrLastAbsorberHeight = ((TGeoBBox*)GetAbsorber(part, seg, 8)->GetVolume()->GetShape())->GetDZ()*2.0;
00422 for (Int_t i = 0; i < 4; i++) {
00423 for (Int_t j = 0; j < 3; j++) {
00424 if ( (part == 0 && (seg == 0 || seg == 2)) || (part == 2 && (seg == 1 || seg == 3)) ){
00425 Int_t zrSegPointSeq[4] = {2, 3, 4, 5};
00426 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
00427 }
00428 else {
00429 Int_t zrSegPointSeq[4] = {1, 0, 7, 6};
00430 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
00431 }
00432
00433 if (j == 2) {
00434 if (part == 0) segP[3*iSegPoint+j] += zrLastAbsorberHeight;
00435 else if (part == 2) segP[3*iSegPoint+j] -= zrLastAbsorberHeight;
00436 }
00437 }
00438 iSegPoint++;
00439 }
00440 }
00441
00442 }
00443 if (part == 0) name = TString("MucEastEc");
00444 else if (part == 2) name = TString("MucWestEc");
00445 name += TString("Seg");
00446 name += seg;
00447 m_MucZR[part][seg] = new BesPolygon2D(name, name, iSegPoint, &segP[0]);
00448 m_MucZR[part][seg]->SetFillColor(mucColor);
00449 m_MucZR[part][seg]->SetFillStyle(mucZRStyle);
00450 m_MucZR[part][seg]->SetLineColor(mucLineColor);
00451 }
00452 }
00453
00454 for (part = 0; part < GetPartNb(); part++) {
00455 for (seg = 0; seg < GetSegNb(part); seg++) {
00456 for (gap = 0; gap < GetGapNb(part); gap++) {
00457 for (strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00458 TGeoPhysicalNode *phyNode = 0;
00459 phyNode = GetPhysicalStrip(part, seg, gap, strip);
00460 TGeoBBox *stripShape = (TGeoBBox*)phyNode->GetShape();
00461 Double_t dx = stripShape->GetDX();
00462 Double_t dy = stripShape->GetDY();
00463 Double_t dz = stripShape->GetDZ();
00464 dz *= m_kStripZMuliple;
00465
00466 for (Int_t i = 0; i < 8; i++) {
00467 switch (i) {
00468 case 0:
00469 local[0] = -dx;
00470 local[1] = -dy;
00471 local[2] = -dz;
00472 break;
00473 case 1:
00474 local[0] = dx;
00475 local[1] = -dy;
00476 local[2] = -dz;
00477 break;
00478 case 2:
00479 local[0] = dx;
00480 local[1] = dy;
00481 local[2] = -dz;
00482 break;
00483 case 3:
00484 local[0] = -dx;
00485 local[1] = dy;
00486 local[2] = -dz;
00487 break;
00488 case 4:
00489 local[0] = -dx;
00490 local[1] = -dy;
00491 local[2] = dz;
00492 break;
00493 case 5:
00494 local[0] = dx;
00495 local[1] = -dy;
00496 local[2] = dz;
00497 break;
00498 case 6:
00499 local[0] = dx;
00500 local[1] = dy;
00501 local[2] = dz;
00502 break;
00503 case 7:
00504 local[0] = -dx;
00505 local[1] = dy;
00506 local[2] = dz;
00507 break;
00508 }
00509
00510 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]);
00511 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
00512 }
00513
00514 name = TString("Muc Part");
00515 name += part;
00516 name += TString(" Seg");
00517 name += seg;
00518 name += TString(" Gap");
00519 name += gap;
00520 name += TString(" Strip");
00521 name += strip;
00522
00523 m_Muc2DStrip[part][seg][gap][strip] = new Muc2DStrip(name, name, 8, &P[0], part, seg, gap, strip);
00524 }
00525 }
00526 }
00527 }
00528 }
00529
00530 void
00531 MucROOTGeo::SetNode()
00532 {
00533 if (m_ROOTGeoInit == 2) {
00534
00535 m_Muc = GetTopVolume();
00536 if (!m_Muc) std::cout << "m_Muc = 0" << std::endl;
00537
00538 int gapCount = 0;
00539 for (int part = 0; part < GetPartNb(); part++) {
00540 for (int seg = 0; seg < GetSegNb(part); seg++) {
00541 for (int gap = 0; gap < GetGapNb(part); gap++) {
00542 m_StripNum[part][seg][gap] = GetVolumeStripPlane(part, seg, gap)->GetNdaughters();
00543
00544 std::stringstream osnameGap;
00545 osnameGap << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "_" << gapCount;
00546 m_NodeGap[part][seg][gap] = GetNode( osnameGap.str() );
00547 gapCount++;
00548
00549 int segment = 0;
00550 if (part==1&&seg==2) segment = 2;
00551 std::stringstream osnameStripPlane;
00552 osnameStripPlane << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP" << "_" << "0";
00553 m_NodeStripPlane[part][seg][gap] = GetNode( osnameStripPlane.str() );
00554 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00555 std::stringstream osnameStrip;
00556 if (strip < 10) {
00557 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "00" << strip << "_" << strip;
00558 }
00559 else if (strip < 100) {
00560 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "0" << strip << "_" << strip;
00561 }
00562 else {
00563 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << strip << "_" << strip;
00564 }
00565
00566 m_NodeStrip[part][seg][gap][strip] = GetNode( osnameStrip.str() );
00567 }
00568 }
00569 }
00570 }
00571
00572 int absorberCount = gapCount;
00573 for (int part = 0; part < GetPartNb(); part++) {
00574 for (int seg = 0; seg < GetSegNb(part); seg++) {
00575 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
00576 std::stringstream osnameAbsorber;
00577 osnameAbsorber << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber << "_" << absorberCount;
00578 m_NodeAbsorber[part][seg][absorber] = GetNode( osnameAbsorber.str() );
00579 absorberCount++;
00580
00581
00582
00583
00584
00585
00586
00587 }
00588 }
00589 }
00590 }
00591 else if (m_ROOTGeoInit == 1) {
00592 int gapCount = 0;
00593 for (int part = 0; part < GetPartNb(); part++) {
00594 for (int seg = 0; seg < GetSegNb(part); seg++) {
00595 for (int gap = 0; gap < GetGapNb(part); gap++) {
00596 m_NodeGap[part][seg][gap] = m_Muc->GetNode(gapCount);
00597 gapCount++;
00598
00599 m_NodeStripPlane[part][seg][gap] = GetGap(part, seg, gap)->GetDaughter(0)->GetDaughter(0);
00600 m_StripNum[part][seg][gap] = GetStripPlane(part, seg, gap)->GetNdaughters();
00601
00602 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00603 m_NodeStrip[part][seg][gap][strip] = GetStripPlane(part, seg, gap)->GetVolume()->GetNode(strip);
00604 }
00605 }
00606 }
00607 }
00608
00609 int absorberCount = gapCount;
00610 for (int part = 0; part < GetPartNb(); part++) {
00611 for (int seg = 0; seg < GetSegNb(part); seg++) {
00612 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
00613 m_NodeAbsorber[part][seg][absorber] = m_Muc->GetNode( absorberCount );
00614 absorberCount++;
00615
00616
00617
00618
00619
00620
00621 }
00622 }
00623 }
00624 }
00625
00626 }
00627
00628 void
00629 MucROOTGeo::SetVolumeDefaultVis()
00630 {
00631 m_Muc->SetLineColor(m_MucColor);
00632 m_Muc->SetVisibility(0);
00633
00634 for (int part = 0; part < GetPartNb(); part++) {
00635 for (int seg = 0; seg < GetSegNb(part); seg++) {
00636 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
00637 GetVolumeAbsorber(part, seg, absorber)->SetLineColor(m_absorberColor);
00638 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
00639
00640
00641
00642
00643
00644
00645 }
00646
00647 for (int gap = 0; gap < GetGapNb(part); gap++) {
00648 GetVolumeGap(part, seg, gap)->SetLineColor(m_gapColor);
00649 GetVolumeGap(part, seg, gap)->SetVisibility(0);
00650
00651 GetVolumeBox(part, seg, gap)->SetLineColor(m_gapColor);
00652 GetVolumeBox(part, seg, gap)->SetVisibility(0);
00653
00654 if (part == 1){
00655 for (int sb = 0; sb < m_kSmallBlockMax; sb++){
00656 GetVolumeAbsorberSmallBlock( gap, sb)->SetLineColor(m_absorberColor);
00657 GetVolumeAbsorberSmallBlock( gap, sb)->SetVisibility(0);
00658 }
00659 }
00660
00661 GetVolumeStripPlane(part, seg, gap)->SetLineColor(m_gapColor);
00662 GetVolumeStripPlane(part, seg, gap)->SetVisibility(0);
00663
00664 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00665 GetVolumeStrip(part, seg, gap, strip)->SetLineColor(m_stripColor);
00666 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
00667 }
00668
00669 for (int up = 0; up < 2; up ++){
00670 GetVolumeBoxSurface(part, seg, gap, up)->SetLineColor(m_bakeliteColor);
00671 GetVolumeBoxSurface(part, seg, gap, up)->SetVisibility(0);
00672 int seg_shift = 0;
00673 if (part == 1 && seg == 2)seg_shift = 1;
00674 for (int panel = 0; panel < m_kPanel[part] + seg_shift; panel++) {
00675 GetVolumeGasChamber(part, seg, gap, up, panel)->SetLineColor(m_gasChamberColor);
00676 GetVolumeGasChamber(part, seg, gap, up, panel)->SetVisibility(0);
00677
00678 GetVolumeGasBorder(part, seg, gap, up, panel)->SetLineColor(m_bakeliteColor);
00679 GetVolumeGasBorder(part, seg, gap, up, panel)->SetVisibility(0);
00680
00681 }
00682 for (int panel = 0; panel < m_kBakelitePanel[part][up] + seg_shift; panel++) {
00683 for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
00684 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetLineColor(m_bakeliteColor);
00685 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetVisibility(0);
00686 }
00687 }
00688 }
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700 }
00701 }
00702 }
00703
00704 for (int part = 0; part < GetPartNb(); part++) {
00705 for (int seg = 0; seg < GetSegNb(part); seg++) {
00706 for (int gap = 0; gap < GetGapNb(part); gap++) {
00707 GetGap(part, seg, gap)->SetVisibility(0);
00708 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00709 GetStrip(part, seg, gap, strip)->SetVisibility(0);
00710 }
00711 }
00712 }
00713 }
00714
00715 }
00716
00717 void
00718 MucROOTGeo::SetAllVisible()
00719 {
00720 m_Muc->SetLineColor(m_MucColor);
00721 m_Muc->SetVisibility(0);
00722
00723 for (int part = 0; part < GetPartNb(); part++) {
00724 for (int seg = 0; seg < GetSegNb(part); seg++) {
00725 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
00726 GetVolumeAbsorber(part, seg, absorber)->SetLineColor(m_absorberColor);
00727 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
00728
00729
00730
00731
00732
00733
00734 }
00735
00736 for (int gap = 0; gap < GetGapNb(part); gap++) {
00737 GetVolumeGap(part, seg, gap)->SetLineColor(m_gapColor);
00738 GetVolumeGap(part, seg, gap)->SetVisibility(1);
00739
00740 GetVolumeBox(part, seg, gap)->SetLineColor(m_stripColor);
00741 GetVolumeBox(part, seg, gap)->SetVisibility(1);
00742
00743 if (part == 1){
00744 for (int sb = 0; sb < m_kSmallBlockMax; sb++){
00745 GetVolumeAbsorberSmallBlock( gap, sb)->SetLineColor(m_absorberColor);
00746 GetVolumeAbsorberSmallBlock( gap, sb)->SetVisibility(1);
00747 }
00748 }
00749
00750 GetVolumeStripPlane(part, seg, gap)->SetLineColor(m_gapColor);
00751 GetVolumeStripPlane(part, seg, gap)->SetVisibility(1);
00752
00753 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00754 GetVolumeStrip(part, seg, gap, strip)->SetLineColor(m_stripColor);
00755 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(1);
00756 }
00757
00758 for (int up = 0; up < 2; up ++){
00759 GetVolumeBoxSurface(part, seg, gap, up)->SetLineColor(m_gapColor);
00760 GetVolumeBoxSurface(part, seg, gap, up)->SetVisibility(1);
00761 int seg_shift = 0;
00762 if (part == 1 && seg == 2)seg_shift = 1;
00763 for (int panel = 0; panel < m_kPanel[part] + seg_shift; panel++) {
00764 GetVolumeGasChamber(part, seg, gap, up, panel)->SetLineColor(m_gasChamberColor);
00765 GetVolumeGasChamber(part, seg, gap, up, panel)->SetVisibility(1);
00766
00767 GetVolumeGasBorder(part, seg, gap, up, panel)->SetLineColor(m_bakeliteColor);
00768 GetVolumeGasBorder(part, seg, gap, up, panel)->SetVisibility(1);
00769 }
00770 for (int panel = 0; panel < m_kBakelitePanel[part][up] + seg_shift; panel++) {
00771 for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
00772 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetLineColor(m_bakeliteColor);
00773 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetVisibility(1);
00774 }
00775 }
00776
00777
00778 }
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790 }
00791 }
00792 }
00793
00794 for (int part = 0; part < GetPartNb(); part++) {
00795 for (int seg = 0; seg < GetSegNb(part); seg++) {
00796 for (int gap = 0; gap < GetGapNb(part); gap++) {
00797 GetGap(part, seg, gap)->SetVisibility(0);
00798 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
00799 GetStrip(part, seg, gap, strip)->SetVisibility(0);
00800 }
00801 }
00802 }
00803 }
00804
00805 }
00806
00807
00808 void
00809 MucROOTGeo::SetQuarterVisible()
00810 {
00811 for (int part = 0; part < m_kPart; part++) {
00812 for (int seg = 0; seg < m_kSeg[part]; seg++) {
00813 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
00814 if (part == 1) {
00815 if (seg > 2) GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
00816 }
00817 else {
00818 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
00819 for (int panel = 0; panel < m_kPanel[part]; panel++) {
00820 if (seg > 0 && seg < 3) GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
00821 }
00822 }
00823 }
00824
00825 for (int gap = 0; gap < m_kGap[part]; gap++) {
00826 if (part == 1 && seg > 2) {
00827 GetVolumeGap(part, seg, gap)->SetVisibility(1);
00828 GetGap(part, seg, gap)->SetVisibility(1);
00829 }
00830 else {
00831 GetVolumeGap(part, seg, gap)->SetVisibility(0);
00832 GetGap(part, seg, gap)->SetVisibility(0);
00833 }
00834 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
00835 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
00836 }
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 }
00847 }
00848 }
00849 }
00850
00851 void
00852 MucROOTGeo::SetHalfVisible()
00853 {
00854 for (int part = 0; part < m_kPart; part++) {
00855 for (int seg = 0; seg < m_kSeg[part]; seg++) {
00856 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
00857 if (part == 1) {
00858 if (seg < 3 || seg > 5) GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
00859 }
00860 else {
00861 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
00862 for (int panel = 0; panel < m_kPanel[part]; panel++) {
00863 if (seg == 0 || seg == 3) GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
00864 }
00865 }
00866 }
00867
00868 for (int gap = 0; gap < m_kGap[part]; gap++) {
00869 if (part == 1 && (seg < 3 || seg > 5)) {
00870 GetVolumeGap(part, seg, gap)->SetVisibility(1);
00871 GetGap(part, seg, gap)->SetVisibility(1);
00872 }
00873 else {
00874 GetVolumeGap(part, seg, gap)->SetVisibility(0);
00875 GetGap(part, seg, gap)->SetVisibility(0);
00876 }
00877 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
00878 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
00879 }
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889 }
00890 }
00891 }
00892 }
00893
00894 void
00895 MucROOTGeo::SetNoEndVisible()
00896 {
00897 int part = 1;
00898 for (int seg = 0; seg < m_kSeg[part]; seg++) {
00899 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
00900 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
00901 }
00902
00903 for (int gap = 0; gap < m_kGap[part]; gap++) {
00904 GetVolumeGap(part, seg, gap)->SetVisibility(1);
00905 GetGap(part, seg, gap)->SetVisibility(1);
00906 }
00907 }
00908 }
00909
00910 void
00911 MucROOTGeo::SetPhysicalNode()
00912 {
00913
00914 if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
00915 TGeoNode *bes = gGeoManager->GetTopNode();
00916 TGeoNode *muc = bes->GetDaughter(3);
00917
00918 for (int part = 0; part < GetPartNb(); part++) {
00919 for (int seg = 0; seg < GetSegNb(part); seg++) {
00920 for (int gap = 0; gap < GetGapNb(part); gap++) {
00921 TGeoNode *nodeGap = GetGap(part, seg, gap);
00922 m_PhysicalGap[part][seg][gap] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
00923 TString("/") + muc->GetName() +
00924 TString("/") + nodeGap->GetName() +
00925 TString("/") + nodeGap->GetDaughter(0)->GetName());
00926
00927 m_PhysicalGap[part][seg][gap]->SetVisibility(0);
00928 m_PhysicalGap[part][seg][gap]->SetIsVolAtt(kFALSE);
00929 m_PhysicalGap[part][seg][gap]->SetLineColor(m_gapColor);
00930
00931 TGeoNode *nodeStripPlane = GetStripPlane(part, seg, gap);
00932
00933 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
00934 TGeoNode *nodeStrip = GetStrip(part, seg, gap, strip);
00935 m_PhysicalStrip[part][seg][gap][strip] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
00936 TString("/") + muc->GetName() +
00937 TString("/") + nodeGap->GetName() +
00938 TString("/") + nodeGap->GetDaughter(0)->GetName() +
00939 TString("/") + nodeStripPlane->GetName() +
00940 TString("/") + nodeStrip->GetName() );
00941 m_PhysicalStrip[part][seg][gap][strip]->SetVisibility(0);
00942 m_PhysicalStrip[part][seg][gap][strip]->SetIsVolAtt(kFALSE);
00943 m_PhysicalStrip[part][seg][gap][strip]->SetLineColor(m_stripColor);
00944 }
00945 }
00946 }
00947 }
00948
00949 for (int part = 0; part < GetPartNb(); part++) {
00950 for (int seg = 0; seg < GetSegNb(part); seg++) {
00951 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
00952 TGeoNode *nodeAbsorber = GetAbsorber(part, seg, absorber);
00953
00954 m_PhysicalAbsorber[part][seg][absorber][0] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
00955 TString("/") + muc->GetName() +
00956 TString("/") + nodeAbsorber->GetName() );
00957 m_PhysicalAbsorber[part][seg][absorber][0]->SetVisibility(0);
00958 m_PhysicalAbsorber[part][seg][absorber][0]->SetIsVolAtt(kFALSE);
00959 m_PhysicalAbsorber[part][seg][absorber][0]->SetLineColor(m_absorberColor);
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973 }
00974 }
00975 }
00976
00977 SetDetector();
00978 }
00979
00980 void
00981 MucROOTGeo::SetDetector()
00982 {
00983 BesView *view = 0;
00984 if (gPad) view = (BesView*)gPad->GetView();
00985
00986 m_DetectorsArray->Clear();
00987 for (int part = 0; part < GetPartNb(); part++) {
00988 for (int seg = 0; seg < GetSegNb(part); seg++) {
00989 for (int gap = 0; gap < GetGapNb(part); gap++) {
00990 TGeoPhysicalNode *phyNode = 0;
00991 phyNode = GetPhysicalGap(part, seg, gap);
00992 if (phyNode) {
00993 phyNode->SetVisibility(0);
00994 if ( (part == 1 && seg <= 8) ||
00995 (part == 0 && seg <= 3) ||
00996 (part == 2 && seg <= 3) ) {
00997 m_DetectorsArray->Add( phyNode );
00998 }
00999 else if (view && view->GetVisFull3DMuc()) {
01000 m_DetectorsArray->Add( phyNode );
01001 }
01002 }
01003 }
01004 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
01005 for (int panel = 0; panel < m_kPanelMax; panel++) {
01006 TGeoPhysicalNode *phyNode = 0;
01007 phyNode = GetPhysicalAbsorber(part, seg, absorber, panel);
01008 if (phyNode) {
01009 phyNode->SetVisibility(0);
01010 if ( (part == 1 && seg <= 8) ||
01011 (part == 0 && seg <= 3) ||
01012 (part == 2 && seg <= 3) ) {
01013 m_DetectorsArray->Add( phyNode );
01014 }
01015 else if (view && view->GetVisFull3DMuc()) {
01016 m_DetectorsArray->Add( phyNode );
01017 }
01018 }
01019 }
01020 }
01021 }
01022 }
01023
01024 }
01025
01026 void
01027 MucROOTGeo::SetHits()
01028 {
01029
01030 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
01031 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
01032 phyNode->SetLineColor(m_stripColor);
01033 phyNode->SetVisibility(0);
01034 }
01035 m_HitsArray->Clear("C");
01036
01037
01038 for (int i = 0; i < m_2DHitsArray->GetEntries(); i++) {
01039 Muc2DStrip *aStrip = (Muc2DStrip*)m_2DHitsArray->At(i);
01040 aStrip->ClearInfo();
01041 aStrip->AddInfo(aStrip->GetTitle());
01042 aStrip->CloseInfo();
01043 }
01044 m_2DHitsArray->Clear("C");
01045
01046 if (gEvent) m_MucDigiCol = gEvent->GetMucDigiCol();
01047
01048 for (int i = 0; i < m_MucDigiCol->GetEntries(); i++) {
01049 Identifier aMucID( ((TMucDigi*)m_MucDigiCol->At(i))->getIntId() );
01050 int part = MucID::part( aMucID );
01051 int seg = MucID::seg( aMucID );
01052 int gap = MucID::gap( aMucID );
01053 int strip = MucID::strip( aMucID );
01054
01055 TGeoPhysicalNode *phyNode = 0;
01056 phyNode = GetPhysicalStrip( part, seg, gap, strip );
01057 if (phyNode) m_HitsArray->Add( phyNode );
01058
01059 Muc2DStrip *aStrip = 0;
01060 aStrip = m_Muc2DStrip[part][seg][gap][strip];
01061 if (aStrip) {
01062 aStrip->ClearInfo();
01063 aStrip->AddInfo(aStrip->GetTitle());
01064
01065 char data[100];
01066 sprintf(data, "Fired");
01067 aStrip->AddInfo( TString(data) );
01068
01069 aStrip->CloseInfo();
01070
01071 m_2DHitsArray->Add(aStrip);
01072 }
01073 }
01074 }
01075
01076 void
01077 MucROOTGeo::SetVisMucDetector()
01078 {
01079 BesView *view = 0;
01080 if (gPad) view = (BesView*)gPad->GetView();
01081
01082 for (int i = 0; i < m_DetectorsArray->GetEntries(); i++) {
01083 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At(i);
01084 phyNode->SetVisibility(0);
01085
01086 if (view && view->GetVisMucGlobal()) {
01087 int part = GetPart(phyNode);
01088 if (part == 0 && view->GetVisMucEast() ||
01089 part == 1 && view->GetVisMucBarrel() ||
01090 part == 2 && view->GetVisMucWest() )
01091 phyNode->SetVisibility(1);
01092 }
01093 }
01094 }
01095
01096 void
01097 MucROOTGeo::SetVisMucHits()
01098 {
01099 BesView *view = 0;
01100 if (gPad) view = (BesView*)gPad->GetView();
01101
01102 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
01103 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
01104 if (view && view->GetVisMucHitsGlobal()) {
01105 int part = GetPart(phyNode);
01106 if (part == 0 && view->GetVisMucHitsEast() ||
01107 part == 1 && view->GetVisMucHitsBarrel() ||
01108 part == 2 && view->GetVisMucHitsWest() ) {
01109 phyNode->SetVisibility(1);
01110
01111 continue;
01112 }
01113 }
01114 phyNode->SetVisibility(0);
01115 }
01116 }
01117
01118 int
01119 MucROOTGeo::GetPartNb()
01120 {
01121 int part = m_kPart;
01122 return part;
01123 }
01124
01125 int
01126 MucROOTGeo::GetSegNb(int part)
01127 {
01128 int seg = m_kSeg[part];
01129 return seg;
01130 }
01131
01132 int
01133 MucROOTGeo::GetGapNb(int part)
01134 {
01135 int gap = m_kGap[part];
01136 return gap;
01137 }
01138
01139 int
01140 MucROOTGeo::GetStripNb(int part, int seg, int gap)
01141 {
01142 int strip = m_StripNum[part][seg][gap];
01143 return strip;
01144 }
01145
01146 int
01147 MucROOTGeo::GetAbsorberNb(int part)
01148 {
01149 int absorber = m_kAbsorber[part];
01150 return absorber;
01151 }
01152
01153 TGeoVolume*
01154 MucROOTGeo::GetVolumeAbsorber( int part, int seg, int absorber )
01155 {
01156 std::stringstream osname;
01157 osname << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber;
01158
01159 return GetLogicalVolume( osname.str() );
01160 }
01161
01162 TGeoVolume*
01163 MucROOTGeo::GetVolumeAbsorberSmallBlock( int gap, int sb )
01164 {
01165 std::stringstream osname;
01166 osname << "VolumeSmallBlock" << "Gap" << gap << "SB" << sb;
01167
01168 return GetLogicalVolume( osname.str() );
01169 }
01170
01171
01172
01173 TGeoVolume*
01174 MucROOTGeo::GetVolumeAbsorberPanel( int part, int seg, int absorber, int panel )
01175 {
01176 std::stringstream osname;
01177 osname << "logical" << "Muc" << "Part" << part << "Seg" << seg << "Absorber" << absorber << "Panel" << panel;
01178
01179 return GetLogicalVolume( osname.str() );
01180 }
01181
01182 TGeoVolume*
01183 MucROOTGeo::GetVolumeGap( int part, int seg, int gap )
01184 {
01185 std::stringstream osname;
01186 osname << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap;
01187
01188 return GetLogicalVolume( osname.str() );
01189 }
01190
01191 TGeoVolume*
01192 MucROOTGeo::GetVolumeBox( int part, int seg, int gap)
01193 {
01194 std::stringstream osname;
01195 osname << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "Al";
01196
01197 return GetLogicalVolume( osname.str() );
01198 }
01199
01200 TGeoVolume*
01201 MucROOTGeo::GetVolumeBoxSurface( int part, int seg, int gap ,int up)
01202 {
01203 std::stringstream osname;
01204 int segment = 0;
01205 if (part ==1 && seg ==2) segment = 2;
01206 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "AlSf" <<up;
01207
01208 return GetLogicalVolume( osname.str() );
01209 }
01210
01211 TGeoVolume*
01212 MucROOTGeo::GetVolumeStripPlane( int part, int seg, int gap )
01213 {
01214 int segment = 0;
01215 if (part==1&&seg==2) segment = 2;
01216 std::stringstream osname;
01217 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP";
01218
01219 return GetLogicalVolume( osname.str() );
01220 }
01221
01222 TGeoVolume*
01223 MucROOTGeo::GetVolumeStrip( int part, int seg, int gap, int strip )
01224 {
01225 std::stringstream osname;
01226 int segment = 0;
01227 if (part == 1 && seg == 2) segment = 2;
01228 if (strip < 10) {
01229 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "00" << strip;
01230 }
01231 else if (strip<100){
01232 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "0" << strip;
01233 }
01234 else {
01235 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << strip;
01236 }
01237
01238 return GetLogicalVolume( osname.str() );
01239 }
01240
01241 TGeoVolume*
01242 MucROOTGeo::GetVolumeGasChamber( int part, int seg, int gap, int rpcUpDown, int panel )
01243 {
01244 std::stringstream osname;
01245 int segment = 0;
01246 if (part ==1 && seg ==2) segment = 2;
01247 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "R" << rpcUpDown << "Pn" << panel << "C";
01248
01249 return GetLogicalVolume( osname.str() );
01250 }
01251
01252 TGeoVolume*
01253 MucROOTGeo::GetVolumeGasBorder( int part, int seg, int gap, int rpcUpDown, int panel )
01254 {
01255 std::stringstream osname;
01256 int segment = 0;
01257 if (part ==1 && seg ==2) segment = 2;
01258 osname << "l" << "Muc" << "P" << part%2 << "S" << segment << "G" << gap << "R" << rpcUpDown << "Pn" << panel << "GB";
01259
01260 return GetLogicalVolume( osname.str() );
01261 }
01262
01263 TGeoVolume*
01264 MucROOTGeo::GetVolumeBakelite( int part, int seg, int gap, int RpcUpDown, int panel, int bakelite )
01265 {
01266 std::stringstream osname;
01267 int segment = 0;
01268 if (part ==1 && seg ==2) segment = 2;
01269 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "R" << RpcUpDown << "Pn" << panel<< "B" << bakelite;
01270
01271 return GetLogicalVolume( osname.str() );
01272 }
01273
01274 TGeoNode*
01275 MucROOTGeo::GetAbsorber( int part, int seg, int absorber )
01276 {
01277 if (m_NodeAbsorber[part][seg][absorber] != 0) {
01278 return m_NodeAbsorber[part][seg][absorber];
01279 }
01280 else {
01281 return 0;
01282 }
01283 }
01284
01285 TGeoNode*
01286 MucROOTGeo::GetAbsorberPanel( int part, int seg, int absorber, int panel )
01287 {
01288 if (m_NodeAbsorberPanel[part][seg][absorber][panel] != 0) {
01289 return m_NodeAbsorberPanel[part][seg][absorber][panel];
01290 }
01291 else {
01292 return 0;
01293 }
01294 }
01295
01296 TGeoNode*
01297 MucROOTGeo::GetGap( int part, int seg, int gap )
01298 {
01299 if (m_NodeGap[part][seg][gap] != 0) {
01300 return m_NodeGap[part][seg][gap];
01301 }
01302 else {
01303 return 0;
01304 }
01305 }
01306
01307 TGeoNode*
01308 MucROOTGeo::GetStripPlane( int part, int seg, int gap )
01309 {
01310 if (m_NodeStripPlane[part][seg][gap] != 0) {
01311 return m_NodeStripPlane[part][seg][gap];
01312 }
01313 else {
01314 return 0;
01315 }
01316 }
01317
01318 TGeoNode*
01319 MucROOTGeo::GetStrip( int part, int seg, int gap, int strip )
01320 {
01321 if (m_NodeStrip[part][seg][gap][strip] != 0) {
01322 return m_NodeStrip[part][seg][gap][strip];
01323 }
01324 else {
01325 return 0;
01326 }
01327 }
01328
01329 TGeoPhysicalNode*
01330 MucROOTGeo::GetPhysicalAbsorber( int part, int seg, int absorber, int panel )
01331 {
01332 return m_PhysicalAbsorber[part][seg][absorber][panel];
01333 }
01334
01335 TGeoPhysicalNode*
01336 MucROOTGeo::GetPhysicalGap( int part, int seg, int gap )
01337 {
01338 if (m_PhysicalGap[part][seg][gap] != 0) {
01339 return m_PhysicalGap[part][seg][gap];
01340 }
01341 else {
01342 return 0;
01343 }
01344 }
01345
01346 TGeoPhysicalNode*
01347 MucROOTGeo::GetPhysicalStrip( int part, int seg, int gap, int strip )
01348 {
01349 if (m_PhysicalStrip[part][seg][gap][strip] != 0) {
01350 return m_PhysicalStrip[part][seg][gap][strip];
01351 }
01352 else {
01353 return 0;
01354 }
01355 }
01356
01357 Muc2DStrip*
01358 MucROOTGeo::Get2DStrip( int part, int seg, int gap, int strip )
01359 {
01360 if (m_Muc2DStrip[part][seg][gap][strip]) return m_Muc2DStrip[part][seg][gap][strip];
01361 else return 0;
01362 }
01363
01364 int
01365 MucROOTGeo::GetPart(TGeoPhysicalNode* phyNode)
01366 {
01367 for (int part = 0; part < GetPartNb(); part++) {
01368 for (int seg = 0; seg < GetSegNb(part); seg++) {
01369 for (int gap = 0; gap < GetGapNb(part); gap++) {
01370 if (phyNode == GetPhysicalGap(part, seg, gap)) {
01371 return part;
01372 }
01373 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
01374 if (phyNode == GetPhysicalStrip(part, seg, gap, strip)) {
01375 return part;
01376 }
01377 }
01378 }
01379 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
01380 for (int panel = 0; panel < m_kPanelMax; panel++) {
01381 if (phyNode == GetPhysicalAbsorber(part, seg, absorber, panel)) {
01382 return part;
01383 }
01384 }
01385 }
01386 }
01387 }
01388
01389 return -1;
01390 }
01391
01392 Bool_t
01393 MucROOTGeo::IsZRVisible( int part, int seg )
01394 {
01395 if (part != 1) return true;
01396
01397 BesView *view = (BesView*)gPad->GetView();
01398 Double_t viewPhi = view->GetLongitude();
01399 viewPhi = Range360(viewPhi);
01400
01401 Int_t viewSeg = Int_t(viewPhi/45.0+0.5);
01402 Int_t upSeg = viewSeg+2;
01403 Int_t downSeg = viewSeg-2;
01404 if (upSeg < 0) upSeg += 8;
01405 else if (upSeg >= 8) upSeg -= 8;
01406 if (downSeg < 0) downSeg += 8;
01407 else if (downSeg >= 8) downSeg -= 8;
01408
01409 if (seg == upSeg || seg == downSeg) return true;
01410 else return false;
01411 }
01412
01413 Double_t
01414 MucROOTGeo::Range360(Double_t input)
01415 {
01416 if (input >= 360.0) {
01417 do {
01418 input -= 360.0;
01419 }
01420 while (input >= 360.0);
01421 }
01422 else if (input < 0.0) {
01423 do {
01424 input += 360.0;
01425 }
01426 while (input < 0.0);
01427 }
01428
01429 return input;
01430 }
01431
01432 void
01433 MucROOTGeo::Draw(Option_t *option)
01434 {
01435 TString opt = option;
01436 opt.ToUpper();
01437
01438 if (!m_2DGeoInit) cout << "MucROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
01439 BesView *view = (BesView*)gPad->GetView();
01440 if (!view) cout << "MucROOTGeo::Draw(), BesView not found" << endl;
01441
01442 if (view->GetVisMucGlobal()) {
01443
01444 for (Int_t part = GetPartNb()-1; part >= 0; part--) {
01445 if ( (part == 0 && view->GetVisMucEast()) ||
01446 (part == 1 && view->GetVisMucBarrel()) ||
01447 (part == 2 && view->GetVisMucWest()) ) {
01448 for (Int_t seg = 0; seg < GetSegNb(part); seg++) {
01449 if (opt.Contains("XY")) {
01450 if (m_MucXY[part][seg]) m_MucXY[part][seg]->Draw("");
01451 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
01452 if (m_MucXYGap[part][seg][gap]) m_MucXYGap[part][seg][gap]->Draw("");
01453 }
01454 }
01455 if (opt.Contains("ZR")) {
01456 if ( m_MucZR[part][seg] ) {
01457 if (part == 1) m_MucZR[part][seg]->SetRotatable(true);
01458 m_MucZR[part][seg]->Draw("");
01459 }
01460 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
01461 if (m_MucZRGap[part][seg][gap]) {
01462 if (part == 1) m_MucZRGap[part][seg][gap]->SetRotatable(true);
01463 m_MucZRGap[part][seg][gap]->Draw("");
01464 }
01465 }
01466 }
01467 }
01468 }
01469 }
01470
01471
01472 for (Int_t part = GetPartNb()-1; part >= 0; part--) {
01473 for (Int_t seg = 0; seg < GetSegNb(part); seg++) {
01474 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
01475 for (Int_t strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
01476 if (m_Muc2DStrip[part][seg][gap][strip]) {
01477 m_Muc2DStrip[part][seg][gap][strip]->SetFired(false);
01478 if ( (part == 0 && view->GetVisMucEast()) ||
01479 (part == 1 && view->GetVisMucBarrel()) ||
01480 (part == 2 && view->GetVisMucWest()) ) {
01481 m_Muc2DStrip[part][seg][gap][strip]->Draw("");
01482 }
01483 }
01484 }
01485 }
01486 }
01487 }
01488
01489 }
01490 }
01491
01492 void
01493 MucROOTGeo::DrawHits(Option_t *option)
01494 {
01495 BesView *view = (BesView*)gPad->GetView();
01496 if (!view) cout << "MucROOTGeo::DrawHits(), BesView not found" << endl;
01497
01498
01499 if (view->GetVisMucHitsGlobal()) {
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512 if (m_MucDigiCol) {
01513 for (int i = 0; i < m_MucDigiCol->GetEntries(); i++) {
01514 TMucDigi *aMucDigi = (TMucDigi*)m_MucDigiCol->At(i);
01515
01516
01517 Identifier aMucID( aMucDigi->getIntId() );
01518 int part = MucID::part( aMucID );
01519 int seg = MucID::seg( aMucID );
01520 int gap = MucID::gap( aMucID );
01521 int strip = MucID::strip( aMucID );
01522
01523 Muc2DStrip *aStrip = 0;
01524 aStrip = m_Muc2DStrip[part][seg][gap][strip];
01525 if (aStrip) {
01526 if ( (part == 0 && view->GetVisMucHitsEast()) ||
01527 (part == 1 && view->GetVisMucHitsBarrel()) ||
01528 (part == 2 && view->GetVisMucHitsWest()) ) {
01529 aStrip->SetFired(true);
01530 aStrip->Draw();
01531 }
01532 }
01533 }
01534 }
01535 }
01536 }
01537