All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVAAlg.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////
2 // \fileMVAAlg.h
3 // m.haigh@warwick.ac.uk
4 ////////////////////////////////////////////////////////////////////
5 #ifndef MVAAlg_H
6 #define MVAAlg_H
7 
8 #include <map>
9 #include <string>
10 #include <vector>
11 
12 namespace art { class Event; }
13 #include "canvas/Persistency/Common/Assns.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 namespace fhicl { class ParameterSet; }
16 
18 
20 
21 namespace detinfo {
22  class DetectorClocksData;
23  class DetectorPropertiesData;
24 }
25 namespace recob {
26  class Hit;
27  class Shower;
28  class SpacePoint;
29  class Track;
30 }
31 #include "Math/Vector3Dfwd.h"
32 #include "TLorentzVector.h"
33 #include "TGraph2D.h"
34 #include "TMVA/Reader.h"
35 #include "TVector3.h"
36 
37 namespace mvapid {
38 
39  //---------------------------------------------------------------
40  class MVAAlg {
41  public:
42  struct SortedObj {
43  TVector3 start, end, dir;
44  double length;
45  std::map<double, const art::Ptr<recob::Hit>> hitMap;
46  };
47 
48  struct SumDistance2 {
49  // the TGraph is a data member of the object
50  TGraph2D* fGraph;
51 
52  SumDistance2(TGraph2D* g) : fGraph(g) {}
53 
54  // implementation of the function to be minimized
55  double
56  operator()(const double* p)
57  {
58 
59  ROOT::Math::XYZVector x0(p[0], p[2], p[4]);
60  ROOT::Math::XYZVector u(p[1], p[3], p[5]);
61 
62  u = u.Unit();
63  double* x = fGraph->GetX();
64  double* y = fGraph->GetY();
65  double* z = fGraph->GetZ();
66  int npoints = fGraph->GetN();
67  double sum = 0;
68  for (int i = 0; i < npoints; ++i) {
69  ROOT::Math::XYZVector xp(x[i], y[i], z[i]);
70  sum += ((xp - x0).Cross(u)).Mag2();
71  }
72  return sum;
73  }
74  };
75 
76  MVAAlg(fhicl::ParameterSet const& pset);
77 
78  void GetDetectorEdges();
79 
80  void GetWireNormals();
81 
82  void RunPID(art::Event& evt,
83  std::vector<anab::MVAPIDResult>& result,
84  art::Assns<recob::Track, anab::MVAPIDResult, void>& trackAssns,
85  art::Assns<recob::Shower, anab::MVAPIDResult, void>& showerAssns);
86 
87  private:
88  int IsInActiveVol(const TVector3& pos);
89 
90  void PrepareEvent(const art::Event& event, const detinfo::DetectorClocksData& clockData);
91 
92  void FitAndSortTrack(art::Ptr<recob::Track> track, int& isStoppingReco, SortedObj& sortedObj);
93 
94  //void SortShower(art::Ptr<recob::Shower> shower,TVector3 dir,int& isStoppingReco,
95  // mvapid::MVAAlg::SortedObj& sortedShower);
96  void SortShower(art::Ptr<recob::Shower> shower,
97  int& isStoppingReco,
98  mvapid::MVAAlg::SortedObj& sortedShower);
99 
100  void RunPCA(std::vector<art::Ptr<recob::Hit>>& hits,
101  std::vector<double>& eVals,
102  std::vector<double>& eVecs);
103 
104  void _Var_Shape(const SortedObj& track,
105  double& coreHaloRatio,
106  double& concentration,
107  double& conicalness);
108 
109  double CalcSegmentdEdxFrac(const detinfo::DetectorClocksData& clock_data,
110  const detinfo::DetectorPropertiesData& det_prop,
111  const SortedObj& track,
112  double start,
113  double end);
114 
115  double CalcSegmentdEdxDist(const detinfo::DetectorClocksData& clock_data,
116  const detinfo::DetectorPropertiesData& det_prop,
117  const SortedObj& track,
118  double start,
119  double end);
120 
121  double CalcSegmentdEdxDistAtEnd(const detinfo::DetectorClocksData& clock_data,
122  const detinfo::DetectorPropertiesData& det_prop,
124  double distAtEnd);
125 
126  int LinFit(const art::Ptr<recob::Track> track, TVector3& trackPoint, TVector3& trackDir);
127 
128  int LinFitShower(const art::Ptr<recob::Shower> shower,
129  TVector3& showerPoint,
130  TVector3& showerDir);
131 
133 
134  double fEventT0;
135 
137 
138  std::map<int, double> fNormToWiresY;
139  std::map<int, double> fNormToWiresZ;
140 
141  std::string fTrackLabel;
142  std::string fShowerLabel;
143  std::string fHitLabel;
144  std::string fSpacePointLabel;
145  std::string fTrackingLabel;
146 
147  std::vector<art::Ptr<recob::Track>> fTracks;
148  std::vector<art::Ptr<recob::Shower>> fShowers;
149  std::vector<art::Ptr<recob::SpacePoint>> fSpacePoints;
150  std::vector<art::Ptr<recob::Hit>> fHits;
151 
152  std::map<art::Ptr<recob::Track>, std::vector<art::Ptr<recob::Hit>>> fTracksToHits;
153  std::map<art::Ptr<recob::Track>, std::vector<art::Ptr<recob::SpacePoint>>> fTracksToSpacePoints;
154  std::map<art::Ptr<recob::Shower>, std::vector<art::Ptr<recob::Hit>>> fShowersToHits;
155  std::map<art::Ptr<recob::Shower>, std::vector<art::Ptr<recob::SpacePoint>>>
157  std::map<art::Ptr<recob::Hit>, art::Ptr<recob::SpacePoint>> fHitsToSpacePoints;
158  std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> fSpacePointsToHits;
159 
161 
162  TMVA::Reader fReader;
163 
164  std::vector<std::string> fMVAMethods;
165  std::vector<std::string> fWeightFiles;
166 
168 
169  TLorentzVector fVertex4Vect;
170 
171  }; // class MVAAlg
172 
173 } // namespace mvapid
174 
175 #endif // ifndef MVAAlg_H
std::vector< art::Ptr< recob::Shower > > fShowers
Definition: MVAAlg.h:148
process_name opflash particleana ie ie ie z
anab::MVAPIDResult fResHolder
Definition: MVAAlg.h:160
double CalcSegmentdEdxDistAtEnd(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const mvapid::MVAAlg::SortedObj &track, double distAtEnd)
Definition: MVAAlg.cxx:628
const calo::CalorimetryAlg fCaloAlg
Definition: MVAAlg.h:132
int LinFit(const art::Ptr< recob::Track > track, TVector3 &trackPoint, TVector3 &trackDir)
Definition: MVAAlg.cxx:690
void RunPCA(std::vector< art::Ptr< recob::Hit >> &hits, std::vector< double > &eVals, std::vector< double > &eVecs)
Definition: MVAAlg.cxx:522
SumDistance2(TGraph2D *g)
Definition: MVAAlg.h:52
double operator()(const double *p)
Definition: MVAAlg.h:56
process_name opflash particleana ie x
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > fHitsToSpacePoints
Definition: MVAAlg.h:157
double fDetMaxX
Definition: MVAAlg.h:136
std::vector< std::string > fMVAMethods
Definition: MVAAlg.h:164
pdgs p
Definition: selectors.fcl:22
int IsInActiveVol(const TVector3 &pos)
Definition: MVAAlg.cxx:78
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::Hit > > > fTracksToHits
Definition: MVAAlg.h:152
process_name use argoneut_mc_hitfinder track
std::string fSpacePointLabel
Definition: MVAAlg.h:144
Definition: Data.h:14
void PrepareEvent(const art::Event &event, const detinfo::DetectorClocksData &clockData)
Definition: MVAAlg.cxx:248
MVAAlg(fhicl::ParameterSet const &pset)
Definition: MVAAlg.cxx:33
TMVA::Reader fReader
Definition: MVAAlg.h:162
BEGIN_PROLOG g
bool fCheatVertex
Definition: MVAAlg.h:167
process_name shower
Definition: cheaterreco.fcl:51
Definition: Data.h:7
void RunPID(art::Event &evt, std::vector< anab::MVAPIDResult > &result, art::Assns< recob::Track, anab::MVAPIDResult, void > &trackAssns, art::Assns< recob::Shower, anab::MVAPIDResult, void > &showerAssns)
Definition: MVAAlg.cxx:147
std::vector< art::Ptr< recob::Hit > > fHits
Definition: MVAAlg.h:150
int LinFitShower(const art::Ptr< recob::Shower > shower, TVector3 &showerPoint, TVector3 &showerDir)
Definition: MVAAlg.cxx:739
void SortShower(art::Ptr< recob::Shower > shower, int &isStoppingReco, mvapid::MVAAlg::SortedObj &sortedShower)
Definition: MVAAlg.cxx:431
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void GetDetectorEdges()
Definition: MVAAlg.cxx:91
process_name opflash particleana ie ie y
double fDetMinY
Definition: MVAAlg.h:136
std::map< double, const art::Ptr< recob::Hit > > hitMap
Definition: MVAAlg.h:45
std::map< int, double > fNormToWiresY
Definition: MVAAlg.h:138
double fDetMinZ
Definition: MVAAlg.h:136
void GetWireNormals()
Definition: MVAAlg.cxx:114
std::vector< art::Ptr< recob::SpacePoint > > fSpacePoints
Definition: MVAAlg.h:149
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
double fDetMinX
Definition: MVAAlg.h:136
TLorentzVector fVertex4Vect
Definition: MVAAlg.h:169
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::Hit > > > fShowersToHits
Definition: MVAAlg.h:154
std::string fTrackingLabel
Definition: MVAAlg.h:145
double CalcSegmentdEdxFrac(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const SortedObj &track, double start, double end)
Definition: MVAAlg.cxx:616
std::string fTrackLabel
Definition: MVAAlg.h:141
std::string fHitLabel
Definition: MVAAlg.h:143
Contains all timing reference information for the detector.
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::SpacePoint > > > fTracksToSpacePoints
Definition: MVAAlg.h:153
void _Var_Shape(const SortedObj &track, double &coreHaloRatio, double &concentration, double &conicalness)
Definition: MVAAlg.cxx:547
std::vector< art::Ptr< recob::Track > > fTracks
Definition: MVAAlg.h:147
std::string fShowerLabel
Definition: MVAAlg.h:142
double fDetMaxZ
Definition: MVAAlg.h:136
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::SpacePoint > > > fShowersToSpacePoints
Definition: MVAAlg.h:156
TCEvent evt
Definition: DataStructs.cxx:8
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > fSpacePointsToHits
Definition: MVAAlg.h:158
double fDetMaxY
Definition: MVAAlg.h:136
void FitAndSortTrack(art::Ptr< recob::Track > track, int &isStoppingReco, SortedObj &sortedObj)
Definition: MVAAlg.cxx:348
std::map< int, double > fNormToWiresZ
Definition: MVAAlg.h:139
double fEventT0
Definition: MVAAlg.h:134
double CalcSegmentdEdxDist(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const SortedObj &track, double start, double end)
Definition: MVAAlg.cxx:639
std::vector< std::string > fWeightFiles
Definition: MVAAlg.h:165