SpacePoint3DDrawerAsymmetry_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file SpacePoint3DDrawerHitAsymmetry_tool.cc
3 /// \author T. Usher
4 ////////////////////////////////////////////////////////////////////////
5 
9 
12 #include "canvas/Persistency/Common/FindManyP.h"
13 
14 #include "TMath.h"
15 #include "TPolyMarker3D.h"
16 
17 namespace evdb_tool
18 {
19 
21 {
22 public:
24 
26 
27  void Draw(const std::vector<art::Ptr<recob::SpacePoint>>&, // Space points
28  evdb::View3D*, // 3D display
29  int, // Color
30  int, // Marker
31  float, // Size) const override;
32  const art::FindManyP<recob::Hit>* // pointer to associated hits
33  ) const;
34 
35 private:
36 
39 };
40 
41 //----------------------------------------------------------------------
42 // Constructor.
44 {
45 // fNumPoints = pset.get< int>("NumPoints", 1000);
46 // fFloatBaseline = pset.get<bool>("FloatBaseline", false);
47  // For now only draw cryostat=0.
48  fMinAsymmetry = pset.get<float>("MinAsymmetry", -1.);
49  fMaxAsymmetry = pset.get<float>("MaxAsymmetry", 1.);
50 
51  return;
52 }
53 
55 {
56  return;
57 }
58 
60  evdb::View3D* view,
61  int color,
62  int marker,
63  float size,
64  const art::FindManyP<recob::Hit>* hitAssnVec) const
65 {
66  // Let's not crash
67  if (hitsVec.empty() || !hitAssnVec) return;
68 
69  // Get services.
71 
72  using HitPosition = std::array<double,6>;
73  std::map<int,std::vector<HitPosition>> colorToHitMap;
74 
75  // Get the scale factor
76  float asymmetryScale((cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) / (fMaxAsymmetry - fMinAsymmetry));
77 
78  for(const auto& spacePoint : hitsVec)
79  {
80  float hitAsymmetry = spacePoint->ErrXYZ()[3] - fMinAsymmetry;
81 
82  if (std::abs(hitAsymmetry) <= fMaxAsymmetry - fMinAsymmetry)
83  {
84  float chgFactor = cst->fRecoQLow[geo::kCollection] + asymmetryScale * hitAsymmetry;
85  int chargeColorIdx = cst->CalQ(geo::kCollection).GetColor(chgFactor);
86  const double* pos = spacePoint->XYZ();
87  const double* err = spacePoint->ErrXYZ();
88 
89  colorToHitMap[chargeColorIdx].push_back(HitPosition()={{pos[0],pos[1],pos[2],err[2],err[2],err[5]}});
90  }
91  }
92 
93  for(auto& hitPair : colorToHitMap)
94  {
95  TPolyMarker3D& pm = view->AddPolyMarker3D(hitPair.second.size(), hitPair.first, kFullDotLarge, 0.25);
96  for (const auto& hit : hitPair.second) pm.SetNextPoint(hit[0],hit[1],hit[2]);
97  }
98 
99  return;
100 }
101 
103 }
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
struct vector vector
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
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
T abs(T value)
T get(std::string const &key) const
Definition: ParameterSet.h:271
const evdb::ColorScale & CalQ(geo::SigType_t st) const
void err(const char *fmt,...)
Definition: message.cpp:226
Detector simulation of raw signals on wires.
std::size_t color(std::string const &procname)
void Draw(const std::vector< art::Ptr< recob::SpacePoint >> &, evdb::View3D *, int, int, float, const art::FindManyP< recob::Hit > *) const
Signal from collection planes.
Definition: geo_types.h:146