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 Types | Private Member Functions | Private Attributes
RPCSeedOverlapper Class Reference

#include <RPCSeedOverlapper.h>

Public Member Functions

void configure (const edm::ParameterSet &iConfig)
 
 RPCSeedOverlapper ()
 
void run ()
 
void setEventSetup (const edm::EventSetup &iSetup)
 
void setIO (std::vector< weightedTrajectorySeed > *goodweightedRef, std::vector< weightedTrajectorySeed > *candidateweightedRef)
 
void unsetIO ()
 
 ~RPCSeedOverlapper ()
 

Private Types

typedef
RPCSeedPattern::weightedTrajectorySeed 
weightedTrajectorySeed
 

Private Member Functions

void CheckOverlap (const edm::EventSetup &iSetup, std::vector< weightedTrajectorySeed > *SeedsRef)
 
bool isShareHit (const edm::OwnVector< TrackingRecHit > &RecHits, const TrackingRecHit &hit, edm::ESHandle< RPCGeometry > rpcGeometry)
 

Private Attributes

std::vector
< weightedTrajectorySeed > * 
candidateweightedSeedsRef
 
const edm::EventSetupeSetup
 
std::vector
< weightedTrajectorySeed > * 
goodweightedSeedsRef
 
bool isCheckcandidateOverlap
 
bool isCheckgoodOverlap
 
bool isConfigured
 
bool isEventSetupset
 
bool isIOset
 
unsigned int ShareRecHitsNumberThreshold
 

Detailed Description

Definition at line 21 of file RPCSeedOverlapper.h.

Member Typedef Documentation

Definition at line 23 of file RPCSeedOverlapper.h.

Constructor & Destructor Documentation

RPCSeedOverlapper::RPCSeedOverlapper ( )

Definition at line 14 of file RPCSeedOverlapper.cc.

14  {
15 
16  isConfigured = false;
17  isIOset = false;
18  isEventSetupset = false;
19 }
RPCSeedOverlapper::~RPCSeedOverlapper ( )

Definition at line 21 of file RPCSeedOverlapper.cc.

21  {
22 
23 }

Member Function Documentation

void RPCSeedOverlapper::CheckOverlap ( const edm::EventSetup iSetup,
std::vector< weightedTrajectorySeed > *  SeedsRef 
)
private

Definition at line 63 of file RPCSeedOverlapper.cc.

References edm::OwnVector< T, P >::clear(), gather_cfg::cout, edm::EventSetup::get(), N, edm::OwnVector< T, P >::push_back(), and edm::OwnVector< T, P >::size().

