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 <vector>
10 
15 #include "fhiclcpp/ParameterSet.h"
16 
23 namespace detinfo {
24  class DetectorClocksData;
25  class DetectorPropertiesData;
26 }
27 
28 #include "Math/GenVector/Cartesian3D.h"
29 #include "Math/GenVector/DisplacementVector3D.h"
30 #include "Math/Vector3Dfwd.h"
31 #include "TGraph2D.h"
32 #include "TLorentzVector.h"
33 #include "TMVA/Reader.h"
34 #include "TVector3.h"
35 
36 namespace mvapid {
37 
38  //---------------------------------------------------------------
39  class MVAAlg {
40  public:
41  struct SortedObj {
42  TVector3 start, end, dir;
43  double length;
44  std::map<double, const art::Ptr<recob::Hit>> hitMap;
45  };
46 
47  struct SumDistance2 {
48  // the TGraph is a data member of the object
49  TGraph2D* fGraph;
50 
51  SumDistance2(TGraph2D* g) : fGraph(g) {}
52 
53  // implementation of the function to be minimized
54  double
55  operator()(const double* p)
56  {
57 
58  ROOT::Math::XYZVector x0(p[0], p[2], p[4]);
59  ROOT::Math::XYZVector u(p[1], p[3], p[5]);
60 
61  u = u.Unit();
62  double* x = fGraph->GetX();
63  double* y = fGraph->GetY();
64  double* z = fGraph->GetZ();
65  int npoints = fGraph->GetN();
66  double sum = 0;
67  for (int i = 0; i < npoints; ++i) {
68  ROOT::Math::XYZVector xp(x[i], y[i], z[i]);
69  sum += ((xp - x0).Cross(u)).Mag2();
70  }
71  return sum;
72  }
73  };
74 
75  MVAAlg(fhicl::ParameterSet const& pset);
76 
77  void GetDetectorEdges();
78 
79  void GetWireNormals();
80 
81  void RunPID(art::Event& evt,
82  std::vector<anab::MVAPIDResult>& result,
85 
86  private:
87  int IsInActiveVol(const TVector3& pos);
88 
89  void PrepareEvent(const art::Event& event, const detinfo::DetectorClocksData& clockData);
90 
91  void FitAndSortTrack(art::Ptr<recob::Track> track, int& isStoppingReco, SortedObj& sortedObj);
92 
93  //void SortShower(art::Ptr<recob::Shower> shower,TVector3 dir,int& isStoppingReco,
94  // mvapid::MVAAlg::SortedObj& sortedShower);
95  void SortShower(art::Ptr<recob::Shower> shower,
96  int& isStoppingReco,
97  mvapid::MVAAlg::SortedObj& sortedShower);
98 
99  void RunPCA(std::vector<art::Ptr<recob::Hit>>& hits,
100  std::vector<double>& eVals,
101  std::vector<double>& eVecs);
102 
103  void _Var_Shape(const SortedObj& track,
104  double& coreHaloRatio,
105  double& concentration,
106  double& conicalness);
107 
108  double CalcSegmentdEdxFrac(const detinfo::DetectorClocksData& clock_data,
109  const detinfo::DetectorPropertiesData& det_prop,
110  const SortedObj& track,
111  double start,
112  double end);
113 
114  double CalcSegmentdEdxDist(const detinfo::DetectorClocksData& clock_data,
115  const detinfo::DetectorPropertiesData& det_prop,
116  const SortedObj& track,
117  double start,
118  double end);
119 
120  double CalcSegmentdEdxDistAtEnd(const detinfo::DetectorClocksData& clock_data,
121  const detinfo::DetectorPropertiesData& det_prop,
122  const mvapid::MVAAlg::SortedObj& track,
123  double distAtEnd);
124 
125  int LinFit(const art::Ptr<recob::Track> track, TVector3& trackPoint, TVector3& trackDir);
126 
127  int LinFitShower(const art::Ptr<recob::Shower> shower,
128  TVector3& showerPoint,
129  TVector3& showerDir);
130 
132 
133  double fEventT0;
134 
135  double fDetMinX, fDetMaxX, fDetMinY, fDetMaxY, fDetMinZ, fDetMaxZ;
136 
137  std::map<int, double> fNormToWiresY;
138  std::map<int, double> fNormToWiresZ;
139 
145 
146  std::vector<art::Ptr<recob::Track>> fTracks;
147  std::vector<art::Ptr<recob::Shower>> fShowers;
148  std::vector<art::Ptr<recob::SpacePoint>> fSpacePoints;
149  std::vector<art::Ptr<recob::Hit>> fHits;
150 
151  std::map<art::Ptr<recob::Track>, std::vector<art::Ptr<recob::Hit>>> fTracksToHits;
152  std::map<art::Ptr<recob::Track>, std::vector<art::Ptr<recob::SpacePoint>>> fTracksToSpacePoints;
153  std::map<art::Ptr<recob::Shower>, std::vector<art::Ptr<recob::Hit>>> fShowersToHits;
154  std::map<art::Ptr<recob::Shower>, std::vector<art::Ptr<recob::SpacePoint>>>
156  std::map<art::Ptr<recob::Hit>, art::Ptr<recob::SpacePoint>> fHitsToSpacePoints;
157  std::map<art::Ptr<recob::SpacePoint>, art::Ptr<recob::Hit>> fSpacePointsToHits;
158 
160 
161  TMVA::Reader fReader;
162 
163  std::vector<std::string> fMVAMethods;
164  std::vector<std::string> fWeightFiles;
165 
167 
168  TLorentzVector fVertex4Vect;
169 
170  }; // class MVAAlg
171 
172 } // namespace mvapid
173 
174 #endif // ifndef MVAAlg_H
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::vector< art::Ptr< recob::Shower > > fShowers
Definition: MVAAlg.h:147
anab::MVAPIDResult fResHolder
Definition: MVAAlg.h:159
const calo::CalorimetryAlg fCaloAlg
Definition: MVAAlg.h:131
SumDistance2(TGraph2D *g)
Definition: MVAAlg.h:51
static constexpr double g
Definition: Units.h:144
double operator()(const double *p)
Definition: MVAAlg.h:55
static QCString result
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > fHitsToSpacePoints
Definition: MVAAlg.h:156
std::vector< std::string > fMVAMethods
Definition: MVAAlg.h:163
std::string string
Definition: nybbler.cc:12
struct vector vector
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::Hit > > > fTracksToHits
Definition: MVAAlg.h:151
std::string fSpacePointLabel
Definition: MVAAlg.h:143
string dir
TMVA::Reader fReader
Definition: MVAAlg.h:161
bool fCheatVertex
Definition: MVAAlg.h:166
std::vector< art::Ptr< recob::Hit > > fHits
Definition: MVAAlg.h:149
Definition: MVAAlg.h:36
std::map< double, const art::Ptr< recob::Hit > > hitMap
Definition: MVAAlg.h:44
std::map< int, double > fNormToWiresY
Definition: MVAAlg.h:137
double fDetMinZ
Definition: MVAAlg.h:135
std::vector< art::Ptr< recob::SpacePoint > > fSpacePoints
Definition: MVAAlg.h:148
p
Definition: test.py:223
TLorentzVector fVertex4Vect
Definition: MVAAlg.h:168
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::Hit > > > fShowersToHits
Definition: MVAAlg.h:153
General LArSoft Utilities.
std::string fTrackingLabel
Definition: MVAAlg.h:144
std::string fTrackLabel
Definition: MVAAlg.h:140
std::string fHitLabel
Definition: MVAAlg.h:142
Declaration of signal hit object.
Contains all timing reference information for the detector.
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::SpacePoint > > > fTracksToSpacePoints
Definition: MVAAlg.h:152
Provides recob::Track data product.
std::vector< art::Ptr< recob::Track > > fTracks
Definition: MVAAlg.h:146
std::string fShowerLabel
Definition: MVAAlg.h:141
list x
Definition: train.py:276
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::SpacePoint > > > fShowersToSpacePoints
Definition: MVAAlg.h:155
TCEvent evt
Definition: DataStructs.cxx:7
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > fSpacePointsToHits
Definition: MVAAlg.h:157
std::map< int, double > fNormToWiresZ
Definition: MVAAlg.h:138
double fEventT0
Definition: MVAAlg.h:133
std::vector< std::string > fWeightFiles
Definition: MVAAlg.h:164
Event finding and building.