CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Attributes
CSCSegAlgoPreClustering Class Reference

#include <CSCSegAlgoPreClustering.h>

Public Types

typedef std::vector< const
CSCRecHit2D * > 
ChamberHitContainer
 

Public Member Functions

std::vector< std::vector
< const CSCRecHit2D * > > 
clusterHits (const CSCChamber *aChamber, const ChamberHitContainer &rechits)
 clusterize More...
 
 CSCSegAlgoPreClustering (const edm::ParameterSet &ps)
 constructor More...
 
 ~CSCSegAlgoPreClustering ()
 destructor More...
 

Private Attributes

bool debug
 
double dXclusBoxMax
 
double dYclusBoxMax
 
float err_x
 
float err_y
 
float mean_x
 
float mean_y
 
const CSCChambertheChamber
 

Detailed Description

Definition at line 20 of file CSCSegAlgoPreClustering.h.

Member Typedef Documentation

Definition at line 22 of file CSCSegAlgoPreClustering.h.

Constructor & Destructor Documentation

CSCSegAlgoPreClustering::CSCSegAlgoPreClustering ( const edm::ParameterSet ps)
explicit

constructor

Definition at line 30 of file CSCSegAlgoPreClustering.cc.

References debug, dXclusBoxMax, dYclusBoxMax, edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

30  {
31  dXclusBoxMax = ps.getParameter<double>("dXclusBoxMax");
32  dYclusBoxMax = ps.getParameter<double>("dYclusBoxMax");
33  debug = ps.getUntrackedParameter<bool>("CSCSegmentDebug");
34 }
T getUntrackedParameter(std::string const &, T const &) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CSCSegAlgoPreClustering::~CSCSegAlgoPreClustering ( )

destructor

Definition at line 39 of file CSCSegAlgoPreClustering.cc.

39 {}

Member Function Documentation

std::vector< std::vector< const CSCRecHit2D * > > CSCSegAlgoPreClustering::clusterHits ( const CSCChamber aChamber,
const ChamberHitContainer rechits 
)

clusterize

Definition at line 44 of file CSCSegAlgoPreClustering.cc.

References SplitLinear::begin, gather_cfg::cout, dXclusBoxMax, dYclusBoxMax, dataset::end, err_x, err_y, mps_fire::i, mean_x, mean_y, DetachedQuadStep_cff::seeds, findQualityFiles::size, groupFilesInBlocks::temp, theChamber, x, and y.

Referenced by CSCSegAlgoDF::run().

