23 #include "TPolyMarker3D.h" 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;
94 if (simEnergyDepositHandle.
isValid() && simEnergyDepositHandle->size() > 0) {
96 <<
"Starting loop over " << simEnergyDepositHandle->size() <<
" SimEnergyDeposits, " 102 using MCPartToSimEnergyMap =
103 std::map<const simb::MCParticle*, std::vector<const sim::SimEnergyDeposit*>>;
105 MCPartToSimEnergyMap mcPartToSimEnergyMap;
108 for (
const auto& simEnergyDeposit : *simEnergyDepositHandle) {
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.);
132 for (
const auto& simEnergyDeposit : mcPartToSimEnergy.second) {
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);
198 if (simEnergyDepositHandle.
isValid() && simEnergyDepositHandle->size() > 0) {
200 <<
"Starting loop over " << simEnergyDepositHandle->size() <<
" SimEnergyDeposits, " 204 auto const clockData =
212 std::map<int, std::vector<sim::SimEnergyDeposit::Point_t>> colorToPositionMap;
215 for (
const auto& simEnergyDeposit : *simEnergyDepositHandle) {
221 double depTime = simEnergyDeposit.T();
224 double g4Ticks = clockData.TPCG4Time2Tick(depTime) -
trigger_offset(clockData);
225 double xPosMinTick = detProp.ConvertTicksToX(0, planeID);
226 double xOffset = detProp.ConvertTicksToX(g4Ticks, planeID) - xPosMinTick;
237 for (
const auto& pair : colorToPositionMap) {
238 int colorIdx(pair.first);
239 int markerIdx(kFullDotMedium);
242 TPolyMarker3D&
pm = view->AddPolyMarker3D(1, colorIdx, markerIdx, markerSize);
245 std::vector<double> posArrayVec;
248 posArrayVec.resize(3 * pair.second.size());
250 for (
const auto& point : pair.second) {
251 posArrayVec[3 * hitCount] = point.X();
252 posArrayVec[3 * hitCount + 1] = point.Y();
253 posArrayVec[3 * hitCount + 2] = point.Z();
257 pm.SetPolyMarker(hitCount, posArrayVec.data(), markerIdx);
The data type to uniquely identify a Plane.
art::InputTag fG4ModuleLabel
module label producing sim::SimChannel objects
geo::TPCID PositionToTPCID(geo::Point_t const &point) const
Returns the ID of the TPC at specified location.
art framework interface to geometry description
bool isValid() const noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void swap(Handle< T > &a, Handle< T > &b)
T get(std::string const &key) const
static int ColorFromPDG(int pdgcode)
static int max(int a, int b)
The data type to uniquely identify a TPC.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
contains information for a single step in the detector simulation
int trigger_offset(DetectorClocksData const &data)
QTextStream & endl(QTextStream &s)
art::InputTag fSimEnergyLabel
Also for SimEnergyDeposits.