63  {
64 
65  std::vector<weightedTrajectorySeed> sortweightedSeeds;
66  std::vector<weightedTrajectorySeed> tempweightedSeeds;
68 
69  edm::ESHandle<RPCGeometry> rpcGeometry;
70  iSetup.get<MuonGeometryRecord>().get(rpcGeometry);
71 
72  while(weightedSeedsRef->size() != 0) {
73  cout << "Finding the weighted seeds group from " << weightedSeedsRef->size() << " seeds which share some recHits" << endl;
74  // Take 1st seed in SeedsRef as referrence and find a collection which always share some recHits with some other
75  tempRecHits.clear();
76  tempweightedSeeds.clear();
77  int N = 0;
78  for(vector<weightedTrajectorySeed>::iterator itweightedseed = weightedSeedsRef->begin(); itweightedseed != weightedSeedsRef->end(); N++) {
79  TrajectorySeed::range RecHitsRange = itweightedseed->first.recHits();
80  if(N == 0) {
81  cout << "Always take the 1st weighted seed to be the referrence." << endl;
82  for(TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
83  cout << "Put its recHits to tempRecHits" << endl;
84  tempRecHits.push_back(it->clone());
85  }
86  cout << "Put it to tempweightedSeeds" << endl;
87  tempweightedSeeds.push_back(*itweightedseed);
88  cout << "Then erase from weightedSeedsRef->" << endl;
89  itweightedseed = weightedSeedsRef->erase(itweightedseed);
90  }
91  else {
92  cout << "Come to other weighted seed for checking " << itweightedseed->first.nHits() << " recHits from " << tempRecHits.size() << " temp recHits" << endl;
93  unsigned int ShareRecHitsNumber = 0;
94  for(TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
95  if(isShareHit(tempRecHits, *it, rpcGeometry))
96  ShareRecHitsNumber++;
97  }
98  if(ShareRecHitsNumber >= ShareRecHitsNumberThreshold) {
99  cout <<"This seed is found to belong to current share group" << endl;
100  for(TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
101  if(!isShareHit(tempRecHits, *it, rpcGeometry)) {
102  cout << "Put its extra recHits to tempRecHits" << endl;
103  tempRecHits.push_back(it->clone());
104  }
105  }
106  cout << "Put it to tempSeeds" << endl;
107  tempweightedSeeds.push_back(*itweightedseed);
108  cout << "Then erase from SeedsRef" << endl;
109  itweightedseed = weightedSeedsRef->erase(itweightedseed);
110  }
111  else
112  itweightedseed++;
113  }
114  }
115  // Find the best weighted seed and kick out those share recHits with it
116  // The best weighted seed save in sortweightedSeeds, those don't share recHits with it will be push back to weightedSeedsRef for next while loop
117  weightedTrajectorySeed bestweightedSeed;
118  vector<weightedTrajectorySeed>::iterator bestweightediter;
119  // Find the min Spt wrt Pt as the best Seed
120  double Quality = 1000000;
121  unsigned NumberofHits = 0;
122  cout << "Find " << tempweightedSeeds.size() << " seeds into one trajectory group" << endl;
123  for(vector<weightedTrajectorySeed>::iterator itweightedseed = tempweightedSeeds.begin(); itweightedseed != tempweightedSeeds.end(); itweightedseed++) {
124  unsigned int nHits = itweightedseed->first.nHits();
125  //std::vector<float> seed_error = itweightedseed->first.startingState().errorMatrix();
126  //double Spt = seed_error[1];
127  double weightedQuality = itweightedseed->second;
128  cout << "Find a weighted seed with quality " << weightedQuality << endl;
129  if((NumberofHits < nHits) || (NumberofHits == nHits && weightedQuality < Quality)) {
130  NumberofHits = nHits;
131  Quality = weightedQuality;
132  bestweightedSeed = *itweightedseed;
133  bestweightediter = itweightedseed;
134  }
135  }
136  cout << "Best good temp seed's quality is " << Quality <<endl;
137  sortweightedSeeds.push_back(bestweightedSeed);
138  tempweightedSeeds.erase(bestweightediter);
139  tempRecHits.clear();
140 
141  for(TrajectorySeed::const_iterator it = bestweightedSeed.first.recHits().first; it != bestweightedSeed.first.recHits().second; it++)
142  tempRecHits.push_back(it->clone());
143 
144  for(vector<weightedTrajectorySeed>::iterator itweightedseed = tempweightedSeeds.begin(); itweightedseed != tempweightedSeeds.end(); ) {
145  cout << "Checking the temp weighted seed's " << itweightedseed->first.nHits() << " hits to " << tempRecHits.size() << " temp recHits" << endl;
146  TrajectorySeed::range RecHitsRange = itweightedseed->first.recHits();
147  bool isShare = false;
148  for(TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++)
149  if(isShareHit(tempRecHits, *it, rpcGeometry))
150  isShare = true;
151 
152  if(isShare == true) {
153  cout << "Find one temp seed share some recHits with best weighted seed" << endl;
154  itweightedseed = tempweightedSeeds.erase(itweightedseed);
155  }
156  else {
157  cout << "This seed has no relation with best weighted seed" << endl;
158  weightedSeedsRef->push_back(*itweightedseed);
159  itweightedseed = tempweightedSeeds.erase(itweightedseed);
160  }
161  }
162  }
163  // At the end exchange SeedsRef with sortSeeds
164  weightedSeedsRef->clear();
165  *weightedSeedsRef = sortweightedSeeds;
166 }
size_type size() const
Definition: OwnVector.h:254
void push_back(D *&d)
Definition: OwnVector.h:280
bool isShareHit(const edm::OwnVector< TrackingRecHit > &RecHits, const TrackingRecHit &hit, edm::ESHandle< RPCGeometry > rpcGeometry)
recHitContainer::const_iterator const_iterator
void clear()
Definition: OwnVector.h:377
std::pair< const_iterator, const_iterator > range
unsigned int ShareRecHitsNumberThreshold
#define N
Definition: blowfish.cc:9
RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed
const T & get() const
Definition: EventSetup.h:56
tuple cout
Definition: gather_cfg.py:121
void RPCSeedOverlapper::configure ( const edm::ParameterSet iConfig)

Definition at line 25 of file RPCSeedOverlapper.cc.

References edm::ParameterSet::getParameter().

25  {
26 
27  isCheckgoodOverlap = iConfig.getParameter<bool>("isCheckgoodOverlap");
28  isCheckcandidateOverlap = iConfig.getParameter<bool>("isCheckcandidateOverlap");
29  ShareRecHitsNumberThreshold = iConfig.getParameter<unsigned int>("ShareRecHitsNumberThreshold");
30  isConfigured = true;
31 }
T getParameter(std::string const &) const
unsigned int ShareRecHitsNumberThreshold
bool RPCSeedOverlapper::isShareHit ( const edm::OwnVector< TrackingRecHit > &  RecHits,
const TrackingRecHit hit,
edm::ESHandle< RPCGeometry rpcGeometry 
)
private

Definition at line 168 of file RPCSeedOverlapper.cc.

References edm::OwnVector< T, P >::begin(), gather_cfg::cout, edm::OwnVector< T, P >::end(), TrackingRecHit::geographicalId(), TrackingRecHit::localPosition(), gen::n, edm::OwnVector< T, P >::size(), GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

