67 art::ServiceHandle<evd::SimulationDrawingOptions const> drawOpt;
71 art::Handle<std::vector<simb::MCParticle>> mcParticleHandle;
73 evt.getByLabel(drawOpt->fG4ModuleLabel, mcParticleHandle);
75 if (!mcParticleHandle.isValid())
return;
78 using TrackToMcParticleMap = std::map<int, const simb::MCParticle*>;
80 TrackToMcParticleMap trackToMcParticleMap;
82 for (
const auto& mcParticle : *mcParticleHandle)
83 trackToMcParticleMap[mcParticle.TrackId()] = &mcParticle;
86 art::Handle<std::vector<sim::SimEnergyDeposit>> simEnergyDepositHandle;
88 evt.getByLabel(drawOpt->fSimEnergyLabel, simEnergyDepositHandle);
90 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(
evt);
92 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt, clockData);
94 if (simEnergyDepositHandle.isValid() && simEnergyDepositHandle->size() > 0) {
95 mf::LogDebug(
"SimEnergyDeposit3DDrawer")
96 <<
"Starting loop over " << simEnergyDepositHandle->size() <<
" SimEnergyDeposits, "
99 art::ServiceHandle<geo::Geometry const> geom;
102 using MCPartToSimEnergyMap =
103 std::map<const simb::MCParticle*, std::vector<const sim::SimEnergyDeposit*>>;
105 MCPartToSimEnergyMap mcPartToSimEnergyMap;
108 for (
const auto& simEnergyDeposit : *simEnergyDepositHandle) {
109 TrackToMcParticleMap::const_iterator trackMCItr =
110 trackToMcParticleMap.find(simEnergyDeposit.TrackID());
112 if (trackMCItr == trackToMcParticleMap.end())
continue;
114 mcPartToSimEnergyMap[trackMCItr->second].push_back(&simEnergyDeposit);
119 std::map<int, std::vector<sim::SimEnergyDeposit::Point_t>> colorToPositionMap;
122 for (
const auto& mcPartToSimEnergy : mcPartToSimEnergyMap) {
126 double g4Ticks(clockData.TPCG4Time2Tick(mcPartToSimEnergy.first->T()) -
129 double xPosMinTick(0.);
130 double xPosMaxTick(std::numeric_limits<double>::max());
132 for (
const auto& simEnergyDeposit : mcPartToSimEnergy.second) {
139 geo::TPCID tpcID = geom->PositionToTPCID(point);
142 xPosMinTick =
detProp.ConvertTicksToX(0, planeID);
143 xPosMaxTick =
detProp.ConvertTicksToX(
detProp.NumberTimeSamples(), planeID);
144 xOffset =
detProp.ConvertTicksToX(g4Ticks, planeID) - xPosMinTick;
146 if (xPosMaxTick < xPosMinTick) std::swap(xPosMinTick, xPosMaxTick);
158 for (
const auto& pair : colorToPositionMap) {
159 int colorIdx(pair.first);
160 int markerIdx(kFullDotMedium);
163 TPolyMarker3D& pm = view->AddPolyMarker3D(1, colorIdx, markerIdx, markerSize);
166 std::vector<double> posArrayVec;
169 posArrayVec.resize(3 * pair.second.size());
171 for (
const auto& point : pair.second) {
172 posArrayVec[3 * hitCount] = point.X();
173 posArrayVec[3 * hitCount + 1] = point.Y();
174 posArrayVec[3 * hitCount + 2] = point.Z();
178 pm.SetPolyMarker(hitCount, posArrayVec.data(), markerIdx);
The data type to uniquely identify a Plane.
static int ColorFromPDG(int pdgcode)
The data type to uniquely identify a TPC.
int trigger_offset(DetectorClocksData const &data)