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

#include "CFAlgoStartPointCompat.h"

Inheritance diagram for cmtool::CFAlgoStartPointCompat:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoStartPointCompat ()
 Default constructor. More...
 
virtual ~CFAlgoStartPointCompat ()
 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...
 
void SetVerbose (bool on)
 Function to set verbose output. More...
 
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...
 

Protected Attributes

TFile * _fout
 TFile pointer to an output file. More...
 

Private Attributes

double _w2cm
 
double _t2cm
 
bool _verbose
 

Detailed Description

User implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 26 of file CFAlgoStartPointCompat.h.

Constructor & Destructor Documentation

cmtool::CFAlgoStartPointCompat::CFAlgoStartPointCompat ( )

Default constructor.

Definition at line 10 of file CFAlgoStartPointCompat.cxx.

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

10  : CFloatAlgoBase()
11  //-------------------------------------------------------
12  {
14  _w2cm = geou.WireToCm();
15  _t2cm = geou.TimeToCm();
16  SetVerbose(false);
17  }
Double_t TimeToCm() const
Double_t WireToCm() const
CFloatAlgoBase()
Default constructor.
void SetVerbose(bool on)
Function to set verbose output.
virtual cmtool::CFAlgoStartPointCompat::~CFAlgoStartPointCompat ( )
inlinevirtual

Default destructor.

Definition at line 34 of file CFAlgoStartPointCompat.h.

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

34 {};

Member Function Documentation

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::CFAlgoStartPointCompat::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 27 of file CFAlgoStartPointCompat.cxx.

References _t2cm, _verbose, _w2cm, e, geo::GeometryCore::IntersectionPoint(), min, and geo::GeometryCore::NearestWire().

Referenced by ~CFAlgoStartPointCompat().

