23 LogTrace(metname) <<
"Muon Trajectory Cleaner called" << endl;
25 TrajectoryContainer::iterator
iter, jter;
26 Trajectory::DataContainer::const_iterator m1, m2;
28 if ( trajC.size() < 1 )
return;
30 LogTrace(metname) <<
"Number of trajectories in the container: " <<trajC.size()<< endl;
36 map<int, vector<int> > seedmap;
41 vector<bool> mask(trajC.size(),
true);
45 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
46 if ( !mask[
i] ) { i++;
continue; }
47 if ( !(*iter)->isValid() || (*iter)->empty() ) {mask[
i] =
false; i++;
continue; }
48 if(seedmap.count(i)==0) seedmap[i].push_back(i);
52 for ( jter = iter+1; jter != trajC.end(); jter++ ) {
53 if ( !mask[j] ) { j++;
continue; }
54 if(seedmap.count(j)==0) seedmap[j].push_back(j);
57 for( m1 = meas1.begin(); m1 != meas1.end(); m1++ ) {
58 for( m2 = meas2.begin(); m2 != meas2.end(); m2++ ) {
59 if ( ( (*m1).recHit()->globalPosition() - (*m2).recHit()->globalPosition()).
mag()< 10
e-5 ) match++;
64 int nTotHits_i = (*iter)->measurements().size();
65 int nTotHits_j = (*jter)->measurements().size();
68 double chi2_dof_i = (*iter)->ndof() > 0 ? (*iter)->chiSquared()/(*iter)->ndof() : (*iter)->chiSquared()/1
e-10;
69 double chi2_dof_j = (*jter)->ndof() > 0 ? (*jter)->chiSquared()/(*jter)->ndof() : (*jter)->chiSquared()/1
e-10;
71 LogTrace(metname) <<
" MuonTrajectoryCleaner:";
72 LogTrace(metname) <<
" * trajC " << i
73 <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
74 <<
" GeV) - chi2/nDOF = " << (*iter)->chiSquared() <<
"/" << (*iter)->ndof() <<
" = " << chi2_dof_i;
75 LogTrace(metname) <<
" - valid RH = " << (*iter)->foundHits() <<
" / total RH = " << nTotHits_i;
76 LogTrace(metname) <<
" * trajC " << j
77 <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
78 <<
" GeV) - chi2/nDOF = " << (*jter)->chiSquared() <<
"/" << (*jter)->ndof() <<
" = " << chi2_dof_j;
79 LogTrace(metname) <<
" - valid RH = " << (*jter)->foundHits() <<
" / total RH = " << nTotHits_j;
82 int hit_diff = (*iter)->foundHits() - (*jter)->foundHits() ;
86 if (
abs(hit_diff) == 0 ) {
93 double fraction = (2.*
match)/((*iter)->measurements().size()+(*jter)->measurements().size());
97 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt) ++belowLimit;
98 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <=
minPt) ++belowLimit;
100 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
101 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
104 if(fraction >= maxFraction && belowLimit == 1 && above == 1){
105 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <
minPt){
108 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
110 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
111 <<
" GeV) rejected because it has too low pt";
115 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
117 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
118 <<
" GeV) rejected because it has too low pt";
122 if (chi2_dof_i > chi2_dof_j) {
125 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
127 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
131 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
133 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
138 if ( hit_diff < 0 ) {
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";
157 if(skipnext)
continue;
163 LogTrace(metname) <<
" Creating map between chosen seed and ghost seeds." << std::endl;
165 auto_ptr<L2SeedAssoc> seedToSeedsMap(
new L2SeedAssoc);
168 for(
map<
int, vector<int> >::iterator itmap=seedmap.begin(); itmap!=seedmap.end(); ++itmap, ++seedcnt) {
172 int tmpsize=(*itmap).second.size();
173 for(
int cnt=0; cnt!=tmpsize; ++cnt) {
176 seedToSeedsMap->insert(tmpL2SeedRef1, tmpL2SeedRef2);
180 event.put(seedToSeedsMap,
"");
185 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
187 result.push_back(*iter);
188 LogTrace(metname) <<
"Keep trajectory with pT = " << (*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV";
204 LogTrace(metname) <<
"Muon Trajectory Cleaner called" << endl;
206 if ( candC.size() < 2 )
return;
208 CandidateContainer::iterator
iter, jter;
209 Trajectory::DataContainer::const_iterator m1, m2;
213 const float deltaPt = 1.0;
215 LogTrace(metname) <<
"Number of muon candidates in the container: " <<candC.size()<< endl;
224 vector<bool> mask(candC.size(),
true);
228 for ( iter = candC.begin(); iter != candC.end(); iter++ ) {
229 if ( !mask[
i] ) { i++;
continue; }
237 innerTSOS = (*iter)->trajectory()->firstMeasurement().updatedState();
240 innerTSOS = (*iter)->trajectory()->lastMeasurement().updatedState();
242 if ( !(innerTSOS.
isValid()) )
continue;
247 for ( jter = iter+1; jter != candC.end(); jter++ ) {
248 if ( !mask[j] ) { j++;
continue; }
252 for ( m1 = meas1.begin(); m1 != meas1.end(); m1++ ) {
253 for ( m2 = meas2.begin(); m2 != meas2.end(); m2++ ) {
254 if ( (*m1).recHit()->isValid() && (*m2).recHit()->isValid() )
255 if ( ( (*m1).recHit()->globalPosition() - (*m2).recHit()->globalPosition()).
mag()< 10
e-5 ) match++;
260 <<
" MuonTrajectoryCleaner: candC " << i <<
" chi2/nRH = "
261 << (*iter)->trajectory()->chiSquared() <<
"/" << (*iter)->trajectory()->foundHits() <<
262 " vs trajC " << j <<
" chi2/nRH = " << (*jter)->trajectory()->chiSquared() <<
263 "/" << (*jter)->trajectory()->foundHits() <<
" Shared RecHits: " <<
match;
267 innerTSOS2 = (*jter)->trajectory()->firstMeasurement().updatedState();
270 innerTSOS2 = (*jter)->trajectory()->lastMeasurement().updatedState();
272 if ( !(innerTSOS2.
isValid()) )
continue;
278 float deta(fabs(eta1-eta2));
280 float dpt(fabs(pt1-pt2));
281 if ( dpt < deltaPt && deta < deltaEta && dphi < deltaPhi ) {
284 <<
" MuonTrajectoryCleaner: candC " << i<<
" and "<<j<<
" direction matched: "
289 bool hitsMatch = ((match > 0) && ((match/((*iter)->trajectory()->foundHits()) > 0.25) || (match/((*jter)->trajectory()->foundHits()) > 0.25))) ?
true :
false;
291 ( ( (*iter)->trackerTrack() == (*jter)->trackerTrack() ) &&
292 ( deltaR<double>((*iter)->muonTrack()->eta(),(*iter)->muonTrack()->phi(), (*jter)->muonTrack()->eta(),(*jter)->muonTrack()->phi()) < 0.2) );
295 if ( ( tracksMatch ) || (hitsMatch > 0) ) {
296 if ( (*iter)->trajectory()->foundHits() == (*jter)->trajectory()->foundHits() ) {
297 if ( (*iter)->trajectory()->chiSquared() > (*jter)->trajectory()->chiSquared() ) {
301 else mask[
j] =
false;
304 if ( (*iter)->trajectory()->foundHits() < (*jter)->trajectory()->foundHits() ) {
308 else mask[
j] =
false;
315 if(skipnext)
continue;
319 for ( iter = candC.begin(); iter != candC.end(); iter++ ) {
321 result.push_back(*iter);
323 delete (*iter)->trajectory();
324 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
void clean(TrajectoryContainer &muonTrajectories, edm::Event &evt)
Clean the trajectories container, erasing the (worst) clone trajectory.
std::vector< TrajectoryMeasurement > DataContainer
MuonCandidate::CandidateContainer CandidateContainer
Abs< T >::type abs(const T &t)
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
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.