LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
 

Private Member Functions

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

Detailed Description

Definition at line 31 of file OpFlash3DDrawer_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 48 of file OpFlash3DDrawer_tool.cc.

48 {}

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.

References evd::ColorDrawingOptions::CalQ(), DrawRectangularBox(), evd::RecoDrawingOptions::fDrawOpFlashes, evd::RecoDrawingOptions::fFlashMinPE, evd::RecoDrawingOptions::fFlashTMax, evd::RecoDrawingOptions::fFlashTMin, evd::RecoDrawingOptions::fOpFlashLabels, evd::ColorDrawingOptions::fRecoQHigh, evd::ColorDrawingOptions::fRecoQLow, geo::OpDetGeo::GetCenter(), evdb::ColorScale::GetColor(), geo::OpDetGeo::HalfH(), geo::OpDetGeo::HalfW(), art::Handle< T >::isValid(), geo::kCollection, geo::GeometryCore::OpDetGeoFromOpChannel(), art::PtrVector< T >::push_back(), and detinfo::sampling_rate().

51  {
53 
54  if (recoOpt->fDrawOpFlashes == 0) return;
55 
56  // Service recovery
58  auto const clock_data =
60  auto const det_prop =
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 
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...
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...
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  }
std::vector< art::InputTag > fOpFlashLabels
module labels that produced events
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:463
int GetColor(double x) const
Definition: ColorScale.cxx:126
double fFlashTMin
Minimal time for a flash to be displayed.
std::vector< double > fRecoQHigh
high edge of ADC values for drawing raw digits
double fFlashTMax
Maximum time for a flash to be displayed.
std::vector< double > fRecoQLow
low edge of ADC values for drawing raw digits
bool isValid() const noexcept
Definition: Handle.h:203
double HalfW() const
Definition: OpDetGeo.cxx:52
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
const evdb::ColorScale & CalQ(geo::SigType_t st) const
double fFlashMinPE
Minimal PE for a flash to be displayed.
geo::Point_t const & GetCenter() const
Definition: OpDetGeo.h:72
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:180
double HalfH() const
Definition: OpDetGeo.cxx:60
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Namespace collecting geometry-related classes utilities.
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
Signal from collection planes.
Definition: geo_types.h:152
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 212 of file OpFlash3DDrawer_tool.cc.

References evdb::View3D::AddPolyLine3D(), and DEFINE_ART_CLASS_TOOL.

Referenced by Draw().

218  {
219  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
220  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
221  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
222  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
223  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
224  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
225 
226  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
227  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
228  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
229  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
230  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
231  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
232 
233  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
234  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
235  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
236  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
237  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
238  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
239 
240  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
241  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
242  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
243  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
244  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
245  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
246 
247  return;
248  }
TPolyLine3D & AddPolyLine3D(int n, int c, int w, int s)
Definition: View3D.cxx:105
std::size_t color(std::string const &procname)

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