29  {
30 
31  // Code-block by Kazu starts
32  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
33  // You may take out this block if you want to allow matching using clusters from only 2 planes.
34  if(clusters.size()==2) return -1;
35  // Code-block by Kazu ends
36 
37  //This algorithm now works for 3 planes: find 3Dstart point from first 2 planes and find
38  //How well that agrees with 3rd plane's start point location.
39 
40  //So first, make sure clusters vector has only 3 elements. If not return -1
41  if ( clusters.size() != 3 )
42  return -1;
43 
44  //Find 3D start point from start point on first 2 planes:
45  //For now convert start point wire in cm back to wire number
46  //Round to integer (sometimes output is double...why???)
47  double startWirecm0 = clusters.at(0)->GetParams().start_point.w;
48  double startTimecm0 = clusters.at(0)->GetParams().start_point.t;
49  int startWire0 = int( startWirecm0 / _w2cm );
50  unsigned int Pl0 = clusters.at(0)->GetParams().start_point.plane;
51  //int startChan1 = larutil::Geometry::GetME()->PlaneWireToChannel(Pl0, startWire0);
52  double startWirecm1 = clusters.at(1)->GetParams().start_point.w;
53  double startTimecm1 = clusters.at(1)->GetParams().start_point.t;
54  int startWire1 = int( startWirecm1 / _w2cm );
55  unsigned int Pl1 = clusters.at(1)->GetParams().start_point.plane;
56  //int startChan2 = larutil::Geometry::GetME()->PlaneWireToChannel(Pl1, startWire1);
57  double startWirecm2 = clusters.at(2)->GetParams().start_point.w;
58  double startTimecm2 = clusters.at(2)->GetParams().start_point.t;
59  int startWire2 = int( startWirecm2 / _w2cm );
60  unsigned int Pl2 = clusters.at(2)->GetParams().start_point.plane;
61  //int startChan3 = larutil::Geometry::GetME()->PlaneWireToChannel(Pl2, startWire2);
62 
63  unsigned int cryo=0;
64  unsigned int tpc =0;
65 
66  //Get Intersections in pairs:
67  //y and z indicate detector coordinate and numbers indicate planes
68  //used to generate that intersection point
69  double yS01, zS01, yS02, zS02, yS12, zS12;
70 
72  geo->IntersectionPoint( startWire0, startWire1,
73  Pl0, Pl1,
74  cryo, tpc,
75  yS01, zS01);
76 
77  geo->IntersectionPoint( startWire0, startWire2,
78  Pl0, Pl2,
79  cryo, tpc,
80  yS02, zS02);
81 
82  geo->IntersectionPoint( startWire1, startWire2,
83  Pl1, Pl2,
84  cryo, tpc,
85  yS12, zS12);
86 
87  //assume X coordinate for these start-points is 0
88  //i.e. only focus on projection onto wire-plane
89  //then check if the start point reconstructe from
90  //planes A and B falls within the wire-range of
91  //the cluster on plane C
92  //For compatibility also, check that the start-point-time
93  //is within the time-range of the cluster on plane C
94  Double_t Start2[3] = {-100., yS01, zS01};
95  Double_t Start1[3] = {-100., yS02, zS02};
96  Double_t Start0[3] = {-100., yS12, zS12};
97  UInt_t WireStart0 = 0;
98  UInt_t WireStart1 = 0;
99  UInt_t WireStart2 = 0;
100  try { WireStart0 = geo->NearestWire( Start0, Pl0); }
101  //catch ( ::larutil::LArUtilException &e) {
102  catch ( ::cet::exception &e) {
103  std::cout << e.what() << std::endl;
104  std::cout << "Exception caught!" << std::endl;
105  WireStart0 = 9999;
106  }
107  try { WireStart1 = geo->NearestWire( Start1, Pl1); }
108  //catch ( ::larutil::LArUtilException &e ) {
109  catch( ::cet::exception &e) {
110  std::cout << e.what() << std::endl;
111  std::cout << "Exception caught!" << std::endl;
112  WireStart0 = 9999;
113  }
114  try { WireStart2 = geo->NearestWire( Start2, Pl2); }
115  //catch ( ::larutil::LArUtilException &e) {
116  catch ( ::cet::exception &e) {
117  std::cout << e.what() << std::endl;
118  std::cout << "Exception caught!" << std::endl;
119  WireStart0 = 9999;
120  }
121 
122  //Now Get Hit-Range for Clusters
123  std::vector<util::PxHit> hits0 = clusters.at(0)->GetHitVector();
124  std::vector<util::PxHit> hits1 = clusters.at(1)->GetHitVector();
125  std::vector<util::PxHit> hits2 = clusters.at(2)->GetHitVector();
126  //define variables for min/max time/wire of each cluster
127  double minWire0 = 9999;
128  double minWire1 = 9999;
129  double minWire2 = 9999;
130  double maxWire0 = 0;
131  double maxWire1 = 0;
132  double maxWire2 = 0;
133  double minTime0 = 9999;
134  double minTime1 = 9999;
135  double minTime2 = 9999;
136  double maxTime0 = 0;
137  double maxTime1 = 0;
138  double maxTime2 = 0;
139  int hitWireTMP = 0;
140  double hitTimeTMP = 0;
141 
142  for (auto& h: hits0){
143  hitWireTMP = int(h.w/_w2cm);
144  hitTimeTMP = int(h.t/_t2cm);
145  if ( hitWireTMP < minWire0 ) { minWire0 = hitWireTMP; }
146  if ( hitWireTMP > maxWire0 ) { maxWire0 = hitWireTMP; }
147  if ( hitTimeTMP < minTime0 ) { minTime0 = hitTimeTMP; }
148  if ( hitTimeTMP > maxTime0 ) { maxTime0 = hitTimeTMP; }
149  }
150  for (auto& h: hits1){
151  hitWireTMP = int(h.w/_w2cm);
152  hitTimeTMP = int(h.t/_t2cm);
153  if ( hitWireTMP < minWire1 ) { minWire1 = hitWireTMP; }
154  if ( hitWireTMP > maxWire1 ) { maxWire1 = hitWireTMP; }
155  if ( hitTimeTMP < minTime1 ) { minTime1 = hitTimeTMP; }
156  if ( hitTimeTMP > maxTime1 ) { maxTime1 = hitTimeTMP; }
157  }
158  for (auto& h: hits2){
159  hitWireTMP = int(h.w/_w2cm);
160  hitTimeTMP = int(h.t/_t2cm);
161  if ( hitWireTMP < minWire2 ) { minWire2 = hitWireTMP; }
162  if ( hitWireTMP > maxWire2 ) { maxWire2 = hitWireTMP; }
163  if ( hitTimeTMP < minTime2 ) { minTime2 = hitTimeTMP; }
164  if ( hitTimeTMP > maxTime2 ) { maxTime2 = hitTimeTMP; }
165  }
166 
167  if ( _verbose ){
168  std::cout << "Start W,T on plane 0: " << "[ " << startWirecm0 << ", " << startTimecm0 << " ]" << std::endl;
169  std::cout << "Start Wire, planne 0: " << startWire0 << std::endl;
170  std::cout << "Start W,T on plane 1: " << "[ " << startWirecm1 << ", " << startTimecm1 << " ]" << std::endl;
171  std::cout << "Start Wire, planne 1: " << startWire1 << std::endl;
172  std::cout << "Start W,T on plane 2: " << "[ " << startWirecm2 << ", " << startTimecm2 << " ]" << std::endl;
173  std::cout << "Start Wire, planne 2: " << startWire2 << std::endl;
174  std::cout << std::endl;
175  std::cout << "Start Reco Point from clusters on planes 1 and 2 (Z,Y):" << std::endl
176  << "[ " << zS12 << ", " << yS12 << " ]" << std::endl;
177  std::cout << "Nearest wire on Pl0 to reco-start point from Pl1, Pl2:" << std::endl
178  << WireStart0 << std::endl;
179  std::cout << "Min-Max Wire for Hits from Cluster on Plane 0:" << std::endl
180  << "[ " << minWire0 << ", " << maxWire0 << " ]" << std::endl;
181  std::cout << "Start Reco Point from clusters on planes 0 and 2 (Z,Y):" << std::endl
182  << "[ " << zS02 << ", " << yS02 << " ]" << std::endl;
183  std::cout << "Nearest wire on Pl1 to reco-start point from Pl0, Pl2:" << std::endl
184  << WireStart1 << std::endl;
185  std::cout << "Min-Max Wire for Hits from Cluster on Plane 1:" << std::endl
186  << "[ " << minWire1 << ", " << maxWire1 << " ]" << std::endl;
187  std::cout << "Start Reco Point from clusters on planes 0 and 1 (Z,Y):" << std::endl
188  << "[ " << zS01 << ", " << yS01 << " ]" << std::endl;
189  std::cout << "Nearest wire on Pl2 to reco-start point from Pl0, Pl1:" << std::endl
190  << WireStart2 << std::endl;
191  std::cout << "Min-Max Wire for Hits from Cluster on Plane 2:" << std::endl
192  << "[ " << minWire2 << ", " << maxWire2 << " ]" << std::endl;
193  std::cout << std::endl;
194  }
195  //Parameter used for evaluation is whether the start-point of any reconstructed start point from 2 planes
196  //is in the start-end time-wire range of the other plane's cluster
197  double compat = 9999;
198  double retVal = -1;
199 
200  if ( (WireStart0 > minWire0) and (WireStart0 < maxWire0) ){
201  if ( std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) ) < compat ){
202  compat = std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) );
203  }
204  }
205  if ( (WireStart1 > minWire1) and (WireStart1 < maxWire1) ){
206  if ( std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) ) < compat ){
207  compat = std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) );
208  }
209  }
210  if ( (WireStart2 > minWire2) and (WireStart2 < maxWire2) ){
211  if ( std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) ) < compat ){
212  compat = std::min( (WireStart0-minWire0) , (maxWire0-WireStart0) );
213  }
214  }
215 
216  if ( compat != 9999 )
217  retVal = 1./compat;
218 
219  return retVal;
220 
221  }
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
Int_t min
Definition: plot.C:26
Float_t e
Definition: plot.C:34
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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::CFAlgoStartPointCompat::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 224 of file CFAlgoStartPointCompat.cxx.

Referenced by ~CFAlgoStartPointCompat().

226  {
227 
228  }
void cmtool::CFAlgoStartPointCompat::Reset ( )
virtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 20 of file CFAlgoStartPointCompat.cxx.

Referenced by ~CFAlgoStartPointCompat().

22  {
23 
24  }
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::CFAlgoStartPointCompat::SetVerbose ( bool  on)
inlinevirtual

Function to set verbose output.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 58 of file CFAlgoStartPointCompat.h.

References _verbose.

Referenced by CFAlgoStartPointCompat().

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::CFAlgoStartPointCompat::_t2cm
private

Definition at line 62 of file CFAlgoStartPointCompat.h.

Referenced by CFAlgoStartPointCompat(), and Float().

bool cmtool::CFAlgoStartPointCompat::_verbose
private

Definition at line 64 of file CFAlgoStartPointCompat.h.

Referenced by Float(), and SetVerbose().

double cmtool::CFAlgoStartPointCompat::_w2cm
private

Definition at line 62 of file CFAlgoStartPointCompat.h.

Referenced by CFAlgoStartPointCompat(), and Float().


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