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