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

#include "CFAlgoTimeOverlap.h"

Inheritance diagram for cmtool::CFAlgoTimeOverlap:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoTimeOverlap ()
 Default constructor. More...
 
virtual ~CFAlgoTimeOverlap ()
 Default destructor. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &clusters)
 
void SetStartTimeCut (float start_time)
 
void SetRatioCut (float ratio)
 
void SetDebug (bool debug)
 
void SetVerbose (bool verbose)
 Setter function for verbosity. More...
 
void RequireThreePlanes (bool doit)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance called within CMergeManager/CMatchManager's Reset() ... maybe implemented via child class. 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

float _time_ratio_cut
 
float _start_time_cut
 
bool _debug
 
bool _verbose
 
bool _require_3planes
 
TFile * _fout
 TFile pointer to an output file. More...
 

Detailed Description

User implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 25 of file CFAlgoTimeOverlap.h.

Constructor & Destructor Documentation

cmtool::CFAlgoTimeOverlap::CFAlgoTimeOverlap ( )

Default constructor.

Definition at line 9 of file CFAlgoTimeOverlap.cxx.

References RequireThreePlanes(), SetDebug(), SetRatioCut(), SetStartTimeCut(), and SetVerbose().

10  //-------------------------------------------------------
11  {
12  SetRatioCut(0.001) ; //(0.095) ;
13  SetStartTimeCut(10) ;
14  SetDebug(false) ;
15  SetVerbose(false) ;
16  RequireThreePlanes(true) ;
17  }
void SetStartTimeCut(float start_time)
CFloatAlgoBase()
Default constructor.
void SetVerbose(bool verbose)
Setter function for verbosity.
void RequireThreePlanes(bool doit)
void SetRatioCut(float ratio)
virtual cmtool::CFAlgoTimeOverlap::~CFAlgoTimeOverlap ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CFAlgoTimeOverlap.h.

References Float().

33 {};

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::CFAlgoTimeOverlap::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

This algorithm calculates the difference between start and end times for merged clusters, and compares across planes to form matches.

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 27 of file CFAlgoTimeOverlap.cxx.

References _debug, _require_3planes, _start_time_cut, _time_ratio_cut, and _verbose.

Referenced by ~CFAlgoTimeOverlap().

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(_require_3planes && clusters.size()==2) return -1;
35  // Code-block by Kazu ends
36 
37  double ratio = 1;
38  double time_difference = 0;
39  double max_time_difference = 0;
40  double max_charge = 0;
41  double charge_ratio = 1;
42 
43  //Preserve location in time space. Cut clusters that have similar time differences,
44  // but hit wires at very different times.
45  double start_t = 0;
46  double end_t = 0;
47  double prev_start_t = 0;
48  double prev_end_t = 0;
49 
50  double max_hits_1 = 0;
51  double max_hits_2 = 0;
52 
53  for(auto const& c : clusters){
54 
55  auto charge = c->GetParams().sum_charge ;
56 
57  time_difference = c->GetParams().start_point.t - c->GetParams().end_point.t ;
58 
59  if(time_difference < 0)
60  time_difference *= -1;
61 
62  if(max_time_difference < time_difference)
63  max_time_difference = time_difference ;
64 
65  if(max_charge < charge)
66  max_charge = charge ;
67 
68  if(c->GetParams().N_Hits > max_hits_1) {
69  max_hits_2 = max_hits_1;
70  max_hits_1 = c->GetParams().N_Hits;
71  }else if(c->GetParams().N_Hits > max_hits_2)
72  max_hits_2 = c->GetParams().N_Hits;
73 
74  }
75 
76  ratio = 1;
77  charge_ratio = 1;
78  for(size_t c_index=0; c_index<clusters.size(); ++c_index) {
79  auto const& c = clusters[c_index];
80 
81  double length = c->GetParams().length ;
82  //auto charge = c->GetParams().sum_charge ;
83  //Order hits from most to least
84  //SetMaxMiddleMin(hits_0,hits_1,hits_2,max_hits,middle_hits,min_hits);
85 
86  //Make start_t always smaller
87  if(c->GetParams().start_point.t > c->GetParams().end_point.t){
88  start_t = c->GetParams().end_point.t ;
89  end_t = c->GetParams().start_point.t ;
90  }
91  else{
92  start_t = c->GetParams().start_point.t ;
93  end_t = c->GetParams().end_point.t ;
94  }
95 
96  if(prev_start_t ==0)
97  prev_start_t = start_t ;
98  if(prev_end_t ==0)
99  prev_end_t = end_t ;
100 
101  time_difference = end_t - start_t ;
102 
103  ratio *= time_difference/max_time_difference ;
104 
105  charge_ratio = max_hits_2 / max_hits_1;// charge/max_charge ;
106 
107  if(c_index==(clusters.size()-1))
108  ratio *= charge_ratio ;
109 
110  //If current cluster's start time is not within some range of the previous cluster's start time,
111  //modify ratio to disallow matching
112 
113  if( (start_t > (prev_start_t - _start_time_cut) && start_t < (prev_start_t + _start_time_cut))
114  || (end_t > (prev_end_t - _start_time_cut) && end_t < (prev_end_t + _start_time_cut) )
115  || (length >25 && start_t >(prev_start_t - 2*_start_time_cut) && start_t < (prev_start_t + 2*_start_time_cut) ) )
116  ratio *= 1;
117  else
118  ratio*= 0.001;
119 
120  prev_start_t = start_t ;
121  prev_end_t = end_t ;
122 
123  if( _debug && c_index==(clusters.size()-1) && ratio > _time_ratio_cut ){
124  std::cout<<"\nPLANE: "<<c->Plane() ;
125  std::cout<<"\nStart point: "<<start_t<<std::endl;
126  std::cout<<"End Point: "<<end_t <<std::endl;
127  // std::cout<<"Previous start time: "<<prev_start_t<<std::endl;
128  std::cout<<"Time diff: "<<time_difference<<std::endl;
129  std::cout<<"Max time diff: "<<max_time_difference<<std::endl;
130  std::cout<<"Ratio for each cluster: "<<ratio<<std::endl;
131  // std::cout<<"Charge: "<<charge<<std::endl;
132  std::cout<<"Charge Ratio: "<<charge_ratio<<std::endl;
133  //std::cout<<"Hits are: "<<min_hits<<", "<<middle_hits<<", "<<max_hits<<std::endl;
134  // std::cout<<"Adjusted Charge Ratio: "<<adjusted_charge_ratio<<std::endl;
135  std::cout<<"Length and Width: "<<c->GetParams().length<<", "<<c->GetParams().width<<std::endl;
136  }
137 
138  }
139 
140  if(_verbose && ratio> _time_ratio_cut)
141  std::cout<<"**************************FOUND A MATCH . ratio is: "<<ratio<<"\n\n\n"<<std::endl;
142 
143  return (ratio > _time_ratio_cut ? ratio : -1 );
144 
145  }
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::CFAlgoTimeOverlap::Report ( )
virtual

