CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
EventDisplay/BesVisLib/BesVisLib-00-06-12/src/MdcROOTGeo.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/10 Zhengyun You Peking University
7 * named from MdcGeo to MdcROOTGeo
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/MdcID.h"
27#include "BesVisLib/BesEvent.h"
28#include "BesVisLib/BesView.h"
30
31const int
32MdcROOTGeo::m_kReplica[m_kLayer] = { 40, 44, 48, 56, 64, 72, 80, 80,
33 76, 76, 88, 88, 100, 100, 112, 112, 128, 128, 140, 140,
34 160, 160, 160, 160, 176, 176, 176, 176, 208, 208, 208, 208, 240, 240, 240, 240,
35 256, 256, 256, 256, 256, 256, 256, 256,
36 288, 288, 288, 288, 288, 288
37 };
38
39const int
40MdcROOTGeo::m_kStereoDir[m_kTrueLayer] = { 1, 1, 1, 1, -1, -1, -1, -1,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1,
43 0, 0, 0, 0, 0, 0, 0
44 };
45const int
46MdcROOTGeo::m_kiCorrectLayer[m_kCorrectLayer] = {9, 11, 13, 15, 17, 19, 36, 38, 40, 42};
47const int
48//MdcROOTGeo::m_kiCorrectReplica[m_kCorrectLayer] = {38, 44, 50, 56, 65, 71, 127, 127, 144, 143};
49MdcROOTGeo::m_kiCorrectReplica[m_kCorrectLayer] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
50
51MdcROOTGeo::MdcROOTGeo(Bool_t cgem_flag) //Long Peixun's update: Add CGEM flag
53{
54 m_MdcColor = 3;
55 m_segmentColor = 0;
56 m_hypeColor = 3;
57 m_tubeColor = 4;
58 //m_twistedTubsColor = kBlue;
59 m_twistedTubsColor = 63; //Long Peixun's update: Blue -> Green, as same as XY View
60 //m_replicaColor = kCyan;
61 m_replicaColor = 73; //Long Peixun's update: Grey -> Blue, as same as XY View
62
63 //Long Peixun's update: According to CGEM flag, set start wire layer
64 if (cgem_flag) m_StartLayer = 8;
65 else m_StartLayer = 0;
66
67 k_TFire = kTRUE;
68 k_QFire = kTRUE;
69 k_QNotOverflow = kFALSE;
70
71 // Default constructor.
72 for (int layer = 0; layer < m_kLayer; layer++) {
73 m_NodeLayer[layer] = 0;
74 for (int replica = 0; replica < m_kReplicaMax; replica++) {
75 m_NodeReplica[layer][replica] = 0;
76 //Long Peixun's update: TGeoPhysicalNode* -> MdcPhysicalPointer
77 m_PhysicalReplica[layer][replica].set(0);
78 }
79 }
80
81 for (int i = 0; i < m_kCorrectLayer; i++) {
82 m_CorrectMap[m_kiCorrectLayer[i]] = m_kiCorrectReplica[i];
83 }
84
85 for (int layer = 0; layer < m_kTrueLayer; layer++) {
86 for (int replica = 0; replica < m_kReplicaMax; replica++) {
87 m_Mdc2DWire[layer][replica] = 0;
88 }
89 }
90}
91
93{
94 //Long Peixun's update: Add destructor
95 cout << "delete old MdcROOTGeo" << endl;
96 for (Int_t layer = 0; layer < m_kTrueLayer; ++layer)
97 {
98 Int_t simuLayer = GetSimuLayer(layer);
99 for (Int_t replica = 0; replica < m_kReplica[simuLayer]; ++replica)
100 {
101 delete m_Mdc2DWire[layer][replica];
102 }
103 }
104 delete m_MdcXY;
105 delete m_MdcZR[0];
106 delete m_MdcZR[1];
107}
108
109void
110MdcROOTGeo::InitFromGDML(const char *gdmlFile, const char *setupName)
111{
112 m_ROOTGeoInit = 2;
113 ReadGdml(gdmlFile, setupName);
114 SetNode();
115}
116
117void
118MdcROOTGeo::InitFromROOT( TGeoVolume *vol )
119{
120 m_ROOTGeoInit = 1;
121 SetVolumeMdc(vol);
122 SetNode();
123}
124
125void
127{
128 if (m_ROOTGeoInit != 1 && m_ROOTGeoInit != 2) {
129 cout << "MdcROOTGeo::Init2DGeometry, ROOT Geometry not Initialized yet!" << endl;
130 return;
131 }
132
133 m_2DGeoInit = 1;
134 Int_t mdcColor = 11; //1002; // 41, 29
135 Int_t mdcLineColor = 15;
136 Int_t mdcXYStyle = 1001;//3001;
137 Int_t mdcZRStyle = 1001;//3007;
138 Int_t mdcStereoSuperColor = 38;
139 Int_t mdcAxialSuperColor = 4;
140
141 Double_t local[3] = {0.0, 0.0, 0.0};
142 Double_t master[3] = {0.0, 0.0, 0.0};
143 //Int_t nPoints = 4;
144 Double_t P[306] = {0.0}; //Long Peixun's update: 300 -> 306, at most 102 points
145 Double_t center[3] = {0.0, 0.0, 0.0};
146 TString name;
147
148 //----------XY-----------
149 // Mdc
150 TGeoTube *mdcShape = (TGeoTube*)GetVolumeMdc()->GetShape();
151 //Long Peixun's update: Consider CGEM detector
152 Double_t rmin = mdcShape->GetRmin();
153 if (m_StartLayer > 0) //if contains CGEM
154 {
155 TGeoTube *mdcShapeOuter = (TGeoTube*)(GetLayer(m_StartLayer)->GetVolume())->GetShape();
156 rmin = mdcShapeOuter->GetRmin();
157 }
158
159 m_MdcXY = new BesCircle2D("Mdc", "Mdc", rmin, mdcShape->GetRmax(), &center[0]);
160 m_MdcXY->SetNSegment(360);
161 m_MdcXY->SetFillColor(mdcColor);
162 m_MdcXY->SetFillStyle(mdcXYStyle);
163 m_MdcXY->SetLineColor(mdcLineColor);
164
165 //Long Peixun's update: Annotate
166/* // Mdc Supers
167 Int_t layerIn[4] = {0,
168 m_kStereoLayerIn,
169 m_kStereoLayerIn+m_kAxialLayerIn,
170 m_kStereoLayerIn+m_kAxialLayerIn+m_kStereoLayerOut
171 };
172 Int_t layerOut[4] = {m_kStereoLayerIn-1,
173 m_kStereoLayerIn+m_kAxialLayerIn-1,
174 m_kStereoLayerIn+m_kAxialLayerIn+m_kStereoLayerOut-1,
175 m_kLayer-1
176 };
177 for (Int_t i = 0; i < 4; i++) {
178 TGeoTube *mdcSuperShapeIn = (TGeoTube*)(GetLayer(layerIn[i])->GetVolume())->GetShape();
179 TGeoTube *mdcSuperShapeOut = (TGeoTube*)(GetLayer(layerOut[i])->GetVolume())->GetShape();
180 name = TString("MdcSuper" + i);
181 m_MdcXYSuper[i] = new BesCircle2D(name, name, mdcSuperShapeIn->GetRmin(), mdcSuperShapeOut->GetRmax(), &center[0]);
182 if (i%2 == 0) m_MdcXYSuper[i]->SetFillColor(mdcStereoSuperColor);
183 else m_MdcXYSuper[i]->SetFillColor(mdcAxialSuperColor);
184 } */
185
186 // Mdc Wires
187 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
188 for (Int_t layer = m_StartLayer; layer < m_kTrueLayer; layer++) {
189 Int_t simuLayer = GetSimuLayer(layer);
190 for (int replica = 0; replica < m_kReplica[simuLayer]; replica++) {
191 //cout << "layer " << layer << " replica " << replica << endl;
192 TGeoPhysicalNode *wirePhyNode = GetPhysicalReplica(simuLayer, replica);
193 name = TString("Mdc Layer ");
194 name += layer;
195 name += " Wire ";
196 name += replica;
197
198 if (m_kStereoDir[layer] != 0) { // stereo Layer
199 TGeoArb8 *wireShape = (TGeoArb8*)wirePhyNode->GetShape();
200 Double_t *localArb8Point, masterArb8Point[24];
201 localArb8Point = wireShape->GetVertices();
202 for (Int_t i = 0; i < 8; i++) {
203 local[0] = localArb8Point[2*i];
204 local[1] = localArb8Point[2*i+1];
205 if (i < 4) local[2] = wireShape->GetDz() * (-1.0);
206 else local[2] = wireShape->GetDz();
207
208 wirePhyNode->GetMatrix(-1*wirePhyNode->GetLevel())
209 ->LocalToMaster(local, &master[0]); // transform to top
210 for (Int_t j = 0; j < 3; j++) {
211 masterArb8Point[3*i+j] = master[j];
212 }
213 }
214
215 m_Mdc2DWire[layer][replica] = new Mdc2DWire(name, name, 8, &masterArb8Point[0]);
216
217 }
218 else { // axial Layer
219
220 TGeoTubeSeg *wireShape = (TGeoTubeSeg*)wirePhyNode->GetShape();
221
222 Double_t centerR = 0.5*(wireShape->GetRmin() + wireShape->GetRmax());
223 if (layer >= m_kStereoLayerIn+m_kAxialLayerIn+m_kStereoLayerOut)
224 centerR = wireShape->GetRmax();
225 Double_t centerPhi =
226 0.5*(wireShape->GetPhi1() + wireShape->GetPhi2()) * TMath::DegToRad();
227 local[0] = centerR * cos(centerPhi);
228 local[1] = centerR * sin(centerPhi);
229 local[2] = 0.0;
230 wirePhyNode->GetMatrix(-1*wirePhyNode->GetLevel())
231 ->LocalToMaster(local, &master[0]); // transform to top
232
233 Double_t rmin = wireShape->GetRmin();
234 Double_t rmax = wireShape->GetRmax();
235 if (layer >= m_kStereoLayerIn+m_kAxialLayerIn+m_kStereoLayerOut)
236 rmax = rmin + 2*(rmax-rmin);
237 m_Mdc2DWire[layer][replica] =
238 new Mdc2DWire( name, name, rmin, rmax, wireShape->GetDz(),centerPhi, &master[0] );
239 }
240 }
241 }
242
243 //----------ZR-----------
244 // Mdc
245 Int_t iPoint = 0;
246 TGeoTube *aMdcLayer = 0;
247
248 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
249 for (Int_t layer = m_StartLayer; layer < m_kLayer; layer++) {
250 aMdcLayer = (TGeoTube*)GetLayer(layer)->GetVolume()->GetShape();
251 P[3*iPoint] = 0.0;
252 P[3*iPoint+1] = aMdcLayer->GetRmin();
253 P[3*iPoint+2] = aMdcLayer->GetDz();
254 iPoint++;
255 }
256
257 P[3*iPoint] = 0.0;
258 P[3*iPoint+1] = aMdcLayer->GetRmax();
259 P[3*iPoint+2] = aMdcLayer->GetDz();
260 iPoint++;
261 P[3*iPoint] = 0.0;
262 P[3*iPoint+1] = aMdcLayer->GetRmax();
263 P[3*iPoint+2] = aMdcLayer->GetDz() * (-1.0);
264 iPoint++;
265
266 for (Int_t layer = m_kLayer-1; layer >= m_StartLayer; layer--) {
267 aMdcLayer = (TGeoTube*)GetLayer(layer)->GetVolume()->GetShape();
268 P[3*iPoint] = 0.0;
269 P[3*iPoint+1] = aMdcLayer->GetRmin();
270 P[3*iPoint+2] = aMdcLayer->GetDz() * (-1.0);
271 iPoint++;
272 }
273
274
275 m_MdcZR[0] = new BesPolygon2D("MdcZRUp", "MdcZRUp", iPoint, &P[0]);
276
277 for (Int_t i = 0; i < iPoint; i++)
278 P[3*i+1] *= -1.0;
279
280 m_MdcZR[1] = new BesPolygon2D("MdcZRDown", "MdcZRDown", iPoint, &P[0]);
281
282 for (Int_t i = 0; i < 2; i++) {
283 m_MdcZR[i]->SetFillColor(mdcColor);
284 m_MdcZR[i]->SetFillStyle(mdcZRStyle);
285 m_MdcZR[i]->SetLineColor(mdcLineColor);
286 m_MdcZR[i]->SetRotatable(true); //Long Peixun's update
287 }
288}
289
290void
292{
293 if (gDebug) {
294 Int_t nDaughters = m_TopVolume->GetNodes()->GetEntries();
295 cout << "logicalMdc contains " << nDaughters << " nodes : " << endl;
296 for (Int_t i = 0; i < nDaughters; i++) {
297 cout << i << " : " << m_TopVolume->GetNode(i)->GetName() << endl;
298 }
299 }
300
301 if (m_ROOTGeoInit == 2) { // from GDML
302 m_Mdc = GetTopVolume();
303 if (!m_Mdc) std::cout << "m_Mdc = 0" << std::endl;
304
305 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
306 for (int layer = m_StartLayer; layer < m_kLayer; layer++) { // is simuLayer
307 // m_NodeReplica[layer][replica] = m_Mdc->GetNode(layer); // you could take it by id;
308 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
309 std::stringstream osname;
310 int rep = replica;
311 if (layer >= 0 && layer < m_kStereoLayerIn) {
312 //osname << "pv_" << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "TwistedTubs" << "_" << rep;
313 osname << "pv_" << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "Cell" << "_" << rep;
314 }
315 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
316 rep = CorrectReplica(layer, rep);
317 //osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << layer << "Replica" << "_" << rep;
318 osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << layer << "Cell" << "_" << rep;
319 }
320 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
321 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
322 //osname << "pv_" << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "TwistedTubs" << "_" << rep;
323 osname << "pv_" << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "Cell" << "_" << rep;
324 }
325 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut && layer < m_kLayer) {
326 rep = CorrectReplica(layer, rep);
327 Int_t nBeforeAxialLayerOut = m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut;
328 Int_t iTrueLayer = nBeforeAxialLayerOut + (layer - nBeforeAxialLayerOut)/2;
329 if (layer%2 == 0) {
330 //osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << iTrueLayer << "_0" << "Replica" << "_" << rep;
331 osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << iTrueLayer << "_0" << "Cell" << "_" << rep;
332 }
333 else {
334 //osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << iTrueLayer << "_1" << "Replica" << "_" << rep;
335 osname << "pv_" << "logical" << "Mdc" << "Axial" << "Layer" << iTrueLayer << "_1" << "Cell" << "_" << rep;
336 }
337 }
338
339 m_NodeReplica[layer][replica] = GetNode( osname.str() );
340 //cout << osname.str() << endl;
341 }
342 }
343 }
344 else if (m_ROOTGeoInit == 1) { // from ROOT object
345 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
346 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
347 // 0 : logicalMdcStereoLayer0_0 35 : logicalMdcStereoLayer35_35
348 // 36 : logicalMdcAxialLayer36_0_36 37 : logicalMdcAxialLayer36_1_37
349 // 49 : logicalMdcAxialLayer42_1_49 50 : logicalMdcSegment1_50
350 TGeoNode *nodeLayer = m_Mdc->GetNode(layer);
351 m_NodeLayer[layer] = nodeLayer;
352 //cout << layer << " " << m_NodeLayer[layer]->GetName() << endl;
353
354 Int_t nDaughters = nodeLayer->GetVolume()->GetNodes()->GetEntries();
355 // if (0) {
356 // cout << m_NodeLayer[layer] << " contains " << nDaughters << " nodes : " << endl;
357 // for (Int_t i = 0; i < nDaughters; i++) {
358 // cout << i << " : " << nodeLayer->GetVolume()->GetNode(i)->GetName() << endl;
359 // }
360 // } //Long Peixun's update: Annotate
361
362 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
363 m_NodeReplica[layer][replica] = nodeLayer->GetVolume()->GetNode(replica);
364 //cout << layer << " " << replica << " " << m_NodeReplica[layer][replica]->GetName() << endl;
365 }
366 }
367 }
368
369 //std::cout << "MdcROOTGeo::SetNode, end of set node" << std::endl;
370}
371
372int
373MdcROOTGeo::CorrectReplica(int layer, int replica)
374{
375 int rep = replica;
376 for (intMap::iterator iter = m_CorrectMap.begin(); iter != m_CorrectMap.end(); iter++) {
377 if (layer == (*iter).first ||
378 (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
379 layer - m_kAxialLayerOut == (*iter).first)) {
380 rep -= (*iter).second;
381 if (rep < 0) rep += m_kReplica[layer];
382 }
383 }
384
385 //std::cout << "layer" << layer << " " << replica << "->" << rep << std::endl;
386 return rep;
387}
388
389void
391{
392 //std::cout << "begin of set defaultvis" << std::endl;
393 m_Mdc->SetLineColor(m_MdcColor);
394 m_Mdc->SetVisibility(0);
395
396 for (int segment = 1; segment <= m_kSegment; segment++) {
397 GetVolumeSegment(segment)->SetLineColor(m_segmentColor);
398 //if (segment > 3) GetVolumeSegment(segment)->SetVisibility(0);
399 GetVolumeSegment(segment)->SetVisibility(1);
400 }
401
402 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
403 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
404 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
405 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
406 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) ) {
407 GetVolumeLayer(layer)->SetLineColor(m_hypeColor);
408 GetVolumeReplica(layer)->SetLineColor(m_twistedTubsColor);
409 }
410 else {
411 GetVolumeLayer(layer)->SetLineColor(m_tubeColor);
412 GetVolumeReplica(layer)->SetLineColor(m_replicaColor);
413 }
414 GetVolumeLayer(layer)->SetVisibility(0);
415 GetVolumeReplica(layer)->SetVisibility(1);
416 }
417
418 for (int segment = 1; segment <= m_kSegment; segment++) {
419 for (int no = 0; no < 2; no++) {
420 GetSegment(segment, no)->SetVisibility(0);
421 }
422 }
423
424 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
425 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
426 GetLayer(layer)->SetVisibility(0);
427 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
428 GetReplica(layer, replica)->SetVisibility(0);
429 }
430 }
431
432 //std::cout << "end of set defaultvis" << std::endl;
433}
434
435void
437{
438 //std::cout << "begin of set defaultvis" << std::endl;
439 m_Mdc->SetLineColor(m_MdcColor);
440 m_Mdc->SetVisibility(0);
441
442 for (int segment = 1; segment <= m_kSegment; segment++) {
443 GetVolumeSegment(segment)->SetLineColor(m_segmentColor);
444 //if (segment > 3) GetVolumeSegment(segment)->SetVisibility(0);
445 GetVolumeSegment(segment)->SetVisibility(1);
446 }
447
448 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
449 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
450 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
451 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
452 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) ) {
453 GetVolumeLayer(layer)->SetLineColor(m_hypeColor);
454 GetVolumeReplica(layer)->SetLineColor(m_twistedTubsColor);
455 }
456 else {
457 GetVolumeLayer(layer)->SetLineColor(m_tubeColor);
458 GetVolumeReplica(layer)->SetLineColor(m_replicaColor);
459 }
460 GetVolumeLayer(layer)->SetVisibility(1);
461 GetVolumeReplica(layer)->SetVisibility(1);
462 }
463
464 for (int segment = 1; segment <= m_kSegment; segment++) {
465 for (int no = 0; no < 2; no++) {
466 GetSegment(segment, no)->SetVisibility(1);
467 }
468 }
469
470 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
471 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
472 GetLayer(layer)->SetVisibility(1);
473 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
474 GetReplica(layer, replica)->SetVisibility(1);
475 }
476 }
477
478
479
480}
481
482void
484{
485 for (int segment = 1; segment <= m_kSegment; segment++) {
486 GetVolumeSegment(segment)->SetVisibility(0);
487 }
488
489 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
490 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
491 GetVolumeLayer(layer)->SetVisibility(0);
492 GetVolumeReplica(layer)->SetVisibility(1);
493 }
494
495 for (int segment = 1; segment <= m_kSegment; segment++) {
496 for (int no = 0; no < 2; no++) {
497 GetSegment(segment, no)->SetVisibility(0);
498 }
499 }
500
501 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
502 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
503 GetLayer(layer)->SetVisibility(0);
504 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
505 if (replica < m_kReplica[layer]/4) GetReplica(layer, replica)->SetVisibility(0);
506 else GetReplica(layer, replica)->SetVisibility(1);
507 }
508 }
509}
510
511void
513{
514 for (int segment = 1; segment <= m_kSegment; segment++) {
515 GetVolumeSegment(segment)->SetVisibility(0);
516 }
517
518 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
519 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
520 GetVolumeLayer(layer)->SetVisibility(0);
521 GetVolumeReplica(layer)->SetVisibility(1);
522 }
523
524 for (int segment = 1; segment <= m_kSegment; segment++) {
525 for (int no = 0; no < 2; no++) {
526 GetSegment(segment, no)->SetVisibility(0);
527 }
528 }
529
530 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
531 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
532 GetLayer(layer)->SetVisibility(0);
533 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
534 if (replica < m_kReplica[layer]/4 ||
535 replica > m_kReplica[layer]*3/4 ) GetReplica(layer, replica)->SetVisibility(1);
536 else GetReplica(layer, replica)->SetVisibility(0);
537 }
538 }
539}
540
541void
543{
544 if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
545 TGeoNode *bes = gGeoManager->GetTopNode();
546 TGeoNode *nodeMdc = bes->GetVolume()->GetNode(m_childNo);
547 //std::cout << "Mdc m_childNo " << m_childNo << std::endl;
548
549 if (!m_Mdc) std::cout << "m_Mdc = 0" << std::endl;
550
551 for (int segment = 0; segment < 2*m_kSegment-2; segment++) {
552 m_PhysicalSegment[segment] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
553 TString("/") + nodeMdc->GetName() +
554 TString("/") + m_Mdc->GetNode((m_kLayer + 2*m_kSegment - 2 - 1) - segment)->GetName() );
555 m_PhysicalSegment[segment]->SetVisibility(0);
556 m_PhysicalSegment[segment]->SetIsVolAtt(kFALSE);
557 m_PhysicalSegment[segment]->SetLineColor(m_segmentColor);
558 //cout << m_PhysicalSegment[segment]->GetName() << endl;
559 }
560
561 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
562 for (int layer = m_StartLayer; layer < m_kLayer; layer++) {
563 TGeoNode *nodeLayer = GetLayer(layer);
564 //std::cout << "Layer " << layer << std::endl;
565 for (int replica = 0; replica < m_kReplica[layer]; replica++) {
566 TGeoNode *nodeReplica = GetReplica(layer, replica);
567
568 //Long Peixun's update: TGeoPhysicalNode* -> MdcPhysicalPointer
569 m_PhysicalReplica[layer][replica] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
570 TString("/") + nodeMdc->GetName() +
571 TString("/") + nodeLayer->GetName() +
572 TString("/") + nodeReplica->GetName() );
573 m_PhysicalReplica[layer][replica]->SetVisibility(0);
574 m_PhysicalReplica[layer][replica]->SetIsVolAtt(kFALSE);
575 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
576 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
577 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) ) {
578 m_PhysicalReplica[layer][replica]->SetLineColor(m_twistedTubsColor);
579 }
580 else {
581 m_PhysicalReplica[layer][replica]->SetLineColor(m_replicaColor);
582 }
583 //if (m_PhysicalReplica[layer][replica]->IsVolAttributes()) std::cout << "yes " << std::endl;
584 }
585 }
586
587 SetDetector();
588}
589
590//Long Peixun's update: Remove annotation; Reset color of replicas
591void
593{
594 // for (int part = 0; part < m_kPart; part++)
595 // {
596 // int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
597 // for (int phi = 0; phi < nPhi; phi++)
598 // {
599 // int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
600 // for (int theta = 0; theta < nTheta; theta++)
601 // {
602 // m_PhysicalCrystal[part][phi][theta]->SetIsVolAtt(kFALSE);
603 // if (part == 1) m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_brCrystalColor);
604 // else m_PhysicalCrystal[part][phi][theta]->SetLineColor(m_ecCrystalColor);
605 // }
606 // }
607 // }
608
609 for (int layer = m_StartLayer; layer < m_kLayer; layer++)
610 {
611 if ( (layer >= 0 && layer < m_kStereoLayerIn) ||
612 (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
613 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) )
614 {
615 for (int replica = 0; replica < m_kReplica[layer]; replica++)
616 GetPhysicalReplica(layer, replica)->SetLineColor(m_twistedTubsColor);
617 }
618 else
619 {
620 for (int replica = 0; replica < m_kReplica[layer]; replica++)
621 GetPhysicalReplica(layer, replica)->SetLineColor(m_replicaColor);
622 }
623 }
624 //std::cout << "end of set defaultvis" << std::endl;
625}
626
627
628void
630{
631 BesView *view = 0;
632 if (gPad) view = dynamic_cast<BesView*>(gPad->GetView());
633 //if (view) cout << "viewVisFull3DMdc " << view->GetVisFull3DMdc() << endl;
634
635 m_DetectorsArray->Clear();
636 for (int segment = 0; segment < 2*m_kSegment-2; segment++) {
637 TGeoPhysicalNode *phyNode = 0;
638 phyNode = m_PhysicalSegment[segment];
639 //cout << m_PhysicalSegment[segment]->GetName() << endl;
640 if (phyNode) {
641 phyNode->SetVisibility(0); // set all invisible before set any visible
642 if ( (segment >= 2 && segment <= 3) || segment > 59) {
643 m_DetectorsArray->Add( phyNode );
644 }
645 else if (view && view->GetVisFull3DMdc()) {
646 m_DetectorsArray->Add( phyNode );
647 }
648 }
649 }
650 /*
651 for (int part = 0; part < m_kPart; part++) {
652 int nPhi = (part == 1 ? m_kPhiBr : m_kPhiEc);
653 for (int phi = 0; phi < nPhi; phi++) {
654 int nTheta = (part == 1 ? m_kThetaBr : m_kThetaEc);
655 for (int theta = 0; theta < nTheta; theta++) {
656 // This is you detector, set it on
657 if ( (part == 1 && theta != 0 && theta != 43 && ((phi != 0 && phi != 60) || theta%2 == 0)) ||
658 (part != 1 && theta != 0) ) {
659 m_PhysicalCrystal[part][phi][theta]->SetVisibility(0);
660 }
661
662 // This is you hit
663 // when you are to set fired hits to another color, say red,
664 // SetIsVolAtt(kFALSE) and to then SetLineColor(kRed);
665 if (phi == 12 && theta == 5) {
666 m_PhysicalCrystal[part][phi][theta]->SetVisibility(1);
667 m_PhysicalCrystal[part][phi][theta]->SetLineColor(2);
668 }
669 }
670 }
671 }
672 std::cout << "end of set detector on" << std::endl;
673 */
674}
675
676//Long Peixun's update: Clear all hits
678{
679 //Long Peixun's update: Annotate cout
680 // cout << "m_HitsArray size(): " << m_HitsArray->GetEntries() << endl;
681 // cout << "m_2DHitsArray size(): " << m_2DHitsArray->GetEntries() << endl;
682
683 //Long Peixun's update: the element type of m_HitsArray is replaced by MdcPhysicalPointer
684 for (int i = 0; i < m_HitsArray->GetEntries(); i++)
685 {
687 (*PphyNode)->SetVisibility(0);
688 }
689 m_HitsArray->Clear("C");
690
691 // set previous event 2D hits info to default
692 for (int i = 0; i < m_2DHitsArray->GetEntries(); i++) {
693 Mdc2DWire *aWire = (Mdc2DWire*)m_2DHitsArray->At(i);
694 aWire->ClearInfo();
695 aWire->AddInfo(aWire->GetTitle());
696 aWire->CloseInfo();
697 }
698 m_2DHitsArray->Clear("C");
699}
700
701void
703{
704 // set previous event hits to default vis
705 //Long Peixun's update: move to ClearHits()
706 ClearHits();
707
708 // set new hits
709 //Long Peixun's update: Consider gEvent == NULL
710 int NDigiCol = 0;
711 if (gEvent)
712 {
713 m_MdcDigiCol = gEvent->GetMdcDigiCol();
714 //Long Peixun's update: Consider m_MdcDigiCol == NULL
715 if (m_MdcDigiCol) NDigiCol = m_MdcDigiCol->GetEntries();
716 else NDigiCol = 0;
717 }
718
719 for (int i = 0; i < NDigiCol; i++) {
720 TMdcDigi *aMdcDigi = (TMdcDigi*)m_MdcDigiCol->At(i);
721 Identifier aMdcID( aMdcDigi->getIntId() );
722 int layer = MdcID::layer( aMdcID );
723 int wire = MdcID::wire( aMdcID );
724
725 Double_t time = RawDataUtil::MdcTime(aMdcDigi->getTimeChannel());
726 Int_t charge = RawDataUtil::MdcCharge(aMdcDigi->getChargeChannel());
727 unsigned int overflow = aMdcDigi->getOverflow();
728
729 //Long Peixun's update: the element type of m_HitsArray is replaced by MdcPhysicalPointer
730 MdcPhysicalPointer* phyNode = 0;
731 if (layer < 36)
732 { // number of layers in the three inner
733 phyNode = &m_PhysicalReplica[layer][wire];
734 // Long Peixun's update: Add additional information into pointer
735 phyNode->setTimeChannel(aMdcDigi->getTimeChannel());
736 phyNode->setChargeChannel(aMdcDigi->getChargeChannel());
737 phyNode->setQOverflow(overflow & 2);
738 if (phyNode) m_HitsArray->Add(phyNode);
739 }
740 else
741 {
742 phyNode = &m_PhysicalReplica[GetSimuLayer(layer)][wire];
743 if (phyNode) m_HitsArray->Add(phyNode);
744 phyNode->setTimeChannel(aMdcDigi->getTimeChannel());
745 phyNode->setChargeChannel(aMdcDigi->getChargeChannel());
746 phyNode->setQOverflow(overflow & 2);
747
748 phyNode = &m_PhysicalReplica[GetSimuLayer(layer) + 1][wire];
749 if (phyNode) m_HitsArray->Add(phyNode);
750 phyNode->setTimeChannel(aMdcDigi->getTimeChannel());
751 phyNode->setChargeChannel(aMdcDigi->getChargeChannel());
752 phyNode->setQOverflow(overflow & 2);
753 }
754
755 Mdc2DWire *aWire = 0;
756 aWire = m_Mdc2DWire[layer][wire];
757 if (aWire) {
758 aWire->ClearInfo();
759 aWire->AddInfo(aWire->GetTitle());
760 double evTime = gEvent->GetHeader().GetEvTime();
761
762 char data[200]; //Long Peixun's update: 100 -> 200
763 if(time>1000000) {
764 sprintf(data, "NO time");
765 }else{
766 sprintf(data, "time=%-.1f ns", time);
767 if(fabs(evTime)>0.0001){
768 sprintf(data, "%s, Tdrift(Raw)=%-.1f ns", data, time - evTime +230);
769 }
770 }
771 if(charge>1000000) {
772 sprintf(data, "%s, NO charge", data);
773 }else{
774 sprintf(data, "%s, charge=%d", data,charge);
775 }
776 aWire->AddInfo( TString(data) );
777 sprintf(data, "Fired");
778 aWire->AddInfo( TString(data) );
779
780 aWire->SetTime(time);//yzhang
781 aWire->SetCharge(charge);//yzhang
782 aWire->SetQOverflow(overflow&2);//yzhang
783 aWire->SetEvTime(evTime);
784
785 //Long Peixun's update: Set raw channel data of aWire
786 aWire->SetTimeChannel(aMdcDigi->getTimeChannel());
787 aWire->SetChargeChannel(aMdcDigi->getChargeChannel());
788
789 aWire->CloseInfo();
790
791 m_2DHitsArray->Add(aWire);
792 }
793 }
794}
795
796void
798{
799 BesView *view = 0;
800 if (gPad) view = dynamic_cast<BesView*>(gPad->GetView());
801
802 for (int i = 0; i < m_DetectorsArray->GetEntries(); i++) {
803 TGeoPhysicalNode *phyNode = (TGeoPhysicalNode*)m_DetectorsArray->At(i);
804 if (view && view->GetVisMdcGlobal()) {
805 phyNode->SetVisibility(1);
806 continue;
807 }
808 phyNode->SetVisibility(0);
809 }
810}
811
812void
814{
815 BesView *view = 0;
816 if (gPad) view = dynamic_cast<BesView*>(gPad->GetView());
817
818 for (int i = 0; i < m_HitsArray->GetEntries(); i++)
819 {
821 if (view && view->GetVisMdcHitsGlobal())
822 {
823 //Long Peixun's update: Consider overflow options in 3D view
824 if ( (k_TFire && PphyNode->getTimeChannel() == 0x7FFFFFFF)
825 || (k_QFire && PphyNode->getChargeChannel() == 0x7FFFFFFF)
826 || (k_QNotOverflow && PphyNode->getQOverflow()) )
827 (*PphyNode)->SetVisibility(0);
828 else
829 (*PphyNode)->SetVisibility(1);
830 }
831 else (*PphyNode)->SetVisibility(0);
832 }
833}
834
835void
837 k_TFire= input;
838 //cout << "Mdc ROOT Geometry TDC Match: " << k_TMatch << endl;
839}
840
841//void
842//MdcROOTGeo::SetTOverflow(Bool_t input){
843// k_TOverflow = input;
844// //cout << "Mdc ROOT Geometry TDC Match: " << k_TMatch << endl;
845//}
846
847void
849 k_QNotOverflow = input;
850 //cout << "Mdc ROOT Geometry TDC Match: " << k_TMatch << endl;
851}
852
853void
855 k_QFire = input;
856 //cout << "Mdc ROOT Geometry ADC Match: " << k_QMatch << endl;
857}
858
859void
861 k_ColorfulWire = input;
862}
863
864void
866 k_MdcTimeSubEvTime = input;
867}
868
869TGeoVolume*
870MdcROOTGeo::GetVolumeSegment( int segment )
871{
872 std::stringstream osname;
873 osname << "logical" << "Mdc" << "Segment" << segment;
874 return GetLogicalVolume( osname.str() );
875}
876
877TGeoVolume*
879{
880 std::stringstream osname;
881 if (layer >= 0 && layer < m_kStereoLayerIn) {
882 osname << "logical" << "Mdc" << "Stereo" << "Layer" << layer;
883 }
884 else if (layer >= m_kStereoLayerIn && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
885 osname << "logical" << "Mdc" << "Axial" << "Layer" << layer;
886 }
887 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
888 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
889 osname << "logical" << "Mdc" << "Stereo" << "Layer" << layer;
890 }
891 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
892 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
893 osname << "logical" << "Mdc" << "Axial" << "Layer" << layer << "_0";
894 }
895 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut &&
896 layer < m_kLayer) {
897 osname << "logical" << "Mdc" << "Axial" << "Layer" << layer - m_kAxialLayerOut << "_1";
898 }
899
900 return GetLogicalVolume( osname.str() );
901}
902
903TGeoVolume*
905{
906 std::stringstream osname;
907 if (layer >= 0 && layer < m_kStereoLayerIn) {
908 osname << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "Cell";
909 }
910 else if (layer >= m_kStereoLayerIn
911 && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
912 osname << "logical" << "Mdc" << "Axial" << "Layer" << layer << "Cell";
913 }
914 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
915 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
916 osname << "logical" << "Mdc" << "Stereo" << "Layer" << layer << "Cell";
917 }
918 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut &&
919 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut) {
920 osname << "logical" << "Mdc"
921 << "Axial" << "Layer" << layer << "_0" << "Cell";
922 }
923 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut + m_kAxialLayerOut
924 && layer < m_kLayer) {
925 osname << "logical" << "Mdc"
926 << "Axial" << "Layer" << layer - m_kAxialLayerOut
927 << "_1" << "Cell";
928 }
929
930 return GetLogicalVolume( osname.str() );
931}
932
933TGeoNode*
934MdcROOTGeo::GetSegment( int segment, int no )
935{
936 std::stringstream osname;
937 if (segment == 1 || segment == 2) {
938 osname << "pv_" << "logical" << "Mdc"
939 << "Segment" << segment << "_"
940 << m_kSegmentNodeOffset - (segment - 1); //huangsh
941 //<< (m_kLayer + (2*m_kSegment -2) -1) - (segment - 1);
942 }
943 else {
944 osname << "pv_" << "logical" << "Mdc"
945 << "Segment" << segment << "_"
946 << m_kSegmentNodeOffset - m_kSegmentBr - 2*(segment - 1 - m_kSegmentBr) - no; //huangsh
947 //<< (m_kLayer + (2*m_kSegment -2) -1) - 2 - (segment - 3)*2 - no;
948 }
949
950 return GetNode( osname.str() );
951}
952
953TGeoNode*
954MdcROOTGeo::GetLayer( int layer )
955{
956 // if m_NodeLayer[] set in SetNode(), could also return m_NodeLayer[layer]
957 if (m_ROOTGeoInit == 2) { // from GDML
958 std::stringstream osname;
959 if (layer >= 0 && layer < m_kStereoLayerIn) {
960 osname << "pv_" << "logical" << "Mdc"
961 << "Stereo" << "Layer" << layer << "_" << layer;
962 }
963 else if (layer >= m_kStereoLayerIn
964 && layer < m_kStereoLayerIn + m_kAxialLayerIn) {
965 osname << "pv_" << "logical" << "Mdc"
966 << "Axial" << "Layer" << layer << "_" << layer;
967 }
968 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn &&
969 layer < m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut) {
970 osname << "pv_" << "logical" << "Mdc"
971 << "Stereo" << "Layer" << layer << "_" << layer;
972 }
973 else if (layer >= m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut
974 && layer < m_kLayer) {
975 Int_t nBeforeAxialLayerOut =
976 m_kStereoLayerIn + m_kAxialLayerIn + m_kStereoLayerOut;
977 Int_t iTrueLayer =
978 nBeforeAxialLayerOut + (layer - nBeforeAxialLayerOut)/2;
979 if (layer%2 == 0) {
980 osname << "pv_" << "logical" << "Mdc"
981 << "Axial" << "Layer" << iTrueLayer << "_0" << "_" << layer;
982 }
983 else {
984 osname << "pv_" << "logical" << "Mdc"
985 << "Axial" << "Layer" << iTrueLayer << "_1" << "_" << layer;
986 }
987 }
988
989 //std::cout << osname.str() << std::endl;
990 return GetNode( osname.str() );
991 }
992 else if (m_ROOTGeoInit == 1) { // from ROOT object
993 if (m_NodeLayer[layer] != 0) {
994 return m_NodeLayer[layer];
995 }
996 else {
997 //std::cout << "Node: " << "Layer" << layer << " not found" << std::endl;
998 return 0;
999 }
1000 }
1001
1002 return 0;
1003}
1004
1005TGeoNode*
1006MdcROOTGeo::GetReplica( int layer, int replica )
1007{
1008 if (m_NodeReplica[layer][replica] != 0) {
1009 //std::cout << " replica " << layer << " " << replica << " found " << std::endl;
1010 return m_NodeReplica[layer][replica];
1011 }
1012 else {
1013 //std::cout << "Node: " << "Layer" << layer << "Replica" << replica << " not found" << std::endl;
1014 return 0;
1015 }
1016}
1017
1018TGeoPhysicalNode*
1020{
1021 if (m_PhysicalSegment[segment] != 0) {
1022 return m_PhysicalSegment[segment];
1023 }
1024 else {
1025 //std::cout << "PhysicalNode: " << "Segment" << segment << " not found" << std::endl;
1026 return 0;
1027 }
1028}
1029
1030TGeoPhysicalNode*
1031MdcROOTGeo::GetPhysicalReplica( Int_t layer, Int_t replica )
1032{
1033 //Long Peixun's update: TGeoPhysicalNode* -> TofPhysicalPointer
1034 if (m_PhysicalReplica[layer][replica]) {
1035 return m_PhysicalReplica[layer][replica].get();
1036 }
1037 else {
1038 //std::cout << "PhysicalNode: " << "Layer" << layer << "Replica" << replica << " not found" << std::endl;
1039 return 0;
1040 }
1041}
1042
1043Mdc2DWire*
1044MdcROOTGeo::Get2DWire( Int_t layer, Int_t wire)
1045{
1046 if (m_Mdc2DWire[layer][wire]) return m_Mdc2DWire[layer][wire];
1047 else return 0;
1048}
1049
1050Int_t
1052{
1053 if (trueLayer < 36 || trueLayer >= m_kTrueLayer) return trueLayer;
1054 if (trueLayer >= 36) return (36 + 2*(trueLayer-36));
1055 return trueLayer;
1056}
1057
1058Bool_t
1059MdcROOTGeo::IsHit(Int_t layer, Int_t wire)
1060{
1061 if (m_MdcDigiCol) {
1062 for (int i = 0; i < m_MdcDigiCol->GetEntries(); i++) {
1063 Identifier mdcID( ((TMdcDigi*)m_MdcDigiCol->At(i))->getIntId() );
1064 if (layer == MdcID::layer( mdcID ) && wire == MdcID::wire( mdcID )) {
1065 return kTRUE;
1066 }
1067 }
1068 }
1069
1070 return kFALSE;
1071}
1072
1073void
1074MdcROOTGeo::Draw(Option_t *option)
1075{
1076 TString opt = option;
1077 opt.ToUpper();
1078
1079 if (!m_2DGeoInit) cout << "MdcROOTGeo::Draw2D(), 2D Geometry not initialized!" << endl;
1080 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
1081 if (!view) cout << "MdcROOTGeo::Draw(), BesView not found" << endl;
1082
1083 if (view->GetVisMdcGlobal()) { // MdcVisGlobal
1084 if (opt.Contains("XY")) {
1085 m_MdcXY->Draw("");
1086 //Long Peixun's update: Annotate
1087 // for (Int_t i = 0; i < 4; i++) {
1088 // m_MdcXYSuper[i]->Draw("");
1089 // }
1090 }
1091
1092 if (opt.Contains("ZR")) {
1093 for (Int_t i = 0; i < 2; i++) {
1094 //m_MdcZR[i]->SetRotatable(true); //Long Peixun's update: Move to initializer
1095 m_MdcZR[i]->Draw("");
1096 }
1097 }
1098
1099 TString wireOpt;
1100 if (view->GetVisMdcTubes()) wireOpt += "TUBE";
1101 if (view->GetVisMdcWires()) wireOpt += ",WIRE";
1102
1103 Int_t replicaDraw = 0; // change draw sequence in a circle, (-1: 0->Max; 1: Max->0)
1104 //Long Peixun's update: Ignore layer 0~7 if detector contains CGEM
1105 for (Int_t layer = m_StartLayer; layer < m_kTrueLayer; layer++) {
1106 Int_t simuLayer = GetSimuLayer(layer);
1107 for (int replica = 0; replica < m_kReplica[simuLayer]; replica++) {
1108 if (m_kStereoDir[layer] == -1) replicaDraw = replica;
1109 else if (m_kStereoDir[layer] == 1) replicaDraw = m_kReplica[simuLayer]-1 - replica;
1110 else replicaDraw = replica;
1111
1112 if (m_Mdc2DWire[layer][replicaDraw]) {
1113 //cout << layer << " " << replicaDraw << endl;
1114 //m_Mdc2DWire[layer][replicaDraw]->SetHighlighted(false);
1115 m_Mdc2DWire[layer][replicaDraw]->SetFired(false);
1116 m_Mdc2DWire[layer][replicaDraw]->Draw(wireOpt);
1117 }
1118 }
1119 }
1120 }
1121}
1122
1123void
1124MdcROOTGeo::DrawHits(Option_t *option)
1125{
1126 // cout << "Draw Hits" << endl;
1127 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
1128 if (!view) cout << "MdcROOTGeo::DrawHits(), BesView not found" << endl;
1129
1130 //cout << "VisMdcHitsGlobal " << view->GetVisMdcHitsGlobal() << endl;
1131 //cout << "VisMdcHits " << view->GetVisMdcHits() << endl;
1132
1133
1134 if (view->GetVisMdcHitsGlobal()) {
1135 TString wireOpt("");
1136 if (view->GetVisMdcTubes()) wireOpt += ",TUBE";
1137 if (view->GetVisMdcHits()) wireOpt += ",WIRE";
1138
1139 //Long Peixun's update: Use m_2DHitsArray which contains ready hits rather than rebuild hits
1140 for (int i = 0; i < m_2DHitsArray->GetEntries(); ++i)
1141 {
1142 Mdc2DWire* aWire = (Mdc2DWire*)m_2DHitsArray->At(i);
1143 if (aWire)
1144 {
1145 if ((k_TFire) && (aWire->GetTimeChannel() == 0x7FFFFFFF))
1146 continue;
1147 if ((k_QFire) && (aWire->GetChargeChannel() == 0x7FFFFFFF))
1148 continue;
1149 if ((k_QNotOverflow) && aWire->GetQOverflow() )
1150 continue;
1151 aWire->SetFired(true);
1152 aWire->SetColorfulWire(k_ColorfulWire, k_MdcTimeSubEvTime);
1153 aWire->Draw(wireOpt);
1154 }
1155 }
1156
1157/* if (m_MdcDigiCol) {
1158 for (int i = 0; i < m_MdcDigiCol->GetEntries(); i++) {
1159 TMdcDigi *aMdcDigi = (TMdcDigi*)m_MdcDigiCol->At(i);
1160
1161 Identifier aMdcID( aMdcDigi->getIntId() );
1162 int layer = MdcID::layer( aMdcID );
1163 int wire = MdcID::wire( aMdcID );
1164 unsigned int overflow = aMdcDigi->getOverflow();
1165
1166 Mdc2DWire *aWire = 0;
1167 aWire = m_Mdc2DWire[layer][wire];
1168 if (aWire){
1169 if ((k_TFire) && (aMdcDigi->getTimeChannel() == 0x7FFFFFFF)){
1170 continue;
1171 }
1172 if ((k_QFire) && (aMdcDigi->getChargeChannel() == 0x7FFFFFFF)){
1173 continue;
1174 }
1175 //if ((!k_TOverflow) && ((overflow&1)>0) ){
1176 // continue;
1177 //}
1178 if ((k_QNotOverflow) && ((overflow&2)>0) ){
1179 continue;
1180 }
1181 aWire->SetFired(true);
1182 aWire->SetColorfulWire(k_ColorfulWire,k_MdcTimeSubEvTime);
1183 aWire->Draw(wireOpt);
1184 }
1185 }
1186 } */
1187 }
1188}
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
R__EXTERN BesEvent * gEvent
Definition BesEvent.h:318
double P(RecMdcKalTrack *trk)
TTree * data
Double_t time
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
virtual void SetNSegment(Int_t np)
Definition BesCircle2D.h:53
virtual void Draw(Option_t *option="")
Double_t GetEvTime()
BesEventHeader GetHeader()
Definition BesEvent.h:310
const TObjArray * GetMdcDigiCol() const
Definition BesEvent.h:106
void SetRotatable(Bool_t input)
virtual void Draw(Option_t *option="")
Bool_t GetVisMdcHitsGlobal()
Definition BesView.h:214
Bool_t GetVisMdcTubes()
Definition BesView.h:132
Bool_t GetVisMdcWires()
Definition BesView.h:133
Bool_t GetVisMdcGlobal()
Definition BesView.h:131
Bool_t GetVisMdcHits()
Definition BesView.h:215
Bool_t GetVisFull3DMdc()
Definition BesView.h:180
void SetChargeChannel(UInt_t cc)
virtual void ClearInfo()
UInt_t GetTimeChannel() const
Definition Mdc2DWire.h:61
void SetQOverflow(Bool_t qOvfl)
virtual void CloseInfo()
void SetTime(Double_t time)
virtual void AddInfo(TString info)
Definition Mdc2DWire.h:37
void SetColorfulWire(Bool_t colorfulWire, Bool_t subEvTime)
void SetEvTime(Double_t time)
void SetTimeChannel(UInt_t tc)
virtual void Draw(Option_t *option="")
Bool_t GetQOverflow() const
Definition Mdc2DWire.h:60
UInt_t GetChargeChannel() const
Definition Mdc2DWire.h:62
virtual void SetFired(bool status=true)
Definition Mdc2DWire.h:33
void SetCharge(Double_t charge)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition MdcID.cxx:49
static int wire(const Identifier &id)
Definition MdcID.cxx:54
Bool_t getQOverflow() const
UInt_t getTimeChannel() const
void setQOverflow(Bool_t sqof)
void setTimeChannel(UInt_t stc)
void setChargeChannel(UInt_t scc)
UInt_t getChargeChannel() const
TGeoNode * GetSegment(int segment, int no)
Get segment node;.
int CorrectReplica(int layer, int replica)
Correct some axial layer id to copyNo;.
void SetVolumeDefaultVis()
Set default visual attributes;.
TGeoVolume * GetVolumeLayer(int layer)
Get layer volume;
TGeoPhysicalNode * GetPhysicalSegment(int segment)
Get segment physical node;.
void SetNode()
Set the pointers to theirs nodes;.
void InitFromROOT(TGeoVolume *vol)
Initialize ROOTGeo from TGeoVolume logicalMdc.
TGeoNode * GetReplica(int layer, int replica)
Get replica node;.
TGeoVolume * GetVolumeReplica(int layer)
Get replica volume;.
TGeoVolume * GetVolumeSegment(int segment)
Get segment volume;.
void ClearHits()
Set all physicalNodes corresponding to digiCol;.
void SetVisMdcDetector()
Set Mdc default detector visibility;.
Int_t GetSimuLayer(Int_t trueLayer)
Trans trueLayer to simuLayer (0~42)->(0~49)
Mdc2DWire * Get2DWire(Int_t layer, Int_t replica)
Get Mdc2DWire;.
void SetVolumeMdc(TGeoVolume *vol)
Set Mdc volume, while initializing from ROOT;.
TGeoPhysicalNode * GetPhysicalReplica(int layer, int replica)
Get replica physical node;.
void SetPhysicalDefaultVis()
Set default physical node attributes;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
Bool_t IsHit(Int_t layer, Int_t wire)
Judge whether the digiCol contains (layer, wire)
void SetDetector()
Draw Detecor (what is detector depends on you)
void InitFromGDML(const char *gdmlFile, const char *setupName)
Initialize ROOTGeo from GDML.
static double MdcTime(int timeChannel)
Definition RawDataUtil.h:8
static double MdcCharge(int chargeChannel)
Definition RawDataUtil.h:11
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 getOverflow() const
Definition TMdcDigi.cxx:42
UInt_t getIntId() const
Definition TRawData.cxx:50
UInt_t getChargeChannel() const
Definition TRawData.cxx:60
UInt_t getTimeChannel() const
Definition TRawData.cxx:55