CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemROOTGeo.cxx
Go to the documentation of this file.
1/*
2 * 2018/1/26 Long Peixun IHEP
3 * Cgem Geometry General for EventDisplay
4 * Inherit from class SubDetectorROOTGeo
5*/
6
7using namespace std;
8
9#include <string>
10#include <fstream>
11#include <iostream>
12#include <sstream>
13#include <vector>
14#include <iomanip>
15
16#include <TGeoManager.h>
17#include <TGeoTube.h>
18#include <TGeoArb8.h>
19#include <TMath.h>
20
21#include "BesVisLib/CgemROOTGeo.h"
22#include "Identifier/CgemID.h"
23#include "BesVisLib/BesEvent.h"
24#include "BesVisLib/BesView.h"
25#include "RawEvent/RawDataUtil.h"
26
27//Use CgemGeomSvc to calculate Cgem strips
28#include "GaudiKernel/Bootstrap.h"
29#include "CgemGeomSvc/CgemGeomSvc.h"
30#include "CgemGeomSvc/CgemGeoReadoutPlane.h"
31#include "CgemGeomSvc/CgemGeoLayer.h"
32
33
34//Constructor
36{
37 m_CgemColor = kSpring;
38 m_XstripColor = 828;
39 m_VstripColor = kTeal;
40
41 for (int layer = 0; layer < m_kCgemLayer; ++layer)
42 {
43 m_NodeCgemAnode[layer] = 0;
44 m_NodeCgemCathode[layer] = 0;
45 for (int foil = 0; foil < m_kCgemFoil; ++foil)
46 m_NodeCgemFoil[layer][foil] = 0;
47
48 for (int sheet = 0; sheet < 2; ++sheet)
49 {
50 NXStrip[layer][sheet] = 0;
51 NVStrip[layer][sheet] = 0;
52 m_CgemXStrip[layer][sheet] = 0;
53 m_CgemVStrip[layer][sheet] = 0;
54 m_CgemSheet[layer][sheet] = 0;
55 }
56 }
57}
58
59//Destructor
61{
62 cout << "delete old CgemROOTGeo" << endl;
63 for (int layer = 0; layer < m_kCgemLayer; ++layer)
64 {
65 for (int sheet = 0; sheet < 2; ++sheet)
66 {
67 if (layer == 0 && sheet == 1) continue;
68 delete m_CgemSheet[layer][sheet];
69
70 for (int strip = 0; strip < NXStrip[layer][sheet]; ++strip)
71 delete m_CgemXStrip[layer][sheet][strip];
72 delete m_CgemXStrip[layer][sheet];
73 for (int strip = 0; strip < NVStrip[layer][sheet]; ++strip)
74 delete m_CgemVStrip[layer][sheet][strip];
75 delete m_CgemVStrip[layer][sheet];
76 }
77 }
78}
79
80//Initialize ROOTGeo from GDML
81void CgemROOTGeo::InitFromGDML(const char *gdmlFile, const char *setupName)
82{
83 m_ROOTGeoInit = 2;
84 ReadGdml(gdmlFile, setupName);
85 SetNode();
86}
87
88//Initialize ROOTGeo from TGeoVolume CGEM
89void CgemROOTGeo::InitFromROOT(TGeoVolume *vol)
90{
91 m_ROOTGeoInit = 1;
92 SetVolumeCgem(vol);
93 SetNode();
94}
95
96//Initialize Geometry
98{
99 Int_t CgemLineColor = 15;
100 Int_t CgemFillColor = 18;
101 Int_t CgemFillStyle = 1001;
102 Int_t CgemLayerStyle = 3003;
103 Int_t CgemElectrodeColor = 12;
104 Int_t CgemFoilColor = 12;
105 m_2DGeoInit = 1;
106
107 TGeoVolume* CgemVol;
108 TGeoTube* CgemTube;
109 TString name;
110 Double_t center[3] = {0.0, 0.0, 0.0};
111 Double_t P[12];
112
113 //XY View
114 TGeoTube* CgemShape = (TGeoTube*)GetVolumeCgem()->GetShape();
115 m_CgemXY = new BesCircle2D("CGEM", "CGEM", CgemShape->GetRmin(), CgemShape->GetRmax(), &center[0]);
116 m_CgemXY->SetNSegment(360);
117 m_CgemXY->SetFillColor(CgemFillColor);
118 m_CgemXY->SetFillStyle(CgemFillStyle);
119 m_CgemXY->SetLineColor(CgemLineColor);
120
121 for (int layer = 0; layer < m_kCgemLayer; ++layer)
122 {
123 CgemVol = GetCgemAnode(layer)->GetVolume();
124 CgemTube = (TGeoTube*)CgemVol->GetShape();
125 name = "CGEM Layer";
126 name += layer;
127 name += " Anode";
128 center[2] = CgemTube->GetDz();
129 m_CgemAnodeXY[layer] = new BesCircle2D(name, name, CgemTube->GetRmin(), CgemTube->GetRmax(), center);
130 m_CgemAnodeXY[layer]->SetNSegment(360);
131 m_CgemAnodeXY[layer]->SetFillStyle(CgemLayerStyle);
132 m_CgemAnodeXY[layer]->SetLineColor(CgemElectrodeColor);
133 m_CgemAnodeXY[layer]->SetFillColor(CgemElectrodeColor);
134
135 CgemVol = GetCgemCathode(layer)->GetVolume();
136 CgemTube = (TGeoTube*)CgemVol->GetShape();
137 name = "CGEM Layer";
138 name += layer;
139 name += " Cathode";
140 center[2] = CgemTube->GetDz();
141 m_CgemCathodeXY[layer] = new BesCircle2D(name, name, CgemTube->GetRmin(), CgemTube->GetRmax(), center);
142 m_CgemCathodeXY[layer]->SetNSegment(360);
143 m_CgemCathodeXY[layer]->SetFillStyle(CgemLayerStyle);
144 m_CgemCathodeXY[layer]->SetLineColor(CgemElectrodeColor);
145 m_CgemCathodeXY[layer]->SetFillColor(CgemElectrodeColor);
146
147 for (int foil = 0; foil < m_kCgemFoil; ++foil)
148 {
149 CgemVol = GetCgemFoil(layer, foil)->GetVolume();
150 CgemTube = (TGeoTube*)CgemVol->GetShape();
151 name = "CGEM Layer";
152 name += layer;
153 name += " Foil";
154 name += foil;
155 center[2] = CgemTube->GetDz();
156 m_CgemFoilXY[layer][foil] = new BesCircle2D(name, name, CgemTube->GetRmin(), CgemTube->GetRmax(), center);
157 m_CgemFoilXY[layer][foil]->SetNSegment(360);
158 m_CgemFoilXY[layer][foil]->SetFillStyle(CgemLayerStyle);
159 m_CgemFoilXY[layer][foil]->SetLineColor(CgemFoilColor);
160 m_CgemFoilXY[layer][foil]->SetFillColor(CgemFoilColor);
161 }
162 }
163
164 //ZR View
165 for (int j = 0; j < 2; ++j)
166 {
167 P[0] = P[3] = P[6] = P[9] = 0;
168 P[1] = P[10] = CgemShape->GetRmin() * (1 - 2 * j);
169 P[2] = P[5] = -CgemShape->GetDz();
170 P[4] = P[7] = CgemShape->GetRmax() * (1 - 2 * j);
171 P[8] = P[11] = CgemShape->GetDz();
172
173 name = "CgemZR ";
174 if (j == 0) name += "Up";
175 else name += "Down";
176 m_CgemZR[j] = new BesPolygon2D(name, name, 4, P);
177 m_CgemZR[j]->SetFillColor(CgemFillColor);
178 m_CgemZR[j]->SetFillStyle(CgemFillStyle);
179 m_CgemZR[j]->SetLineColor(CgemLineColor);
180 m_CgemZR[j]->SetRotatable(true);
181 }
182
183 for (int layer = 0; layer < m_kCgemLayer; ++layer)
184 {
185 for (int j = 0; j < 2; ++j)
186 {
187 CgemVol = GetCgemAnode(layer)->GetVolume();
188 CgemTube = (TGeoTube*)CgemVol->GetShape();
189 name = "CgemZR Layer";
190 name += layer;
191 if (j == 0) name += " Anode Up";
192 else name += " Anode Down";
193
194 P[0] = P[3] = P[6] = P[9] = 0;
195 P[1] = P[10] = CgemTube->GetRmin() * (1 - 2 * j);
196 P[2] = P[5] = -CgemTube->GetDz();
197 P[4] = P[7] = CgemTube->GetRmax() * (1 - 2 * j);
198 P[8] = P[11] = CgemTube->GetDz();
199
200 m_CgemAnodeZR[layer][j] = new BesPolygon2D(name, name, 4, P);
201 m_CgemAnodeZR[layer][j]->SetFillStyle(CgemLayerStyle);
202 m_CgemAnodeZR[layer][j]->SetLineColor(CgemElectrodeColor);
203 m_CgemAnodeZR[layer][j]->SetFillColor(CgemElectrodeColor);
204 m_CgemAnodeZR[layer][j]->SetRotatable(true);
205
206 CgemVol = GetCgemCathode(layer)->GetVolume();
207 CgemTube = (TGeoTube*)CgemVol->GetShape();
208 name = "CgemZR Layer";
209 name += layer;
210 if (j == 0) name += " Cathode Up";
211 else name += " Cathode Down";
212
213 P[0] = P[3] = P[6] = P[9] = 0;
214 P[1] = P[10] = CgemTube->GetRmin() * (1 - 2 * j);
215 P[2] = P[5] = -CgemTube->GetDz();
216 P[4] = P[7] = CgemTube->GetRmax() * (1 - 2 * j);
217 P[8] = P[11] = CgemTube->GetDz();
218
219 m_CgemCathodeZR[layer][j] = new BesPolygon2D(name, name, 4, P);
220 m_CgemCathodeZR[layer][j]->SetFillStyle(CgemLayerStyle);
221 m_CgemCathodeZR[layer][j]->SetLineColor(CgemElectrodeColor);
222 m_CgemCathodeZR[layer][j]->SetFillColor(CgemElectrodeColor);
223 m_CgemCathodeZR[layer][j]->SetRotatable(true);
224
225 for (int foil = 0; foil < m_kCgemFoil; ++foil)
226 {
227 CgemVol = GetCgemFoil(layer, foil)->GetVolume();
228 CgemTube = (TGeoTube*)CgemVol->GetShape();
229 name = "CgemZR Layer";
230 name += layer;
231 name += " Foil";
232 name += foil;
233 if (j == 0) name += " Up";
234 else name += " Down";
235
236 P[0] = P[3] = P[6] = P[9] = 0;
237 P[1] = P[10] = CgemTube->GetRmin() * (1 - 2 * j);
238 P[2] = P[5] = -CgemTube->GetDz();
239 P[4] = P[7] = CgemTube->GetRmax() * (1 - 2 * j);
240 P[8] = P[11] = CgemTube->GetDz();
241
242 m_CgemFoilZR[layer][foil][j] = new BesPolygon2D(name, name, 4, P);
243 m_CgemFoilZR[layer][foil][j]->SetFillStyle(CgemLayerStyle);
244 m_CgemFoilZR[layer][foil][j]->SetLineColor(CgemFoilColor);
245 m_CgemFoilZR[layer][foil][j]->SetFillColor(CgemFoilColor);
246 m_CgemFoilZR[layer][foil][j]->SetRotatable(true);
247 }
248 }
249 }
250
251 //Calculate CGEM strips by using CgemGeomSvc package
252 CgemGeomSvc cgs("CgemGeomSvc", Gaudi::svcLocator());
253 cgs.initGeom();
254 CgemGeoReadoutPlane* plane = 0;
255 CgemGeoLayer* geolayer = 0;
256
257 for (int layer = 0; layer < 3; ++layer)
258 {
259 for (int sheet = 0; sheet < 2; ++sheet)
260 {
261 //Load data of Readout Plane
262 if (layer == 0 && sheet == 1) continue;
263 plane = cgs.getReadoutPlane(layer, sheet);
264 geolayer = cgs.getCgemLayer(layer);
265
266 cout << "layer" << layer << " sheet" << sheet << " " << plane << endl;
267 cout << "\tRX:" << plane->getRX() << endl;
268 cout << "\tRV:" << plane->getRV() << endl;
269 cout << "\tXmin:" << plane->getXmin() << endl;
270 cout << "\tWidth:" << plane->getWidth() << endl;
271 cout << "\tZmin:" << plane->getZmin() << endl;
272 cout << "\tLength:" << plane->getLength() << endl;
273 cout << "\tXPitch:" << plane->getXPitch() << endl;
274 cout << "\tVPitch:" << plane->getVPitch() << endl;
275 cout << "\tStereo Angle:" << plane->getStereoAngle() << endl;
276 cout << "\tMid R at Gap:" << plane->getMidRAtGap() << endl;
277 cout << "\tVmax:" << plane->getVmax() << endl;
278 cout << "\tX-strip number:" << plane->getNXstrips() << endl;
279 cout << "\tV-strip number:" << plane->getNVstrips() << endl;
280 cout << "\tX-strip width:" << geolayer->getWidthOfStripX() << endl;
281 cout << "\tV-strip width:" << geolayer->getWidthOfStripV() << endl;
282
283 //Construct sheets unfolded geometry
284 //P[1] = P[4] = -plane->getLength() / 2;
285 P[1] = P[4] = plane->getZmin(); //New Geom
286 P[2] = P[5] = P[8] = P[11] = 0;
287 //P[7] = P[10] = plane->getLength() / 2;
288 P[7] = P[10] = plane->getZmin() + plane->getLength(); //New Geom
289 P[0] = P[9] = plane->getXmin(); //New Geom
290 P[3] = P[6] = plane->getXmin() + plane->getWidth(); //New Geom
291 /*
292 if (layer == 0)
293 {
294 P[0] = P[9] = -plane->getWidth() / 2;
295 P[3] = P[6] = plane->getWidth() / 2;
296 }
297 else
298 {
299 P[0] = P[9] = plane->getXmin() - plane->getWidth();
300 P[3] = P[6] = plane->getXmin();
301 }
302 */
303
304 name = "CGEM Layer";
305 name += layer;
306 name += " Sheet";
307 name += sheet;
308 m_CgemSheet[layer][sheet] = new BesPolygon2D(name, name, 4, P);
309 m_CgemSheet[layer][sheet]->SetFillColor(CgemFillColor);
310 m_CgemSheet[layer][sheet]->SetFillStyle(CgemFillStyle);
311 m_CgemSheet[layer][sheet]->SetLineColor(CgemLineColor);
312
313
314 //Variables which will be used in constructing strips geometry
315 double r, wid, len, phi, xmin, zmin, ang, pit, thick, size, v, ruf;
316 ruf = (plane->getRX() + plane->getRV()) / 2;
317
318 //Construct X-strips 2D and 3D geometry
319 int n = plane->getNXstrips();
320 NXStrip[layer][sheet] = n;
321 m_CgemXStrip[layer][sheet] = new Cgem2DXStrip*[n];
322 XStripPhi[layer][sheet] = new Double_t[n];
323 len = plane->getLength();
324 wid = plane->getWidth();
325 zmin = plane->getZmin();
326 r = plane->getRX();
327 thick = 0.1;
328 size = geolayer->getWidthOfStripX();
329 SheetWidth[layer][sheet] = wid;
330 RX[layer][sheet] = r;
331 ZMin[layer][sheet] = zmin;
332
333 for (int strip = 0; strip < n; ++strip)
334 {
335 name = "CGEM X-Strip Layer";
336 name += layer;
337 name += " Sheet";
338 name += sheet;
339 name += " Strip";
340 name += strip;
341 phi = plane->getPhiFromXID(strip);
342 XStripPhi[layer][sheet][strip] = phi;
343 m_CgemXStrip[layer][sheet][strip] = new Cgem2DXStrip(name, name,
344 len, wid, phi, zmin, r, size, thick, layer, sheet, strip, ruf);
345 }
346
347 phi = plane->getPhiFromXID(n - 1);
348 phi -= plane->getPhiFromXID(0);
349
350 //Construct V-strips 2D and 3D geometry
351 n = plane->getNVstrips();
352 NVStrip[layer][sheet] = n;
353 m_CgemVStrip[layer][sheet] = new Cgem2DVStrip*[n];
354 VStripV[layer][sheet] = new Double_t[n];
355 r = plane->getRV();
356 len = plane->getLength();
357 wid = phi * ruf + geolayer->getWidthOfStripX(); //New Geom
358 ang = plane->getStereoAngle();
359 xmin = plane->getXmin();
360 pit = plane->getVPitch();
361 thick = 0.1;
362 size = geolayer->getWidthOfStripV();
363 RV[layer][sheet] = r;
364 SheetLength[layer][sheet] = len;
365 StereoAngle[layer][sheet] = ang;
366 //New Geom
367 XMin[layer][sheet] = plane->getPhiFromXID(0) * ruf - geolayer->getWidthOfStripX() / 2; //New Geom
368 xmin = XMin[layer][sheet];
369 VPitch[layer][sheet] = pit;
370 XPitch[layer][sheet] = plane->getXPitch();
371
372 for (int strip = 0; strip < n; ++strip)
373 {
374 name = "CGEM V-Strip Layer";
375 name += layer;
376 name += " Sheet";
377 name += sheet;
378 name += " Strip";
379 name += strip;
380 //New Geom
381 v = plane->getCentralVFromVID(strip);
382 VStripV[layer][sheet][strip] = v;
383 m_CgemVStrip[layer][sheet][strip] = new Cgem2DVStrip(name, name, v,
384 r, len, wid, ang, xmin, zmin, pit, size, thick, layer, sheet, strip, ruf);
385 }
386 } //sheet
387 } //layer
388}
389
390//Set the pointers to theirs nodes
392{
393 if (m_ROOTGeoInit == 2)
394 { //from GDML
395 m_CGEM = GetTopVolume();
396 if (!m_CGEM) std::cout << "m_CGEM = 0" << std::endl;
397 // Int_t nDaughters = m_CGEM->GetNodes()->GetEntries();
398 // cout << "CGEM contains " << nDaughters << " nodes : " << endl;
399 // analNodes(m_CGEM->GetNodes(), 0);
400
401 for (int layer = 0; layer < m_kCgemLayer; ++layer)
402 {
403 std::stringstream osanode, oscathode;
404 osanode << "pv_Anode_logic" << layer << "_0";
405 oscathode << "pv_Cathode_logic" << layer << "_8";
406 m_NodeCgemAnode[layer] = GetNode(osanode.str());
407 m_NodeCgemCathode[layer] = GetNode(oscathode.str());
408 // cout << osanode.str() << " " << m_NodeCgemAnode[layer] << endl;
409 // cout << oscathode.str() << " " << m_NodeCgemCathode[layer] << endl;
410
411 for (int foil = 0; foil < m_kCgemFoil; ++foil)
412 {
413 std::stringstream osfoil;
414 osfoil << "pv_GemFoil_logic" << layer << "foil" << foil << "_" << m_kCgemFoil - foil;
415 m_NodeCgemFoil[layer][foil] = GetNode(osfoil.str());
416 // cout << osfoil.str() << " " << m_NodeCgemFoil[layer][foil] << endl;
417 }
418 }
419 }
420 else if (m_ROOTGeoInit == 1)
421 { //from ROOT
422 for (int layer = 0; layer < m_kCgemLayer; ++layer)
423 {
424 TGeoNode* cgemLayer = m_CGEM->GetNode(m_kCgemLayer - layer);
425 m_NodeCgemAnode[layer] = cgemLayer->GetVolume()->GetNode(0);
426 m_NodeCgemCathode[layer] = cgemLayer->GetVolume()->GetNode(8);
427 for (int foil = 0; foil < m_kCgemFoil; ++foil)
428 {
429 m_NodeCgemFoil[layer][foil] = cgemLayer->GetVolume()->GetNode(m_kCgemFoil - foil);
430 }
431 }
432 }
433}
434
435//Set default visual attributes
437{
438
439}
440
441//Set default 3D color
443{
444
445}
446
447//Set all visible
449{
450
451}
452
453//Set quater visible
455{
456
457}
458
459//Set half visible
461{
462
463}
464
465//Set the pointers to the physical nodes
467{
468
469}
470
471//Draw Detecor (what is detector depends on you)
473{
474
475}
476
477//Long Peixun's update: Clear all hits
479{
480 for (int i = 0; i < m_2DHitsArray->GetEntries(); ++i)
481 {
483 strip->ClearInfo();
484 strip->AddInfo(strip->GetTitle());
485 strip->CloseInfo();
486 }
487 m_2DHitsArray->Clear("C");
488}
489
490//Set all physicalNodes corresponding to digiCol
492{
493 // set previous event 2D hits info to default
494 ClearHits();
495
496 int NDigiCol = 0;
497 if (gEvent)
498 {
499 m_CgemDigiCol = gEvent->GetCgemDigiCol();
500 if (m_CgemDigiCol) NDigiCol = m_CgemDigiCol->GetEntries();
501 else NDigiCol = 0;
502 }
503
504 for (int i = 0; i < NDigiCol; ++i)
505 {
506 TCgemDigi* aCgemDigi = (TCgemDigi*)m_CgemDigiCol->At(i);
507 Identifier aCgemID(aCgemDigi->getIntId());
508 int layer = CgemID::layer(aCgemID);
509 int sheet = CgemID::sheet(aCgemID);
510 int strip = CgemID::strip(aCgemID);
511 bool is_x = CgemID::is_xstrip(aCgemID);
512
513 Double_t time = RawDataUtil::CgemTime(aCgemDigi->getTimeChannel());
514 Int_t charge = RawDataUtil::CgemCharge(aCgemDigi->getChargeChannel());
515
516 //Construct 2D hits
517 Cgem2DStripBase* aStrip = 0;
518 if (is_x)
519 {
520 if (strip < NXStrip[layer][sheet] && strip >= 0)
521 aStrip = m_CgemXStrip[layer][sheet][strip];
522 }
523 else
524 {
525 if (strip < NVStrip[layer][sheet] && strip > 0)
526 aStrip = m_CgemVStrip[layer][sheet][strip];
527 }
528
529 //Add 2D hits
530 if (aStrip)
531 {
532 aStrip->CloseInfo();
533 //aStrip->AddInfo(aStrip->GetTitle());
534 double evTime = gEvent->GetHeader().GetEvTime();
535
536 char data[200];
537 if(time>1000000)
538 sprintf(data, "NO time");
539 else
540 {
541 sprintf(data, "time=%-.1f ns", time);
542 if(fabs(evTime)>0.0001)
543 sprintf(data, "%s, Tdrift(Raw)=%-.1f ns", data, time - evTime +230);
544 }
545
546 if(charge>1000000) sprintf(data, "%s, NO charge", data);
547 else sprintf(data, "%s, charge=%d", data,charge);
548
549 aStrip->AddInfo(TString(data));
550 sprintf(data, "Fired");
551 aStrip->AddInfo(TString(data));
552 //aStrip->SetTime(time);
553 //aStrip->SetCharge(charge);
554 //unsigned int overflow = aCgemDigi->getOverflow();
555 //aWire->SetQOverflow(overflow & 2);
556 //aWire->SetEvTime(evTime);
557 aStrip->CloseInfo();
558 m_2DHitsArray->Add(aStrip);
559 }
560 }
561}
562
563//Set CGEM default detector visibility;
565{
566
567}
568
569//Set CGEM hits visibility;
571{
572
573}
574
575TGeoNode* CgemROOTGeo::GetCgemAnode(int layer)
576{
577 return m_NodeCgemAnode[layer];
578}
579
580TGeoNode* CgemROOTGeo::GetCgemCathode(int layer)
581{
582 return m_NodeCgemCathode[layer];
583}
584
585TGeoNode* CgemROOTGeo::GetCgemFoil(int layer, int foil)
586{
587 return m_NodeCgemFoil[layer][foil];
588}
589
590//Draw function
591void CgemROOTGeo::Draw(Option_t *option)
592{
593 TString opt = option;
594 opt.ToUpper();
595
596 if (!m_2DGeoInit) cout << "CgemROOTGeo::Draw(), Geometry not initialized!" << endl;
597 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
598 if (!view) cout << "CgemROOTGeo::Draw(), BesView not found" << endl;
599
600 if (view->GetVisCgemGlobal())
601 {
602 if (opt.Contains("XY")) m_CgemXY->Draw("");
603 if (opt.Contains("ZR"))
604 {
605 m_CgemZR[0]->Draw("");
606 m_CgemZR[1]->Draw("");
607 }
608
609 if (view->GetVisCgemLayers())
610 {
611 if (opt.Contains("XY"))
612 {
613 for (int layer = 0; layer < m_kCgemLayer; ++layer)
614 {
615 m_CgemAnodeXY[layer]->Draw("");
616 m_CgemCathodeXY[layer]->Draw("");
617 for (int foil = 0; foil < m_kCgemFoil; ++foil)
618 m_CgemFoilXY[layer][foil]->Draw("");
619 }
620 }
621
622 if (opt.Contains("ZR"))
623 {
624 for (int layer = 0; layer < m_kCgemLayer; ++layer)
625 {
626 m_CgemAnodeZR[layer][0]->Draw("");
627 m_CgemAnodeZR[layer][1]->Draw("");
628 m_CgemCathodeZR[layer][0]->Draw("");
629 m_CgemCathodeZR[layer][1]->Draw("");
630 for (int foil = 0; foil < m_kCgemFoil; ++foil)
631 {
632 m_CgemFoilZR[layer][foil][0]->Draw("");
633 m_CgemFoilZR[layer][foil][1]->Draw("");
634 }
635 }
636 }
637 }
638
639 if (opt.Contains("ZR")) //In ZR View, draw X-strip first
640 {
641 if (view->GetVisCgemXStrips())
642 {
643 for (int layer = 0; layer < m_kCgemLayer; ++layer)
644 {
645 for (int sheet = 0; sheet < 2; ++sheet)
646 {
647 if (layer == 0 && sheet == 1) continue;
648 for (int strip = 0; strip < NXStrip[layer][sheet]; ++strip)
649 {
650 m_CgemXStrip[layer][sheet][strip]->SetFired(false);
651 m_CgemXStrip[layer][sheet][strip]->Draw(opt);
652 }
653 }
654 }
655 }
656 if (view->GetVisCgemVStrips())
657 {
658 for (int layer = 0; layer < m_kCgemLayer; ++layer)
659 {
660 for (int sheet = 0; sheet < 2; ++sheet)
661 {
662 if (layer == 0 && sheet == 1) continue;
663 for (int strip = 0; strip < NVStrip[layer][sheet]; ++strip)
664 {
665 m_CgemVStrip[layer][sheet][strip]->SetFired(false);
666 m_CgemVStrip[layer][sheet][strip]->Draw(opt);
667 }
668 }
669 }
670 }
671 }
672 else //In XY View, draw V-strip first
673 {
674 if (view->GetVisCgemVStrips())
675 {
676 for (int layer = 0; layer < m_kCgemLayer; ++layer)
677 {
678 for (int sheet = 0; sheet < 2; ++sheet)
679 {
680 if (layer == 0 && sheet == 1) continue;
681 for (int strip = 0; strip < NVStrip[layer][sheet]; ++strip)
682 {
683 m_CgemVStrip[layer][sheet][strip]->SetFired(false);
684 m_CgemVStrip[layer][sheet][strip]->Draw(opt);
685 }
686 }
687 }
688 }
689 if (view->GetVisCgemXStrips())
690 {
691 for (int layer = 0; layer < m_kCgemLayer; ++layer)
692 {
693 for (int sheet = 0; sheet < 2; ++sheet)
694 {
695 if (layer == 0 && sheet == 1) continue;
696 for (int strip = 0; strip < NXStrip[layer][sheet]; ++strip)
697 {
698 m_CgemXStrip[layer][sheet][strip]->SetFired(false);
699 m_CgemXStrip[layer][sheet][strip]->Draw(opt);
700 }
701 }
702 }
703 }
704 }
705 }
706}
707
708//Draw unfolded function
709void CgemROOTGeo::DrawUF(int layer, Option_t *option)
710{
711 if (layer < 0 || layer >= m_kCgemLayer) return;
712 TString opt = option;
713 opt += ",UF";
714 opt.ToUpper();
715 if (!m_2DGeoInit) cout << "CgemROOTGeo::Draw(), Geometry not initialized!" << endl;
716 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
717 if (!view) cout << "CgemROOTGeo::Draw(), BesView not found" << endl;
718
719 if (view->GetVisCgemGlobal())
720 {
721 for (int sheet = 0; sheet < 2; ++sheet)
722 {
723 if (layer == 0 && sheet == 1) continue;
724 if (view->GetVisCgemLayers()) m_CgemSheet[layer][sheet]->Draw(opt);
725
726 if (view->GetVisCgemXStrips())
727 {
728 for (int strip = 0; strip < NXStrip[layer][sheet]; ++strip)
729 {
730 m_CgemXStrip[layer][sheet][strip]->SetFired(false);
731 m_CgemXStrip[layer][sheet][strip]->Draw(opt);
732 }
733 }
734 if (view->GetVisCgemVStrips())
735 {
736 for (int strip = 0; strip < NVStrip[layer][sheet]; ++strip)
737 {
738 m_CgemVStrip[layer][sheet][strip]->SetFired(false);
739 m_CgemVStrip[layer][sheet][strip]->Draw(opt);
740 }
741 }
742 }
743 }
744}
745
746//Draw 2D hits
747void CgemROOTGeo::DrawHits(Option_t *option)
748{
749 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
750 if (!view) cout << "CgemROOTGeo::DrawHits(), BesView not found" << endl;
751
752 if (view->GetVisCgemHitsGlobal())
753 {
754 for (int i = 0; i < m_2DHitsArray->GetEntries(); ++i)
755 {
757 bool skip = false;
758 if (aStrip->GetType() == CGEM_X_STRIP)
759 {
760 if (!view->GetVisCgemHitsXStrip()) skip = true;
761 }
762 else if (aStrip->GetType() == CGEM_V_STRIP)
763 {
764 if (!view->GetVisCgemHitsVStrip()) skip = true;
765 }
766
767 if (!skip && aStrip)
768 {
769 //normal view
770 if ((view->GetViewType() & kXYView) || (view->GetViewType() & kZRView))
771 {
772 aStrip->SetFired(true);
773 aStrip->Draw(option);
774 }
775
776 //unfolded view
777 else if ((view->GetViewType() & kCgemUFView0) && aStrip->GetLayer() == 0)
778 {
779 aStrip->SetFired(true);
780 aStrip->Draw(option);
781 }
782 else if ((view->GetViewType() & kCgemUFView1) && aStrip->GetLayer() == 1)
783 {
784 aStrip->SetFired(true);
785 aStrip->Draw(option);
786 }
787 else if ((view->GetViewType() & kCgemUFView2) && aStrip->GetLayer() == 2)
788 {
789 aStrip->SetFired(true);
790 aStrip->Draw(option);
791 }
792 }
793 } //for end
794 }
795}
796
797void CgemROOTGeo::Draw3DHits(Option_t *option)
798{
799 BesView *view = dynamic_cast<BesView*>(gPad->GetView());
800 if (!view) cout << "CgemROOTGeo::Draw3DHits(), BesView not found" << endl;
801
802 if (view->GetVisCgemHitsGlobal())
803 {
804 int NDigiCol = 0;
805 if (gEvent)
806 {
807 m_CgemDigiCol = gEvent->GetCgemDigiCol();
808 if (m_CgemDigiCol) NDigiCol = m_CgemDigiCol->GetEntries();
809 else NDigiCol = 0;
810 }
811
812 for (int i = 0; i < NDigiCol; ++i)
813 {
814 TCgemDigi* aCgemDigi = (TCgemDigi*)m_CgemDigiCol->At(i);
815 Identifier aCgemID(aCgemDigi->getIntId());
816 int layer = CgemID::layer(aCgemID);
817 int sheet = CgemID::sheet(aCgemID);
818 int strip = CgemID::strip(aCgemID);
819 bool is_x = CgemID::is_xstrip(aCgemID);
820 TPolyLine3D* pStrip = 0;
821
822 if (is_x)
823 {
824 if (view->GetVisCgemHitsXStrip() && strip < NXStrip[layer][sheet] && strip >= 0)
825 {
826 //Construct X-strip 3D hits
827 Double_t P[6];
828 double phi = XStripPhi[layer][sheet][strip];
829 double r = RX[layer][sheet];
830 double zmin = ZMin[layer][sheet];
831 P[0] = P[3] = TMath::Cos(phi) * r;
832 P[1] = P[4] = TMath::Sin(phi) * r;
833 P[2] = -zmin;
834 P[5] = zmin;
835
836 pStrip = new TPolyLine3D(2, P);
837 pStrip->SetBit(kCanDelete);
838 pStrip->SetLineWidth(4);
839 pStrip->SetLineColor(m_XstripColor);
840 pStrip->Draw(option);
841 }
842 }
843 else
844 {
845 if (view->GetVisCgemHitsVStrip() && strip < NVStrip[layer][sheet] && strip >= 0)
846 {
847 //Construct V-strip 3D hits
848 double r = RV[layer][sheet];
849 double len = SheetLength[layer][sheet];
850 double wid = SheetWidth[layer][sheet];
851 double ang = StereoAngle[layer][sheet];
852 double xmin = XMin[layer][sheet];
853 double zmin = ZMin[layer][sheet];
854 double pit = VPitch[layer][sheet];
855 CgemVStripCalculator calc(r, len, wid, ang, xmin, zmin, pit);
856
857 int N = calc.getPointNumberFromV(strip);
858 if (N > 0)
859 {
860 pStrip = new TPolyLine3D(N);
861 pStrip->SetBit(kCanDelete);
862 pStrip->SetLineWidth(3);
863 pStrip->SetLineColor(m_VstripColor);
864
865 double tphi = 0, tz = 0;
866 for (int i = 0; i < N; ++i)
867 {
868 //New Geom
869 double v = VStripV[layer][sheet][strip];
870 calc.getNthPointFromV(v, i, tphi, tz);
871 double x = r * TMath::Cos(tphi);
872 double y = r * TMath::Sin(tphi);
873 double z = tz;
874 pStrip->SetPoint(i, x, y, z);
875 }
876
877 pStrip->Draw(option);
878 }
879 }
880 }
881 }
882 }
883}
884
885//Get 2D strip
886Cgem2DStripBase* CgemROOTGeo::Get2DStrip(bool is_x, int layer, int sheet, int strip) const
887{
888 if (is_x)
889 {
890 if (strip >= 0 && strip < NXStrip[layer][sheet])
891 return m_CgemXStrip[layer][sheet][strip];
892 }
893 else
894 {
895 if (strip >= 0 && strip < NVStrip[layer][sheet])
896 return m_CgemVStrip[layer][sheet][strip];
897 }
898 return 0;
899}
900
901//These 4 functions are used for CGEM clusters calculation in BesEvent
902double CgemROOTGeo::calcZFromLayerSheetVIDPhi(int layer, int sheet, double v, double phi) const
903{
904 if (layer < 0 || layer >= m_kCgemLayer || sheet < 0 || sheet >= 2) return 0.0;
905 double ruf = (RV[layer][sheet] + RX[layer][sheet]) / 2;
906 double len = SheetLength[layer][sheet];
907 double wid = SheetWidth[layer][sheet];
908 double ang = StereoAngle[layer][sheet];
909 double xmin = XMin[layer][sheet];
910 double zmin = ZMin[layer][sheet];
911 double pit = VPitch[layer][sheet];
912 double vuf = v / RV[layer][sheet] * ruf;
913 CgemVStripCalculator calc(ruf, len, wid, ang, xmin, zmin, pit);
914 return calc.getZFromVPhi(v, phi);
915}
916
917double CgemROOTGeo::getRFromLayerSheet(int layer, int sheet) const
918{
919 if (layer < 0 || layer >= m_kCgemLayer || sheet < 0 || sheet >= 2) return 0.0;
920 return (RX[layer][sheet] + RV[layer][sheet]) / 2;
921}
922
923double CgemROOTGeo::getSheetWidth(int layer, int sheet) const
924{
925 if (layer < 0 || layer >= m_kCgemLayer || sheet < 0 || sheet >= 2) return 0.0;
926 return SheetWidth[layer][sheet];
927}
928
929double CgemROOTGeo::isPointInSheet(int layer, int sheet, double phi, double z) const
930{
931 if (layer < 0 || layer >= m_kCgemLayer || sheet < 0 || sheet >= 2) return 0.0;
932 double ruf = (RV[layer][sheet] + RX[layer][sheet]) / 2;
933 double len = SheetLength[layer][sheet];
934 double wid = SheetWidth[layer][sheet];
935 double ang = StereoAngle[layer][sheet];
936 double xmin = XMin[layer][sheet];
937 double zmin = ZMin[layer][sheet];
938 double pit = VPitch[layer][sheet];
939 CgemVStripCalculator calc(ruf, len, wid, ang, xmin, zmin, pit);
940 return calc.isPointInSheet(phi, z);
941}
double P(RecMdcKalTrack *trk)
const Int_t n
TTree * data
Double_t x[10]
Double_t time
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
virtual void Draw(Option_t *option="")
virtual void Draw(Option_t *option="")
virtual void ClearInfo()
Definition: Cgem2DStrip.cxx:41
virtual void Draw(Option_t *option="")=0
virtual ECgemStripType GetType() const =0
virtual void CloseInfo()=0
virtual void Draw(Option_t *option="")
virtual void Draw(Option_t *option="")
double getPhiFromXID(int X_ID) const
bool initGeom()
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
static bool is_xstrip(const Identifier &id)
double getRFromLayerSheet(int layer, int sheet) const
void SetVisCgemHits()
TGeoNode * GetCgemAnode(int layer)
void SetPhysicalNode()
void SetHits()
void SetNode()
void Draw3DHits(Option_t *option)
double getSheetWidth(int layer, int sheet) const
void SetVolumeDefaultVis()
void InitFromROOT(TGeoVolume *vol)
Definition: CgemROOTGeo.cxx:89
Cgem2DStripBase * Get2DStrip(bool is_x, int layer, int sheet, int strip) const
TGeoNode * GetCgemCathode(int layer)
virtual ~CgemROOTGeo()
Definition: CgemROOTGeo.cxx:60
void ClearHits()
void InitGeometry()
Definition: CgemROOTGeo.cxx:97
TGeoNode * GetCgemFoil(int layer, int foil)
double isPointInSheet(int layer, int sheet, double phi, double z) const
void SetPhysicalDefaultVis()
void DrawHits(Option_t *option)
void SetAllVisible()
void Draw(Option_t *option)
double calcZFromLayerSheetVIDPhi(int layer, int sheet, double v, double phi) const
void SetVisCgemDetector()
void SetDetector()
void DrawUF(int layer, Option_t *option="")
void SetHalfVisible()
void SetQuarterVisible()
void InitFromGDML(const char *gdmlFile, const char *setupName)
Definition: CgemROOTGeo.cxx:81
int getPointNumberFromV(double v) const
int getNthPointFromV(double v, int i, double &phi, double &z) const
bool isPointInSheet(double phi, double z) const
double getZFromVPhi(double v, double phi) const
static double CgemCharge(int chargeChannel)
TGeoNode * GetNode(const std::string &nn)
Get a node(physical volume) by name;.
void ReadGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
c1_1 Draw()