CbmRoot
L1AlgoDraw.h
Go to the documentation of this file.
1 #ifndef L1AlgoDraw_h
2 #define L1AlgoDraw_h 1
3 
4 #define DRAW
5 
6 #include "CbmKF.h"
7 #include "CbmL1.h"
8 #include "L1Algo/L1Algo.h"
9 
10 #include "TApplication.h"
11 #include "TCanvas.h"
12 #include "TEllipse.h"
13 #include "TFrame.h"
14 #include "TLatex.h"
15 #include "TMarker.h"
16 #include "TPad.h"
17 #include "TPaveText.h"
18 #include "TPolyLine.h"
19 #include "TPolyLine3D.h"
20 #include "TPolyMarker.h"
21 #include "TStyle.h"
22 #include "TText.h"
23 #include "TView3D.h"
24 
25 // #include <unistd.h> // for dir navigation
26 
27 //static TApplication *myapp;
28 
29 class L1AlgoDraw {
30  struct Point {
31  double x, y, z;
32  Point() {};
33  Point(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {};
34  };
35 
36 public:
37  L1AlgoDraw();
38  void InitL1Draw(L1Algo* algo_);
39 
40  void DrawMCTracks();
41  void DrawRecoTracks();
42 
43  void DrawTriplets(vector<L1Triplet>& triplets, const THitI* realIHit);
44  void DrawDoublets(vector<THitI>* Duplets_hits,
45  map<THitI, THitI>* Duplets_start,
46  const int MaxArrSize,
48  unsigned int* realIHit);
49  void DrawDoubletsOnSta(int iSta,
50  THitI* Duplets_hits,
51  THitI* Duplets_start,
52  const int MaxArrSize,
53  THitI* StsRestHitsStartIndex,
54  unsigned int* realIHit);
55 
56  void DrawTarget();
57  void DrawInputHits(); // draw all hits, which TF have gotten
58  void
59  DrawRestHits(THitI* StsRestHitsStartIndex,
60  THitI* StsRestHitsStopIndex,
61  unsigned int*
62  realIHit); // draw only hits which leave on current iteration.
63 
64  void DrawInfo();
65  void ClearVeiw();
66  void SaveCanvas(TString name);
67  void DrawAsk();
68 
69 private:
70  Point GetHitCoor(int ih);
71 
72  void DrawTriplet(int il, int im, int ir);
73  void DrawDoublet(int il, int ir);
74 
75 
77 
78  vector<fscal> vStsStrips, vStsStripsB;
79  vector<L1StsHit> vStsHits;
81 
82  int NStations;
84 
85  int mcolor[10]; // color for hits on i-station
86  int StaColor; // color for stantions
87  int hitsMStyle; // style for hits
88  int fakesMStyle; // style for fakes
89  int targetMStyle; // style for target
90 
91  double HitSize; // size of hits
92 
93  int fVerbose;
94  /*static*/ TCanvas *YZ, *YX, *XZ, *XYZ;
95  bool ask;
96 };
97 
99 
100  int tmp[10] = {5, 7, 3, 8, 6, 2, 4, 1, 9, 14}; // color for hits on i-station
101  for (int i = 0; i < 10; i++) {
102  mcolor[i] = tmp[i];
103  }
104  StaColor = 17;
105  hitsMStyle = 20;
106  fakesMStyle = 24;
107  targetMStyle = 29;
108 
109  HitSize = 1;
110 
111  gStyle->SetCanvasBorderMode(0);
112  gStyle->SetCanvasBorderSize(1);
113  gStyle->SetCanvasColor(0);
114 
115  YZ = new TCanvas("YZ", "YZ Side View", -1, 0, 500, 500);
116  YZ->Range(-5.0, -50.0, 105.0, 50.0);
117  YZ->Draw();
118  YZ->Update();
119 
120  XZ = new TCanvas("XZ", "XZ Top View", -1, 500, 500, 500);
121  XZ->Range(-5.0, -50.0, 105.0, 50.0);
122  XZ->Draw();
123  XZ->Update();
124 
125  YX = new TCanvas("YX", "YX Front View", -506, 0, 500, 500);
126  YX->Range(-50.0, -50.0, 50.0, 50.0);
127  YX->Draw();
128  YX->Update();
129 
130  // XYZ = new TCanvas ("XYZ", "XYZ 3D View", -0, 0, 1000, 1000);
131  XYZ = new TCanvas("XYZ", "XYZ 3D View", -500, 500, 500, 500);
132  XYZ->Range(-5.0, -50.0, 115.0, 60.0);
133  // TView3D *view = (TView3D*) XYZ->GetView3D();
134  // view = (TView3D*) TView::CreateView(1);
135  // TView3D *view = new TView3D();
136  // view->SetRange(-50.0, -50.0, -0.0, 50.0, 50.0, 110.0);
137  // view->SetRange(0,0,0,4,4,4);
138  // view->Draw();
139  // XYZ->ResetView3D(view);
140  XYZ->Draw();
141  XYZ->Update();
142 
143  fVerbose = CbmL1::Instance()->fVerbose;
144  ask = true;
145 }
146 
148  // algo = CbmL1::Instance()->algo;
149  algo = algo_;
150  vStsStrips.resize(algo->vStsStrips.size());
151  for (int i = 0; i < algo->vStsStrips.size(); i++) {
153  }
154  vStsStripsB.resize(algo->vStsStripsB.size());
155  for (int i = 0; i < algo->vStsStripsB.size(); i++) {
157  }
158  vStsHits.resize(algo->vStsHits.size());
159  for (int i = 0; i < algo->vStsHits.size(); i++) {
160  vStsHits[i] = algo->vStsHits[i];
161  }
163  for (int i = 0; i < NStations; i++) {
166  vStations[i] = algo->vStations[i];
167  }
168 }
169 
171  int NRegMCTracks = 0;
172  CbmL1& L1 = *CbmL1::Instance();
173  TPolyLine pline;
174  if (fVerbose >= 10) {
175  cout << "Only reconstructable tracks are shown." << endl;
176  cout << "Red - primary p > 0.5 - (first iteration)" << endl;
177  cout << "Blue - primary p < 0.5 - (second iteration)" << endl;
178  cout << "Green - secondary p > 0.5 - (third\\first iteration)" << endl;
179  cout << "Gray - secondary p < 0.5 - (third\\second iteration)" << endl;
180  };
181 
182  for (vector<CbmL1MCTrack>::iterator it = L1.vMCTracks.begin();
183  it != L1.vMCTracks.end();
184  ++it) {
185  CbmL1MCTrack& T = *it;
186  //draw reconstructable tracks only
187  if (!T.IsReconstructable()) continue;
188  //if (( T.mother_ID< 0 )&&( T.nContStations<3 )) continue;
189  //if (( T.mother_ID>=0 )&&( T.nContStations<4 )) continue;
190  //if( T.p<.2 ) continue;
191  if (T.p < 0.1) continue;
192  pline.SetLineColor(kRed);
193  if (T.p < 0.5) pline.SetLineColor(kBlue);
194  if (T.mother_ID != -1) pline.SetLineColor(8);
195  if ((T.mother_ID != -1) && (T.p < 0.5)) pline.SetLineColor(12);
196  if (fVerbose >= 1)
197  cout << "MC Track: p = " << T.p << " mother_ID = " << T.mother_ID
198  << " PDG = " << T.pdg << " x,y,z = (" << T.x << ", " << T.y << ", "
199  << T.z << ")" << endl;
200  double par[6];
201  par[0] = T.x;
202  par[1] = T.y;
203  //if( fabs(T.pz)<0.1 ) continue;
204  par[2] = T.px / T.pz;
205  par[3] = T.py / T.pz;
206  par[4] = T.q / T.p;
207  par[5] = T.z;
208 
209  int npoints = T.Points.size();
210  if (fVerbose >= 10) cout << " NMCPoints = " << npoints << endl;
211  if (npoints < 1) continue;
212 
213  vector<double> lx, ly, lz;
214  lx.push_back(par[0]);
215  ly.push_back(par[1]);
216  lz.push_back(par[5]);
217 
218  bool ok = true;
219 
220  if (fVerbose >= 4) {
221  cout << "hits = ";
222  for (int ih = 0; ih < T.StsHits.size(); ih++)
223  cout << T.StsHits[ih] << " ";
224  cout << endl;
225  }
226  for (int ip = 0; ip < npoints; ip++) {
227  CbmL1MCPoint& p = L1.vMCPoints[T.Points[ip]];
228  double par1[6];
229  //if( fabs(p.pz)<0.05 ) continue;
230  par1[0] = p.x;
231  par1[1] = p.y;
232  par1[2] = p.px / p.pz;
233  par1[3] = p.py / p.pz;
234  par1[4] = p.q / p.p;
235  par1[5] = p.z;
236  if (fVerbose >= 5) {
237  static float pz = -1;
238  if (fabs(pz - p.z) > 1.0) cout << "-- ";
239  cout << "point.z = " << p.z << endl;
240  pz = p.z;
241  }
242 
243  double Zfrst = par[5];
244  double Zlast = par1[5];
245  double step = .5;
246  if (step > fabs(Zfrst - Zlast) / 5) step = fabs(Zfrst - Zlast) / 5;
247  if (Zlast < par[5]) step = -step;
248  while (fabs(par[5] - Zlast) > fabs(step)) {
249  double znxt = par[5] + step;
250  CbmKF::Instance()->Propagate(par1, 0, znxt, par1[4]);
251  CbmKF::Instance()->Propagate(par, 0, znxt, par[4]);
252  double w = fabs(znxt - Zfrst);
253  double w1 = fabs(znxt - Zlast);
254  if (w + w1 < 1.e-3) {
255  w = 1;
256  w1 = 0;
257  }
258  float xl = (w1 * par[0] + w * par1[0]) / (w + w1);
259  float yl = (w1 * par[1] + w * par1[1]) / (w + w1);
260  float zl = (w1 * par[5] + w * par1[5]) / (w + w1);
261  if ((fabs(xl) > 50.0) || (fabs(yl) > 50.0)) {
262  //cout << "*** track " << NRegMCTracks+1 << " xl = " << xl << ", zl = " << zl << endl;
263  //cout << "*** track " << NRegMCTracks+1 << " yl = " << yl << ", zl = " << zl << endl;
264  ok = false;
265  continue;
266  }
267  lx.push_back((w1 * par[0] + w * par1[0]) / (w + w1));
268  ly.push_back((w1 * par[1] + w * par1[1]) / (w + w1));
269  lz.push_back((w1 * par[5] + w * par1[5]) / (w + w1));
270  }
271 
272  par[0] = p.x;
273  par[1] = p.y;
274  par[2] = p.px / p.pz;
275  par[3] = p.py / p.pz;
276  par[4] = p.q / p.p;
277  par[5] = p.z;
278  lx.push_back(par[0]);
279  ly.push_back(par[1]);
280  lz.push_back(par[5]);
281  }
282 
283  if (ok) {
284 
285  NRegMCTracks++;
286 
287  YZ->cd();
288  pline.DrawPolyLine(lx.size(), &(lz[0]), &(ly[0]));
289  XZ->cd();
290  pline.DrawPolyLine(lx.size(), &(lz[0]), &(lx[0]));
291  YX->cd();
292  pline.DrawPolyLine(lx.size(), &(lx[0]), &(ly[0]));
293 
294  // YZ->cd(); YZ->Update();
295  // XZ->cd(); XZ->Update();
296  // YX->cd(); YX->Update();
297  // DrawAsk();
298  }
299  }
300 
301  cout << "L1CADraw: number of registered MC tracks: " << NRegMCTracks << endl;
302 
303  YZ->cd();
304  YZ->Update();
305  XZ->cd();
306  XZ->Update();
307  YX->cd();
308  YX->Update();
309 }
310 
312  // XYZ->cd();
313  // TView *view = TView::CreateView(1);
314  // view->SetRange(-100,-100,-100, 100, 100, 100);
315 
316  int NRecTracks = 0;
317  // CbmL1 &L1 = *CbmL1::Instance();
318 
319  int curRecoHit = 0;
320  vector<THitI>& recoHits = algo->vRecoHits;
321  for (vector<L1Track>::iterator it = algo->vTracks.begin();
322  it != algo->vTracks.end();
323  ++it) {
324  L1Track& T = *it;
325  int nHits = T.NHits;
326  // if (nHits > 5) continue; // draw clones
327  // YZ->cd(); YZ->Update();
328  // XZ->cd(); XZ->Update();
329  // YX->cd(); YX->Update();
330  // DrawAsk();
331  vector<double> lx, ly, lz;
332  vector<double> lx_turned, ly_turned, lz_turned;
333 
334  TPolyLine pline;
335  pline.SetLineColor(kBlue);
336  // TPolyLine3D pline3D(nHits);
337  // pline3D.SetLineColor(kBlue);
338  if (fVerbose >= 4) { cout << "hits = "; }
339  for (int iHit = 0; iHit < nHits; iHit++) {
340  unsigned int ih = recoHits[curRecoHit++];
341  if (fVerbose >= 4) { cout << ih << " "; }
342 
343  Point p = GetHitCoor(ih);
344  lx.push_back(p.x);
345  ly.push_back(p.y);
346  lz.push_back(p.z);
347 
348  TVector3 v3(p.x, p.y, p.z);
349  v3.RotateX(TMath::Pi() / 5);
350  v3.RotateY(TMath::Pi() / 20);
351  v3.RotateZ(TMath::Pi() / 100);
352  lx_turned.push_back(v3.x());
353  ly_turned.push_back(v3.y());
354  lz_turned.push_back(v3.z());
355  // pline3D.SetPoint(iHit, p.x, p.y, p.z);
356  }
357  if (fVerbose >= 4) { cout << endl; }
358  if (1) {
359 
360  NRecTracks++;
361 
362  YZ->cd();
363  pline.DrawPolyLine(lx.size(), &(lz[0]), &(ly[0]));
364  XZ->cd();
365  pline.DrawPolyLine(lx.size(), &(lz[0]), &(lx[0]));
366  YX->cd();
367  pline.DrawPolyLine(lx.size(), &(lx[0]), &(ly[0]));
368  XYZ->cd();
369  pline.DrawPolyLine(lx_turned.size(), &(lz_turned[0]), &(lx_turned[0]));
370  // pline3D.Draw();
371  }
372  }
373 
374  cout << "L1CADraw: number of reconstructed tracks: " << NRecTracks << endl;
375 
376  YZ->cd();
377  YZ->Update();
378  XZ->cd();
379  XZ->Update();
380  YX->cd();
381  YX->Update();
382 
383  XYZ->cd();
384  XYZ->Update();
385 }
386 
387 void L1AlgoDraw::DrawTriplets(vector<L1Triplet>& triplets,
388  const THitI* realIHit) {
389  // vector <L1Triplet> triplets = algo->vTriplets;
390  for (int iTrip = 0; iTrip < triplets.size(); iTrip++) {
391  L1Triplet& trip = triplets[iTrip];
392 
393  unsigned int iLHit = trip.GetLHit();
394  iLHit = realIHit[iLHit];
395  unsigned int iMHit = trip.GetMHit();
396  iMHit = realIHit[iMHit];
397  unsigned int iRHit = trip.GetRHit();
398  iRHit = realIHit[iRHit];
399 
400  DrawTriplet(iLHit, iMHit, iRHit);
401  }
402 
403  YZ->cd();
404  YZ->Update();
405  XZ->cd();
406  XZ->Update();
407  YX->cd();
408  YX->Update();
409 };
410 
411 void L1AlgoDraw::DrawTriplet(int il, int im, int ir) {
412  TPolyLine pline;
413  pline.SetLineColor(kBlack);
414  TMarker marker;
415  marker.SetMarkerColor(kBlack);
416  marker.SetMarkerStyle(26);
417  marker.SetMarkerSize(HitSize * 2);
418 
419  vector<double> lx, ly, lz;
420 
421  Point coor;
422 
423  coor = GetHitCoor(il);
424  lx.push_back(coor.x);
425  ly.push_back(coor.y);
426  lz.push_back(coor.z);
427 
428  coor = GetHitCoor(im);
429  lx.push_back(coor.x);
430  ly.push_back(coor.y);
431  lz.push_back(coor.z);
432 
433  coor = GetHitCoor(ir);
434  lx.push_back(coor.x);
435  ly.push_back(coor.y);
436  lz.push_back(coor.z);
437 
438  const int nHits = 3;
439  YZ->cd();
440  pline.DrawPolyLine(nHits, &(lz[0]), &(ly[0]));
441  marker.DrawMarker(lz[nHits - 1], ly[nHits - 1]);
442  XZ->cd();
443  pline.DrawPolyLine(nHits, &(lz[0]), &(lx[0]));
444  marker.DrawMarker(lz[nHits - 1], lx[nHits - 1]);
445  YX->cd();
446  pline.DrawPolyLine(nHits, &(lx[0]), &(ly[0]));
447  marker.DrawMarker(lx[nHits - 1], ly[nHits - 1]);
448 }
449 
450 void L1AlgoDraw::DrawDoublets(vector<THitI>* Duplets_hits,
451  map<THitI, THitI>* Duplets_start,
452  const int MaxArrSize,
453  THitI* StsRestHitsStartIndex,
454  unsigned int* realIHit) {
455  for (int iSta = 0; iSta < NStations - 1; iSta++) {
456  const int firstHitOnSta = StsRestHitsStartIndex[iSta];
457  const int firstHitOnNextSta = StsRestHitsStartIndex[iSta + 1];
458  THitI* staDupletsHits = &(Duplets_hits[iSta][0]);
459  map<THitI, THitI>& staDupletsStart = Duplets_start[iSta];
460 
461  for (int iRestLHit = firstHitOnSta; iRestLHit < firstHitOnNextSta;
462  iRestLHit++) {
463  const int ilh = iRestLHit - firstHitOnSta;
464  const int iirhFirst = staDupletsStart[ilh];
465  const int iirhLast = staDupletsStart[ilh + 1] - 1;
466 
467  for (int iirh = iirhFirst; iirh <= iirhLast; iirh++) {
468  const int iRestRHit = staDupletsHits[iirh] + firstHitOnNextSta;
469 
470  const int iLHit = realIHit[iRestLHit];
471  const int iRHit = realIHit[iRestRHit];
472 
473  DrawDoublet(iLHit, iRHit);
474  }
475  }
476  }
477 
478  YZ->cd();
479  YZ->Update();
480  XZ->cd();
481  XZ->Update();
482  YX->cd();
483  YX->Update();
484 };
485 
487  THitI* Duplets_hits,
488  THitI* Duplets_start,
489  const int MaxArrSize,
490  THitI* StsRestHitsStartIndex,
491  unsigned int* realIHit) {
492  const int firstHitOnSta = StsRestHitsStartIndex[iSta];
493  const int firstHitOnNextSta = StsRestHitsStartIndex[iSta + 1];
494  THitI* staDupletsHits = Duplets_hits + MaxArrSize * iSta;
495  THitI* staDupletsStart = Duplets_start + MaxArrSize * iSta;
496 
497  for (int iRestLHit = firstHitOnSta; iRestLHit < firstHitOnNextSta;
498  iRestLHit++) {
499  const int ilh = iRestLHit - firstHitOnSta;
500  const int iirhFirst = staDupletsStart[ilh];
501  const int iirhLast = staDupletsStart[ilh + 1] - 1;
502 
503  for (int iirh = iirhFirst; iirh <= iirhLast; iirh++) {
504  const int iRestRHit = staDupletsHits[iirh] + firstHitOnNextSta;
505 
506  const int iLHit = realIHit[iRestLHit];
507  const int iRHit = realIHit[iRestRHit];
508 
509  DrawDoublet(iLHit, iRHit);
510  }
511  }
512 
513  YZ->cd();
514  YZ->Update();
515  XZ->cd();
516  XZ->Update();
517  YX->cd();
518  YX->Update();
519 };
520 
521 void L1AlgoDraw::DrawDoublet(int il, int ir) {
522  TPolyLine pline;
523  pline.SetLineColor(kBlue);
524  TMarker marker;
525  marker.SetMarkerColor(kBlue);
526  marker.SetMarkerStyle(27);
527  marker.SetMarkerSize(HitSize * 2);
528 
529  vector<double> lx, ly, lz;
530 
531  Point coor;
532 
533  coor = GetHitCoor(il);
534  lx.push_back(coor.x);
535  ly.push_back(coor.y);
536  lz.push_back(coor.z);
537 
538  coor = GetHitCoor(ir);
539  lx.push_back(coor.x);
540  ly.push_back(coor.y);
541  lz.push_back(coor.z);
542 
543  const int nHits = 2;
544  YZ->cd();
545  pline.DrawPolyLine(nHits, &(lz[0]), &(ly[0]));
546  marker.DrawMarker(lz[nHits - 1], ly[nHits - 1]);
547  XZ->cd();
548  pline.DrawPolyLine(nHits, &(lz[0]), &(lx[0]));
549  marker.DrawMarker(lz[nHits - 1], lx[nHits - 1]);
550  YX->cd();
551  pline.DrawPolyLine(nHits, &(lx[0]), &(ly[0]));
552  marker.DrawMarker(lx[nHits - 1], ly[nHits - 1]);
553 }
554 
555 
557  cout << " vStsHits.size = " << algo->vStsHits.size() << endl;
558  cout << " vRecoHits.size = " << algo->vRecoHits.size() << endl;
559  cout << " vTracks.size = " << algo->vTracks.size() << endl;
560 }
561 
563 
564  float x = 0, y = 0, z = 0;
565  float x_t, z_t;
566 
567  TVector3 v3(x, y, z);
568  v3.RotateX(TMath::Pi() / 5);
569  v3.RotateY(TMath::Pi() / 20);
570  v3.RotateZ(TMath::Pi() / 100);
571  x_t = v3.x();
572  z_t = v3.z();
573 
574  {
575  YZ->cd();
576 
577  TMarker* marker = new TMarker(z, y, targetMStyle);
578  marker->SetMarkerColor(kRed);
579  marker->SetMarkerStyle(targetMStyle);
580  marker->SetMarkerSize(HitSize);
581  marker->Draw();
582  }
583 
584  {
585  XZ->cd();
586 
587  TMarker* marker = new TMarker(z, x, targetMStyle);
588  marker->SetMarkerColor(kRed);
589  marker->SetMarkerStyle(targetMStyle);
590  marker->SetMarkerSize(HitSize);
591  marker->Draw();
592  }
593 
594  {
595  YX->cd();
596 
597  TMarker* marker = new TMarker(x, y, targetMStyle);
598  marker->SetMarkerColor(kRed);
599  marker->SetMarkerStyle(targetMStyle);
600  marker->SetMarkerSize(HitSize);
601  marker->Draw();
602  }
603 
604  {
605  XYZ->cd();
606 
607  TMarker* marker = new TMarker(z_t, x_t, targetMStyle);
608  marker->SetMarkerColor(kRed);
609  marker->SetMarkerStyle(targetMStyle);
610  marker->SetMarkerSize(HitSize);
611  marker->Draw();
612  }
613 }
614 
616 
617  TLatex latex;
618  latex.SetTextFont(132);
619  latex.SetTextAlign(12);
620  latex.SetTextSize(0.035);
621 
622  YZ->cd();
623  latex.DrawLatex(0.0, 45.0, "YZ Side View");
624  YZ->Draw();
625  XZ->cd();
626  latex.DrawLatex(0.0, 45.0, "XZ Top View");
627  XZ->Draw();
628  YX->cd();
629  latex.DrawLatex(-45.0, 45.0, "YX Front View");
630  YX->Draw();
631 
632 
633  int nhits = vStsHits.size();
634  Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
635  Double_t x_poly_fake[nhits], y_poly_fake[nhits], z_poly_fake[nhits];
636  Double_t x_poly_turned[nhits], z_poly_turned[nhits];
637  Double_t x_poly_fake_turned[nhits], z_poly_fake_turned[nhits];
638 
639 
640  for (int ista = NStations - 1; ista >= 0;
641  ista--) { // //start downstream chambers
642  L1Station& st = vStations[ista];
643  Int_t n_poly = 0;
644  Int_t n_poly_fake = 0;
645  for (int ih = StsHitsStartIndex[ista]; ih < StsHitsStopIndex[ista]; ih++) {
646  L1StsHit& h = vStsHits[ih];
647  int iMC = CbmL1::Instance()->vHitMCRef[ih];
648  //if( (vSFlag[h.f] | vSFlagB[h.b] )&0x02 ) continue; // if used
649 
650  float x, y, z;
651  float x_t, z_t;
652  algo->GetHitCoor(h, x, y, z, st);
653 
654  TVector3 v3(x, y, z);
655  v3.RotateX(TMath::Pi() / 5);
656  v3.RotateY(TMath::Pi() / 20);
657  v3.RotateZ(TMath::Pi() / 100);
658  x_t = v3.x();
659  z_t = v3.z();
660 
661  if (iMC >= 0) {
662  x_poly[n_poly] = x;
663  y_poly[n_poly] = y;
664  z_poly[n_poly] = z;
665  x_poly_turned[n_poly] = x_t;
666  z_poly_turned[n_poly] = z_t;
667  n_poly++;
668  } else {
669  x_poly_fake[n_poly_fake] = x;
670  y_poly_fake[n_poly_fake] = y;
671  z_poly_fake[n_poly_fake] = z;
672  x_poly_fake_turned[n_poly_fake] = x_t;
673  z_poly_fake_turned[n_poly_fake] = z_t;
674  n_poly_fake++;
675  }
676  }
677 
678  YZ->cd();
679 
680  TLine* line = new TLine();
681  line->SetLineColor(StaColor);
682  line->DrawLine(st.z[0], -st.Rmax[0], st.z[0], st.Rmax[0]);
683 
684  TPolyMarker* pmyz = new TPolyMarker(n_poly, z_poly, y_poly);
685  pmyz->SetMarkerColor(mcolor[ista]);
686  pmyz->SetMarkerStyle(hitsMStyle);
687  pmyz->SetMarkerSize(HitSize);
688  pmyz->Draw();
689 
690  TPolyMarker* pmyz_fake =
691  new TPolyMarker(n_poly_fake, z_poly_fake, y_poly_fake);
692  pmyz_fake->SetMarkerColor(mcolor[ista]);
693  pmyz_fake->SetMarkerStyle(fakesMStyle);
694  pmyz_fake->SetMarkerSize(HitSize);
695  pmyz_fake->Draw();
696 
697  XZ->cd();
698 
699  line->DrawLine(st.z[0], -st.Rmax[0], st.z[0], st.Rmax[0]);
700 
701  TPolyMarker* pmxz = new TPolyMarker(n_poly, z_poly, x_poly);
702  pmxz->SetMarkerColor(mcolor[ista]);
703  pmxz->SetMarkerStyle(hitsMStyle);
704  pmxz->SetMarkerSize(HitSize);
705  pmxz->Draw();
706 
707  TPolyMarker* pmxz_fake =
708  new TPolyMarker(n_poly_fake, z_poly_fake, x_poly_fake);
709  pmxz_fake->SetMarkerColor(mcolor[ista]);
710  pmxz_fake->SetMarkerStyle(fakesMStyle);
711  pmxz_fake->SetMarkerSize(HitSize);
712  pmxz_fake->Draw();
713 
714  YX->cd();
715 
716  TEllipse* ellipse = new TEllipse(0.0, 0.0, st.Rmax[0]);
717  ellipse->SetLineColor(StaColor);
718  ellipse->SetFillStyle(0);
719  ellipse->Draw();
720 
721  TPolyMarker* pmyx = new TPolyMarker(n_poly, x_poly, y_poly);
722  pmyx->SetMarkerColor(mcolor[ista]);
723  pmyx->SetMarkerStyle(hitsMStyle);
724  pmyx->SetMarkerSize(HitSize);
725  pmyx->Draw();
726 
727  TPolyMarker* pmyx_fake =
728  new TPolyMarker(n_poly_fake, x_poly_fake, y_poly_fake);
729  pmyx_fake->SetMarkerColor(mcolor[ista]);
730  pmyx_fake->SetMarkerStyle(fakesMStyle);
731  pmyx_fake->SetMarkerSize(HitSize);
732  pmyx_fake->Draw();
733 
734  XYZ->cd();
735 
736  TPolyMarker* pmxyz = new TPolyMarker(n_poly, z_poly_turned, x_poly_turned);
737  pmxyz->SetMarkerColor(mcolor[ista]);
738  pmxyz->SetMarkerStyle(hitsMStyle);
739  pmxyz->SetMarkerSize(HitSize);
740  pmxyz->Draw();
741 
742  TPolyMarker* pmxyz_fake =
743  new TPolyMarker(n_poly_fake, z_poly_fake_turned, x_poly_fake_turned);
744  pmxyz_fake->SetMarkerColor(mcolor[ista]);
745  pmxyz_fake->SetMarkerStyle(fakesMStyle);
746  pmxyz_fake->SetMarkerSize(HitSize);
747  pmxyz_fake->Draw();
748  }
749 
750 } // DrawInputHits
751 
752 void L1AlgoDraw::DrawRestHits(THitI* StsRestHitsStartIndex,
753  THitI* StsRestHitsStopIndex,
754  unsigned int* realIHit) {
755 
756  TLatex latex;
757  latex.SetTextFont(132);
758  latex.SetTextAlign(12);
759  latex.SetTextSize(0.035);
760 
761  YZ->cd();
762  latex.DrawLatex(0.0, 45.0, "YZ Side View");
763  YZ->Draw();
764  XZ->cd();
765  latex.DrawLatex(0.0, 45.0, "XZ Top View");
766  XZ->Draw();
767  YX->cd();
768  latex.DrawLatex(-45.0, 45.0, "YX Front View");
769  YX->Draw();
770 
771 
772  int nhits = vStsHits.size();
773  Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
774  Double_t x_poly_fake[nhits], y_poly_fake[nhits], z_poly_fake[nhits];
775 
776 
777  for (int ista = NStations - 1; ista >= 0;
778  ista--) { // //start downstream chambers
779  L1Station& st = vStations[ista];
780  Int_t n_poly = 0;
781  Int_t n_poly_fake = 0;
782  for (int iRestHit = StsRestHitsStartIndex[ista];
783  iRestHit < StsRestHitsStopIndex[ista];
784  iRestHit++) {
785  int ih = realIHit[iRestHit];
786  L1StsHit& h = vStsHits[ih];
787  int iMC = CbmL1::Instance()->vHitMCRef[ih];
788  //if( (vSFlag[h.f] | vSFlagB[h.b] )&0x02 ) continue; // if used
789 
790  float x, y, z;
791  algo->GetHitCoor(h, x, y, z, st);
792  if (iMC >= 0) {
793  x_poly[n_poly] = x;
794  y_poly[n_poly] = y;
795  z_poly[n_poly] = z;
796  n_poly++;
797  } else {
798  x_poly_fake[n_poly_fake] = x;
799  y_poly_fake[n_poly_fake] = y;
800  z_poly_fake[n_poly_fake] = z;
801  n_poly_fake++;
802  }
803  }
804 
805  YZ->cd();
806 
807  TLine* line = new TLine();
808  line->SetLineColor(StaColor);
809  line->DrawLine(st.z[0], -st.Rmax[0], st.z[0], st.Rmax[0]);
810 
811  TPolyMarker* pmyz = new TPolyMarker(n_poly, z_poly, y_poly);
812  pmyz->SetMarkerColor(mcolor[ista]);
813  pmyz->SetMarkerStyle(hitsMStyle);
814  pmyz->SetMarkerSize(HitSize);
815  pmyz->Draw();
816 
817  TPolyMarker* pmyz_fake =
818  new TPolyMarker(n_poly_fake, z_poly_fake, y_poly_fake);
819  pmyz_fake->SetMarkerColor(mcolor[ista]);
820  pmyz_fake->SetMarkerStyle(fakesMStyle);
821  pmyz_fake->SetMarkerSize(HitSize);
822  pmyz_fake->Draw();
823 
824  XZ->cd();
825 
826  line->DrawLine(st.z[0], -st.Rmax[0], st.z[0], st.Rmax[0]);
827 
828  TPolyMarker* pmxz = new TPolyMarker(n_poly, z_poly, x_poly);
829  pmxz->SetMarkerColor(mcolor[ista]);
830  pmxz->SetMarkerStyle(hitsMStyle);
831  pmxz->SetMarkerSize(HitSize);
832  pmxz->Draw();
833 
834  TPolyMarker* pmxz_fake =
835  new TPolyMarker(n_poly_fake, z_poly_fake, x_poly_fake);
836  pmxz_fake->SetMarkerColor(mcolor[ista]);
837  pmxz_fake->SetMarkerStyle(fakesMStyle);
838  pmxz_fake->SetMarkerSize(HitSize);
839  pmxz_fake->Draw();
840 
841  YX->cd();
842 
843  TEllipse* ellipse = new TEllipse(0.0, 0.0, st.Rmax[0]);
844  ellipse->SetLineColor(StaColor);
845  ellipse->SetFillStyle(0);
846  ellipse->Draw();
847 
848  TPolyMarker* pmyx = new TPolyMarker(n_poly, x_poly, y_poly);
849  pmyx->SetMarkerColor(mcolor[ista]);
850  pmyx->SetMarkerStyle(hitsMStyle);
851  pmyx->SetMarkerSize(HitSize);
852  pmyx->Draw();
853 
854  TPolyMarker* pmyx_fake =
855  new TPolyMarker(n_poly_fake, x_poly_fake, y_poly_fake);
856  pmyx_fake->SetMarkerColor(mcolor[ista]);
857  pmyx_fake->SetMarkerStyle(fakesMStyle);
858  pmyx_fake->SetMarkerSize(HitSize);
859  pmyx_fake->Draw();
860  }
861 
862 } // DrawCurHits
863 
865  char symbol;
866  if (ask) {
867  std::cout << "ask>";
868  do {
869  std::cin.get(symbol);
870  if (symbol == 'r') ask = false;
871  if (symbol == 'q') exit;
872  } while (symbol != '\n');
873  std::cout << endl;
874  }
875 }
876 
878  YZ->Clear();
879  XZ->Clear();
880  YX->Clear();
881  XYZ->Clear();
882 }
883 
885  L1StsHit& hit = vStsHits[ih];
886  // find station
887  int ista = 0;
888  for (int i = 0; i < NStations; i++) {
889  if ((StsHitsStartIndex[i] <= ih) && (StsHitsStopIndex[i] > ih)) {
890  ista = i;
891  break;
892  }
893  }
894  L1Station& sta = vStations[ista];
895  float x, y, z;
896  algo->GetHitCoor(hit, x, y, z, sta);
897  return Point(x, y, z);
898 };
899 
900 void L1AlgoDraw::SaveCanvas(TString name) {
901  system("mkdir L1CADraw -p");
902  chdir("L1CADraw");
903  TString tmp = name;
904  tmp += "YXView.pdf";
905  YX->cd();
906  // YX->SaveAs("YXView.eps");
907  YX->SaveAs(tmp);
908 
909  tmp = name;
910  tmp += "XZView.pdf";
911  XZ->cd();
912  // XZ->SaveAs("XZView.eps");
913  XZ->SaveAs(tmp);
914 
915  tmp = name;
916  tmp += "YZView.pdf";
917  YZ->cd();
918  // YZ->SaveAs("YZView.eps");
919  YZ->SaveAs(tmp);
920 
921  tmp = name;
922  tmp += "XYZView.pdf";
923  XYZ->cd();
924  XYZ->SaveAs(tmp);
925  // XYZ->SaveAs("XYZView.eps");
926  // XYZ->SaveAs("XYZView.png");
927  // XYZ->SaveAs("XYZView.pdf");
928  chdir("..");
929 }
930 
931 #endif
L1AlgoDraw::XYZ
TCanvas * XYZ
Definition: L1AlgoDraw.h:94
L1Algo::vStsHits
const vector< L1StsHit > * vStsHits
Definition: L1Algo.h:344
CbmL1MCPoint::q
double q
Definition: CbmL1MCPoint.h:59
L1AlgoDraw::Point::x
double x
Definition: L1AlgoDraw.h:31
h
Generates beam ions for transport simulation.
Definition: CbmBeamGenerator.h:17
L1Algo.h
L1AlgoDraw::fVerbose
int fVerbose
Definition: L1AlgoDraw.h:93
L1AlgoDraw::L1AlgoDraw
L1AlgoDraw()
Definition: L1AlgoDraw.h:98
L1AlgoDraw::ClearVeiw
void ClearVeiw()
Definition: L1AlgoDraw.h:877
CbmKF.h
L1AlgoDraw::DrawDoublet
void DrawDoublet(int il, int ir)
Definition: L1AlgoDraw.h:521
CbmL1MCPoint::x
double x
Definition: CbmL1MCPoint.h:56
CbmL1MCTrack::q
double q
Definition: CbmL1MCTrack.h:31
CbmL1MCPoint
Definition: CbmL1MCPoint.h:23
L1Triplet
Definition: L1Triplet.h:4
L1Station
Definition: L1Station.h:9
L1AlgoDraw::YX
TCanvas * YX
Definition: L1AlgoDraw.h:94
CbmKF::Propagate
Int_t Propagate(Double_t *T, Double_t *C, Double_t z_out, Double_t QP0)
Definition: CbmKF.cxx:554
CbmL1MCPoint::y
double y
Definition: CbmL1MCPoint.h:56
L1AlgoDraw::DrawInfo
void DrawInfo()
Definition: L1AlgoDraw.h:556
L1Algo::StsHitsStartIndex
const THitI * StsHitsStartIndex
Definition: L1Algo.h:358
L1AlgoDraw::DrawTriplets
void DrawTriplets(vector< L1Triplet > &triplets, const THitI *realIHit)
Definition: L1AlgoDraw.h:387
L1AlgoDraw::InitL1Draw
void InitL1Draw(L1Algo *algo_)
Definition: L1AlgoDraw.h:147
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
L1AlgoDraw::targetMStyle
int targetMStyle
Definition: L1AlgoDraw.h:89
L1Algo::vStsStrips
const vector< L1Strip > * vStsStrips
Definition: L1Algo.h:340
CbmL1MCTrack::y
double y
Definition: CbmL1MCTrack.h:31
CbmL1MCTrack::x
double x
Definition: CbmL1MCTrack.h:31
L1Algo::StsHitsStopIndex
const THitI * StsHitsStopIndex
Definition: L1Algo.h:359
CbmL1.h
L1StsHit
Definition: L1StsHit.h:12
L1AlgoDraw::Point::Point
Point()
Definition: L1AlgoDraw.h:32
CbmL1MCTrack::px
double px
Definition: CbmL1MCTrack.h:31
L1AlgoDraw::DrawInputHits
void DrawInputHits()
Definition: L1AlgoDraw.h:615
L1Triplet::GetRHit
THitI GetRHit() const
Definition: L1Triplet.h:121
L1Algo::vStsStripsB
const vector< L1Strip > * vStsStripsB
Definition: L1Algo.h:341
L1AlgoDraw::Point::y
double y
Definition: L1AlgoDraw.h:31
CbmL1MCTrack::pdg
int pdg
Definition: CbmL1MCTrack.h:32
L1AlgoDraw::DrawRestHits
void DrawRestHits(THitI *StsRestHitsStartIndex, THitI *StsRestHitsStopIndex, unsigned int *realIHit)
Definition: L1AlgoDraw.h:752
CbmL1MCPoint::pz
double pz
Definition: CbmL1MCPoint.h:56
L1AlgoDraw::algo
L1Algo * algo
Definition: L1AlgoDraw.h:76
CbmL1MCTrack::py
double py
Definition: CbmL1MCTrack.h:31
THitI
unsigned int THitI
Definition: L1StsHit.h:8
L1Algo::NStations
int NStations
Definition: L1Algo.h:333
CbmKF::Instance
static CbmKF * Instance()
Definition: CbmKF.h:39
L1Station::z
fvec z
Definition: L1Station.h:28
CbmL1::Instance
static CbmL1 * Instance()
Definition: CbmL1.h:129
L1AlgoDraw::StaColor
int StaColor
Definition: L1AlgoDraw.h:86
L1AlgoDraw::DrawTarget
void DrawTarget()
Definition: L1AlgoDraw.h:562
L1AlgoDraw::vStsHits
vector< L1StsHit > vStsHits
Definition: L1AlgoDraw.h:79
CbmL1MCTrack::p
double p
Definition: CbmL1MCTrack.h:31
L1Track::NHits
unsigned char NHits
Definition: L1Track.h:22
CbmL1MCTrack::Points
vector< int > Points
Definition: CbmL1MCTrack.h:33
CbmL1MCTrack::mother_ID
int mother_ID
Definition: CbmL1MCTrack.h:32
CbmL1MCTrack::z
double z
Definition: CbmL1MCTrack.h:31
L1AlgoDraw::hitsMStyle
int hitsMStyle
Definition: L1AlgoDraw.h:87
Point
Definition: CbmGlobalTrackingTof.cxx:90
L1AlgoDraw::NStations
int NStations
Definition: L1AlgoDraw.h:82
CbmL1MCPoint::p
double p
Definition: CbmL1MCPoint.h:59
L1AlgoDraw::StsHitsStartIndex
int StsHitsStartIndex[20]
Definition: L1AlgoDraw.h:80
L1Algo::vTracks
L1Vector< L1Track > vTracks
Definition: L1Algo.h:355
L1AlgoDraw::ask
bool ask
Definition: L1AlgoDraw.h:95
L1AlgoDraw::vStations
L1Station vStations[20]
Definition: L1AlgoDraw.h:83
L1Algo
Definition: L1Algo.h:79
L1AlgoDraw::vStsStrips
vector< fscal > vStsStrips
Definition: L1AlgoDraw.h:78
L1Triplet::GetLHit
THitI GetLHit() const
Definition: L1Triplet.h:119
xMath::Pi
double Pi()
Definition: xMath.h:5
L1AlgoDraw::SaveCanvas
void SaveCanvas(TString name)
Definition: L1AlgoDraw.h:900
L1AlgoDraw::mcolor
int mcolor[10]
Definition: L1AlgoDraw.h:85
L1Track
Definition: L1Track.h:20
CbmL1MCPoint::z
double z
Definition: CbmL1MCPoint.h:56
L1Algo::vRecoHits
L1Vector< THitI > vRecoHits
Definition: L1Algo.h:356
L1AlgoDraw::vStsStripsB
vector< fscal > vStsStripsB
Definition: L1AlgoDraw.h:78
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
L1AlgoDraw::DrawAsk
void DrawAsk()
Definition: L1AlgoDraw.h:864
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
L1AlgoDraw::GetHitCoor
Point GetHitCoor(int ih)
Definition: L1AlgoDraw.h:884
L1AlgoDraw::HitSize
double HitSize
Definition: L1AlgoDraw.h:91
L1AlgoDraw::fakesMStyle
int fakesMStyle
Definition: L1AlgoDraw.h:88
L1AlgoDraw::DrawMCTracks
void DrawMCTracks()
Definition: L1AlgoDraw.h:170
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmL1MCTrack::pz
double pz
Definition: CbmL1MCTrack.h:31
L1AlgoDraw::Point
Definition: L1AlgoDraw.h:30
CbmL1::vHitMCRef
vector< int > vHitMCRef
Definition: CbmL1.h:339
L1AlgoDraw::DrawDoubletsOnSta
void DrawDoubletsOnSta(int iSta, THitI *Duplets_hits, THitI *Duplets_start, const int MaxArrSize, THitI *StsRestHitsStartIndex, unsigned int *realIHit)
Definition: L1AlgoDraw.h:486
L1AlgoDraw::DrawDoublets
void DrawDoublets(vector< THitI > *Duplets_hits, map< THitI, THitI > *Duplets_start, const int MaxArrSize, THitI *StsHitsStartIndex, unsigned int *realIHit)
Definition: L1AlgoDraw.h:450
CbmL1MCTrack::StsHits
vector< int > StsHits
Definition: CbmL1MCTrack.h:34
L1AlgoDraw::Point::z
double z
Definition: L1AlgoDraw.h:31
L1Triplet::GetMHit
THitI GetMHit() const
Definition: L1Triplet.h:120
CbmL1MCPoint::px
double px
Definition: CbmL1MCPoint.h:56
CbmL1MCTrack
Definition: CbmL1MCTrack.h:29
CbmL1::vMCPoints
vector< CbmL1MCPoint > vMCPoints
Definition: CbmL1.h:197
L1AlgoDraw::XZ
TCanvas * XZ
Definition: L1AlgoDraw.h:94
L1AlgoDraw::DrawTriplet
void DrawTriplet(int il, int im, int ir)
Definition: L1AlgoDraw.h:411
L1AlgoDraw
Definition: L1AlgoDraw.h:29
CbmL1
Definition: CbmL1.h:113
L1Station::Rmax
fvec Rmax
Definition: L1Station.h:28
CbmL1MCPoint::py
double py
Definition: CbmL1MCPoint.h:56
L1Algo::GetHitCoor
void GetHitCoor(const L1StsHit &_h, fscal &_x, fscal &_y, fscal &_z, const L1Station &sta)
--— Hit-point-strips conversion routines ---—
Definition: L1Algo.cxx:235
CbmL1::vMCTracks
vector< CbmL1MCTrack > vMCTracks
Definition: CbmL1.h:337
L1AlgoDraw::StsHitsStopIndex
int StsHitsStopIndex[20]
Definition: L1AlgoDraw.h:80
L1AlgoDraw::YZ
TCanvas * YZ
Definition: L1AlgoDraw.h:94
CbmL1MCTrack::IsReconstructable
bool IsReconstructable() const
Definition: CbmL1MCTrack.h:105
L1AlgoDraw::DrawRecoTracks
void DrawRecoTracks()
Definition: L1AlgoDraw.h:311
L1AlgoDraw::Point::Point
Point(double _x, double _y, double _z)
Definition: L1AlgoDraw.h:33