LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
EMShowerAlg.h
Go to the documentation of this file.
1 // Implementation of the EMShower algorithm
3 //
4 // Forms EM showers from clusters and associated tracks.
5 // Also provides methods for finding the vertex and further
6 // properties of the shower.
7 //
8 // Mike Wallbank (m.wallbank@sheffield.ac.uk), September 2015
10 
11 #ifndef EMShowerAlg_hxx
12 #define EMShowerAlg_hxx
13 
14 // framework
15 #include "fhiclcpp/ParameterSet.h"
24 
25 // larsoft
45 
46 // C++
47 #include <iostream>
48 #include <map>
49 #include <iterator>
50 
51 // ROOT
52 #include "TVector2.h"
53 #include "TMath.h"
54 
55 //temp
56 #include "TGraph.h"
57 #include "TMultiGraph.h"
58 #include "TLine.h"
59 #include "TCanvas.h"
60 #include "TString.h"
61 #include "TF1.h"
63 #include "TH1I.h"
64 #include "TText.h"
65 #include "TFile.h"
66 #include "TPrincipal.h"
67 #include "TProfile.h"
68 
69 namespace shower {
70  class EMShowerAlg;
71  class HitPosition;
72 }
73 
75 public:
76 
77  EMShowerAlg(fhicl::ParameterSet const& pset);
78 
81  art::FindManyP<recob::Hit> const& fmh,
83  std::map<int,std::vector<int> >& clusterToTracks,
84  std::map<int,std::vector<int> >& trackToClusters);
85 
88  art::FindManyP<recob::Hit> const& fmh,
90  std::vector<int> const& clustersToIgnore,
91  std::map<int,std::vector<int> >& clusterToTracks,
92  std::map<int,std::vector<int> >& trackToClusters);
93 
95  std::vector<int> CheckShowerPlanes(std::vector<std::vector<int> > const& initialShowers,
96  std::vector<art::Ptr<recob::Cluster> > const& clusters,
97  art::FindManyP<recob::Hit> const& fmh);
98 
102  std::unique_ptr<recob::Track> ConstructTrack(std::vector<art::Ptr<recob::Hit> > const& track1,
103  std::vector<art::Ptr<recob::Hit> > const& track2,
104  std::map<int,TVector2> const& showerCentreMap);
105 
108  std::unique_ptr<recob::Track> ConstructTrack(std::vector<art::Ptr<recob::Hit> > const& track1,
109  std::vector<art::Ptr<recob::Hit> > const& track2);
110 
112  void FindInitialTrack(const std::map<int,std::vector<art::Ptr<recob::Hit> > >& hits,//art::PtrVector<recob::Hit> const& hits,
113  std::unique_ptr<recob::Track>& initialTrack,
114  std::map<int,std::vector<art::Ptr<recob::Hit> > >& initialTrackHits, int plane);
115 
117  std::vector<std::vector<int> > FindShowers(std::map<int,std::vector<int> > const& trackToClusters);
118 
121  std::unique_ptr<recob::Track> const& initialTrack,
122  std::map<int,std::vector<art::Ptr<recob::Hit> > > const& initialTrackHits);
123 
127  int & iok);
128 
130  std::vector<recob::SpacePoint> MakeSpacePoints(std::map<int,std::vector<art::Ptr<recob::Hit> > > hits, std::vector<std::vector<art::Ptr<recob::Hit> > >& hitAssns);
131 
133  //std::map<int,std::vector<art::Ptr<recob::Hit> > > OrderShowerHits(art::PtrVector<recob::Hit> const& shower, int plane);
134  std::map<int,std::vector<art::Ptr<recob::Hit> > > OrderShowerHits(const art::PtrVector<recob::Hit>& shower, int plane);
135 
137  void FindInitialTrackHits(std::vector<art::Ptr<recob::Hit> >const& showerHits,
138  art::Ptr<recob::Vertex> const& vertex,
139  std::vector<art::Ptr<recob::Hit> >& trackHits);
140 
142  Int_t WeightedFit(const Int_t n, const Double_t *x, const Double_t *y, const Double_t *w, Double_t *parm);
143 
145  bool isCleanShower(std::vector<art::Ptr<recob::Hit> > const& hits);
146 
147  int fDebug;
148 
149 private:
150 
152  void CheckIsolatedHits(std::map<int,std::vector<art::Ptr<recob::Hit> > >& showerHitsMap);
153 
156  bool CheckShowerHits(std::map<int,std::vector<art::Ptr<recob::Hit> > > const& showerHitsMap);
157 
159  TVector3 Construct3DPoint(art::Ptr<recob::Hit> const& hit1, art::Ptr<recob::Hit> const& hit2);
160 
162  double FinddEdx(std::vector<art::Ptr<recob::Hit> > const& trackHits, std::unique_ptr<recob::Track> const& track);
163 
166  std::vector<art::Ptr<recob::Hit> > FindOrderOfHits(std::vector<art::Ptr<recob::Hit> > const& hits, bool perpendicular = false);
167 
170  std::map<int,std::vector<art::Ptr<recob::Hit> > > FindShowerStart(std::map<int,std::vector<art::Ptr<recob::Hit> > > const& orderedShowerMap);
171 
176  std::map<int,std::map<int,bool> > GetPlanePermutations(const std::map<int,std::vector<art::Ptr<recob::Hit> > >& showerHitsMap);
177 
179  double GlobalWire(const geo::WireID& wireID);
180 
182  TVector2 HitCoordinates(art::Ptr<recob::Hit> const& hit);
183 
185  TVector2 HitPosition(art::Ptr<recob::Hit> const& hit);
186 
188  TVector2 HitPosition(TVector2 const& pos, geo::PlaneID planeID);
189 
191  std::unique_ptr<recob::Track> MakeInitialTrack(std::map<int,std::vector<art::Ptr<recob::Hit> > > const& initialHitsMap,
192  std::map<int,std::vector<art::Ptr<recob::Hit> > > const& showerHitsMap);
193 
195  void OrderShowerHits(std::vector<art::Ptr<recob::Hit> > const& shower,
196  std::vector<art::Ptr<recob::Hit> >& orderedShower,
197  art::Ptr<recob::Vertex> const& vertex);
198 
201  TVector2 Project3DPointOntoPlane(TVector3 const& point, int plane, int cryostat = 0);
202 
206  std::map<double,int> RelativeWireWidth(const std::map<int,std::vector<art::Ptr<recob::Hit> > >& showerHitsMap);
207 
209  TVector2 ShowerCentre(const std::vector<art::Ptr<recob::Hit> >& showerHits);
210 
212  TVector2 ShowerDirection(const std::vector<art::Ptr<recob::Hit> >& showerHits);
213 
215  double ShowerHitRMS(const std::vector<art::Ptr<recob::Hit> >& showerHits);
216 
218  double ShowerHitRMSGradient(const std::vector<art::Ptr<recob::Hit> >& showerHits, TVector2 trueStart = TVector2(0,0));
219 
221  int WorstPlane(const std::map<int,std::vector<art::Ptr<recob::Hit> > >& showerHitsMap);
222 
223 
224  // Parameters
228  // Parameters to fit wire vs time
229  unsigned int fNfitpass;
230  std::vector<unsigned int> fNfithits;
231  std::vector<double> fToler;
232 
233  // Services used by this class
237 
238  // Algs used by this class
242 
243  std::string fDetector;
244 
245 
246  // tmp
247  int FindTrueParticle(const std::vector<art::Ptr<recob::Hit> >& showerHits);
252  void MakePicture();
255 
256 };
257 
259  public:
260 
261  TVector2 WireTick;
262  TVector2 Cm;
263 
264  // default constructor
265  HitPosition();
266  // contructors
267  HitPosition(TVector2 wiretick, TVector2 cm): HitPosition()
268  {
269  WireTick = wiretick;
270  Cm = cm;
271  }
272  HitPosition(TVector2 wiretick, geo::PlaneID planeID): HitPosition() {
273  WireTick = wiretick;
274  Cm = ConvertWireTickToCm(wiretick, planeID);
275  }
276 
277  TVector2 ConvertWireTickToCm(TVector2 wiretick, geo::PlaneID planeID) {
278  return TVector2(wiretick.X() * fGeom->WirePitch(planeID),
279  fDetProp->ConvertTicksToX(wiretick.Y(), planeID));
280  }
281 
282  private:
283 
284  geo::GeometryCore const* fGeom = nullptr;
286 
287 };
288 
289 #endif
Float_t x
Definition: compare.C:6
TProfile * hNumSegments
Definition: EMShowerAlg.h:251
double GlobalWire(const geo::WireID &wireID)
Find the global wire position.
std::vector< double > fToler
Definition: EMShowerAlg.h:231
art::ServiceHandle< cheat::BackTrackerService > bt_serv
Definition: EMShowerAlg.h:249
Int_t WeightedFit(const Int_t n, const Double_t *x, const Double_t *y, const Double_t *w, Double_t *parm)
<Tingjun to="" document>="">
void FindInitialTrackHits(std::vector< art::Ptr< recob::Hit > >const &showerHits, art::Ptr< recob::Vertex > const &vertex, std::vector< art::Ptr< recob::Hit > > &trackHits)
<Tingjun to="" document>="">
Encapsulate the construction of a single cyostat.
EMShowerAlg(fhicl::ParameterSet const &pset)
Definition: EMShowerAlg.cxx:13
Implementation of the Projection Matching Algorithm.
std::vector< recob::SpacePoint > MakeSpacePoints(std::map< int, std::vector< art::Ptr< recob::Hit > > > hits, std::vector< std::vector< art::Ptr< recob::Hit > > > &hitAssns)
Makes space points from the shower hits in each plane.
std::map< int, std::vector< art::Ptr< recob::Hit > > > FindShowerStart(std::map< int, std::vector< art::Ptr< recob::Hit > > > const &orderedShowerMap)
Declaration of signal hit object.
Float_t y
Definition: compare.C:6
TVector3 Construct3DPoint(art::Ptr< recob::Hit > const &hit1, art::Ptr< recob::Hit > const &hit2)
Constructs a 3D point (in [cm]) to represent the hits given in two views.
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
TVector2 Project3DPointOntoPlane(TVector3 const &point, int plane, int cryostat=0)
bool CheckShowerHits(std::map< int, std::vector< art::Ptr< recob::Hit > > > const &showerHitsMap)
std::map< int, std::vector< art::Ptr< recob::Hit > > > OrderShowerHits(const art::PtrVector< recob::Hit > &shower, int plane)
Takes the hits associated with a shower and orders them so they follow the direction of the shower...
TVector2 HitPosition(art::Ptr< recob::Hit > const &hit)
Return the coordinates of this hit in units of cm.
int FindParticleID(const art::Ptr< recob::Hit > &hit)
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
TVector2 ShowerDirection(const std::vector< art::Ptr< recob::Hit > > &showerHits)
Returns a rough charge-weighted shower &#39;direction&#39; given the hits in the shower.
bool isCleanShower(std::vector< art::Ptr< recob::Hit > > const &hits)
<Tingjun to="" document>="">
calo::CalorimetryAlg fCalorimetryAlg
Definition: EMShowerAlg.h:240
TVector2 ShowerCentre(const std::vector< art::Ptr< recob::Hit > > &showerHits)
Returns the charge-weighted shower centre.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::unique_ptr< recob::Track > MakeInitialTrack(std::map< int, std::vector< art::Ptr< recob::Hit > > > const &initialHitsMap, std::map< int, std::vector< art::Ptr< recob::Hit > > > const &showerHitsMap)
Takes initial track hits from multiple views and forms a track object which best represents the start...
Access the description of detector geometry.
HitPosition(TVector2 wiretick, TVector2 cm)
Definition: EMShowerAlg.h:267
void hits()
Definition: readHits.C:15
std::vector< std::vector< int > > FindShowers(std::map< int, std::vector< int > > const &trackToClusters)
Makes showers given a map between tracks and all clusters associated with them.
HitPosition(TVector2 wiretick, geo::PlaneID planeID)
Definition: EMShowerAlg.h:272
int WorstPlane(const std::map< int, std::vector< art::Ptr< recob::Hit > > > &showerHitsMap)
Returns the plane which is determined to be the least likely to be correct.
unsigned int fNfitpass
Definition: EMShowerAlg.h:229
void AssociateClustersAndTracks(std::vector< art::Ptr< recob::Cluster > > const &clusters, art::FindManyP< recob::Hit > const &fmh, art::FindManyP< recob::Track > const &fmt, std::map< int, std::vector< int > > &clusterToTracks, std::map< int, std::vector< int > > &trackToClusters)
Map associated tracks and clusters together given their associated hits.
Definition: EMShowerAlg.cxx:43
std::string fDetector
Definition: EMShowerAlg.h:243
shower::ShowerEnergyAlg fShowerEnergyAlg
Definition: EMShowerAlg.h:239
TVector2 ConvertWireTickToCm(TVector2 wiretick, geo::PlaneID planeID)
Definition: EMShowerAlg.h:277
pma::ProjectionMatchingAlg fProjectionMatchingAlg
Definition: EMShowerAlg.h:241
std::map< int, std::map< int, bool > > GetPlanePermutations(const std::map< int, std::vector< art::Ptr< recob::Hit > > > &showerHitsMap)
double ShowerHitRMS(const std::vector< art::Ptr< recob::Hit > > &showerHits)
Returns the RMS of the hits from the central shower &#39;axis&#39; along the length of the shower...
Description of geometry of one entire detector.
Declaration of cluster object.
art::ServiceHandle< geo::Geometry > fGeom
Definition: EMShowerAlg.h:234
Provides recob::Track data product.
std::unique_ptr< recob::Track > ConstructTrack(std::vector< art::Ptr< recob::Hit > > const &track1, std::vector< art::Ptr< recob::Hit > > const &track2, std::map< int, TVector2 > const &showerCentreMap)
double FinddEdx(std::vector< art::Ptr< recob::Hit > > const &trackHits, std::unique_ptr< recob::Track > const &track)
Finds dE/dx for the track given a set of hits.
Detector simulation of raw signals on wires.
double ShowerHitRMSGradient(const std::vector< art::Ptr< recob::Hit > > &showerHits, TVector2 trueStart=TVector2(0, 0))
Returns the gradient of the RMS vs shower segment graph.
void FindInitialTrack(const std::map< int, std::vector< art::Ptr< recob::Hit > > > &hits, std::unique_ptr< recob::Track > &initialTrack, std::map< int, std::vector< art::Ptr< recob::Hit > > > &initialTrackHits, int plane)
Finds the initial track-like part of the shower and the hits in all views associated with it...
Encapsulate the geometry of a wire.
void CheckIsolatedHits(std::map< int, std::vector< art::Ptr< recob::Hit > > > &showerHitsMap)
Checks the hits across the views in a given shower to determine if there is one in the incorrect TPC...
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
Implementation of the Projection Matching Algorithm.
Encapsulate the construction of a single detector plane.
art::ServiceHandle< art::TFileService > tfs
Definition: EMShowerAlg.h:236
TProfile * hNumHitsInSegment
Definition: EMShowerAlg.h:251
std::vector< art::Ptr< recob::Hit > > FindOrderOfHits(std::vector< art::Ptr< recob::Hit > > const &hits, bool perpendicular=false)
detinfo::DetectorProperties const * fDetProp
Definition: EMShowerAlg.h:235
recob::Shower MakeShower(art::PtrVector< recob::Hit > const &hits, std::unique_ptr< recob::Track > const &initialTrack, std::map< int, std::vector< art::Ptr< recob::Hit > > > const &initialTrackHits)
Makes a recob::Shower object given the hits in the shower and the initial track-like part...
std::vector< int > CheckShowerPlanes(std::vector< std::vector< int > > const &initialShowers, std::vector< art::Ptr< recob::Cluster > > const &clusters, art::FindManyP< recob::Hit > const &fmh)
Takes the initial showers found and tries to resolve issues where one bad view ruins the event...
Char_t n[5]
TVector2 HitCoordinates(art::Ptr< recob::Hit > const &hit)
Return the coordinates of this hit in global wire/tick space.
std::vector< unsigned int > fNfithits
Definition: EMShowerAlg.h:230
Float_t track
Definition: plot.C:34
Float_t w
Definition: plot.C:23
Utility functions to extract information from recob::Track.
art framework interface to geometry description
std::map< double, int > RelativeWireWidth(const std::map< int, std::vector< art::Ptr< recob::Hit > > > &showerHitsMap)
Encapsulate the construction of a single detector plane.
int FindTrueParticle(const std::vector< art::Ptr< recob::Hit > > &showerHits)
vertex reconstruction