All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpacePoint3DDrawerChiSquare_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file SpacePoint3DDrawerChiSquare_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 "TPolyMarker3D.h"
17 
18 namespace evdb_tool
19 {
20 
22 {
23 public:
24  explicit SpacePoint3DDrawerChiSquare(const fhicl::ParameterSet&);
25 
27 
28  void Draw(const std::vector<art::Ptr<recob::SpacePoint>>&, // Space points
29  evdb::View3D*, // 3D display
30  int, // Color
31  int, // Marker
32  float, // Size) const override;
33  const art::FindManyP<recob::Hit>* // pointer to associated hits
34  ) const;
35 
36 private:
37 };
38 
39 //----------------------------------------------------------------------
40 // Constructor.
42 {
43 // fNumPoints = pset.get< int>("NumPoints", 1000);
44 // fFloatBaseline = pset.get<bool>("FloatBaseline", false);
45  // For now only draw cryostat=0.
46 
47  return;
48 }
49 
51 {
52  return;
53 }
54 
55 void SpacePoint3DDrawerChiSquare::Draw(const std::vector<art::Ptr<recob::SpacePoint>>& hitsVec,
56  evdb::View3D* view,
57  int color,
58  int marker,
59  float size,
60  const art::FindManyP<recob::Hit>* hitAssns) const
61 {
62  // Get services.
63  art::ServiceHandle<evd::ColorDrawingOptions const> cst;
64 
65  using HitPosition = std::array<double,6>;
66  std::map<int,std::vector<HitPosition>> colorToHitMap;
67 
68  float minHitChiSquare(0.);
69  float maxHitChiSquare(2.);
70  float hitChiSqScale((cst->fRecoQHigh[geo::kCollection] - cst->fRecoQLow[geo::kCollection]) / (maxHitChiSquare - minHitChiSquare));
71 
72  for(const auto& spacePoint : hitsVec)
73  {
74  const double* pos = spacePoint->XYZ();
75  const double* err = spacePoint->ErrXYZ();
76 
77  int chargeColorIdx(0);
78  float spacePointChiSq(spacePoint->Chisq());
79 
80  float hitChiSq = std::max(minHitChiSquare, std::min(maxHitChiSquare, spacePointChiSq));
81 
82  float chgFactor = cst->fRecoQHigh[geo::kCollection] - hitChiSqScale * hitChiSq;
83 
84  chargeColorIdx = cst->CalQ(geo::kCollection).GetColor(chgFactor);
85 
86  colorToHitMap[chargeColorIdx].push_back(HitPosition()={{pos[0],pos[1],pos[2],err[3],err[3],err[5]}});
87  }
88 
89  for(auto& hitPair : colorToHitMap)
90  {
91  TPolyMarker3D& pm = view->AddPolyMarker3D(hitPair.second.size(), hitPair.first, kFullDotLarge, 0.17);
92  for (const auto& hit : hitPair.second) pm.SetNextPoint(hit[0],hit[1],hit[2]);
93  }
94 
95  return;
96 }
97 
98 DEFINE_ART_CLASS_TOOL(SpacePoint3DDrawerChiSquare)
99 }
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
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