Public Member Functions | Private Member Functions | List of all members
evdb_tool::DrawSimPhoton3D Class Reference
Inheritance diagram for evdb_tool::DrawSimPhoton3D:
evdb_tool::ISim3DDrawer

Public Member Functions

 DrawSimPhoton3D (const fhicl::ParameterSet &pset)
 
 ~DrawSimPhoton3D ()
 
void Draw (const art::Event &, evdb::View3D *) const override
 
- Public Member Functions inherited from evdb_tool::ISim3DDrawer
virtual ~ISim3DDrawer () noexcept=default
 

Private Member Functions

void DrawRectangularBox (evdb::View3D *, const Eigen::Vector3f &, const Eigen::Vector3f &, int, int, int) const
 

Detailed Description

Definition at line 25 of file DrawSimPhoton3D_tool.cc.

Constructor & Destructor Documentation

evdb_tool::DrawSimPhoton3D::DrawSimPhoton3D ( const fhicl::ParameterSet pset)
explicit

Definition at line 44 of file DrawSimPhoton3D_tool.cc.

45  {
46  // fNumPoints = pset.get< int>("NumPoints", 1000);
47  // fFloatBaseline = pset.get<bool>("FloatBaseline", false);
48 
49  return;
50  }
evdb_tool::DrawSimPhoton3D::~DrawSimPhoton3D ( )

Definition at line 52 of file DrawSimPhoton3D_tool.cc.

52 {}

Member Function Documentation

void evdb_tool::DrawSimPhoton3D::Draw ( const art::Event evt,
evdb::View3D *  view 
) const
overridevirtual

Implements evdb_tool::ISim3DDrawer.

Definition at line 55 of file DrawSimPhoton3D_tool.cc.

