16 #include "nuevdb/EventDisplayBase/View3D.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "art/Utilities/ToolMacros.h"
21 #include "canvas/Persistency/Common/FindManyP.h"
23 #include "TPolyLine3D.h"
34 void Draw(
const art::Event&, evdb::View3D*)
const override;
38 const Eigen::Vector3f&,
39 const Eigen::Vector3f&,
52 art::ServiceHandle<evd::RecoDrawingOptions> recoOpt;
54 if (recoOpt->fDrawOpFlashes == 0)
return;
57 art::ServiceHandle<geo::Geometry> geo;
58 auto const clock_data =
59 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
61 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clock_data);
62 art::ServiceHandle<evd::ColorDrawingOptions> cst;
64 std::vector<geo::PlaneID> planeIDVec;
71 art::Handle<std::vector<recob::OpFlash>> opFlashHandle;
74 std::vector<float> opHitPEVec;
77 for (
size_t idx = 0; idx < recoOpt->fOpFlashLabels.size(); idx++) {
78 art::InputTag opFlashProducer = recoOpt->fOpFlashLabels[idx];
80 event.getByLabel(opFlashProducer, opFlashHandle);
82 if (!opFlashHandle.isValid())
continue;
83 if (opFlashHandle->size() == 0)
continue;
86 art::PtrVector<recob::OpFlash> opFlashVec;
88 for (
size_t idx = 0; idx < opFlashHandle->size(); idx++)
89 opFlashVec.push_back(art::Ptr<recob::OpFlash>(opFlashHandle, idx));
92 art::FindManyP<recob::OpHit> opHitAssnVec(opFlashVec, event, opFlashProducer);
94 if (opHitAssnVec.size() == 0)
continue;
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;
103 if (opFlashPtr->TotalPE() < recoOpt->fFlashMinPE)
continue;
104 if (opFlashPtr->Time() < recoOpt->fFlashTMin)
continue;
105 if (opFlashPtr->Time() > recoOpt->fFlashTMax)
continue;
108 const std::vector<art::Ptr<recob::OpHit>>& opHitVec = opHitAssnVec.at(opFlashPtr.key());
110 for (
const auto& opHit : opHitVec)
111 opHitPEVec.push_back(opHit->PE());
116 if (!opHitPEVec.empty()) {
118 std::sort(opHitPEVec.begin(), opHitPEVec.end());
120 float minTotalPE = opHitPEVec.front();
121 float maxTotalPE = opHitPEVec[0.9 * opHitPEVec.size()];
125 (maxTotalPE - minTotalPE));
128 for (
size_t idx = 0; idx < recoOpt->fOpFlashLabels.size(); idx++) {
129 art::InputTag opFlashProducer = recoOpt->fOpFlashLabels[idx];
131 event.getByLabel(opFlashProducer, opFlashHandle);
133 if (!opFlashHandle.isValid())
continue;
134 if (opFlashHandle->size() == 0)
continue;
137 art::PtrVector<recob::OpFlash> opFlashVec;
139 for (
size_t idx = 0; idx < opFlashHandle->size(); idx++)
140 opFlashVec.push_back(art::Ptr<recob::OpFlash>(opFlashHandle, idx));
143 art::FindManyP<recob::OpHit> opHitAssnVec(opFlashVec, event, opFlashProducer);
145 if (opHitAssnVec.size() == 0)
continue;
148 for (
const auto& opFlashPtr : opFlashVec) {
150 if (opFlashPtr->TotalPE() < recoOpt->fFlashMinPE)
continue;
151 if (opFlashPtr->Time() < recoOpt->fFlashTMin)
continue;
152 if (opFlashPtr->Time() > recoOpt->fFlashTMax)
continue;
155 const std::vector<art::Ptr<recob::OpHit>> opHitVec = opHitAssnVec.at(opFlashPtr.key());
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]);
165 float flashXpos = det_prop.ConvertTicksToX(flashTick, planeIDVec[idx]);
166 float flashXWid = det_prop.ConvertTicksToX(flashWidth, planeIDVec[idx]);
169 for (
const auto& opHit : opHitVec) {
170 unsigned int opChannel = opHit->OpChannel();
171 const geo::OpDetGeo& opHitGeo = geo->OpDetGeoFromOpChannel(opChannel);
173 float zWidth = opHitGeo.
HalfW();
174 float yWidth = opHitGeo.
HalfH();
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);
182 flashXpos = opHitPos.X();
185 opHitPEScale * std::min(maxTotalPE,
float(opHit->PE()));
192 std::cout <<
" == flashtick: " << flashTick <<
", flashwidth: " << flashWidth
193 <<
", flashXpos: " << flashXpos <<
", wid: " << flashXWid
194 <<
", opHitPEScale: " << opHitPEScale << std::endl;
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());
214 const Eigen::Vector3f& coordsLo,
215 const Eigen::Vector3f& coordsHi,
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]);
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]);
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]);
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]);
The data type to uniquely identify a Plane.
void GetCenter(double *xyz, double localz=0.0) const
The color scales used by the event display.
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.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
Signal from collection planes.