BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
EventDisplay/BesVisLib/BesVisLib-00-04-03/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 <TMath.h>
24
26#include "Identifier/TofID.h"
27#include "BesVisLib/BesEvent.h"
28#include "BesVisLib/BesView.h"
30
31
34{
35 // Default constructor.
36 k_TMatch = kTRUE;
37 k_QMatch = kTRUE;
38 for (int part = 0; part < m_kPart; part++) {
39 for (int layer = 0; layer < m_kLayerBr; layer++) {
40 m_NodeAl[part][layer] = 0;
41 m_NodeScin[part][layer] = 0;
42 for (int scin = 0; scin < m_kScinBr; scin++) {
43 m_NodePVF[part][layer][scin] = 0;
44 m_PhysicalScin[part][layer][scin] = 0;
45 m_Tof2DScin[part][layer][scin] = 0;
46 }
47 }
48 }
49
50 m_TofColor = 6;
51 m_BucketColor = 4;
52 m_ScinColor = kYellow;
53}
54
56{ }
57
58void
59TofROOTGeo::InitFromGDML( const char *gdmlFile, const char *setupName )
60{
61 m_ROOTGeoInit = 2;
62
63 ReadGdml(gdmlFile, setupName);
64 SetNode();
65}
66
67void
68TofROOTGeo::InitFromROOT( TGeoVolume *vol )
69{
70 m_ROOTGeoInit = 1;
71
72 SetVolumeTof(vol);
73 SetNode();
74}
75
76void
78{
79 if (m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2) {
80 cout << "TofROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
81 return;
82 }
83 m_2DGeoInit = 1;
84
85 Double_t local[3] = {0.0, 0.0, 0.0};
86 Double_t master[3] = {0.0, 0.0, 0.0};
87 //Int_t nPoints = 8;
88 //Double_t P[300] = {0.0};
89 //Double_t center[3] = {0.0, 0.0, 0.0};
90 TString name;
91
92 // Tof Scintillators
93 for (Int_t part = 0; part < m_kPart; part++) {
94 for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
95 for (int scin = 0; scin < GetScinNb(part); scin++) {
96 TGeoPhysicalNode *scinPhyNode = GetPhysicalScin(part, layer, scin);
97 if (part == 1) {
98 name = TString("Tof Part 1");
99 name += " Layer ";
100 name += layer;
101 name += " Phi ";
102 name += scin;
103 }
104 else {
105 if (part == 0) name = TString("EastEc");
106 else if (part == 2) name = TString("WestEc");
107 name = TString("Tof Part ");
108 name += part;
109 name += " Phi ";
110 name += scin;
111 }
112 TGeoArb8 *scinShape = (TGeoArb8*)scinPhyNode->GetShape();
113 Double_t *localArb8Point, masterArb8Point[24];
114 localArb8Point = scinShape->GetVertices();
115
116 for (Int_t i = 0; i < 8; i++) {
117 local[0] = localArb8Point[2*i];
118 local[1] = localArb8Point[2*i+1];
119 if (i < 4) local[2] = scinShape->GetDz() * (-1.0);
120 else local[2] = scinShape->GetDz();
121
122 //cout << i << " local x: " << local[0] << " y: " << local[1] << " z: " << local[2] << endl;
123 scinPhyNode->GetMatrix(-1*scinPhyNode->GetLevel())->LocalToMaster(local, &master[0]); // transform to top
124 //cout << " master x: " << master[0] << " y: " << master[1] << " z: " << master[2] << endl;
125
126 for (Int_t j = 0; j < 3; j++) {
127 masterArb8Point[3*i+j] = master[j];
128 }
129 }
130
131 m_Tof2DScin[part][layer][scin] = new Tof2DScin(name, name, 8, &masterArb8Point[0], part);
132 }
133 }
134 }
135}
136
137void
139{
140 if (m_ROOTGeoInit == 2) { // from GDML
141 m_Tof = GetTopVolume();
142 if (!m_Tof) std::cout << "m_Tof = 0" << std::endl;
143
144 for (int part = 0; part < m_kPart; part++) {
145 for (int layer = 0; layer < GetLayerNb(part); layer++) {
146 std::stringstream osnameAl;
147 if (part == 1) osnameAl << "pv_" << "logical" << "AlBr" << layer+1 << "_0";
148 else if (part == 0) osnameAl << "pv_" << "logical" << "AlEcEast" << "_0";
149 else osnameAl << "pv_" << "logical" << "AlEcWest" << "_0";
150 m_NodeAl[part][layer] = GetNode( osnameAl.str() );
151
152 std::stringstream osnameScin;
153 if (part == 1) osnameScin << "pv_" << "logical" << "ScinBr" << layer+1 << "_0";
154 else if (part == 0) osnameScin << "pv_" << "logical" << "ScinEcEast" << "_0";
155 else osnameScin << "pv_" << "logical" << "ScinEcWest" << "_0";
156
157 m_NodeScin[part][layer] = GetNode( osnameScin.str() );
158
159 for (int scin = 0; scin < GetScinNb(part); scin++) {
160 std::stringstream osnamePVF;
161 if (part == 1) {
162 osnamePVF << "pv_" << "logicalPVFBr"<< layer+1 << "_" << (2*m_kScinBr*3 - 1) - (layer*m_kScinBr + scin)*3;
163 }
164 else if (part == 2) {
165 osnamePVF << "pv_" << "logicalPVFEcWest" << "_" << (2*m_kScinEc - 1) - scin*2;
166
167 }
168 else if (part == 0) {
169 osnamePVF << "pv_" << "logicalPVFEcEast" << "_" << (2*m_kScinEc - 1) - scin*2;
170 }
171 m_NodePVF[part][layer][scin] = GetNode( osnamePVF.str() );
172 }
173 }
174 }
175 }
176 else if (m_ROOTGeoInit == 1) { // from ROOT object
177 for (int part = 0; part < m_kPart; part++) {
178 int ipart = 0;
179 if (part == 1) ipart = 2;
180 if (part ==2 ) ipart = 1;
181 for (int layer = 0; layer < GetLayerNb(part); layer++) {
182 for (int scin = 0; scin < GetScinNb(part); scin++) {
183 int iNode = 0;
184// if (part == 1) {
185// iNode = layer*m_kScinBr + scin;
186// }
187// else if (part == 2) { // West placed first in Tof.gdml
188// iNode = 2*m_kScinBr + scin;
189// }
190// else if (part == 0) {
191// iNode = 2*m_kScinBr + m_kScinEc + scin;
192// }
193 if (part != 1){
194 iNode = (2*m_kScinEc - 1) - scin*2;
195 }
196 if (part == 1) {
197 iNode = (2*m_kScinBr*3 - 1) - (layer*m_kScinBr + scin)*3;
198 }
199
200 m_NodePVF[part][layer][scin] = m_Tof->GetNode( ipart )->GetVolume()->GetNode(iNode);//fix me, change structure now
201 }
202 m_NodeAl[part][layer] = m_NodePVF[part][layer][0]->GetVolume()->GetNode(0);
203 //cout << m_NodeAl[part][layer]->GetName() << endl;
204 m_NodeScin[part][layer] = m_NodeAl[part][layer]->GetVolume()->GetNode(0);
205 //cout << m_NodeScin[part][layer]->GetName() << endl;
206 }
207 }
208 }
209
210 //std::cout << "TofROOTGeo::SetNode, end of set node" << std::endl;
211}
212
213void
215{
216 //std::cout << "begin of set defaultvis" << std::endl;
217
218 m_Tof->SetLineColor(m_TofColor);
219 m_Tof->SetVisibility(0);
220
221 for (int part = 0; part < m_kPart; part++) {
222 GetVolumePart(part)->SetLineColor(m_ScinColor);
223 GetVolumePart(part)->SetVisibility(0);
224 for (int layer = 0; layer < GetLayerNb(part); layer++) {
225 GetVolumePVF(part, layer)->SetLineColor(m_ScinColor);
226 GetVolumePVF(part, layer)->SetVisibility(0);
227
228 GetVolumeAl(part, layer)->SetLineColor(m_ScinColor);
229 GetVolumeAl(part, layer)->SetVisibility(0);
230
231 GetVolumeScin(part, layer)->SetLineColor(m_ScinColor);
232 GetVolumeScin(part, layer)->SetVisibility(0);
233
234 GetVolumeBucket(part, layer)->SetLineColor(m_BucketColor);
235 GetVolumeBucket(part, layer)->SetVisibility(0);
236 }
237 }
238 //std::cout << "end of set defaultvis" << std::endl;
239}
240
241void
242TofROOTGeo::SetTMatch(Bool_t input = false){
243 k_TMatch = input;
244}
245
246void
247TofROOTGeo::SetQMatch(Bool_t input = false){
248 k_QMatch = input;
249}
250
251void
253{
254 m_Tof->SetLineColor(m_TofColor);
255 m_Tof->SetVisibility(0);
256
257 for (int part = 0; part < m_kPart; part++) {
258 for (int layer = 0; layer < GetLayerNb(part); layer++) {
259 GetVolumePVF(part, layer)->SetLineColor(m_ScinColor);
260 GetVolumePVF(part, layer)->SetVisibility(1);
261
262 GetVolumeAl(part, layer)->SetLineColor(m_ScinColor);
263 GetVolumeAl(part, layer)->SetVisibility(1);
264
265 GetVolumeScin(part, layer)->SetLineColor(m_ScinColor);
266 GetVolumeScin(part, layer)->SetVisibility(1);
267
268 GetVolumeBucket(part, layer)->SetLineColor(m_BucketColor);
269 GetVolumeBucket(part, layer)->SetVisibility(1);
270 }
271 }
272}
273
274void
276{
277 /*
278 for (int part = 0; part < m_kPart; part++) {
279 GetVolumeScin(part)->SetVisibility(1);
280 GetVolumeBucket(part)->SetVisibility(1);
281
282 int nScin = 0;
283 if (part == 1) nScin = m_kAssemblyBr;
284 else nScin = m_kAssemblyEc;
285 for (int scin = 0; scin < nScin; scin++) {
286 if (scin < nScin/4) GetScin(part, scin)->SetVisibility(0);
287 else GetScin(part, scin)->SetVisibility(1);
288
289 int nBucket = 0;
290 if (part == 1) nBucket = m_kBucketBr;
291 else nBucket = m_kBucketEc;
292 for (int bucket = 0; bucket < nBucket; bucket++) {
293 if (scin < nScin/4) GetBucket(part, scin, bucket)->SetVisibility(0);
294 else GetBucket(part, scin, bucket)->SetVisibility(1);
295 }
296 }
297 }
298 */
299}
300
301void
303{
304 /*
305 for (int part = 0; part < m_kPart; part++) {
306 GetVolumeScin(part)->SetVisibility(1);
307 GetVolumeBucket(part)->SetVisibility(1);
308
309 int nScin = 0;
310 if (part == 1) nScin = m_kAssemblyBr;
311 else nScin = m_kAssemblyEc;
312 for (int scin = 0; scin < nScin; scin++) {
313 if (scin < nScin/4+1 ||
314 scin > nScin*3/4 ) GetScin(part, scin)->SetVisibility(1);
315 else GetScin(part, scin)->SetVisibility(0);
316
317 int nBucket = 0;
318 if (part == 1) nBucket = m_kBucketBr;
319 else nBucket = m_kBucketEc;
320 for (int bucket = 0; bucket < nBucket; bucket++) {
321 if (scin < nScin/4+1 ||
322 scin > nScin*3/4 ) GetBucket(part, scin, bucket)->SetVisibility(1);
323 else GetBucket(part, scin, bucket)->SetVisibility(0);
324 }
325 }
326 }
327 */
328}
329
330void
332{
333 /*
334 int part = 1;
335 GetVolumeScin(0)->SetVisibility(1);
336 GetVolumeBucket(0)->SetVisibility(1);
337
338 int nScin = 0;
339 nScin = m_kAssemblyBr;
340 for (int scin = 0; scin < nScin; scin++) {
341 GetScin(part, scin)->SetVisibility(1);
342
343 int nBucket = 0;
344 nBucket = m_kBucketBr;
345 for (int bucket = 0; bucket < nBucket; bucket++) {
346 GetBucket(part, scin, bucket)->SetVisibility(1);
347 }
348 }
349 */
350}
351
352void
354{
355 if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
356 TGeoNode *bes = gGeoManager->GetTopNode();
357 //std::cout << "Tof m_childNo " << m_childNo << std::endl;
358 //TGeoNode *nodeTof = bes->GetVolume()->GetNode(0);
359 TGeoNode *nodeTof = bes->GetDaughter(1);
360 for (int part = 0; part < m_kPart; part++) {
361
362// std::stringstream osnamePart;
363// if (part == 1) osnamePart << "pv_" << "logicalBrTof" << "_2";
364// else if(part == 0) osnamePart << "pv_" << "logicalEcTofEast" << "_0";
365// else osnamePart << "pv_" << "logicalEcTofWest" << "_1";
366
367// TGeoNode *nodePart = GetNode( osnamePart.str() );
368
369 int ipart = 0;
370 if (part == 1) ipart = 2;
371 if (part ==2 ) ipart = 1;
372 TGeoNode *nodePart;
373 nodePart = nodeTof->GetVolume()->GetNode(ipart);
374
375 for (int layer = 0; layer < GetLayerNb(part); layer++) {
376 TGeoNode *nodeAl = GetAl(part, layer);
377 TGeoNode *nodeScin = GetScin(part, layer);
378 for (int scin = 0; scin < GetScinNb(part); scin++) {
379 TGeoNode *nodePVF = GetPVF(part, layer, scin);
380 m_PhysicalScin[part][layer][scin] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
381 TString("/") + nodeTof->GetName() +
382 TString("/") + nodePart->GetName() +
383 TString("/") + nodePVF->GetName() +
384 TString("/") + nodeAl->GetName() +
385 TString("/") + nodeScin->GetName() );
386 //cout<<"in SetPhysicalNode() "<<part<<" "<<layer<<" "<<scin<<" "<<endl;
387 //cout<<" "<<bes->GetName()<<" "<<nodeTof->GetName()<<" "<<nodePVF->GetName()<<" "<<nodeAl->GetName()<<" "<<nodeScin->GetName()<<endl;
388 m_PhysicalScin[part][layer][scin]->SetVisibility(0);
389 m_PhysicalScin[part][layer][scin]->SetIsVolAtt(kFALSE);
390 m_PhysicalScin[part][layer][scin]->SetLineColor(m_ScinColor);
391 }
392 }
393 }
394
395 SetDetector();
396}
397
398void
400{
401 BesView *view = 0;
402 if (gPad) view = (BesView*)gPad->GetView();
403 //if (view) cout << "viewVisFull3DTof " << view->GetVisFull3DTof() << endl;
404
405 m_DetectorsArray->Clear();
406 for (int part = 0; part < m_kPart; part++) {
407 for (int layer = 0; layer < GetLayerNb(part); layer++) {
408 for (int scin = 0; scin < GetScinNb(part); scin++) {
409 TGeoPhysicalNode *phyNode = 0;
410 phyNode = GetPhysicalScin(part, layer, scin);
411 if (phyNode) {
412 phyNode->SetVisibility(0); // set all invisible before set any visible
413 if (part == 2 ||
414 (scin >= GetScinNb(part)*0/4 && scin < GetScinNb(part)*8/8)) {
415 m_DetectorsArray->Add( phyNode );
416 }
417 else if (view && view->GetVisFull3DTof()) {
418 m_DetectorsArray->Add( phyNode );
419 }
420 }
421 }
422 }
423 }
424}
425
426void
428{
429 // set previous event hits to default vis
430 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
431 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
432 if (phyNode){
433 //phyNode->SetLineColor(m_ScinColor);
434 phyNode->SetVisibility(0);
435 }
436 }
437 m_HitsArray->Clear("C");
438
439 // set previous event 2D hits info to default
440 for (int i = 0; i < m_2DHitsArray->GetEntries(); i++) {
441 Tof2DScin *aScin = (Tof2DScin*)m_2DHitsArray->At(i);
442 aScin->ClearInfo();
443 aScin->AddInfo(aScin->GetTitle());
444 aScin->CloseInfo();
445 aScin->ResetTimeCharge();
446 }
447 m_2DHitsArray->Clear("C");
448
449 if (gEvent) m_TofDigiCol = gEvent->GetTofDigiCol();
450
451 for (int i = 0; i < m_TofDigiCol->GetEntries(); i++) {
452 TTofDigi *aTofDigi = (TTofDigi*)m_TofDigiCol->At(i);
453
454 Identifier atofID( aTofDigi->getIntId() );
455 int part = TofID::barrel_ec( atofID );
456 int layer = TofID::layer( atofID );
457 int scin = TofID::phi_module( atofID );
458
459 //Double_t charge = Double_t(aTofDigi->getChargeChannel()) / TOF_CHARGE_FACTOR;
460 //Double_t time = Double_t(aTofDigi->getTimeChannel()) / TOF_TIME_FACTOR;
461
462 Double_t charge = RawDataUtil::TofCharge(aTofDigi->getChargeChannel());
463 Double_t time = RawDataUtil::TofTime(aTofDigi->getTimeChannel());
464
465 TGeoPhysicalNode *phyNode = 0;
466 phyNode = GetPhysicalScin( part, layer, scin );
467 if (phyNode) {
468 m_HitsArray->Add( phyNode );
469 }
470
471 Tof2DScin *aScin = 0;
472 aScin = m_Tof2DScin[part][layer][scin];
473 if (aScin) {
474 char data[100];
475
476 if (aScin->GetCharge() == 0.0) {
477 aScin->ClearInfo();
478 aScin->AddInfo(aScin->GetTitle());
479 sprintf(data, "time1 = %-.3f ns, charge1 = %-.3f MeV", time, charge);
480 aScin->AddInfo( TString(data) );
481 }
482 else {
483 sprintf(data, "time2 = %-.3f ns, charge2 = %-.3f MeV", time, charge);
484 aScin->AddInfo( TString(data) );
485 sprintf(data, "Fired");
486 aScin->AddInfo( TString(data) );
487 }
488
489 aScin->CloseInfo();
490 aScin->SetCharge(aScin->GetCharge() + charge);
491
492 m_2DHitsArray->Add(aScin);
493 }
494 }
495}
496
497 void
499{
500 /*
501 for (int part = 0; part < m_kPart; part++) {
502 for (int layer = 0; layer < GetLayerNb(part); layer++) {
503 for (int scin = 0; scin < GetScinNb(part); scin++) {
504 TGeoPhysicalNode *phyNode = GetPhysicalScin(part, layer, scin);
505 if (phyNode) phyNode->SetLineColor(m_ScinColor);
506 }
507 }
508 }
509 */
510
511 BesView *view = 0;
512 if (gPad) view = (BesView*)gPad->GetView();
513
514 //cout << "VisTofEast " << view->GetVisTofEast() << endl;
515 for (int i = 0; i < m_DetectorsArray->GetEntries(); i++) {
516 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At(i);
517 phyNode->SetVisibility(0);
518 if (view && view->GetVisTofGlobal()) {
519 int part = GetPart(phyNode);
520 if (part == 0 && view->GetVisTofEast() ||
521 part == 1 && view->GetVisTofBarrel() ||
522 part == 2 && view->GetVisTofWest() )
523 phyNode->SetVisibility(1);
524 }
525 }
526}
527
528 void
530{
531 BesView *view = 0;
532 if (gPad) view = (BesView*)gPad->GetView();
533
534 for (int i = 0; i < m_HitsArray->GetEntries(); i++) {
535 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_HitsArray->At(i);
536 if (phyNode){
537 if (view && view->GetVisTofHitsGlobal()) {
538 int part = GetPart(phyNode);
539 if (part == 0 && view->GetVisTofHitsEast() ||
540 part == 1 && view->GetVisTofHitsBarrel() ||
541 part == 2 && view->GetVisTofHitsWest() ) {
542 phyNode->SetVisibility(1);
543 phyNode->SetLineColor(kGreen);
544 continue;
545 }
546 }
547 phyNode->SetVisibility(0);
548 }
549 }
550}
551
552 int
554{
555 int nPart = m_kPart;
556 return nPart;
557}
558
559 int
560TofROOTGeo::GetScinNb(int part)
561{
562 int nScin = m_kScinBr;
563 if (part != 1) nScin = m_kScinEc;
564 return nScin;
565}
566
567 int
569{
570 int nLayer = m_kLayerBr;
571 if (part != 1) nLayer = m_kLayerEc;
572 return nLayer;
573}
574
575/*
576 TGeoVolumeAssembly*
577 TofROOTGeo::GetVolumeAssembly( int part )
578 {
579 std::stringstream osname;
580 if (part == 0 || part == 2) {
581 osname << "logical" << "Tof" << "AssemblyEc";
582 }
583 else {
584 if (part == 1) {
585 osname << "logical" << "Tof" << "AssemblyBr";
586 }
587 }
588
589 return GetAssemblyVolume( osname.str() );
590 }
591 */
592
593 TGeoVolume*
595{
596 std::stringstream osname;
597 if (part == 1) {
598 osname << "logicalBrTof";
599 }
600 else if (part == 0){
601 osname << "logicalEcTofWest";
602 }
603 else {
604 osname << "logicalEcTofEast";
605 }
606
607 return GetLogicalVolume( osname.str() );
608
609
610
611}
612
613 TGeoVolume*
614TofROOTGeo::GetVolumePVF( int part, int layer )
615{
616 std::stringstream osname;
617 if (part == 0) {
618 osname << "logical" << "PVFEcEast";
619 }
620 else if (part == 2){
621 osname << "logical" << "PVFEcWest";
622 }
623 else {
624 if (part == 1) {
625 osname << "logical" << "PVFBr" << layer+1;
626 }
627 }
628
629 return GetLogicalVolume( osname.str() );
630}
631
632 TGeoVolume*
633TofROOTGeo::GetVolumeAl( int part, int layer )
634{
635 std::stringstream osname;
636 if (part == 0) {
637 osname << "logical" << "AlEcEast";
638 }
639 else if (part == 2){
640 osname << "logical" << "AlEcWest";
641 }
642 else {
643 if (part == 1) {
644 osname << "logical" << "AlBr" << layer+1;
645 }
646 }
647
648 return GetLogicalVolume( osname.str() );
649}
650
651 TGeoVolume*
652TofROOTGeo::GetVolumeScin( int part, int layer )
653{
654 std::stringstream osname;
655 if (part == 0) {
656 osname << "logical" << "ScinEcEast";
657 }
658 else if (part == 2){
659 osname << "logical" << "ScinEcWest";
660 }
661 else {
662 if (part == 1) {
663 osname << "logical" << "ScinBr" << layer+1;
664 }
665 }
666
667 return GetLogicalVolume( osname.str() );
668}
669
670 TGeoVolume*
671TofROOTGeo::GetVolumeBucket( int part, int layer )
672{
673 std::stringstream osname;
674 if (part == 0 || part == 2) {
675 osname << "logical" << "BucketEc";
676 }
677 else {
678 if (part == 1) {
679 osname << "logical" << "BucketBr" << layer+1;
680 }
681 }
682
683 return GetLogicalVolume( osname.str() );
684}
685
686 TGeoNode*
687TofROOTGeo::GetPVF( int part, int layer, int scin )
688{
689 if (m_NodePVF[part][layer][scin] != 0) {
690 return m_NodePVF[part][layer][scin];
691 }
692 else {
693 std::cout << "Node: " << "Part" << part << "Layer" << layer << "PVF" << scin << " not found" << std::endl;
694 return 0;
695 }
696
697 return m_NodePVF[part][layer][scin];
698}
699
700 TGeoNode*
701TofROOTGeo::GetAl( int part, int layer )
702{
703 if (m_NodeAl[part][layer] != 0) {
704 return m_NodeAl[part][layer];
705 }
706 else {
707 std::cout << "Node: " << "Part" << part << "Layer" << layer << "Al" << " not found" << std::endl;
708 return 0;
709 }
710
711 return m_NodeAl[part][layer];
712}
713
714 TGeoNode*
715TofROOTGeo::GetScin( int part, int layer )
716{
717 if (m_NodeScin[part][layer] != 0) {
718 return m_NodeScin[part][layer];
719 }
720 else {
721 std::cout << "Node: " << "Part" << part << "Layer" << layer << "Scin" << " not found" << std::endl;
722 return 0;
723 }
724
725 return m_NodeScin[part][layer];
726}
727
728
729/*
730 TGeoNode *
731 TofROOTGeo::GetBucket( int part, int scin, int bucket )
732 {
733 std::stringstream osname;
734 if (part == 0) {
735 osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + m_kAssemblyEc + scin << "_1";
736 }
737 else if (part == 1) {
738 osname << "pv_" << "logical" << "Tof" << "BucketBr" << "_" << scin << "_" << bucket+1;
739 }
740 else if (part == 2) {
741 osname << "pv_" << "logical" << "Tof" << "BucketEc" << "_" << m_kAssemblyBr + scin << "_1";
742 }
743
744 return GetNode( osname.str() );
745 }
746 */
747
748 TGeoPhysicalNode*
749TofROOTGeo::GetPhysicalScin( int part, int layer, int scin )
750{
751 if (m_PhysicalScin[part][layer][scin] != 0) {
752 return m_PhysicalScin[part][layer][scin];
753 }
754 else {
755 std::cout << "PhysicalNode: " << "Part"
756 << part << "Layer" << layer << "Scin"
757 << scin << " not found" << std::endl;
758 return 0;
759 }
760}
761
762 Tof2DScin*
763TofROOTGeo::Get2DScin( Int_t part, Int_t layer, Int_t scin)
764{
765 if (m_Tof2DScin[part][layer][scin]) return m_Tof2DScin[part][layer][scin];
766 else return 0;
767}
768
769 Int_t
770TofROOTGeo::GetPart(TGeoPhysicalNode* phyNode)
771{
772 for (Int_t part = 0; part < m_kPart; part++) {
773 for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
774 for (int scin = 0; scin < GetScinNb(part); scin++) {
775 if (phyNode == GetPhysicalScin(part, layer, scin)) {
776 //cout << "GetPart()" << part << endl;
777 return part;
778 }
779 }
780 }
781 }
782
783 cout << "TofROOTGeo::GetPart, this scintillator physical node does not exist!" << endl;
784 return -1;
785}
786
787 void
788TofROOTGeo::Draw(Option_t *option)
789{
790 TString opt = option;
791 opt.ToUpper();
792
793 if (!m_2DGeoInit) cout << "TofROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
794 BesView *view = (BesView*)gPad->GetView();
795 if (!view) cout << "TofROOTGeo::Draw(), BesView not found" << endl;
796
797 if (view->GetVisTofGlobal()) { // TofVisGlobal
798 TString scinOpt;
799
800 //if (opt.Contains("XY")) {
801 // west part drawn first usually
802 for (Int_t part = m_kPart-1; part >= 0; part--) {
803 for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
804 for (int scin = 0; scin < GetScinNb(part); scin++) {
805
806 if (m_Tof2DScin[part][layer][scin]) {
807 //cout << "part " << part << " layer " << layer << " scin " << scin << endl;
808 //m_Tof2DScin[part][layer][scin]->SetHighlighted(false);
809 m_Tof2DScin[part][layer][scin]->SetFired(false);
810 if ( (part == 0 && view->GetVisTofEast()) ||
811 (part == 1 && view->GetVisTofBarrel()) ||
812 (part == 2 && view->GetVisTofWest()) )
813 m_Tof2DScin[part][layer][scin]->Draw(scinOpt);
814 }
815 }
816 }
817 }
818 }
819 }
820
821 void
822 TofROOTGeo::DrawHits(Option_t *option)
823 {
824 // cout << "Draw Hits" << endl;
825 BesView *view = (BesView*)gPad->GetView();
826 if (!view) cout << "TofROOTGeo::DrawHits(), BesView not found" << endl;
827
828 //cout << "VisTofHitsGlobal " << view->GetVisTofHitsGlobal() << endl;
829 //cout << "VisTofHitsEast " << view->GetVisTofHitsEast() << endl;
830 //cout << "VisTofHitsBarrel " << view->GetVisTofHitsBarrel() << endl;
831 //cout << "VisTofHitsWest " << view->GetVisTofHitsWest() << endl;
832
833 if (view->GetVisTofHitsGlobal()) {
834
835 // reset time and charge to zero
836 for (Int_t part = m_kPart-1; part >= 0; part--) {
837 for (Int_t layer = 0; layer < GetLayerNb(part); layer++) {
838 for (int scin = 0; scin < GetScinNb(part); scin++) {
839 if (m_Tof2DScin[part][layer][scin]) {
840 m_Tof2DScin[part][layer][scin]->ResetTimeCharge();
841 }
842 }
843 }
844 }
845
846 if (m_TofDigiCol) {
847 for (int i = 0; i < m_TofDigiCol->GetEntries(); i++) {
848 TTofDigi *aTofDigi = (TTofDigi*)m_TofDigiCol->At(i);
849
850 Identifier aTofID( aTofDigi->getIntId() );
851 int part = TofID::barrel_ec( aTofID );
852 int layer = TofID::layer( aTofID );
853 int scin = TofID::phi_module( aTofID );
854
855 Double_t charge = Double_t(aTofDigi->getChargeChannel()) / TOF_CHARGE_FACTOR;
856 //cout << "charge " << charge << endl;
857
858 Tof2DScin *aScin = 0;
859 aScin = m_Tof2DScin[part][layer][scin];
860 // Mdc TQMatch for example
861 //
862 //if (aWire &&
863 // ((overflow == 0)||(overflow == 12))){
864 // if ((k_TMatch) &&
865 // (aMdcDigi->getTimeChannel() == 0x7FFFFFFF)){
866 // continue;
867 // }
868 // if ((k_QMatch) &&
869 // (aMdcDigi->getChargeChannel() == 0x7FFFFFFF)){
870 // continue;
871 // }
872 //}
873
874 if (aScin) {
875 if ((k_TMatch)&&
876 (aTofDigi->getTimeChannel() == 0x7FFFFFFF)){
877 continue;
878 }
879 if ((k_QMatch)&&
880 (aTofDigi->getChargeChannel() == 0x7FFFFFFF)){
881 continue;
882 }
883
884 aScin->SetCharge(aScin->GetCharge() + charge);
885
886 if ( (part == 0 && view->GetVisTofHitsEast()) ||
887 (part == 1 && view->GetVisTofHitsBarrel()) ||
888 (part == 2 && view->GetVisTofHitsWest()) ) {
889 aScin->SetFired(true);
890 aScin->Draw();
891 }
892 }
893 }
894 }
895 }
896 }
R__EXTERN BesEvent * gEvent
Definition: BesEvent.h:278
TTree * data
Double_t time
const TObjArray * GetTofDigiCol() const
Definition: BesEvent.h:74
Bool_t GetVisFull3DTof()
Definition: BesView.h:143
Bool_t GetVisTofBarrel()
Definition: BesView.h:105
Bool_t GetVisTofEast()
Definition: BesView.h:104
Bool_t GetVisTofGlobal()
Definition: BesView.h:103
Bool_t GetVisTofHitsWest()
Definition: BesView.h:172
Bool_t GetVisTofHitsGlobal()
Definition: BesView.h:169
Bool_t GetVisTofWest()
Definition: BesView.h:106
Bool_t GetVisTofHitsBarrel()
Definition: BesView.h:171
Bool_t GetVisTofHitsEast()
Definition: BesView.h:170
static double TofTime(unsigned int timeChannel)
Definition: RawDataUtil.h:63
static double TofCharge(unsigned int chargeChannel)
Definition: RawDataUtil.h:66
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 Double_t GetCharge()
Definition: Tof2DScin.h:42
virtual void Draw(Option_t *option="")
Definition: Tof2DScin.cxx:197
virtual void AddInfo(TString info)
Definition: Tof2DScin.h:35
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:121
virtual void ClearInfo()
Definition: Tof2DScin.cxx:115
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
TGeoNode * GetAl(int part, int layer)
Get Al 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;.
void InitFromGDML(const char *gdmlFile, const char *setupName)
Initialize ROOTGeo from GDML.
TGeoVolume * GetVolumeBucket(int part)
Get bucket volume;.
void SetHits()
Set all physicalNodes corresponding to digiCol;.
TGeoVolume * GetVolumePart(int part)
Get assembly volume; part=0,2 for AssemblyEc, 1 for AssemblyBr;
void SetDetector()
Draw Detecor (what is detector depends on you)
TGeoNode * GetScin(int part, int scin)
Get scintillator node;.
void DrawHits(Option_t *option)
Draw 2D hits.
Tof2DScin * Get2DScin(Int_t part, Int_t layer, Int_t scin)
Get Tof2DScin;.
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;.