56  {
58 
59  // If the option is turned off, there's nothing to do
60  if (!drawOpt->fShowSimPhotonInfo) return;
61 
62  // Recover a handle to the collection of MCParticles
63  // We need these so we can determine the offset (if any)
65 
66  evt.getByLabel(drawOpt->fG4ModuleLabel, mcParticleHandle);
67 
68  if (!mcParticleHandle.isValid()) return;
69 
70  // Create a mapping between track ID's and MCParticles
71  using TrackToMcParticleMap = std::map<int, const simb::MCParticle*>;
72 
73  TrackToMcParticleMap trackToMcParticleMap;
74 
75  for (const auto& mcParticle : *mcParticleHandle)
76  trackToMcParticleMap[mcParticle.TrackId()] = &mcParticle;
77 
78  // Now recover the simphotons
80 
81  evt.getByLabel(drawOpt->fSimPhotonLabel, simPhotonsHandle);
82 
83  if (simPhotonsHandle.isValid() && simPhotonsHandle->size() > 0) {
84  mf::LogDebug("SimPhoton3DDrawer")
85  << "Starting loop over " << simPhotonsHandle->size() << " SimPhotons, " << std::endl;
86 
87  // Get the detector properties, clocks...
90 
91  // First step is to create a map between MCParticle and SimEnergyDeposit objects...
92  using MCPartToOnePhotonMap =
93  std::map<const simb::MCParticle*, std::vector<const sim::OnePhoton*>>;
94  using ChanToMCPartToOnePhotonMap = std::map<int, MCPartToOnePhotonMap>;
95 
96  ChanToMCPartToOnePhotonMap chanToMCPartToOnePhotonMap;
97 
98  // Go through the SimEnergyDeposits and populate the map
99  for (const auto& simPhoton : *simPhotonsHandle) {
100  MCPartToOnePhotonMap& mcPartToOnePhotonMap =
101  chanToMCPartToOnePhotonMap[simPhoton.OpChannel()];
102 
103  for (const auto& onePhoton : simPhoton) {
105  trackToMcParticleMap.find(onePhoton.MotherTrackID);
106 
107  if (trackMCItr == trackToMcParticleMap.end()) continue;
108 
109  mcPartToOnePhotonMap[trackMCItr->second].push_back(&onePhoton);
110  }
111  }
112 
113  // Mapping of energy deposited per channel...
114  std::map<int, float> channelToEnergyMap;
115 
116  // Keep track of mininum and maximum
117  float maxEnergy = std::numeric_limits<float>::lowest();
118  float minEnergy = std::numeric_limits<float>::max();
119 
120  // Go through everything and get cenergy desposited per channel...
121  for (const auto& chanToMCPartToOnePhoton : chanToMCPartToOnePhotonMap) {
122  float totalE(0.);
123 
124  // Go through all contributors to this channel
125  for (const auto& mcPartToOnePhoton : chanToMCPartToOnePhoton.second) {
126  // Current scheme will ignore displacement in time... need to come back to this at some point...
127  // // The first task we need to take on is to find the offset for the energy deposit
128  // // This is for the case of "out of time" particles... (e.g. cosmic rays)
129  // double g4Ticks(detClocks->TPCG4Time2Tick(mcPartToOnePhoton.first->T())-theDetector->TriggerOffset());
130  // double xOffset(0.);
131  // double xPosMinTick(0.);
132  // double xPosMaxTick(std::numeric_limits<double>::max());
133 
134  for (const auto& onePhoton : mcPartToOnePhoton.second) {
135  // Eigen::Vector3f point(onePhoton->InitialPosition.X(),onePhoton->InitialPosition.Y(),onePhoton->InitialPosition.Z());
136  //
137  // std::cout << " - Initial: " << onePhoton->InitialPosition.X() << "/" << onePhoton->InitialPosition.Y() << "/" << onePhoton->InitialPosition.Z() << ", final : " //<< onePhoton->FinalLocalPosition.X() << "/" << onePhoton->FinalLocalPosition.Y() << "/" << onePhoton->FinalLocalPosition.Z() << std::endl;
138  //
139  // // If we have cosmic rays then we need to get the offset which allows translating from
140  // // when they were generated vs when they were tracked.
141  // // Note that this also explicitly checks that they are in a TPC volume
142  // try
143  // {
144  // geo::TPCID tpcID = geom->PositionToTPCID(geo::Point_t(point[0],point[1],point[2]));
145  //
146  // if (tpcID.Cryostat == geo::CryostatID::InvalidID || tpcID.TPC == geo::TPCID::InvalidID) continue;
147  //
148  // geo::PlaneID planeID(tpcID,0);
149  //
150  // xPosMinTick = theDetector->ConvertTicksToX(0,planeID);
151  // xPosMaxTick = theDetector->ConvertTicksToX(theDetector->NumberTimeSamples(),planeID);
152  // xOffset = theDetector->ConvertTicksToX(g4Ticks, planeID) - xPosMinTick;
153  //
154  // if (xPosMaxTick < xPosMinTick) std::swap(xPosMinTick,xPosMaxTick);
155  // }
156  // catch(...) {continue;}
157 
158  // Recover the deposited energy
159  totalE += onePhoton->Energy;
160  }
161  }
162 
163  channelToEnergyMap[chanToMCPartToOnePhoton.first] = totalE;
164 
165  maxEnergy = std::max(maxEnergy, totalE);
166  minEnergy = std::min(minEnergy, totalE);
167  }
168 
169  // Get the scale factor from energy deposit range
170  float yzWidthScale(1. / (maxEnergy - minEnergy));
171  float energyDepositScale(
172  (cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) * yzWidthScale);
173 
174  // Go through the channels and draw the objects
175  for (const auto& channelToEnergy : channelToEnergyMap) {
176  // Recover the color index based on energy
177  float widthFactor =
178  0.95 * std::max(float(0.), std::min(float(1.), yzWidthScale* channelToEnergy.second));
179  float energyFactor =
180  cst->fRecoQLow[geo::kCollection] + energyDepositScale * channelToEnergy.second;
181 
182  // Recover the position for this channel
183  const geo::OpDetGeo& opHitGeo = geom->OpDetGeoFromOpChannel(channelToEnergy.first);
184  const geo::Point_t& opHitPos = opHitGeo.GetCenter();
185  float xWidth = 0.01;
186  float zWidth = widthFactor * opHitGeo.HalfW();
187  float yWidth = widthFactor * opHitGeo.HalfH();
188 
189  // Get widths of box to draw
190  Eigen::Vector3f coordsLo(
191  opHitPos.X() - xWidth, opHitPos.Y() - yWidth, opHitPos.Z() - zWidth);
192  Eigen::Vector3f coordsHi(
193  opHitPos.X() + xWidth, opHitPos.Y() + yWidth, opHitPos.Z() + zWidth);
194 
195  int energyColorIdx = cst->CalQ(geo::kCollection).GetColor(energyFactor);
196 
197  DrawRectangularBox(view, coordsLo, coordsHi, energyColorIdx, 1, 1);
198  }
199  }
200 
201  return;
202  }
void DrawRectangularBox(evdb::View3D *, const Eigen::Vector3f &, const Eigen::Vector3f &, int, int, int) const
art::InputTag fG4ModuleLabel
module label producing sim::SimChannel objects
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
intermediate_table::const_iterator const_iterator
std::vector< double > fRecoQHigh
high edge of ADC values for drawing raw digits
std::vector< double > fRecoQLow
low edge of ADC values for drawing raw digits
bool isValid() const noexcept
Definition: Handle.h:191
double HalfW() const
Definition: OpDetGeo.cxx:71
bool fShowSimPhotonInfo
Display SimPhoton info in 3D display.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
art::InputTag fSimPhotonLabel
and for SimPhotons
const evdb::ColorScale & CalQ(geo::SigType_t st) const
static int max(int a, int b)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
double HalfH() const
Definition: OpDetGeo.cxx:79
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146
void evdb_tool::DrawSimPhoton3D::DrawRectangularBox ( evdb::View3D *  view,
const Eigen::Vector3f &  coordsLo,
const Eigen::Vector3f &  coordsHi,
int  color,
int  width,
int  style 
) const
private

