LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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...
 
float Float (util::GeometryUtilities const &, const std::vector< const cluster::ClusterParamsAlg * > &clusters) override
 
void SetStartTimeCut (float start_time)
 
void SetRatioCut (float ratio)
 
void SetDebug (bool debug)
 
void SetVerbose (bool verbose) override
 Setter function for verbosity. More...
 
void RequireThreePlanes (bool doit)
 
void Report () override
 
void Reset () override
 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 > &)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &)
 
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 6 of file CFAlgoTimeOverlap.cxx.

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

8  {
9  SetRatioCut(0.001); //(0.095) ;
10  SetStartTimeCut(10);
11  SetDebug(false);
12  SetVerbose(false);
13  RequireThreePlanes(true);
14  }
void SetStartTimeCut(float start_time)
void SetVerbose(bool verbose) override
Setter function for verbosity.
void RequireThreePlanes(bool doit)
void SetRatioCut(float ratio)

Member Function Documentation

virtual void cmtool::CMAlgoBase::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  )
inlinevirtualinherited

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

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

Definition at line 45 of file CMAlgoBase.h.

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

45 {}
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

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

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

Definition at line 50 of file CMAlgoBase.h.

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

50 {}
float cmtool::CFAlgoTimeOverlap::Float ( util::GeometryUtilities const &  ,
const std::vector< const cluster::ClusterParamsAlg * > &  clusters 
)
overridevirtual

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 22 of file CFAlgoTimeOverlap.cxx.

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

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

Definition at line 57 of file CMAlgoBase.h.

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

57 {}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

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

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

Definition at line 62 of file CMAlgoBase.h.

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

62 {}
void cmtool::CFAlgoTimeOverlap::Report ( )
overridevirtual

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 225 of file CFAlgoTimeOverlap.cxx.

Referenced by RequireThreePlanes().

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

Definition at line 50 of file CFAlgoTimeOverlap.h.

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

Referenced by CFAlgoTimeOverlap().

void cmtool::CFAlgoTimeOverlap::Reset ( )
overridevirtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 17 of file CFAlgoTimeOverlap.cxx.

Referenced by RequireThreePlanes().

19  {}
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 72 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

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

72 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:79
void cmtool::CFAlgoTimeOverlap::SetDebug ( bool  debug)
inline

Definition at line 46 of file CFAlgoTimeOverlap.h.

References _debug, and tca::debug.

Referenced by CFAlgoTimeOverlap().

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

Definition at line 39 of file CFAlgoTimeOverlap.h.

References _time_ratio_cut.

Referenced by CFAlgoTimeOverlap().

void cmtool::CFAlgoTimeOverlap::SetStartTimeCut ( float  start_time)
inline

Definition at line 37 of file CFAlgoTimeOverlap.h.

References _start_time_cut.

Referenced by CFAlgoTimeOverlap().

37 { _start_time_cut = start_time; }
void cmtool::CFAlgoTimeOverlap::SetVerbose ( bool  doit)
inlineoverridevirtual

Setter function for verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 48 of file CFAlgoTimeOverlap.h.

References _verbose.

Referenced by CFAlgoTimeOverlap().

48 { _verbose = verbose; }

Member Data Documentation

bool cmtool::CFAlgoTimeOverlap::_debug
protected

Definition at line 59 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetDebug().

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 79 of file CMAlgoBase.h.

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

bool cmtool::CFAlgoTimeOverlap::_require_3planes
protected

Definition at line 61 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and RequireThreePlanes().

float cmtool::CFAlgoTimeOverlap::_start_time_cut
protected

Definition at line 58 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetStartTimeCut().

float cmtool::CFAlgoTimeOverlap::_time_ratio_cut
protected

Definition at line 57 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetRatioCut().

bool cmtool::CFAlgoTimeOverlap::_verbose
protected

Definition at line 60 of file CFAlgoTimeOverlap.h.

Referenced by Float(), and SetVerbose().


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