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