9 #include "TGNumberEntry.h"
13 #include "TPolyMarker.h"
14 #include "TVirtualX.h"
15 #include "TVirtualPadPainter.h"
17 #include "art/Framework/Services/Registry/ServiceHandle.h"
18 #include "cetlib_except/exception.h"
27 #include "nuevdb/EventDisplayBase/EventHolder.h"
28 #include "nuevdb/EventDisplayBase/View2D.h"
73 art::ServiceHandle<geo::Geometry const> geo;
78 Pad()->SetBit(TPad::kCannotMove);
81 Pad()->SetLeftMargin(0.080);
82 Pad()->SetRightMargin(0.010);
83 Pad()->SetTopMargin(0.010);
84 Pad()->SetBottomMargin(0.10);
94 for (
size_t i = 0; i < geo->NTPC(); ++i) {
95 double local[3] = {0., 0., 0.};
96 double world[3] = {0., 0., 0.};
99 if (minx > world[0] - geo->DetHalfWidth(i)) minx = world[0] - geo->DetHalfWidth(i);
100 if (maxx < world[0] + geo->DetHalfWidth(i)) maxx = world[0] + geo->DetHalfWidth(i);
101 if (miny > world[1] - geo->DetHalfHeight(i)) miny = world[1] - geo->DetHalfHeight(i);
102 if (maxy < world[1] + geo->DetHalfHeight(i)) maxy = world[1] + geo->DetHalfHeight(i);
103 if (minz > world[2] - geo->DetLength(i) / 2.) minz = world[2] - geo->DetLength(i) / 2.;
104 if (maxz < world[2] + geo->DetLength(i) / 2.) maxz = world[2] + geo->DetLength(i) / 2.;
108 TPCBox.push_back(TBox(world[0] - geo->DetHalfWidth(i),
109 world[1] - geo->DetHalfHeight(i),
110 world[0] + geo->DetHalfWidth(i),
111 world[1] + geo->DetHalfHeight(i)));
114 TPCBox.push_back(TBox(world[2] - geo->DetLength(i) / 2.,
115 world[0] - geo->DetHalfWidth(i),
116 world[2] + geo->DetLength(i) / 2.,
117 world[0] + geo->DetHalfWidth(i)));
120 TPCBox.push_back(TBox(world[2] - geo->DetLength(i) / 2.,
121 world[1] - geo->DetHalfHeight(i),
122 world[2] + geo->DetLength(i) / 2.,
123 world[1] + geo->DetHalfHeight(i)));
126 throw cet::exception(
"Ortho3DPad")
127 << __func__ <<
": unwknow projection " << ((int)proj) <<
"\n";
129 TPCBox.back().SetFillStyle(0);
130 TPCBox.back().SetLineStyle(2);
131 TPCBox.back().SetLineWidth(2);
132 TPCBox.back().SetLineColor(16);
155 throw cet::exception(
"Ortho3DPad")
156 << __func__ <<
": unwknow projection " << ((int)proj) <<
"\n";
162 fHisto->SetBit(kCannotPick);
163 fHisto->SetBit(TPad::kCannotMove);
164 fHisto->SetTitleOffset(1.,
"Y");
165 fHisto->SetTitleOffset(1.,
"X");
166 fHisto->GetXaxis()->SetLabelSize(0.04);
167 fHisto->GetXaxis()->SetTitleSize(0.04);
170 fHisto->GetXaxis()->SetTitle(
"x (cm)");
171 fHisto->GetYaxis()->SetTitle(
"y (cm)");
174 fHisto->GetXaxis()->SetTitle(
"z (cm)");
175 fHisto->GetYaxis()->SetTitle(
"x (cm)");
178 fHisto->GetXaxis()->SetTitle(
"z (cm)");
179 fHisto->GetYaxis()->SetTitle(
"y (cm)");
182 throw cet::exception(
"Ortho3DPad")
183 << __func__ <<
": unexpected flow (projection: " << ((int)proj) <<
")\n";
186 fHisto->GetXaxis()->CenterTitle();
187 fHisto->GetYaxis()->SetLabelSize(0.04);
188 fHisto->GetYaxis()->SetTitleSize(0.04);
189 fHisto->GetYaxis()->CenterTitle();
193 fView =
new evdb::View2D();
196 Pad()->SetFillColor(18);
197 Pad()->SetFrameFillColor(18);
198 Pad()->GetPainter()->SetFillColor(18);
204 std::ostringstream ostr;
205 ostr <<
"evd::Ortho3DPad::MouseEvent((evd::Ortho3DPad*)" <<
this <<
")";
206 fPad->AddExec(
"getmousezoom", ostr.str().c_str());
241 if (art::Event
const* evtPtr = evdb::EventHolder::Instance()->GetEvent()) {
242 auto const&
evt = *evtPtr;
243 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(
evt);
245 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt, clockData);
247 SimulationDraw()->MCTruthOrtho(
evt, fProj, fMSize, fView);
248 RecoBaseDraw()->SpacePointOrtho(
evt, fProj, fMSize, fView);
249 RecoBaseDraw()->PFParticleOrtho(
evt, fProj, fMSize, fView);
250 RecoBaseDraw()->ProngOrtho(
evt, fProj, fMSize, fView);
251 RecoBaseDraw()->SeedOrtho(
evt, fProj, fView);
252 RecoBaseDraw()->OpFlashOrtho(
evt, clockData,
detProp, fProj, fView);
253 RecoBaseDraw()->VertexOrtho(
evt, fProj, fView);
258 fPad->GetPainter()->SetFillColor(18);
262 latex.SetTextColor(16);
263 latex.SetTextSize(0.05);
264 for (
size_t i = 0; i < TPCBox.size(); ++i) {
266 double x1 = TPCBox[i].GetX2() - 0.02 * (fXHi - fXLo);
267 double y1 = TPCBox[i].GetY2() - 0.05 * (fYHi - fYLo);
268 for (
size_t j = 0; j < i; ++j) {
269 if (
std::abs(x1 - (TPCBox[j].GetX2() - 0.02 * (fXHi - fXLo))) < 1
e-6 &&
270 std::abs(y1 - (TPCBox[j].GetY2() - 0.05 * (fYHi - fYLo))) < 1
e-6) {
271 y1 -= 0.05 * (fYHi - fYLo);
274 latex.DrawLatex(x1, y1, Form(
"%lu", i));
287 fHisto->GetXaxis()->SetRangeUser(xlo, xhi);
288 fHisto->GetYaxis()->SetRangeUser(ylo, yhi);
302 fHisto->GetXaxis()->SetRangeUser(fXLo, fXHi);
303 fHisto->GetYaxis()->SetRangeUser(fYLo, fYHi);
308 SetMarkerSize(1.,
false);
324 if (fMSize != size / 4.) {
332 if (fMSizeEntry) fMSizeEntry->SetNumber(size);
337 TIter next(fPad->GetListOfPrimitives());
338 while (TObject* obj = next()) {
339 if (obj->InheritsFrom(TPolyMarker::Class())) {
340 TPolyMarker* pm = (TPolyMarker*)obj;
341 pm->SetMarkerSize(fMSize);
363 if (fMSizeEntry) fMSizeEntry->SetNumber(4. * fMSize);
376 if (!fMSizeEntry)
throw cet::exception(
"Ortho3DPad") << __func__ <<
": no MSize entry\n";
377 double val = fMSizeEntry->GetNumber();
382 SetMarkerSize(val,
true);
392 TObject* select = gPad->GetSelected();
394 if (!select->InheritsFrom(
"TBox"))
return;
395 ((TBox*)select)->SetBit(TBox::kCannotMove);
400 if (fMousePad != 0) p = fMousePad;
413 int event = gPad->GetEvent();
414 int px = gPad->GetEventX();
415 int py = gPad->GetEventY();
416 double x = gPad->AbsPixeltoX(px);
417 double y = gPad->AbsPixeltoY(py);
426 gPad->SetCursor(kCross);
436 gPad->SetCursor(kCross);
483 gPad->SetCursor(kCross);
490 double pxlo = std::min(fPressPx, fCurrentPx);
491 double pxhi = std::max(fPressPx, fCurrentPx);
492 double pylo = std::min(fPressPy, fCurrentPy);
493 double pyhi = std::max(fPressPy, fCurrentPy);
494 gVirtualX->DrawBox(pxlo, pylo, pxhi, pyhi, TVirtualX::kHollow);
500 gVirtualX->SetLineColor(-1);
501 gVirtualX->SetLineStyle(0);
502 gVirtualX->SetLineWidth(1);
507 gPad->SetCursor(kCross);
524 gPad->SetCursor(kCross);
531 double xlo = std::min(fPressX, fReleaseX);
532 double xhi = std::max(fPressX, fReleaseX);
533 double ylo = std::min(fPressY, fReleaseY);
534 double yhi = std::max(fPressY, fReleaseY);
535 SetZoom(xlo, ylo, xhi, yhi,
true);
void SetZoom(double xlo, double ylo, double xhi, double yhi, bool update)
process_name opflash particleana ie x
void SetMarkerSize(double size, bool update)
void SetMSizeEntry(TGNumberEntry *p)
Geometry information for a single TPC.
A drawing pad showing an orthographic rendering of 3D objects.
std::size_t size(FixedBins< T, C > const &) noexcept
process_name opflash particleana ie ie y
Base class for event display drawing pads.
Drawing pad showing an orthographic projection of 3D objects in the detector.
Ortho3DPad(const char *nm, const char *ti, evd::OrthoProj_t proj, double x1, double y1, double x2, double y2)
Class to aid in the rendering of RecoBase objects.
std::vector< TBox > TPCBox
TPC box.
process_name physics producers generator physics producers generator physics producers generator py
Render the objects from the Simulation package.
TH1F * fHisto
Enclosing histogram.
TPad * fPad
The ROOT graphics pad.
static void MouseEvent(evd::Ortho3DPad *p)
static Ortho3DPad * fMousePad
Selected pad for mouse action.
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
evdb::View2D * fView
Collection of graphics objects to render.
art framework interface to geometry description
void Draw(const char *opt=0)
Encapsulate the construction of a single detector plane.