LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ClusterParamsAlg.h
Go to the documentation of this file.
1 // ClusterParamsAlg.h
3 //
4 // ClusterParamsAlg class
5 //
6 // Andrzej Szelc (andrzej.szelc@yale.edu)
7 //
9 #ifndef CLUSTERPARAMSALG_H
10 #define CLUSTERPARAMSALG_H
11 
12 //--- std/stl include ---//
13 #include <vector>
14 //--- ROOT include ---//
15 #include <TMath.h>
16 #include <TH2F.h>
17 #include <TF1.h>
18 #include <TH1F.h>
19 #include <TPrincipal.h>
20 #include <TCanvas.h>
21 #include <TLegend.h>
22 
23 //--- LArSoft include ---//
25 #include "ClusterParams.h"
26 #include "CRUException.h"
27 
28 //#include "LArUtilManager.hh"
29 //#include "FANNService.hh"
30 
31 //#include "DataFormat-TypeDef.hh"
32 //#include "LArUtil-TypeDef.hh"
33 //#include "HoughBaseAlg.hh"
34 
35 #include "TPrincipal.h"
36 #include "TStopwatch.h"
37 
38 // ... more #include in tempimplementation below
39 
40 namespace cluster {
41 
43 
44  public:
45 
48 
49 // /// Alternative constructor with larlight's hits
50 // ClusterParamsAlg(const std::vector<const ::larlite::hit*>&);
51 
53  ClusterParamsAlg(const std::vector<util::PxHit>&);
54 
56 
57  void Initialize();
58 
59  //void SetHits(const std::vector<larutil::PxHit*>&);
60 
61  void SetMinNHits(size_t nhit) { fMinNHits = nhit; }
62 
63  size_t MinNHits() const { return fMinNHits; }
64 
65  // int SetHits(const std::vector<const ::larlite::hit*> &);
66 
67  int SetHits(const std::vector<util::PxHit> &);
68 
69  void SetRefineDirectionQMin(double qmin){ fQMinRefDir = qmin; }
70 
71  void SetVerbose(bool yes=true){ verbose = yes;}
72 
73  // void SetArgoneutGeometry();
74 
75  template <typename Stream>
76  void Report(Stream& stream) const;
77 
78  template <typename Stream>
79  void TimeReport(Stream& stream) const;
80 
88  void GetFANNVector(std::vector<float> & data);
89  // std::vector<float> & GetFANNVector();
90 
96  void PrintFANNVector();
97 
98 
111  void FillParams(bool override_DoGetAverages =false,
112  bool override_DoGetRoughAxis =false,
113  bool override_DoGetProfileInfo =false,
114  bool override_DoRefineStartPointsAndDirection=false,
115  // bool override_DoRefineDirection =false,
116  bool override_DoGetFinalSlope =false,
117  bool override_DoTrackShowerSep =false,
118  bool override_DoEndCharge = false);
119 
120  const cluster_params& GetParams() const
121  { return fParams;}
122 
136  void GetAverages(bool override=false);
137 
138 
146  //void GetRoughAxis(bool override=false);
147  void GetRoughAxis(bool override=false);
148 
149 
159  void GetProfileInfo(bool override=false);
160 
161 
168  void RefineStartPoints(bool override=false);
169 
178  void GetFinalSlope(bool override=false);
179 
187  void GetEndCharges(bool override_ = false);
188 
189  void RefineDirection(bool override=false);
190 
191  void RefineStartPointAndDirection(bool override=false);
192 
193  void TrackShowerSeparation(bool override=false);
194 
195  void setNeuralNetPath(std::string s){fNeuralNetPath = s;}
196 
197  void FillPolygon();
198 
199  void GetOpeningAngle();
200 
203 
204  double RoughSlope() {return fRough2DSlope;}
206 
232  double StartCharge(float length = 1., unsigned int nbins = 10);
233 
245  double EndCharge(float length = 1., unsigned int nbins = 10);
246 
254  float MultipleHitWires();
255 
263  float MultipleHitDensity();
264 
265 
266  void EnableFANN();
267 
268  void DisableFANN(){enableFANN = false;}
269 
270  size_t GetNHits() const {return fHitVector.size();}
271  const std::vector<util::PxHit>& GetHitVector() const {return fHitVector;}
272  int Plane() const {return fPlane;}
273  void SetPlane(int p);
274 
275  protected:
276 
278 
280  size_t fMinNHits;
281 
286  std::vector<util::PxHit> fHitVector;
287 
288  // bool to control debug/verbose mode
289  // defaults to off.
290  bool verbose;
291 
292  //settable parameters:
293  std::vector<double> fChargeCutoffThreshold;
294  int fPlane;
295 
296  //this is required in RefineDirection
297  double fQMinRefDir;
298 
299  std::vector< double > fChargeProfile;
300  std::vector< double > fCoarseChargeProfile;
301 
302  std::vector< double > fChargeProfileNew;
303  // double fMaxLinLength;
304  // double fLinBins;
305 
312 
313  //extreme intercepts using the rough_2d_slope
314  // double fInterHigh;
315  // double fInterLow;
320 
321  // book keeping variables to validate completion of methods:
331 
332  double fRough2DSlope; // slope
333  double fRough2DIntercept; // slope
337 
366  double IntegrateFitCharge(
367  double from_length, double to_length,
368  unsigned int fit_first_bin, unsigned int fit_end_bin
369  );
370 
372  static double LinearIntegral(double m, double q, double x1, double x2);
373 
374  public:
375 
377 
378  std::string fNeuralNetPath;
379 
380  std::vector<std::string> fTimeRecord_ProcName;
381  std::vector<double> fTimeRecord_ProcTime;
382 
383  }; //class ClusterParamsAlg
384 
385 } //namespace cluster
386 
387 
388 //------------------------------------------------------------------------------
389 //--- template implementation
390 //---
391 
392 #include <ostream> // std::endl
393 
394 namespace cluster {
395 
396  template <typename Stream>
397  void ClusterParamsAlg::TimeReport(Stream& stream) const {
398 
399  stream << " <<ClusterParamsAlg::TimeReport>> starts..."<<std::endl;
400  for(size_t i=0; i<fTimeRecord_ProcName.size(); ++i){
401 
402  stream << " Function: "
403  << fTimeRecord_ProcName[i].c_str()
404  << " ... Time = "
406  << " [s]"
407  << std::endl;
408 
409  }
410  stream<< " <<ClusterParamsAlg::TimeReport>> ends..."<<std::endl;
411  }
412 
413 } //namespace cluster
414 
415 #endif
util::GeometryUtilities * fGSer
const util::PxPoint & RoughStartPoint()
Float_t s
Definition: plot.C:23
void GetRoughAxis(bool override=false)
std::vector< double > fChargeProfileNew
void GetProfileInfo(bool override=false)
void SetRefineDirectionQMin(double qmin)
std::vector< std::string > fTimeRecord_ProcName
void RefineStartPoints(bool override=false)
double EndCharge(float length=1., unsigned int nbins=10)
Returns the expected charge at the end of the cluster.
Float_t x1[n_points_granero]
Definition: compare.C:5
void GetFinalSlope(bool override=false)
double StartCharge(float length=1., unsigned int nbins=10)
Returns the expected charge at the beginning of the cluster.
ClusterParamsAlg()
Default constructor.
void setNeuralNetPath(std::string s)
std::vector< util::PxHit > fHitVector
Cluster finding and building.
void FillParams(bool override_DoGetAverages=false, bool override_DoGetRoughAxis=false, bool override_DoGetProfileInfo=false, bool override_DoRefineStartPointsAndDirection=false, bool override_DoGetFinalSlope=false, bool override_DoTrackShowerSep=false, bool override_DoEndCharge=false)
float MultipleHitDensity()
Returns the number of multiple hits per wire.
Class def header for exception classes in ClusterRecoUtil package.
const cluster_params & GetParams() const
cluster::cluster_params fParams
const std::vector< util::PxHit > & GetHitVector() const
void TimeReport(Stream &stream) const
void TrackShowerSeparation(bool override=false)
std::vector< double > fTimeRecord_ProcTime
void GetAverages(bool override=false)
void RefineStartPointAndDirection(bool override=false)
void SetMinNHits(size_t nhit)
void RefineDirection(bool override=false)
std::vector< double > fCoarseChargeProfile
size_t fMinNHits
Cut value for # hits: below this value clusters are not evaluated.
int SetHits(const std::vector< util::PxHit > &)
const util::PxPoint & RoughEndPoint()
void GetEndCharges(bool override_=false)
Float_t x2[n_points_geant4]
Definition: compare.C:26
void Report(Stream &stream) const
double IntegrateFitCharge(double from_length, double to_length, unsigned int fit_first_bin, unsigned int fit_end_bin)
Integrates the charge between two positions in the cluster axis.
void SetVerbose(bool yes=true)
static double LinearIntegral(double m, double q, double x1, double x2)
Returns the integral of f(x) = mx + q defined in [x1, x2].
std::vector< double > fChargeProfile
std::vector< double > fChargeCutoffThreshold
float MultipleHitWires()
Returns the number of multiple hits per wire.
void GetFANNVector(std::vector< float > &data)