CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 24 of file CSCSegAlgoPreClustering.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 31 of file CSCSegAlgoPreClustering.cc.

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

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

destructor

Definition at line 41 of file CSCSegAlgoPreClustering.cc.

41  {
42 
43 }

Member Function Documentation

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

clusterize

Definition at line 50 of file CSCSegAlgoPreClustering.cc.

References begin, gather_cfg::cout, dXclusBoxMax, dYclusBoxMax, end, err_x, err_y, i, mean_x, mean_y, findQualityFiles::size, groupFilesInBlocks::temp, theChamber, x, and detailsBasic3DVector::y.

Referenced by CSCSegAlgoDF::run().

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

Member Data Documentation

bool CSCSegAlgoPreClustering::debug
private

Definition at line 36 of file CSCSegAlgoPreClustering.h.

Referenced by CSCSegAlgoPreClustering().

double CSCSegAlgoPreClustering::dXclusBoxMax
private

Definition at line 37 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits(), and CSCSegAlgoPreClustering().

double CSCSegAlgoPreClustering::dYclusBoxMax
private

Definition at line 38 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits(), and CSCSegAlgoPreClustering().

float CSCSegAlgoPreClustering::err_x
private

Definition at line 40 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::err_y
private

Definition at line 40 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::mean_x
private

Definition at line 40 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

float CSCSegAlgoPreClustering::mean_y
private

Definition at line 40 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().

const CSCChamber* CSCSegAlgoPreClustering::theChamber
private

Definition at line 41 of file CSCSegAlgoPreClustering.h.

Referenced by clusterHits().