All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpacePoint3DDrawerAsymmetry_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file SpacePoint3DDrawerHitAsymmetry_tool.cc
3 /// \author T. Usher
4 ////////////////////////////////////////////////////////////////////////
5 
9 
10 #include "nuevdb/EventDisplayBase/View3D.h"
11 
12 #include "art/Framework/Services/Registry/ServiceHandle.h"
13 #include "art/Utilities/ToolMacros.h"
14 #include "canvas/Persistency/Common/FindManyP.h"
15 
16 #include "TMath.h"
17 #include "TPolyMarker3D.h"
18 
19 namespace evdb_tool
20 {
21 
23 {
24 public:
25  explicit SpacePoint3DDrawerHitAsymmetry(const fhicl::ParameterSet&);
26 
28 
29  void Draw(const std::vector<art::Ptr<recob::SpacePoint>>&, // Space points
30  evdb::View3D*, // 3D display
31  int, // Color
32  int, // Marker
33  float, // Size) const override;
34  const art::FindManyP<recob::Hit>* // pointer to associated hits
35  ) const;
36 
37 private:
38 
41 };
42 
43 //----------------------------------------------------------------------
44 // Constructor.
46 {
47 // fNumPoints = pset.get< int>("NumPoints", 1000);
48 // fFloatBaseline = pset.get<bool>("FloatBaseline", false);
49  // For now only draw cryostat=0.
50  fMinAsymmetry = pset.get<float>("MinAsymmetry", -1.);
51  fMaxAsymmetry = pset.get<float>("MaxAsymmetry", 1.);
52 
53  return;
54 }
55 
57 {
58  return;
59 }
60 
61 void SpacePoint3DDrawerHitAsymmetry::Draw(const std::vector<art::Ptr<recob::SpacePoint>>& hitsVec,
62  evdb::View3D* view,
63  int color,
64  int marker,
65  float size,
66  const art::FindManyP<recob::Hit>* hitAssnVec) const
67 {
68  // Let's not crash
69  if (hitsVec.empty() || !hitAssnVec) return;
70 
71  // Get services.
72  art::ServiceHandle<evd::ColorDrawingOptions const> cst;
73 
74  using HitPosition = std::array<double,6>;
75  std::map<int,std::vector<HitPosition>> colorToHitMap;
76 
77  // Get the scale factor
78  float asymmetryScale((cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) / (fMaxAsymmetry - fMinAsymmetry));
79 
80  for(const auto& spacePoint : hitsVec)
81  {
82  float hitAsymmetry = spacePoint->ErrXYZ()[3] - fMinAsymmetry;
83 
84  if (std::abs(hitAsymmetry) <= fMaxAsymmetry - fMinAsymmetry)
85  {
86  float chgFactor = cst->fRecoQLow[geo::kCollection] + asymmetryScale * hitAsymmetry;
87  int chargeColorIdx = cst->CalQ(geo::kCollection).GetColor(chgFactor);
88  const double* pos = spacePoint->XYZ();
89  const double* err = spacePoint->ErrXYZ();
90 
91  colorToHitMap[chargeColorIdx].push_back(HitPosition()={{pos[0],pos[1],pos[2],err[2],err[2],err[5]}});
92  }
93  }
94 
95  for(auto& hitPair : colorToHitMap)
96  {
97  TPolyMarker3D& pm = view->AddPolyMarker3D(hitPair.second.size(), hitPair.first, kFullDotLarge, 0.25);
98  for (const auto& hit : hitPair.second) pm.SetNextPoint(hit[0],hit[1],hit[2]);
99  }
100 
101  return;
102 }
103 
104 DEFINE_ART_CLASS_TOOL(SpacePoint3DDrawerHitAsymmetry)
105 }
EResult err(const char *call)
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
process_name hit
Definition: cheaterreco.fcl:51
The color scales used by the event display.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
T abs(T value)
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