Optional function: called after Bool() function is called for all possible cluster pairs by CMergeManager/CMatchManager IFF run with verbosity level kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 237 of file CFAlgoTimeOverlap.cxx.

Referenced by RequireThreePlanes().

239  {
240  }
void cmtool::CFAlgoTimeOverlap::RequireThreePlanes ( bool  doit)
inline

Definition at line 54 of file CFAlgoTimeOverlap.h.

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

Referenced by CFAlgoTimeOverlap().

void cmtool::CFAlgoTimeOverlap::Reset ( )
virtual

Function to reset the algorithm instance called within CMergeManager/CMatchManager's Reset() ... maybe implemented via child class.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 20 of file CFAlgoTimeOverlap.cxx.

Referenced by RequireThreePlanes().

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::CFAlgoTimeOverlap::SetDebug ( bool  debug)
inline

Definition at line 50 of file CFAlgoTimeOverlap.h.

References _debug, and tca::debug.

Referenced by CFAlgoTimeOverlap().

50 { _debug = debug ; }
DebugStuff debug
Definition: DebugStruct.cxx:4
void cmtool::CFAlgoTimeOverlap::SetRatioCut ( float  ratio)
inline

Definition at line 42 of file CFAlgoTimeOverlap.h.

References _time_ratio_cut.

Referenced by CFAlgoTimeOverlap().

42 { _time_ratio_cut = ratio ; }
void cmtool::CFAlgoTimeOverlap::SetStartTimeCut ( float  start_time)
inline

Definition at line 40 of file CFAlgoTimeOverlap.h.

References _start_time_cut.

Referenced by CFAlgoTimeOverlap().

40 { _start_time_cut = start_time ; }
void cmtool::CFAlgoTimeOverlap::SetVerbose ( bool  doit)
inlinevirtual

Setter function for verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 52 of file CFAlgoTimeOverlap.h.

References _verbose.

Referenced by CFAlgoTimeOverlap().

52 { _verbose = verbose ; }

Member Data Documentation

bool cmtool::CFAlgoTimeOverlap::_debug
protected

Definition at line 63 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetDebug().

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().

bool cmtool::CFAlgoTimeOverlap::_require_3planes
protected

Definition at line 65 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and RequireThreePlanes().

float cmtool::CFAlgoTimeOverlap::_start_time_cut
protected

Definition at line 62 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetStartTimeCut().

float cmtool::CFAlgoTimeOverlap::_time_ratio_cut
protected

Definition at line 61 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetRatioCut().

bool cmtool::CFAlgoTimeOverlap::_verbose
protected

Definition at line 64 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetVerbose().


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