Project

General

Profile

Bug #1842 » doublet_npe.cpp

Doublet Recon code based on NPE - Overton, Edward, 25 April 2016 13:14

 
1
#include <algorithm>
2
void SciFiSpacePointRec::look_for_duplets_npe(SciFiEvent &evt,
3
					      std::vector<SciFiCluster*> (&clusters)[2][6][3]) const {
4
  
5
  for ( int Tracker = 0; Tracker < 2; Tracker++ ) {  // for each tracker
6
    for ( int Station = 0; Station < 6; Station++ ) {  // for each station
7

    
8
      // Make a list of all clusters in the station:
9
      std::vector<SciFiCluster*> station_clusters;
10
      for ( int a_plane = 0; a_plane < 3; a_plane++ )
11
	station_clusters.insert(station_clusters.end(),
12
				clusters[Tracker][Station][a_plane].begin(),
13
				clusters[Tracker][Station][a_plane].end());
14
									    
15
      // Sort clusters in NPE order:
16
      std::sort(station_clusters.begin(), station_clusters.end(), 
17
		[](const SciFiCluster* a, const SciFiCluster* b) -> bool{ 
18
		  return a->get_npe() > b->get_npe(); 
19
		});
20

    
21
      //debug print statememnt
22
      //int unused = 0;
23
      //for (auto c : station_clusters) if (not c->is_used()) unused++;
24
      //if (unused > 1){
25
      //
26
      //	std::cerr << std::endl;
27
      //	std::cerr << "T:" << Tracker << " S:" << Station << std::endl;
28
      //	std::cerr << "LY: ";
29
      //	for (auto c : station_clusters) std::cerr << c->get_npe() << ", ";
30
      //	std::cerr << std::endl;
31
      //}
32
	
33
      // Iterate over clusters in NPE order to make duplets:
34
      for (auto a_it = station_clusters.begin(); a_it != station_clusters.end(); ++a_it){
35
	SciFiCluster* candidate_A = (*a_it);
36
	// Inner iteration over other candidates:
37
	for (auto b_it = station_clusters.begin(); b_it != station_clusters.end(); ++b_it){
38
	  SciFiCluster* candidate_B = (*b_it);
39
	  if ( clusters_are_not_used(candidate_A, candidate_B) &&
40
	       candidate_A->get_plane() != candidate_B->get_plane() &&
41
	       duplet_within_radius(candidate_A, candidate_B) ) {
42

    
43
	    //std::cerr << "DP: " << candidate_A->get_npe() << ", " << candidate_B->get_npe() << std::endl;
44
	    SciFiSpacePoint* duplet = new SciFiSpacePoint(candidate_A, candidate_B);
45
	    build_duplet(duplet);
46
	    evt.add_spacepoint(duplet);
47
	    break;
48
	  }
49
	}
50
      }
51
    }
52
  }
53
}
(2-2/2)