BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EventDisplay/BesVisLib/src/TofROOTGeo.cxx
Go to the documentation of this file.
1//$id$
2/*
3 * 2004/11/29 Zhengyun You Peking University
4 * Tof Geometry General for EventDisplay
5 *
6 * 2004/12/9 Zhengyun You Peking University
7 * named from TofGeo to TofROOTGeo
8 * inherit from class SubDetectorROOTGeo
9 */
10
11using namespace std;
12
13#include <fstream>
14#include <iomanip>
15#include <iostream>
16#include <sstream>
17#include <string>
18#include <vector>
19
20#include <TGeoArb8.h>
21#include <TGeoManager.h>
22#include <TGeoNode.h> //...
23#include <TGeoTrd2.h> //Huang Shuhui's update: For Mrpc
24#include <TGeoTube.h>
25#include <TMath.h>
26
27#include "BesVisLib/BesEvent.h"
28#include "BesVisLib/BesView.h"
29#include "BesVisLib/TofROOTGeo.h"
30#include "Identifier/TofID.h"
31#include "RawEvent/RawDataUtil.h"
32
34 // Default constructor.
35 k_TMatch = kTRUE;
36 k_QMatch = kTRUE;
37 for ( int part = 0; part < m_kPart; part++ )
38 {
39 // Long Peixun's update: m_kLayerBr -> m_kModuleEc
40 for ( int layer = 0; layer < m_kModuleEc; layer++ )
41 {
42 if ( layer < 2 )
43 {
44 m_NodeAl[part][layer] = nullptr;
45 m_NodeScin[part][layer] = nullptr;
46 }
47
48 for ( int scin = 0; scin < m_kScinBr; scin++ )
49 {
50 if ( layer < 2 ) m_NodePVF[part][layer][scin] = nullptr;
51
52 m_PhysicalScin[part][layer][scin] = nullptr;
53 m_Tof2DScin[part][layer][scin] = nullptr;
54 }
55 }
56 }
57
58 // Huang Shuhui's update: For Mrpc
59 fTofMrpc = 0;
60
61 // Long Peixun's update: Merge m_PhysicalMrpc into m_PhysicalScin
62 // for (int part = 0; part < m_kPart; part++)
63 //{
64 // for (int module = 0; module < m_kModuleEc; module++)
65 // {
66 // m_NodeModule[part][module] = 0;
67 // for (int strip = 0; strip < m_kStripEc; strip++)
68 // {
69 // m_PhysicalMrpc[part][module][strip] = 0;
70 // }
71 // }
72 //}
73
74 m_TofColor = 6;
75 m_BucketColor = 4;
76 m_ScinColor = kYellow;
77}
78
80 // Long Peixun's update: Add destructor
81 cout << "delete old TofROOTGeo" << endl;
82 for ( int part = 0; part < m_kPart; part++ )
83 {
84 for ( int layer = 0; layer < m_kModuleEc; layer++ )
85 {
86 for ( int scin = 0; scin < m_kScinBr; scin++ ) { delete m_Tof2DScin[part][layer][scin]; }
87 }
88 }
89}
90
91void TofROOTGeo::InitFromGDML( const char* gdmlFile, const char* setupName ) {
92 m_ROOTGeoInit = 2;
93
94 // Huang Shuhui's update: Load in Tof_mrpc Gdml Geometry, set fTofMrpc flag
95 fTofMrpc = 0;
96 if ( TString( gdmlFile ).Contains( "Tof_mrpc.gdml" ) ) fTofMrpc = 1;
97 else cout << "Cannot read Tof_mrpc!" << endl;
98 if ( fTofMrpc )
99 cout << "fTofMrpc: "
100 << "Using new Geometry of Tof!" << endl;
101
102 ReadGdml( gdmlFile, setupName );
103 SetNode();
104}
105
106void TofROOTGeo::InitFromROOT( TGeoVolume* vol ) {
107 m_ROOTGeoInit = 1;
108
109 // Huang Shuhui's update: To judge MRPC
110 fTofMrpc = 0;
111 TGeoNode* contianer = vol->GetNode( 0 )->GetVolume()->GetNode( 0 );
112 if ( TString( contianer->GetName() ).Contains( "container" ) ) fTofMrpc = 1;
113 if ( fTofMrpc )
114 cout << "fTofMrpc: "
115 << "Using new Geometry of Tof!" << endl;
116
117 SetVolumeTof( vol );
118 SetNode();
119}
120
122 if ( m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2 )
123 {
124 cout << "TofROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
125 return;
126 }
127 m_2DGeoInit = 1;
128
129 Double_t local[3] = { 0.0, 0.0, 0.0 };
130 Double_t master[3] = { 0.0, 0.0, 0.0 };
131 // Int_t nPoints = 8;
132 // Double_t P[300] = {0.0};
133 // Double_t center[3] = {0.0, 0.0, 0.0};
134 TString name;
135
136 // Huang Shuhui's update: Tof Mrpc
137 if ( fTofMrpc )
138 {
139 for ( Int_t part = 0; part < m_kPart; part++ )
140 {
141 if ( part == 1 )
142 {
143 for ( Int_t layer = 0; layer < GetLayerNb( part ); layer++ )
144 {
145 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
146 {
147 TGeoPhysicalNode* scinPhyNode = GetPhysicalScin( part, layer, scin );
148 if ( part == 1 )
149 {
150 name = TString( "Tof Part 1" );
151 name += " Layer ";
152 name += layer;
153 name += " Phi ";
154 name += scin;
155 }
156 TGeoArb8* scinShape = (TGeoArb8*)scinPhyNode->GetShape();
157 Double_t *localArb8Point, masterArb8Point[24];
158 localArb8Point = scinShape->GetVertices();
159
160 for ( Int_t i = 0; i < 8; i++ )
161 {
162 local[0] = localArb8Point[2 * i];
163 local[1] = localArb8Point[2 * i + 1];
164 if ( i < 4 ) local[2] = scinShape->GetDz() * ( -1.0 );
165 else local[2] = scinShape->GetDz();
166
167 // cout << i << " local x: " << local[0] << " y: " << local[1] << " z: " <<
168 // local[2] << endl;
169 scinPhyNode->GetMatrix( -1 * scinPhyNode->GetLevel() )
170 ->LocalToMaster( local, &master[0] ); // transform to top
171 // cout << " master x: " << master[0] << " y: " << master[1] << " z: " <<
172 // master[2] << endl;
173
174 for ( Int_t j = 0; j < 3; j++ ) { masterArb8Point[3 * i + j] = master[j]; }
175 }
176
177 m_Tof2DScin[part][layer][scin] =
178 new Tof2DScin( name, name, 8, &masterArb8Point[0], part );
179 } // scin
180 } // layer
181 } // part = 1
182 else
183 {
184 for ( int module = 0; module < GetModuleNb( part ); module++ )
185 {
186 for ( int strip = 0; strip < GetStripNb( part ); strip++ )
187 {
188 TGeoPhysicalNode* mrpcPhyNode = GetPhysicalScin( part, module, strip );
189 if ( part == 0 )
190 {
191 name = TString( "EastEc" );
192 name = TString( "Tof Part" );
193 name += part;
194 name += " Module ";
195 name += module;
196 name += " Strip ";
197 name += strip;
198 }
199 else if ( part == 2 )
200 {
201 name = TString( "WestEc" );
202 name = TString( "Tof Part" );
203 name += part;
204 name += " Module ";
205 name += module;
206 name += " Strip ";
207 name += strip;
208 }
209
210 TGeoTrd2* mrpcShape = (TGeoTrd2*)mrpcPhyNode->GetShape();
211
212 Double_t x1, x2, y1, y2, z;
213 x1 = mrpcShape->GetDx1();
214 x2 = mrpcShape->GetDx2();
215 y1 = mrpcShape->GetDy1() * 500; // *500, make mrpc thick in ZR view
216 y2 = mrpcShape->GetDy2() * 500; // *500, make mrpc thick in ZR view
217 z = mrpcShape->GetDz();
218 Double_t masterArb8Point[24];
219
220 for ( Int_t i = 0; i < 8; i++ )
221 {
222 if ( i == 0 )
223 {
224 local[0] = -x1;
225 local[1] = -y1;
226 local[2] = -z;
227 }
228 else if ( i == 4 )
229 {
230 local[0] = -x1;
231 local[1] = y1;
232 local[2] = -z;
233 }
234 else if ( i == 7 )
235 {
236 local[0] = x1;
237 local[1] = y1;
238 local[2] = -z;
239 }
240 else if ( i == 3 )
241 {
242 local[0] = x1;
243 local[1] = -y1;
244 local[2] = -z;
245 }
246 else if ( i == 1 )
247 {
248 local[0] = -x2;
249 local[1] = -y2;
250 local[2] = z;
251 }
252 else if ( i == 5 )
253 {
254 local[0] = -x2;
255 local[1] = y2;
256 local[2] = z;
257 }
258 else if ( i == 6 )
259 {
260 local[0] = x2;
261 local[1] = y2;
262 local[2] = z;
263 }
264 else if ( i == 2 )
265 {
266 local[0] = x2;
267 local[1] = -y2;
268 local[2] = z;
269 }
270
271 mrpcPhyNode->GetMatrix( -1 * mrpcPhyNode->GetLevel() )
272 ->LocalToMaster( local, &master[0] ); // transform to top
273 for ( Int_t j = 0; j < 3; j++ ) { masterArb8Point[3 * i + j] = master[j]; }
274 }
275
276 m_Tof2DScin[part][module][strip] =
277 new Tof2DScin( name, name, 8, &masterArb8Point[0], part );
278 } // strip
279 } // module
280 } // part = 0/2
281 } // part
282 }
283 else // Old Tof Geometry
284 {
285 // Tof Scintillators
286 for ( Int_t part = 0; part < m_kPart; part++ )
287 {
288 for ( Int_t layer = 0; layer < GetLayerNb( part ); layer++ )
289 {
290 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
291 {
292 TGeoPhysicalNode* scinPhyNode = GetPhysicalScin( part, layer, scin );
293 if ( part == 1 )
294 {
295 name = TString( "Tof Part 1" );
296 name += " Layer ";
297 name += layer;
298 name += " Phi ";
299 name += scin;
300 }
301 else
302 {
303 if ( part == 0 ) name = TString( "EastEc" );
304 else if ( part == 2 ) name = TString( "WestEc" );
305 name = TString( "Tof Part " );
306 name += part;
307 name += " Phi ";
308 name += scin;
309 }
310 TGeoArb8* scinShape = (TGeoArb8*)scinPhyNode->GetShape();
311 Double_t *localArb8Point, masterArb8Point[24];
312 localArb8Point = scinShape->GetVertices();
313
314 for ( Int_t i = 0; i < 8; i++ )
315 {
316 local[0] = localArb8Point[2 * i];
317 local[1] = localArb8Point[2 * i + 1];
318 if ( i < 4 ) local[2] = scinShape->GetDz() * ( -1.0 );
319 else local[2] = scinShape->GetDz();
320
321 // cout << i << " local x: " << local[0] << " y: " << local[1] << " z: " <<
322 // local[2] << endl;
323 scinPhyNode->GetMatrix( -1 * scinPhyNode->GetLevel() )
324 ->LocalToMaster( local, &master[0] ); // transform to top
325 // cout << " master x: " << master[0] << " y: " << master[1] << " z: " << master[2]
326 // << endl;
327
328 for ( Int_t j = 0; j < 3; j++ ) { masterArb8Point[3 * i + j] = master[j]; }
329 }
330
331 m_Tof2DScin[part][layer][scin] =
332 new Tof2DScin( name, name, 8, &masterArb8Point[0], part );
333 }
334 } // scin
335 } // layer
336 } // part
337}
338
339void TofROOTGeo::SetNode() {
340 if ( m_ROOTGeoInit == 2 )
341 { // from GDML
342 m_Tof = GetTopVolume();
343 if ( !m_Tof ) std::cout << "m_Tof = 0" << std::endl;
344
345 if ( fTofMrpc )
346 { // Huang Shuhui's update: for Tof with MRPC
347 for ( int part = 0; part < m_kPart; part++ )
348 {
349 if ( part != 1 ) continue; // For TofMrpc Barrel
350 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
351 {
352 std::stringstream osnameAl;
353 if ( part == 1 )
354 osnameAl << "pv_"
355 << "logical"
356 << "AlBr" << layer + 1 << "_0";
357 m_NodeAl[part][layer] = GetNode( osnameAl.str() );
358 if ( !m_NodeAl[part][layer] ) cout << "empty pointer: m_NodeAl" << endl;
359
360 std::stringstream osnameScin;
361 if ( part == 1 )
362 osnameScin << "pv_"
363 << "logical"
364 << "ScinBr" << layer + 1 << "_0";
365 m_NodeScin[part][layer] = GetNode( osnameScin.str() );
366 if ( !m_NodeScin[part][layer] ) cout << "empty pointer: m_NodeScin" << endl;
367
368 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
369 {
370 std::stringstream osnamePVF;
371 if ( part == 1 )
372 {
373 osnamePVF << "pv_"
374 << "logicalPVFBr" << layer + 1 << "_"
375 << ( 2 * m_kScinBr * 3 - 1 ) - ( layer * m_kScinBr + scin ) * 3;
376 }
377 m_NodePVF[part][layer][scin] = GetNode( osnamePVF.str() );
378 if ( !m_NodePVF[part][layer][scin] ) cout << "empty pointer: m_NodePVF" << endl;
379 } // scin
380 } // layer
381 } // part
382
383 for ( int part = 0; part < m_kPart; part++ )
384 {
385 if ( part == 1 ) continue; // For TofMrpc Endcap
386 for ( int module = 0; module < GetModuleNb( part ); module++ )
387 {
388 std::stringstream osnameModule;
389 std::stringstream osnamegasContainer;
390 std::stringstream osnamebareChamber;
391 std::stringstream osnamepcbBoard1;
392
393 osnamebareChamber << "pv_"
394 << "logical_"
395 << "bareChamber"
396 << "_" << GetChamberNodeNb( module );
397 m_NodebareChamber[part][module] = GetNode( osnamebareChamber.str() );
398 if ( !m_NodebareChamber ) cout << "empty pointer: m_NodebareChamber" << endl;
399
400 osnamepcbBoard1 << "pv_"
401 << "logical_"
402 << "pcbBoard1"
403 << "_" << GetBoard1NodeNb( module );
404 m_NodepcbBoard1[part][module] = GetNode( osnamepcbBoard1.str() );
405 if ( !m_NodepcbBoard1 ) cout << "empty pointer: m_NodepcbBoard1" << endl;
406
407 if ( part == 0 )
408 {
409 if ( !TMath::Odd( module ) )
410 {
411 osnameModule << "pv_"
412 << "logical_"
413 << "container_m0"
414 << "_" << module;
415 osnamegasContainer << "pv_"
416 << "logical_"
417 << "gasContainer_m0"
418 << "_" << GetContainerNodeNb( module );
419 }
420 else
421 {
422 osnameModule << "pv_"
423 << "logical_"
424 << "container_m3"
425 << "_" << module;
426 osnamegasContainer << "pv_"
427 << "logical_"
428 << "gasContainer_m3"
429 << "_" << GetContainerNodeNb( module );
430 }
431 }
432
433 if ( part == 2 )
434 {
435 if ( !TMath::Odd( module ) )
436 {
437 osnameModule << "pv_"
438 << "logical_"
439 << "container_m1"
440 << "_" << module;
441 osnamegasContainer << "pv_"
442 << "logical_"
443 << "gasContainer_m1"
444 << "_" << GetContainerNodeNb( module );
445 }
446 else
447 {
448 osnameModule << "pv_"
449 << "logical_"
450 << "container_m2"
451 << "_" << module;
452 osnamegasContainer << "pv_"
453 << "logical_"
454 << "gasContainer_m2"
455 << "_" << GetContainerNodeNb( module );
456 }
457 }
458
459 m_NodeModule[part][module] = GetNode( osnameModule.str() );
460 if ( !m_NodeModule[part][module] ) cout << "empty pointer: m_NodeModule " << endl;
461 m_NodegasContainer[part][module] = GetNode( osnamegasContainer.str() );
462 if ( !m_NodegasContainer[part][module] )
463 cout << "empty pointer: m_NodegasContainer " << endl;
464
465 for ( int strip = 0; strip < GetStripNb( module ); strip++ )
466 {
467 std::stringstream osnameStrip;
468 osnameStrip << "pv_"
469 << "logical_"
470 << "strip_" << ( GetStripNb( module ) - 1 ) - strip << "_" << strip;
471 m_NodeStrip[part][module][strip] = GetNode( osnameStrip.str() );
472 if ( !m_NodeStrip[part][module][strip] )
473 cout << "empty pointer: m_NodeStrip " << endl;
474 } // strip
475 } // module
476 } // part
477 } // judge mrpc
478 else
479 {
480 for ( int part = 0; part < m_kPart; part++ )
481 {
482 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
483 {
484 std::stringstream osnameAl;
485 if ( part == 1 )
486 osnameAl << "pv_"
487 << "logical"
488 << "AlBr" << layer + 1 << "_0";
489 else if ( part == 0 )
490 osnameAl << "pv_"
491 << "logical"
492 << "AlEcEast"
493 << "_0";
494 else
495 osnameAl << "pv_"
496 << "logical"
497 << "AlEcWest"
498 << "_0";
499 m_NodeAl[part][layer] = GetNode( osnameAl.str() );
500
501 std::stringstream osnameScin;
502 if ( part == 1 )
503 osnameScin << "pv_"
504 << "logical"
505 << "ScinBr" << layer + 1 << "_0";
506 else if ( part == 0 )
507 osnameScin << "pv_"
508 << "logical"
509 << "ScinEcEast"
510 << "_0";
511 else
512 osnameScin << "pv_"
513 << "logical"
514 << "ScinEcWest"
515 << "_0";
516 m_NodeScin[part][layer] = GetNode( osnameScin.str() );
517
518 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
519 {
520 std::stringstream osnamePVF;
521 if ( part == 1 )
522 {
523 osnamePVF << "pv_"
524 << "logicalPVFBr" << layer + 1 << "_"
525 << ( 2 * m_kScinBr * 3 - 1 ) - ( layer * m_kScinBr + scin ) * 3;
526 }
527 else if ( part == 2 )
528 {
529 osnamePVF << "pv_"
530 << "logicalPVFEcWest"
531 << "_" << ( 2 * m_kScinEc - 1 ) - scin * 2;
532 }
533 else if ( part == 0 )
534 {
535 osnamePVF << "pv_"
536 << "logicalPVFEcEast"
537 << "_" << ( 2 * m_kScinEc - 1 ) - scin * 2;
538 }
539 m_NodePVF[part][layer][scin] = GetNode( osnamePVF.str() );
540 } // scin
541 } // layer
542 } // part
543 } // judge mrpc
544 }
545 else if ( m_ROOTGeoInit == 1 )
546 { // from ROOT object
547 // Huang Shuhui's update: for Tof with MRPC
548 if ( fTofMrpc )
549 {
550 for ( int part = 0; part < m_kPart; part++ )
551 {
552 int ipart = 0;
553 if ( part == 1 ) ipart = 2;
554 else if ( part == 2 ) ipart = 1;
555 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
556 {
557 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
558 {
559 int iNode = 0;
560 if ( part == 1 )
561 {
562 iNode = ( 2 * m_kScinBr * 3 - 1 ) - ( layer * m_kScinBr + scin ) * 3;
563 m_NodePVF[part][layer][scin] =
564 m_Tof->GetNode( ipart )->GetVolume()->GetNode( iNode );
565 m_NodeAl[part][layer] = m_NodePVF[part][layer][0]->GetVolume()->GetNode( 0 );
566 m_NodeScin[part][layer] = m_NodeAl[part][layer]->GetVolume()->GetNode( 0 );
567 }
568 if ( part != 1 )
569 {
570 m_NodeModule[part][layer] =
571 m_Tof->GetNode( ipart )->GetVolume()->GetNode( layer );
572 m_NodegasContainer[part][layer] =
573 m_NodeModule[part][layer]->GetVolume()->GetNode( 0 );
574 m_NodebareChamber[part][layer] =
575 m_NodegasContainer[part][layer]->GetVolume()->GetNode( 6 );
576 m_NodepcbBoard1[part][layer] =
577 m_NodebareChamber[part][layer]->GetVolume()->GetNode( 30 );
578 m_NodeStrip[part][layer][scin] =
579 m_NodepcbBoard1[part][layer]->GetVolume()->GetNode( scin );
580 }
581 } // scin
582 } // layer
583 } // part
584 } // judge mrpc
585 else
586 {
587 for ( int part = 0; part < m_kPart; part++ )
588 {
589 int ipart = 0;
590 if ( part == 1 ) ipart = 2;
591 if ( part == 2 ) ipart = 1;
592 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
593 {
594 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
595 {
596 int iNode = 0;
597 // if (part == 1) {
598 // iNode = layer*m_kScinBr + scin;
599 // }
600 // else if (part == 2) { // West placed first in Tof.gdml
601 // iNode = 2*m_kScinBr + scin;
602 // }
603 // else if (part == 0) {
604 // iNode = 2*m_kScinBr + m_kScinEc + scin;
605 // }
606 if ( part != 1 ) { iNode = ( 2 * m_kScinEc - 1 ) - scin * 2; }
607 if ( part == 1 )
608 { iNode = ( 2 * m_kScinBr * 3 - 1 ) - ( layer * m_kScinBr + scin ) * 3; }
609 m_NodePVF[part][layer][scin] = m_Tof->GetNode( ipart )->GetVolume()->GetNode(
610 iNode ); // fix me, change structure now
611 }
612 m_NodeAl[part][layer] = m_NodePVF[part][layer][0]->GetVolume()->GetNode( 0 );
613 // cout << m_NodeAl[part][layer]->GetName() << endl;
614 m_NodeScin[part][layer] = m_NodeAl[part][layer]->GetVolume()->GetNode( 0 );
615 // cout << m_NodeScin[part][layer]->GetName() << endl;
616 } // layer
617 } // part
618 } // judge mrpc
619 }
620
621 // std::cout << "TofROOTGeo::SetNode, end of set node" << std::endl;
622}
623
625 // std::cout << "begin of set defaultvis" << std::endl;
626
627 m_Tof->SetLineColor( m_TofColor );
628 m_Tof->SetVisibility( 0 );
629
630 for ( int part = 0; part < m_kPart; part++ )
631 {
632 GetVolumePart( part )->SetLineColor( m_ScinColor );
633 GetVolumePart( part )->SetVisibility( 0 );
634 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
635 {
636 GetVolumePVF( part, layer )->SetLineColor( m_ScinColor );
637 GetVolumePVF( part, layer )->SetVisibility( 0 );
638
639 GetVolumeAl( part, layer )->SetLineColor( m_ScinColor );
640 GetVolumeAl( part, layer )->SetVisibility( 0 );
641
642 GetVolumeScin( part, layer )->SetLineColor( m_ScinColor );
643 GetVolumeScin( part, layer )->SetVisibility( 0 );
644
645 GetVolumeBucket( part, layer )->SetLineColor( m_BucketColor );
646 GetVolumeBucket( part, layer )->SetVisibility( 0 );
647 }
648 }
649 // std::cout << "end of set defaultvis" << std::endl;
650}
651
652// Long Peixun's update: Set default 3D color
654 if ( fTofMrpc )
655 { // Tof with MRPC
656 for ( int part = 0; part < m_kPart; part++ )
657 {
658 if ( part == 1 )
659 {
660 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
661 {
662 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
663 GetPhysicalScin( part, layer, scin )->SetLineColor( m_ScinColor );
664 }
665 }
666 else
667 {
668 for ( int module = 0; module < GetModuleNb( part ); module++ )
669 {
670 for ( int strip = 0; strip < GetStripNb( module ); strip++ )
671 GetPhysicalScin( part, module, strip );
672 }
673 }
674 }
675 }
676 else
677 { // Old Tof
678 for ( int part = 0; part < m_kPart; part++ )
679 {
680 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
681 {
682 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
683 GetPhysicalScin( part, layer, scin )->SetLineColor( m_ScinColor );
684 }
685 }
686 }
687}
688
689void TofROOTGeo::SetTMatch( Bool_t input = false ) { k_TMatch = input; }
690
691void TofROOTGeo::SetQMatch( Bool_t input = false ) { k_QMatch = input; }
692
694 m_Tof->SetLineColor( m_TofColor );
695 m_Tof->SetVisibility( 0 );
696
697 for ( int part = 0; part < m_kPart; part++ )
698 {
699 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
700 {
701 GetVolumePVF( part, layer )->SetLineColor( m_ScinColor );
702 GetVolumePVF( part, layer )->SetVisibility( 1 );
703
704 GetVolumeAl( part, layer )->SetLineColor( m_ScinColor );
705 GetVolumeAl( part, layer )->SetVisibility( 1 );
706
707 GetVolumeScin( part, layer )->SetLineColor( m_ScinColor );
708 GetVolumeScin( part, layer )->SetVisibility( 1 );
709
710 GetVolumeBucket( part, layer )->SetLineColor( m_BucketColor );
711 GetVolumeBucket( part, layer )->SetVisibility( 1 );
712 }
713 }
714}
715
717 /*
718 for (int part = 0; part < m_kPart; part++) {
719 GetVolumeScin(part)->SetVisibility(1);
720 GetVolumeBucket(part)->SetVisibility(1);
721
722 int nScin = 0;
723 if (part == 1) nScin = m_kAssemblyBr;
724 else nScin = m_kAssemblyEc;
725 for (int scin = 0; scin < nScin; scin++) {
726 if (scin < nScin/4) GetScin(part, scin)->SetVisibility(0);
727 else GetScin(part, scin)->SetVisibility(1);
728
729 int nBucket = 0;
730 if (part == 1) nBucket = m_kBucketBr;
731 else nBucket = m_kBucketEc;
732 for (int bucket = 0; bucket < nBucket; bucket++) {
733 if (scin < nScin/4) GetBucket(part, scin, bucket)->SetVisibility(0);
734 else GetBucket(part, scin, bucket)->SetVisibility(1);
735 }
736 }
737 }
738 */
739}
740
742 /*
743 for (int part = 0; part < m_kPart; part++) {
744 GetVolumeScin(part)->SetVisibility(1);
745 GetVolumeBucket(part)->SetVisibility(1);
746
747 int nScin = 0;
748 if (part == 1) nScin = m_kAssemblyBr;
749 else nScin = m_kAssemblyEc;
750 for (int scin = 0; scin < nScin; scin++) {
751 if (scin < nScin/4+1 ||
752 scin > nScin*3/4 ) GetScin(part, scin)->SetVisibility(1);
753 else GetScin(part, scin)->SetVisibility(0);
754
755 int nBucket = 0;
756 if (part == 1) nBucket = m_kBucketBr;
757 else nBucket = m_kBucketEc;
758 for (int bucket = 0; bucket < nBucket; bucket++) {
759 if (scin < nScin/4+1 ||
760 scin > nScin*3/4 ) GetBucket(part, scin, bucket)->SetVisibility(1);
761 else GetBucket(part, scin, bucket)->SetVisibility(0);
762 }
763 }
764 }
765 */
766}
767
769 /*
770 int part = 1;
771 GetVolumeScin(0)->SetVisibility(1);
772 GetVolumeBucket(0)->SetVisibility(1);
773
774 int nScin = 0;
775 nScin = m_kAssemblyBr;
776 for (int scin = 0; scin < nScin; scin++) {
777 GetScin(part, scin)->SetVisibility(1);
778
779 int nBucket = 0;
780 nBucket = m_kBucketBr;
781 for (int bucket = 0; bucket < nBucket; bucket++) {
782 GetBucket(part, scin, bucket)->SetVisibility(1);
783 }
784 }
785 */
786}
787
789 if ( gGeoManager == 0 ) std::cout << "Create gGeoManager first" << std::endl;
790 TGeoNode* bes = gGeoManager->GetTopNode();
791 // std::cout << "Tof m_childNo " << m_childNo << std::endl;
792 // TGeoNode *nodeTof = bes->GetVolume()->GetNode(0);
793 TGeoNode* nodeTof = bes->GetDaughter( 1 );
794 for ( int part = 0; part < m_kPart; part++ )
795 {
796
797 // std::stringstream osnamePart;
798 // if (part == 1) osnamePart << "pv_" << "logicalBrTof" << "_2";
799 // else if(part == 0) osnamePart << "pv_" << "logicalEcTofEast" << "_0";
800 // else osnamePart << "pv_" << "logicalEcTofWest" << "_1";
801 // TGeoNode *nodePart = GetNode( osnamePart.str() );
802
803 int ipart = 0;
804 if ( part == 1 ) ipart = 2;
805 if ( part == 2 ) ipart = 1;
806 TGeoNode* nodePart;
807 nodePart = nodeTof->GetVolume()->GetNode( ipart );
808
809 if ( fTofMrpc )
810 { // Huang Shuhui's update: for Tof with MRPC
811 if ( part == 1 )
812 {
813 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
814 {
815 TGeoNode* nodeAl = GetAl( part, layer );
816 TGeoNode* nodeScin = GetScin( part, layer );
817 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
818 {
819 TGeoNode* nodePVF = GetPVF( part, layer, scin );
820 m_PhysicalScin[part][layer][scin] = gGeoManager->MakePhysicalNode(
821 TString( "/" ) + bes->GetName() + TString( "/" ) + nodeTof->GetName() +
822 TString( "/" ) + nodePart->GetName() + TString( "/" ) + nodePVF->GetName() +
823 TString( "/" ) + nodeAl->GetName() + TString( "/" ) + nodeScin->GetName() );
824 if ( !m_PhysicalScin[part][layer][scin] )
825 cout << "empty pointer: m_PhysicalScin" << endl;
826 m_PhysicalScin[part][layer][scin]->SetVisibility( 0 );
827 m_PhysicalScin[part][layer][scin]->SetIsVolAtt( kFALSE );
828 m_PhysicalScin[part][layer][scin]->SetLineColor( m_ScinColor );
829 } // scin
830 } // layer
831 }
832 else
833 {
834 for ( int module = 0; module < GetModuleNb( part ); module++ )
835 {
836 TGeoNode* nodeModule = GetModule( part, module );
837 TGeoNode* nodegasContainer = GetgasContainer( part, module );
838 TGeoNode* nodebareChamber = GetbareChamber( part, module );
839 TGeoNode* nodepcbBoard1 = GetpcbBoard1( part, module );
840 for ( int strip = 0; strip < GetStripNb( module ); strip++ )
841 {
842 TGeoNode* nodeStrip = GetStrip( part, module, strip );
843 m_PhysicalScin[part][module][strip] = gGeoManager->MakePhysicalNode(
844 TString( "/" ) + bes->GetName() + TString( "/" ) + nodeTof->GetName() +
845 TString( "/" ) + nodePart->GetName() + TString( "/" ) + nodeModule->GetName() +
846 TString( "/" ) + nodegasContainer->GetName() + TString( "/" ) +
847 nodebareChamber->GetName() + TString( "/" ) + nodepcbBoard1->GetName() +
848 TString( "/" ) + nodeStrip->GetName() );
849 if ( !m_PhysicalScin[part][module][strip] )
850 cout << "empty pointer: m_PhysicalScin" << endl;
851 m_PhysicalScin[part][module][strip] = m_PhysicalScin[part][module][strip];
852
853 m_PhysicalScin[part][module][strip]->SetVisibility( 0 );
854 m_PhysicalScin[part][module][strip]->SetIsVolAtt( kFALSE );
855 m_PhysicalScin[part][module][strip]->SetLineColor( m_ScinColor );
856 } // strip
857 } // module
858 }
859 } // judge mrpc
860 else
861 {
862 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
863 {
864 TGeoNode* nodeAl = GetAl( part, layer );
865 TGeoNode* nodeScin = GetScin( part, layer );
866 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
867 {
868 TGeoNode* nodePVF = GetPVF( part, layer, scin );
869 m_PhysicalScin[part][layer][scin] = gGeoManager->MakePhysicalNode(
870 TString( "/" ) + bes->GetName() + TString( "/" ) + nodeTof->GetName() +
871 TString( "/" ) + nodePart->GetName() + TString( "/" ) + nodePVF->GetName() +
872 TString( "/" ) + nodeAl->GetName() + TString( "/" ) + nodeScin->GetName() );
873 // cout<<"in SetPhysicalNode() "<<part<<" "<<layer<<" "<<scin<<" "<<endl;
874 // cout<<" "<<bes->GetName()<<" "<<nodeTof->GetName()<<"
875 // "<<nodePVF->GetName()<<" "<<nodeAl->GetName()<<" "<<nodeScin->GetName()<<endl;
876 m_PhysicalScin[part][layer][scin]->SetVisibility( 0 );
877 m_PhysicalScin[part][layer][scin]->SetIsVolAtt( kFALSE );
878 m_PhysicalScin[part][layer][scin]->SetLineColor( m_ScinColor );
879 } // scin
880 } // layer
881 } // judge mrpc
882 } // part
883
884 SetDetector();
885}
886
888 BesView* view = 0;
889 if ( gPad ) view = dynamic_cast<BesView*>( gPad->GetView() );
890 // if (view) cout << "viewVisFull3DTof " << view->GetVisFull3DTof() << endl;
891 m_DetectorsArray->Clear();
892
893 // Long Peixun's update: for Tof Mrpc
894 if ( fTofMrpc )
895 {
896 for ( int part = 0; part < m_kPart; part++ )
897 {
898 if ( part == 1 )
899 {
900 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
901 {
902 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
903 {
904 TGeoPhysicalNode* phyNode = 0;
905 phyNode = GetPhysicalScin( part, layer, scin );
906 if ( phyNode )
907 {
908 phyNode->SetVisibility( 0 ); // set all invisible before set any visible
909 m_DetectorsArray->Add( phyNode );
910 }
911 }
912 }
913 }
914 else
915 {
916 for ( int module = 0; module < GetModuleNb( part ); module++ )
917 {
918 for ( int strip = 0; strip < GetStripNb( module ); strip++ )
919 {
920 TGeoPhysicalNode* phyNode = 0;
921 phyNode = GetPhysicalScin( part, module, strip );
922 if ( phyNode )
923 {
924 phyNode->SetVisibility( 0 ); // set all invisible before set any visible
925 m_DetectorsArray->Add( phyNode );
926 }
927 }
928 }
929 }
930 }
931 }
932 else
933 {
934 for ( int part = 0; part < m_kPart; part++ )
935 {
936 for ( int layer = 0; layer < GetLayerNb( part ); layer++ )
937 {
938 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
939 {
940 TGeoPhysicalNode* phyNode = 0;
941 phyNode = GetPhysicalScin( part, layer, scin );
942 if ( phyNode )
943 {
944 phyNode->SetVisibility( 0 ); // set all invisible before set any visible
945 // Long Peixun's update: Remove useless judgement
946 // if (part == 2 ||
947 // (scin >= GetScinNb(part)*0/4 && scin < GetScinNb(part)*8/8)) {
948 m_DetectorsArray->Add( phyNode );
949 // }
950 // else if (view && view->GetVisFull3DTof()) {
951 // m_DetectorsArray->Add( phyNode );
952 // }
953 }
954 }
955 }
956 }
957 }
958}
959
961 // set previous event hits to default vis
962 for ( int i = 0; i < m_HitsArray->GetEntries(); i++ )
963 {
964 TGeoPhysicalNode* phyNode = (TGeoPhysicalNode*)m_HitsArray->At( i );
965 if ( phyNode )
966 {
967 // phyNode->SetLineColor(m_ScinColor);
968 phyNode->SetVisibility( 0 );
969 }
970 }
971 m_HitsArray->Clear( "C" );
972
973 // set previous event 2D hits info to default
974 for ( int i = 0; i < m_2DHitsArray->GetEntries(); i++ )
975 {
976 Tof2DScin* aScin = (Tof2DScin*)m_2DHitsArray->At( i );
977 aScin->ClearInfo();
978 aScin->AddInfo( aScin->GetTitle() );
979 aScin->CloseInfo();
980 aScin->ResetTimeCharge();
981 }
982 m_2DHitsArray->Clear( "C" );
983
984 // Long Peixun's update: Consider gEvent == NULL
985 int NDigiCol = 0;
986 if ( gEvent )
987 {
988 m_TofDigiCol = gEvent->GetTofDigiCol();
989 // Long Peixun's update: Consider m_TofDigiCol == NULL
990 if ( m_TofDigiCol ) NDigiCol = m_TofDigiCol->GetEntries();
991 else NDigiCol = 0;
992 }
993
994 for ( int i = 0; i < NDigiCol; i++ )
995 {
996 TTofDigi* aTofDigi = (TTofDigi*)m_TofDigiCol->At( i );
997 Identifier atofID( aTofDigi->getIntId() );
998 int part, layer, scin;
999
1000 if ( fTofMrpc )
1001 { // Huang Shuhui's update: for Tof_mrpc hits
1002 part = TofID::barrel_ec( atofID );
1003 if ( part == 1 )
1004 {
1005 layer = TofID::layer( atofID );
1006 scin = TofID::phi_module( atofID );
1007 }
1008 else
1009 {
1010 // In BOSS 7.0.3
1011 int part_Ec = TofID::endcap( atofID );
1012 if ( part_Ec == 0 ) part = 0;
1013 else part = 2;
1014 layer = TofID::module( atofID );
1015 scin = TofID::strip( atofID );
1016
1017 // In CgemBOSS 6.6.5.b
1018 // int part_Ec = TofID::end(atofID);
1019 // if (part_Ec == 0) part = 0;
1020 // else part = 2;
1021 // layer = TofID::layer(atofID);
1022 // scin = TofID::phi_module(atofID);
1023 }
1024 }
1025 else
1026 {
1027 part = TofID::barrel_ec( atofID );
1028 layer = TofID::layer( atofID );
1029 scin = TofID::phi_module( atofID );
1030 }
1031
1032 if ( layer < 0 || scin < 0 )
1033 {
1034 std::cout << "TofROOTGeo::SetHits() error: "
1035 << " part=" << part << " layer=" << layer << " scin=" << scin << std::endl;
1036 continue;
1037 }
1038
1039 // Long Peixun has a question: Do we need to divide by TOF_*_FACTOR?
1040 Double_t charge = Double_t( aTofDigi->getChargeChannel() ) / TOF_CHARGE_FACTOR;
1041 Double_t time = Double_t( aTofDigi->getTimeChannel() ) / TOF_TIME_FACTOR;
1042 // Double_t charge = RawDataUtil::TofCharge(aTofDigi->getChargeChannel());
1043 // Double_t time = RawDataUtil::TofTime(aTofDigi->getTimeChannel());
1044
1045 TGeoPhysicalNode* phyNode = 0;
1046 phyNode = GetPhysicalScin( part, layer, scin );
1047 if ( phyNode ) { m_HitsArray->Add( phyNode ); }
1048
1049 Tof2DScin* aScin = 0;
1050 aScin = m_Tof2DScin[part][layer][scin];
1051 if ( aScin )
1052 {
1053 char data[100];
1054
1055 if ( fTofMrpc )
1056 { // Huang Shuhui's update: for Tof_mrpc hits
1057 if ( part != 1 )
1058 {
1059 if ( aScin->GetCharge() == 0.0 )
1060 {
1061 aScin->ClearInfo();
1062 aScin->AddInfo( aScin->GetTitle() );
1063 // Long Peixun's update: Subscript index
1064 sprintf( data, "t_{leading1} = %-.3f ns, t_{trailing1} = %-.3f ns", time, charge );
1065 aScin->AddInfo( TString( data ) );
1066 }
1067 else
1068 {
1069 // Long Peixun's update: Subscript index
1070 sprintf( data, "t_{leading2} = %-.3f ns, t_{trailing2} = %-.3f ns", time, charge );
1071 aScin->AddInfo( TString( data ) );
1072 sprintf( data, "Fired" );
1073 aScin->AddInfo( TString( data ) );
1074 }
1075 }
1076 else
1077 {
1078 if ( aScin->GetCharge() == 0.0 )
1079 {
1080 aScin->ClearInfo();
1081 aScin->AddInfo( aScin->GetTitle() );
1082 sprintf( data, "time1 = %-.3f ns, charge1 = %-.3f MeV", time, charge );
1083 aScin->AddInfo( TString( data ) );
1084 }
1085 else
1086 {
1087 sprintf( data, "time2 = %-.3f ns, charge2 = %-.3f MeV", time, charge );
1088 aScin->AddInfo( TString( data ) );
1089 sprintf( data, "Fired" );
1090 aScin->AddInfo( TString( data ) );
1091 }
1092 }
1093 }
1094 else
1095 {
1096 if ( aScin->GetCharge() == 0.0 )
1097 {
1098 aScin->ClearInfo();
1099 aScin->AddInfo( aScin->GetTitle() );
1100 sprintf( data, "time1 = %-.3f ns, charge1 = %-.3f MeV", time, charge );
1101 aScin->AddInfo( TString( data ) );
1102 }
1103 else
1104 {
1105 sprintf( data, "time2 = %-.3f ns, charge2 = %-.3f MeV", time, charge );
1106 aScin->AddInfo( TString( data ) );
1107 sprintf( data, "Fired" );
1108 aScin->AddInfo( TString( data ) );
1109 }
1110 }
1111
1112 aScin->CloseInfo();
1113 aScin->SetCharge( aScin->GetCharge() + charge );
1114 // Long Peixun's update: Set raw channel data of aScin
1115 aScin->SetTimeChannel( aTofDigi->getTimeChannel() );
1116 aScin->SetChargeChannel( aTofDigi->getChargeChannel() );
1117 m_2DHitsArray->Add( aScin );
1118 }
1119 }
1120}
1121
1123 /*
1124 for (int part = 0; part < m_kPart; part++) {
1125 for (int layer = 0; layer < GetLayerNb(part); layer++) {
1126 for (int scin = 0; scin < GetScinNb(part); scin++) {
1127 TGeoPhysicalNode *phyNode = GetPhysicalScin(part, layer, scin);
1128 if (phyNode) phyNode->SetLineColor(m_ScinColor);
1129 }
1130 }
1131 }
1132 */
1133
1134 BesView* view = 0;
1135 if ( gPad ) view = dynamic_cast<BesView*>( gPad->GetView() );
1136
1137 // cout << "VisTofEast " << view->GetVisTofEast() << endl;
1138 for ( int i = 0; i < m_DetectorsArray->GetEntries(); i++ )
1139 {
1140 TGeoPhysicalNode* phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At( i );
1141 phyNode->SetVisibility( 0 );
1142 if ( view && view->GetVisTofGlobal() )
1143 {
1144 int part = GetPart( phyNode );
1145 if ( part == 0 && view->GetVisTofEast() || part == 1 && view->GetVisTofBarrel() ||
1146 part == 2 && view->GetVisTofWest() )
1147 phyNode->SetVisibility( 1 );
1148 }
1149 }
1150}
1151
1153 BesView* view = 0;
1154 if ( gPad ) view = dynamic_cast<BesView*>( gPad->GetView() );
1155
1156 for ( int i = 0; i < m_HitsArray->GetEntries(); i++ )
1157 {
1158 TGeoPhysicalNode* phyNode = (TGeoPhysicalNode*)m_HitsArray->At( i );
1159 if ( phyNode )
1160 {
1161 int part = GetPart( phyNode );
1162 if ( view && view->GetVisTofHitsGlobal() )
1163 {
1164 if ( part == 0 && view->GetVisTofHitsEast() ||
1165 part == 1 && view->GetVisTofHitsBarrel() ||
1166 part == 2 && view->GetVisTofHitsWest() )
1167 {
1168 phyNode->SetVisibility( 1 );
1169 phyNode->SetLineColor( 801 ); // Long Peixun's update: Green -> Orange
1170 continue;
1171 }
1172 }
1173 // Long Peixun's update: Unfired visibility should be determined by Detector option
1174 // rather than His option phyNode->SetVisibility(0);
1175 if ( part > -1 ) phyNode->SetLineColor( m_ScinColor );
1176 }
1177 }
1178}
1179
1181 return m_kPart; // Long Peixun's update: code optimization
1182}
1183
1184int TofROOTGeo::GetScinNb( int part ) {
1185 // Long Peixun's update: code optimization
1186 // Huang Shuhui's update: for Tof with MRPC
1187 if ( part == 1 ) return m_kScinBr;
1188 else
1189 {
1190 if ( fTofMrpc ) return m_kStripEc;
1191 return m_kScinEc;
1192 }
1193}
1194
1195int TofROOTGeo::GetLayerNb( int part ) {
1196 // Long Peixun's update: code optimization
1197 // Huang Shuhui's update: for Tof with MRPC
1198 if ( part == 1 ) return m_kLayerBr;
1199 else
1200 {
1201 if ( fTofMrpc ) return m_kModuleEc;
1202 return m_kLayerEc;
1203 }
1204}
1205
1206// Huang Shuhui's update: for Tof with MRPC
1207// Long Peixun's update: code optimization
1208int TofROOTGeo::GetModuleNb( int part ) { return m_kModuleEc; }
1209int TofROOTGeo::GetChamberNodeNb( int module ) { return m_kChamberNodeNb; }
1210int TofROOTGeo::GetContainerNodeNb( int module ) { return m_kContainerNodeNb; }
1211int TofROOTGeo::GetBoard1NodeNb( int module ) { return m_kBoard1NodeNb; }
1212int TofROOTGeo::GetStripNb( int module ) { return m_kStripEc; }
1213
1214/*
1215 TGeoVolumeAssembly*
1216 TofROOTGeo::GetVolumeAssembly( int part )
1217 {
1218 std::stringstream osname;
1219 if (part == 0 || part == 2) {
1220 osname << "logical" << "Tof" << "AssemblyEc";
1221 }
1222 else {
1223 if (part == 1) {
1224 osname << "logical" << "Tof" << "AssemblyBr";
1225 }
1226 }
1227
1228 return GetAssemblyVolume( osname.str() );
1229 }
1230 */
1231
1232TGeoVolume* TofROOTGeo::GetVolumePart( int part ) {
1233 std::stringstream osname;
1234 if ( part == 1 ) { osname << "logicalBrTof"; }
1235 else if ( part == 0 ) { osname << "logicalEcTofWest"; }
1236 else { osname << "logicalEcTofEast"; }
1237 return GetLogicalVolume( osname.str() );
1238}
1239
1240TGeoVolume* TofROOTGeo::GetVolumePVF( int part, int layer ) {
1241 std::stringstream osname;
1242 if ( part == 0 )
1243 {
1244 osname << "logical"
1245 << "PVFEcEast";
1246 }
1247 else if ( part == 2 )
1248 {
1249 osname << "logical"
1250 << "PVFEcWest";
1251 }
1252 else
1253 {
1254 if ( part == 1 )
1255 {
1256 osname << "logical"
1257 << "PVFBr" << layer + 1;
1258 }
1259 }
1260 return GetLogicalVolume( osname.str() );
1261}
1262
1263TGeoVolume* TofROOTGeo::GetVolumeAl( int part, int layer ) {
1264 std::stringstream osname;
1265 if ( part == 0 )
1266 {
1267 osname << "logical"
1268 << "AlEcEast";
1269 }
1270 else if ( part == 2 )
1271 {
1272 osname << "logical"
1273 << "AlEcWest";
1274 }
1275 else
1276 {
1277 if ( part == 1 )
1278 {
1279 osname << "logical"
1280 << "AlBr" << layer + 1;
1281 }
1282 }
1283 return GetLogicalVolume( osname.str() );
1284}
1285
1286TGeoVolume* TofROOTGeo::GetVolumeScin( int part, int layer ) {
1287 std::stringstream osname;
1288 if ( part == 0 )
1289 {
1290 osname << "logical"
1291 << "ScinEcEast";
1292 }
1293 else if ( part == 2 )
1294 {
1295 osname << "logical"
1296 << "ScinEcWest";
1297 }
1298 else
1299 {
1300 if ( part == 1 )
1301 {
1302 osname << "logical"
1303 << "ScinBr" << layer + 1;
1304 }
1305 }
1306 return GetLogicalVolume( osname.str() );
1307}
1308
1309TGeoVolume* TofROOTGeo::GetVolumeBucket( int part, int layer ) {
1310 std::stringstream osname;
1311 if ( part == 0 || part == 2 )
1312 {
1313 osname << "logical"
1314 << "BucketEc";
1315 }
1316 else
1317 {
1318 if ( part == 1 )
1319 {
1320 osname << "logical"
1321 << "BucketBr" << layer + 1;
1322 }
1323 }
1324 return GetLogicalVolume( osname.str() );
1325}
1326
1327TGeoNode* TofROOTGeo::GetPVF( int part, int layer, int scin ) {
1328 if ( m_NodePVF[part][layer][scin] != 0 ) { return m_NodePVF[part][layer][scin]; }
1329 else
1330 {
1331 std::cout << "Node: "
1332 << "Part" << part << "Layer" << layer << "PVF" << scin << " not found"
1333 << std::endl;
1334 return 0;
1335 }
1336 return m_NodePVF[part][layer][scin];
1337}
1338
1339TGeoNode* TofROOTGeo::GetAl( int part, int layer ) {
1340 if ( m_NodeAl[part][layer] != 0 ) { return m_NodeAl[part][layer]; }
1341 else
1342 {
1343 std::cout << "Node: "
1344 << "Part" << part << "Layer" << layer << "Al"
1345 << " not found" << std::endl;
1346 return 0;
1347 }
1348 return m_NodeAl[part][layer];
1349}
1350
1351TGeoNode* TofROOTGeo::GetScin( int part, int layer ) {
1352 if ( m_NodeScin[part][layer] != 0 ) { return m_NodeScin[part][layer]; }
1353 else
1354 {
1355 std::cout << "Node: "
1356 << "Part" << part << "Layer" << layer << "Scin"
1357 << " not found" << std::endl;
1358 return 0;
1359 }
1360 return m_NodeScin[part][layer];
1361}
1362
1363// Huang Shuhui's update: for Tof with MRPC
1364TGeoNode* TofROOTGeo::GetModule( int part, int module ) {
1365 if ( m_NodeModule[part][module] != 0 ) { return m_NodeModule[part][module]; }
1366 else
1367 {
1368 std::cout << "Node: "
1369 << "Part" << part << "Module" << module << " not found" << std::endl;
1370 return 0;
1371 }
1372 return m_NodeModule[part][module];
1373}
1374
1375TGeoNode* TofROOTGeo::GetgasContainer( int part, int module ) {
1376 if ( m_NodegasContainer[part][module] != 0 ) { return m_NodegasContainer[part][module]; }
1377 else
1378 {
1379 std::cout << "Node: "
1380 << "Part" << part << "Module" << module << "gasContainer"
1381 << " not found" << std::endl;
1382 return 0;
1383 }
1384
1385 return m_NodegasContainer[part][module];
1386}
1387
1388TGeoNode* TofROOTGeo::GetbareChamber( int part, int module ) {
1389 if ( m_NodebareChamber[part][module] != 0 ) { return m_NodebareChamber[part][module]; }
1390 else
1391 {
1392 std::cout << "Node: "
1393 << "Part" << part << "Module" << module << "bareChamber"
1394 << " not found" << std::endl;
1395 return 0;
1396 }
1397
1398 return m_NodebareChamber[part][module];
1399}
1400
1401TGeoNode* TofROOTGeo::GetpcbBoard1( int part, int module ) {
1402 if ( m_NodepcbBoard1[part][module] != 0 ) { return m_NodepcbBoard1[part][module]; }
1403 else
1404 {
1405 std::cout << "Node: "
1406 << "Part" << part << "Module" << module << "pcbBoard1"
1407 << " not found" << std::endl;
1408 return 0;
1409 }
1410
1411 return m_NodepcbBoard1[part][module];
1412}
1413
1414TGeoNode* TofROOTGeo::GetStrip( int part, int module, int strip ) {
1415 if ( m_NodeStrip[part][module][strip] != 0 ) { return m_NodeStrip[part][module][strip]; }
1416 else
1417 {
1418 std::cout << "Node: "
1419 << "Part" << part << "Module" << module << "Strip" << strip << " not found"
1420 << std::endl;
1421 return 0;
1422 }
1423
1424 return m_NodeStrip[part][module][strip];
1425}
1426
1427/*
1428 TGeoNode *
1429 TofROOTGeo::GetBucket( int part, int scin, int bucket )
1430 {
1431 std::stringstream osname;
1432 if (part == 0) {
1433 osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + m_kAssemblyEc
1434 + scin << "_1";
1435 }
1436 else if (part == 1) {
1437 osname << "pv_" << "logical" << "Tof" << "BucketBr" << "_" << scin << "_" << bucket+1;
1438 }
1439 else if (part == 2) {
1440 osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + scin << "_1";
1441 }
1442
1443 return GetNode( osname.str() );
1444 }
1445 */
1446
1447TGeoPhysicalNode* TofROOTGeo::GetPhysicalScin( int part, int layer, int scin ) {
1448 if ( m_PhysicalScin[part][layer][scin] != 0 ) { return m_PhysicalScin[part][layer][scin]; }
1449 else
1450 {
1451 std::cout << "PhysicalNode: "
1452 << "Part" << part << "Layer" << layer << "Scin" << scin << " not found"
1453 << std::endl;
1454 return 0;
1455 }
1456}
1457
1458Tof2DScin* TofROOTGeo::Get2DScin( Int_t part, Int_t layer, Int_t scin ) {
1459 if ( m_Tof2DScin[part][layer][scin] ) return m_Tof2DScin[part][layer][scin];
1460 else return 0;
1461}
1462
1463Int_t TofROOTGeo::GetPart( TGeoPhysicalNode* phyNode ) {
1464 for ( Int_t part = 0; part < m_kPart; part++ )
1465 {
1466 for ( Int_t layer = 0; layer < GetLayerNb( part ); layer++ )
1467 {
1468 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
1469 {
1470 if ( phyNode == GetPhysicalScin( part, layer, scin ) )
1471 {
1472 // cout << "GetPart()" << part << endl;
1473 return part;
1474 }
1475 }
1476 }
1477 }
1478 cout << "TofROOTGeo::GetPart, this scintillator physical node does not exist!" << endl;
1479 return -1;
1480}
1481
1482void TofROOTGeo::Draw( Option_t* option ) {
1483 TString opt = option;
1484 opt.ToUpper();
1485
1486 if ( !m_2DGeoInit ) cout << "TofROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
1487 BesView* view = dynamic_cast<BesView*>( gPad->GetView() );
1488 if ( !view ) cout << "TofROOTGeo::Draw(), BesView not found" << endl;
1489
1490 if ( view->GetVisTofGlobal() )
1491 { // TofVisGlobal
1492 TString scinOpt;
1493
1494 // if (opt.Contains("XY")) {
1495 // west part drawn first usually
1496 for ( Int_t part = m_kPart - 1; part >= 0; part-- )
1497 {
1498 for ( Int_t layer = 0; layer < GetLayerNb( part ); layer++ )
1499 {
1500 for ( int scin = 0; scin < GetScinNb( part ); scin++ )
1501 {
1502 if ( m_Tof2DScin[part][layer][scin] )
1503 {
1504 // cout << "part " << part << " layer " << layer << " scin " << scin << endl;
1505 // m_Tof2DScin[part][layer][scin]->SetHighlighted(false);
1506 m_Tof2DScin[part][layer][scin]->SetFired( false );
1507 if ( ( part == 0 && view->GetVisTofEast() ) ||
1508 ( part == 1 && view->GetVisTofBarrel() ) ||
1509 ( part == 2 && view->GetVisTofWest() ) )
1510 m_Tof2DScin[part][layer][scin]->Draw( scinOpt );
1511 }
1512 }
1513 }
1514 }
1515 }
1516}
1517
1518void TofROOTGeo::DrawHits( Option_t* option ) {
1519 // cout << "Draw Hits" << endl;
1520 BesView* view = dynamic_cast<BesView*>( gPad->GetView() );
1521 if ( !view ) cout << "TofROOTGeo::DrawHits(), BesView not found" << endl;
1522
1523 // cout << "VisTofHitsGlobal " << view->GetVisTofHitsGlobal() << endl;
1524 // cout << "VisTofHitsEast " << view->GetVisTofHitsEast() << endl;
1525 // cout << "VisTofHitsBarrel " << view->GetVisTofHitsBarrel() << endl;
1526 // cout << "VisTofHitsWest " << view->GetVisTofHitsWest() << endl;
1527
1528 if ( view->GetVisTofHitsGlobal() )
1529 {
1530 // Long Peixun's update: Use m_2DHitsArray which contains ready hits rather than rebuild
1531 // hits
1532 for ( int i = 0; i < m_2DHitsArray->GetEntries(); ++i )
1533 {
1534 Tof2DScin* aScin = (Tof2DScin*)m_2DHitsArray->At( i );
1535 if ( aScin )
1536 {
1537 if ( ( k_TMatch ) && ( aScin->GetTimeChannel() == 0x7FFFFFFF ) ) continue;
1538 if ( ( k_QMatch ) && ( aScin->GetChargeChannel() == 0x7FFFFFFF ) ) continue;
1539
1540 if ( ( aScin->GetPart() == 0 && view->GetVisTofHitsEast() ) ||
1541 ( aScin->GetPart() == 1 && view->GetVisTofHitsBarrel() ) ||
1542 ( aScin->GetPart() == 2 && view->GetVisTofHitsWest() ) )
1543 {
1544 aScin->SetFired( true );
1545 aScin->Draw();
1546 }
1547 }
1548 }
1549
1550 /* // reset time and charge to zero
1551 for (Int_t part = m_kPart-1; part >= 0; part--) {
1552 for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
1553 for (int scin = 0; scin < GetScinNb(part); scin++) {
1554 if (m_Tof2DScin[part][layer][scin]) {
1555 m_Tof2DScin[part][layer][scin]->ResetTimeCharge();
1556 }
1557 }
1558 }
1559 }
1560
1561 if (m_TofDigiCol) {
1562 for (int i = 0; i < m_TofDigiCol->GetEntries(); i++) {
1563 TTofDigi *aTofDigi = (TTofDigi*)m_TofDigiCol->At(i);
1564
1565 Identifier aTofID( aTofDigi->getIntId() );
1566 int part = TofID::barrel_ec( aTofID );
1567 int layer = TofID::layer( aTofID );
1568 int scin = TofID::phi_module( aTofID );
1569
1570 Double_t charge = Double_t(aTofDigi->getChargeChannel()) / TOF_CHARGE_FACTOR;
1571 //cout << "charge " << charge << endl;
1572
1573 Tof2DScin *aScin = 0;
1574 aScin = m_Tof2DScin[part][layer][scin];
1575 // Mdc TQMatch for example
1576 //
1577 //if (aWire &&
1578 // ((overflow == 0)||(overflow == 12))){
1579 // if ((k_TMatch) &&
1580 // (aMdcDigi->getTimeChannel() == 0x7FFFFFFF)){
1581 // continue;
1582 // }
1583 // if ((k_QMatch) &&
1584 // (aMdcDigi->getChargeChannel() == 0x7FFFFFFF)){
1585 // continue;
1586 // }
1587 //}
1588
1589 if (aScin) {
1590 if ((k_TMatch)&&
1591 (aTofDigi->getTimeChannel() == 0x7FFFFFFF)){
1592 continue;
1593 }
1594 if ((k_QMatch)&&
1595 (aTofDigi->getChargeChannel() == 0x7FFFFFFF)){
1596 continue;
1597 }
1598
1599 aScin->SetCharge(aScin->GetCharge() + charge);
1600
1601 if ( (part == 0 && view->GetVisTofHitsEast()) ||
1602 (part == 1 && view->GetVisTofHitsBarrel()) ||
1603 (part == 2 && view->GetVisTofHitsWest()) ) {
1604 aScin->SetFired(true);
1605 aScin->Draw();
1606 }
1607 }
1608 }
1609 } */
1610 }
1611}
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 time
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:42
UInt_t getChargeChannel() const
Definition TRawData.cxx:48
UInt_t getTimeChannel() const
Definition TRawData.cxx:45
virtual void Draw(Option_t *option="")
virtual void SetCharge(Double_t charge)
virtual void SetFired(bool status=true)
virtual void CloseInfo()
virtual void ClearInfo()
static int endcap(const Identifier &id)
Definition TofID.cxx:108
static int strip(const Identifier &id)
Definition TofID.cxx:120
static int phi_module(const Identifier &id)
Definition TofID.cxx:65
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition TofID.cxx:54
static int layer(const Identifier &id)
Definition TofID.cxx:59
static int module(const Identifier &id)
Definition TofID.cxx:114
TGeoNode * GetAl(int part, int layer)
Get Al node;.
void SetQuarterVisible()
Set quater visible;.
TGeoNode * GetpcbBoard1(int part, int module)
Get pcbBoard1 node;.
TGeoVolume * GetVolumeScin(int part)
Get scintillator volume;.
void SetVolumeTof(TGeoVolume *vol)
Set Tof volume, while initializing from ROOT;.
void InitFromROOT(TGeoVolume *vol)
Initialize ROOTGeo from TGeoVolume logicalTof.
TGeoVolume * GetVolumeAl(int part, int layer)
Get Al volume;.
TGeoNode * GetModule(int part, int module)
Get module node;.
TGeoNode * GetgasContainer(int part, int module)
Get gasContainer node;.
void Draw(Option_t *option)
Draw function.
void InitFromGDML(const char *gdmlFile, const char *setupName)
Initialize ROOTGeo from GDML.
TGeoVolume * GetVolumeBucket(int part)
Get bucket volume;.
void SetHalfVisible()
Set half visible;.
TGeoNode * GetbareChamber(int part, int module)
Get bareChamber node;.
void SetNoEndVisible()
Set noend visible;.
void SetHits()
Set all physicalNodes corresponding to digiCol;.
TGeoVolume * GetVolumePart(int part)
Get assembly volume; part=0,2 for AssemblyEc, 1 for AssemblyBr;.
void SetDetector()
Draw Detecor (what is detector depends on you).
TGeoNode * GetScin(int part, int scin)
Get scintillator node;.
void DrawHits(Option_t *option)
Draw 2D hits.
Tof2DScin * Get2DScin(Int_t part, Int_t layer, Int_t scin)
Get Tof2DScin;.
TGeoNode * GetStrip(int part, int module, int strip)
Get strip node;.
void SetVisTofDetector()
Set Tof detector visibility;.
int GetScinNb(int part)
Get number of scintillators on each part;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
TGeoNode * GetPVF(int part, int layer, int scin)
Get PVF node;.
void Init2DGeometry()
Initialize 2D Geometry.
TGeoVolume * GetVolumePVF(int part, int layer)
Get PVF volume;.
void SetVisTofHits()
Set Tof hits visibility;.
TGeoPhysicalNode * GetPhysicalScin(int part, int scin)
Get scintillator physical node;.
Int_t GetPart(TGeoPhysicalNode *phyNode)
Get part no of a scintillator physcial node.
void SetNode()
Set the pointers to theirs nodes;.
void SetVolumeDefaultVis()
Set default visual attributes;.