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