LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
MVAAlg.h
Go to the documentation of this file.
1 // \fileMVAAlg.h
3 // m.haigh@warwick.ac.uk
5 #ifndef MVAAlg_H
6 #define MVAAlg_H
7 #include <vector>
8 #include <map>
9 //#include <cmath>
10 #include <iostream>
11 //#include <stdint.h>
12 
13 #include "fhiclcpp/ParameterSet.h"
18 
19 //#include "SimpleTypesAndConstants/geo_types.h"
20 //#include "SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
21 //#include "RecoBase/Wire.h"
27 //#include "RecoAlg/APAGeometryAlg.h"
29 //#include "MCCheater/BackTracker.h"
30 
31 //#include "TMatrixD.h"
32 //#include "TVectorD.h"
33 #include "TVector3.h"
34 #include "TLorentzVector.h"
35 #include "TGraph2D.h"
36 #include <Math/Vector3D.h>
37 #include "TMVA/Reader.h"
38 
40 
41 
42 namespace mvapid{
43 
44 
45 
46  //---------------------------------------------------------------
47  class MVAAlg {
48  public:
49 
50 struct SortedObj{
51  TVector3 start, end, dir;
52  double length;
53  std::map<double,const art::Ptr<recob::Hit> > hitMap;
54 };
55 
56 struct SumDistance2 {
57  // the TGraph is a data member of the object
58  TGraph2D* fGraph;
59 
60  SumDistance2(TGraph2D* g) : fGraph(g) {}
61 
62  // implementation of the function to be minimized
63  double operator() (const double * p) {
64 
65  ROOT::Math::XYZVector x0(p[0], p[2], p[4] );
66  ROOT::Math::XYZVector u(p[1],p[3], p[5] );
67 
68  u=u.Unit();
69  double * x = fGraph->GetX();
70  double * y = fGraph->GetY();
71  double * z = fGraph->GetZ();
72  int npoints = fGraph->GetN();
73  double sum = 0;
74  for (int i = 0; i < npoints; ++i) {
75  ROOT::Math::XYZVector xp(x[i],y[i],z[i]);
76  sum += ((xp-x0).Cross(u)) .Mag2();
77  }
78  return sum;
79  }
80 };
81 
82  MVAAlg(fhicl::ParameterSet const& pset, const art::EDProducer* parentModule);
83 
84  virtual ~MVAAlg();
85 
86  void GetDetectorEdges();
87 
88  void GetWireNormals();
89 
90  void reconfigure(fhicl::ParameterSet const& p);
91 
92  void RunPID(art::Event& evt,std::vector<anab::MVAPIDResult>& result,
95 
96  private:
97 
98  int IsInActiveVol(const TVector3& pos);
99 
100  void PrepareEvent(const art::Event& event);
101 
102  void FitAndSortTrack(art::Ptr<recob::Track> track,int& isStoppingReco,
103  SortedObj& sortedObj);
104 
105  //void SortShower(art::Ptr<recob::Shower> shower,TVector3 dir,int& isStoppingReco,
106  // mvapid::MVAAlg::SortedObj& sortedShower);
107  void SortShower(art::Ptr<recob::Shower> shower,int& isStoppingReco,mvapid::MVAAlg::SortedObj& sortedShower);
108 
109  void RunPCA(std::vector< art::Ptr<recob::Hit> >& hits,std::vector<double>& eVals,std::vector<double>& eVecs);
110 
111  void _Var_Shape(const SortedObj& track,
112  double& coreHaloRatio,double& concentration,
113  double& conicalness);
114 
115  double CalcSegmentdEdxFrac(const SortedObj& track,double start,double end);
116 
117  double CalcSegmentdEdxDist(const SortedObj& track,double start,double end);
118 
119  double CalcSegmentdEdxDistAtEnd(const mvapid::MVAAlg::SortedObj& track,double distAtEnd);
120 
121  int LinFit(const art::Ptr<recob::Track> track,TVector3& trackPoint,TVector3& trackDir);
122 
123  int LinFitShower(const art::Ptr<recob::Shower> shower,TVector3& showerPoint,TVector3& showerDir);
124 
126 
127  double fEventT0;
128 
130 
131  std::map<int,double> fNormToWiresY;
132  std::map<int,double> fNormToWiresZ;
133 
135 
136  std::string fTrackLabel;
137  std::string fShowerLabel;
138  std::string fHitLabel;
139  std::string fSpacePointLabel;
140  std::string fTrackingLabel;
141 
142  std::vector<art::Ptr<recob::Track> > fTracks;
143  std::vector<art::Ptr<recob::Shower> > fShowers;
144  std::vector<art::Ptr<recob::SpacePoint> > fSpacePoints;
145  std::vector<art::Ptr<recob::Hit> > fHits;
146 
147  std::map<art::Ptr<recob::Track>,std::vector<art::Ptr<recob::Hit> > > fTracksToHits;
148  std::map<art::Ptr<recob::Track>,std::vector<art::Ptr<recob::SpacePoint> > > fTracksToSpacePoints;
149  std::map<art::Ptr<recob::Shower>,std::vector<art::Ptr<recob::Hit> > > fShowersToHits;
150  std::map<art::Ptr<recob::Shower>,std::vector<art::Ptr<recob::SpacePoint> > > fShowersToSpacePoints;
151  std::map<art::Ptr<recob::Hit>,art::Ptr<recob::SpacePoint> > fHitsToSpacePoints;
152  std::map<art::Ptr<recob::SpacePoint>,art::Ptr<recob::Hit > > fSpacePointsToHits;
153 
155 
156  TMVA::Reader fReader;
157 
158  std::vector<std::string> fMVAMethods;
159  std::vector<std::string> fWeightFiles;
160 
162 
163  TLorentzVector fVertex4Vect;
164 
165  }; // class MVAAlg
166 
167 } // namespace mvapid
168 
169 #endif // ifndef MVAAlg_H
Float_t x
Definition: compare.C:6
std::vector< art::Ptr< recob::Shower > > fShowers
Definition: MVAAlg.h:143
double CalcSegmentdEdxDist(const SortedObj &track, double start, double end)
Definition: MVAAlg.cxx:618
anab::MVAPIDResult fResHolder
Definition: MVAAlg.h:154
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > fHitsToSpacePoints
Definition: MVAAlg.h:151
const calo::CalorimetryAlg fCaloAlg
Definition: MVAAlg.h:125
int LinFit(const art::Ptr< recob::Track > track, TVector3 &trackPoint, TVector3 &trackDir)
Definition: MVAAlg.cxx:661
SumDistance2(TGraph2D *g)
Definition: MVAAlg.h:60
double fDetMaxX
Definition: MVAAlg.h:129
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::SpacePoint > > > fTracksToSpacePoints
Definition: MVAAlg.h:148
std::vector< std::string > fMVAMethods
Definition: MVAAlg.h:158
double CalcSegmentdEdxFrac(const SortedObj &track, double start, double end)
Definition: MVAAlg.cxx:606
Declaration of signal hit object.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
int IsInActiveVol(const TVector3 &pos)
Definition: MVAAlg.cxx:76
std::string fSpacePointLabel
Definition: MVAAlg.h:139
TMVA::Reader fReader
Definition: MVAAlg.h:156
bool fCheatVertex
Definition: MVAAlg.h:161
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:148
std::vector< art::Ptr< recob::Hit > > fHits
Definition: MVAAlg.h:145
virtual ~MVAAlg()
Definition: MVAAlg.cxx:72
void RunPCA(std::vector< art::Ptr< recob::Hit > > &hits, std::vector< double > &eVals, std::vector< double > &eVecs)
Definition: MVAAlg.cxx:513
int LinFitShower(const art::Ptr< recob::Shower > shower, TVector3 &showerPoint, TVector3 &showerDir)
Definition: MVAAlg.cxx:708
Definition: MVAAlg.h:42
void SortShower(art::Ptr< recob::Shower > shower, int &isStoppingReco, mvapid::MVAAlg::SortedObj &sortedShower)
Definition: MVAAlg.cxx:437
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void GetDetectorEdges()
Definition: MVAAlg.cxx:89
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::Hit > > > fShowersToHits
Definition: MVAAlg.h:149
void hits()
Definition: readHits.C:15
void PrepareEvent(const art::Event &event)
Definition: MVAAlg.cxx:272
std::map< art::Ptr< recob::Track >, std::vector< art::Ptr< recob::Hit > > > fTracksToHits
Definition: MVAAlg.h:147
double fDetMinY
Definition: MVAAlg.h:129
double fDetMinZ
Definition: MVAAlg.h:129
void GetWireNormals()
Definition: MVAAlg.cxx:118
const art::EDProducer * fParentModule
Definition: MVAAlg.h:134
std::vector< art::Ptr< recob::SpacePoint > > fSpacePoints
Definition: MVAAlg.h:144
MVAAlg(fhicl::ParameterSet const &pset, const art::EDProducer *parentModule)
Definition: MVAAlg.cxx:28
double fDetMinX
Definition: MVAAlg.h:129
TLorentzVector fVertex4Vect
Definition: MVAAlg.h:163
Declaration of cluster object.
Provides recob::Track data product.
std::string fTrackingLabel
Definition: MVAAlg.h:140
std::string fTrackLabel
Definition: MVAAlg.h:136
std::string fHitLabel
Definition: MVAAlg.h:138
std::map< double, const art::Ptr< recob::Hit > > hitMap
Definition: MVAAlg.h:53
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::SpacePoint > > > fShowersToSpacePoints
Definition: MVAAlg.h:150
void reconfigure(fhicl::ParameterSet const &p)
Definition: MVAAlg.cxx:74
void _Var_Shape(const SortedObj &track, double &coreHaloRatio, double &concentration, double &conicalness)
Definition: MVAAlg.cxx:539
std::vector< art::Ptr< recob::Track > > fTracks
Definition: MVAAlg.h:142
std::string fShowerLabel
Definition: MVAAlg.h:137
std::map< int, double > fNormToWiresY
Definition: MVAAlg.h:131
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > fSpacePointsToHits
Definition: MVAAlg.h:152
double fDetMaxZ
Definition: MVAAlg.h:129
double fDetMaxY
Definition: MVAAlg.h:129
void FitAndSortTrack(art::Ptr< recob::Track > track, int &isStoppingReco, SortedObj &sortedObj)
Definition: MVAAlg.cxx:374
Float_t track
Definition: plot.C:34
double CalcSegmentdEdxDistAtEnd(const mvapid::MVAAlg::SortedObj &track, double distAtEnd)
Definition: MVAAlg.cxx:612
double fEventT0
Definition: MVAAlg.h:127
std::map< int, double > fNormToWiresZ
Definition: MVAAlg.h:132
std::vector< std::string > fWeightFiles
Definition: MVAAlg.h:159
Event finding and building.