BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EventDisplay/BesVisLib/BesVisLib-00-04-04/src/MucROOTGeo.cxx
Go to the documentation of this file.
1//$id$
2/*
3 * 2004/11/29 Zhengyun You Peking University
4 * Muc Geometry General for EventDisplay
5 *
6 * 2004/12/11 Zhengyun You Peking University
7 * named from MucGeo to MucROOTGeo
8 * inherit from class SubDetectorROOTGeo
9 */
10
11using namespace std;
12
13
14#include <string>
15#include <fstream>
16#include <iostream>
17#include <sstream>
18#include <vector>
19#include <iomanip>
20
21#include <TGeoManager.h>
22#include <TGeoBoolNode.h>
23#include <TGeoBBox.h>
24#include <TGeoTube.h>
25#include <TGeoArb8.h>
26#include <TMath.h>
27
28#include "BesVisLib/MucROOTGeo.h"
29#include "Identifier/MucID.h"
30#include "BesVisLib/BesEvent.h"
31#include "BesVisLib/BesView.h"
32
33const int MucROOTGeo::m_kSeg[m_kPart] = {4, 8, 4};
34const int MucROOTGeo::m_kAbsorber[m_kPart] = {9, 9, 9};
35const int MucROOTGeo::m_kGap[m_kPart] = {8, 9, 8};
36const int MucROOTGeo::m_kPanel[m_kPart] = {3, 4, 3};
37const int MucROOTGeo::m_kBakelitePanel[m_kPart][m_kUpDown]= {3, 5, 4, 4, 3, 5};
38
41{
42 // Default constructor.
43 for (int part = 0; part < m_kPart; part++) {
44 for (int seg = 0; seg < m_kSegMax; seg++) {
45 m_MucXY[part][seg] = 0;
46 m_MucZR[part][seg] = 0;
47
48 for (int gap = 0; gap < m_kGapMax; gap++) {
49 m_NodeGap[part][seg][gap] = 0;
50 m_PhysicalGap[part][seg][gap] = 0;
51 m_MucXYGap[part][seg][gap] = 0;
52 m_MucZRGap[part][seg][gap] = 0;
53
54 for (int strip = 0; strip < m_kStripMax; strip++) {
55 m_NodeStrip[part][seg][gap][strip] = 0;
56 m_PhysicalStrip[part][seg][gap][strip] = 0;
57 //m_Muc2DStrip[part][seg][gap][strip] = 0;
58 }
59 }
60 for (int absorber = 0; absorber < m_kAbsorberMax; absorber++) {
61 m_NodeAbsorber[part][seg][absorber] = 0;
62 for (int panel = 0; panel < m_kPanelMax; panel++) {
63 m_NodeAbsorberPanel[part][seg][absorber][panel] = 0;
64 m_PhysicalAbsorber[part][seg][absorber][panel] = 0;
65 }
66 }
67 }
68 }
69
70 m_MucColor = 2;
71 m_absorberColor = 2; // 1006
72 m_gapColor = 16; // 1
73 m_gasChamberColor = 8;
74 m_bakeliteColor = 8;
75 m_stripColor = 2;//kWhite;
76}
77
79{ }
80
81void
82MucROOTGeo::InitFromGDML( const char *gdmlFile, const char *setupName )
83{
84 m_ROOTGeoInit = 2;
85
86 ReadGdml(gdmlFile, setupName);
87 SetNode();
88}
89
90void
91MucROOTGeo::InitFromROOT( TGeoVolume *vol )
92{
93 m_ROOTGeoInit = 1;
94
95 SetVolumeMuc(vol);
96 SetNode();
97}
98
99void
101{
102 if (m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2) {
103 cout << "MucROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
104 return;
105 }
106 m_2DGeoInit = 1;
107
108 Int_t mucColor = 1002;
109 Int_t mucLineColor = 15; //15;
110 Int_t mucXYStyle = 1001;//3001;
111 Int_t mucZRStyle = 1001;//3007;
112
113 Int_t mucGapColor = 10; // 1002
114 Int_t mucGapStyle = 1001; //1001;
115 Int_t mucGapXYECStyle = 4000; //1001;
116 Int_t mucGapLineColor = 15;
117
118 Double_t x = 0.0, y = 0.0, z = 0.0;
119 Double_t r = 0.0, phi = 0.0;
120 Double_t local[3] = {0.0, 0.0, 0.0};
121 Double_t master[3] = {0.0, 0.0, 0.0};
122 //Int_t nPoints = 4;
123 Double_t P[300] = {0.0};
124 //Double_t center[3] = {0.0, 0.0, 0.0};
125 TString name;
126
127 Int_t part = 0, seg = 0, gap = 0, strip = 0;
128
129 //----------XY-----------
130 // Muc
131 TGeoCompositeShape *mucShape = (TGeoCompositeShape*)GetVolumeMuc()->GetShape();
132 if (mucShape) ;
133
134 TGeoBoolNode *mucBoolNode = mucShape->GetBoolNode();
135 TGeoBBox *mucOuterShape = (TGeoBBox*)mucBoolNode->GetLeftShape();
136 TGeoTube *mucInnerShape = (TGeoTube*)mucBoolNode->GetRightShape();
137 if (mucOuterShape) ;
138 //if (mucInnerShape) cout << "mucInnerShape name : " << mucInnerShape->GetName() << endl;
139 //else cout << "MucROOTGeo:Init2DGeoometry, mucInnerShape not found" << endl;
140
141 Double_t mucOuterR = mucOuterShape->GetDX();
142 Double_t mucInnerR = mucInnerShape->GetRmax() + 40.0; // 40.0 is the height of first gap
143
144 // Barrel
145 // barrel segment XY view
146
147 part = 1;
148 Int_t xySegPointSeq[4] = {0,1,1,0}; // point 0,1,2,3 -> 0,1,1,0
149 for (seg = 0; seg < GetSegNb(part); seg++) {
150 name = TString("MucBarrelSeg");
151 name += seg;
152 for (Int_t iPoint = 0; iPoint < 4; iPoint++) {
153 if (iPoint < 2) r = mucInnerR/TMath::Cos(TMath::Pi()/8.0);
154 else r = mucOuterR/TMath::Cos(TMath::Pi()/8.0);
155 phi = TMath::Pi()/8.0 * (2*seg-1 + 2*xySegPointSeq[iPoint]);
156 x = r * TMath::Cos(phi);
157 y = r * TMath::Sin(phi);
158 z = 0.0;
159 P[3*iPoint] = x;
160 P[3*iPoint+1] = y;
161 P[3*iPoint+2] = z;
162 }
163 m_MucXY[part][seg] = new BesPolygon2D(name, name, 4, &P[0]);
164 m_MucXY[part][seg]->SetFillColor(mucColor);
165 m_MucXY[part][seg]->SetFillStyle(mucXYStyle);
166 m_MucXY[part][seg]->SetLineColor(mucLineColor);
167 }
168
169 // barrel segment ZR view
170
171 part = 1;
172 for (seg = 0; seg < GetSegNb(part); seg++) {
173 for (Int_t iPoint = 0; iPoint < 4; iPoint++) {
174 if (iPoint == 0 || iPoint == 3 ) r = mucInnerR;
175 else r = mucOuterR;
176 phi = TMath::Pi()/4.0 * seg;
177
178 x = r * TMath::Cos(phi);
179 y = r * TMath::Sin(phi);
180
181 TGeoVolume *volAbsorber = 0;
182 volAbsorber= GetAbsorber(part, seg, 0)->GetVolume();
183 TGeoBBox *absorberShape = (TGeoBBox*)volAbsorber->GetShape();
184 if (seg == 2)cout<<"in MucROOTGeo::Init2DGeometry() x,y,z = "<<absorberShape->GetDX()<<" "<<absorberShape->GetDY()<<" "<<absorberShape->GetDZ()<<endl;
185 Double_t dy = absorberShape->GetDY();
186 z = dy;
187 if (iPoint < 2) z = -dy;
188
189 P[3*iPoint] = x;
190 P[3*iPoint+1] = y;
191 P[3*iPoint+2] = z;
192 }
193
194 if (seg == 2 || seg == 6) {
195 if (seg == 2) name = TString("MucBarrelUpSeg");
196 if (seg == 6) name = TString("MucBarrelDownSeg");
197
198 m_MucZR[part][seg] = new BesPolygon2D(name, name, 4, &P[0]);
199 m_MucZR[part][seg]->SetFillColor(mucColor);
200 m_MucZR[part][seg]->SetFillStyle(mucZRStyle);
201 m_MucZR[part][seg]->SetLineColor(mucLineColor);
202 }
203 }
204
205 // barrel gap
206
207 part = 1;
208 for (seg = 0; seg < GetSegNb(part); seg++) {
209 for (gap = 0; gap < GetGapNb(part); gap++) {
210
211 TGeoPhysicalNode *phyNode = 0;
212 phyNode = GetPhysicalGap(part, seg, gap);
213
214 TGeoBBox *gapShape = (TGeoBBox*)phyNode->GetShape();
215 Double_t dx = gapShape->GetDX();
216 Double_t dy = gapShape->GetDY();
217 Double_t dz = gapShape->GetDZ();
218
219 // barrel gap XY view
220 for (Int_t i = 0; i < 4; i++) {
221 local[1] = 0.0; // y
222 switch (i) {
223 case 0:
224 local[0] = -dx;
225 local[2] = -dz;
226 break;
227 case 1:
228 local[0] = dx;
229 local[2] = -dz;
230 break;
231 case 2:
232 local[0] = dx;
233 local[2] = dz;
234 break;
235 case 3:
236 local[0] = -dx;
237 local[2] = dz;
238 break;
239 }
240 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
241 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
242 }
243
244 name = TString("MucBarrelSeg");
245 name += seg;
246 name += TString("Gap");
247 name += gap;
248
249 m_MucXYGap[part][seg][gap] = new BesPolygon2D(name, name, 4, &P[0]);
250 m_MucXYGap[part][seg][gap]->SetFillColor(mucGapColor);
251 m_MucXYGap[part][seg][gap]->SetFillStyle(mucGapStyle);
252 m_MucXYGap[part][seg][gap]->SetLineColor(mucGapLineColor);
253
254 // barrel gap ZR view
255 for (Int_t i = 0; i < 4; i++) {
256 local[0] = 0.0; // x
257 switch (i) {
258 case 0:
259 local[1] = -dy;
260 local[2] = -dz;
261 break;
262 case 1:
263 local[1] = -dy;
264 local[2] = dz;
265 break;
266 case 2:
267 local[1] = dy;
268 local[2] = dz;
269 break;
270 case 3:
271 local[1] = dy;
272 local[2] = -dz;
273 break;
274 }
275 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
276 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
277 }
278
279 if (seg == 2 || seg == 6) {
280 if (seg == 2) {
281 name = TString("MucBarrelUpSegGap");
282 name += gap;
283 }
284 else if (seg == 6) {
285 name = TString("MucBarrelDownSegGap");
286 name += gap;
287 }
288
289 m_MucZRGap[part][seg][gap] = new BesPolygon2D(name, name, 4, &P[0]);
290 m_MucZRGap[part][seg][gap]->SetFillColor(mucGapColor);
291 m_MucZRGap[part][seg][gap]->SetFillStyle(mucGapStyle);
292 m_MucZRGap[part][seg][gap]->SetLineColor(mucGapLineColor);
293 }
294 }
295 }
296 // End cap
297 for (part = 0; part < GetPartNb(); part++) {
298 if (part == 1) continue;
299 for (seg = 0; seg < GetSegNb(part); seg++) {
300 Double_t segP[100];
301 Int_t iSegPoint = 0;
302
303 for (gap = 0; gap < GetGapNb(part); gap++) {
304 TGeoPhysicalNode *phyNode = 0;
305 phyNode = GetPhysicalGap(part, seg, gap);
306
307 Int_t ixyPoint = 0, izrPoint = 0;
308 Int_t nPanel = 3; //4
309 //TGeoCompositeShape *addPanelShape[nPanel];
310 //TGeoTrap *panelShape[nPanel];
311 TGeoCompositeShape *addPanelShape[4];
312 TGeoTrap *panelShape[4];
313
314
315 for (Int_t panel = nPanel-1; panel >= 0; panel--) {
316 if (panel == nPanel-1) addPanelShape[panel] = (TGeoCompositeShape*)GetGap(part, seg, gap)->GetVolume()->GetShape();
317 else addPanelShape[panel] = (TGeoCompositeShape*)addPanelShape[panel+1]->GetBoolNode()->GetLeftShape();
318
319 panelShape[panel] = (TGeoTrap*)addPanelShape[panel]->GetBoolNode()->GetRightShape();
320
321 Double_t *localArb8Point, masterArb8Point[3*8];
322 localArb8Point = panelShape[panel]->GetVertices();
323 for (Int_t i = 0; i < 8; i++) {
324 local[0] = localArb8Point[2*i];
325 local[1] = localArb8Point[2*i+1];
326 if (i < 4) local[2] = panelShape[panel]->GetDz() * (-1.0);
327 else local[2] = panelShape[panel]->GetDz();
328
329 addPanelShape[panel]->GetBoolNode()->GetRightMatrix()->LocalToMaster(local, &master[0]); // transform to gap coordinate
330
331 for (Int_t j = 0; j < 3; j++) local[j] = master[j];
332 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
333 for (Int_t j = 0; j < 3; j++) {
334 masterArb8Point[3*i+j] = master[j];
335 }
336 }
337
338 // xy, add point on panel 3 and panel 0 //panel 3 -> panel 2(new geom)
339 if (panel == 2) {
340 Int_t xyPanelPointSeq[4] = {0, 3, 7, 4};
341 for (Int_t i = 0; i < 4; i++) {
342 for (Int_t j = 0; j < 3; j++) {
343 P[3*ixyPoint+j] = masterArb8Point[3*xyPanelPointSeq[i]+j];
344 }
345 ixyPoint++;
346 }
347 }
348 if (panel == 0) {
349 Int_t xyPanelPointSeq[4] = {7, 4, 0, 3};
350 for (Int_t i = 0; i < 4; i++) {
351 for (Int_t j = 0; j < 3; j++) {
352 P[3*ixyPoint+j] = masterArb8Point[3*xyPanelPointSeq[i]+j];
353 }
354 ixyPoint++;
355 }
356 }
357
358 // zr, add point on panel 3 and panel 0, use P from P[100] //panel 3 -> panel 2(new geom)
359 if (panel == 2) {
360 Int_t zrPanelPointSeq[4] = {4, 7, 6, 5};
361 for (Int_t i = 0; i < 4; i++) {
362 for (Int_t j = 0; j < 3; j++) {
363 P[100+3*izrPoint+j] = masterArb8Point[3*zrPanelPointSeq[i]+j];
364 }
365 izrPoint++;
366 }
367 }
368 if (panel == 0) {
369 Int_t zrPanelPointSeq[4] = {6, 5, 4, 7};
370 for (Int_t i = 0; i < 4; i++) {
371 for (Int_t j = 0; j < 3; j++) {
372 P[100+3*izrPoint+j] = masterArb8Point[3*zrPanelPointSeq[i]+j];
373 }
374 izrPoint++;
375 }
376 }
377 }
378
379 if (part == 0) name = TString("MucEastEc");
380 else if (part == 2) name = TString("MucWestEc");
381 name += TString("Seg");
382 name += seg;
383 name += TString("Gap");
384 name += gap;
385
386 //cout << name << endl;
387 m_MucXYGap[part][seg][gap] = new BesPolygon2D(name, name, ixyPoint, &P[0]); // ixyPoint = 8
388 m_MucXYGap[part][seg][gap]->SetFillColor(mucGapColor);
389 m_MucXYGap[part][seg][gap]->SetFillStyle(mucGapXYECStyle);
390 m_MucXYGap[part][seg][gap]->SetLineColor(mucGapLineColor);
391
392 m_MucZRGap[part][seg][gap] = new BesPolygon2D(name, name, izrPoint, &P[100]); // izrPoint = 8
393 m_MucZRGap[part][seg][gap]->SetFillColor(mucGapColor);
394 m_MucZRGap[part][seg][gap]->SetFillStyle(mucGapStyle);
395 m_MucZRGap[part][seg][gap]->SetLineColor(mucGapLineColor);
396
397 // end cap segment ZR view
398
399 if (gap == 0) {
400 Double_t zrFirstAbsorberHeight = ((TGeoBBox*)GetAbsorber(part, seg, 0)->GetVolume()->GetShape())->GetDZ()*2.0;
401 for (Int_t i = 0; i < 4; i++) {
402 for (Int_t j = 0; j < 3; j++) {
403 if ( (part == 0 && (seg == 0 || seg == 2)) || (part == 2 && (seg == 1 || seg == 3)) ) {
404 Int_t zrSegPointSeq[4] = {6, 7, 0, 1};
405 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
406 }
407 else {
408 Int_t zrSegPointSeq[4] = {5, 4, 3, 2};
409 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
410 }
411
412 if (j == 2) {
413 if (part == 0) segP[3*iSegPoint+j] -= zrFirstAbsorberHeight;
414 else if (part == 2) segP[3*iSegPoint+j] += zrFirstAbsorberHeight;
415 }
416 }
417 iSegPoint++;
418 }
419 }
420 else if (gap == 7) {
421 Double_t zrLastAbsorberHeight = ((TGeoBBox*)GetAbsorber(part, seg, 8)->GetVolume()->GetShape())->GetDZ()*2.0;
422 for (Int_t i = 0; i < 4; i++) {
423 for (Int_t j = 0; j < 3; j++) {
424 if ( (part == 0 && (seg == 0 || seg == 2)) || (part == 2 && (seg == 1 || seg == 3)) ){
425 Int_t zrSegPointSeq[4] = {2, 3, 4, 5};
426 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
427 }
428 else {
429 Int_t zrSegPointSeq[4] = {1, 0, 7, 6};
430 segP[3*iSegPoint+j] = P[100+3*zrSegPointSeq[i]+j];
431 }
432
433 if (j == 2) {
434 if (part == 0) segP[3*iSegPoint+j] += zrLastAbsorberHeight;
435 else if (part == 2) segP[3*iSegPoint+j] -= zrLastAbsorberHeight;
436 }
437 }
438 iSegPoint++;
439 }
440 }
441
442 }
443 if (part == 0) name = TString("MucEastEc");
444 else if (part == 2) name = TString("MucWestEc");
445 name += TString("Seg");
446 name += seg;
447 m_MucZR[part][seg] = new BesPolygon2D(name, name, iSegPoint, &segP[0]); // izrPoint = 8
448 m_MucZR[part][seg]->SetFillColor(mucColor);
449 m_MucZR[part][seg]->SetFillStyle(mucZRStyle);
450 m_MucZR[part][seg]->SetLineColor(mucLineColor);
451 }
452 }
453
454 for (part = 0; part < GetPartNb(); part++) {
455 for (seg = 0; seg < GetSegNb(part); seg++) {
456 for (gap = 0; gap < GetGapNb(part); gap++) {
457 for (strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
458 TGeoPhysicalNode *phyNode = 0;
459 phyNode = GetPhysicalStrip(part, seg, gap, strip);
460 TGeoBBox *stripShape = (TGeoBBox*)phyNode->GetShape();
461 Double_t dx = stripShape->GetDX();
462 Double_t dy = stripShape->GetDY();
463 Double_t dz = stripShape->GetDZ();
464 dz *= m_kStripZMuliple;
465
466 for (Int_t i = 0; i < 8; i++) {
467 switch (i) {
468 case 0:
469 local[0] = -dx;
470 local[1] = -dy;
471 local[2] = -dz;
472 break;
473 case 1:
474 local[0] = dx;
475 local[1] = -dy;
476 local[2] = -dz;
477 break;
478 case 2:
479 local[0] = dx;
480 local[1] = dy;
481 local[2] = -dz;
482 break;
483 case 3:
484 local[0] = -dx;
485 local[1] = dy;
486 local[2] = -dz;
487 break;
488 case 4:
489 local[0] = -dx;
490 local[1] = -dy;
491 local[2] = dz;
492 break;
493 case 5:
494 local[0] = dx;
495 local[1] = -dy;
496 local[2] = dz;
497 break;
498 case 6:
499 local[0] = dx;
500 local[1] = dy;
501 local[2] = dz;
502 break;
503 case 7:
504 local[0] = -dx;
505 local[1] = dy;
506 local[2] = dz;
507 break;
508 }
509
510 phyNode->GetMatrix(-1*phyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
511 for (Int_t j = 0; j < 3; j++) P[3*i+j] = master[j];
512 }
513
514 name = TString("Muc Part");
515 name += part;
516 name += TString(" Seg");
517 name += seg;
518 name += TString(" Gap");
519 name += gap;
520 name += TString(" Strip");
521 name += strip;
522
523 m_Muc2DStrip[part][seg][gap][strip] = new Muc2DStrip(name, name, 8, &P[0], part, seg, gap, strip);
524 }
525 }
526 }
527 }
528}
529
530void
532{
533 if (m_ROOTGeoInit == 2) { // from GDML
534
535 m_Muc = GetTopVolume();
536 if (!m_Muc) std::cout << "m_Muc = 0" << std::endl;
537
538 int gapCount = 0;
539 for (int part = 0; part < GetPartNb(); part++) {
540 for (int seg = 0; seg < GetSegNb(part); seg++) {
541 for (int gap = 0; gap < GetGapNb(part); gap++) {
542 m_StripNum[part][seg][gap] = GetVolumeStripPlane(part, seg, gap)->GetNdaughters();
543
544 std::stringstream osnameGap;
545 osnameGap << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "_" << gapCount;
546 m_NodeGap[part][seg][gap] = GetNode( osnameGap.str() );
547 gapCount++;
548
549 int segment = 0;
550 if (part==1&&seg==2) segment = 2;
551 std::stringstream osnameStripPlane;
552 osnameStripPlane << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP" << "_" << "0";
553 m_NodeStripPlane[part][seg][gap] = GetNode( osnameStripPlane.str() );
554 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
555 std::stringstream osnameStrip;
556 if (strip < 10) {
557 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "00" << strip << "_" << strip;
558 }
559 else if (strip < 100) {
560 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "0" << strip << "_" << strip;
561 }
562 else {
563 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << strip << "_" << strip;
564 }
565
566 m_NodeStrip[part][seg][gap][strip] = GetNode( osnameStrip.str() );
567 }
568 }
569 }
570 }
571
572 int absorberCount = gapCount;
573 for (int part = 0; part < GetPartNb(); part++) {
574 for (int seg = 0; seg < GetSegNb(part); seg++) {
575 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
576 std::stringstream osnameAbsorber;
577 osnameAbsorber << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber << "_" << absorberCount;
578 m_NodeAbsorber[part][seg][absorber] = GetNode( osnameAbsorber.str() );
579 absorberCount++;
580// if (part != 1) {
581// for (int panel = 0; panel < m_kPanelMax; panel++) { // end cap is the absorber panel, to be modified to an absorber
582// std::stringstream osnamePanel;
583// osnamePanel << "pv_" << "logical" << "Muc" << "Part" << part << "Seg" << seg << "Absorber" << absorber << "Panel" << panel << "_" << panel;
584// m_NodeAbsorberPanel[part][seg][absorber][panel] = GetNode( osnamePanel.str() );
585// }
586// }
587 }
588 }
589 }
590 }
591 else if (m_ROOTGeoInit == 1) { // from ROOT object
592 int gapCount = 0;
593 for (int part = 0; part < GetPartNb(); part++) {
594 for (int seg = 0; seg < GetSegNb(part); seg++) {
595 for (int gap = 0; gap < GetGapNb(part); gap++) {
596 m_NodeGap[part][seg][gap] = m_Muc->GetNode(gapCount);
597 gapCount++;
598
599 m_NodeStripPlane[part][seg][gap] = GetGap(part, seg, gap)->GetDaughter(0)->GetDaughter(0); //new geom: gap->box->stripplane
600 m_StripNum[part][seg][gap] = GetStripPlane(part, seg, gap)->GetNdaughters();
601
602 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
603 m_NodeStrip[part][seg][gap][strip] = GetStripPlane(part, seg, gap)->GetVolume()->GetNode(strip);
604 }
605 }
606 }
607 }
608
609 int absorberCount = gapCount;
610 for (int part = 0; part < GetPartNb(); part++) {
611 for (int seg = 0; seg < GetSegNb(part); seg++) {
612 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
613 m_NodeAbsorber[part][seg][absorber] = m_Muc->GetNode( absorberCount );
614 absorberCount++;
615
616// if (part != 1) {
617// for (int panel = 0; panel < m_kPanelMax; panel++) { // end cap is the absorber panel, to be modified to an absorber
618// m_NodeAbsorberPanel[part][seg][absorber][panel] = m_NodeAbsorber[part][seg][absorber]->GetVolume()->GetNode(panel);
619// }
620// }
621 }
622 }
623 }
624 }
625
626}
627
628void
630{
631 m_Muc->SetLineColor(m_MucColor);
632 m_Muc->SetVisibility(0);
633
634 for (int part = 0; part < GetPartNb(); part++) {
635 for (int seg = 0; seg < GetSegNb(part); seg++) {
636 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
637 GetVolumeAbsorber(part, seg, absorber)->SetLineColor(m_absorberColor);
638 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
639// if (part != 1) {
640// for (int panel = 0; panel < m_kPanel[part]; panel++) {
641// GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetLineColor(m_absorberColor);
642// GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(0);
643// }
644// }
645 }
646
647 for (int gap = 0; gap < GetGapNb(part); gap++) {
648 GetVolumeGap(part, seg, gap)->SetLineColor(m_gapColor);
649 GetVolumeGap(part, seg, gap)->SetVisibility(0);
650
651 GetVolumeBox(part, seg, gap)->SetLineColor(m_gapColor);
652 GetVolumeBox(part, seg, gap)->SetVisibility(0);
653
654 if (part == 1){
655 for (int sb = 0; sb < m_kSmallBlockMax; sb++){
656 GetVolumeAbsorberSmallBlock( gap, sb)->SetLineColor(m_absorberColor);
657 GetVolumeAbsorberSmallBlock( gap, sb)->SetVisibility(0);
658 }
659 }
660
661 GetVolumeStripPlane(part, seg, gap)->SetLineColor(m_gapColor);
662 GetVolumeStripPlane(part, seg, gap)->SetVisibility(0);
663
664 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
665 GetVolumeStrip(part, seg, gap, strip)->SetLineColor(m_stripColor);
666 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
667 }
668
669 for (int up = 0; up < 2; up ++){
670 GetVolumeBoxSurface(part, seg, gap, up)->SetLineColor(m_bakeliteColor); //need change
671 GetVolumeBoxSurface(part, seg, gap, up)->SetVisibility(0);
672 int seg_shift = 0;
673 if (part == 1 && seg == 2)seg_shift = 1;
674 for (int panel = 0; panel < m_kPanel[part] + seg_shift; panel++) {
675 GetVolumeGasChamber(part, seg, gap, up, panel)->SetLineColor(m_gasChamberColor);
676 GetVolumeGasChamber(part, seg, gap, up, panel)->SetVisibility(0);
677
678 GetVolumeGasBorder(part, seg, gap, up, panel)->SetLineColor(m_bakeliteColor);
679 GetVolumeGasBorder(part, seg, gap, up, panel)->SetVisibility(0);
680
681 }
682 for (int panel = 0; panel < m_kBakelitePanel[part][up] + seg_shift; panel++) {
683 for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
684 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetLineColor(m_bakeliteColor);
685 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetVisibility(0);
686 }
687 }
688 }
689
690// for (int panel = 0; panel < m_kPanel[part]; panel++) { //comment out 2007.1.2
691// for(int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
692// GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetLineColor(m_bakeliteColor);
693// GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(0);
694// }
695// for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
696// GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetLineColor(m_gasChamberColor);
697// GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(0);
698// }
699// }
700 }
701 }
702 }
703
704 for (int part = 0; part < GetPartNb(); part++) {
705 for (int seg = 0; seg < GetSegNb(part); seg++) {
706 for (int gap = 0; gap < GetGapNb(part); gap++) {
707 GetGap(part, seg, gap)->SetVisibility(0);
708 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
709 GetStrip(part, seg, gap, strip)->SetVisibility(0);
710 }
711 }
712 }
713 }
714
715}
716
717void
719{
720 m_Muc->SetLineColor(m_MucColor);
721 m_Muc->SetVisibility(0);
722
723 for (int part = 0; part < GetPartNb(); part++) {
724 for (int seg = 0; seg < GetSegNb(part); seg++) {
725 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
726 GetVolumeAbsorber(part, seg, absorber)->SetLineColor(m_absorberColor);
727 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
728// if (part != 1) {
729// for (int panel = 0; panel < m_kPanel[part]; panel++) {
730// GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetLineColor(m_absorberColor);
731// GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(0);
732// }
733// }
734 }
735
736 for (int gap = 0; gap < GetGapNb(part); gap++) {
737 GetVolumeGap(part, seg, gap)->SetLineColor(m_gapColor);
738 GetVolumeGap(part, seg, gap)->SetVisibility(1);
739
740 GetVolumeBox(part, seg, gap)->SetLineColor(m_stripColor);
741 GetVolumeBox(part, seg, gap)->SetVisibility(1);
742
743 if (part == 1){
744 for (int sb = 0; sb < m_kSmallBlockMax; sb++){
745 GetVolumeAbsorberSmallBlock( gap, sb)->SetLineColor(m_absorberColor);
746 GetVolumeAbsorberSmallBlock( gap, sb)->SetVisibility(1);
747 }
748 }
749
750 GetVolumeStripPlane(part, seg, gap)->SetLineColor(m_gapColor);
751 GetVolumeStripPlane(part, seg, gap)->SetVisibility(1);
752
753 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
754 GetVolumeStrip(part, seg, gap, strip)->SetLineColor(m_stripColor);
755 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(1);
756 }
757
758 for (int up = 0; up < 2; up ++){
759 GetVolumeBoxSurface(part, seg, gap, up)->SetLineColor(m_gapColor); //need change
760 GetVolumeBoxSurface(part, seg, gap, up)->SetVisibility(1);
761 int seg_shift = 0;
762 if (part == 1 && seg == 2)seg_shift = 1;
763 for (int panel = 0; panel < m_kPanel[part] + seg_shift; panel++) {
764 GetVolumeGasChamber(part, seg, gap, up, panel)->SetLineColor(m_gasChamberColor);
765 GetVolumeGasChamber(part, seg, gap, up, panel)->SetVisibility(1);
766
767 GetVolumeGasBorder(part, seg, gap, up, panel)->SetLineColor(m_bakeliteColor);
768 GetVolumeGasBorder(part, seg, gap, up, panel)->SetVisibility(1);
769 }
770 for (int panel = 0; panel < m_kBakelitePanel[part][up] + seg_shift; panel++) {
771 for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
772 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetLineColor(m_bakeliteColor);
773 GetVolumeBakelite(part, seg, gap, up, panel, bakelite)->SetVisibility(1);
774 }
775 }
776
777
778 }
779
780// for (int panel = 0; panel < m_kPanel[part]; panel++) { //comment out 2007.1.2
781// for(int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
782// GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetLineColor(m_bakeliteColor);
783// GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(0);
784// }
785// for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
786// GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetLineColor(m_gasChamberColor);
787// GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(0);
788// }
789// }
790 }
791 }
792 }
793
794 for (int part = 0; part < GetPartNb(); part++) {
795 for (int seg = 0; seg < GetSegNb(part); seg++) {
796 for (int gap = 0; gap < GetGapNb(part); gap++) {
797 GetGap(part, seg, gap)->SetVisibility(0);
798 for (int strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
799 GetStrip(part, seg, gap, strip)->SetVisibility(0);
800 }
801 }
802 }
803 }
804
805}
806
807
808void
810{
811 for (int part = 0; part < m_kPart; part++) {
812 for (int seg = 0; seg < m_kSeg[part]; seg++) {
813 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
814 if (part == 1) {
815 if (seg > 2) GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
816 }
817 else {
818 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
819 for (int panel = 0; panel < m_kPanel[part]; panel++) {
820 if (seg > 0 && seg < 3) GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
821 }
822 }
823 }
824
825 for (int gap = 0; gap < m_kGap[part]; gap++) {
826 if (part == 1 && seg > 2) {
827 GetVolumeGap(part, seg, gap)->SetVisibility(1);
828 GetGap(part, seg, gap)->SetVisibility(1);
829 }
830 else {
831 GetVolumeGap(part, seg, gap)->SetVisibility(0);
832 GetGap(part, seg, gap)->SetVisibility(0);
833 }
834 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
835 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
836 }
837
838// for (int panel = 0; panel < m_kPanel[part]; panel++) {
839// for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
840// if ((part != 1 && seg > 0 && seg < 3) || (part == 1 && seg > 2)) GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(1);
841// }
842// for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
843// if ((part != 1 && seg > 0 && seg < 3) || (part == 1 && seg > 2)) GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(1);
844// }
845// }
846 }
847 }
848 }
849}
850
851void
853{
854 for (int part = 0; part < m_kPart; part++) {
855 for (int seg = 0; seg < m_kSeg[part]; seg++) {
856 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
857 if (part == 1) {
858 if (seg < 3 || seg > 5) GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
859 }
860 else {
861 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
862 for (int panel = 0; panel < m_kPanel[part]; panel++) {
863 if (seg == 0 || seg == 3) GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
864 }
865 }
866 }
867
868 for (int gap = 0; gap < m_kGap[part]; gap++) {
869 if (part == 1 && (seg < 3 || seg > 5)) {
870 GetVolumeGap(part, seg, gap)->SetVisibility(1);
871 GetGap(part, seg, gap)->SetVisibility(1);
872 }
873 else {
874 GetVolumeGap(part, seg, gap)->SetVisibility(0);
875 GetGap(part, seg, gap)->SetVisibility(0);
876 }
877 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
878 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
879 }
880
881// for (int panel = 0; panel < m_kPanel[part]; panel++) {
882// for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
883// if (part != 1 && (seg == 0 || seg == 3)) GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(1);
884// }
885// for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
886// if (part != 1 && (seg == 0 || seg == 3)) GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(1);
887// }
888// }
889 }
890 }
891 }
892}
893
894void
896{
897 int part = 1;
898 for (int seg = 0; seg < m_kSeg[part]; seg++) {
899 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
900 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
901 }
902
903 for (int gap = 0; gap < m_kGap[part]; gap++) {
904 GetVolumeGap(part, seg, gap)->SetVisibility(1);
905 GetGap(part, seg, gap)->SetVisibility(1);
906 }
907 }
908}
909
910void
912{
913
914 if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
915 TGeoNode *bes = gGeoManager->GetTopNode();
916 TGeoNode *muc = bes->GetDaughter(3); //3->0
917
918 for (int part = 0; part < GetPartNb(); part++) {
919 for (int seg = 0; seg < GetSegNb(part); seg++) {
920 for (int gap = 0; gap < GetGapNb(part); gap++) {
921 TGeoNode *nodeGap = GetGap(part, seg, gap);
922 m_PhysicalGap[part][seg][gap] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
923 TString("/") + muc->GetName() +
924 TString("/") + nodeGap->GetName() +
925 TString("/") + nodeGap->GetDaughter(0)->GetName());
926
927 m_PhysicalGap[part][seg][gap]->SetVisibility(0);
928 m_PhysicalGap[part][seg][gap]->SetIsVolAtt(kFALSE);
929 m_PhysicalGap[part][seg][gap]->SetLineColor(m_gapColor);
930
931 TGeoNode *nodeStripPlane = GetStripPlane(part, seg, gap);
932
933 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
934 TGeoNode *nodeStrip = GetStrip(part, seg, gap, strip);
935 m_PhysicalStrip[part][seg][gap][strip] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
936 TString("/") + muc->GetName() +
937 TString("/") + nodeGap->GetName() +
938 TString("/") + nodeGap->GetDaughter(0)->GetName() +
939 TString("/") + nodeStripPlane->GetName() +
940 TString("/") + nodeStrip->GetName() );
941 m_PhysicalStrip[part][seg][gap][strip]->SetVisibility(0);
942 m_PhysicalStrip[part][seg][gap][strip]->SetIsVolAtt(kFALSE);
943 m_PhysicalStrip[part][seg][gap][strip]->SetLineColor(m_stripColor);
944 }
945 }
946 }
947 }
948
949 for (int part = 0; part < GetPartNb(); part++) {
950 for (int seg = 0; seg < GetSegNb(part); seg++) {
951 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
952 TGeoNode *nodeAbsorber = GetAbsorber(part, seg, absorber);
953// if (part == 1) {
954 m_PhysicalAbsorber[part][seg][absorber][0] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
955 TString("/") + muc->GetName() +
956 TString("/") + nodeAbsorber->GetName() );
957 m_PhysicalAbsorber[part][seg][absorber][0]->SetVisibility(0);
958 m_PhysicalAbsorber[part][seg][absorber][0]->SetIsVolAtt(kFALSE);
959 m_PhysicalAbsorber[part][seg][absorber][0]->SetLineColor(m_absorberColor);
960// }
961// else {
962// for (int panel = 0; panel < m_kPanelMax; panel++) {
963// TGeoNode *nodeAbsorberPanel = GetAbsorberPanel(part, seg, absorber, panel);
964// m_PhysicalAbsorber[part][seg][absorber][panel] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
965// TString("/") + muc->GetName() +
966// TString("/") + nodeAbsorber->GetName() +
967// TString("/") + nodeAbsorberPanel->GetName() );
968// m_PhysicalAbsorber[part][seg][absorber][panel]->SetVisibility(0);
969// m_PhysicalAbsorber[part][seg][absorber][panel]->SetIsVolAtt(kFALSE);
970// m_PhysicalAbsorber[part][seg][absorber][panel]->SetLineColor(m_absorberColor);
971// }
972// }
973 }
974 }
975 }
976
977 SetDetector();
978}
979
980void
982{
983 BesView *view = 0;
984 if (gPad) view = (BesView*)gPad->GetView();
985
986 m_DetectorsArray->Clear();
987 for (int part = 0; part < GetPartNb(); part++) {
988 for (int seg = 0; seg < GetSegNb(part); seg++) {
989 for (int gap = 0; gap < GetGapNb(part); gap++) {
990 TGeoPhysicalNode *phyNode = 0;
991 phyNode = GetPhysicalGap(part, seg, gap);
992 if (phyNode) {
993 phyNode->SetVisibility(0); // set all invisible before set any visible
994 if ( (part == 1 && seg <= 8) ||
995 (part == 0 && seg <= 3) ||
996 (part == 2 && seg <= 3) ) {
997 m_DetectorsArray->Add( phyNode );
998 }
999 else if (view && view->GetVisFull3DMuc()) {
1000 m_DetectorsArray->Add( phyNode );
1001 }
1002 }
1003 }
1004 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
1005 for (int panel = 0; panel < m_kPanelMax; panel++) {
1006 TGeoPhysicalNode *phyNode = 0;
1007 phyNode = GetPhysicalAbsorber(part, seg, absorber, panel);
1008 if (phyNode) {
1009 phyNode->SetVisibility(0);
1010 if ( (part == 1 && seg <= 8) ||
1011 (part == 0 && seg <= 3) ||
1012 (part == 2 && seg <= 3) ) {
1013 m_DetectorsArray->Add( phyNode );
1014 }
1015 else if (view && view->GetVisFull3DMuc()) {
1016 m_DetectorsArray->Add( phyNode );
1017 }
1018 }
1019 }
1020 }
1021 }
1022 }
1023
1024}
1025
1026void
1028{
1029 // set previous event hits to default vis
1030 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
1031 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
1032 phyNode->SetLineColor(m_stripColor);
1033 phyNode->SetVisibility(0);
1034 }
1035 m_HitsArray->Clear("C");
1036
1037 // set previous event 2D hits info to default
1038 for (int i = 0; i < m_2DHitsArray->GetEntries(); i++) {
1039 Muc2DStrip *aStrip = (Muc2DStrip*)m_2DHitsArray->At(i);
1040 aStrip->ClearInfo();
1041 aStrip->AddInfo(aStrip->GetTitle());
1042 aStrip->CloseInfo();
1043 }
1044 m_2DHitsArray->Clear("C");
1045
1046 if (gEvent) m_MucDigiCol = gEvent->GetMucDigiCol();
1047
1048 for (int i = 0; i < m_MucDigiCol->GetEntries(); i++) {
1049 Identifier aMucID( ((TMucDigi*)m_MucDigiCol->At(i))->getIntId() );
1050 int part = MucID::part( aMucID );
1051 int seg = MucID::seg( aMucID );
1052 int gap = MucID::gap( aMucID );
1053 int strip = MucID::strip( aMucID );
1054
1055 TGeoPhysicalNode *phyNode = 0;
1056 phyNode = GetPhysicalStrip( part, seg, gap, strip );
1057 if (phyNode) m_HitsArray->Add( phyNode );
1058
1059 Muc2DStrip *aStrip = 0;
1060 aStrip = m_Muc2DStrip[part][seg][gap][strip];
1061 if (aStrip) {
1062 aStrip->ClearInfo();
1063 aStrip->AddInfo(aStrip->GetTitle());
1064
1065 char data[100];
1066 sprintf(data, "Fired");
1067 aStrip->AddInfo( TString(data) );
1068
1069 aStrip->CloseInfo();
1070
1071 m_2DHitsArray->Add(aStrip);
1072 }
1073 }
1074}
1075
1076void
1078{
1079 BesView *view = 0;
1080 if (gPad) view = (BesView*)gPad->GetView();
1081
1082 for (int i = 0; i < m_DetectorsArray->GetEntries(); i++) {
1083 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At(i);
1084 phyNode->SetVisibility(0);
1085
1086 if (view && view->GetVisMucGlobal()) {
1087 int part = GetPart(phyNode);
1088 if (part == 0 && view->GetVisMucEast() ||
1089 part == 1 && view->GetVisMucBarrel() ||
1090 part == 2 && view->GetVisMucWest() )
1091 phyNode->SetVisibility(1);
1092 }
1093 }
1094}
1095
1096void
1098{
1099 BesView *view = 0;
1100 if (gPad) view = (BesView*)gPad->GetView();
1101
1102 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
1103 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
1104 if (view && view->GetVisMucHitsGlobal()) {
1105 int part = GetPart(phyNode);
1106 if (part == 0 && view->GetVisMucHitsEast() ||
1107 part == 1 && view->GetVisMucHitsBarrel() ||
1108 part == 2 && view->GetVisMucHitsWest() ) {
1109 phyNode->SetVisibility(1);
1110 //phyNode->SetLineColor(kRed);
1111 continue;
1112 }
1113 }
1114 phyNode->SetVisibility(0);
1115 }
1116}
1117
1118int
1120{
1121 int part = m_kPart;
1122 return part;
1123}
1124
1125int
1127{
1128 int seg = m_kSeg[part];
1129 return seg;
1130}
1131
1132int
1134{
1135 int gap = m_kGap[part];
1136 return gap;
1137}
1138
1139int
1140MucROOTGeo::GetStripNb(int part, int seg, int gap)
1141{
1142 int strip = m_StripNum[part][seg][gap];
1143 return strip;
1144}
1145
1146int
1148{
1149 int absorber = m_kAbsorber[part];
1150 return absorber;
1151}
1152
1153TGeoVolume*
1154MucROOTGeo::GetVolumeAbsorber( int part, int seg, int absorber )
1155{
1156 std::stringstream osname;
1157 osname << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber;
1158
1159 return GetLogicalVolume( osname.str() );
1160}
1161
1162TGeoVolume*
1164{
1165 std::stringstream osname;
1166 osname << "VolumeSmallBlock" << "Gap" << gap << "SB" << sb;
1167
1168 return GetLogicalVolume( osname.str() );
1169}
1170
1171
1172
1173TGeoVolume*
1174MucROOTGeo::GetVolumeAbsorberPanel( int part, int seg, int absorber, int panel )
1175{
1176 std::stringstream osname; //useless now 2007.1.2
1177 osname << "logical" << "Muc" << "Part" << part << "Seg" << seg << "Absorber" << absorber << "Panel" << panel;
1178
1179 return GetLogicalVolume( osname.str() );
1180}
1181
1182TGeoVolume*
1183MucROOTGeo::GetVolumeGap( int part, int seg, int gap )
1184{
1185 std::stringstream osname;
1186 osname << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap;
1187
1188 return GetLogicalVolume( osname.str() );
1189}
1190
1191TGeoVolume*
1192MucROOTGeo::GetVolumeBox( int part, int seg, int gap)
1193{
1194 std::stringstream osname;
1195 osname << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "Al";
1196
1197 return GetLogicalVolume( osname.str() );
1198}
1199
1200TGeoVolume*
1201MucROOTGeo::GetVolumeBoxSurface( int part, int seg, int gap ,int up)
1202{
1203 std::stringstream osname;
1204 int segment = 0;
1205 if (part ==1 && seg ==2) segment = 2;
1206 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "AlSf" <<up;
1207
1208 return GetLogicalVolume( osname.str() );
1209}
1210
1211TGeoVolume*
1212MucROOTGeo::GetVolumeStripPlane( int part, int seg, int gap )
1213{
1214 int segment = 0;
1215 if (part==1&&seg==2) segment = 2;
1216 std::stringstream osname;
1217 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP";
1218
1219 return GetLogicalVolume( osname.str() );
1220}
1221
1222TGeoVolume*
1223MucROOTGeo::GetVolumeStrip( int part, int seg, int gap, int strip )
1224{
1225 std::stringstream osname;
1226 int segment = 0;
1227 if (part == 1 && seg == 2) segment = 2;
1228 if (strip < 10) {
1229 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "00" << strip;
1230 }
1231 else if (strip<100){
1232 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "0" << strip;
1233 }
1234 else {
1235 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << strip;
1236 }
1237
1238 return GetLogicalVolume( osname.str() );
1239}
1240
1241TGeoVolume*
1242MucROOTGeo::GetVolumeGasChamber( int part, int seg, int gap, int rpcUpDown, int panel )
1243{
1244 std::stringstream osname;
1245 int segment = 0;
1246 if (part ==1 && seg ==2) segment = 2;
1247 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "R" << rpcUpDown << "Pn" << panel << "C";
1248
1249 return GetLogicalVolume( osname.str() );
1250}
1251
1252TGeoVolume*
1253MucROOTGeo::GetVolumeGasBorder( int part, int seg, int gap, int rpcUpDown, int panel )
1254{
1255 std::stringstream osname;
1256 int segment = 0;
1257 if (part ==1 && seg ==2) segment = 2;
1258 osname << "l" << "Muc" << "P" << part%2 << "S" << segment << "G" << gap << "R" << rpcUpDown << "Pn" << panel << "GB";
1259
1260 return GetLogicalVolume( osname.str() );
1261}
1262
1263TGeoVolume*
1264MucROOTGeo::GetVolumeBakelite( int part, int seg, int gap, int RpcUpDown, int panel, int bakelite )
1265{
1266 std::stringstream osname;
1267 int segment = 0;
1268 if (part ==1 && seg ==2) segment = 2;
1269 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "R" << RpcUpDown << "Pn" << panel<< "B" << bakelite;
1270
1271 return GetLogicalVolume( osname.str() );
1272}
1273
1274TGeoNode*
1275MucROOTGeo::GetAbsorber( int part, int seg, int absorber )
1276{
1277 if (m_NodeAbsorber[part][seg][absorber] != 0) {
1278 return m_NodeAbsorber[part][seg][absorber];
1279 }
1280 else {
1281 return 0;
1282 }
1283}
1284
1285TGeoNode*
1286MucROOTGeo::GetAbsorberPanel( int part, int seg, int absorber, int panel )
1287{
1288 if (m_NodeAbsorberPanel[part][seg][absorber][panel] != 0) {
1289 return m_NodeAbsorberPanel[part][seg][absorber][panel];
1290 }
1291 else {
1292 return 0;
1293 }
1294}
1295
1296TGeoNode*
1297MucROOTGeo::GetGap( int part, int seg, int gap )
1298{
1299 if (m_NodeGap[part][seg][gap] != 0) {
1300 return m_NodeGap[part][seg][gap];
1301 }
1302 else {
1303 return 0;
1304 }
1305}
1306
1307TGeoNode*
1308MucROOTGeo::GetStripPlane( int part, int seg, int gap )
1309{
1310 if (m_NodeStripPlane[part][seg][gap] != 0) {
1311 return m_NodeStripPlane[part][seg][gap];
1312 }
1313 else {
1314 return 0;
1315 }
1316}
1317
1318TGeoNode*
1319MucROOTGeo::GetStrip( int part, int seg, int gap, int strip )
1320{
1321 if (m_NodeStrip[part][seg][gap][strip] != 0) {
1322 return m_NodeStrip[part][seg][gap][strip];
1323 }
1324 else {
1325 return 0;
1326 }
1327}
1328
1329TGeoPhysicalNode*
1330MucROOTGeo::GetPhysicalAbsorber( int part, int seg, int absorber, int panel )
1331{
1332 return m_PhysicalAbsorber[part][seg][absorber][panel];
1333}
1334
1335TGeoPhysicalNode*
1336MucROOTGeo::GetPhysicalGap( int part, int seg, int gap )
1337{
1338 if (m_PhysicalGap[part][seg][gap] != 0) {
1339 return m_PhysicalGap[part][seg][gap];
1340 }
1341 else {
1342 return 0;
1343 }
1344}
1345
1346TGeoPhysicalNode*
1347MucROOTGeo::GetPhysicalStrip( int part, int seg, int gap, int strip )
1348{
1349 if (m_PhysicalStrip[part][seg][gap][strip] != 0) {
1350 return m_PhysicalStrip[part][seg][gap][strip];
1351 }
1352 else {
1353 return 0;
1354 }
1355}
1356
1358MucROOTGeo::Get2DStrip( int part, int seg, int gap, int strip )
1359{
1360 if (m_Muc2DStrip[part][seg][gap][strip]) return m_Muc2DStrip[part][seg][gap][strip];
1361 else return 0;
1362}
1363
1364int
1365MucROOTGeo::GetPart(TGeoPhysicalNode* phyNode)
1366{
1367 for (int part = 0; part < GetPartNb(); part++) {
1368 for (int seg = 0; seg < GetSegNb(part); seg++) {
1369 for (int gap = 0; gap < GetGapNb(part); gap++) {
1370 if (phyNode == GetPhysicalGap(part, seg, gap)) {
1371 return part;
1372 }
1373 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
1374 if (phyNode == GetPhysicalStrip(part, seg, gap, strip)) {
1375 return part;
1376 }
1377 }
1378 }
1379 for (int absorber = 0; absorber < GetAbsorberNb(part); absorber++) {
1380 for (int panel = 0; panel < m_kPanelMax; panel++) {
1381 if (phyNode == GetPhysicalAbsorber(part, seg, absorber, panel)) {
1382 return part;
1383 }
1384 }
1385 }
1386 }
1387 }
1388
1389 return -1;
1390}
1391
1392Bool_t
1393MucROOTGeo::IsZRVisible( int part, int seg )
1394{
1395 if (part != 1) return true;
1396
1397 BesView *view = (BesView*)gPad->GetView();
1398 Double_t viewPhi = view->GetLongitude();
1399 viewPhi = Range360(viewPhi);
1400
1401 Int_t viewSeg = Int_t(viewPhi/45.0+0.5);
1402 Int_t upSeg = viewSeg+2;
1403 Int_t downSeg = viewSeg-2;
1404 if (upSeg < 0) upSeg += 8;
1405 else if (upSeg >= 8) upSeg -= 8;
1406 if (downSeg < 0) downSeg += 8;
1407 else if (downSeg >= 8) downSeg -= 8;
1408
1409 if (seg == upSeg || seg == downSeg) return true;
1410 else return false;
1411}
1412
1413Double_t
1415{
1416 if (input >= 360.0) {
1417 do {
1418 input -= 360.0;
1419 }
1420 while (input >= 360.0);
1421 }
1422 else if (input < 0.0) {
1423 do {
1424 input += 360.0;
1425 }
1426 while (input < 0.0);
1427 }
1428
1429 return input;
1430}
1431
1432void
1433MucROOTGeo::Draw(Option_t *option)
1434{
1435 TString opt = option;
1436 opt.ToUpper();
1437
1438 if (!m_2DGeoInit) cout << "MucROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
1439 BesView *view = (BesView*)gPad->GetView();
1440 if (!view) cout << "MucROOTGeo::Draw(), BesView not found" << endl;
1441
1442 if (view->GetVisMucGlobal()) { // MucVisGlobal
1443 // seg and gap
1444 for (Int_t part = GetPartNb()-1; part >= 0; part--) { // draw west first
1445 if ( (part == 0 && view->GetVisMucEast()) ||
1446 (part == 1 && view->GetVisMucBarrel()) ||
1447 (part == 2 && view->GetVisMucWest()) ) {
1448 for (Int_t seg = 0; seg < GetSegNb(part); seg++) {
1449 if (opt.Contains("XY")) {
1450 if (m_MucXY[part][seg]) m_MucXY[part][seg]->Draw("");
1451 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
1452 if (m_MucXYGap[part][seg][gap]) m_MucXYGap[part][seg][gap]->Draw("");
1453 }
1454 }
1455 if (opt.Contains("ZR")) {
1456 if ( m_MucZR[part][seg] ) { // && IsZRVisible(part, seg) ) {
1457 if (part == 1) m_MucZR[part][seg]->SetRotatable(true);
1458 m_MucZR[part][seg]->Draw("");
1459 }
1460 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
1461 if (m_MucZRGap[part][seg][gap]) {
1462 if (part == 1) m_MucZRGap[part][seg][gap]->SetRotatable(true);
1463 m_MucZRGap[part][seg][gap]->Draw("");
1464 }
1465 }
1466 }
1467 }
1468 }
1469 }
1470
1471 // strips, should be drawn after all segs and gaps have been drawn
1472 for (Int_t part = GetPartNb()-1; part >= 0; part--) { // draw west first
1473 for (Int_t seg = 0; seg < GetSegNb(part); seg++) {
1474 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
1475 for (Int_t strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
1476 if (m_Muc2DStrip[part][seg][gap][strip]) {
1477 m_Muc2DStrip[part][seg][gap][strip]->SetFired(false);
1478 if ( (part == 0 && view->GetVisMucEast()) ||
1479 (part == 1 && view->GetVisMucBarrel()) ||
1480 (part == 2 && view->GetVisMucWest()) ) {
1481 m_Muc2DStrip[part][seg][gap][strip]->Draw("");
1482 }
1483 }
1484 }
1485 }
1486 }
1487 }
1488
1489 }
1490}
1491
1492void
1493MucROOTGeo::DrawHits(Option_t *option)
1494{
1495 BesView *view = (BesView*)gPad->GetView();
1496 if (!view) cout << "MucROOTGeo::DrawHits(), BesView not found" << endl;
1497
1498
1499 if (view->GetVisMucHitsGlobal()) {
1500
1501 /*
1502 for (Int_t part = GetPartNb()-1; part >= 0; part--) { // draw west first
1503 for (Int_t seg = 0; seg < GetSegNb(part); seg++) {
1504 for (Int_t gap = 0; gap < GetGapNb(part); gap++) {
1505 for (Int_t strip = 0; strip < GetStripNb(part, seg, gap); strip++) {
1506 if (m_Muc2DStrip[part][seg][gap][strip]) m_Muc2DStrip[part][seg][gap][strip]->ClearInfo();
1507 }
1508 }
1509 }
1510 }*/
1511
1512 if (m_MucDigiCol) {
1513 for (int i = 0; i < m_MucDigiCol->GetEntries(); i++) {
1514 TMucDigi *aMucDigi = (TMucDigi*)m_MucDigiCol->At(i);
1515
1516 //cout << aMucDigi->getIntId() << endl;
1517 Identifier aMucID( aMucDigi->getIntId() );
1518 int part = MucID::part( aMucID );
1519 int seg = MucID::seg( aMucID );
1520 int gap = MucID::gap( aMucID );
1521 int strip = MucID::strip( aMucID );
1522
1523 Muc2DStrip *aStrip = 0;
1524 aStrip = m_Muc2DStrip[part][seg][gap][strip];
1525 if (aStrip) {
1526 if ( (part == 0 && view->GetVisMucHitsEast()) ||
1527 (part == 1 && view->GetVisMucHitsBarrel()) ||
1528 (part == 2 && view->GetVisMucHitsWest()) ) {
1529 aStrip->SetFired(true);
1530 aStrip->Draw();
1531 }
1532 }
1533 }
1534 }
1535 }
1536}
1537
double P(RecMdcKalTrack *trk)
TTree * data
Double_t x[10]
virtual void Draw(Option_t *option="")
virtual void Draw(Option_t *option="")
Definition: Muc2DStrip.cxx:204
virtual void ClearInfo()
Definition: Muc2DStrip.cxx:119
virtual void CloseInfo()
Definition: Muc2DStrip.cxx:125
static int part(const Identifier &id)
Definition: MucID.cxx:46
static int gap(const Identifier &id)
Definition: MucID.cxx:66
static int seg(const Identifier &id)
Definition: MucID.cxx:56
static int strip(const Identifier &id)
Definition: MucID.cxx:76
TGeoVolume * GetVolumeStripPlane(int part, int seg, int gap)
Get strip plane volume;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
int GetGapNb(int part)
Get number of gap on part;.
void SetDetector()
Set Detecor (what is detector depends on you)
void SetVolumeDefaultVis()
Set default visual attributes;.
TGeoVolume * GetVolumeGasChamber(int part, int seg, int gap, int panel, int gasChamber)
Get rpc gas chamber volume;
int GetAbsorberNb(int part)
Get number of absorber on part;.
TGeoPhysicalNode * GetPhysicalStrip(int part, int seg, int gap, int strip)
Get strip physical node;.
TGeoVolume * GetVolumeBox(int part, int seg, int gap)
Get box volume;
TGeoVolume * GetVolumeBakelite(int part, int seg, int gap, int panel, int bakelite)
Get rpc bakelite volume;
TGeoVolume * GetVolumeGasBorder(int part, int seg, int gap, int panel, int gasChamber)
Get rpc gas border volume;
Double_t Range360(Double_t input)
Get input value 0~360.
void SetNode()
Set the pointers to theirs nodes;.
void SetVolumeMuc(TGeoVolume *vol)
Set Muc volume, while initializing from ROOT;.
TGeoVolume * GetVolumeAbsorberPanel(int part, int seg, int absorber, int panel)
Get absorber panel volume;
TGeoNode * GetAbsorber(int part, int seg, int absorber)
Get absorber node;
Bool_t IsZRVisible(int part, int seg)
Is a segment visible in ZR view.
void SetVisMucDetector()
Set Muc detector visibility;.
Int_t GetPart(TGeoPhysicalNode *phyNode)
Get part no of a physcial node.
int GetSegNb(int part)
Get number of segment on part;.
TGeoVolume * GetVolumeGap(int part, int seg, int gap)
Get gap volume;
void SetHits()
Set all physicalNodes corresponding to digiCol;.
TGeoVolume * GetVolumeBoxSurface(int part, int seg, int gap, int up)
Get box surface volume;
TGeoNode * GetGap(int part, int seg, int gap)
Get absorber node;
TGeoNode * GetStripPlane(int part, int seg, int gap)
Get box node;.
TGeoVolume * GetVolumeStrip(int part, int seg, int gap, int strip)
Get strip volume;
TGeoVolume * GetVolumeAbsorber(int part, int seg, int absorber)
Get absorber volume;
TGeoPhysicalNode * GetPhysicalGap(int part, int seg, int gap)
Get rpc gas chamber node;
TGeoNode * GetStrip(int part, int seg, int gap, int strip)
Get strip node;
TGeoPhysicalNode * GetPhysicalAbsorber(int part, int seg, int gap, int panel)
Get rpc gas chamber node;
int GetStripNb(int part, int seg, int gap)
Get number of strip on gap;.
Muc2DStrip * Get2DStrip(int part, int seg, int gap, int strip)
Get Muc2DStrip;.
TGeoVolume * GetVolumeAbsorberSmallBlock(int gap, int sb)
Get absorber small block;.
TGeoNode * GetAbsorberPanel(int part, int seg, int absorber, int panel)
Get absorber panel node;
void InitFromGDML(const char *gdmlFile, const char *setupName)
Initialize ROOTGeo from GDML.
void InitFromROOT(TGeoVolume *vol)
Initialize ROOTGeo from TGeoVolume logicalMuc.
TGeoNode * GetNode(const std::string &nn)
Get a node(physical volume) by name;.
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.
UInt_t getIntId() const
Definition: TRawData.cxx:50