23 const std::string
metname =
"Muon|RecoMuon|MuonTrajectoryCleaner";
25 LogTrace(metname) <<
"Muon Trajectory Cleaner called" << endl;
27 TrajectoryContainer::iterator iter, jter;
28 Trajectory::DataContainer::const_iterator m1, m2;
30 if ( trajC.size() < 1 )
return;
32 LogTrace(metname) <<
"Number of trajectories in the container: " <<trajC.size()<< endl;
36 int nTot1DHits_i(0), nTot1DHits_j(0);
39 map<int, vector<int> > seedmap;
44 vector<bool> mask(trajC.size(),
true);
48 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
49 if ( !mask[
i] ) { i++;
continue; }
50 if ( !(*iter)->isValid() || (*iter)->empty() ) {mask[
i] =
false; i++;
continue; }
51 if(seedmap.count(i)==0) seedmap[i].push_back(i);
55 for ( jter = iter+1; jter != trajC.end(); jter++ ) {
56 if ( !mask[j] ) { j++;
continue; }
57 if(seedmap.count(j)==0) seedmap[j].push_back(j);
61 for( m1 = meas1.begin(); m1 != meas1.end(); m1++ ) {
64 else trhC1.push_back((*m1).recHit());
65 for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator trh1=trhC1.begin(); trh1!=trhC1.end(); ++trh1, ++nTot1DHits_i) {
67 for( m2 = meas2.begin(); m2 != meas2.end(); m2++ ) {
70 else trhC2.push_back((*m2).recHit());
71 for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator trh2=trhC2.begin(); trh2!=trhC2.end(); ++trh2, ++nTot1DHits_j) {
72 if( ( (*trh1)->globalPosition() - (*trh2)->globalPosition()).
mag() < 10
e-5 ) match++;
80 int nTotHits_i = (*iter)->measurements().size();
81 int nTotHits_j = (*jter)->measurements().size();
84 double chi2_dof_i = (*iter)->ndof() > 0 ? (*iter)->chiSquared()/(*iter)->ndof() : (*iter)->chiSquared()/1
e-10;
85 double chi2_dof_j = (*jter)->ndof() > 0 ? (*jter)->chiSquared()/(*jter)->ndof() : (*jter)->chiSquared()/1
e-10;
87 LogTrace(metname) <<
" MuonTrajectoryCleaner:";
88 LogTrace(metname) <<
" * trajC " << i
89 <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
90 <<
" GeV) - chi2/nDOF = " << (*iter)->chiSquared() <<
"/" << (*iter)->ndof() <<
" = " << chi2_dof_i;
91 LogTrace(metname) <<
" - valid RH = " << (*iter)->foundHits() <<
" / total RH = " << nTotHits_i <<
" / total 1D RH = " << nTot1DHits_i;
92 LogTrace(metname) <<
" * trajC " << j
93 <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
94 <<
" GeV) - chi2/nDOF = " << (*jter)->chiSquared() <<
"/" << (*jter)->ndof() <<
" = " << chi2_dof_j;
95 LogTrace(metname) <<
" - valid RH = " << (*jter)->foundHits() <<
" / total RH = " << nTotHits_j <<
" / total 1D RH = " << nTot1DHits_j;
98 int hit_diff = (*iter)->foundHits() - (*jter)->foundHits() ;
102 if (
abs(hit_diff) <= 4 ) {
107 double maxFraction = 0.95;
109 double fraction = (2.*
match)/((*iter)->measurements().size()+(*jter)->measurements().size());
113 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt) ++belowLimit;
114 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt) ++belowLimit;
116 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
117 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
120 if(fraction >= maxFraction && belowLimit == 1 && above == 1){
121 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <
minPt){
124 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
126 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
127 <<
" GeV) rejected because it has too low pt";
131 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
133 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
134 <<
" GeV) rejected because it has too low pt";
138 if (chi2_dof_i > chi2_dof_j) {
141 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
143 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
147 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
149 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
154 if ( hit_diff < 0 ) {
157 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
159 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
163 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
165 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
173 if(skipnext)
continue;
179 LogTrace(metname) <<
" Creating map between chosen seed and ghost seeds." << std::endl;
181 auto_ptr<L2SeedAssoc> seedToSeedsMap(
new L2SeedAssoc);
184 for(
map<
int, vector<int> >::iterator itmap=seedmap.begin(); itmap!=seedmap.end(); ++itmap, ++seedcnt) {
188 int tmpsize=(*itmap).second.size();
189 for(
int cnt=0; cnt!=tmpsize; ++cnt) {
192 seedToSeedsMap->insert(tmpL2SeedRef1, tmpL2SeedRef2);
196 event.put(seedToSeedsMap,
"");
201 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
203 result.push_back(*iter);
204 LogTrace(metname) <<
"Keep trajectory with pT = " << (*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV";
218 const std::string
metname =
"Muon|RecoMuon|MuonTrajectoryCleaner";
220 LogTrace(metname) <<
"Muon Trajectory Cleaner called" << endl;
222 if ( candC.size() < 2 )
return;
224 CandidateContainer::iterator iter, jter;
225 Trajectory::DataContainer::const_iterator m1, m2;
229 const float deltaPt = 1.0;
231 LogTrace(metname) <<
"Number of muon candidates in the container: " <<candC.size()<< endl;
240 vector<bool> mask(candC.size(),
true);
244 for ( iter = candC.begin(); iter != candC.end(); iter++ ) {
245 if ( !mask[
i] ) { i++;
continue; }
253 innerTSOS = (*iter)->trajectory()->firstMeasurement().updatedState();
256 innerTSOS = (*iter)->trajectory()->lastMeasurement().updatedState();
258 if ( !(innerTSOS.
isValid()) )
continue;
263 for ( jter = iter+1; jter != candC.end(); jter++ ) {
264 if ( !mask[j] ) { j++;
continue; }
268 for ( m1 = meas1.begin(); m1 != meas1.end(); m1++ ) {
269 for ( m2 = meas2.begin(); m2 != meas2.end(); m2++ ) {
270 if ( (*m1).recHit()->isValid() && (*m2).recHit()->isValid() )
271 if ( ( (*m1).recHit()->globalPosition() - (*m2).recHit()->globalPosition()).
mag()< 10
e-5 ) match++;
276 <<
" MuonTrajectoryCleaner: candC " << i <<
" chi2/nRH = "
277 << (*iter)->trajectory()->chiSquared() <<
"/" << (*iter)->trajectory()->foundHits() <<
278 " vs trajC " << j <<
" chi2/nRH = " << (*jter)->trajectory()->chiSquared() <<
279 "/" << (*jter)->trajectory()->foundHits() <<
" Shared RecHits: " <<
match;
283 innerTSOS2 = (*jter)->trajectory()->firstMeasurement().updatedState();
286 innerTSOS2 = (*jter)->trajectory()->lastMeasurement().updatedState();
288 if ( !(innerTSOS2.
isValid()) )
continue;
294 float deta(fabs(eta1-eta2));
296 float dpt(fabs(pt1-pt2));
297 if ( dpt < deltaPt && deta < deltaEta && dphi < deltaPhi ) {
300 <<
" MuonTrajectoryCleaner: candC " << i<<
" and "<<j<<
" direction matched: "
305 bool hitsMatch = ((match > 0) && ((match/((*iter)->trajectory()->foundHits()) > 0.25) || (match/((*jter)->trajectory()->foundHits()) > 0.25))) ?
true :
false;
307 ( ( (*iter)->trackerTrack() == (*jter)->trackerTrack() ) &&
308 ( deltaR<double>((*iter)->muonTrack()->eta(),(*iter)->muonTrack()->phi(), (*jter)->muonTrack()->eta(),(*jter)->muonTrack()->phi()) < 0.2) );
311 if ( ( tracksMatch ) || (hitsMatch > 0) ) {
312 if ( (*iter)->trajectory()->foundHits() == (*jter)->trajectory()->foundHits() ) {
313 if ( (*iter)->trajectory()->chiSquared() > (*jter)->trajectory()->chiSquared() ) {
317 else mask[
j] =
false;
320 if ( (*iter)->trajectory()->foundHits() < (*jter)->trajectory()->foundHits() ) {
324 else mask[
j] =
false;
331 if(skipnext)
continue;
335 for ( iter = candC.begin(); iter != candC.end(); iter++ ) {
337 result.push_back(*iter);
339 delete (*iter)->trajectory();
340 delete (*iter)->trackerTrajectory();
const std::string metname
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
edm::AssociationMap< edm::OneToMany< L2MuonTrajectorySeedCollection, L2MuonTrajectorySeedCollection > > L2SeedAssoc
static TransientTrackingRecHit::ConstRecHitContainer breakInSubRecHits(TransientTrackingRecHit::ConstRecHitPointer, int granularity)
takes a muon rechit and returns its sub-rechits given a certain granularity
void clean(TrajectoryContainer &muonTrajectories, edm::Event &evt)
Clean the trajectories container, erasing the (worst) clone trajectory.
std::vector< TrajectoryMeasurement > DataContainer
MuonCandidate::CandidateContainer CandidateContainer
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< ConstRecHitPointer > ConstRecHitContainer
MuonCandidate::TrajectoryContainer TrajectoryContainer
REF castTo() const
cast to a concrete type
GlobalVector globalMomentum() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.