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::OpFlash3DDrawer Class Reference
Inheritance diagram for evdb_tool::OpFlash3DDrawer:
evdb_tool::I3DDrawer

Public Member Functions

 OpFlash3DDrawer (const fhicl::ParameterSet &)
 
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 30 of file OpFlash3DDrawer_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 47 of file OpFlash3DDrawer_tool.cc.

47 {}

Member Function Documentation

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

Implements evdb_tool::I3DDrawer.

Definition at line 50 of file OpFlash3DDrawer_tool.cc.

51  {
52  art::ServiceHandle<evd::RecoDrawingOptions> recoOpt;
53 
54  if (recoOpt->fDrawOpFlashes == 0) return;
55 
56  // Service recovery
57  art::ServiceHandle<geo::Geometry> geo;
58  auto const clock_data =
59  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
60  auto const det_prop =
61  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clock_data);
62  art::ServiceHandle<evd::ColorDrawingOptions> cst;
63 
64  std::vector<geo::PlaneID> planeIDVec;
65 
66  planeIDVec.push_back(geo::PlaneID(0, 0, 0));
67  planeIDVec.push_back(geo::PlaneID(0, 1, 0));
68  planeIDVec.push_back(geo::PlaneID(1, 0, 0));
69  planeIDVec.push_back(geo::PlaneID(1, 1, 0));
70 
71  art::Handle<std::vector<recob::OpFlash>> opFlashHandle;
72 
73  // This seems like a time waster but we want to get the full color scale for all OpHits... so loops away...
74  std::vector<float> opHitPEVec;
75 
76  // This is almost identically the same for loop we will re-excute below... sigh...
77  for (size_t idx = 0; idx < recoOpt->fOpFlashLabels.size(); idx++) {
78  art::InputTag opFlashProducer = recoOpt->fOpFlashLabels[idx];
79 
80  event.getByLabel(opFlashProducer, opFlashHandle);
81 
82  if (!opFlashHandle.isValid()) continue;
83  if (opFlashHandle->size() == 0) continue;
84 
85  // To get associations we'll need an art ptr vector...
86  art::PtrVector<recob::OpFlash> opFlashVec;
87 
88  for (size_t idx = 0; idx < opFlashHandle->size(); idx++)
89  opFlashVec.push_back(art::Ptr<recob::OpFlash>(opFlashHandle, idx));
90 
91  // Recover the associations to op hits
92  art::FindManyP<recob::OpHit> opHitAssnVec(opFlashVec, event, opFlashProducer);
93 
94  if (opHitAssnVec.size() == 0) continue;
95 
96  // Start the loop over flashes
97  for (const auto& opFlashPtr : opFlashVec) {
98  std::cout << "--> opFlash PE: " << opFlashPtr->TotalPE() << ", Time: " << opFlashPtr->Time()
99  << ", width: " << opFlashPtr->TimeWidth() << ", y/w: " << opFlashPtr->YCenter()
100  << "/" << opFlashPtr->YWidth() << ", Z/w: " << opFlashPtr->ZCenter() << "/"
101  << opFlashPtr->ZWidth() << std::endl;
102  // Make some selections...
103  if (opFlashPtr->TotalPE() < recoOpt->fFlashMinPE) continue;
104  if (opFlashPtr->Time() < recoOpt->fFlashTMin) continue;
105  if (opFlashPtr->Time() > recoOpt->fFlashTMax) continue;
106 
107  // Start by going through the associated OpHits
108  const std::vector<art::Ptr<recob::OpHit>>& opHitVec = opHitAssnVec.at(opFlashPtr.key());
109 
110  for (const auto& opHit : opHitVec)
111  opHitPEVec.push_back(opHit->PE());
112  }
113  }
114 
115  // Do we have any flashes and hits?
116  if (!opHitPEVec.empty()) {
117  // Sorting is good for mind and body...
118  std::sort(opHitPEVec.begin(), opHitPEVec.end());
119 
120  float minTotalPE = opHitPEVec.front();
121  float maxTotalPE = opHitPEVec[0.9 * opHitPEVec.size()];
122 
123  // Now we can set the scaling factor for PE
124  float opHitPEScale((cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) /
125  (maxTotalPE - minTotalPE));
126 
127  // We are meant to draw the flashes/hits, so loop over the list of input flashes
128  for (size_t idx = 0; idx < recoOpt->fOpFlashLabels.size(); idx++) {
129  art::InputTag opFlashProducer = recoOpt->fOpFlashLabels[idx];
130 
131  event.getByLabel(opFlashProducer, opFlashHandle);
132 
133  if (!opFlashHandle.isValid()) continue;
134  if (opFlashHandle->size() == 0) continue;
135 
136  // To get associations we'll need an art ptr vector...
137  art::PtrVector<recob::OpFlash> opFlashVec;
138 
139  for (size_t idx = 0; idx < opFlashHandle->size(); idx++)
140  opFlashVec.push_back(art::Ptr<recob::OpFlash>(opFlashHandle, idx));
141 
142  // Recover the associations to op hits
143  art::FindManyP<recob::OpHit> opHitAssnVec(opFlashVec, event, opFlashProducer);
144 
145  if (opHitAssnVec.size() == 0) continue;
146 
147  // Start the loop over flashes
148  for (const auto& opFlashPtr : opFlashVec) {
149  // Make some selections...
150  if (opFlashPtr->TotalPE() < recoOpt->fFlashMinPE) continue;
151  if (opFlashPtr->Time() < recoOpt->fFlashTMin) continue;
152  if (opFlashPtr->Time() > recoOpt->fFlashTMax) continue;
153 
154  // Start by going through the associated OpHits
155  const std::vector<art::Ptr<recob::OpHit>> opHitVec = opHitAssnVec.at(opFlashPtr.key());
156 
157  // We use the flash time to give us an x position (for now... will
158  // need a better way eventually)
159  float flashTick = opFlashPtr->Time() / sampling_rate(clock_data) * 1e3 +
160  det_prop.GetXTicksOffset(planeIDVec[idx]);
161  float flashWidth = opFlashPtr->TimeWidth() / sampling_rate(clock_data) * 1e3 +
162  det_prop.GetXTicksOffset(planeIDVec[idx]);
163 
164  // Now convert from time to distance...
165  float flashXpos = det_prop.ConvertTicksToX(flashTick, planeIDVec[idx]);
166  float flashXWid = det_prop.ConvertTicksToX(flashWidth, planeIDVec[idx]);
167 
168  // Loop through the OpHits here
169  for (const auto& opHit : opHitVec) {
170  unsigned int opChannel = opHit->OpChannel();
171  const geo::OpDetGeo& opHitGeo = geo->OpDetGeoFromOpChannel(opChannel);
172  const geo::Point_t& opHitPos = opHitGeo.GetCenter();
173  float zWidth = opHitGeo.HalfW();
174  float yWidth = opHitGeo.HalfH();
175 
176  Eigen::Vector3f opHitLo(
177  opHitPos.X() - flashXWid, opHitPos.Y() - yWidth, opHitPos.Z() - zWidth);
178  Eigen::Vector3f opHitHi(
179  opHitPos.X() + flashXWid, opHitPos.Y() + yWidth, opHitPos.Z() + zWidth);
180 
181  // Temporary kludge...
182  flashXpos = opHitPos.X();
183 
184  float peFactor = cst->fRecoQLow[geo::kCollection] +
185  opHitPEScale * std::min(maxTotalPE, float(opHit->PE()));
186 
187  int chargeColorIdx = cst->CalQ(geo::kCollection).GetColor(peFactor);
188 
189  DrawRectangularBox(view, opHitLo, opHitHi, chargeColorIdx, 2, 1);
190  }
191 
192  std::cout << " == flashtick: " << flashTick << ", flashwidth: " << flashWidth
193  << ", flashXpos: " << flashXpos << ", wid: " << flashXWid
194  << ", opHitPEScale: " << opHitPEScale << std::endl;
195 
196  // std::vector<Eigen::Vector3f>
197  Eigen::Vector3f coordsLo(flashXpos - flashXWid,
198  opFlashPtr->YCenter() - opFlashPtr->YWidth(),
199  opFlashPtr->ZCenter() - opFlashPtr->ZWidth());
200  Eigen::Vector3f coordsHi(flashXpos + flashXWid,
201  opFlashPtr->YCenter() + opFlashPtr->YWidth(),
202  opFlashPtr->ZCenter() + opFlashPtr->ZWidth());
203 
204  DrawRectangularBox(view, coordsLo, coordsHi, kRed, 2, 1);
205  }
206  }
207  }
208 
209  return;
210  }
void DrawRectangularBox(evdb::View3D *, const Eigen::Vector3f &, const Eigen::Vector3f &, int, int, int) const
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
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
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
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
BEGIN_PROLOG could also be cout
Signal from collection planes.
Definition: geo_types.h:146
void evdb_tool::OpFlash3DDrawer::DrawRectangularBox ( evdb::View3D *  view,
const Eigen::Vector3f &  coordsLo,
const Eigen::Vector3f &  coordsHi,
int  color,
int  width,
int  style 
) const
private

Definition at line 213 of file OpFlash3DDrawer_tool.cc.

219  {
220  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
221  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
222  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
223  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
224  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
225  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
226 
227  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
228  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
229  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
230  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
231  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
232  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
233 
234  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
235  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
236  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
237  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
238  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
239  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
240 
241  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
242  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
243  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
244  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
245  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
246  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
247 
248  return;
249  }
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: