LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cmtool::CFAlgoStartPointMatch Class Reference

#include "CFAlgoStartPointMatch.h"

Inheritance diagram for cmtool::CFAlgoStartPointMatch:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoStartPointMatch ()
 Default constructor. More...
 
virtual ~CFAlgoStartPointMatch ()
 Default destructor. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &clusters)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance, called together with manager's Reset() More...
 
double Area2D (double Ax, double Ay, double Bx, double By, double Cx, double Cy)
 
double Area3D (double Ax, double Ay, double Az, double Bx, double By, double Bz, double Cx, double Cy, double Cz)
 
void UseTime (bool on)
 
void SetMaxArea (double area)
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void IterationEnd ()
 
void SetAnaFile (TFile *fout)
 Setter function for an output plot TFile pointer. More...
 
virtual void SetVerbose (bool doit=true)
 Setter function for verbosity. More...
 

Protected Attributes

TFile * _fout
 TFile pointer to an output file. More...
 
bool _verbose
 Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager's verbosity level is >= kPerMerging. More...
 

Private Attributes

double _w2cm
 
double _t2cm
 
double _MaxArea
 
bool _time
 

Detailed Description

User implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 26 of file CFAlgoStartPointMatch.h.

Constructor & Destructor Documentation

cmtool::CFAlgoStartPointMatch::CFAlgoStartPointMatch ( )

Default constructor.

Definition at line 9 of file CFAlgoStartPointMatch.cxx.

References _t2cm, _w2cm, SetMaxArea(), util::GeometryUtilities::TimeToCm(), UseTime(), and util::GeometryUtilities::WireToCm().

10  //-------------------------------------------------------
11  {
13  _w2cm = geou.WireToCm();
14  _t2cm = geou.TimeToCm();
15  UseTime(true);
16  SetMaxArea(100.);
17 
18  }
Double_t TimeToCm() const
Double_t WireToCm() const
CFloatAlgoBase()
Default constructor.
virtual cmtool::CFAlgoStartPointMatch::~CFAlgoStartPointMatch ( )
inlinevirtual

Default destructor.

Definition at line 34 of file CFAlgoStartPointMatch.h.

References Area2D(), Area3D(), Float(), Report(), and Reset().

34 {};

Member Function Documentation

double cmtool::CFAlgoStartPointMatch::Area2D ( double  Ax,
double  Ay,
double  Bx,
double  By,
double  Cx,
double  Cy 
)

Definition at line 124 of file CFAlgoStartPointMatch.cxx.

Referenced by Float(), and ~CFAlgoStartPointMatch().

124  {
125  //---------------------------------------------------------------------------------------------------
126 
127  double a = (Ax*(By-Cy)+Bx*(Cy-Ay)+Cx*(Ay-By))*0.5;
128 
129  if ( a < 0 ) { a *= -1; }
130 
131  return a;
132 
133  }
double cmtool::CFAlgoStartPointMatch::Area3D ( double  Ax,
double  Ay,
double  Az,
double  Bx,
double  By,
double  Bz,
double  Cx,
double  Cy,
double  Cz 
)

Definition at line 136 of file CFAlgoStartPointMatch.cxx.

Referenced by Float(), and ~CFAlgoStartPointMatch().

138  {
139  //---------------------------------------------------------------------------------------------------
140 
141  //Create vectors AB and AC
142  Bx = Bx-Ax;
143  By = By-Ay;
144  Bz = Bz-Az;
145  Cx = Cx-Ax;
146  Cy = Cy-Ay;
147  Cz = Cz-Az;
148 
149  return 0.5*sqrt( (By*Cz-Cz*By)*(By*Cz-Cz*By) + (Bz*Cx-Bx*Cz)*(Bz*Cx-Bx*Cz) + (Bx*Cy-By*Cx)*(Bx*Cy-By*Cx) );
150  }
virtual void cmtool::CMAlgoBase::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtualinherited

Optional function: called at the beginning of 1st iteration. This is called per event.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, cmtool::CBAlgoArray, and cmtool::CBAlgoPolyShortestDist.

Definition at line 45 of file CMAlgoBase.h.

Referenced by cmtool::CMergeManager::EventBegin().

46  { if(clusters.size()) return; }
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

Optional function: called at the end of event ... after the last merging iteration is over.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 51 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventEnd(), and cmtool::CMergeManager::EventEnd().

52  {return;}
float cmtool::CFAlgoStartPointMatch::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

Core function: given a set of CPANs, return a float which indicates the compatibility the cluster combination.

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 28 of file CFAlgoStartPointMatch.cxx.

References _MaxArea, _time, cmtool::CMAlgoBase::_verbose, _w2cm, Area2D(), Area3D(), and geo::GeometryCore::IntersectionPoint().

Referenced by ~CFAlgoStartPointMatch().

30  {
31 
32  // Code-block by Kazu starts
33  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
34  // You may take out this block if you want to allow matching using clusters from only 2 planes.
35  if(clusters.size()==2) return -1;
36  // Code-block by Kazu ends
37 
38  //This algorithm now works for 3 planes: find 3Dstart point from first 2 planes and find
39  //How well that agrees with 3rd plane's start point location.
40 
41  //So first, make sure clusters vector has only 3 elements. If not return -1
42  if ( clusters.size() != 3 )
43  return -1;
44 
45  //Find 3D start point from start point on first 2 planes:
46  //For now convert start point wire in cm back to wire number
47  //Round to integer (sometimes output is double...why???)
48  int startWire1 = int( clusters.at(0)->GetParams().start_point.w / _w2cm );
49  double startTime1 = clusters.at(0)->GetParams().start_point.t;
50  unsigned int Pl1 = clusters.at(0)->GetParams().start_point.plane;
51  int startWire2 = int( clusters.at(1)->GetParams().start_point.w / _w2cm );
52  double startTime2 = clusters.at(1)->GetParams().start_point.t;
53  unsigned int Pl2 = clusters.at(1)->GetParams().start_point.plane;
54  int startWire3 = int( clusters.at(2)->GetParams().start_point.w / _w2cm );
55  double startTime3 = clusters.at(2)->GetParams().start_point.t;
56  unsigned int Pl3 = clusters.at(2)->GetParams().start_point.plane;
57 
58  unsigned int cryo=0;
59  unsigned int tpc =0;
60 
61  //Get Intersections in pairs:
62  //y and z indicate detector coordinate and numbers indicate planes
63  //used to generate that intersection point
64  double yS12, zS12, yS13, zS13, yS23, zS23;
65 
67  geo->IntersectionPoint( startWire1, startWire2,
68  Pl1, Pl2,
69  cryo, tpc,
70  yS12, zS12);
71 
72  geo->IntersectionPoint( startWire1, startWire3,
73  Pl1, Pl3,
74  cryo, tpc,
75  yS13, zS13);
76 
77  geo->IntersectionPoint( startWire2, startWire3,
78  Pl2, Pl3,
79  cryo, tpc,
80  yS23, zS23);
81 
82  if ( _verbose ){
83  std::cout << "Wire Start Numbers: " << std::endl;
84  std::cout << "\t" << startWire1 << std::endl;
85  std::cout << "\t" << startWire2 << std::endl;
86  std::cout << "\t" << startWire3 << std::endl;
87  std::cout << std::endl;
88  }
89 
90  if ( _verbose ){
91  std::cout << "Intersection Pl1-Pl3: ( " << yS13 << ", " << zS13 << " )" << std::endl;
92  std::cout << "Intersection Pl1-Pl2: ( " << yS12 << ", " << zS12 << " )" << std::endl;
93  std::cout << "Intersection Pl2-Pl3: ( " << yS23 << ", " << zS23 << " )" << std::endl;
94  }
95 
96  //Parameter used for evaluation is area of triangle formed by the three intersection points
97  double area = -1;
98  if ( !_time ){
99  area = Area2D( yS12, zS12, yS23, zS23, yS13, zS13 );
100  }
101  if ( _time ){
102  area = Area3D( (yS12+yS13)/2. , (zS12+zS13)/2. , startTime1,
103  (yS13+yS23)/2. , (zS13+zS23)/2. , startTime3,
104  (yS12+yS23)/2. , (zS13+zS23)/2. , startTime2 );
105  }
106 
107  if ( _verbose ) { std::cout << "Area of intersections triangle is: " << area << std::endl; }
108 
109  if ( area > _MaxArea )
110  return -1;
111  else
112  return 1./area;
113 
114  }
double Area2D(double Ax, double Ay, double Bx, double By, double Cx, double Cy)
double Area3D(double Ax, double Ay, double Az, double Bx, double By, double Bz, double Cx, double Cy, double Cz)
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
Namespace collecting geometry-related classes utilities.
bool _verbose
Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager&#39;s verbosity level is >= kPer...
Definition: CMAlgoBase.h:88
virtual void cmtool::CMAlgoBase::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtualinherited

Optional function: called at the beggining of each iteration over all pairs of clusters. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 59 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventBegin(), cmtool::CMatchManager::IterationBegin(), and cmtool::CMergeManager::IterationBegin().

60  { if(clusters.size()) return;}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

Optional function: called at the end of each iteration over all pairs of clusters.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 65 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::IterationEnd(), and cmtool::CMergeManager::IterationEnd().

66  {return; }
void cmtool::CFAlgoStartPointMatch::Report ( )
virtual

Optional function: called after each iterative approach if a manager class is run with verbosity level <= kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 117 of file CFAlgoStartPointMatch.cxx.

Referenced by ~CFAlgoStartPointMatch().

119  {
120 
121  }
void cmtool::CFAlgoStartPointMatch::Reset ( )
virtual

Function to reset the algorithm instance, called together with manager's Reset()

Reimplemented from cmtool::CMAlgoBase.

Definition at line 21 of file CFAlgoStartPointMatch.cxx.

Referenced by ~CFAlgoStartPointMatch().

23  {
24 
25  }
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 77 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

Referenced by cmtool::CMergeManager::EventBegin().

77 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:85
void cmtool::CFAlgoStartPointMatch::SetMaxArea ( double  area)
inline

Definition at line 67 of file CFAlgoStartPointMatch.h.

References _MaxArea.

Referenced by CFAlgoStartPointMatch().

virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited
void cmtool::CFAlgoStartPointMatch::UseTime ( bool  on)
inline

Definition at line 65 of file CFAlgoStartPointMatch.h.

References _time.

Referenced by CFAlgoStartPointMatch().

Member Data Documentation

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 85 of file CMAlgoBase.h.

Referenced by cmtool::CMAlgoBase::CMAlgoBase(), and cmtool::CMAlgoBase::SetAnaFile().

double cmtool::CFAlgoStartPointMatch::_MaxArea
private

Definition at line 94 of file CFAlgoStartPointMatch.h.

Referenced by Float(), and SetMaxArea().

double cmtool::CFAlgoStartPointMatch::_t2cm
private

Definition at line 93 of file CFAlgoStartPointMatch.h.

Referenced by CFAlgoStartPointMatch().

bool cmtool::CFAlgoStartPointMatch::_time
private

Definition at line 95 of file CFAlgoStartPointMatch.h.

Referenced by Float(), and UseTime().

double cmtool::CFAlgoStartPointMatch::_w2cm
private

Optional function: called at the beginning of 1st iteration. This is called per event. Optional function: called at the end of event ... after the last merging iteration is over. Optional function: called at the beggining of each iterative loop. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event. Optional function: called at the end of each iterative loop.

Definition at line 93 of file CFAlgoStartPointMatch.h.

Referenced by CFAlgoStartPointMatch(), and Float().


The documentation for this class was generated from the following files: