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