All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | List of all members
evdb_tool::OpHit3DDrawer Class Reference
Inheritance diagram for evdb_tool::OpHit3DDrawer:
evdb_tool::I3DDrawer

Public Member Functions

 OpHit3DDrawer (const fhicl::ParameterSet &)
 
 ~OpHit3DDrawer ()
 
void Draw (const art::Event &, evdb::View3D *) const override
 
- Public Member Functions inherited from evdb_tool::I3DDrawer
virtual ~I3DDrawer () noexcept=default
 

Private Member Functions

void DrawRectangularBox (evdb::View3D *, const Eigen::Vector3f &, const Eigen::Vector3f &, int, int, int) const
 

Detailed Description

Definition at line 26 of file OpHit3DDrawer_tool.cc.

Constructor & Destructor Documentation

evdb_tool::OpHit3DDrawer::OpHit3DDrawer ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 41 of file OpHit3DDrawer_tool.cc.

42 {
43  return;
44 }
evdb_tool::OpHit3DDrawer::~OpHit3DDrawer ( )

Definition at line 46 of file OpHit3DDrawer_tool.cc.

47 {
48 }

Member Function Documentation

void evdb_tool::OpHit3DDrawer::Draw ( const art::Event &  event,
evdb::View3D *  view 
) const
overridevirtual

Implements evdb_tool::I3DDrawer.

Definition at line 50 of file OpHit3DDrawer_tool.cc.

51 {
52  art::ServiceHandle<evd::RecoDrawingOptions> recoOpt;
53 
54  if (recoOpt->fDrawOpHits == 0) return;
55 
56  // Service recovery
57  art::ServiceHandle<geo::Geometry> geo;
58  art::ServiceHandle<evd::ColorDrawingOptions> cst;
59 
60  art::Handle<std::vector<recob::OpHit>> opHitHandle;
61 
62  // This seems like a time waster but we want to get the full color scale for all OpHits... so loops away...
63  std::vector<float> opHitPEVec;
64 
65  // This is almost identically the same for loop we will re-excute below... sigh...
66  // But the idea is to get a min/max range for the drawing colors...
67  for(size_t idx = 0; idx < recoOpt->fOpHitLabels.size(); idx++)
68  {
69  art::InputTag opHitProducer = recoOpt->fOpHitLabels[idx];
70 
71  event.getByLabel(opHitProducer, opHitHandle);
72 
73  if (!opHitHandle.isValid() ) continue;
74  if ( opHitHandle->size() == 0) continue;
75 
76  // Start the loop over flashes
77  for(const auto& opHit : *opHitHandle)
78  {
79  // Make some selections...
80  if (opHit.PE() < recoOpt->fFlashMinPE) continue;
81  if (opHit.PeakTime() < recoOpt->fFlashTMin) continue;
82  if (opHit.PeakTime() > recoOpt->fFlashTMax) continue;
83 
84  opHitPEVec.push_back(opHit.PE());
85  }
86  }
87 
88  // Do we have any flashes and hits?
89  if (!opHitPEVec.empty())
90  {
91  // Sorting is good for mind and body...
92  std::sort(opHitPEVec.begin(),opHitPEVec.end());
93 
94  float minTotalPE = opHitPEVec.front();
95  float maxTotalPE = opHitPEVec[0.9 * opHitPEVec.size()];
96 
97  // Now we can set the scaling factor for PE
98  float opHitPEScale((cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) / (maxTotalPE - minTotalPE));
99 
100  // We are meant to draw the flashes/hits, so loop over the list of input flashes
101  for(size_t idx = 0; idx < recoOpt->fOpHitLabels.size(); idx++)
102  {
103  art::InputTag opHitProducer = recoOpt->fOpHitLabels[idx];
104 
105  event.getByLabel(opHitProducer, opHitHandle);
106 
107  if (!opHitHandle.isValid() ) continue;
108  if ( opHitHandle->size() == 0) continue;
109 
110  // Start the loop over flashes
111  for(const auto& opHit : *opHitHandle)
112  {
113  // Make some selections...
114  if (opHit.PE() < recoOpt->fFlashMinPE) continue;
115  if (opHit.PeakTime() < recoOpt->fFlashTMin) continue;
116  if (opHit.PeakTime() > recoOpt->fFlashTMax) continue;
117 
118  unsigned int opChannel = opHit.OpChannel();
119  const geo::OpDetGeo& opHitGeo = geo->OpDetGeoFromOpChannel(opChannel);
120  const geo::Point_t& opHitPos = opHitGeo.GetCenter();
121  float xWidth = opHit.Width();
122  float zWidth = opHitGeo.HalfW();
123  float yWidth = opHitGeo.HalfH();
124 
125  Eigen::Vector3f opHitLo(opHitPos.X() - xWidth, opHitPos.Y() - yWidth, opHitPos.Z() - zWidth);
126  Eigen::Vector3f opHitHi(opHitPos.X() + xWidth, opHitPos.Y() + yWidth, opHitPos.Z() + zWidth);
127 
128  float peFactor = cst->fRecoQLow[geo::kCollection] + opHitPEScale * std::min(maxTotalPE,float(opHit.PE()));
129 
130  int chargeColorIdx = cst->CalQ(geo::kCollection).GetColor(peFactor);
131 
132  DrawRectangularBox(view, opHitLo, opHitHi, chargeColorIdx, 2, 1);
133  }
134  }
135  }
136 
137  return;
138 }
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
double HalfW() const
Definition: OpDetGeo.cxx:71
double HalfH() const
Definition: OpDetGeo.cxx:79
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
void DrawRectangularBox(evdb::View3D *, const Eigen::Vector3f &, const Eigen::Vector3f &, int, int, int) const
Signal from collection planes.
Definition: geo_types.h:146
void evdb_tool::OpHit3DDrawer::DrawRectangularBox ( evdb::View3D *  view,
const Eigen::Vector3f &  coordsLo,
const Eigen::Vector3f &  coordsHi,
int  color,
int  width,
int  style 
) const
private

Definition at line 140 of file OpHit3DDrawer_tool.cc.

141 {
142  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
143  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
144  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
145  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
146  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
147  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
148 
149  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
150  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
151  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
152  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
153  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
154  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
155 
156  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
157  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
158  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
159  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
160  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
161  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
162 
163  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
164  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
165  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
166  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
167  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
168  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
169 
170  return;
171 }
walls no bottom
Definition: selectors.fcl:105
def style
Definition: util.py:237
walls no top
Definition: selectors.fcl:105

The documentation for this class was generated from the following file: