10 #include "TGDimension.h" 11 #include "TGNumberEntry.h" 15 #include "TRootEmbeddedCanvas.h" 18 #include "TGTextView.h" 66 , fCryoInput(nullptr), fTPCInput(nullptr), fTotalTPCLabel(nullptr)
69 , fLastEvent(new
util::DataProductChangeTracker_t)
87 fMC =
new MCBriefPad(
"fMCPad",
"MC Info.",0.15,0.13,1.0,0.17,
"");
92 fWireQ =
new TQPad(
"fWireQPad",
"ADCvsTime",0.15,0.0,1.0,0.14,
"TQ", 0, 0);
93 fWireQ->
Pad()->SetBit(TPad::kCannotMove,
true);
98 fMetaFrame =
new TGCompositeFrame(mf, 60, 60, kHorizontalFrame);
104 fLayout =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
105 kLHintsExpandY, 5, 5, 5, 5);
113 fMetaFrame->AddFrame(
fVFrame,
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY));
123 TGNumberFormat::kNESInteger,
124 TGNumberFormat::kNEAAnyNumber,
125 TGNumberFormat::kNELLimitMinMax,
129 kWire = TMath::Nint(0.5*geo->
Nwires(0));
139 fPlaneEntry->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SetPlane()");
140 fPlaneEntry->GetNumberEntry()->Connect(
"ReturnPressed()",
"evd::TWQProjectionView",
this,
"SetPlane()");
145 unsigned int maxwire=0;
146 for (
unsigned int ip=0;ip<geo->
Nplanes();ip++)
147 maxwire = (geo->
Nwires(ip)-1 > maxwire) ? geo->
Nwires(ip)-1 : maxwire;
151 TGNumberFormat::kNESInteger,
152 TGNumberFormat::kNEAAnyNumber,
153 TGNumberFormat::kNELLimitMinMax,
161 fWireEntry->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SetWire()");
162 fWireEntry->GetNumberEntry()->Connect(
"ReturnPressed()",
"evd::TWQProjectionView",
this,
"SetWire()");
169 TGNumberFormat::kNESInteger,
170 TGNumberFormat::kNEAAnyNumber,
171 TGNumberFormat::kNELLimitMinMax,
185 fThresEntry->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SetThreshold()");
186 fThresEntry->GetNumberEntry()->Connect(
"ReturnPressed()",
"evd::TWQProjectionView",
this,
"SetThreshold()");
193 fGreyScale->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetGreyscale()");
194 if(cst->fColorOrGray == 1)
fGreyScale->SetState(kButtonDown);
199 fMCOn->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetMCInfo()");
207 fRawDraw ->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetRawCalib()");
208 fCalibDraw ->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetRawCalib()");
209 fRawCalibDraw->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetRawCalib()");
218 fFrame->AddFrame(
fMCOn,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
220 fFrame->AddFrame(
fGreyScale,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
221 fFrame->AddFrame(
fRawCalibDraw,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
222 fFrame->AddFrame(
fCalibDraw,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
223 fFrame->AddFrame(
fRawDraw,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
224 fFrame->AddFrame(
fPlaneEntry,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1 ) );
225 fFrame->AddFrame(
fPlaneLabel,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
226 fFrame->AddFrame(
fWireEntry,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1 ) );
227 fFrame->AddFrame(
fWireLabel,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
228 fFrame->AddFrame(
fThresEntry,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 2, 1 ) );
229 fFrame->AddFrame(
fThresLabel,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0, 0, 5, 1 ) );
232 unsigned int nplanes = geo->
Nplanes();
234 if(evdlayoutopt-> fShowSideBar)
247 for(
unsigned int i = 0; i < nplanes; ++i){
251 double twy1 = 0.17 + (i)*(1.0-0.171)/(1.*nplanes);
252 double twy2 = 0.17 + (i+1)*(1.0-0.171)/(1.*nplanes);
256 TString padname =
"fWireProjP";
259 TString padtitle =
"Plane";
266 fPlanes[i]->Pad()->AddExec(
"mousedispatch",Form(
"evd::TWQProjectionView::MouseDispatch(%d, (void*)%lu)", i, (
unsigned long)
this));
268 padname =
"fQPadPlane";
275 fPlaneQ.push_back(
new TQPad(padname, padtitle, twx2, twy1, twx3, twy2,
"Q", i, 0));
297 for(
unsigned int i = 0; i <
fPlanes.size(); ++i){
310 planePad->RawDataDraw()->ResetRegionOfInterest();
319 for(
unsigned int i=0; i<
fPlanes.size();++i){
322 fPlanes[i]->Pad()->GetFrame()->SetBit(TPad::kCannotMove,
true);
324 for(
unsigned int j=0;j<
fPlaneQ.size();++j){
327 fPlaneQ[j]->Pad()->GetFrame()->SetBit(TPad::kCannotMove,
true);
343 mf::LogDebug(
"TWQProjectionView") <<
"Starting to draw";
368 curr_zooming_plane=-1;
370 unsigned int const nPlanes =
fPlanes.size();
371 LOG_DEBUG(
"TWQProjectionView") <<
"Start drawing " << nPlanes <<
" planes";
373 for(
unsigned int i=0;i<nPlanes;++i){
376 planePad->
Pad()->Update();
377 planePad->
Pad()->GetFrame()->SetBit(TPad::kCannotMove,
true);
393 <<
"Done drawing " << nPlanes <<
" planes";
485 for(
size_t iplane = 0; iplane <
fPlanes.size(); ++iplane){
489 double ch=0,convch=0;
491 fPlanes[iplane]->RawDataDraw()->GetChargeSum(iplane,ch,convch);
492 mf::LogVerbatim(
"TWQProjectionView") <<
"Warning! Calculating for RawData! ";
495 fPlanes[iplane]->RecoBaseDraw()->GetChargeSum(iplane,ch,convch);
498 mf::LogVerbatim(
"TWQProjectionView") <<
"\ncharge collected at collection plane: " 499 << iplane <<
" " << ch <<
" " << convch;
510 int event = gPad->GetEvent();
522 if(shift_lock==1)
break;
523 if(evdlayoutopt-> fChangeWire==1) wqpp->
ChangeWire(plane);
524 case kButton1Down: shift_lock=0;
539 int event = gPad->GetEvent();
540 int px = gPad->GetEventX();
541 if(
event!=11)
return;
542 TObject *select = gPad->GetSelected();
544 if(!select->InheritsFrom(
"TBox"))
return;
547 float xx = gPad->AbsPixeltoX(px);
548 float x = gPad->PadtoX(xx);
552 kWire = (
unsigned int)TMath::Nint(x);
564 int event = gPad->GetEvent();
572 int px = gPad->GetEventX();
573 double w0 = gPad->AbsPixeltoX(px);
574 double x = gPad->PadtoX(w0);
576 int py = gPad->GetEventY();
577 double t0 = gPad->AbsPixeltoY(py);
578 double y = gPad->PadtoY(t0);
581 curr_zooming_plane=-1;
585 for(
size_t ii = 0; ii < this->
ppoints.size(); ++ii)
586 if(ppx.
plane==this->ppoints[ii].plane){
591 this->
fPlanes[this->
ppoints[ii].plane]->View()->AddMarker(ppx.
w, ppx.
t, kRed, 29, 2.0);
593 this->
fPlanes[plane]->View()->AddMarker(0.0,0.0,2,1,0.1);
595 repeat_plane=this->
ppoints[ii].plane;
601 if(repeat_plane==-1){
609 this->
fPlanes[plane]->Pad()->cd();
610 this->
fPlanes[plane]->View()->Clear();
612 this->
fPlanes[plane]->View()->AddMarker(ppx.
w, ppx.
t, kRed, 29, 2.0);
614 this->
fPlanes[plane]->View()->AddMarker(0.0,0.0,2,1,0.1);
615 this->
fPlanes[plane]->View()->Draw();
629 fPlanes[
x]->View()->AddMarker(0.0,0.0,2,1,0.1);
650 if(
pline.size() >= 2){
652 double xyz_vertex_fit[3];
655 const double origin[3] = {0.,0.,0.};
656 double xx0 = 0., yy0 = 0., zz0 = 0.;
657 double xx1 = 0., yy1 = 0., zz1 = 0.;
672 bool wires_cross=
false;
673 bool time_good=
false;
683 TGText *
tt=
new TGText(
"too big");
684 tt->InsLine(1,
"time distance");
691 TGText *
tt=
new TGText(
"wires cross");
701 xx0=(xyz_vertex_fit[0]+second_time)/2;
709 TGText *
tt=
new TGText(
"cross");
710 tt->InsLine(1,
"wires do not");
731 TGText *
tt=
new TGText(
"too big");
732 tt->InsLine(1,
"time distance");
739 TGText *
tt=
new TGText(
"wires do cross");
749 xx1=(xyz_vertex_fit[0]+second_time)/2;
756 TGText *
tt=
new TGText(
"cross");
757 tt->InsLine(1,
"wires do not");
768 length=pow(xx0-xx1,2)+pow(yy0-yy1,2)+pow(zz0-zz1,2);
769 length=pow(length,0.5);
774 TGText *
tt=
new TGText(
"selected points");
775 tt->InsLine(1,
"not enough");
796 double xyz_vertex_fit[3] = {0.};
797 double second_time = 0.;
798 double pos[3] = {0.};
799 const double origin[3] = {0.,0.,0.};
813 bool wires_cross=
false;
814 bool time_good=
false;
825 TGText *
tt=
new TGText(
"too big");
826 tt->InsLine(1,
"time distance");
845 TGText *
tt=
new TGText(Form(
"z:%4.1f",z));
846 tt->InsLine(1,Form(
"x:%4.1f,",(xyz_vertex_fit[0]+second_time)/2));
847 tt->InsLine(1,Form(
"y:%4.1f,",y));
855 TGText *
tt=
new TGText(
"cross");
856 tt->InsLine(1,
"wires do not");
865 unsigned int wplane = 0;
866 unsigned int wirevertex = 0;
871 for(
int yy = 0; yy < 2; ++yy)
883 pos[1]=xyz_vertex_fit[1];
884 pos[2]=xyz_vertex_fit[2];
886 wirevertex = geom->
NearestWire(pos, wplane, rawOpt->fTPC, rawOpt->fCryostat);
894 fPlanes[wplane]->View()->Clear();
896 fPlanes[wplane]->View()->AddMarker(wirevertex, timestart, kMagenta, 29, 2.0);
898 fPlanes[wplane]->View()->AddMarker(0.0,0.0,2,1,0.1);
899 fPlanes[wplane]->Pad()->Update();
900 fPlanes[wplane]->View()->Draw();
908 TGText *
tt=
new TGText(
"selected points");
909 tt->InsLine(1,
"not enough");
935 std::stringstream
ss;
936 ss<<
" " << std::setprecision(1) << std::fixed << KineticEnergy <<
" MeV";
939 tt->InsLine(1,ss.str().c_str());
952 TGText *
tt=
new TGText(
"not enough lines selected");
959 for(ii = 0; ii <
pline.size(); ++ii){
966 for(
size_t ii = 0; ii <
pline.size(); ++ii){
987 if(error1!=-1 && error2!=-1)
988 fPlanes[p0N.
plane]->SaveHitList(p0N.
w,p0N.
t,p1N.
w,p1N.
t,kDistance, zoom_opt,
false);
994 for(
size_t jj = 0;jj <
fPlanes.size(); ++jj){
1009 TGText *
tt=
new TGText(Form(
"Length:%4.1f",length));
1010 tt->InsLine(1,Form(
"Omega P%d:%4.1f,",
pline[0].plane,omx[0]));
1011 tt->InsLine(2,Form(
"Omega P%d:%4.1f,",
pline[1].plane,omx[1]));
1012 tt->InsLine(3,Form(
"Phi: %4.1f,",xphi));
1014 tt->InsLine(4, Form(
"Theta: %4.1f",xtheta));
1030 if(this->
pline.size()==0)
return;
1031 for(
size_t i = 0;i <
fPlanes.size(); ++i){
1049 fPlanes[0]->HitSelectorGet()->SeedVector().clear();
1051 for(
size_t i = 0; i <
fPlanes.size(); ++i){
1075 fPlanes[0]->HitSelectorGet()->SeedVector().pop_back();
1079 if(SeedsToRemove==0) SeedsToRemove=3;
1083 <<
" of " <<
seedlines.size() <<
" seed lines";
1086 for(
int i=0; i!=SeedsToRemove; ++i)
1090 for(
size_t i=0; i!=
fPlanes.size(); ++i){
1104 TObject *select = gPad->GetSelected();
1106 if(!select->InheritsFrom(
"TBox"))
return;
1108 static Float_t w0=-1,
t0=-1, w1=-1,
t1=-1;
1110 static Int_t pxold, pyold;
1111 static Int_t pw0, pt0;
1112 static Int_t linedrawn;
1116 static int wstart,wend;
1117 static float tstart,tend;
1119 int event = gPad->GetEvent();
1120 int px = gPad->GetEventX();
1121 int py = gPad->GetEventY();
1126 gVirtualX->SetLineColor(-1);
1127 w0 = gPad->AbsPixeltoX(px);
1128 t0 = gPad->AbsPixeltoY(py);
1130 pxold = px; pyold = py;
1132 float x = gPad->PadtoX(w0);
1133 tstart = gPad->PadtoY(
t0);
1135 wstart = (
unsigned int)TMath::Nint(x);
1136 curr_zooming_plane=plane;
1139 case kButton1Motion:{
1159 if (linedrawn) gVirtualX->DrawBox(lx, ly, hx, hy,TVirtualX::kHollow);
1182 gVirtualX->DrawBox(lx, ly, hx, hy,TVirtualX::kHollow);
1186 if (px == pw0 && py == pt0)
break;
1187 w1 = gPad->AbsPixeltoX(px);
1188 t1 = gPad->AbsPixeltoY(py);
1189 gPad->Modified(kTRUE);
1194 float x = gPad->PadtoX(w1);
1195 tend = gPad->PadtoY(
t1);
1196 wend = (
unsigned int)TMath::Nint(x);
1198 gROOT->SetEditorMode();
1201 double xx1,yy1,xx2,yy2;
1203 gPad->GetRangeAxis(xx1, yy1, xx2, yy2);
1205 if(wstart != 0 && tstart != 0 &&
1206 ( std::abs(wend-wstart ) > 0.01*(xx2-xx1) ) &&
1207 ( std::abs(tend-tstart ) > 0.01*(yy2-yy1) &&
1208 curr_zooming_plane==plane ) ){
1211 this->
SetZoom(plane,wstart,wend,tstart,tend);
1226 static Float_t w0=-1,
t0=-1, w1=-1,
t1=-1;
1228 static Int_t pxold, pyold;
1229 static Int_t pw0, pt0;
1231 static Int_t linedrawn;
1235 static Int_t LastSeedt0;
1236 static Int_t LastSeedt1;
1237 static Int_t LastSeedPlane;
1241 double MaxSeedTimeDiff=100;
1243 int event = gPad->GetEvent();
1244 int px = gPad->GetEventX();
1245 int py = gPad->GetEventY();
1256 w0 = gPad->AbsPixeltoX(px);
1257 t0 = gPad->AbsPixeltoY(py);
1259 if((SeedCounter%3)==1){
1261 py=gPad->YtoAbsPixel(
t0);
1265 LastSeedPlane=plane;
1269 pxold = px; pyold = py;
1271 curr_zooming_plane=plane;
1275 case kButton1Motion:{
1282 if((evdlayoutopt->
fMakeSeeds)&&((SeedCounter%3)==1)){
1285 pt0=gPad->YtoAbsPixel(
t0);
1296 if (linedrawn) gVirtualX->DrawLine(lx, ly, hx, hy);
1308 if (linedrawn) gVirtualX->DrawLine(lx, ly, hx, hy);
1313 if (px == pw0 && py == pt0)
break;
1314 w1 = gPad->AbsPixeltoX(px);
1315 t1 = gPad->AbsPixeltoY(py);
1317 gPad->Modified(kTRUE);
1329 if((SeedCounter%3)==2){
1330 if(LastSeedPlane==plane){
1332 mf::LogVerbatim(
"TWQProjectionView") <<
"Cannot draw seed with 2 lines in same plane!";
1336 if(((LastSeedt0-
t0)>MaxSeedTimeDiff)||(LastSeedt1-
t1)>MaxSeedTimeDiff){
1337 mf::LogVerbatim(
"TWQProjectionView")<<
"This seed line does not fit the last proj. not adding it";
1343 mf::LogVerbatim(
"TWQProjectionView")<<
"This is a good seed. adding line and returing 2";
1353 else if((SeedCounter%3)==1){
1360 else if((SeedCounter%3)==0){
1361 mf::LogVerbatim(
"TWQProjectionView") <<
"You have been eaten by a Grue. And seed mode is doing something wrong.";
1374 return linefinished;
1381 TObject *select = gPad->GetSelected();
1383 if(!select->InheritsFrom(
"TBox"))
return;
1391 curr_zooming_plane=-1;
1392 gROOT->SetEditorMode();
1395 int repeat_plane=-1;
1397 for(
size_t ii = 0; ii < this->
pline.size(); ++ii){
1398 if(ppx.
plane==this->pline[ii].plane){
1399 this->
pline[ii]=ppx;
1402 this->
fPlanes[plane]->Pad()->cd();
1411 repeat_plane=this->
pline[ii].plane;
1417 if(repeat_plane==-1){
1418 if( this->
pline.size()>=2){
1425 this->
fPlanes[this->
pline[0].plane]->Pad()->Modified();
1427 this->
fPlanes[this->
pline[0].plane]->Pad()->GetFrame()->SetBit(TPad::kCannotMove,
true);
1428 this->
fPlanes[this->
pline[0].plane]->Pad()->SetBit(TPad::kCannotMove,
true);
1429 this->
pline.pop_front();
1432 this->
pline.push_back(ppx);
1433 this->
fPlanes[plane]->Pad()->cd();
1434 this->
fPlanes[plane]->View()->Clear();
1435 this->
fPlanes[plane]->View()->Draw();
1437 int size=
pline.size()-1;
1438 TLine& l = this->
fPlanes[this->
pline[size].plane]->View()->AddLine(
pline[size].w0,
1442 this->
fPlanes[this->
pline[size].plane]->View()->Draw();
1456 TObject *select = gPad->GetSelected();
1458 if(!select->InheritsFrom(
"TBox"))
return;
1463 int DrawStatus =
DrawLine(plane,ppx);
1470 curr_zooming_plane=-1;
1471 gROOT->SetEditorMode();
1478 for(
size_t p = 0; p !=
fPlanes.size(); ++p)
1481 else if(DrawStatus==2){
1482 mf::LogVerbatim(
"TWQProjectionView") <<
"Adding third seed projection";
1507 geomutil.
GetYZ(&l0_pt0, &l1_pt0, yz0);
1508 geomutil.
GetYZ(&l0_pt1, &l1_pt1, yz1);
1513 util::PxLine thirdline(thirdp0.plane, thirdp0.w, thirdp0.t, thirdp1.
w, thirdp1.
t);
1518 << thirdline.
w0<<
" " 1519 <<thirdline.
t0<<
" to " 1520 << thirdline.
w1 <<
" " 1526 for(
size_t p=0; p!=
fPlanes.size(); ++p){
1533 double seedpt[3], seeddir[3], seederr[3];
1535 for(
int i=0; i!=3; ++i){
1540 seedpt[0] = (x0+
x1)/2.;
1541 seeddir[0] = (x1-x0)/2.;
1543 seedpt[1] = (yz0[0]+yz1[0])/2.;
1544 seeddir[1] = (yz1[0]-yz0[0])/2.;
1545 seedpt[2] = (yz0[1]+yz1[1])/2.;
1546 seeddir[2] = (yz1[1]-yz0[1])/2.;
1548 recob::Seed NewSeed(seedpt,seeddir,seederr,seederr);
1549 fPlanes[0]->HitSelectorGet()->SeedVector().push_back(NewSeed);
1550 mf::LogVerbatim(
"TWQProjectionView") <<
"Adding seed, vector now of size " 1551 <<
fPlanes[0]->HitSelectorGet()->SeedVector().size();
1559 <<
fPlanes[0]->HitSelectorGet()->SeedVector().size();
1561 int NSeeds =
fPlanes[0]->HitSelectorGet()->SeedVector().size();
1564 std::stringstream
ss;
1568 Length =
fPlanes[0]->HitSelectorGet()->SeedVector().at(0).GetLength()*2.;
1571 ss<<
" " << Length<<
" cm";
1572 TGText *
tt =
new TGText(ss.str().c_str());
1573 tt->InsLine(1,
"3D Track : ");
1579 double FirstPt[3], LastPt[3], FirstDir[3], LastDir[3], Err[3];
1580 fPlanes[0]->HitSelectorGet()->SeedVector().at(0).GetPoint(FirstPt,Err);
1581 fPlanes[0]->HitSelectorGet()->SeedVector().at(0).GetDirection(FirstDir,Err);
1582 fPlanes[0]->HitSelectorGet()->SeedVector().at(NSeeds-1).GetPoint(LastPt,Err);
1583 fPlanes[0]->HitSelectorGet()->SeedVector().at(NSeeds-1).GetDirection(LastDir,Err);
1584 for(
int i=0; i!=3; ++i){
1585 FirstPt[i] -= FirstDir[i];
1586 LastPt[i] += LastDir[i];
1588 ss<<
"z| " <<std::setprecision(0)<<std::fixed<< FirstPt[2] <<
"," <<
"\t" <<LastPt[2];
1589 tt =
new TGText(ss.str().c_str());
1593 ss<<
"x| " <<std::setprecision(0)<<std::fixed<< FirstPt[0] <<
","<<
"\t" <<LastPt[0];
1596 tt->InsLine(1,ss.str().c_str());
1600 ss<<
"y| " <<std::setprecision(0)<<std::fixed<< FirstPt[1] <<
","<<
"\t" <<LastPt[1];
1602 tt->InsLine(1,ss.str().c_str());
1610 TVector3 TPCHighBoundary = TVector3(2 * geo->
DetHalfWidth(),
1613 TVector3 TPCLowBoundary = TVector3(0,
1617 << TPCLowBoundary[0] <<
" " 1618 << TPCLowBoundary[1] <<
" " 1619 << TPCLowBoundary[2] <<
"\n" 1620 << TPCHighBoundary[0] <<
" " 1621 << TPCHighBoundary[1] <<
" " 1622 << TPCHighBoundary[2];
1623 bool OverPointFound=
false;
1624 for(
int i=0; i!=3; ++i){
1625 if((FirstPt[i]>(TPCHighBoundary[i])) ||
1626 (FirstPt[i]<(TPCLowBoundary[i])) ||
1627 (LastPt[i]>(TPCHighBoundary[i])) ||
1628 (LastPt[i]<(TPCLowBoundary[i]))){
1631 OverPointFound=
true;
1633 if(!OverPointFound){
1634 if((FirstPt[i]>(TPCHighBoundary[i]-5))||(FirstPt[i]<(TPCLowBoundary[i]+5)) ||
1635 (LastPt[i]>(TPCHighBoundary[i]-5))||(LastPt[i]<(TPCLowBoundary[i]+5))){
1636 mf::LogVerbatim(
"TWQProjectionView") <<
"One point 5cm from TPC boundary";
1638 OverPointFound=
true;
1658 int event = gPad->GetEvent();
1661 if(
event!=7)
return;
1667 int px = gPad->GetEventX();
1668 double w0 = gPad->AbsPixeltoX(px);
1669 double x = gPad->PadtoX(w0);
1671 int py = gPad->GetEventY();
1672 double t0 = gPad->AbsPixeltoY(py);
1673 double y = gPad->PadtoY(t0);
1675 fPlanes[plane]->SelectOneHit(x,y,zoom_opt);
1687 if(flag==
true) zoom_opt=
"1";
1698 for(
size_t iplane = 0; iplane <
fPlanes.size(); ++iplane){
1699 int minw,maxw,mint,maxt;
1703 test =
fPlanes[iplane]->RawDataDraw()->GetRegionOfInterest(iplane,minw,maxw,mint,maxt);
1705 fPlanes[iplane]->RecoBaseDraw()->GetRegionOfInterest(iplane,minw,maxw,mint,maxt);
1711 minw = -0.005*(geo->
Nwires(iplane)-1);
1712 maxw = 1.005*(geo->
Nwires(iplane)-1);
1713 mint = -0.005*
fPlanes[iplane]->RawDataDraw()->TotalClockTicks();
1714 maxt = 1.01*
fPlanes[iplane]->RawDataDraw()->TotalClockTicks();
1717 SetZoom(iplane,minw,maxw,mint,maxt,
false);
1718 zo.
wmin[iplane]=minw;
1719 zo.
tmin[iplane]=mint;
1720 zo.
wmax[iplane]=maxw;
1721 zo.
tmax[iplane]=maxt;
1749 pPlane->SetZoomFromView();
1781 LOG_DEBUG(
"TWQProjectionView") <<
"Explicit request for redrawing";
1796 fZoomInterest->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ZoomInterest()");
1801 fUnZoomInterest->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ZoomInterest(=false)");
1805 fZoomBack->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ZoomBack()");
1809 fToggleAutoZoom->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SetZoomInterest()");
1815 fVFrame->AddFrame(
fZoomBack,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1 ) );
1832 fToggleZoom->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"RadioButtonsDispatch(=0)");
1833 fToggleClusters->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"RadioButtonsDispatch(=1)");
1834 fToggleSeeds->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"RadioButtonsDispatch(=2)");
1841 fCalcAngle->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"SaveSelection()");
1844 fClear->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ClearSelection()");
1847 fClearLastSeed->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ClearLastSeed()");
1863 TGText *
tt=
new TGText(
"...");
1868 TGNumberFormat::kNESReal,
1869 TGNumberFormat::kNEAPositive,
1870 TGNumberFormat::kNELLimitMinMax,
1878 fDistance->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SetDistance()");
1879 fDistance->GetNumberEntry()->Connect(
"ReturnPressed()",
"evd::TWQProjectionView",
this,
"SetDistance()");
1889 fVFrame->AddFrame(
fCalcAngle,
new TGLayoutHints(kLHintsTop|kLHintsLeft,0,0,5,1));
1890 fVFrame->AddFrame(
fClear,
new TGLayoutHints(kLHintsTop | kLHintsLeft,0,0,5,1));
1894 fVFrame->AddFrame(
fDistance,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1 ) );
1897 fVFrame->AddFrame(
fAngleInfo,
new TGLayoutHints(kLHintsTop | kLHintsLeft,0,0,5,1));
1899 fVFrame->AddFrame(
fDistance,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1 ) );
1913 fRedraw->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ForceRedraw()");
1915 fVFrame->AddFrame(
fRedraw,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1 ) );
1929 TGHorizontalFrame* pRow =
nullptr;
1934 pRow =
new TGHorizontalFrame(
fVFrame, 216, 32, kHorizontalFrame);
1937 unsigned int const NCryo = geom.
Ncryostats();
1939 unsigned int const NCryoDigits =
std::to_string(NCryo - 1).length();
1944 TGLabel* pLabel =
new TGLabel(pRow,
"Cryo #");
1945 pLabel->SetTextJustify(kTextRight | kTextCenterY);
1949 pRow, (Double_t) CurrentCryo,
1951 TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber,
1952 TGNumberFormat::kNELLimitMinMax, -1, NCryo
1956 pTotalCryoLabel->SetTextJustify(kTextLeft | kTextCenterY);
1958 pRow->AddFrame(pLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
1959 pRow->AddFrame(
fCryoInput,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1960 pRow->AddFrame(pTotalCryoLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
1962 fCryoInput->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SelectTPC()");
1965 TGLabel* pLabel =
new TGLabel(pRow,
"Cryo #0 (1 total)");
1967 pRow->AddFrame(pLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
1970 fVFrame->AddFrame(pRow,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1976 pRow =
new TGHorizontalFrame(
fVFrame, 216, 32, kHorizontalFrame);
1978 unsigned int MaxTPC = geom.
MaxTPCs();
1980 unsigned int const NTPCDigits =
std::to_string(MaxTPC - 1).length();
1986 TGLabel* pLabel =
new TGLabel(pRow,
"TPC #");
1987 pLabel->SetTextJustify(kTextRight | kTextCenterY);
1991 pRow, (Double_t) CurrentTPC,
1993 TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber,
1994 TGNumberFormat::kNELLimitMinMax, -1, MaxTPC
2000 pRow->AddFrame(pLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
2001 pRow->AddFrame(
fTPCInput,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
2002 pRow->AddFrame(
fTotalTPCLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
2004 fTPCInput->Connect(
"ValueSet(Long_t)",
"evd::TWQProjectionView",
this,
"SelectTPC()");
2007 TGLabel* pLabel =
new TGLabel(pRow,
"TPC #0 (1 total)");
2009 pRow->AddFrame(pLabel,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 5, 5));
2012 fVFrame->AddFrame(pRow,
new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
2055 if (NewTPC.Cryostat-- == 0)
2059 else if (!geom.
HasTPC(NewTPC)) {
2061 unsigned int const NCryos = geom.
Ncryostats();
2063 if (NewTPC.Cryostat >= NCryos) {
2068 if (++NewTPC.Cryostat >= NCryos)
2073 LOG_DEBUG(
"TWQProjectionView") << __func__ <<
": invalid TPC " 2074 << RequestedTPC <<
", corrected as " << NewTPC <<
" instead";
2077 if (!geom.
HasTPC(NewTPC)) {
2078 LOG_ERROR(
"TWQProjectionView") << __func__ <<
": internal error: " 2079 << RequestedTPC <<
" turned into an invalid TPC " << NewTPC;
2081 else if (NewTPC != CurrentTPC) {
2082 LOG_DEBUG(
"TWQProjectionView") << __func__ <<
": switching from " 2083 << CurrentTPC <<
" to " << NewTPC;
2086 if (rawOpt.
fCryostat != NewTPC.Cryostat) {
2087 unsigned int const NTPCs = geom.
NTPC(NewTPC);
2094 rawOpt.
fTPC = NewTPC.TPC;
2105 if (NewTPC != RequestedTPC) {
2122 else if(parameter==1){
2128 else if(parameter==2){
2148 fFindEndpoint->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"FindEndPoint()");
2152 TGText *
tt=
new TGText(
"x,y,z");
2157 fClearPPoints->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ClearEndPoints()");
2160 fToggleShowMarkers->Connect(
"Clicked()",
"evd::TWQProjectionView",
this,
"ToggleEndPointMarkers()");
2164 fVFrame->AddFrame(
fXYZPosition,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 1 ) );
2180 ThePrevZoomOpt.
wmin[plane],
2181 ThePrevZoomOpt.
wmax[plane],
2182 ThePrevZoomOpt.
tmin[plane],
2183 ThePrevZoomOpt.
tmax[plane],
2187 for(
size_t iplane = 0; iplane !=
fPlanes.size(); ++iplane){
2189 ThePrevZoomOpt.
wmin[iplane],
2190 ThePrevZoomOpt.
wmax[iplane],
2191 ThePrevZoomOpt.
tmin[iplane],
2192 ThePrevZoomOpt.
tmax[iplane],
2201 mf::LogVerbatim(
"TWQProjectionView") <<
"unable to unzoom further - no zoom settings left on stack"<<std::endl;
2224 TVirtualPad *ori = gPad;
2241 curr_zooming_plane=-1;
2243 fPlanes[plane]->SetZoomRange(wirelow, wirehi,timelow,timehi);
2261 TVirtualPad *ori = gPad;
2269 fWireQ->
Pad()->SetBit(TPad::kCannotMove,
true);
2270 fWireQ->
Pad()->GetFrame()->SetBit(TPad::kCannotMove,
true);
2287 kPlane = (
unsigned int)
fPlaneEntry->GetNumberEntry()->GetNumber();
2296 kWire = (geo->
Nwires(kPlane)-1 > (
unsigned int)
fWireEntry->GetNumberEntry()->GetNumber() ) ? (
unsigned int)
fWireEntry->GetNumberEntry()->GetNumber() : geo->
Nwires(kPlane)-1;
2304 kDistance = (double)
fDistance->GetNumberEntry()->GetNumber();
2310 double threshold =
fThresEntry->GetNumberEntry()->GetNumber();
2317 TVirtualPad *ori = gPad;
2336 TGButton *b = (TGButton *)gTQSender;
2337 if(b->GetState() == kButtonDown){
2344 TVirtualPad *ori = gPad;
2360 TGButton *b = (TGButton *)gTQSender;
2361 int id = b->WidgetId();
2383 TVirtualPad *ori = gPad;
2405 TGButton *b = (TGButton *)gTQSender;
2406 if(b->GetState() == kButtonDown){
2415 TVirtualPad *ori = gPad;
2433 std::vector<recob::Seed> SeedVec=
fPlanes[0]->HitSelectorGet()->SeedVector();
2434 for(
size_t p = 0; p !=
fPlanes.size(); ++p){
2444 BezLength =
fPlanes[p]->UpdateSeedCurve(SeedVec, p);
2463 ({*pEvent, art::ServiceHandle<evd::RawDrawingOptions>()->fRawDataLabel})
void SetTestFlag(int value)
std::vector< ZoomOptions > fPrevZoomOpt
TGNumberEntry * fCryoInput
current cryostat
code to link reconstructed objects back to the MC truth information
TGRadioButton * fToggleClusters
Use make cluster setting.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
HeaderPad * fHeaderPad
Show header information.
std::deque< util::PxLine > pline
list of lines in each WireProjPad used for calculating 2d and 3d angles, also making seeds (eventuall...
const art::Event * GetEvent() const
double z
z position of intersection
Namespace for general, non-LArSoft-specific utilities.
int fEnableMCTruthCheckBox
1 to have the check box appear, 0 otherwise
double t1
defined to be the ending t-position (of line or seed depending)
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
yes & test(std::ostream &)
void SetMouseZoomRegion(int plane)
static unsigned int kWire
virtual int TriggerOffset() const =0
int DrawLine(int plane, util::PxLine &pline)
void SetTestFlag(int number=1)
Drawing pad for short summary of an MC event.
TGTextButton * fCalcAngle
Calculate the 2D & 3D angles between lines.
Drawing pad showing a single X-Z or Y-Z projection of an event.
Display parameters for the raw data.
TGTextButton * fZoomBack
Unzoom on iteresting region.
Double_t Get2Dangle(Double_t deltawire, Double_t deltatime) const
int fDrawRawDataOrCalibWires
0 for raw
TGCompositeFrame * fFrame
Graphics frame.
Float_t x1[n_points_granero]
double fLastThreshold
Kludge to prevent double drawing when changing threshold.
unsigned int CryostatID_t
Type for the ID number.
TGTextButton * fZoomInterest
Zoom on iteresting region.
The data type to uniquely identify a Plane.
void Draw(const char *opt=0)
Drawing pad for time or charge histograms.
bool isZoomAutomatic
true if user did not ask for custom zoom
void ForceRedraw()
Forces a redraw of the window.
TGNumberEntry * fTPCInput
current TPC
TGCheckButton * fToggleShowMarkers
Toggle the ShowEndPointMarkersSetting.
Classes detecting configuration changes.
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
TQPad * fWireQ
Histogram of charge vs time on selected wire.
std::map< int, double > wmax
TGTextView * fXYZPosition
Display the xyz position.
static unsigned int kPlane
TCanvas * fCanvas
The ROOT drawing canvas.
A collection of drawable 2-D objects.
WireID_t Wire
Index of the wire within its plane.
static void FromPDG(TLine &line, int pdgcode)
int fMakeClusters
Draw two lines to make clusters if clicked.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
TGLayoutHints * fLayout
Layout hints for frame.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
TGNumberEntry * fDistance
Distance from line to find hits in cluster.
Manage all things related to colors for the event display.
std::deque< util::PxPoint > ppoints
list of points in each WireProjPad used for x,y,z finding
double w0
defined to be the vertex w-position
TGTextButton * fFindEndpoint
Calculate XYZ position of two points in wire planes.
Singleton to hold the current art::Event for the event display.
TGRadioButton * fRawCalibDraw
Draw raw and calibrated information.
void SetAutomaticZoomMode(bool bSet=true)
Records whether we are automatically zooming to the region of interest.
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
TGRadioButton * fToggleSeeds
Use the make seed setting.
int fMakeSeeds
Draw two lines to make clusters if clicked.
#define LOG_ERROR(category)
int fShowEndPointSection
Show section corresponding to EndPoint finding.
std::vector< double > const & GetCurrentZoom() const
The color scales used by the event display.
TWQProjectionView(TGMainFrame *mf)
double w1
defined to be the ending w-position (of line or seed depending)
int fShowClusterSection
Show section to make clusters.
Access the description of detector geometry.
TGCheckButton * fToggleAutoZoom
Toggle the autozoom setting.
TGCompositeFrame * fMetaFrame
needed for the side frame
TGTextButton * fClear
Clears the selected points in an event.
TGTextButton * fClearPPoints
Clear current list of End Points.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
TGRadioButton * fToggleZoom
Use zoom setting.
unsigned short fXsize
Size of the canvas;.
A drawing pad for time vs wire.
void ResetRegionsOfInterest()
Clear all the regions of interest.
int fAutoZoomInterest
Set the automatic zoom to the interest region.
TGLabel * fTotalTPCLabel
total TPCs in the current cryostat
unsigned int TPCID_t
Type for the ID number.
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
Class to perform operations needed to select hits and pass them to a cluster.
static EventHolder * Instance()
void SetUpDrawingButtons()
virtual double Temperature() const =0
static int curr_zooming_plane
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
int fShowEndPointMarkers
Draw EndPoint Markers if clicked.
double fMinSignal
minimum ADC count to display a time bin
void ChangeWire(int plane)
TGTextButton * fRedraw
Button to force redraw.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
geo::TPCID CurrentTPC() const
Returns the current TPC as a TPCID.
TGCompositeFrame * fVFrame
needed for the side frame
void SelectHit(int plane)
void Draw(const char *opt="")
TGNumberEntry * fThresEntry
ADC threshold to display.
std::vector< TQPad * > fPlaneQ
charge on each plane
void SelectTPC()
select TPC from GUI
std::vector< util::PxLine > seedlines
list of lines in each WireProjPad used for calculating 2d and 3d angles, also making seeds (eventuall...
The data type to uniquely identify a TPC.
Description of geometry of one entire detector.
bool OnNewEvent()
Returns if a new event is detected; if so, it also resets accordingly.
Class to aid in the rendering of RecoBase objects.
void DrawPads(const char *opt="")
TGRadioButton * fCalibDraw
Draw calibrated information only.
Class to aid in the rendering of RawData objects.
void ZoomInterest(bool flag=true)
void SetUpClusterButtons()
unsigned short fYsize
Size of the canvas;.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
void SetClusterInterest()
TGRadioButton * fRawDraw
Draw Raw information only.
TGTextButton * fUnZoomInterest
Unzoom on iteresting region.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, geo::Point_t &intersection) const
Computes the intersection between two wires.
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
void RadioButtonsDispatch(int parameter)
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
TGNumberEntry * fPlaneEntry
Plane number displayed.
Int_t GetYZ(const PxPoint *p0, const PxPoint *p1, Double_t *yz) const
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Encapsulate the construction of a single detector plane.
std::map< int, double > tmin
void ToggleEndPointMarkers()
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
double y
y position of intersection
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
static std::string TotalElementsString(unsigned int NElements)
Returns a string visualizing the total number of elements.
void clear()
Set a new event and data product label as current.
Int_t GetProjectedPoint(const PxPoint *p0, const PxPoint *p1, PxPoint &pN) const
int fColorOrGray
0 = color, 1 = gray
static void MouseDispatch(int plane, void *wqpv)
TGCheckButton * fMCOn
Display MC truth information.
static const char * zoom_opt
TGTextButton * fClearLastSeed
Clears the selected points in an event.
int fPrintTotalCharge
Print out the total charge in an event.
constexpr double kBogusD
obviously bogus double value
void SetClusters(int plane)
void SetZoom(int plane, int wirelow, int wirehi, int timelo, int timehi, bool StoreZoom=true)
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
MCBriefPad * fMC
Short summary of MC event.
A view showing the time vs wire, charge and charge vs time information for an event.
std::vector< TWireProjPad * > fPlanes
time vs wire projection for each plane
Namespace collecting geometry-related classes utilities.
bool update(DataProductChangeTracker_t const &new_prod)
Update to a new data product, return true if it has changed.
void SelectPoint(int plane)
TGCheckButton * fGreyScale
Display gray or color scale.
util::DataProductChangeTracker_t * fLastEvent
keeps track of latest event
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Int_t Get3DaxisN(Int_t iplane0, Int_t iplane1, Double_t omega0, Double_t omega1, Double_t &phi, Double_t &theta) const
unsigned int MaxTPCs() const
Returns the largest number of TPCs a cryostat in the detector has.
double t0
defined to be the vertex t-position
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
TGNumberEntry * fWireEntry
Wire number displayed.
bool isValid() const
Returns whether there is a current event and data product.
art framework interface to geometry description
constexpr Point origin()
Returns a origin position with a point of the specified type.
Event finding and building.
The data type to uniquely identify a cryostat.
Signal from collection planes.
std::map< int, double > wmin
std::map< int, double > tmax
void SetPlaneWire(unsigned int plane=0, unsigned int wire=0)