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 28 of file OpFlash3DDrawer_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file OpFlash3DDrawer_tool.cc.

45 {}

Member Function Documentation

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

Implements evdb_tool::I3DDrawer.

Definition at line 48 of file OpFlash3DDrawer_tool.cc.

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

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

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