CMS 3D CMS Logo

RPCSeedOverlapper.cc
Go to the documentation of this file.
1 
9 
10 using namespace std;
11 using namespace edm;
12 
14  isConfigured = false;
15  isIOset = false;
16  isEventSetupset = false;
17 }
18 
20 
22  isCheckgoodOverlap = iConfig.getParameter<bool>("isCheckgoodOverlap");
23  isCheckcandidateOverlap = iConfig.getParameter<bool>("isCheckcandidateOverlap");
24  ShareRecHitsNumberThreshold = iConfig.getParameter<unsigned int>("ShareRecHitsNumberThreshold");
25  isConfigured = true;
26 }
27 
28 void RPCSeedOverlapper::setIO(std::vector<weightedTrajectorySeed> *goodweightedRef,
29  std::vector<weightedTrajectorySeed> *candidateweightedRef) {
30  goodweightedSeedsRef = goodweightedRef;
31  candidateweightedSeedsRef = candidateweightedRef;
32  isIOset = true;
33 }
34 
35 void RPCSeedOverlapper::unsetIO() { isIOset = false; }
36 
38  eSetup = &iSetup;
39  isEventSetupset = true;
40 }
41 
43  if (isConfigured == false || isIOset == false || isEventSetupset == false) {
44  cout << "Configuration or IO is not set yet" << endl;
45  return;
46  }
47  if (isCheckgoodOverlap == true)
48  CheckOverlap(*eSetup, goodweightedSeedsRef);
49  if (isCheckcandidateOverlap == true)
50  CheckOverlap(*eSetup, candidateweightedSeedsRef);
51 }
52 
54  std::vector<weightedTrajectorySeed> *weightedSeedsRef) {
55  std::vector<weightedTrajectorySeed> sortweightedSeeds;
56  std::vector<weightedTrajectorySeed> tempweightedSeeds;
58 
59  edm::ESHandle<RPCGeometry> rpcGeometry;
60  iSetup.get<MuonGeometryRecord>().get(rpcGeometry);
61 
62  while (!weightedSeedsRef->empty()) {
63  cout << "Finding the weighted seeds group from " << weightedSeedsRef->size() << " seeds which share some recHits"
64  << endl;
65  // Take 1st seed in SeedsRef as referrence and find a collection which always share some recHits with some other
66  tempRecHits.clear();
67  tempweightedSeeds.clear();
68  int N = 0;
69  for (vector<weightedTrajectorySeed>::iterator itweightedseed = weightedSeedsRef->begin();
70  itweightedseed != weightedSeedsRef->end();
71  N++) {
72  TrajectorySeed::range RecHitsRange = itweightedseed->first.recHits();
73  if (N == 0) {
74  cout << "Always take the 1st weighted seed to be the referrence." << endl;
75  for (TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
76  cout << "Put its recHits to tempRecHits" << endl;
77  tempRecHits.push_back(it->clone());
78  }
79  cout << "Put it to tempweightedSeeds" << endl;
80  tempweightedSeeds.push_back(*itweightedseed);
81  cout << "Then erase from weightedSeedsRef->" << endl;
82  itweightedseed = weightedSeedsRef->erase(itweightedseed);
83  } else {
84  cout << "Come to other weighted seed for checking " << itweightedseed->first.nHits() << " recHits from "
85  << tempRecHits.size() << " temp recHits" << endl;
86  unsigned int ShareRecHitsNumber = 0;
87  for (TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
88  if (isShareHit(tempRecHits, *it, rpcGeometry))
89  ShareRecHitsNumber++;
90  }
91  if (ShareRecHitsNumber >= ShareRecHitsNumberThreshold) {
92  cout << "This seed is found to belong to current share group" << endl;
93  for (TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++) {
94  if (!isShareHit(tempRecHits, *it, rpcGeometry)) {
95  cout << "Put its extra recHits to tempRecHits" << endl;
96  tempRecHits.push_back(it->clone());
97  }
98  }
99  cout << "Put it to tempSeeds" << endl;
100  tempweightedSeeds.push_back(*itweightedseed);
101  cout << "Then erase from SeedsRef" << endl;
102  itweightedseed = weightedSeedsRef->erase(itweightedseed);
103  } else
104  itweightedseed++;
105  }
106  }
107  // Find the best weighted seed and kick out those share recHits with it
108  // The best weighted seed save in sortweightedSeeds, those don't share recHits with it will be push back to weightedSeedsRef for next while loop
109  weightedTrajectorySeed bestweightedSeed;
110  vector<weightedTrajectorySeed>::iterator bestweightediter;
111  // Find the min Spt wrt Pt as the best Seed
112  double Quality = 1000000;
113  unsigned NumberofHits = 0;
114  cout << "Find " << tempweightedSeeds.size() << " seeds into one trajectory group" << endl;
115  for (vector<weightedTrajectorySeed>::iterator itweightedseed = tempweightedSeeds.begin();
116  itweightedseed != tempweightedSeeds.end();
117  itweightedseed++) {
118  unsigned int nHits = itweightedseed->first.nHits();
119  //std::vector<float> seed_error = itweightedseed->first.startingState().errorMatrix();
120  //double Spt = seed_error[1];
121  double weightedQuality = itweightedseed->second;
122  cout << "Find a weighted seed with quality " << weightedQuality << endl;
123  if ((NumberofHits < nHits) || (NumberofHits == nHits && weightedQuality < Quality)) {
124  NumberofHits = nHits;
125  Quality = weightedQuality;
126  bestweightedSeed = *itweightedseed;
127  bestweightediter = itweightedseed;
128  }
129  }
130  cout << "Best good temp seed's quality is " << Quality << endl;
131  sortweightedSeeds.push_back(bestweightedSeed);
132  tempweightedSeeds.erase(bestweightediter);
133  tempRecHits.clear();
134 
135  for (TrajectorySeed::const_iterator it = bestweightedSeed.first.recHits().first;
136  it != bestweightedSeed.first.recHits().second;
137  it++)
138  tempRecHits.push_back(it->clone());
139 
140  for (vector<weightedTrajectorySeed>::iterator itweightedseed = tempweightedSeeds.begin();
141  itweightedseed != tempweightedSeeds.end();) {
142  cout << "Checking the temp weighted seed's " << itweightedseed->first.nHits() << " hits to " << tempRecHits.size()
143  << " temp recHits" << endl;
144  TrajectorySeed::range RecHitsRange = itweightedseed->first.recHits();
145  bool isShare = false;
146  for (TrajectorySeed::const_iterator it = RecHitsRange.first; it != RecHitsRange.second; it++)
147  if (isShareHit(tempRecHits, *it, rpcGeometry))
148  isShare = true;
149 
150  if (isShare == true) {
151  cout << "Find one temp seed share some recHits with best weighted seed" << endl;
152  itweightedseed = tempweightedSeeds.erase(itweightedseed);
153  } else {
154  cout << "This seed has no relation with best weighted seed" << endl;
155  weightedSeedsRef->push_back(*itweightedseed);
156  itweightedseed = tempweightedSeeds.erase(itweightedseed);
157  }
158  }
159  }
160  // At the end exchange SeedsRef with sortSeeds
161  weightedSeedsRef->clear();
162  *weightedSeedsRef = sortweightedSeeds;
163 }
164 
166  const TrackingRecHit &hit,
167  edm::ESHandle<RPCGeometry> rpcGeometry) {
168  bool istheSame = false;
169  unsigned int n = 1;
170  cout << "Checking from " << RecHits.size() << " temp recHits" << endl;
171 
172  LocalPoint lpos1 = hit.localPosition();
173  DetId RPCId1 = hit.geographicalId();
174  const GeomDetUnit *rpcroll1 = rpcGeometry->idToDetUnit(RPCId1);
175  GlobalPoint gpos1 = rpcroll1->toGlobal(lpos1);
176  cout << "The hit's position: " << gpos1.x() << ", " << gpos1.y() << ", " << gpos1.z() << endl;
177  for (edm::OwnVector<TrackingRecHit>::const_iterator it = RecHits.begin(); it != RecHits.end(); it++, n++) {
178  cout << "Checking the " << n << " th recHit from tempRecHits" << endl;
179  LocalPoint lpos2 = it->localPosition();
180  DetId RPCId2 = it->geographicalId();
181  const GeomDetUnit *rpcroll2 = rpcGeometry->idToDetUnit(RPCId2);
182  GlobalPoint gpos2 = rpcroll2->toGlobal(lpos2);
183  cout << "The temp hit's position: " << gpos2.x() << ", " << gpos2.y() << ", " << gpos2.z() << endl;
184 
185  if ((gpos1.x() == gpos2.x()) && (gpos1.y() == gpos2.y()) && (gpos1.z() == gpos2.z())) {
186  cout << "This hit is found to be the same" << endl;
187  istheSame = true;
188  }
189  }
190  return istheSame;
191 }
RPCSeedOverlapper::CheckOverlap
void CheckOverlap(const edm::EventSetup &iSetup, std::vector< weightedTrajectorySeed > *SeedsRef)
Definition: RPCSeedOverlapper.cc:53
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
GeomDet
Definition: GeomDet.h:27
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrajectorySeed::const_iterator
recHitContainer::const_iterator const_iterator
Definition: TrajectorySeed.h:20
RPCSeedOverlapper::~RPCSeedOverlapper
~RPCSeedOverlapper()
Definition: RPCSeedOverlapper.cc:19
RPCGeometry::idToDetUnit
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: RPCGeometry.cc:30
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle< RPCGeometry >
N
#define N
Definition: blowfish.cc:9
Point3DBase< float, LocalTag >
RPCSeedOverlapper::weightedTrajectorySeed
RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed
Definition: RPCSeedOverlapper.h:21
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
edm::ParameterSet
Definition: ParameterSet.h:36
RPCSeedOverlapper::configure
void configure(const edm::ParameterSet &iConfig)
Definition: RPCSeedOverlapper.cc:21
RPCSeedOverlapper::isShareHit
bool isShareHit(const edm::OwnVector< TrackingRecHit > &RecHits, const TrackingRecHit &hit, edm::ESHandle< RPCGeometry > rpcGeometry)
Definition: RPCSeedOverlapper.cc:165
RPCSeedOverlapper::RPCSeedOverlapper
RPCSeedOverlapper()
Definition: RPCSeedOverlapper.cc:13
RPCSeedOverlapper::setEventSetup
void setEventSetup(const edm::EventSetup &iSetup)
Definition: RPCSeedOverlapper.cc:37
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
TrackingRecHit
Definition: TrackingRecHit.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
GeomDet.h
std
Definition: JetResolutionObject.h:76
RPCSeedOverlapper::run
void run()
Definition: RPCSeedOverlapper.cc:42
RPCSeedOverlapper::unsetIO
void unsetIO()
Definition: RPCSeedOverlapper.cc:35
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
RPCSeedOverlapper.h
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
MuonGeometryRecord.h
RPCSeedOverlapper::setIO
void setIO(std::vector< weightedTrajectorySeed > *goodweightedRef, std::vector< weightedTrajectorySeed > *candidateweightedRef)
Definition: RPCSeedOverlapper.cc:28
g4TestOverlap_cfg.CheckOverlap
CheckOverlap
Definition: g4TestOverlap_cfg.py:12
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
edm::OwnVector::clear
void clear()
Definition: OwnVector.h:481
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
ecaldqm::Quality
Quality
Definition: DBWriterWorkers.cc:55