LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TWQMultiTPCProjection.cxx
Go to the documentation of this file.
1 //
6 
7 #include "Buttons.h"
8 #include "TCanvas.h"
9 #include "TFrame.h"
10 #include "TGFrame.h" // For TGMainFrame, TGHorizontalFrame
11 #include "TGLabel.h"
12 #include "TGLayout.h" // For TGLayoutHints
13 #include "TGNumberEntry.h"
14 #include "TGTextView.h"
15 #include "TMath.h"
16 #include "TROOT.h"
17 #include "TRootEmbeddedCanvas.h"
18 #include "TString.h"
19 #include "TVirtualX.h"
20 
38 
41 
42 namespace evd {
43 
44  static unsigned int kPlane;
45  static unsigned int kWire;
46  static double kDistance;
47  static int curr_zooming_plane;
48  static const char* zoom_opt = 0;
49 
50  static int shift_lock;
51 
52  //......................................................................
54  {
55 
57 
58  // first make pads for things that don't depend on the number of
59  // planes in the detector
60  // bottom left corner is (0.,0.), top right is (1., 1.)
61 
63  fHeaderPad = new HeaderPad("fHeaderPadMultiTPC", "Header", 0.0, 0.0, 0.15, 0.13, "");
64  fHeaderPad->Draw();
65 
67  fMC = new MCBriefPad("fMCPadMultiTPC", "MC Info.", 0.15, 0.13, 1.0, 0.17, "");
68  fMC->Draw();
69 
71  fWireQ = new TQPad("fWireQPadMultiTPC", "ADCvsTime", 0.15, 0.0, 1.0, 0.13, "TQ", 0, 0);
72  fWireQ->Pad()->SetBit(TPad::kCannotMove, true);
73  fWireQ->Draw();
74 
75  // add new "meta frame" to hold the GUI Canvas and a side frame (vframe)
76  fMetaFrame = new TGCompositeFrame(mf, 60, 60, kHorizontalFrame);
77  fMetaFrame->SetBit(TPad::kCannotMove, true);
78 
79  //new frame organizing the buttons on the left of the canvas.
80  fVFrame = new TGCompositeFrame(fMetaFrame, 60, 60, kVerticalFrame);
81  // Define a layout for placing the canvas within the frame.
82  fLayout =
83  new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5);
84 
85  mf->RemoveFrame((TGFrame*)fEmbCanvas);
86  mf->RemoveFrame(fFrame);
87 
88  fEmbCanvas->ReparentWindow(fMetaFrame, fXsize, fYsize);
89 
90  fMetaFrame->AddFrame(fVFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY));
91  fMetaFrame->AddFrame(fEmbCanvas, fLayout);
92 
93  mf->AddFrame(fMetaFrame, fLayout);
94  mf->AddFrame(fFrame);
95 
96  // plane number entry
97  fPlaneEntry = new TGNumberEntry(fFrame,
98  0,
99  2,
100  -1,
101  TGNumberFormat::kNESInteger,
102  TGNumberFormat::kNEAAnyNumber,
103  TGNumberFormat::kNELLimitMinMax,
104  0,
105  geo->Nplanes() - 1);
106 
107  kPlane = 0;
108  constexpr geo::PlaneID planeid{0, 0, 0};
109  kWire = TMath::Nint(0.5 * geo->Nwires(planeid));
110  kDistance = 1.5;
111  fWireQ->SetPlaneWire(kPlane, kWire);
112 
113  // Initial value
114  fPlaneEntry->SetNumber(kPlane);
115 
116  // There are two "signals" to which a TGNumberEntry may respond:
117  // when the user clicks on the arrows, or when the user types in a
118  // new number in the text field.
119  fPlaneEntry->Connect("ValueSet(Long_t)", "evd::TWQMultiTPCProjectionView", this, "SetPlane()");
120  fPlaneEntry->GetNumberEntry()->Connect(
121  "ReturnPressed()", "evd::TWQMultiTPCProjectionView", this, "SetPlane()");
122  // Text label for this numeric field.
123  fPlaneLabel = new TGLabel(fFrame, "Plane");
124 
125  // wire number entry
126  fWireEntry = new TGNumberEntry(fFrame,
127  0,
128  6,
129  -1,
130  TGNumberFormat::kNESInteger,
131  TGNumberFormat::kNEAAnyNumber,
132  TGNumberFormat::kNELLimitMinMax,
133  0,
134  geo->Nwires(planeid) - 1);
135  // Initial value
136  fWireEntry->SetNumber(kWire);
137 
138  // There are two "signals" to which a TGNumberEntry may respond:
139  // when the user clicks on the arrows, or when the user types in a
140  // new number in the text field.
141  fWireEntry->Connect("ValueSet(Long_t)", "evd::TWQMultiTPCProjectionView", this, "SetWire()");
142  fWireEntry->GetNumberEntry()->Connect(
143  "ReturnPressed()", "evd::TWQMultiTPCProjectionView", this, "SetWire()");
144 
145  // Text label for this numeric field.
146  fWireLabel = new TGLabel(fFrame, "Wire");
147 
148  // adc threshold number entry
149  fThresEntry = new TGNumberEntry(fFrame,
150  0,
151  6,
152  -1,
153  TGNumberFormat::kNESInteger,
154  TGNumberFormat::kNEAAnyNumber,
155  TGNumberFormat::kNELLimitMinMax,
156  0,
157  geo->Nwires(planeid) - 1);
158  // Initial value
163 
164  fThresEntry->SetNumber(rawopt->fMinSignal);
165 
166  // There are two "signals" to which a TGNumberEntry may respond:
167  // when the user clicks on the arrows, or when the user types in a
168  // new number in the text field.
169  fThresEntry->Connect(
170  "ValueSet(Long_t)", "evd::TWQMultiTPCProjectionView", this, "SetThreshold()");
171  fThresEntry->GetNumberEntry()->Connect(
172  "ReturnPressed()", "evd::TWQMultiTPCProjectionView", this, "SetThreshold()");
173 
174  // Text label for this numeric field.
175  fThresLabel = new TGLabel(fFrame, "ADC Threshold");
176 
177  // check button to toggle color vs grey
178  fGreyScale = new TGCheckButton(fFrame, "Grayscale", 1);
179  fGreyScale->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetGreyscale()");
180  if (cst->fColorOrGray == 1) fGreyScale->SetState(kButtonDown);
181 
182  // check button to toggle MC information
183  if (evdlayoutopt->fEnableMCTruthCheckBox) {
184  fMCOn = new TGCheckButton(fFrame, "MC Truth", 5);
185  fMCOn->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetMCInfo()");
186  if (sdo->fShowMCTruthText == 1) fMCOn->SetState(kButtonDown);
187  }
188 
189  // radio buttons to toggle drawing raw vs calibrated information
190  fRawCalibDraw = new TGRadioButton(fFrame, "Both", 2);
191  fCalibDraw = new TGRadioButton(fFrame, "Reconstructed", 3);
192  fRawDraw = new TGRadioButton(fFrame, "Raw", 4);
193  fRawDraw->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetRawCalib()");
194  fCalibDraw->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetRawCalib()");
195  fRawCalibDraw->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetRawCalib()");
196  if (rawopt->fDrawRawDataOrCalibWires == 0)
197  fRawDraw->SetState(kButtonDown);
198  else if (rawopt->fDrawRawDataOrCalibWires == 1)
199  fCalibDraw->SetState(kButtonDown);
200  else if (rawopt->fDrawRawDataOrCalibWires == 2)
201  fRawCalibDraw->SetState(kButtonDown);
202 
203  // Put all these widgets into the frame. The last
204  // four numbers in each TGLayoutHint are padleft, padright,
205  // padtop, padbottom.
206  if (evdlayoutopt->fEnableMCTruthCheckBox) {
207  fFrame->AddFrame(fMCOn, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
208  }
209  fFrame->AddFrame(fGreyScale, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
210  fFrame->AddFrame(fRawCalibDraw, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
211  fFrame->AddFrame(fCalibDraw, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
212  fFrame->AddFrame(fRawDraw, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
213  fFrame->AddFrame(fPlaneEntry, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1));
214  fFrame->AddFrame(fPlaneLabel, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
215  fFrame->AddFrame(fWireEntry, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1));
216  fFrame->AddFrame(fWireLabel, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
217  fFrame->AddFrame(fThresEntry, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1));
218  fFrame->AddFrame(fThresLabel, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1));
219 
220  if (evdlayoutopt->fShowSideBar)
221  SetUpSideBar();
222  else
223  evdlayoutopt->fShowEndPointSection =
224  0; // zero it to avoid a misconfiguration in the fcl file.
225 
226  //zero the ppoints queue.
227  ppoints.clear();
228  pline.clear();
229 
230  // geometry to figure out the number of TPCs
231  unsigned int ntpc = geo->NTPC();
232 
233  // geometry to figure out the number of planes
234  unsigned int nplanes = geo->Nplanes();
235 
236  // now determine the positions of all the time vs wire number
237  // and charge histograms for the planes
238  for (unsigned int t = 0; t < ntpc; ++t) {
239  for (unsigned int i = 0; i < nplanes; ++i) {
240  double twx1 = 0. + t * 0.97 / (1. * ntpc);
241  double twx2 = t * 0.97 / (1. * ntpc);
242  double twx3 = 1.0;
243  double twy1 = 0.17 + (i) * (1.0 - 0.171) / (1. * nplanes);
244  double twy2 = 0.17 + (i + 1) * (1.0 - 0.171) / (1. * nplanes);
245 
246  TString padname = "fWireProjTPC";
247  padname += t;
248  padname += "Plane";
249  padname += i;
250 
251  TString padtitle = "TPC";
252  padtitle += t;
253  padtitle += "Plane";
254  padtitle += i;
255 
256  evdb::Canvas::fCanvas->cd();
257 
258  mf::LogVerbatim("MultiTPC") << "make new plane ";
259  fPlanes.push_back(
260  new TWireProjPad(padname, padtitle, twx1, twy1, twx2, twy2, i + t * nplanes));
261  fPlanes.back()->Draw();
262  // fPlanes.back()->Pad()->AddExec("mousedispatch",
263  // Form("evd::TWQMultiTPCProjectionView::MouseDispatch(%d, (void*)%d)",
264  // i+t*nplanes, this)
265  // );
266  fPlanes.back()->Pad()->AddExec(
267  "mousedispatch",
268  Form("evd::TWQMultiTPCProjectionView::MouseDispatch(%d, (void*)%lu)",
269  i + t * nplanes,
270  (unsigned long)this));
271 
272  mf::LogVerbatim("MultiTPC") << "size of planes vec is now " << fPlanes.size();
273 
274  if (t + 1 == ntpc) {
275  padname = "fQPadTPC";
276  padname += t;
277  padname += "Plane";
278  padname += i;
279 
280  padtitle = "QTPC";
281  padtitle += t;
282  padname += "Plane";
283  padname += i;
284 
285  evdb::Canvas::fCanvas->cd();
286  fPlaneQ.push_back(new TQPad(padname, padtitle, twx2, twy1, twx3, twy2, "Q", i, 0));
287  fPlaneQ[i]->Draw();
288  }
289  } // end loop to draw pads
290  }
291 
292  evdb::Canvas::fCanvas->Update();
293  }
294 
295  //......................................................................
297  {
298  if (fHeaderPad) {
299  delete fHeaderPad;
300  fHeaderPad = 0;
301  }
302  if (fMC) {
303  delete fMC;
304  fMC = 0;
305  }
306  if (fWireQ) {
307  delete fWireQ;
308  fWireQ = 0;
309  }
310  if (fPlaneEntry) {
311  delete fPlaneEntry;
312  fPlaneEntry = 0;
313  }
314  if (fWireEntry) {
315  delete fWireEntry;
316  fWireEntry = 0;
317  }
318  if (fPlaneLabel) {
319  delete fPlaneLabel;
320  fPlaneLabel = 0;
321  }
322  if (fWireLabel) {
323  delete fWireLabel;
324  fWireLabel = 0;
325  }
326  for (unsigned int i = 0; i < fPlanes.size(); ++i) {
327  if (fPlanes[i]) {
328  delete fPlanes[i];
329  fPlanes[i] = 0;
330  }
331  if (fPlaneQ[i]) {
332  delete fPlaneQ[i];
333  fPlaneQ[i] = 0;
334  }
335  }
336  fPlanes.clear();
337  fPlaneQ.clear();
338  }
339 
340  //......................................................................
341  void TWQMultiTPCProjectionView::DrawPads(const char* /*opt*/)
342  {
343  for (unsigned int i = 0; i < fPlanes.size(); ++i) {
344  fPlanes[i]->Draw();
345  fPlanes[i]->Pad()->Update();
346  fPlanes[i]->Pad()->GetFrame()->SetBit(TPad::kCannotMove, true);
347  }
348  for (unsigned int j = 0; j < fPlaneQ.size(); ++j) {
349  fPlaneQ[j]->Draw();
350  fPlaneQ[j]->Pad()->Update();
351  fPlaneQ[j]->Pad()->GetFrame()->SetBit(TPad::kCannotMove, true);
352  }
353  }
354  //......................................................................
355  void TWQMultiTPCProjectionView::Draw(const char* opt)
356  {
358 
359  fPrevZoomOpt.clear();
360 
361  evdb::Canvas::fCanvas->cd();
362  zoom_opt = 0;
363  fHeaderPad->Draw();
364  fMC->Draw();
365  fWireQ->Draw();
366 
368 
369  if (evdlayoutopt->fPrintTotalCharge) PrintCharge();
370 
371  //clear queue of selected points
372  ppoints.clear();
373  pline.clear();
374  // Reset current zooming plane - since it's not currently zooming.
375  curr_zooming_plane = -1;
376 
377  // double Charge=0, ConvCharge=0;
378  for (size_t i = 0; i < fPlanes.size(); ++i) {
379  fPlanes[i]->Draw(opt);
380  fPlanes[i]->Pad()->Update();
381  fPlanes[i]->Pad()->GetFrame()->SetBit(TPad::kCannotMove, true);
382  fPlaneQ[i]->Draw();
383  std::vector<double> ZoomParams = fPlanes[i]->GetCurrentZoom();
384  fZoomOpt.wmin[i] = ZoomParams[0];
385  fZoomOpt.wmax[i] = ZoomParams[1];
386  fZoomOpt.tmin[i] = ZoomParams[2];
387  fZoomOpt.tmax[i] = ZoomParams[3];
388  }
389 
390  // Reset any text boxes which are enabled
391  if (fXYZPosition) fXYZPosition->SetForegroundColor(kBlack);
392 
393  if (fAngleInfo) fAngleInfo->SetForegroundColor(kBlack);
394 
395  evdb::Canvas::fCanvas->Update();
396  }
397 
398  // comment out this method as for now we don't want to change every
399  // plane to have the same range in wire number because wire numbers
400  // don't necessarily overlap from plane to plane, ie the same range
401  // isn't appropriate for every plane
402  //......................................................................
403  // void TWQMultiTPCProjectionView::RangeChanged()
404  // {
405  // static int ilolast = -1;
406  // static int ihilast = -1;
407  //
408  // int ilo;
409  // int ihi;
410  // std::vector<int> lo;
411  // std::vector<int> hi;
412  // std::vector<bool> axischanged;
413  // for(unsigned int i = 0; i < fPlanes.size(); ++i){
414  // fPlanes[i]->GetWireRange(&ilo, &ihi);
415  // lo.push_back(ilo);
416  // hi.push_back(ihi);
417  // axischanged.push_back((ilo != ilolast) || (ihi != ihilast));
418  // }
419  //
420  // TVirtualPad* ori = gPad;
421  //
422  // // loop over the bools to see which axes need to change
423  // for(unsigned int i = 0; i < axischanged.size(); ++i){
424  // if (axischanged[i]) {
425  // fPlanes[i]->SetWireRange(ilo, ihi);
426  // fPlanes[i]->Pad()->cd();
427  // fPlanes[i]->Pad()->Modified();
428  // fPlanes[i]->Pad()->Update();
429  //
430  // ilolast = ilo;
431  // ihilast = ihi;
432  // }
433  // }
434  //
435  // evdb::Canvas::fCanvas->cd();
436  // evdb::Canvas::fCanvas->Modified();
437  // evdb::Canvas::fCanvas->Update();
438  // ori->cd();
439  // }
440  //......................................................................
441  //......................................................................
443  {
444 
447 
448  geo::TPCID tpcid = rawopt->CurrentTPC();
449 
450  for (size_t iplane = 0; iplane < fPlanes.size(); ++iplane) {
451  if (geo->SignalType(geo::PlaneID(tpcid, iplane)) == geo::kCollection) {
452  double ch = 0, convch = 0;
453  if (rawopt->fDrawRawDataOrCalibWires == 0) {
454  fPlanes[iplane]->RawDataDraw()->GetChargeSum(iplane, ch, convch);
455  mf::LogVerbatim("TWQMultiTPCProjectionView") << "Warning! Calculating for RawData! ";
456  }
457  else {
458  fPlanes[iplane]->RecoBaseDraw()->GetChargeSum(iplane, ch, convch);
459  }
460 
461  mf::LogVerbatim("TWQMultiTPCProjectionView")
462  << "\ncharge collected at collection plane: " << iplane << " " << ch << " " << convch;
463  }
464  }
465  }
466 
467  //-------------------------------------------------------------------
468  //......................................................................
469  void TWQMultiTPCProjectionView::MouseDispatch(int plane, void* wqpv)
470  {
471  //initial check for a mouse click on a TBox object
472  int event = gPad->GetEvent();
475 
476  switch (event) {
477 
478  case kButton1Shift:
479  shift_lock = 1;
480  // TWQMultiTPCProjectionView::SelectHit() is undefined
481  //if(evdlayoutopt->fMakeClusters==1){wqpp->SelectHit(plane);}
482  //else {wqpp->SelectPoint(plane);}
483  wqpp->SelectPoint(plane);
484  break;
485  case kButton1Up:
486  if (shift_lock == 1) break;
487  if (evdlayoutopt->fChangeWire == 1) wqpp->ChangeWire(plane);
488  case kButton1Down: shift_lock = 0;
489  case kButton1Motion:
490  wqpp->SetMouseZoomRegion(plane);
491  break;
492  // default:
493  }
494  }
495 
496  //......................................................................
498  {
499  //initial check for a mouse click on a TBox object
500  int event = gPad->GetEvent();
501  int px = gPad->GetEventX();
502  if (event != 11) return;
503  TObject* select = gPad->GetSelected();
504  if (!select) return;
505  if (!select->InheritsFrom("TBox")) return;
506 
507  //now find wire that was clicked on
508  float xx = gPad->AbsPixeltoX(px);
509  float x = gPad->PadtoX(xx);
510 
511  kPlane = plane;
512  kWire = (unsigned int)TMath::Nint(x);
513 
514  this->SetPlaneWire();
515 
516  return;
517  }
518 
519  //......................................................................
521  {
522  //initial check for a mouse click on a TBox object
523  int event = gPad->GetEvent();
524 
525  if (event != 7) return;
526 
528  if (evdlayoutopt->fShowEndPointSection != 1) return;
529  //struct planepoint;
530  int px = gPad->GetEventX();
531  double w0 = gPad->AbsPixeltoX(px);
532  double x = gPad->PadtoX(w0);
533 
534  int py = gPad->GetEventY();
535  double t0 = gPad->AbsPixeltoY(py);
536  double y = gPad->PadtoY(t0);
537 
538  util::PxPoint ppx(plane, x, y);
539  curr_zooming_plane = -1;
540 
541  // check if not clicking on a plane that is already in the ppoints list:
542  int repeat_plane = -1;
543  for (size_t ii = 0; ii < this->ppoints.size(); ++ii)
544  if (ppx.plane == this->ppoints[ii].plane) {
545  this->ppoints[ii] = ppx;
546  //clear View and draw new Marker
547  this->fPlanes[this->ppoints[ii].plane]->View()->Clear();
548  if (evdlayoutopt->fShowEndPointMarkers)
549  this->fPlanes[this->ppoints[ii].plane]->View()->AddMarker(ppx.w, ppx.t, kRed, 29, 2.0);
550  else
551  this->fPlanes[plane]->View()->AddMarker(0.0, 0.0, 2, 1, 0.1);
552  this->fPlanes[this->ppoints[ii].plane]->View()->Draw();
553  repeat_plane = this->ppoints[ii].plane;
554  break;
555  }
556 
557  //if plane does not repeat and size of list is larger than 2 pop_front
558  // and delete its marker. Otherwise just push_back.
559  if (repeat_plane == -1) {
560  if (this->ppoints.size() >= 2) {
561  this->fPlanes[this->ppoints[0].plane]->Pad()->cd();
562  this->fPlanes[this->ppoints[0].plane]->View()->Clear();
563  this->fPlanes[this->ppoints[0].plane]->View()->Draw();
564  this->ppoints.pop_front();
565  }
566  this->ppoints.push_back(ppx);
567  this->fPlanes[plane]->Pad()->cd();
568  this->fPlanes[plane]->View()->Clear();
569  if (evdlayoutopt->fShowEndPointMarkers)
570  this->fPlanes[plane]->View()->AddMarker(ppx.w, ppx.t, kRed, 29, 2.0);
571  else
572  this->fPlanes[plane]->View()->AddMarker(0.0, 0.0, 2, 1, 0.1);
573  this->fPlanes[plane]->View()->Draw();
574  }
575 
576  return;
577  }
578 
579  //......................................................................
581  {
582  for (size_t x = 0; x < fPlanes.size(); ++x) {
583  fPlanes[x]->Pad()->cd();
584  fPlanes[x]->View()->Clear();
585  fPlanes[x]->View()->AddMarker(0.0, 0.0, 2, 1, 0.1);
586  fPlanes[x]->Pad()->Update();
587  fPlanes[x]->View()->Draw();
588  }
589  ppoints.clear();
590  gPad->Modified();
591  gPad->Update();
592  gPad->cd();
593  }
594 
595  //......................................................................
597  detinfo::DetectorPropertiesData const& detProp)
598  {
599  // if list is larger than or equal to two, can project to XYZ and extrapolate to third plane (if exists)
600 
601  if (pline.size() >= 2) {
602 
603  double xyz_vertex_fit[3];
604  double second_time;
605  double xx0 = 0., yy0 = 0., zz0 = 0.;
606  double xx1 = 0., yy1 = 0., zz1 = 0.;
607  double length;
608 
609  double y, z;
610 
613  double ftimetick = sampling_rate(clockData) / 1000.;
614  double larv = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
615 
616  //find channels corresponding to found wires.
617  geo::TPCID const tpcid{rawOpt->fCryostat, rawOpt->fTPC};
618  geo::PlaneID const plane_0{tpcid, pline[0].plane};
619  geo::PlaneID const plane_1{tpcid, pline[1].plane};
620  int chan1 = geom->PlaneWireToChannel(geo::WireID(plane_0, pline[0].w0));
621  int chan2 = geom->PlaneWireToChannel(geo::WireID(plane_1, pline[1].w0));
622 
623  bool wires_cross = false;
624  bool time_good = false;
625 
626  if (fabs(pline[0].t0 - pline[1].t0) < 200) {
627  wires_cross = geom->ChannelsIntersect(chan1, chan2, y, z);
628  time_good = true;
629  }
630  else {
631  TGText* tt = new TGText("too big");
632  tt->InsLine(1, "time distance");
633  fXYZPosition->SetText(tt);
634  fXYZPosition->Update();
635  // return; //not returning, because may need to delete marker from wplane
636  }
637 
638  if (wires_cross) {
639  TGText* tt = new TGText("wires cross");
640  fXYZPosition->SetText(tt);
641  fXYZPosition->Update();
642  xyz_vertex_fit[1] = y;
643  xyz_vertex_fit[2] = z;
644  auto pos = geom->Plane(plane_0).GetBoxCenter();
645  xyz_vertex_fit[0] = (pline[0].t0 - trigger_offset(clockData)) * larv * ftimetick + pos.X();
646  pos = geom->Plane(plane_1).GetBoxCenter();
647  second_time = (pline[1].t0 - trigger_offset(clockData)) * larv * ftimetick + pos.X();
648 
649  xx0 = (xyz_vertex_fit[0] + second_time) / 2;
650  yy0 = y;
651  zz0 = z;
652 
654  }
655  else {
656  if (time_good) { //otherwise the wires_cross are false by default
657  TGText* tt = new TGText("cross");
658  tt->InsLine(1, "wires do not");
659  fXYZPosition->SetText(tt);
660  fXYZPosition->Update();
661  }
662  // return; //not returning, because may need to delete marker from wplanereturn;
663  }
664  //find channels corresponding to found wires AT END OF LINE.
665  chan1 = geom->PlaneWireToChannel(geo::WireID(plane_0, pline[0].w1));
666  chan2 = geom->PlaneWireToChannel(geo::WireID(plane_1, pline[1].w1));
667 
668  wires_cross = false;
669  time_good = false;
670 
671  if (fabs(pline[0].t1 - pline[1].t1) < 200) {
672  wires_cross = geom->ChannelsIntersect(chan1, chan2, y, z);
673  time_good = true;
674  }
675  else {
676  TGText* tt = new TGText("too big");
677  tt->InsLine(1, "time distance");
678  fXYZPosition->SetText(tt);
679  fXYZPosition->Update();
680  // return; //not returning, because may need to delete marker from wplane
681  }
682 
683  if (wires_cross) {
684  TGText* tt = new TGText("wires do cross");
685  fXYZPosition->SetText(tt);
686  fXYZPosition->Update();
687  xyz_vertex_fit[1] = y;
688  xyz_vertex_fit[2] = z;
689  constexpr geo::TPCID tpcid{0, 0};
690  auto pos = geom->Plane(geo::PlaneID(tpcid, pline[0].plane)).GetBoxCenter();
691  xyz_vertex_fit[0] = (pline[0].t1 - trigger_offset(clockData)) * larv * ftimetick + pos.X();
692  pos = geom->Plane(geo::PlaneID(tpcid, pline[1].plane)).GetBoxCenter();
693  second_time = (pline[1].t1 - trigger_offset(clockData)) * larv * ftimetick + pos.X();
694 
695  xx1 = (xyz_vertex_fit[0] + second_time) / 2;
696  yy1 = y;
697  zz1 = z;
698  }
699  else {
700  if (time_good) { //otherwise the wires_cross are false by default
701  TGText* tt = new TGText("cross");
702  tt->InsLine(1, "wires do not");
703  fXYZPosition->SetText(tt);
704  fXYZPosition->Update();
705  }
706  // return; //not returning, because may need to delete marker from wplanereturn;
707  }
708  //update pad?
709  gPad->Modified();
710  gPad->Update();
711  gPad->cd();
712 
713  length = pow(xx0 - xx1, 2) + pow(yy0 - yy1, 2) + pow(zz0 - zz1, 2);
714  length = pow(length, 0.5);
715  return length;
716  } // end if( this->ppoints.size()>=2)
717 
718  else {
719  TGText* tt = new TGText("selected points");
720  tt->InsLine(1, "not enough");
721  fXYZPosition->SetText(tt);
722  fXYZPosition->Update();
723  }
724 
725  return -99;
726  }
727 
728  //......................................................................
730  {
731  art::Event const* pEvent = evdb::EventHolder::Instance()->GetEvent();
732  if (not pEvent) {
733  std::cerr << "No event available\n";
734  return;
735  }
736 
737  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(*pEvent);
738  auto const detProp =
739  art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(*pEvent, clockData);
740 
741  // if list is larger than or equal to two, can project to XYZ and extrapolate to third plane (if exists)
742 
743  if (ppoints.size() >= 2) {
744 
745  double xyz_vertex_fit[3] = {0.};
746  double second_time = 0.;
747  geo::PlaneGeo::LocalPoint_t const origin{0., 0., 0.};
748  double y = 0.;
749  double z = 0.;
750 
753  double ftimetick = sampling_rate(clockData) / 1000.;
754  double larv = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
755 
756  geo::TPCID const tpcid{rawOpt->fCryostat, rawOpt->fTPC};
757  geo::PlaneID const plane_0{tpcid, ppoints[0].plane};
758  geo::PlaneID const plane_1{tpcid, ppoints[1].plane};
759 
760  //find channels corresponding to found wires.
761  int chan1 = geom->PlaneWireToChannel(geo::WireID(plane_0, ppoints[0].w));
762  int chan2 = geom->PlaneWireToChannel(geo::WireID(plane_1, ppoints[1].w));
763 
764  bool wires_cross = false;
765  bool time_good = false;
766 
767  if (fabs(ppoints[0].t - ppoints[1].t) < 200) {
768  wires_cross = geom->ChannelsIntersect(chan1, chan2, y, z);
769  time_good = true;
770  }
771  else {
772  TGText* tt = new TGText("too big");
773  tt->InsLine(1, "time distance");
774  fXYZPosition->SetText(tt);
775  fXYZPosition->Update();
776  // return; //not returning, because may need to delete marker from wplane
777  }
778 
779  if (wires_cross) {
780  xyz_vertex_fit[1] = y;
781  xyz_vertex_fit[2] = z;
782  auto pos = geom->Plane(plane_0).toWorldCoords(origin);
783  xyz_vertex_fit[0] = (ppoints[0].t - trigger_offset(clockData)) * larv * ftimetick + pos.X();
784  pos = geom->Plane(plane_1).toWorldCoords(origin);
785  second_time = (ppoints[1].t - trigger_offset(clockData)) * larv * ftimetick + pos.X();
786 
787  TGText* tt = new TGText(Form("z:%4.1f", z));
788  tt->InsLine(1, Form("x:%4.1f,", (xyz_vertex_fit[0] + second_time) / 2));
789  tt->InsLine(1, Form("y:%4.1f,", y));
790  fXYZPosition->SetText(tt);
791  fXYZPosition->Update();
793  }
794  else {
795  if (time_good) { //otherwise the wires_cross are false by default
796  TGText* tt = new TGText("cross");
797  tt->InsLine(1, "wires do not");
798  fXYZPosition->SetText(tt);
799  fXYZPosition->Update();
800  }
801  // return; //not returning, because may need to delete marker from wplanereturn;
802  }
803  // extrapolate third point only if there are enough planes
804  if (fPlanes.size() > 2) {
805 
806  unsigned int wplane = 0;
807  unsigned int wirevertex = 0;
809 
810  for (size_t xx = 0; xx < fPlanes.size(); ++xx) {
811  wplane = 0;
812  for (int yy = 0; yy < 2; ++yy)
813  if (ppoints[yy].plane == xx) ++wplane;
814 
815  if (!wplane) {
816  wplane = xx;
817  break;
818  }
819  }
820 
821  geo::PlaneID const planeID{tpcid, wplane};
822  auto pos = geom->Plane(planeID).toWorldCoords(origin);
823  pos.SetY(xyz_vertex_fit[1]);
824  pos.SetZ(xyz_vertex_fit[2]);
825 
826  wirevertex = geom->NearestWireID(pos, planeID).Wire;
827 
828  double drifttick =
829  ((xyz_vertex_fit[0]) / detProp.DriftVelocity(detProp.Efield(), detProp.Temperature())) *
830  (1. / ftimetick);
831  double timestart =
832  drifttick -
833  (pos.X() / detProp.DriftVelocity(detProp.Efield(), detProp.Temperature())) *
834  (1. / ftimetick) +
835  trigger_offset(clockData);
836 
837  fPlanes[wplane]->Pad()->cd();
838  fPlanes[wplane]->View()->Clear();
839  if (wires_cross && evdlayoutopt->fShowEndPointMarkers) //only Draw if it makes sense
840  fPlanes[wplane]->View()->AddMarker(wirevertex, timestart, kMagenta, 29, 2.0);
841  else //draw dummy marker to delete old one
842  fPlanes[wplane]->View()->AddMarker(0.0, 0.0, 2, 1, 0.1);
843  fPlanes[wplane]->Pad()->Update();
844  fPlanes[wplane]->View()->Draw();
845  } // end if(fPlanes.size()>2)
846  //update pad?
847  gPad->Modified();
848  gPad->Update();
849  gPad->cd();
850  } // end if( this->ppoints.size()>=2)
851  else {
852  TGText* tt = new TGText("selected points");
853  tt->InsLine(1, "not enough");
854  fXYZPosition->SetText(tt);
855  fXYZPosition->Update();
856  }
857 
858  return;
859  }
860 
861  //.......................................................................
863  {
864  //*-*-*-*-*-*-*-*-*-*-*Create a new arrow in this pad*-*-*-*-*-*-*-*-*-*-*-*-*
865  //*-* ==============================
866  //
867  TObject* select = gPad->GetSelected();
868  if (!select) return;
869  if (!select->InheritsFrom("TBox")) return;
870 
871  static Float_t w0 = -1, t0 = -1, w1 = -1, t1 = -1;
872 
873  static Int_t pxold, pyold;
874  static Int_t pw0, pt0;
875  static Int_t linedrawn;
876  //static int curr_plane;
877  //TLine *line;
878 
879  static int wstart, wend;
880  static float tstart, tend;
881 
882  int event = gPad->GetEvent();
883  int px = gPad->GetEventX();
884  int py = gPad->GetEventY();
885 
886  switch (event) {
887 
888  case kButton1Down: {
889  gVirtualX->SetLineColor(-1);
890  w0 = gPad->AbsPixeltoX(px);
891  t0 = gPad->AbsPixeltoY(py);
892  pw0 = px;
893  pt0 = py;
894  pxold = px;
895  pyold = py;
896  linedrawn = 0;
897  float x = gPad->PadtoX(w0);
898  tstart = gPad->PadtoY(t0);
899 
900  wstart = (unsigned int)TMath::Nint(x);
901  curr_zooming_plane = plane;
902  break;
903  }
904  case kButton1Motion: {
905  int lx, hx, ly, hy;
906  if (pw0 < pxold) {
907  lx = pw0;
908  hx = pxold;
909  }
910  else {
911  lx = pxold;
912  hx = pw0;
913  }
914 
915  if (pt0 < pyold) {
916  ly = pt0;
917  hy = pyold;
918  }
919  else {
920  ly = pyold;
921  hy = pt0;
922  }
923 
924  if (linedrawn) gVirtualX->DrawBox(lx, ly, hx, hy, TVirtualX::kHollow);
925  pxold = px;
926  pyold = py;
927  linedrawn = 1;
928 
929  if (pw0 < pxold) {
930  lx = pw0;
931  hx = pxold;
932  }
933  else {
934  lx = pxold;
935  hx = pw0;
936  }
937 
938  if (pt0 < pyold) {
939  ly = pt0;
940  hy = pyold;
941  }
942  else {
943  ly = pyold;
944  hy = pt0;
945  }
946 
947  gVirtualX->DrawBox(lx, ly, hx, hy, TVirtualX::kHollow);
948  break;
949  }
950  case kButton1Up: {
951  if (px == pw0 && py == pt0) break;
952  w1 = gPad->AbsPixeltoX(px);
953  t1 = gPad->AbsPixeltoY(py);
954  gPad->Modified(kTRUE);
955 
956  // line = new TLine(w0,t0,w1,t1);
957  // line->Draw();
958 
959  float x = gPad->PadtoX(w1);
960  tend = gPad->PadtoY(t1);
961  wend = (unsigned int)TMath::Nint(x);
962 
963  gROOT->SetEditorMode();
964 
965  //make sure the box is significantly big to avoid accidental zooms on nothing.
966  double xx1, yy1, xx2, yy2;
967 
968  gPad->GetRangeAxis(xx1, yy1, xx2, yy2);
969 
970  if (wstart != 0 && tstart != 0 && (fabs(wend - wstart) > 0.01 * (xx2 - xx1)) &&
971  (fabs(tend - tstart) > 0.01 * (yy2 - yy1) && curr_zooming_plane == plane)) {
972 
973  this->SetZoom(plane, wstart, wend, tstart, tend);
974  wstart = -1;
975  tstart = -1;
976  }
977  break;
978  }
979  } // end switch
980  }
981 
982  //......................................................................
983  // if flag is true then zoom. If flag is false then unzoom.
985  {
986  mf::LogVerbatim("TWQMultiTPCProjectionView") << "ZoomInterest called";
987 
988  if (flag == true)
989  zoom_opt = "1";
990  else
991  zoom_opt = "0";
992 
995 
997  // mf::LogVerbatim("TWQMultiTPCProjectionView") <<"Zoom interest pushing back zoom options"<<std::endl;
998  fPrevZoomOpt.push_back(fZoomOpt);
999 
1000  for (size_t iplane = 0; iplane < fPlanes.size(); ++iplane) {
1001  int minw, maxw, mint, maxt;
1002  if (flag) {
1003  int test = 0;
1004  if (rawopt->fDrawRawDataOrCalibWires == 0)
1005  fPlanes[iplane]->RawDataDraw()->GetRegionOfInterest(iplane, minw, maxw, mint, maxt);
1006  else
1007  fPlanes[iplane]->RecoBaseDraw()->GetRegionOfInterest(iplane, minw, maxw, mint, maxt);
1008 
1009  if (test == -1) continue;
1010  }
1011  else {
1012  geo::PlaneID const planeID(0, 0, iplane);
1013  minw = -0.005 * (geo->Nwires(planeID) - 1);
1014  maxw = 1.005 * (geo->Nwires(planeID) - 1);
1015  mint = -0.005 * fPlanes[iplane]->RawDataDraw()->TotalClockTicks();
1016  maxt = 1.01 * fPlanes[iplane]->RawDataDraw()->TotalClockTicks();
1017  }
1018 
1019  SetZoom(iplane, minw, maxw, mint, maxt, false);
1020  zo.wmin[iplane] = minw;
1021  zo.tmin[iplane] = mint;
1022  zo.wmax[iplane] = maxw;
1023  zo.tmax[iplane] = maxt;
1024  zo.OnlyPlaneChanged = -1;
1025  }
1026  fZoomOpt = zo;
1027  }
1028 
1029  //......................................................................
1031  {
1032  SetUpZoomButtons();
1034  }
1035 
1036  //......................................................................
1038  {
1040  evdlayoutopt->fAutoZoomInterest = fToggleAutoZoom->GetState();
1041  }
1042 
1043  //......................................................................
1045  {
1047  evdlayoutopt->fShowEndPointMarkers = fToggleShowMarkers->GetState();
1048  }
1049 
1050  //......................................................................
1052  {
1053  // enter zoom buttons
1055 
1056  fZoomInterest = new TGTextButton(fVFrame, "&Zoom Interest", 150);
1057  fZoomInterest->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "ZoomInterest()");
1058 
1059  fUnZoomInterest = new TGTextButton(fVFrame, "&UnZoom Interest", 150);
1060  fUnZoomInterest->Connect(
1061  "Clicked()", "evd::TWQMultiTPCProjectionView", this, "ZoomInterest(=false)");
1062 
1063  fZoomBack = new TGTextButton(fVFrame, "&Zoom Back", 150);
1064  fZoomBack->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "ZoomBack()");
1065 
1066  fToggleAutoZoom = new TGCheckButton(fVFrame, "AutoZoom", 0);
1067  ;
1068  fToggleAutoZoom->Connect(
1069  "Clicked()", "evd::TWQMultiTPCProjectionView", this, "SetZoomInterest()");
1070  if (evdlayoutopt->fAutoZoomInterest == 1) fToggleAutoZoom->SetState(kButtonDown);
1071 
1072  fVFrame->AddFrame(fZoomInterest, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1073  fVFrame->AddFrame(fUnZoomInterest, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1074 
1075  fVFrame->AddFrame(fZoomBack, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1076 
1077  fVFrame->AddFrame(fToggleAutoZoom, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1078  }
1079 
1080  //----------------------------------------------------------------------------
1082  {
1083  if (parameter == 1 || parameter == 2) { fToggleZoom->SetState(kButtonUp); }
1084  }
1085 
1086  //......................................................................
1088  {
1089  // enter zoom buttons
1091  if (!evdlayoutopt->fShowEndPointSection) return;
1092 
1093  // int fShowEndPointMarkers; ///< Draw EndPoint Markers if clicked.
1094 
1095  fFindEndpoint = new TGTextButton(fVFrame, "&Find XYZ", 150);
1096  fFindEndpoint->Connect("Clicked()", "evd::TWQMultiTPCProjectionView", this, "FindEndPoint()");
1097 
1098  fXYZPosition = new TGTextView(
1099  fVFrame, 100, 55, 999, TGView::kNoHSB | TGView::kNoVSB);
1100  fXYZPosition->SetEditable("false");
1101  TGText* tt = new TGText("x,y,z");
1102  fXYZPosition->SetText(tt);
1103 
1104  fClearPPoints = new TGTextButton(fVFrame, "&Clear Points", 150);
1105  fClearPPoints->Connect(
1106  "Clicked()", "evd::TWQMultiTPCProjectionView", this, "ClearEndPoints()"); // ?
1107 
1109  new TGCheckButton(fVFrame, "ShowMarkers", 0);
1110  fToggleShowMarkers->Connect(
1111  "Clicked()", "evd::TWQMultiTPCProjectionView", this, "ToggleEndPointMarkers()");
1112  if (evdlayoutopt->fShowEndPointMarkers == 1) fToggleShowMarkers->SetState(kButtonDown);
1113 
1114  fVFrame->AddFrame(fFindEndpoint, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1115  fVFrame->AddFrame(fXYZPosition, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1116  fVFrame->AddFrame(fClearPPoints, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1117  fVFrame->AddFrame(fToggleShowMarkers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1));
1118  }
1119 
1121  // Go back one step in zoom
1122 
1124  {
1125  if (fPrevZoomOpt.size() > 0) {
1126  ZoomOptionsMultiTPC ThePrevZoomOpt = fPrevZoomOpt.at(fPrevZoomOpt.size() - 1);
1127  int plane = fZoomOpt.OnlyPlaneChanged;
1128  if (plane != -1) {
1129  SetZoom(plane,
1130  ThePrevZoomOpt.wmin[plane],
1131  ThePrevZoomOpt.wmax[plane],
1132  ThePrevZoomOpt.tmin[plane],
1133  ThePrevZoomOpt.tmax[plane],
1134  false);
1135  }
1136  else {
1137  for (size_t iplane = 0; iplane != fPlanes.size(); ++iplane) {
1138  SetZoom(iplane,
1139  ThePrevZoomOpt.wmin[iplane],
1140  ThePrevZoomOpt.wmax[iplane],
1141  ThePrevZoomOpt.tmin[iplane],
1142  ThePrevZoomOpt.tmax[iplane],
1143  false);
1144  }
1145  }
1146 
1147  fPrevZoomOpt.pop_back();
1148  }
1149  else
1150  mf::LogVerbatim("TWQMultiTPCProjectionView")
1151  << "unable to unzoom further - no zoom settings left on stack" << std::endl;
1152  }
1153 
1154  //------------------------------------
1156  int wirelow,
1157  int wirehi,
1158  int timelow,
1159  int timehi,
1160  bool StoreZoom)
1161  {
1162 
1163  if (StoreZoom) {
1164  fPrevZoomOpt.push_back(fZoomOpt);
1165  fZoomOpt.OnlyPlaneChanged = plane;
1166  }
1167 
1168  fZoomOpt.wmin[plane] = wirelow;
1169  fZoomOpt.wmax[plane] = wirehi;
1170  fZoomOpt.tmin[plane] = timelow;
1171  fZoomOpt.tmax[plane] = timehi;
1172 
1173  TVirtualPad* ori = gPad;
1174  zoom_opt = "1";
1175 
1176  // error checking - useful for the mouse zoom.
1177  if (wirehi < wirelow) {
1178  int temp = wirelow;
1179  wirelow = wirehi;
1180  wirehi = temp;
1181  }
1182 
1183  if (timehi < timelow) {
1184  int temp = timelow;
1185  timelow = timehi;
1186  timehi = temp;
1187  }
1188 
1189  //if drawing, then currently not zooming
1190  curr_zooming_plane = -1;
1191 
1192  fPlanes[plane]->SetZoomRange(wirelow, wirehi, timelow, timehi);
1193  fPlanes[plane]->Draw("1");
1194  fPlanes[plane]->UpdatePad();
1195 
1196  evdb::Canvas::fCanvas->cd();
1197  evdb::Canvas::fCanvas->Modified();
1198  evdb::Canvas::fCanvas->Update();
1199 
1200  // UpdateSeedCurve();
1201 
1202  ori->cd();
1203 
1204  return;
1205  }
1206 
1207  //-----------------------------------------------------------------
1209  {
1210  TVirtualPad* ori = gPad;
1211 
1212  fWireQ->SetPlaneWire(kPlane, kWire);
1213 
1214  fWireQ->Draw();
1215  fWireQ->Pad()->cd();
1216  fWireQ->Pad()->Modified();
1217  fWireQ->Pad()->Update();
1218  fWireQ->Pad()->SetBit(TPad::kCannotMove, true);
1219  fWireQ->Pad()->GetFrame()->SetBit(TPad::kCannotMove, true);
1220 
1221  fPlaneEntry->SetNumber(kPlane);
1222  fWireEntry->SetNumber(kWire);
1223 
1224  evdb::Canvas::fCanvas->cd();
1225  evdb::Canvas::fCanvas->Modified();
1226  evdb::Canvas::fCanvas->Update();
1227 
1228  ori->cd();
1229  }
1230 
1231  //-----------------------------------------------------------------
1233  {
1234  kPlane = (unsigned int)fPlaneEntry->GetNumberEntry()->GetNumber();
1235 
1236  this->SetPlaneWire();
1237  }
1238 
1239  //-----------------------------------------------------------------
1241  {
1242  kWire = (unsigned int)fWireEntry->GetNumberEntry()->GetNumber();
1243 
1244  this->SetPlaneWire();
1245  }
1246 
1247  //-----------------------------------------------------------------
1249  {
1250  kDistance = (double)fDistance->GetNumberEntry()->GetNumber();
1251  }
1252 
1253  //-----------------------------------------------------------------
1255  {
1256  double threshold = fThresEntry->GetNumberEntry()->GetNumber();
1257 
1259  rawopt->fMinSignal = threshold;
1260 
1261  TVirtualPad* ori = gPad;
1262  this->DrawPads(zoom_opt);
1263  evdb::Canvas::fCanvas->cd();
1264  evdb::Canvas::fCanvas->Modified();
1265  evdb::Canvas::fCanvas->Update();
1266 
1267  ori->cd();
1268 
1269  return;
1270  }
1271 
1272  //-----------------------------------------------------------------
1274  {
1276 
1277  TGButton* b = (TGButton*)gTQSender;
1278  if (b->GetState() == kButtonDown) { cst->fColorOrGray = 1; }
1279  else {
1280  cst->fColorOrGray = 0;
1281  }
1282 
1283  TVirtualPad* ori = gPad;
1284  this->DrawPads(zoom_opt);
1285  evdb::Canvas::fCanvas->cd();
1286  evdb::Canvas::fCanvas->Modified();
1287  evdb::Canvas::fCanvas->Update();
1288 
1289  ori->cd();
1290 
1291  return;
1292  }
1293 
1294  //-----------------------------------------------------------------
1296  {
1298 
1299  TGButton* b = (TGButton*)gTQSender;
1300  int id = b->WidgetId();
1301 
1302  // id values are set in lines 125 - 127
1303  if (id == 4) {
1304  rawopt->fDrawRawDataOrCalibWires = 0;
1305  fRawDraw->SetState(kButtonDown);
1306  fCalibDraw->SetState(kButtonUp);
1307  fRawCalibDraw->SetState(kButtonUp);
1308  }
1309  else if (id == 3) {
1310  rawopt->fDrawRawDataOrCalibWires = 1;
1311  fRawDraw->SetState(kButtonUp);
1312  fCalibDraw->SetState(kButtonDown);
1313  fRawCalibDraw->SetState(kButtonUp);
1314  }
1315  else if (id == 2) {
1316  rawopt->fDrawRawDataOrCalibWires = 2;
1317  fRawDraw->SetState(kButtonUp);
1318  fCalibDraw->SetState(kButtonUp);
1319  fRawCalibDraw->SetState(kButtonDown);
1320  }
1321 
1322  TVirtualPad* ori = gPad;
1323 
1324  fWireQ->Draw();
1325  fWireQ->Pad()->cd();
1326  fWireQ->Pad()->Modified();
1327  fWireQ->Pad()->Update();
1328 
1329  this->DrawPads(zoom_opt);
1330  evdb::Canvas::fCanvas->cd();
1331  evdb::Canvas::fCanvas->Modified();
1332  evdb::Canvas::fCanvas->Update();
1333 
1334  ori->cd();
1335 
1336  return;
1337  }
1338 
1339  //-----------------------------------------------------------------
1341  {
1343 
1344  TGButton* b = (TGButton*)gTQSender;
1345  if (b->GetState() == kButtonDown) {
1346  sdo->fShowMCTruthText = 1;
1347  sdo->fShowMCTruthVectors = 1;
1348  }
1349  else {
1350  sdo->fShowMCTruthText = 0;
1351  sdo->fShowMCTruthVectors = 0;
1352  }
1353 
1354  TVirtualPad* ori = gPad;
1355 
1356  fMC->Draw();
1357  evdb::Canvas::fCanvas->cd();
1358  evdb::Canvas::fCanvas->Modified();
1359  evdb::Canvas::fCanvas->Update();
1360 
1361  ori->cd();
1362  }
1363 
1364 } // namespace
Float_t x
Definition: compare.C:6
code to link reconstructed objects back to the MC truth information
TGRadioButton * fCalibDraw
Draw calibrated information only.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:686
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
TQPad * fWireQ
Histogram of charge vs time on selected wire.
Double_t xx
Definition: macro.C:12
int fEnableMCTruthCheckBox
1 to have the check box appear, 0 otherwise
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
TTree * t1
Definition: plottest35.C:26
static unsigned int kWire
Drawing pad for short summary of an MC event.
Drawing pad showing a single X-Z or Y-Z projection of an event.
TGCompositeFrame * fVFrame
needed for the side frame
int fDrawRawDataOrCalibWires
0 for raw
TGCompositeFrame * fFrame
Graphics frame.
Definition: Canvas.h:39
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
Drawing pad for time or charge histograms.
double Temperature() const
In kelvin.
TGNumberEntry * fThresEntry
ADC threshold to display.
std::map< int, double > tmin
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
static unsigned int kPlane
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
A collection of drawable 2-D objects.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
void Draw()
Definition: TQPad.cxx:112
TGTextButton * fUnZoomInterest
Unzoom on iteresting region.
TGRadioButton * fRawCalibDraw
Draw raw and calibrated information.
TGLayoutHints * fLayout
Layout hints for frame.
Definition: Canvas.h:40
Manage all things related to colors for the event display.
std::vector< TWireProjPad * > fPlanes
time vs wire projection for each plane
Singleton to hold the current art::Event for the event display.
MCBriefPad * fMC
Short summary of MC event.
double FindLineLength(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
static double kDistance
double Efield(unsigned int planegap=0) const
kV/cm
TGNumberEntry * fPlaneEntry
Plane number displayed.
int fShowEndPointSection
Show section corresponding to EndPoint finding.
The color scales used by the event display.
HeaderPad * fHeaderPad
Show header information.
std::deque< util::PxPoint > ppoints
list of points in each WireProjPad used for x,y,z finding
TGTextButton * fFindEndpoint
Calculate XYZ position of two points in wire planes.
Drawing pad for time or charge histograms.
Definition: type_traits.h:61
TGCheckButton * fMCOn
Display MC truth information.
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
Point_t GetBoxCenter() const
Returns the centre of the box representing the plane.
Definition: PlaneGeo.h:449
int fShowSideBar
1 to show, 0 don&#39;t show
TGTextButton * fZoomBack
Unzoom on iteresting region.
LArSoft includes.
unsigned short fXsize
Size of the canvas;.
Definition: Canvas.h:44
A drawing pad for time vs wire.
Definition: TWireProjPad.h:27
int fAutoZoomInterest
Set the automatic zoom to the interest region.
TGCheckButton * fToggleAutoZoom
Toggle the autozoom setting.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1225
TGTextButton * fClearPPoints
Clear current list of End Points.
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
static EventHolder * Instance()
Definition: EventHolder.cxx:15
double t
Definition: PxUtils.h:10
static int curr_zooming_plane
int fShowEndPointMarkers
Draw EndPoint Markers if clicked.
double fMinSignal
minimum ADC count to display a time bin
TGTextView * fXYZPosition
Display the xyz position.
TGRadioButton * fRawDraw
Draw Raw information only.
TPad * Pad()
Definition: DrawingPad.h:31
geo::TPCID CurrentTPC() const
Returns the current TPC as a TPCID.
static int shift_lock
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
TGCompositeFrame * fMetaFrame
needed for the side frame
Class to aid in the rendering of RecoBase objects.
Class to aid in the rendering of RawData objects.
double w
Definition: PxUtils.h:9
unsigned short fYsize
Size of the canvas;.
Definition: Canvas.h:45
void Draw(const char *opt="")
Definition: HeaderPad.cxx:47
std::map< int, double > wmax
TGTextButton * fZoomInterest
Zoom on iteresting region.
static void MouseDispatch(int plane, void *wqpv)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
Encapsulate the construction of a single detector plane.
int fChangeWire
1 to click mouse and change wire, 0 don&#39;t
Contains all timing reference information for the detector.
TGRadioButton * fToggleZoom
Use zoom setting.
std::vector< TQPad * > fPlaneQ
charge on each plane
TGCheckButton * fGreyScale
Display gray or color scale.
int fColorOrGray
0 = color, 1 = gray
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
int trigger_offset(DetectorClocksData const &data)
static const char * zoom_opt
std::vector< ZoomOptionsMultiTPC > fPrevZoomOpt
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Definition: GeometryCore.h:977
int fPrintTotalCharge
Print out the total charge in an event.
std::deque< util::PxLine > pline
list of lines in each WireProjPad used for calculating 2d and 3d angles
std::map< int, double > wmin
void SetZoom(int plane, int wirelow, int wirehi, int timelo, int timehi, bool StoreZoom=true)
TGNumberEntry * fWireEntry
Wire number displayed.
std::map< int, double > tmax
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Namespace collecting geometry-related classes utilities.
Float_t w
Definition: plot.C:20
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Definition: Canvas.h:41
art framework interface to geometry description
geo::Point3DBase_t< PlaneGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML wire plane frame.
Definition: PlaneGeo.h:106
unsigned int plane
Definition: PxUtils.h:11
TGNumberEntry * fDistance
Distance from line to find hits in cluster.
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
Event finding and building.
TGCheckButton * fToggleShowMarkers
Toggle the ShowEndPointMarkersSetting.
Signal from collection planes.
Definition: geo_types.h:152
void SetPlaneWire(unsigned int plane=0, unsigned int wire=0)
Definition: TQPad.h:40