Definition at line 205 of file DrawSimPhoton3D_tool.cc.

211  {
212  TPolyLine3D& top = view->AddPolyLine3D(5, color, width, style);
213  top.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
214  top.SetPoint(1, coordsHi[0], coordsHi[1], coordsLo[2]);
215  top.SetPoint(2, coordsHi[0], coordsHi[1], coordsHi[2]);
216  top.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
217  top.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
218 
219  TPolyLine3D& side = view->AddPolyLine3D(5, color, width, style);
220  side.SetPoint(0, coordsHi[0], coordsHi[1], coordsLo[2]);
221  side.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
222  side.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
223  side.SetPoint(3, coordsHi[0], coordsHi[1], coordsHi[2]);
224  side.SetPoint(4, coordsHi[0], coordsHi[1], coordsLo[2]);
225 
226  TPolyLine3D& side2 = view->AddPolyLine3D(5, color, width, style);
227  side2.SetPoint(0, coordsLo[0], coordsHi[1], coordsLo[2]);
228  side2.SetPoint(1, coordsLo[0], coordsLo[1], coordsLo[2]);
229  side2.SetPoint(2, coordsLo[0], coordsLo[1], coordsHi[2]);
230  side2.SetPoint(3, coordsLo[0], coordsHi[1], coordsHi[2]);
231  side2.SetPoint(4, coordsLo[0], coordsHi[1], coordsLo[2]);
232 
233  TPolyLine3D& bottom = view->AddPolyLine3D(5, color, width, style);
234  bottom.SetPoint(0, coordsLo[0], coordsLo[1], coordsLo[2]);
235  bottom.SetPoint(1, coordsHi[0], coordsLo[1], coordsLo[2]);
236  bottom.SetPoint(2, coordsHi[0], coordsLo[1], coordsHi[2]);
237  bottom.SetPoint(3, coordsLo[0], coordsLo[1], coordsHi[2]);
238  bottom.SetPoint(4, coordsLo[0], coordsLo[1], coordsLo[2]);
239 
240  return;
241  }
std::size_t color(std::string const &procname)

The documentation for this class was generated from the following file: