CbmRoot
riplet/LxDraw.cxx
Go to the documentation of this file.
1 #ifdef LXDRAW
2 
3 #include "LxDraw.h"
4 #include "CbmKF.h"
5 #include "Lx.h"
6 #include "TEllipse.h"
7 #include "TGeoArb8.h"
8 #include "TGeoBoolNode.h"
9 #include "TGeoCompositeShape.h"
10 #include "TGeoCone.h"
11 #include "TGeoManager.h"
12 #include "TLatex.h"
13 #include "TLine.h"
14 #include "TMCProcess.h"
15 #include "TPolyLine.h"
16 #include "TPolyMarker.h"
17 #include "TStyle.h"
18 #include <iostream>
19 #include <math.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 
23 #ifdef CLUSTER_MODE
24 #include "kdtree++/kdtree.hpp"
25 #endif //CLUSTER_MODE
26 
27 #define USE_MUCH_ABSORBER
28 
29 using namespace std;
30 
31 static int StaColour = 17;
32 
34  : YZ("YZ", "YZ Side View", -10, -50, 650, 1000)
35  , XZ("XZ", "XZ Top View", -10, -50, 650, 1000)
36  , YX("YX", "YX Front View", -500, 0, 1000, 1000)
37  , ask(true) {
38  gStyle->SetCanvasBorderMode(0);
39  gStyle->SetCanvasBorderSize(1);
40  gStyle->SetCanvasColor(0);
41 
42  YZ.Range(-15.0, -300.0, 600.0, 300.0);
43  YZ.Draw();
44  YZ.Update();
45 
46  XZ.Range(-15.0, -300.0, 600.0, 300.0);
47  XZ.Draw();
48  XZ.Update();
49 
50  YX.Range(-300.0, -300.0, 300.0, 300.0);
51  YX.Draw();
52  YX.Update();
53 }
54 
55 void LxDraw::ClearView() {
56  YZ.Clear();
57  XZ.Clear();
58  YX.Clear();
59 }
60 
61 void LxDraw::Ask() {
62  char symbol;
63 
64  if (ask) {
65  cout << "ask>";
66 
67  do {
68  cin.get(symbol);
69 
70  if (symbol == 'r') ask = false;
71 
72  if (symbol == 'q') exit;
73  } while (symbol != '\n');
74 
75  cout << endl;
76  }
77 }
78 
79 void LxDraw::DrawMCTracks() {
80  char buf[128];
81  int NRegMCTracks = 0;
82  LxFinder* finder = LxFinder::Instance();
83  TPolyLine pline;
84 
85  static int mc_tr_count = 0;
86 
87  for (vector<LxMCTrack>::iterator it = finder->MCTracks.begin();
88  it != finder->MCTracks.end();
89  ++it) {
90  LxMCTrack& T = *it;
91 
92  //if ((13 != T.pdg && -13 != T.pdg) || T.mother_ID >= 0)
93  //continue;
94 
95  bool mcPointOnSta[18] = {true,
96  true,
97  true,
98  false,
99  false,
100  false,
101  false,
102  false,
103  false,
104  false,
105  false,
106  false,
107  false,
108  false,
109  false,
110  false,
111  false,
112  false};
113  int mcpCount = 0;
114 
115  for (vector<LxMCPoint*>::iterator j = T.Points.begin(); j != T.Points.end();
116  ++j) {
117  LxMCPoint* pMCPoint = *j;
118  mcPointOnSta[pMCPoint->stationNumber * 3 + pMCPoint->layerNumber] = true;
119  ++mcpCount;
120  }
121 
122  bool isRefTrack = true;
123 
124  for (int j = 0; j < 18; ++j) {
125  if (!mcPointOnSta[j]) isRefTrack = false;
126  }
127 
128  //if (!isRefTrack)
129  if (mcpCount < 15) continue;
130 
131  pline.SetLineColor(kRed);
132 
133  if (T.p < 0.5) pline.SetLineColor(kBlue);
134 
135  if (T.mother_ID != -1) pline.SetLineColor(8);
136 
137  if ((T.mother_ID != -1) && (T.p < 0.5)) pline.SetLineColor(12);
138 
139  double par[6];
140  par[0] = T.x;
141  par[1] = T.y;
142  par[2] = T.px / T.pz;
143  par[3] = T.py / T.pz;
144  par[4] = T.q / T.p;
145  par[5] = T.z;
146 
147  if (T.Points.size() < 1) continue;
148 
149  vector<double> lx, ly, lz;
150  lx.push_back(par[0]);
151  ly.push_back(par[1]);
152  lz.push_back(par[5]);
153 
154  bool ok = true;
155  cout << "LxDraw: drawing MC track with " << T.stationsWithHits
156  << " hitted stations and " << T.layersWithHits << " hitted layers";
157 
158  if (T.layersWithHits < LXSTATIONS * LXLAYERS) {
159  cout << " ";
160 
161  for (Int_t j = 0; j < LXSTATIONS; ++j) {
162  cout << "[";
163 
164  for (Int_t k = 0; k < LXLAYERS; ++k) {
165  if (T.hitsOnStations[j][k])
166  cout << "x";
167  else
168  cout << "o";
169  }
170 
171  cout << "]";
172  }
173  }
174 
175  cout << endl;
176 
177  for (std::vector<LxMCPoint*>::iterator ip = T.Points.begin();
178  ip != T.Points.end();
179  ++ip) {
180  LxMCPoint* p = *ip;
181  double par1[6];
182  par1[0] = p->x;
183  par1[1] = p->y;
184  par1[2] = p->px / p->pz;
185  par1[3] = p->py / p->pz;
186  par1[4] = p->q / p->p;
187  par1[5] = p->z;
188 
189  double Zfrst = par[5];
190  double Zlast = par1[5];
191  double step = .5;
192 
193  if (step > fabs(Zfrst - Zlast) / 5) step = fabs(Zfrst - Zlast) / 5;
194 
195  if (Zlast < par[5]) step = -step;
196 
197  while (fabs(par[5] - Zlast) > fabs(step)) {
198  double znxt = par[5] + step;
199  CbmKF::Instance()->Propagate(par1, 0, znxt, par1[4]);
200  CbmKF::Instance()->Propagate(par, 0, znxt, par[4]);
201  double w = fabs(znxt - Zfrst);
202  double w1 = fabs(znxt - Zlast);
203 
204  if (w + w1 < 1.e-3) {
205  w = 1;
206  w1 = 0;
207  }
208 
209  float xl = (w1 * par[0] + w * par1[0]) / (w + w1);
210  float yl = (w1 * par[1] + w * par1[1]) / (w + w1);
211  float zl = (w1 * par[5] + w * par1[5]) / (w + w1);
212 
213  if ((fabs(xl) > 400.0) || (fabs(yl) > 400.0)) {
214  //cout << "*** track " << NRegMCTracks+1 << " xl = " << xl << ", zl = " << zl << endl;
215  //cout << "*** track " << NRegMCTracks+1 << " yl = " << yl << ", zl = " << zl << endl;
216  ok = false; // Timur
217  continue; // Timur
218  }
219 
220  lx.push_back((w1 * par[0] + w * par1[0]) / (w + w1));
221  ly.push_back((w1 * par[1] + w * par1[1]) / (w + w1));
222  lz.push_back((w1 * par[5] + w * par1[5]) / (w + w1));
223 
224  if (lx.size() > 200) break;
225  }
226 
227  par[0] = p->x;
228  par[1] = p->y;
229 
230  if (p->pz != 0) {
231  par[2] = p->px / p->pz;
232  par[3] = p->py / p->pz;
233  } else {
234  par[2] = 1000 * 1000 * 1000;
235  par[3] = 1000 * 1000 * 1000;
236  }
237 
238  if (p->p != 0)
239  par[4] = p->q / p->p;
240  else
241  par[4] = 1000 * 1000 * 1000;
242 
243  par[5] = p->z;
244  lx.push_back(par[0]);
245  ly.push_back(par[1]);
246  lz.push_back(par[5]);
247  }
248 
249  if (ok) {
250  double max_z = 0, min_z = 500;
251 
252  for (vector<double>::iterator i = lz.begin(); i != lz.end(); ++i) {
253  if (*i > max_z) max_z = *i;
254 
255  if (*i < min_z) min_z = *i;
256  }
257 
258  if (min_z < 10 && max_z > 503) ++mc_tr_count;
259 
260  NRegMCTracks++;
261  YZ.cd();
262  pline.DrawPolyLine(lx.size(), &(lz[0]), &(ly[0]));
263  XZ.cd();
264  pline.DrawPolyLine(lx.size(), &(lz[0]), &(lx[0]));
265  YX.cd();
266  pline.DrawPolyLine(lx.size(), &(lx[0]), &(ly[0]));
267  }
268  }
269 
270  cout << "LxDraw: number of registered MC tracks: " << NRegMCTracks << endl;
271  YZ.cd();
272  YZ.Update();
273  XZ.cd();
274  XZ.Update();
275  YX.cd();
276  YX.Update();
277 }
278 
279 void LxDraw::DrawInputHits() {
280  DrawMuch();
281 
282  // Draw hits
283  int mcolour = 4;
284  int hitsMStyle = 1; //5;
285  double HitSize = 1;
286  LxFinder* finder = LxFinder::Instance();
287  LxSpace& lxSpace = finder->caSpace;
288 
289  int nhits = 0;
290 
291  for (int i = 0; i < 6; ++i)
292  //for (int i = 0; i < 1; ++i)
293  {
294  LxStation* pSt = lxSpace.stations[i];
295 
296  for (int j = 0; j < 3; ++j)
297  //for (int j = 0; j < 1; ++j)
298  {
299  LxLayer* pLa = pSt->layers[j];
300  //nhits += static_cast<KDTreePointsType*> (pLa->pointsHandle)->size();
301  nhits += pLa->points.size();
302  }
303  }
304 
305  Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
306  Double_t x_poly2[nhits], y_poly2[nhits], z_poly2[nhits]; // Removed.
307  Double_t x_poly3[nhits], y_poly3[nhits], z_poly3[nhits]; // Restored.
308  TVector3 pos, err;
309  int n_poly = 0;
310  int n_poly2 = 0;
311  int n_poly3 = 0;
312 
313  //for (int i = 5; i >= 0; --i)
314  for (int i = 0; i >= 0; --i) {
315  LxStation* pSt = lxSpace.stations[i];
316 
317  //for (int j = 2; j >= 0; --j)
318  for (int j = 1; j >= 1; --j) {
319  LxLayer* pLa = pSt->layers[j];
320 
321  //for (KDTreePointsType::iterator k = static_cast<KDTreePointsType*> (pLa->pointsHandle)->begin(); k != static_cast<KDTreePointsType*> (pLa->pointsHandle)->end(); ++k)
322  for (list<LxPoint*>::iterator k = pLa->points.begin();
323  k != pLa->points.end();
324  ++k) {
325  LxPoint* pPo = *k;
326 
327  if (pPo->artificial) {
328  x_poly3[n_poly3] = pPo->x;
329  y_poly3[n_poly3] = pPo->y;
330  z_poly3[n_poly3] = pPo->z;
331  ++n_poly3;
332  } else if (!pPo->valid) {
333  x_poly2[n_poly2] = pPo->x;
334  y_poly2[n_poly2] = pPo->y;
335  z_poly2[n_poly2] = pPo->z;
336  ++n_poly2;
337  } else {
338  x_poly[n_poly] = pPo->x;
339  y_poly[n_poly] = pPo->y;
340  z_poly[n_poly] = pPo->z;
341  ++n_poly;
342  }
343  }
344  }
345  }
346 
347  YZ.cd();
348 
349  TPolyMarker* pmyz = new TPolyMarker(n_poly, z_poly, y_poly);
350  pmyz->SetMarkerColor(mcolour);
351  pmyz->SetMarkerStyle(hitsMStyle);
352  pmyz->SetMarkerSize(HitSize);
353  pmyz->Draw();
354 
355  TPolyMarker* pmyz2 = new TPolyMarker(n_poly2, z_poly2, y_poly2);
356  pmyz2->SetMarkerColor(2);
357  pmyz2->SetMarkerStyle(hitsMStyle);
358  pmyz2->SetMarkerSize(HitSize);
359  pmyz2->Draw();
360 
361  TPolyMarker* pmyz3 = new TPolyMarker(n_poly3, z_poly3, y_poly3);
362  pmyz3->SetMarkerColor(3);
363  pmyz3->SetMarkerStyle(hitsMStyle);
364  pmyz3->SetMarkerSize(HitSize);
365  pmyz3->Draw();
366 
367  XZ.cd();
368 
369  TPolyMarker* pmxz = new TPolyMarker(n_poly, z_poly, x_poly);
370  pmxz->SetMarkerColor(mcolour);
371  pmxz->SetMarkerStyle(hitsMStyle);
372  pmxz->SetMarkerSize(HitSize);
373  pmxz->Draw();
374 
375  TPolyMarker* pmxz2 = new TPolyMarker(n_poly2, z_poly2, x_poly2);
376  pmxz2->SetMarkerColor(2);
377  pmxz2->SetMarkerStyle(hitsMStyle);
378  pmxz2->SetMarkerSize(HitSize);
379  pmxz2->Draw();
380 
381  TPolyMarker* pmxz3 = new TPolyMarker(n_poly3, z_poly3, x_poly3);
382  pmxz3->SetMarkerColor(3);
383  pmxz3->SetMarkerStyle(hitsMStyle);
384  pmxz3->SetMarkerSize(HitSize);
385  pmxz3->Draw();
386 
387  YX.cd();
388 
389  TPolyMarker* pmyx = new TPolyMarker(n_poly, x_poly, y_poly);
390  pmyx->SetMarkerColor(mcolour);
391  pmyx->SetMarkerStyle(hitsMStyle);
392  pmyx->SetMarkerSize(HitSize);
393  pmyx->Draw();
394 
395  TPolyMarker* pmyx2 = new TPolyMarker(n_poly2, x_poly2, y_poly2);
396  pmyx2->SetMarkerColor(2);
397  pmyx2->SetMarkerStyle(hitsMStyle);
398  pmyx2->SetMarkerSize(HitSize);
399  pmyx2->Draw();
400 
401  TPolyMarker* pmyx3 = new TPolyMarker(n_poly3, x_poly3, y_poly3);
402  pmyx3->SetMarkerColor(3);
403  pmyx3->SetMarkerStyle(hitsMStyle);
404  pmyx3->SetMarkerSize(HitSize);
405  pmyx3->Draw();
406 }
407 
408 void LxDraw::DrawMuch(TGeoNode* node) {
409  TObjArray* children;
410  TObject* childO;
411 
412  if (0 != strstr(node->GetName(), "active")) {
413  TGeoCompositeShape* cs =
414  dynamic_cast<TGeoCompositeShape*>(node->GetVolume()->GetShape());
415 
416  if (cs) {
417  TGeoBoolNode* bn = cs->GetBoolNode();
418  TGeoTrap* trap = dynamic_cast<TGeoTrap*>(bn->GetLeftShape());
419 
420  if (trap) {
421  Double_t minY = 0, maxY = 0, minX = 0, maxX = 0, Z = 0;
422  Double_t* xy = trap->GetVertices();
423  Double_t trapX[5];
424  Double_t trapY[5];
425 
426  for (int i = 0; i < 4; ++i) {
427  Double_t localCoords[3] = {xy[2 * i], xy[2 * i + 1], 0.};
428  Double_t globalCoords[3];
429  gGeoManager->LocalToMaster(localCoords, globalCoords);
430 
431  if (minY > globalCoords[1]) minY = globalCoords[1];
432 
433  if (maxY < globalCoords[1]) maxY = globalCoords[1];
434 
435  if (minX > globalCoords[0]) minX = globalCoords[0];
436 
437  if (maxX < globalCoords[0]) maxX = globalCoords[0];
438 
439  Z = globalCoords[2];
440  trapX[i] = globalCoords[0];
441  trapY[i] = globalCoords[1];
442  }
443 
444  trapX[4] = trapX[0];
445  trapY[4] = trapY[0];
446 
447  YZ.cd();
448  TLine* line = new TLine();
449  line->SetLineColor(StaColour);
450  line->DrawLine(Z, minY, Z, maxY);
451 
452  XZ.cd();
453  line->DrawLine(Z, minX, Z, maxX);
454 
455  YX.cd();
456  TPolyLine* pline = new TPolyLine(5, trapX, trapY);
457  pline->SetFillColor(StaColour);
458  pline->SetLineColor(kCyan + 4);
459  pline->SetLineWidth(1);
460  pline->Draw("f");
461  pline->Draw();
462  }
463  }
464 
465  goto exit;
466  }
467 
468  children = node->GetNodes();
469 
470  if (0 == children) goto exit;
471 
472  childO = children->First();
473 
474  while (childO) {
475  TGeoNode* child = dynamic_cast<TGeoNode*>(childO);
476 
477  if (child) {
478  gGeoManager->GetCurrentNavigator()->CdDown(child);
479  DrawMuch(child);
480  }
481 
482  childO = children->After(childO);
483  }
484 
485 exit:
486  gGeoManager->CdUp();
487 }
488 
489 void LxDraw::DrawMuch() {
490  TLatex latex;
491  latex.SetTextFont(132);
492  latex.SetTextAlign(12);
493  latex.SetTextSize(0.035);
494 
495  YZ.cd();
496  latex.DrawLatex(0.0, 250.0, "YZ Side View");
497  YZ.Draw();
498 
499  XZ.cd();
500  latex.DrawLatex(0.0, 250.0, "XZ Top View");
501  XZ.Draw();
502 
503  YX.cd();
504  latex.DrawLatex(-270.0, 250.0, "YX Front View");
505  YX.Draw();
506 
507  for (int i = 6; i > 0; --i) {
508  char buf[128];
509  // Draw 3 layers of the much station
510  //if (i < 7)
511  {
512  sprintf(buf, "/cave_1/much_0/muchstation0%d_0", i);
513  gGeoManager->cd(buf);
514  DrawMuch(gGeoManager->GetCurrentNode());
515  }
516 #ifdef USE_MUCH_ABSORBER
517  // Draw an absorber
518  sprintf(buf, "/cave_1/much_0/muchabsorber0%d_0", i);
519  gGeoManager->cd(buf);
520  Double_t localCoords[3] = {0., 0., 0.};
521  Double_t globalCoords[3];
522  gGeoManager->LocalToMaster(localCoords, globalCoords);
523  TGeoVolume* muchAbsVol = gGeoManager->GetCurrentVolume();
524  TGeoShape* muchAbsShape = muchAbsVol->GetShape();
525  TGeoCone* muchAbsCone = dynamic_cast<TGeoCone*>(muchAbsShape);
526 
527  Double_t fRmax1 = muchAbsCone->GetRmax1();
528  Double_t fRmax2 = muchAbsCone->GetRmax2();
529  Double_t fDz = muchAbsCone->GetDz();
530  Double_t fZ = globalCoords[2];
531 
532  Double_t maXs[5] = {fZ - fDz, fZ - fDz, fZ + fDz, fZ + fDz, fZ - fDz};
533  Double_t maYs[5] = {-fRmax1, fRmax1, fRmax2, -fRmax2, -fRmax1};
534  TPolyLine* muchAbsorber = new TPolyLine(5, maXs, maYs);
535  muchAbsorber->SetFillColor(kYellow);
536  muchAbsorber->SetLineColor(kYellow);
537  muchAbsorber->SetLineWidth(1);
538  YZ.cd();
539  muchAbsorber->Draw("f");
540  muchAbsorber->Draw();
541  XZ.cd();
542  muchAbsorber->Draw("f");
543  muchAbsorber->Draw();
544  YX.cd();
545  TEllipse* ellipse = new TEllipse(0.0, 0.0, fRmax2);
546  ellipse->SetFillColor(kYellow);
547  ellipse->SetLineColor(kYellow);
548  ellipse->SetLineWidth(1);
549  ellipse->SetFillStyle(3002);
550  ellipse->Draw("f");
551  ellipse->Draw();
552  TEllipse* ellipseInner = new TEllipse(0.0, 0.0, fRmax1);
553  ellipseInner->SetFillColor(kYellow - 7);
554  ellipseInner->SetLineColor(kYellow - 7);
555  ellipseInner->SetLineWidth(1);
556  ellipseInner->SetFillStyle(3002);
557  ellipseInner->Draw("f");
558  ellipseInner->Draw();
559 #endif //USE_MUCH_ABSORBER
560  }
561 }
562 
563 #ifdef CLUSTER_MODE
564 struct KDRayWrap {
565  LxRay* ray;
566  Double_t data[4];
567  static bool destroyRays;
568 
569  KDRayWrap(Double_t x, Double_t y, LxRay* r) : ray(r) {
570  data[0] = x;
571  data[1] = y;
572  data[2] = ray->tx;
573  data[3] = ray->ty;
574  }
575 
576  KDRayWrap(Double_t x, Double_t y, Double_t tx, Double_t ty)
577  : ray(0) // This constructor is used when setting search-range bounds.
578  {
579  data[0] = x;
580  data[1] = y;
581  data[2] = tx;
582  data[3] = ty;
583  }
584 
585  ~KDRayWrap() {
586  if (destroyRays) delete ray;
587  }
588 
589  // Stuff required by libkdtree++
590  typedef Double_t value_type;
591 
592  value_type operator[](size_t n) const { return data[n]; }
593 };
594 
595 //bool KDRayWrap::destroyRays = false;
596 
597 typedef KDTree::KDTree<4, KDRayWrap> KDRaysStorageType;
598 #endif //CLUSTER_MODE
599 
600 void LxDraw::DrawRays() {
601  LxFinder* finder = LxFinder::Instance();
602  LxSpace& caSpace = finder->caSpace;
603  int stationsNumber = caSpace.stations.size();
604 
605  for (Int_t i = stationsNumber - 1; i > 0; --i) {
606  LxStation* rSt = caSpace.stations[i];
607 #ifdef CLUSTER_MODE
608  KDRaysStorageType* rays =
609  static_cast<KDRaysStorageType*>(rSt->clusteredRaysHandle);
610  Double_t lZ = caSpace.stations[i - 1]->zCoord;
611 
612  for (KDRaysStorageType::iterator j = rays->begin(); j != rays->end(); ++j) {
613  KDRayWrap& wrap = const_cast<KDRayWrap&>(*j);
614  LxRay* ray = wrap.ray;
615  LxPoint* rPo = ray->source;
616  Double_t deltaZ = lZ - rPo->z;
617  Double_t lX = rPo->x + ray->tx * deltaZ;
618  Double_t lY = rPo->y + ray->ty * deltaZ;
619 
620  YZ.cd();
621  TLine* yzLine = new TLine(rPo->z, rPo->y, lZ, lY);
622  yzLine->SetLineColor(kRed);
623  yzLine->Draw();
624 
625  XZ.cd();
626  TLine* xzLine = new TLine(rPo->z, rPo->x, lZ, lX);
627  xzLine->SetLineColor(kRed);
628  xzLine->Draw();
629 
630  YX.cd();
631  TLine* yxLine = new TLine(rPo->x, rPo->y, lX, lY);
632  yxLine->SetLineColor(kRed);
633  yxLine->Draw();
634  }
635 #else //CLUSTER_MODE
636  LxLayer* rLa = rSt->layers[0];
637  LxStation* lSt = caSpace.stations[i - 1];
638  int lLaInd = lSt->layers.size() - 1;
639  LxLayer* lLa = lSt->layers[lLaInd];
640 
641  if (rLa->points.size() == 0 || lLa->points.size() == 0) continue;
642 
643  Double_t lZ = (*lLa->points.begin())->z;
644 
645  for (list<LxPoint*>::iterator j = rLa->points.begin();
646  j != rLa->points.end();
647  ++j) {
648  LxPoint* rPo = *j;
649  Double_t deltaZ = lZ - rPo->z;
650 
651  for (list<LxRay*>::iterator k = rPo->rays.begin(); k != rPo->rays.end();
652  ++k) {
653  LxRay* ray = *k;
654 
655  Double_t lX = rPo->x + ray->tx * deltaZ;
656  Double_t lY = rPo->y + ray->ty * deltaZ;
657 
658  YZ.cd();
659  TLine* yzLine = new TLine(rPo->z, rPo->y, lZ, lY);
660  yzLine->SetLineColor(kRed);
661  yzLine->Draw();
662 
663  XZ.cd();
664  TLine* xzLine = new TLine(rPo->z, rPo->x, lZ, lX);
665  xzLine->SetLineColor(kRed);
666  xzLine->Draw();
667 
668  YX.cd();
669  TLine* yxLine = new TLine(rPo->x, rPo->y, lX, lY);
670  yxLine->SetLineColor(kRed);
671  yxLine->Draw();
672  }
673  }
674 #endif //CLUSTER_MODE
675  }
676 
677  YZ.cd();
678  YZ.Update();
679  XZ.cd();
680  XZ.Update();
681  YX.cd();
682  YX.Update();
683 }
684 
685 void LxDraw::DrawRecoTracks() {
686  LxFinder* finder = LxFinder::Instance();
687  LxSpace& caSpace = finder->caSpace;
688  int stationsNumber = caSpace.stations.size();
689 
690  for (list<LxTrack*>::iterator i = caSpace.tracks.begin();
691  i != caSpace.tracks.end();
692  ++i) {
693  LxTrack* track = *i;
694 
695 #ifdef USE_KALMAN_FIT
696  bool kalmanDrawn = false;
697 #endif //USE_KALMAN_FIT
698 
699  for (int j = 0; j < track->length; ++j) {
700  LxRay* ray = track->rays[j];
701 
702  if (0 == ray) break;
703 
704  Double_t rX = ray->source->x;
705  Double_t rY = ray->source->y;
706  Double_t rZ = ray->source->z;
707 
708  Double_t lZ = caSpace.stations[ray->station->stationNumber - 1]->zCoord;
709  Double_t deltaZ = lZ - rZ;
710  Double_t lX = rX + ray->tx * deltaZ;
711  Double_t lY = rY + ray->ty * deltaZ;
712 
713 #ifdef USE_KALMAN_FIT
714  Double_t kalmanZl = track->z;
715  Double_t kalmanXl = track->x;
716  Double_t kalmanYl = track->y;
717  Double_t kalmanZr = ray->source->z;
718  Double_t kalmanXr = kalmanXl + track->tx * (kalmanZr - kalmanZl);
719  Double_t kalmanYr = kalmanYl + track->ty * (kalmanZr - kalmanZl);
720 #endif //USE_KALMAN_FIT
721 
722  YZ.cd();
723  TLine* yzLineL = new TLine(rZ, rY, lZ, lY);
724  yzLineL->SetLineColor(kBlue);
725  yzLineL->Draw();
726 
727  if (!kalmanDrawn) {
728  TLine* kalmanYZLine = new TLine(kalmanZr, kalmanYr, kalmanZl, kalmanYl);
729  kalmanYZLine->SetLineColor(kBlack);
730  kalmanYZLine->Draw();
731  }
732 
733  XZ.cd();
734  TLine* xzLineL = new TLine(rZ, rX, lZ, lX);
735  xzLineL->SetLineColor(kBlue);
736  xzLineL->Draw();
737 
738  if (!kalmanDrawn) {
739  TLine* kalmanXZLine = new TLine(kalmanZr, kalmanXr, kalmanZl, kalmanXl);
740  kalmanXZLine->SetLineColor(kBlack);
741  kalmanXZLine->Draw();
742  }
743 
744  YX.cd();
745  TLine* yxLineL = new TLine(rX, rY, lX, lY);
746  yxLineL->SetLineColor(kBlue);
747  yxLineL->Draw();
748 
749  if (!kalmanDrawn) {
750  TLine* kalmanYXLine = new TLine(kalmanXr, kalmanYr, kalmanXl, kalmanYl);
751  kalmanYXLine->SetLineColor(kBlack);
752  kalmanYXLine->Draw();
753  }
754 
755 #ifdef USE_KALMAN_FIT
756  kalmanDrawn = true;
757 #endif //USE_KALMAN_FIT
758  }
759 
760  // Draw a segment of an external track if it is set.
761 
762  //if (track->externalTrack)
763  if (false) {
764  Double_t rZ = caSpace.stations[0]->layers[0]->zCoord;
765  const FairTrackParam* param = track->externalTrack->track->GetParamLast();
766 
767  Double_t lX = param->GetX();
768  Double_t lY = param->GetY();
769  Double_t lZ = param->GetZ();
770  Double_t deltaZ = rZ - lZ;
771  Double_t rX = lX + param->GetTx() * deltaZ;
772  Double_t rY = lY + param->GetTy() * deltaZ;
773 
774  YZ.cd();
775  TLine* yzLine = new TLine(lZ, lY, rZ, rY);
776  yzLine->SetLineColor(kPink);
777  yzLine->Draw();
778 
779  XZ.cd();
780  TLine* xzLine = new TLine(lZ, lX, rZ, rX);
781  xzLine->SetLineColor(kPink);
782  xzLine->Draw();
783 
784  YX.cd();
785  TLine* yxLine = new TLine(lX, lY, rX, rY);
786  yxLine->SetLineColor(kPink);
787  yxLine->Draw();
788  }
789  }
790 
791  YZ.cd();
792  YZ.Update();
793  XZ.cd();
794  XZ.Update();
795  YX.cd();
796  YX.Update();
797 }
798 
799 void LxDraw::DrawMCPoints() {
800  int mcolour = 2;
801  int hitsMStyle = 2;
802  double HitSize = 1;
803  LxFinder* finder = LxFinder::Instance();
804 
805  int nhits = finder->MCPoints.size();
806  Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
807  TVector3 pos;
808  int n_poly = 0;
809 
810  for (vector<LxMCPoint>::iterator i = finder->MCPoints.begin();
811  i != finder->MCPoints.end();
812  ++i) {
813  LxMCPoint& point = *i;
814 
815  x_poly[n_poly] = point.x;
816  y_poly[n_poly] = point.y;
817  z_poly[n_poly] = point.z;
818 
819  ++n_poly;
820  }
821 
822  YZ.cd();
823 
824  TPolyMarker* pmyz = new TPolyMarker(n_poly, z_poly, y_poly);
825  pmyz->SetMarkerColor(mcolour);
826  pmyz->SetMarkerStyle(hitsMStyle);
827  pmyz->SetMarkerSize(HitSize);
828  pmyz->Draw();
829  YZ.Update();
830 
831  XZ.cd();
832 
833  TPolyMarker* pmxz = new TPolyMarker(n_poly, z_poly, x_poly);
834  pmxz->SetMarkerColor(mcolour);
835  pmxz->SetMarkerStyle(hitsMStyle);
836  pmxz->SetMarkerSize(HitSize);
837  pmxz->Draw();
838  XZ.Update();
839 
840  YX.cd();
841 
842  TPolyMarker* pmyx = new TPolyMarker(n_poly, x_poly, y_poly);
843  pmyx->SetMarkerColor(mcolour);
844  pmyx->SetMarkerStyle(hitsMStyle);
845  pmyx->SetMarkerSize(HitSize);
846  pmyx->Draw();
847  YX.Update();
848 }
849 
850 void LxDraw::DrawExtTracks() {
851  LxFinder* finder = LxFinder::Instance();
852  LxSpace& caSpace = finder->caSpace;
853  Double_t rZ = caSpace.stations[0]->layers[0]->zCoord;
854 
855  for (list<LxExtTrack>::iterator i = caSpace.extTracks.begin();
856  i != caSpace.extTracks.end();
857  ++i) {
858  LxExtTrack& extTrack = *i;
859  const FairTrackParam* param = extTrack.track->GetParamLast();
860 
861  Double_t lX = param->GetX();
862  Double_t lY = param->GetY();
863  Double_t lZ = param->GetZ();
864  Double_t deltaZ = rZ - lZ;
865  Double_t rX = lX + param->GetTx() * deltaZ;
866  Double_t rY = lY + param->GetTy() * deltaZ;
867 
868  YZ.cd();
869  TLine* yzLine = new TLine(lZ, lY, rZ, rY);
870  yzLine->SetLineColor(kPink);
871  yzLine->Draw();
872 
873  XZ.cd();
874  TLine* xzLine = new TLine(lZ, lX, rZ, rX);
875  xzLine->SetLineColor(kPink);
876  xzLine->Draw();
877 
878  YX.cd();
879  TLine* yxLine = new TLine(lX, lY, rX, rY);
880  yxLine->SetLineColor(kPink);
881  yxLine->Draw();
882  }
883 
884  YZ.cd();
885  YZ.Update();
886  XZ.cd();
887  XZ.Update();
888  YX.cd();
889  YX.Update();
890 }
891 
892 void LxDraw::SaveCanvas(TString name) {
893  system("mkdir LxDraw -p");
894  chdir("LxDraw");
895  TString tmp = name;
896  tmp += "YXView.pdf";
897  YX.cd();
898  YX.SaveAs(tmp);
899 
900  tmp = name;
901  tmp += "XZView.pdf";
902  XZ.cd();
903  XZ.SaveAs(tmp);
904 
905  tmp = name;
906  tmp += "YZView.pdf";
907  YZ.cd();
908  YZ.SaveAs(tmp);
909 
910  chdir("..");
911 }
912 
913 #endif //LXDRAW
LxFinder
Definition: Simple/Lx.h:73
LxTrack
Definition: LxCA.h:268
LxMCPoint
Definition: Simple/LxMC.h:16
LxStation::layers
std::vector< LxLayer * > layers
Definition: LxCA.h:190
LxMCTrack::stationsWithHits
Int_t stationsWithHits
Definition: Simple/LxMC.h:37
LxPoint::artificial
bool artificial
Definition: LxCA.h:57
CbmTrack::GetParamLast
const FairTrackParam * GetParamLast() const
Definition: CbmTrack.h:62
LxDraw::YZ
TCanvas YZ
Definition: Simple/LxDraw.h:25
CbmKF.h
LxMCTrack::q
scaltype q
Definition: Simple/LxMC.h:28
LxDraw::DrawMCTracks
void DrawMCTracks()
Definition: Simple/LxDraw.cxx:78
LxMCPoint::p
scaltype p
Definition: Simple/LxMC.h:17
LxMCTrack::layersWithHits
Int_t layersWithHits
Definition: Simple/LxMC.h:38
CbmKF::Propagate
Int_t Propagate(Double_t *T, Double_t *C, Double_t z_out, Double_t QP0)
Definition: CbmKF.cxx:554
LxTrack::length
int length
Definition: LxCA.h:280
LxMCPoint::x
scaltype x
Definition: Simple/LxMC.h:17
LxDraw::DrawMCPoints
void DrawMCPoints()
Definition: Simple/LxDraw.cxx:833
LxSpace::tracks
std::list< LxTrack * > tracks
Definition: LxCA.h:326
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
LxMCTrack::p
scaltype p
Definition: Simple/LxMC.h:28
LxDraw::DrawExtTracks
void DrawExtTracks()
Definition: Simple/LxDraw.cxx:884
LxFinder::MCTracks
std::vector< LxMCTrack > MCTracks
Definition: Simple/Lx.h:204
LxTrack::rays
LxRay * rays[LXSTATIONS - 1]
Definition: LxCA.h:281
LxMCPoint::z
scaltype z
Definition: Simple/LxMC.h:17
LxDraw::YX
TCanvas YX
Definition: Simple/LxDraw.h:26
LxFinder::MCPoints
std::vector< LxMCPoint > MCPoints
Definition: Simple/Lx.h:202
LxMCPoint::py
scaltype py
Definition: Simple/LxMC.h:17
LxRay::station
LxStation * station
Definition: LxCA.h:120
LxMCTrack::Points
std::vector< LxMCPoint * > Points
Definition: Simple/LxMC.h:31
LxSpace::extTracks
std::list< LxExtTrack > extTracks
Definition: LxCA.h:327
LxMCPoint::layerNumber
Int_t layerNumber
Definition: Simple/LxMC.h:18
LxDraw::DrawRecoTracks
void DrawRecoTracks()
Definition: Simple/LxDraw.cxx:713
LXLAYERS
#define LXLAYERS
Definition: Simple/LxSettings.h:8
caSpace
LxSpace caSpace
Definition: riplet/Lx.cxx:72
LxMCPoint::px
scaltype px
Definition: Simple/LxMC.h:17
LxPoint::y
scaltype y
Definition: LxCA.h:53
LxSpace
Definition: LxCA.h:309
LxStation::stationNumber
int stationNumber
Definition: LxCA.h:206
LxMCTrack::y
scaltype y
Definition: Simple/LxMC.h:28
LxPoint
Definition: LxCA.h:52
LxExtTrack
Definition: LxCA.h:249
CbmKF::Instance
static CbmKF * Instance()
Definition: CbmKF.h:39
LxDraw::XZ
TCanvas XZ
Definition: Simple/LxDraw.h:27
LxMCPoint::stationNumber
Int_t stationNumber
Definition: Simple/LxMC.h:18
LxLayer::points
std::list< LxPoint * > points
Definition: LxCA.h:153
LxRay::ty
scaltype ty
Definition: LxCA.h:116
LxPoint::rays
std::list< LxRay * > rays
Definition: LxCA.h:59
LxRay::tx
scaltype tx
Definition: LxCA.h:116
LxPoint::z
scaltype z
Definition: LxCA.h:53
LxSpace::stations
std::vector< LxStation * > stations
Definition: LxCA.h:325
LxFinder::Instance
static LxFinder * Instance()
Definition: Simple/Lx.cxx:249
LxMCTrack::px
scaltype px
Definition: Simple/LxMC.h:28
LxDraw::Ask
void Ask()
Definition: Simple/LxDraw.cxx:60
LxMCTrack::z
scaltype z
Definition: Simple/LxMC.h:28
LxDraw::LxDraw
LxDraw()
Definition: Simple/LxDraw.cxx:32
LxFinder::caSpace
LxSpace caSpace
Definition: Simple/Lx.h:211
LxExtTrack::track
CbmStsTrack * track
Definition: LxCA.h:250
LxMCTrack::x
scaltype x
Definition: Simple/LxMC.h:28
LxMCTrack::hitsOnStations
bool hitsOnStations[LXSTATIONS][LXLAYERS]
Definition: Simple/LxMC.h:39
LxPoint::valid
bool valid
Definition: LxCA.h:56
LxMCTrack::pz
scaltype pz
Definition: Simple/LxMC.h:28
LxDraw::SaveCanvas
void SaveCanvas(TString name)
Definition: Simple/LxDraw.cxx:926
LxStation
Definition: LxCA.h:189
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
LxRay::source
LxPoint * source
Definition: LxCA.h:118
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
LxDraw::ClearView
void ClearView()
Definition: Simple/LxDraw.cxx:54
LxDraw::DrawMuch
void DrawMuch()
Definition: Simple/LxDraw.cxx:517
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
LxMCPoint::pz
scaltype pz
Definition: Simple/LxMC.h:17
LxMCPoint::q
scaltype q
Definition: Simple/LxMC.h:17
LxMCTrack
Definition: Simple/LxMC.h:27
LxDraw::ask
bool ask
Definition: Simple/LxDraw.h:28
LxDraw::DrawRays
void DrawRays()
Definition: Simple/LxDraw.cxx:628
LXSTATIONS
#define LXSTATIONS
Definition: Simple/LxSettings.h:9
LxLayer
Definition: LxCA.h:152
LxDraw::DrawInputHits
void DrawInputHits()
Definition: Simple/LxDraw.cxx:303
LxMCPoint::y
scaltype y
Definition: Simple/LxMC.h:17
StaColour
static int StaColour
Definition: Simple/LxDraw.cxx:30
LxPoint::x
scaltype x
Definition: LxCA.h:53
LxMCTrack::mother_ID
Int_t mother_ID
Definition: Simple/LxMC.h:29
LxMCTrack::py
scaltype py
Definition: Simple/LxMC.h:28
operator[]
float & operator[](int i)
Definition: L1/vectors/P4_F32vec4.h:3
LxRay
Definition: LxCA.h:115
LxTrack::externalTrack
LxExtTrack * externalTrack
Definition: LxCA.h:269