6 #include "TGeoBoolNode.h"
7 #include "TGeoCompositeShape.h"
9 #include "TGeoManager.h"
12 #include "TMCProcess.h"
14 #include "TPolyLine.h"
15 #include "TPolyMarker.h"
23 #include "kdtree++/kdtree.hpp"
26 #define USE_MUCH_ABSORBER
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)
37 gStyle->SetCanvasBorderMode(0);
38 gStyle->SetCanvasBorderSize(1);
39 gStyle->SetCanvasColor(0);
41 YZ.Range(-15.0, -300.0, 600.0, 300.0);
45 XZ.Range(-15.0, -300.0, 600.0, 300.0);
49 YX.Range(-300.0, -300.0, 300.0, 300.0);
69 if (symbol ==
'r')
ask =
false;
71 if (symbol ==
'q') exit(1);
72 }
while (symbol !=
'\n');
84 static int mc_tr_count = 0;
86 for (vector<LxMCTrack>::iterator it = finder->
MCTracks.begin();
94 bool mcPointOnSta[18] = {
false,
114 for (vector<LxMCPoint*>::iterator j = T.
Points.begin(); j != T.
Points.end();
121 bool isRefTrack =
true;
123 for (
int j = 0; j < 15; ++j) {
124 if (!mcPointOnSta[j]) isRefTrack =
false;
131 pline.SetLineColor(kRed);
133 if (T.
p < 0.5) pline.SetLineColor(kBlue);
135 if (T.
mother_ID != -1) pline.SetLineColor(8);
137 if ((T.
mother_ID != -1) && (T.
p < 0.5)) pline.SetLineColor(12);
148 par[2] = T.
px / T.
pz;
149 par[3] = T.
py / T.
pz;
153 if (T.
Points.size() < 1)
continue;
155 vector<double> lx, ly, lz;
156 lx.push_back(par[0]);
157 ly.push_back(par[1]);
158 lz.push_back(par[5]);
185 for (std::vector<LxMCPoint*>::iterator ip = T.
Points.begin();
192 par1[2] = p->
px / p->
pz;
193 par1[3] = p->
py / p->
pz;
194 par1[4] = p->
q / p->
p;
197 double Zfrst = par[5];
198 double Zlast = par1[5];
201 if (step >
fabs(Zfrst - Zlast) / 5) step =
fabs(Zfrst - Zlast) / 5;
203 if (Zlast < par[5]) step = -step;
205 while (
fabs(par[5] - Zlast) >
fabs(step)) {
206 double znxt = par[5] + step;
209 double w =
fabs(znxt - Zfrst);
210 double w1 =
fabs(znxt - Zlast);
212 if (w + w1 < 1.e-3) {
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);
221 if (
fabs(zl - z00) < dz0) {
225 dz0 =
fabs(zl - z00);
228 if ((
fabs(xl) > 400.0) || (
fabs(yl) > 400.0)) {
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));
239 if (lx.size() > 200)
break;
246 par[2] = p->
px / p->
pz;
247 par[3] = p->
py / p->
pz;
249 par[2] = 1000 * 1000 * 1000;
250 par[3] = 1000 * 1000 * 1000;
254 par[4] = p->
q / p->
p;
256 par[4] = 1000 * 1000 * 1000;
259 lx.push_back(par[0]);
260 ly.push_back(par[1]);
261 lz.push_back(par[5]);
265 double max_z = 0, min_z = 500;
267 for (vector<double>::iterator
i = lz.begin();
i != lz.end(); ++
i) {
268 if (*
i > max_z) max_z = *
i;
270 if (*
i < min_z) min_z = *
i;
273 if (min_z < 10 && max_z > 503) ++mc_tr_count;
277 pline.DrawPolyLine(lx.size(), &(lz[0]), &(ly[0]));
278 TMarker* xMarker =
new TMarker(z0, y0, 30);
279 xMarker->SetMarkerColor(kRed);
282 pline.DrawPolyLine(lx.size(), &(lz[0]), &(lx[0]));
283 TMarker* yMarker =
new TMarker(z0, x0, 30);
284 yMarker->SetMarkerColor(kRed);
287 pline.DrawPolyLine(lx.size(), &(lx[0]), &(ly[0]));
288 TMarker* zMarker =
new TMarker(x0, y0, 30);
289 zMarker->SetMarkerColor(kRed);
294 cout <<
"LxDraw: number of registered MC tracks: " << NRegMCTracks << endl;
315 for (
int i = 0;
i < 6; ++
i)
320 for (
int j = 0; j < 3; ++j)
325 nhits += pLa->
points.size();
329 scaltype x_poly[nhits], y_poly[nhits], z_poly[nhits];
330 scaltype x_poly2[nhits], y_poly2[nhits], z_poly2[nhits];
331 scaltype x_poly3[nhits], y_poly3[nhits], z_poly3[nhits];
337 for (
int i = 5;
i >= 0; --
i)
342 for (
int j = 2; j >= 0; --j)
348 for (list<LxPoint*>::iterator k = pLa->
points.begin();
354 x_poly3[n_poly3] = pPo->
x;
355 y_poly3[n_poly3] = pPo->
y;
356 z_poly3[n_poly3] = pPo->
z;
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;
364 x_poly[n_poly] = pPo->
x;
365 y_poly[n_poly] = pPo->
y;
366 z_poly[n_poly] = pPo->
z;
375 TPolyMarker* pmyz =
new TPolyMarker(n_poly, z_poly, y_poly);
376 pmyz->SetMarkerColor(mcolour);
377 pmyz->SetMarkerStyle(hitsMStyle);
378 pmyz->SetMarkerSize(HitSize);
381 TPolyMarker* pmyz2 =
new TPolyMarker(n_poly2, z_poly2, y_poly2);
382 pmyz2->SetMarkerColor(2);
383 pmyz2->SetMarkerStyle(hitsMStyle);
384 pmyz2->SetMarkerSize(HitSize);
387 TPolyMarker* pmyz3 =
new TPolyMarker(n_poly3, z_poly3, y_poly3);
388 pmyz3->SetMarkerColor(3);
389 pmyz3->SetMarkerStyle(hitsMStyle);
390 pmyz3->SetMarkerSize(HitSize);
395 TPolyMarker* pmxz =
new TPolyMarker(n_poly, z_poly, x_poly);
396 pmxz->SetMarkerColor(mcolour);
397 pmxz->SetMarkerStyle(hitsMStyle);
398 pmxz->SetMarkerSize(HitSize);
401 TPolyMarker* pmxz2 =
new TPolyMarker(n_poly2, z_poly2, x_poly2);
402 pmxz2->SetMarkerColor(2);
403 pmxz2->SetMarkerStyle(hitsMStyle);
404 pmxz2->SetMarkerSize(HitSize);
407 TPolyMarker* pmxz3 =
new TPolyMarker(n_poly3, z_poly3, x_poly3);
408 pmxz3->SetMarkerColor(3);
409 pmxz3->SetMarkerStyle(hitsMStyle);
410 pmxz3->SetMarkerSize(HitSize);
415 TPolyMarker* pmyx =
new TPolyMarker(n_poly, x_poly, y_poly);
416 pmyx->SetMarkerColor(mcolour);
417 pmyx->SetMarkerStyle(hitsMStyle);
418 pmyx->SetMarkerSize(HitSize);
421 TPolyMarker* pmyx2 =
new TPolyMarker(n_poly2, x_poly2, y_poly2);
422 pmyx2->SetMarkerColor(2);
423 pmyx2->SetMarkerStyle(hitsMStyle);
424 pmyx2->SetMarkerSize(HitSize);
427 TPolyMarker* pmyx3 =
new TPolyMarker(n_poly3, x_poly3, y_poly3);
428 pmyx3->SetMarkerColor(3);
429 pmyx3->SetMarkerStyle(hitsMStyle);
430 pmyx3->SetMarkerSize(HitSize);
438 if (0 != strstr(node->GetName(),
"active")) {
439 TGeoCompositeShape* cs =
440 dynamic_cast<TGeoCompositeShape*
>(node->GetVolume()->GetShape());
443 TGeoBoolNode* bn = cs->GetBoolNode();
444 TGeoTrap* trap =
dynamic_cast<TGeoTrap*
>(bn->GetLeftShape());
447 scaltype minY = 0, maxY = 0, minX = 0, maxX = 0, Z = 0;
448 Double_t* xy = trap->GetVertices();
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);
457 if (minY > globalCoords[1]) minY = globalCoords[1];
459 if (maxY < globalCoords[1]) maxY = globalCoords[1];
461 if (minX > globalCoords[0]) minX = globalCoords[0];
463 if (maxX < globalCoords[0]) maxX = globalCoords[0];
466 trapX[
i] = globalCoords[0];
467 trapY[
i] = globalCoords[1];
474 TLine* line =
new TLine();
476 line->DrawLine(Z, minY, Z, maxY);
479 line->DrawLine(Z, minX, Z, maxX);
482 TPolyLine* pline =
new TPolyLine(5, trapX, trapY);
484 pline->SetLineColor(kCyan + 4);
485 pline->SetLineWidth(1);
494 children = node->GetNodes();
496 if (0 == children)
goto exit;
498 childO = children->First();
501 TGeoNode* child =
dynamic_cast<TGeoNode*
>(childO);
506 gGeoManager->GetCurrentNavigator()->CdDown(child);
510 childO = children->After(childO);
519 latex.SetTextFont(132);
520 latex.SetTextAlign(12);
521 latex.SetTextSize(0.035);
524 latex.DrawLatex(0.0, 250.0,
"YZ Side View");
528 latex.DrawLatex(0.0, 250.0,
"XZ Top View");
532 latex.DrawLatex(-270.0, 250.0,
"YX Front View");
535 for (
int i = 6;
i > 0; --
i) {
540 sprintf(buf,
"/cave_1/much_0/muchstation0%d_0",
i);
541 gGeoManager->cd(buf);
542 DrawMuch(gGeoManager->GetCurrentNode());
544 #ifdef USE_MUCH_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);
555 scaltype fRmax1 = muchAbsCone->GetRmax1();
556 scaltype fRmax2 = muchAbsCone->GetRmax2();
557 scaltype fDz = muchAbsCone->GetDz();
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);
567 muchAbsorber->Draw(
"f");
568 muchAbsorber->Draw();
570 muchAbsorber->Draw(
"f");
571 muchAbsorber->Draw();
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);
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
595 static bool destroyRays;
614 if (destroyRays)
delete ray;
620 value_type
operator[](
size_t n)
const {
return data[n]; }
625 typedef KDTree::KDTree<4, KDRayWrap> KDRaysStorageType;
626 #endif //CLUSTER_MODE
633 for (Int_t
i = stationsNumber - 1;
i > 0; --
i) {
636 KDRaysStorageType* rays =
637 static_cast<KDRaysStorageType*
>(rSt->clusteredRaysHandle);
640 for (KDRaysStorageType::iterator j = rays->begin(); j != rays->end(); ++j) {
641 KDRayWrap& wrap =
const_cast<KDRayWrap&
>(*j);
642 LxRay* ray = wrap.ray;
649 TLine* yzLine =
new TLine(rPo->
z, rPo->
y, lZ, lY);
650 yzLine->SetLineColor(kRed);
654 TLine* xzLine =
new TLine(rPo->
z, rPo->
x, lZ, lX);
655 xzLine->SetLineColor(kRed);
659 TLine* yxLine =
new TLine(rPo->
x, rPo->
y, lX, lY);
660 yxLine->SetLineColor(kRed);
666 int lLaInd = lSt->
layers.size() - 1;
669 if (rLa->
points.size() == 0 || lLa->
points.size() == 0)
continue;
673 for (list<LxPoint*>::iterator j = rLa->
points.begin();
679 for (list<LxRay*>::iterator k = rPo->
rays.begin(); k != rPo->
rays.end();
687 TLine* yzLine =
new TLine(rPo->
z, rPo->
y, lZ, lY);
688 yzLine->SetLineColor(kRed);
692 TLine* xzLine =
new TLine(rPo->
z, rPo->
x, lZ, lX);
693 xzLine->SetLineColor(kRed);
697 TLine* yxLine =
new TLine(rPo->
x, rPo->
y, lX, lY);
698 yxLine->SetLineColor(kRed);
702 #endif //CLUSTER_MODE
723 #ifdef USE_KALMAN_FIT
724 bool kalmanDrawn =
false;
725 #endif //USE_KALMAN_FIT
727 for (
int j = 0; j < track->
length; ++j) {
741 #ifdef USE_KALMAN_FIT
746 scaltype kalmanXr = kalmanXl + track->tx * (kalmanZr - kalmanZl);
747 scaltype kalmanYr = kalmanYl + track->ty * (kalmanZr - kalmanZl);
748 #endif //USE_KALMAN_FIT
751 TLine* yzLineL =
new TLine(rZ, rY, lZ, lY);
752 yzLineL->SetLineColor(kBlue);
755 #ifdef USE_KALMAN_FIT
757 TLine* kalmanYZLine =
new TLine(kalmanZr, kalmanYr, kalmanZl, kalmanYl);
758 kalmanYZLine->SetLineColor(kBlack);
759 kalmanYZLine->Draw();
761 #endif //USE_KALMAN_FIT
764 TLine* xzLineL =
new TLine(rZ, rX, lZ, lX);
765 xzLineL->SetLineColor(kBlue);
768 #ifdef USE_KALMAN_FIT
770 TLine* kalmanXZLine =
new TLine(kalmanZr, kalmanXr, kalmanZl, kalmanXl);
771 kalmanXZLine->SetLineColor(kBlack);
772 kalmanXZLine->Draw();
774 #endif //USE_KALMAN_FIT
777 TLine* yxLineL =
new TLine(rX, rY, lX, lY);
778 yxLineL->SetLineColor(kBlue);
781 #ifdef USE_KALMAN_FIT
783 TLine* kalmanYXLine =
new TLine(kalmanXr, kalmanYr, kalmanXl, kalmanYl);
784 kalmanYXLine->SetLineColor(kBlack);
785 kalmanYXLine->Draw();
787 #endif //USE_KALMAN_FIT
789 #ifdef USE_KALMAN_FIT
791 #endif //USE_KALMAN_FIT
805 scaltype rX = lX + param->GetTx() * deltaZ;
806 scaltype rY = lY + param->GetTy() * deltaZ;
809 TLine* yzLine =
new TLine(lZ, lY, rZ, rY);
810 yzLine->SetLineColor(kPink);
814 TLine* xzLine =
new TLine(lZ, lX, rZ, rX);
815 xzLine->SetLineColor(kPink);
819 TLine* yxLine =
new TLine(lX, lY, rX, rY);
820 yxLine->SetLineColor(kPink);
839 int nhits = finder->
MCPoints.size();
840 scaltype x_poly[nhits], y_poly[nhits], z_poly[nhits];
844 for (vector<LxMCPoint>::iterator
i = finder->
MCPoints.begin();
849 x_poly[n_poly] = point.
x;
850 y_poly[n_poly] = point.
y;
851 z_poly[n_poly] = point.
z;
858 TPolyMarker* pmyz =
new TPolyMarker(n_poly, z_poly, y_poly);
859 pmyz->SetMarkerColor(mcolour);
860 pmyz->SetMarkerStyle(hitsMStyle);
861 pmyz->SetMarkerSize(HitSize);
867 TPolyMarker* pmxz =
new TPolyMarker(n_poly, z_poly, x_poly);
868 pmxz->SetMarkerColor(mcolour);
869 pmxz->SetMarkerStyle(hitsMStyle);
870 pmxz->SetMarkerSize(HitSize);
876 TPolyMarker* pmyx =
new TPolyMarker(n_poly, x_poly, y_poly);
877 pmyx->SetMarkerColor(mcolour);
878 pmyx->SetMarkerStyle(hitsMStyle);
879 pmyx->SetMarkerSize(HitSize);
899 scaltype rX = lX + param->GetTx() * deltaZ;
900 scaltype rY = lY + param->GetTy() * deltaZ;
903 TLine* yzLine =
new TLine(lZ, lY, rZ, rY);
904 yzLine->SetLineColor(kPink);
908 TLine* xzLine =
new TLine(lZ, lX, rZ, rX);
909 xzLine->SetLineColor(kPink);
913 TLine* yxLine =
new TLine(lX, lY, rX, rY);
914 yxLine->SetLineColor(kPink);
927 system(
"mkdir LxDraw -p");