Clean the trajectories container, erasing the (worst) clone trajectory.
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;
34 int nTot1DHits_i(0), nTot1DHits_j(0);
37 map<int, vector<int> > seedmap;
42 vector<bool> mask(trajC.size(),
true);
46 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
47 if ( !mask[
i] ) { i++;
continue; }
48 if ( !(*iter)->isValid() || (*iter)->empty() ) {mask[
i] =
false; i++;
continue; }
49 if(seedmap.count(i)==0) seedmap[i].push_back(i);
53 for ( jter = iter+1; jter != trajC.end(); jter++ ) {
54 if ( !mask[
j] ) { j++;
continue; }
55 if(seedmap.count(j)==0) seedmap[j].push_back(j);
59 for( m1 = meas1.begin(); m1 != meas1.end(); m1++ ) {
62 else trhC1.push_back((*m1).recHit());
63 for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator trh1=trhC1.begin(); trh1!=trhC1.end(); ++trh1, ++nTot1DHits_i) {
65 for( m2 = meas2.begin(); m2 != meas2.end(); m2++ ) {
68 else trhC2.push_back((*m2).recHit());
69 for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator trh2=trhC2.begin(); trh2!=trhC2.end(); ++trh2, ++nTot1DHits_j) {
70 if( ( (*trh1)->globalPosition() - (*trh2)->globalPosition()).
mag() < 10
e-5 )
match++;
78 int nTotHits_i = (*iter)->measurements().size();
79 int nTotHits_j = (*jter)->measurements().size();
82 double chi2_dof_i = (*iter)->ndof() > 0 ? (*iter)->chiSquared()/(*iter)->ndof() : (*iter)->chiSquared()/1
e-10;
83 double chi2_dof_j = (*jter)->ndof() > 0 ? (*jter)->chiSquared()/(*jter)->ndof() : (*jter)->chiSquared()/1
e-10;
85 LogTrace(metname) <<
" MuonTrajectoryCleaner:";
86 LogTrace(metname) <<
" * trajC " << i
87 <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
88 <<
" GeV) - chi2/nDOF = " << (*iter)->chiSquared() <<
"/" << (*iter)->ndof() <<
" = " << chi2_dof_i;
89 LogTrace(metname) <<
" - valid RH = " << (*iter)->foundHits() <<
" / total RH = " << nTotHits_i <<
" / total 1D RH = " << nTot1DHits_i;
90 LogTrace(metname) <<
" * trajC " << j
91 <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
92 <<
" GeV) - chi2/nDOF = " << (*jter)->chiSquared() <<
"/" << (*jter)->ndof() <<
" = " << chi2_dof_j;
93 LogTrace(metname) <<
" - valid RH = " << (*jter)->foundHits() <<
" / total RH = " << nTotHits_j <<
" / total 1D RH = " << nTot1DHits_j;
96 int hit_diff = (*iter)->foundHits() - (*jter)->foundHits() ;
100 if (
abs(hit_diff) <= 4 ) {
105 double maxFraction = 0.95;
107 double fraction = (2.*
match)/((*iter)->measurements().size()+(*jter)->measurements().size());
111 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() <= minPt) ++belowLimit;
112 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() <= minPt) ++belowLimit;
114 if((*jter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
115 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() >= dPt) ++above;
118 if(fraction >= maxFraction && belowLimit == 1 && above == 1){
119 if((*iter)->lastMeasurement().updatedState().globalMomentum().perp() < minPt){
122 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
124 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp()
125 <<
" GeV) rejected because it has too low pt";
129 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
131 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp()
132 <<
" GeV) rejected because it has too low pt";
136 if (chi2_dof_i > chi2_dof_j) {
139 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
141 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
145 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
147 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
152 if ( hit_diff < 0 ) {
155 seedmap[
j].insert(seedmap[j].
end(), seedmap[i].
begin(), seedmap[i].
end());
157 LogTrace(metname) <<
"Trajectory # " << i <<
" (pT="<<(*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
161 seedmap[
i].insert(seedmap[i].
end(), seedmap[j].
begin(), seedmap[j].
end());
163 LogTrace(metname) <<
"Trajectory # " << j <<
" (pT="<<(*jter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV) rejected";
171 if(skipnext)
continue;
177 LogTrace(metname) <<
" Creating map between chosen seed and ghost seeds." << std::endl;
179 auto_ptr<L2SeedAssoc> seedToSeedsMap(
new L2SeedAssoc);
182 for(
map<
int, vector<int> >::iterator itmap=seedmap.begin(); itmap!=seedmap.end(); ++itmap, ++seedcnt) {
186 int tmpsize=(*itmap).second.size();
187 for(
int cnt=0; cnt!=tmpsize; ++cnt) {
190 seedToSeedsMap->insert(tmpL2SeedRef1, tmpL2SeedRef2);
194 event.put(seedToSeedsMap,
"");
199 for ( iter = trajC.begin(); iter != trajC.end(); iter++ ) {
201 result.push_back(*iter);
202 LogTrace(metname) <<
"Keep trajectory with pT = " << (*iter)->lastMeasurement().updatedState().globalMomentum().perp() <<
" GeV";
const std::string metname
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static TransientTrackingRecHit::ConstRecHitContainer breakInSubRecHits(TransientTrackingRecHit::ConstRecHitPointer, int granularity)
takes a muon rechit and returns its sub-rechits given a certain granularity
std::vector< TrajectoryMeasurement > DataContainer
Abs< T >::type abs(const T &t)
std::vector< ConstRecHitPointer > ConstRecHitContainer
MuonCandidate::TrajectoryContainer TrajectoryContainer
REF castTo() const
cast to a concrete type
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.