12 #include "nuevdb/EventDisplayBase/View3D.h"
13 #include "nusimdata/SimulationBase/MCParticle.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 #include "art/Utilities/ToolMacros.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "TPolyLine3D.h"
33 void Draw(
const art::Event&, evdb::View3D*)
const override;
37 const Eigen::Vector3f&,
38 const Eigen::Vector3f&,
59 art::ServiceHandle<evd::SimulationDrawingOptions> drawOpt;
62 if (!drawOpt->fShowSimPhotonInfo)
return;
66 art::Handle<std::vector<simb::MCParticle>> mcParticleHandle;
68 evt.getByLabel(drawOpt->fG4ModuleLabel, mcParticleHandle);
70 if (!mcParticleHandle.isValid())
return;
73 using TrackToMcParticleMap = std::map<int, const simb::MCParticle*>;
75 TrackToMcParticleMap trackToMcParticleMap;
77 for (
const auto& mcParticle : *mcParticleHandle)
78 trackToMcParticleMap[mcParticle.TrackId()] = &mcParticle;
81 art::Handle<std::vector<sim::SimPhotons>> simPhotonsHandle;
83 evt.getByLabel(drawOpt->fSimPhotonLabel, simPhotonsHandle);
85 if (simPhotonsHandle.isValid() && simPhotonsHandle->size() > 0) {
86 mf::LogDebug(
"SimPhoton3DDrawer")
87 <<
"Starting loop over " << simPhotonsHandle->size() <<
" SimPhotons, " << std::endl;
90 art::ServiceHandle<geo::Geometry> geom;
91 art::ServiceHandle<evd::ColorDrawingOptions> cst;
94 using MCPartToOnePhotonMap =
95 std::map<const simb::MCParticle*, std::vector<const sim::OnePhoton*>>;
96 using ChanToMCPartToOnePhotonMap = std::map<int, MCPartToOnePhotonMap>;
98 ChanToMCPartToOnePhotonMap chanToMCPartToOnePhotonMap;
101 for (
const auto& simPhoton : *simPhotonsHandle) {
102 MCPartToOnePhotonMap& mcPartToOnePhotonMap =
103 chanToMCPartToOnePhotonMap[simPhoton.OpChannel()];
105 for (
const auto& onePhoton : simPhoton) {
106 TrackToMcParticleMap::const_iterator trackMCItr =
107 trackToMcParticleMap.find(onePhoton.MotherTrackID);
109 if (trackMCItr == trackToMcParticleMap.end())
continue;
111 mcPartToOnePhotonMap[trackMCItr->second].push_back(&onePhoton);
116 std::map<int, float> channelToEnergyMap;
119 float maxEnergy = std::numeric_limits<float>::lowest();
120 float minEnergy = std::numeric_limits<float>::max();
123 for (
const auto& chanToMCPartToOnePhoton : chanToMCPartToOnePhotonMap) {
127 for (
const auto& mcPartToOnePhoton : chanToMCPartToOnePhoton.second) {
136 for (
const auto& onePhoton : mcPartToOnePhoton.second) {
161 totalE += onePhoton->Energy;
165 channelToEnergyMap[chanToMCPartToOnePhoton.first] = totalE;
167 maxEnergy = std::max(maxEnergy, totalE);
168 minEnergy = std::min(minEnergy, totalE);
172 float yzWidthScale(1. / (maxEnergy - minEnergy));
173 float energyDepositScale(
177 for (
const auto& channelToEnergy : channelToEnergyMap) {
180 0.95 * std::max(
float(0.), std::min(
float(1.), yzWidthScale* channelToEnergy.second));
182 cst->fRecoQLow[
geo::kCollection] + energyDepositScale * channelToEnergy.second;
185 const geo::OpDetGeo& opHitGeo = geom->OpDetGeoFromOpChannel(channelToEnergy.first);
188 float zWidth = widthFactor * opHitGeo.
HalfW();
189 float yWidth = widthFactor * opHitGeo.
HalfH();
192 Eigen::Vector3f coordsLo(
193 opHitPos.X() - xWidth, opHitPos.Y() - yWidth, opHitPos.Z() - zWidth);
194 Eigen::Vector3f coordsHi(
195 opHitPos.X() + xWidth, opHitPos.Y() + yWidth, opHitPos.Z() + zWidth);
208 const Eigen::Vector3f& coordsLo,
209 const Eigen::Vector3f& coordsHi,
214 TPolyLine3D&
top = view->AddPolyLine3D(5, color, width, style);
215 top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
216 top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
217 top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
218 top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
219 top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
221 TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
222 side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
223 side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
224 side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
225 side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
226 side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
228 TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
229 side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
230 side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
231 side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
232 side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
233 side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
235 TPolyLine3D&
bottom = view->AddPolyLine3D(5, color, width, style);
236 bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
237 bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
238 bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
239 bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
240 bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
void GetCenter(double *xyz, double localz=0.0) const
The color scales used by the event display.
Simulation objects for optical detectors.
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
Signal from collection planes.