All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
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...
 
- Public Member Functions inherited from cmtool::CMAlgoBase
 CMAlgoBase ()
 
virtual ~CMAlgoBase ()=default
 
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
 
- Protected Attributes inherited from cmtool::CMAlgoBase
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...
 

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.

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

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

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

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

Definition at line 67 of file CFAlgoTimeOverlap.h.

68  {
69  _require_3planes = doit;
70  }
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 18 of file CFAlgoTimeOverlap.cxx.

20  {}
void cmtool::CFAlgoTimeOverlap::SetDebug ( bool  debug)
inline

Definition at line 55 of file CFAlgoTimeOverlap.h.

void cmtool::CFAlgoTimeOverlap::SetRatioCut ( float  ratio)
inline

Definition at line 44 of file CFAlgoTimeOverlap.h.

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

Definition at line 38 of file CFAlgoTimeOverlap.h.

39  {
41  }
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production start_time
void cmtool::CFAlgoTimeOverlap::SetVerbose ( bool  doit)
inlineoverridevirtual

Setter function for verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 61 of file CFAlgoTimeOverlap.h.

62  {
63  _verbose = verbose;
64  }
v let verbose

Member Data Documentation

bool cmtool::CFAlgoTimeOverlap::_debug
protected

Definition at line 79 of file CFAlgoTimeOverlap.h.

bool cmtool::CFAlgoTimeOverlap::_require_3planes
protected

Definition at line 81 of file CFAlgoTimeOverlap.h.

float cmtool::CFAlgoTimeOverlap::_start_time_cut
protected

Definition at line 78 of file CFAlgoTimeOverlap.h.

float cmtool::CFAlgoTimeOverlap::_time_ratio_cut
protected

Definition at line 77 of file CFAlgoTimeOverlap.h.

bool cmtool::CFAlgoTimeOverlap::_verbose
protected

Definition at line 80 of file CFAlgoTimeOverlap.h.


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