27 TrajectoryContainer::iterator iter, jter;
28 Trajectory::DataContainer::const_iterator m1,
m2;
33 LogTrace(
metname) <<
"Number of trajectories in the container: " << trajC.size() << endl;
39 map<int, vector<int> > seedmap;
44 vector<bool>
mask(trajC.size(),
true);
48 for (iter = trajC.begin(); iter != trajC.end(); iter++) {
53 if (!(*iter)->isValid() || (*iter)->empty()) {
58 if (seedmap.count(
i) == 0)
62 bool skipnext =
false;
63 for (jter = iter + 1; jter != trajC.end(); jter++) {
68 if (seedmap.count(
j) == 0)
72 for (m1 = meas1.begin(); m1 != meas1.end(); m1++) {
73 for (
m2 = meas2.begin();
m2 != meas2.end();
m2++) {
74 if (((*m1).recHit()->globalPosition() - (*m2).recHit()->globalPosition()).
mag() < 10
e-5)
80 double chi2_dof_i = (*iter)->ndof() > 0 ? (*iter)->chiSquared() / (*iter)->ndof() : (*iter)->chiSquared() / 1
e-10;
81 double chi2_dof_j = (*jter)->ndof() > 0 ? (*jter)->chiSquared() / (*jter)->ndof() : (*jter)->chiSquared() / 1
e-10;
85 <<
" (pT=" << (*iter)->lastMeasurement().updatedState().globalMomentum().perp()
86 <<
" GeV) - chi2/nDOF = " << (*iter)->chiSquared() <<
"/" << (*iter)->ndof() <<
" = " 89 <<
" / total RH = " << (*iter)->measurements().size();
91 <<
" (pT=" << (*jter)->lastMeasurement().updatedState().globalMomentum().perp()
92 <<
" GeV) - chi2/nDOF = " << (*jter)->chiSquared() <<
"/" << (*jter)->ndof() <<
" = " 95 <<
" / total RH = " << (*jter)->measurements().size();
98 int hit_diff = (*iter)->foundHits() - (*jter)->foundHits();
102 if (
abs(hit_diff) == 0) {
109 double fraction = (2. *
match) / ((*iter)->measurements().size() + (*jter)->measurements().size());
113 if ((*jter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt)
115 if ((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt)
118 if ((*jter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt)
120 if ((*iter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt)
124 if ((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <
minPt) {
127 seedmap[
j].insert(seedmap[
j].
end(), seedmap[
i].
begin(), seedmap[
i].
end());
130 <<
" (pT=" << (*iter)->lastMeasurement().updatedState().globalMomentum().perp()
131 <<
" GeV) rejected because it has too low pt";
134 seedmap[
i].insert(seedmap[
i].
end(), seedmap[
j].
begin(), seedmap[
j].
end());
137 <<
" (pT=" << (*jter)->lastMeasurement().updatedState().globalMomentum().perp()
138 <<
" GeV) rejected because it has too low pt";
141 if (chi2_dof_i > chi2_dof_j) {
144 seedmap[
j].insert(seedmap[
j].
end(), seedmap[
i].
begin(), seedmap[
i].
end());
147 <<
" (pT=" << (*iter)->lastMeasurement().updatedState().globalMomentum().perp()
151 seedmap[
i].insert(seedmap[
i].
end(), seedmap[
j].
begin(), seedmap[
j].
end());
154 <<
" (pT=" << (*jter)->lastMeasurement().updatedState().globalMomentum().perp()
162 seedmap[
j].insert(seedmap[
j].
end(), seedmap[
i].
begin(), seedmap[
i].
end());
165 <<
" (pT=" << (*iter)->lastMeasurement().updatedState().globalMomentum().perp()
169 seedmap[
i].insert(seedmap[
i].
end(), seedmap[
j].
begin(), seedmap[
j].
end());
172 <<
" (pT=" << (*jter)->lastMeasurement().updatedState().globalMomentum().perp()
188 LogTrace(
metname) <<
" Creating map between chosen seed and ghost seeds." << std::endl;
190 auto seedToSeedsMap = std::make_unique<L2SeedAssoc>();
191 if (!
seeds->empty()) {
194 event.get(ptr.
id(), seedsHandle);
195 seedToSeedsMap = std::make_unique<L2SeedAssoc>(seedsHandle, seedsHandle);
200 for (
map<
int, vector<int> >::iterator itmap = seedmap.begin(); itmap != seedmap.end(); ++itmap, ++seedcnt) {
205 int tmpsize = (*itmap).second.size();
206 for (
int cnt = 0; cnt != tmpsize; ++cnt) {
210 seedToSeedsMap->insert(tmpL2SeedRef1, tmpL2SeedRef2);
214 event.put(
std::move(seedToSeedsMap),
"");
221 for (iter = trajC.begin(); iter != trajC.end(); iter++) {
224 << (*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV";
241 if (candC.size() < 2)
244 CandidateContainer::iterator iter, jter;
245 Trajectory::DataContainer::const_iterator m1,
m2;
251 LogTrace(
metname) <<
"Number of muon candidates in the container: " << candC.size() << endl;
260 vector<bool>
mask(candC.size(),
true);
264 for (iter = candC.begin(); iter != candC.end(); iter++) {
271 bool skipnext =
false;
276 innerTSOS = (*iter)->trajectory()->firstMeasurement().updatedState();
278 innerTSOS = (*iter)->trajectory()->lastMeasurement().updatedState();
286 for (jter = iter + 1; jter != candC.end(); jter++) {
294 for (m1 = meas1.begin(); m1 != meas1.end(); m1++) {
295 for (
m2 = meas2.begin();
m2 != meas2.end();
m2++) {
296 if ((*m1).recHit()->isValid() && (*m2).recHit()->isValid())
297 if (((*m1).recHit()->globalPosition() - (*m2).recHit()->globalPosition()).
mag() < 10
e-5)
303 <<
" chi2/nRH = " << (*iter)->trajectory()->chiSquared() <<
"/" 304 << (*iter)->trajectory()->foundHits() <<
" vs trajC " <<
j 305 <<
" chi2/nRH = " << (*jter)->trajectory()->chiSquared() <<
"/" 306 << (*jter)->trajectory()->foundHits() <<
" Shared RecHits: " <<
match;
310 innerTSOS2 = (*jter)->trajectory()->firstMeasurement().updatedState();
312 innerTSOS2 = (*jter)->trajectory()->lastMeasurement().updatedState();
323 float dpt(fabs(
pt1 -
pt2));
327 <<
" direction matched: " << innerTSOS.
globalMomentum() <<
" and " 332 bool hitsMatch = ((
match > 0) && ((
match / ((*iter)->trajectory()->foundHits()) > 0.25) ||
333 (
match / ((*jter)->trajectory()->foundHits()) > 0.25)))
337 (((*iter)->trackerTrack() == (*jter)->trackerTrack()) && (deltaR<double>((*iter)->muonTrack()->eta(),
338 (*iter)->muonTrack()->phi(),
339 (*jter)->muonTrack()->eta(),
340 (*jter)->muonTrack()->phi()) < 0.2));
343 if ((tracksMatch) || (hitsMatch > 0)) {
344 if ((*iter)->trajectory()->foundHits() == (*jter)->trajectory()->foundHits()) {
345 if ((*iter)->trajectory()->chiSquared() > (*jter)->trajectory()->chiSquared()) {
351 if ((*iter)->trajectory()->foundHits() < (*jter)->trajectory()->foundHits()) {
370 for (iter = candC.begin(); iter != candC.end(); iter++) {
void clean(TrajectoryContainer &muonTrajectories, edm::Event &evt, const edm::Handle< edm::View< TrajectorySeed > > &seeds)
Clean the trajectories container, erasing the (worst) clone trajectory.
ProductID id() const
Accessor for product ID.
const std::string metname
Geom::Phi< T > phi() const
static const double deltaEta
edm::AssociationMap< edm::OneToMany< L2MuonTrajectorySeedCollection, L2MuonTrajectorySeedCollection > > L2SeedAssoc
std::vector< TrajectoryMeasurement > DataContainer
MuonCandidate::CandidateContainer CandidateContainer
Abs< T >::type abs(const T &t)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
MuonCandidate::TrajectoryContainer TrajectoryContainer
GlobalVector globalMomentum() const
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.