8 #include "TGeoBoolNode.h"
9 #include "TGeoCompositeShape.h"
11 #include "TGeoManager.h"
14 #include "TMCProcess.h"
15 #include "TPolyLine.h"
16 #include "TPolyMarker.h"
24 #include "kdtree++/kdtree.hpp"
27 #define USE_MUCH_ABSORBER
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)
38 gStyle->SetCanvasBorderMode(0);
39 gStyle->SetCanvasBorderSize(1);
40 gStyle->SetCanvasColor(0);
42 YZ.Range(-15.0, -300.0, 600.0, 300.0);
46 XZ.Range(-15.0, -300.0, 600.0, 300.0);
50 YX.Range(-300.0, -300.0, 300.0, 300.0);
70 if (symbol ==
'r')
ask =
false;
72 if (symbol ==
'q') exit;
73 }
while (symbol !=
'\n');
85 static int mc_tr_count = 0;
87 for (vector<LxMCTrack>::iterator it = finder->
MCTracks.begin();
95 bool mcPointOnSta[18] = {
true,
115 for (vector<LxMCPoint*>::iterator j = T.
Points.begin(); j != T.
Points.end();
122 bool isRefTrack =
true;
124 for (
int j = 0; j < 18; ++j) {
125 if (!mcPointOnSta[j]) isRefTrack =
false;
129 if (mcpCount < 15)
continue;
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);
142 par[2] = T.
px / T.
pz;
143 par[3] = T.
py / T.
pz;
147 if (T.
Points.size() < 1)
continue;
149 vector<double> lx, ly, lz;
150 lx.push_back(par[0]);
151 ly.push_back(par[1]);
152 lz.push_back(par[5]);
156 <<
" hitted stations and " << T.
layersWithHits <<
" hitted layers";
164 for (Int_t k = 0; k <
LXLAYERS; ++k) {
177 for (std::vector<LxMCPoint*>::iterator ip = T.
Points.begin();
184 par1[2] = p->
px / p->
pz;
185 par1[3] = p->
py / p->
pz;
186 par1[4] = p->
q / p->
p;
189 double Zfrst = par[5];
190 double Zlast = par1[5];
193 if (step >
fabs(Zfrst - Zlast) / 5) step =
fabs(Zfrst - Zlast) / 5;
195 if (Zlast < par[5]) step = -step;
197 while (
fabs(par[5] - Zlast) >
fabs(step)) {
198 double znxt = par[5] + step;
201 double w =
fabs(znxt - Zfrst);
202 double w1 =
fabs(znxt - Zlast);
204 if (w + w1 < 1.e-3) {
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);
213 if ((
fabs(xl) > 400.0) || (
fabs(yl) > 400.0)) {
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));
224 if (lx.size() > 200)
break;
231 par[2] = p->
px / p->
pz;
232 par[3] = p->
py / p->
pz;
234 par[2] = 1000 * 1000 * 1000;
235 par[3] = 1000 * 1000 * 1000;
239 par[4] = p->
q / p->
p;
241 par[4] = 1000 * 1000 * 1000;
244 lx.push_back(par[0]);
245 ly.push_back(par[1]);
246 lz.push_back(par[5]);
250 double max_z = 0, min_z = 500;
252 for (vector<double>::iterator
i = lz.begin();
i != lz.end(); ++
i) {
253 if (*
i > max_z) max_z = *
i;
255 if (*
i < min_z) min_z = *
i;
258 if (min_z < 10 && max_z > 503) ++mc_tr_count;
262 pline.DrawPolyLine(lx.size(), &(lz[0]), &(ly[0]));
264 pline.DrawPolyLine(lx.size(), &(lz[0]), &(lx[0]));
266 pline.DrawPolyLine(lx.size(), &(lx[0]), &(ly[0]));
270 cout <<
"LxDraw: number of registered MC tracks: " << NRegMCTracks << endl;
291 for (
int i = 0;
i < 6; ++
i)
296 for (
int j = 0; j < 3; ++j)
301 nhits += pLa->
points.size();
305 Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
306 Double_t x_poly2[nhits], y_poly2[nhits], z_poly2[nhits];
307 Double_t x_poly3[nhits], y_poly3[nhits], z_poly3[nhits];
314 for (
int i = 0;
i >= 0; --
i) {
318 for (
int j = 1; j >= 1; --j) {
322 for (list<LxPoint*>::iterator k = pLa->
points.begin();
328 x_poly3[n_poly3] = pPo->
x;
329 y_poly3[n_poly3] = pPo->
y;
330 z_poly3[n_poly3] = pPo->
z;
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;
338 x_poly[n_poly] = pPo->
x;
339 y_poly[n_poly] = pPo->
y;
340 z_poly[n_poly] = pPo->
z;
349 TPolyMarker* pmyz =
new TPolyMarker(n_poly, z_poly, y_poly);
350 pmyz->SetMarkerColor(mcolour);
351 pmyz->SetMarkerStyle(hitsMStyle);
352 pmyz->SetMarkerSize(HitSize);
355 TPolyMarker* pmyz2 =
new TPolyMarker(n_poly2, z_poly2, y_poly2);
356 pmyz2->SetMarkerColor(2);
357 pmyz2->SetMarkerStyle(hitsMStyle);
358 pmyz2->SetMarkerSize(HitSize);
361 TPolyMarker* pmyz3 =
new TPolyMarker(n_poly3, z_poly3, y_poly3);
362 pmyz3->SetMarkerColor(3);
363 pmyz3->SetMarkerStyle(hitsMStyle);
364 pmyz3->SetMarkerSize(HitSize);
369 TPolyMarker* pmxz =
new TPolyMarker(n_poly, z_poly, x_poly);
370 pmxz->SetMarkerColor(mcolour);
371 pmxz->SetMarkerStyle(hitsMStyle);
372 pmxz->SetMarkerSize(HitSize);
375 TPolyMarker* pmxz2 =
new TPolyMarker(n_poly2, z_poly2, x_poly2);
376 pmxz2->SetMarkerColor(2);
377 pmxz2->SetMarkerStyle(hitsMStyle);
378 pmxz2->SetMarkerSize(HitSize);
381 TPolyMarker* pmxz3 =
new TPolyMarker(n_poly3, z_poly3, x_poly3);
382 pmxz3->SetMarkerColor(3);
383 pmxz3->SetMarkerStyle(hitsMStyle);
384 pmxz3->SetMarkerSize(HitSize);
389 TPolyMarker* pmyx =
new TPolyMarker(n_poly, x_poly, y_poly);
390 pmyx->SetMarkerColor(mcolour);
391 pmyx->SetMarkerStyle(hitsMStyle);
392 pmyx->SetMarkerSize(HitSize);
395 TPolyMarker* pmyx2 =
new TPolyMarker(n_poly2, x_poly2, y_poly2);
396 pmyx2->SetMarkerColor(2);
397 pmyx2->SetMarkerStyle(hitsMStyle);
398 pmyx2->SetMarkerSize(HitSize);
401 TPolyMarker* pmyx3 =
new TPolyMarker(n_poly3, x_poly3, y_poly3);
402 pmyx3->SetMarkerColor(3);
403 pmyx3->SetMarkerStyle(hitsMStyle);
404 pmyx3->SetMarkerSize(HitSize);
412 if (0 != strstr(node->GetName(),
"active")) {
413 TGeoCompositeShape* cs =
414 dynamic_cast<TGeoCompositeShape*
>(node->GetVolume()->GetShape());
417 TGeoBoolNode* bn = cs->GetBoolNode();
418 TGeoTrap* trap =
dynamic_cast<TGeoTrap*
>(bn->GetLeftShape());
421 Double_t minY = 0, maxY = 0, minX = 0, maxX = 0, Z = 0;
422 Double_t* xy = trap->GetVertices();
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);
431 if (minY > globalCoords[1]) minY = globalCoords[1];
433 if (maxY < globalCoords[1]) maxY = globalCoords[1];
435 if (minX > globalCoords[0]) minX = globalCoords[0];
437 if (maxX < globalCoords[0]) maxX = globalCoords[0];
440 trapX[
i] = globalCoords[0];
441 trapY[
i] = globalCoords[1];
448 TLine* line =
new TLine();
450 line->DrawLine(Z, minY, Z, maxY);
453 line->DrawLine(Z, minX, Z, maxX);
456 TPolyLine* pline =
new TPolyLine(5, trapX, trapY);
458 pline->SetLineColor(kCyan + 4);
459 pline->SetLineWidth(1);
468 children = node->GetNodes();
470 if (0 == children)
goto exit;
472 childO = children->First();
475 TGeoNode* child =
dynamic_cast<TGeoNode*
>(childO);
478 gGeoManager->GetCurrentNavigator()->CdDown(child);
482 childO = children->After(childO);
491 latex.SetTextFont(132);
492 latex.SetTextAlign(12);
493 latex.SetTextSize(0.035);
496 latex.DrawLatex(0.0, 250.0,
"YZ Side View");
500 latex.DrawLatex(0.0, 250.0,
"XZ Top View");
504 latex.DrawLatex(-270.0, 250.0,
"YX Front View");
507 for (
int i = 6;
i > 0; --
i) {
512 sprintf(buf,
"/cave_1/much_0/muchstation0%d_0",
i);
513 gGeoManager->cd(buf);
514 DrawMuch(gGeoManager->GetCurrentNode());
516 #ifdef USE_MUCH_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);
527 Double_t fRmax1 = muchAbsCone->GetRmax1();
528 Double_t fRmax2 = muchAbsCone->GetRmax2();
529 Double_t fDz = muchAbsCone->GetDz();
530 Double_t fZ = globalCoords[2];
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);
539 muchAbsorber->Draw(
"f");
540 muchAbsorber->Draw();
542 muchAbsorber->Draw(
"f");
543 muchAbsorber->Draw();
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);
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
567 static bool destroyRays;
569 KDRayWrap(Double_t
x, Double_t
y,
LxRay* r) : ray(r) {
576 KDRayWrap(Double_t
x, Double_t
y, Double_t tx, Double_t ty)
586 if (destroyRays)
delete ray;
590 typedef Double_t value_type;
592 value_type
operator[](
size_t n)
const {
return data[n]; }
597 typedef KDTree::KDTree<4, KDRayWrap> KDRaysStorageType;
598 #endif //CLUSTER_MODE
605 for (Int_t
i = stationsNumber - 1;
i > 0; --
i) {
608 KDRaysStorageType* rays =
609 static_cast<KDRaysStorageType*
>(rSt->clusteredRaysHandle);
612 for (KDRaysStorageType::iterator j = rays->begin(); j != rays->end(); ++j) {
613 KDRayWrap& wrap =
const_cast<KDRayWrap&
>(*j);
614 LxRay* ray = wrap.ray;
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;
621 TLine* yzLine =
new TLine(rPo->
z, rPo->
y, lZ, lY);
622 yzLine->SetLineColor(kRed);
626 TLine* xzLine =
new TLine(rPo->
z, rPo->
x, lZ, lX);
627 xzLine->SetLineColor(kRed);
631 TLine* yxLine =
new TLine(rPo->
x, rPo->
y, lX, lY);
632 yxLine->SetLineColor(kRed);
638 int lLaInd = lSt->
layers.size() - 1;
641 if (rLa->
points.size() == 0 || lLa->
points.size() == 0)
continue;
643 Double_t lZ = (*lLa->
points.begin())->z;
645 for (list<LxPoint*>::iterator j = rLa->
points.begin();
649 Double_t deltaZ = lZ - rPo->
z;
651 for (list<LxRay*>::iterator k = rPo->
rays.begin(); k != rPo->
rays.end();
655 Double_t lX = rPo->
x + ray->
tx * deltaZ;
656 Double_t lY = rPo->
y + ray->
ty * deltaZ;
659 TLine* yzLine =
new TLine(rPo->
z, rPo->
y, lZ, lY);
660 yzLine->SetLineColor(kRed);
664 TLine* xzLine =
new TLine(rPo->
z, rPo->
x, lZ, lX);
665 xzLine->SetLineColor(kRed);
669 TLine* yxLine =
new TLine(rPo->
x, rPo->
y, lX, lY);
670 yxLine->SetLineColor(kRed);
674 #endif //CLUSTER_MODE
695 #ifdef USE_KALMAN_FIT
696 bool kalmanDrawn =
false;
697 #endif //USE_KALMAN_FIT
699 for (
int j = 0; j < track->
length; ++j) {
709 Double_t deltaZ = lZ - rZ;
710 Double_t lX = rX + ray->
tx * deltaZ;
711 Double_t lY = rY + ray->
ty * deltaZ;
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
723 TLine* yzLineL =
new TLine(rZ, rY, lZ, lY);
724 yzLineL->SetLineColor(kBlue);
728 TLine* kalmanYZLine =
new TLine(kalmanZr, kalmanYr, kalmanZl, kalmanYl);
729 kalmanYZLine->SetLineColor(kBlack);
730 kalmanYZLine->Draw();
734 TLine* xzLineL =
new TLine(rZ, rX, lZ, lX);
735 xzLineL->SetLineColor(kBlue);
739 TLine* kalmanXZLine =
new TLine(kalmanZr, kalmanXr, kalmanZl, kalmanXl);
740 kalmanXZLine->SetLineColor(kBlack);
741 kalmanXZLine->Draw();
745 TLine* yxLineL =
new TLine(rX, rY, lX, lY);
746 yxLineL->SetLineColor(kBlue);
750 TLine* kalmanYXLine =
new TLine(kalmanXr, kalmanYr, kalmanXl, kalmanYl);
751 kalmanYXLine->SetLineColor(kBlack);
752 kalmanYXLine->Draw();
755 #ifdef USE_KALMAN_FIT
757 #endif //USE_KALMAN_FIT
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;
775 TLine* yzLine =
new TLine(lZ, lY, rZ, rY);
776 yzLine->SetLineColor(kPink);
780 TLine* xzLine =
new TLine(lZ, lX, rZ, rX);
781 xzLine->SetLineColor(kPink);
785 TLine* yxLine =
new TLine(lX, lY, rX, rY);
786 yxLine->SetLineColor(kPink);
805 int nhits = finder->
MCPoints.size();
806 Double_t x_poly[nhits], y_poly[nhits], z_poly[nhits];
810 for (vector<LxMCPoint>::iterator
i = finder->
MCPoints.begin();
815 x_poly[n_poly] = point.
x;
816 y_poly[n_poly] = point.
y;
817 z_poly[n_poly] = point.
z;
824 TPolyMarker* pmyz =
new TPolyMarker(n_poly, z_poly, y_poly);
825 pmyz->SetMarkerColor(mcolour);
826 pmyz->SetMarkerStyle(hitsMStyle);
827 pmyz->SetMarkerSize(HitSize);
833 TPolyMarker* pmxz =
new TPolyMarker(n_poly, z_poly, x_poly);
834 pmxz->SetMarkerColor(mcolour);
835 pmxz->SetMarkerStyle(hitsMStyle);
836 pmxz->SetMarkerSize(HitSize);
842 TPolyMarker* pmyx =
new TPolyMarker(n_poly, x_poly, y_poly);
843 pmyx->SetMarkerColor(mcolour);
844 pmyx->SetMarkerStyle(hitsMStyle);
845 pmyx->SetMarkerSize(HitSize);
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;
869 TLine* yzLine =
new TLine(lZ, lY, rZ, rY);
870 yzLine->SetLineColor(kPink);
874 TLine* xzLine =
new TLine(lZ, lX, rZ, rX);
875 xzLine->SetLineColor(kPink);
879 TLine* yxLine =
new TLine(lX, lY, rX, rY);
880 yxLine->SetLineColor(kPink);
893 system(
"mkdir LxDraw -p");