CMS 3D CMS Logo

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

#include <RoadSearchCloudCleanerAlgorithm.h>

Public Member Functions

 RoadSearchCloudCleanerAlgorithm (const edm::ParameterSet &conf)
 
void run (const RoadSearchCloudCollection *input, const edm::EventSetup &es, RoadSearchCloudCollection &output)
 Runs the algorithm. More...
 
 ~RoadSearchCloudCleanerAlgorithm ()
 

Private Attributes

unsigned int maxRecHitsInCloud_
 
double mergingFraction_
 

Detailed Description

Definition at line 22 of file RoadSearchCloudCleanerAlgorithm.h.

Constructor & Destructor Documentation

RoadSearchCloudCleanerAlgorithm::RoadSearchCloudCleanerAlgorithm ( const edm::ParameterSet conf)

Definition at line 23 of file RoadSearchCloudCleanerAlgorithm.cc.

References edm::ParameterSet::getParameter(), maxRecHitsInCloud_, and mergingFraction_.

23  {
24 
25  // store parameter
26  mergingFraction_ = conf.getParameter<double>("MergingFraction");
27  maxRecHitsInCloud_ = conf.getParameter<int>("MaxRecHitsInCloud");
28 
29 }
T getParameter(std::string const &) const
RoadSearchCloudCleanerAlgorithm::~RoadSearchCloudCleanerAlgorithm ( )

Definition at line 31 of file RoadSearchCloudCleanerAlgorithm.cc.

31  {
32 }

Member Function Documentation

void RoadSearchCloudCleanerAlgorithm::run ( const RoadSearchCloudCollection input,
const edm::EventSetup es,
RoadSearchCloudCollection output 
)

Runs the algorithm.

Definition at line 34 of file RoadSearchCloudCleanerAlgorithm.cc.

References RoadSearchCloud::addHit(), RoadSearchCloud::begin_hits(), RoadSearchCloud::end_hits(), i, collect_tpl::input, gen::k, LogDebug, maxRecHitsInCloud_, mergingFraction_, and RoadSearchCloud::size().

Referenced by cms::RoadSearchCloudCleaner::produce().

37 {
38 
39  //
40  // right now cloud cleaning solely consist of merging clouds based on the number
41  // of shared hits (getting rid of obvious duplicates) - don't need roads and
42  // geometry for this - eventually this stage will become a sub-process (probably
43  // early on) of cloud cleaning
44  //
45 
46  LogDebug("RoadSearch") << "Raw Clouds input size: " << input->size();
47 
48  //
49  // no raw clouds - nothing to try merging
50  //
51 
52  if ( input->empty() ){
53  LogDebug("RoadSearch") << "Found " << output.size() << " clouds.";
54  return;
55  }
56 
57  //
58  // 1 raw cloud - nothing to try merging, but one cloud to duplicate
59  //
60 
61  if ( 1==input->size() ){
62  output = *input;
63  LogDebug("RoadSearch") << "Found " << output.size() << " clouds.";
64  return;
65  }
66 
67  //
68  // got > 1 raw cloud - something to try merging
69  //
70  std::vector<bool> already_gone(input->size());
71  for (unsigned int i=0; i<input->size(); ++i) {
72  already_gone[i] = false;
73  }
74 
75  int raw_cloud_ctr=0;
76  // loop over clouds
77  for ( RoadSearchCloudCollection::const_iterator raw_cloud = input->begin(); raw_cloud != input->end(); ++raw_cloud) {
78  ++raw_cloud_ctr;
79 
80  if (already_gone[raw_cloud_ctr-1])continue;
81 
82  // produce output cloud where other clouds are merged in
83  RoadSearchCloud lone_cloud = *raw_cloud;
84  int second_cloud_ctr=raw_cloud_ctr;
85  for ( RoadSearchCloudCollection::const_iterator second_cloud = raw_cloud+1; second_cloud != input->end(); ++second_cloud) {
86  second_cloud_ctr++;
87 
88  std::vector<const TrackingRecHit*> unshared_hits;
89 
90  if ( already_gone[second_cloud_ctr-1] )continue;
91 
92  for ( RoadSearchCloud::RecHitVector::const_iterator second_cloud_hit = second_cloud->begin_hits();
93  second_cloud_hit != second_cloud->end_hits();
94  ++ second_cloud_hit ) {
95  bool is_shared = false;
96  for ( RoadSearchCloud::RecHitVector::const_iterator lone_cloud_hit = lone_cloud.begin_hits();
97  lone_cloud_hit != lone_cloud.end_hits();
98  ++ lone_cloud_hit ) {
99 
100  if ((*lone_cloud_hit)->geographicalId().rawId() == (*second_cloud_hit)->geographicalId().rawId())
101  if ((*lone_cloud_hit)->localPosition().x() == (*second_cloud_hit)->localPosition().x())
102  if ((*lone_cloud_hit)->localPosition().y() == (*second_cloud_hit)->localPosition().y())
103  {is_shared=true; break;}
104  }
105  if (!is_shared) unshared_hits.push_back(*second_cloud_hit);
106 
107  if ( ((float(unshared_hits.size())/float(lone_cloud.size())) >
108  ((float(second_cloud->size())/float(lone_cloud.size()))-mergingFraction_)) &&
109  ((float(unshared_hits.size())/float(second_cloud->size())) > (1-mergingFraction_))){
110  // You'll never merge these clouds..... Could quit now!
111  break;
112  }
113 
114  }
115 
116  double f_lone_shared=double(second_cloud->size()-unshared_hits.size())/double(lone_cloud.size());
117  double f_second_shared=double(second_cloud->size()-unshared_hits.size())/double(second_cloud->size());
118 
119  if ( ( (static_cast<unsigned int>(f_lone_shared*1E9) > static_cast<unsigned int>(mergingFraction_*1E9))||(static_cast<unsigned int>(f_second_shared*1E9) > static_cast<unsigned int>(mergingFraction_*1E9)) )
120  && (lone_cloud.size()+unshared_hits.size() <= maxRecHitsInCloud_) ){
121 
122  LogDebug("RoadSearch") << " Merge CloudA: " << raw_cloud_ctr << " with CloudB: " << second_cloud_ctr
123  << " Shared fractions are " << f_lone_shared << " and " << f_second_shared;
124 
125  //
126  // got a cloud to merge
127  //
128  for (unsigned int k=0; k<unshared_hits.size(); ++k) {
129  lone_cloud.addHit(unshared_hits[k]);
130  }
131 
132  already_gone[second_cloud_ctr-1]=true;
133 
134  }//end got a cloud to merge
135 
136  }//interate over all second clouds
137 
138  output.push_back(lone_cloud);
139 
140  }//iterate over all raw clouds
141 
142  LogDebug("RoadSearch") << "Found " << output.size() << " clean clouds.";
143 
144 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int size() const
RecHitVector::const_iterator begin_hits() const
void addHit(const TrackingRecHit *input)
tuple input
Definition: collect_tpl.py:10
int k[5][pyjets_maxn]
RecHitVector::const_iterator end_hits() const

Member Data Documentation

unsigned int RoadSearchCloudCleanerAlgorithm::maxRecHitsInCloud_
private

Definition at line 36 of file RoadSearchCloudCleanerAlgorithm.h.

Referenced by RoadSearchCloudCleanerAlgorithm(), and run().

double RoadSearchCloudCleanerAlgorithm::mergingFraction_
private

Definition at line 35 of file RoadSearchCloudCleanerAlgorithm.h.

Referenced by RoadSearchCloudCleanerAlgorithm(), and run().