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