371 std::vector<const simb::MCParticle*> plist;
375 int neutralColor(12);
377 int neutrinoColor(38);
384 <<
"Starting loop over " << plist.size() <<
" McParticles, voxel list size is " 397 std::map<int, const simb::MCParticle*> trackToMcParticleMap;
400 double minPartEnergy(0.01);
402 for (
size_t p = 0;
p < plist.size(); ++
p) {
403 trackToMcParticleMap[plist[
p]->TrackId()] = plist[
p];
411 int pdgCode(mcPart->
PdgCode());
415 double partEnergy = mcPart->
E();
419 if (!mcTraj.
empty() && partEnergy > minPartEnergy && mcPart->
TrackId() < 100000000) {
420 double g4Ticks(clockData.TPCG4Time2Tick(mcPart->
T()) -
trigger_offset(clockData));
422 double xPosMinTick = 0.;
426 int numTrajPoints = mcTraj.
size();
428 std::unique_ptr<double[]> hitPositions(
new double[3 * numTrajPoints]);
431 for (
int hitIdx = 0; hitIdx < numTrajPoints; hitIdx++) {
432 double xPos = mcTraj.
X(hitIdx);
433 double yPos = mcTraj.
Y(hitIdx);
434 double zPos = mcTraj.
Z(hitIdx);
445 xPosMinTick = detProp.ConvertTicksToX(0, planeID);
446 xPosMaxTick = detProp.ConvertTicksToX(detProp.NumberTimeSamples(), planeID);
447 xOffset = detProp.ConvertTicksToX(g4Ticks, planeID) - xPosMinTick;
449 if (xPosMaxTick < xPosMinTick)
std::swap(xPosMinTick, xPosMaxTick);
459 if (xPos > xPosMinTick && xPos < xPosMaxTick) {
469 hitPositions[3 * hitCount] = xPos;
470 hitPositions[3 * hitCount + 1] = yPos;
471 hitPositions[3 * hitCount + 2] = zPos;
476 TPolyLine3D& pl(view->AddPolyLine3D(1, colorIdx, 1, 1));
479 if (partCharge == 0.) {
480 pl.SetLineColor(neutralColor);
484 pl.SetPolyLine(hitCount, hitPositions.get(),
"");
490 std::map<const simb::MCParticle*, std::vector<std::vector<double>>> partToPosMap;
493 for (vxitr = voxels.
begin(); vxitr != voxels.
end(); vxitr++) {
498 int trackId = vxd.
TrackID(partIdx);
503 partToPosMap[mcPart].push_back(std::vector<double>(3));
505 partToPosMap[mcPart].back()[0] = vxd.
VoxelID().
X();
506 partToPosMap[mcPart].back()[1] = vxd.
VoxelID().
Y();
507 partToPosMap[mcPart].back()[2] = vxd.
VoxelID().
Z();
514 std::map<const simb::MCParticle*, std::vector<std::vector<double>>>
::iterator partToPosMapItr;
516 for (partToPosMapItr = partToPosMap.begin(); partToPosMapItr != partToPosMap.end();
522 if (!mcPart || partToPosMapItr->second.empty())
continue;
524 double g4Ticks(clockData.TPCG4Time2Tick(mcPart->
T()) -
trigger_offset(clockData));
526 double xPosMinTick = 0.;
530 int markerIdx(kFullDotSmall);
534 colorIdx = grayedColor;
539 std::unique_ptr<double[]> hitPositions(
new double[3 * partToPosMapItr->second.size()]);
543 for (
size_t posIdx = 0; posIdx < partToPosMapItr->second.size(); posIdx++) {
544 const std::vector<double>& posVec = partToPosMapItr->second[posIdx];
547 geo::Point_t hitLocation(posVec[0], posVec[1], posVec[2]);
553 xPosMinTick = detProp.ConvertTicksToX(0, planeID);
554 xPosMaxTick = detProp.ConvertTicksToX(detProp.NumberTimeSamples(), planeID);
555 xOffset = detProp.ConvertTicksToX(g4Ticks, planeID) - xPosMinTick;
557 if (xPosMaxTick < xPosMinTick)
std::swap(xPosMinTick, xPosMaxTick);
563 double xCoord = posVec[0] + xOffset;
567 if (xCoord > xPosMinTick && xCoord < xPosMaxTick) {
568 hitPositions[3 * hitCount] = xCoord;
569 hitPositions[3 * hitCount + 1] = posVec[1];
570 hitPositions[3 * hitCount + 2] = posVec[2];
575 TPolyMarker3D&
pm = view->AddPolyMarker3D(1, colorIdx, markerIdx, markerSize);
576 pm.SetPolyMarker(hitCount, hitPositions.get(), markerIdx);
580 std::vector<const simb::MCTruth*> mctruth;
584 for (
unsigned int idx = 0; idx < mctruth.size(); idx++) {
586 for (
int particleIdx = 0; particleIdx < mctruth[idx]->NParticles(); particleIdx++) {
594 TVector3 particlePosition(mcPart.
Vx(), mcPart.
Vy(), mcPart.
Vz());
597 TVector3 oppPartDir(-mcPart.
Px(), -mcPart.
Py(), -mcPart.
Pz());
599 if (oppPartDir.Mag2() > 0.) oppPartDir.SetMag(1.);
601 double arcLenToDraw = -particlePosition.Z() / oppPartDir.CosTheta();
604 if (arcLenToDraw > 0.) {
606 TPolyLine3D& pl(view->AddPolyLine3D(2, neutrinoColor, 1, 2));
608 pl.SetPoint(0, particlePosition.X(), particlePosition.Y(), particlePosition.Z());
610 particlePosition +=
std::min(arcLenToDraw + 10., 1000.) * oppPartDir;
612 pl.SetPoint(1, particlePosition.X(), particlePosition.Y(), particlePosition.Z());
double E(const int i=0) const
double Z(const size_type i) const
double X(const size_type i) const
double Py(const int i=0) const
const simb::MCTrajectory & Trajectory() const
The data type to uniquely identify a Plane.
double Px(const int i=0) const
static sim::LArVoxelList GetLArVoxelList(const art::Event &evt, std::string moduleLabel)
int GetMCTruth(const art::Event &evt, std::vector< const simb::MCTruth * > &mctruth)
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.
list_type::const_iterator const_iterator
double Y(const size_type i) const
void swap(Handle< T > &a, Handle< T > &b)
int GetParticle(const art::Event &evt, std::vector< const simb::MCParticle * > &plist)
static int ColorFromPDG(int pdgcode)
double T(const int i=0) const
double fMinEnergyDeposition
bool fShowMCTruthTrajectories
size_type NumberParticles() const
static int max(int a, int b)
The data type to uniquely identify a TPC.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
double Vx(const int i=0) const
mapped_type Energy() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
double Pz(const int i=0) const
double Vz(const int i=0) const
int trigger_offset(DetectorClocksData const &data)
sim::LArVoxelID VoxelID() const
double Vy(const int i=0) const
QTextStream & endl(QTextStream &s)
bool fShowMCTruthFullSize
const key_type & TrackID(const size_type) const