168  {
169 
170  bool istheSame = false;
171  unsigned int n = 1;
172  cout << "Checking from " << RecHits.size() << " temp recHits" << endl;
173 
174  LocalPoint lpos1 = hit.localPosition();
175  DetId RPCId1 = hit.geographicalId();
176  const GeomDetUnit *rpcroll1 = rpcGeometry->idToDetUnit(RPCId1);
177  GlobalPoint gpos1 = rpcroll1->toGlobal(lpos1);
178  cout << "The hit's position: " << gpos1.x() << ", " << gpos1.y() << ", " << gpos1.z() << endl;
179  for(edm::OwnVector<TrackingRecHit>::const_iterator it = RecHits.begin(); it !=RecHits.end(); it++, n++) {
180  cout << "Checking the " << n << " th recHit from tempRecHits" << endl;
181  LocalPoint lpos2 = it->localPosition();
182  DetId RPCId2 = it->geographicalId();
183  const GeomDetUnit *rpcroll2 = rpcGeometry->idToDetUnit(RPCId2);
184  GlobalPoint gpos2 = rpcroll2->toGlobal(lpos2);
185  cout << "The temp hit's position: " << gpos2.x() << ", " << gpos2.y() << ", " << gpos2.z() << endl;
186 
187  if((gpos1.x() == gpos2.x()) && (gpos1.y() == gpos2.y()) && (gpos1.z() == gpos2.z())) {
188  cout << "This hit is found to be the same" << endl;
189  istheSame = true;
190  }
191  }
192  return istheSame;
193 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
size_type size() const
Definition: OwnVector.h:254
T y() const
Definition: PV3DBase.h:63
iterator begin()
Definition: OwnVector.h:234
T z() const
Definition: PV3DBase.h:64
Definition: DetId.h:18
iterator end()
Definition: OwnVector.h:239
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
void RPCSeedOverlapper::run ( void  )

Definition at line 51 of file RPCSeedOverlapper.cc.

References gather_cfg::cout.

51  {
52 
53  if(isConfigured == false || isIOset == false || isEventSetupset == false) {
54  cout << "Configuration or IO is not set yet" << endl;
55  return;
56  }
57  if(isCheckgoodOverlap == true)
59  if(isCheckcandidateOverlap == true)
61 }
std::vector< weightedTrajectorySeed > * candidateweightedSeedsRef
std::vector< weightedTrajectorySeed > * goodweightedSeedsRef
const edm::EventSetup * eSetup
tuple cout
Definition: gather_cfg.py:121
void CheckOverlap(const edm::EventSetup &iSetup, std::vector< weightedTrajectorySeed > *SeedsRef)
void RPCSeedOverlapper::setEventSetup ( const edm::EventSetup iSetup)

Definition at line 45 of file RPCSeedOverlapper.cc.

45  {
46 
47  eSetup = &iSetup;
48  isEventSetupset = true;
49 }
const edm::EventSetup * eSetup
void RPCSeedOverlapper::setIO ( std::vector< weightedTrajectorySeed > *  goodweightedRef,
std::vector< weightedTrajectorySeed > *  candidateweightedRef 
)

Definition at line 33 of file RPCSeedOverlapper.cc.

33  {
34 
35  goodweightedSeedsRef = goodweightedRef;
36  candidateweightedSeedsRef = candidateweightedRef;
37  isIOset = true;
38 }
std::vector< weightedTrajectorySeed > * candidateweightedSeedsRef
std::vector< weightedTrajectorySeed > * goodweightedSeedsRef
void RPCSeedOverlapper::unsetIO ( )

Definition at line 40 of file RPCSeedOverlapper.cc.

40  {
41 
42  isIOset = false;
43 }

Member Data Documentation

std::vector<weightedTrajectorySeed>* RPCSeedOverlapper::candidateweightedSeedsRef
private

Definition at line 46 of file RPCSeedOverlapper.h.

const edm::EventSetup* RPCSeedOverlapper::eSetup
private

Definition at line 47 of file RPCSeedOverlapper.h.

std::vector<weightedTrajectorySeed>* RPCSeedOverlapper::goodweightedSeedsRef
private

Definition at line 45 of file RPCSeedOverlapper.h.

bool RPCSeedOverlapper::isCheckcandidateOverlap
private

Definition at line 42 of file RPCSeedOverlapper.h.

bool RPCSeedOverlapper::isCheckgoodOverlap
private

Definition at line 41 of file RPCSeedOverlapper.h.

bool RPCSeedOverlapper::isConfigured
private

Definition at line 37 of file RPCSeedOverlapper.h.

bool RPCSeedOverlapper::isEventSetupset
private

Definition at line 39 of file RPCSeedOverlapper.h.

bool RPCSeedOverlapper::isIOset
private

Definition at line 38 of file RPCSeedOverlapper.h.

unsigned int RPCSeedOverlapper::ShareRecHitsNumberThreshold
private

Definition at line 43 of file RPCSeedOverlapper.h.