45  {
46  theChamber = aChamber;
47 
48  std::vector<ChamberHitContainer> rechits_clusters; // this is a collection of groups of rechits
49 
50  //float dXclus = 0.0;
51  //float dYclus = 0.0;
52  float dXclus_box = 0.0;
53  float dYclus_box = 0.0;
54 
55  std::vector<const CSCRecHit2D*> temp;
56 
57  std::vector<ChamberHitContainer> seeds;
58 
59  std::vector<float> running_meanX;
60  std::vector<float> running_meanY;
61 
62  std::vector<float> seed_minX;
63  std::vector<float> seed_maxX;
64  std::vector<float> seed_minY;
65  std::vector<float> seed_maxY;
66 
67  // split rechits into subvectors and return vector of vectors:
68  // Loop over rechits
69  // Create one seed per hit
70  for (unsigned int i = 0; i < rechits.size(); ++i) {
71  temp.clear();
72 
73  temp.push_back(rechits[i]);
74 
75  seeds.push_back(temp);
76 
77  // First added hit in seed defines the mean to which the next hit is compared
78  // for this seed.
79 
80  running_meanX.push_back(rechits[i]->localPosition().x());
81  running_meanY.push_back(rechits[i]->localPosition().y());
82 
83  // set min/max X and Y for box containing the hits in the precluster:
84  seed_minX.push_back(rechits[i]->localPosition().x());
85  seed_maxX.push_back(rechits[i]->localPosition().x());
86  seed_minY.push_back(rechits[i]->localPosition().y());
87  seed_maxY.push_back(rechits[i]->localPosition().y());
88  }
89 
90  // merge clusters that are too close
91  // measure distance between final "running mean"
92  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
93  for (size_t MMM = NNN + 1; MMM < seeds.size(); ++MMM) {
94  if (running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999.) {
95  std::cout << "We should never see this line now!!!" << std::endl;
96  continue; //skip seeds that have been used
97  }
98 
99  // calculate cut criteria for simple running mean distance cut:
100  //dXclus = fabs(running_meanX[NNN] - running_meanX[MMM]);
101  //dYclus = fabs(running_meanY[NNN] - running_meanY[MMM]);
102 
103  // calculate minmal distance between precluster boxes containing the hits:
104  if (running_meanX[NNN] > running_meanX[MMM])
105  dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
106  else
107  dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
108  if (running_meanY[NNN] > running_meanY[MMM])
109  dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
110  else
111  dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
112 
113  if (dXclus_box < dXclusBoxMax && dYclus_box < dYclusBoxMax) {
114  // merge clusters!
115  // merge by adding seed NNN to seed MMM and erasing seed NNN
116 
117  // calculate running mean for the merged seed:
118  running_meanX[MMM] = (running_meanX[NNN] * seeds[NNN].size() + running_meanX[MMM] * seeds[MMM].size()) /
119  (seeds[NNN].size() + seeds[MMM].size());
120  running_meanY[MMM] = (running_meanY[NNN] * seeds[NNN].size() + running_meanY[MMM] * seeds[MMM].size()) /
121  (seeds[NNN].size() + seeds[MMM].size());
122 
123  // update min/max X and Y for box containing the hits in the merged cluster:
124  if (seed_minX[NNN] <= seed_minX[MMM])
125  seed_minX[MMM] = seed_minX[NNN];
126  if (seed_maxX[NNN] > seed_maxX[MMM])
127  seed_maxX[MMM] = seed_maxX[NNN];
128  if (seed_minY[NNN] <= seed_minY[MMM])
129  seed_minY[MMM] = seed_minY[NNN];
130  if (seed_maxY[NNN] > seed_maxY[MMM])
131  seed_maxY[MMM] = seed_maxY[NNN];
132 
133  // add seed NNN to MMM (lower to larger number)
134  seeds[MMM].insert(seeds[MMM].end(), seeds[NNN].begin(), seeds[NNN].end());
135 
136  // mark seed NNN as used (at the moment just set running mean to 999999.)
137  running_meanX[NNN] = 999999.;
138  running_meanY[NNN] = 999999.;
139  // we have merged a seed (NNN) to the highter seed (MMM) - need to contimue to
140  // next seed (NNN+1)
141  break;
142  }
143  }
144  }
145 
146  // hand over the final seeds to the output
147  // would be more elegant if we could do the above step with
148  // erasing the merged ones, rather than the
149  for (size_t NNN = 0; NNN < seeds.size(); ++NNN) {
150  if (running_meanX[NNN] == 999999.)
151  continue; //skip seeds that have been marked as used up in merging
152  rechits_clusters.push_back(seeds[NNN]);
153  mean_x = running_meanX[NNN];
154  mean_y = running_meanY[NNN];
155  err_x =
156  (seed_maxX[NNN] - seed_minX[NNN]) / 3.464101615; // use box size divided by sqrt(12) as position error estimate
157  err_y =
158  (seed_maxY[NNN] - seed_minY[NNN]) / 3.464101615; // use box size divided by sqrt(12) as position error estimate
159  }
160 
161  return rechits_clusters;
162 }
string end
Definition: dataset.py:937
tuple cout
Definition: gather_cfg.py:144
tuple size
Write out results.

Member Data Documentation

bool CSCSegAlgoPreClustering::debug
private
double CSCSegAlgoPreClustering::dXclusBoxMax
private

Definition at line 36 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits(), and CSCSegAlgoPreClustering().

double CSCSegAlgoPreClustering::dYclusBoxMax
private

Definition at line 37 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits(), and CSCSegAlgoPreClustering().

float CSCSegAlgoPreClustering::err_x
private

Definition at line 39 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::err_y
private

Definition at line 39 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::mean_x
private

Definition at line 39 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::mean_y
private

Definition at line 39 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

const CSCChamber* CSCSegAlgoPreClustering::theChamber
private

Definition at line 40 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().