This algorithm calculates the difference between start and end times for merged clusters, and compares across planes to form matches. 
   36     double time_difference = 0;
 
   37     double max_time_difference = 0;
 
   38     double max_charge = 0;
 
   39     double charge_ratio = 1;
 
   45     double prev_start_t = 0;
 
   46     double prev_end_t = 0;
 
   48     double max_hits_1 = 0;
 
   49     double max_hits_2 = 0;
 
   51     for (
auto const& c : clusters) {
 
   53       auto charge = c->GetParams().sum_charge;
 
   55       time_difference = c->GetParams().start_point.t - c->GetParams().end_point.t;
 
   57       if (time_difference < 0) time_difference *= -1;
 
   59       if (max_time_difference < time_difference) max_time_difference = time_difference;
 
   61       if (max_charge < charge) max_charge = charge;
 
   63       if (c->GetParams().N_Hits > max_hits_1) {
 
   64         max_hits_2 = max_hits_1;
 
   65         max_hits_1 = c->GetParams().N_Hits;
 
   67       else if (c->GetParams().N_Hits > max_hits_2)
 
   68         max_hits_2 = c->GetParams().N_Hits;
 
   73     for (
size_t c_index = 0; c_index < clusters.size(); ++c_index) {
 
   74       auto const& c = clusters[c_index];
 
   76       double length = c->GetParams().length;
 
   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;
 
   87         start_t = c->GetParams().start_point.t;
 
   88         end_t = c->GetParams().end_point.t;
 
   91       if (prev_start_t == 0) prev_start_t = start_t;
 
   92       if (prev_end_t == 0) prev_end_t = end_t;
 
   94       time_difference = end_t - start_t;
 
   96       ratio *= time_difference / max_time_difference;
 
   98       charge_ratio = max_hits_2 / max_hits_1; 
 
  100       if (c_index == (clusters.size() - 1)) ratio *= charge_ratio;
 
  114       prev_start_t = start_t;
 
  119         std::cout << 
"\nStart point: " << start_t << std::endl;
 
  120         std::cout << 
"End Point: " << end_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;
 
  126         std::cout << 
"Charge Ratio: " << charge_ratio << std::endl;
 
  129         std::cout << 
"Length and Width: " << c->GetParams().length << 
", " << c->GetParams().width
 
  135       std::cout << 
"**************************FOUND A MATCH . ratio is: " << ratio << 
"\n\n\n" 
BEGIN_PROLOG could also be cout