#include <RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h>
Definition at line 38 of file GlobalMuonRefitter.h.
typedef MuonTransientTrackingRecHit::ConstMuonRecHitContainer GlobalMuonRefitter::ConstMuonRecHitContainer |
Definition at line 50 of file GlobalMuonRefitter.h.
typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer GlobalMuonRefitter::ConstMuonRecHitPointer |
Definition at line 48 of file GlobalMuonRefitter.h.
Definition at line 43 of file GlobalMuonRefitter.h.
Definition at line 45 of file GlobalMuonRefitter.h.
Definition at line 49 of file GlobalMuonRefitter.h.
Definition at line 47 of file GlobalMuonRefitter.h.
Definition at line 42 of file GlobalMuonRefitter.h.
Definition at line 44 of file GlobalMuonRefitter.h.
typedef std::vector<Trajectory> GlobalMuonRefitter::TC |
Definition at line 52 of file GlobalMuonRefitter.h.
typedef TC::const_iterator GlobalMuonRefitter::TI |
Definition at line 53 of file GlobalMuonRefitter.h.
enum GlobalMuonRefitter::RefitDirection [protected] |
Reimplemented from TrackTransformer.
Definition at line 71 of file GlobalMuonRefitter.h.
00071 {inToOut,outToIn,undetermined};
GlobalMuonRefitter::GlobalMuonRefitter | ( | const edm::ParameterSet & | par, | |
const MuonServiceProxy * | service | |||
) |
constructor with Parameter Set and MuonServiceProxy
Definition at line 68 of file GlobalMuonRefitter.cc.
References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), theCategory, theCSCChi2Cut, theDTChi2Cut, theHitThreshold, theLayerMeasurements, and theRPCChi2Cut.
00069 : 00070 TrackTransformer(par), 00071 theService(service) { 00072 00073 theCategory = par.getUntrackedParameter<string>("Category", "Muon|RecoMuon|GlobalMuon|GlobalMuonRefitter"); 00074 00075 theLayerMeasurements = new MuonDetLayerMeasurements(par.getParameter<InputTag>("DTRecSegmentLabel"), 00076 par.getParameter<InputTag>("CSCRecSegmentLabel"), 00077 par.getParameter<InputTag>("RPCRecSegmentLabel")); 00078 00079 theHitThreshold = par.getParameter<int>("HitThreshold"); 00080 theDTChi2Cut = par.getParameter<double>("Chi2CutDT"); 00081 theCSCChi2Cut = par.getParameter<double>("Chi2CutCSC"); 00082 theRPCChi2Cut = par.getParameter<double>("Chi2CutRPC"); 00083 00084 }
GlobalMuonRefitter::~GlobalMuonRefitter | ( | ) | [virtual] |
destructor
Definition at line 90 of file GlobalMuonRefitter.cc.
References theLayerMeasurements.
00090 { 00091 00092 if (theLayerMeasurements) delete theLayerMeasurements; 00093 00094 }
void GlobalMuonRefitter::checkMuonHits | ( | const reco::Track & | muon, | |
ConstRecHitContainer & | all, | |||
ConstRecHitContainer & | first, | |||
std::vector< int > & | hits | |||
) | const [protected] |
check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit
Definition at line 175 of file GlobalMuonRefitter.cc.
References alongMomentum, MuonSubdetId::CSC, MuonSubdetId::DT, lat::endl(), i, LogTrace, muonGeometry::mag(), DetId::Muon, DetId::rawId(), MuonDetLayerMeasurements::recHits(), MuonSubdetId::RPC, RPCDetId::station(), DTChamberId::station(), CSCDetId::station(), theCategory, theLayerMeasurements, and theService.
Referenced by refit().
00178 { 00179 00180 LogTrace(theCategory) << " GlobalMuonRefitter::checkMuonHits " << endl; 00181 00182 int dethits[4]; 00183 for ( int i=0; i<4; i++ ) hits[i]=dethits[i]=0; 00184 00185 // MuonTransientTrackingRecHitBuilder muonRecHitBuilder(theService->trackingGeometry()); 00186 00187 // ConstRecHitContainer muonRecHits = muonRecHitBuilder.build(muon.recHitsBegin(),muon.recHitsEnd()); 00188 00189 // loop through all muon hits and calculate the maximum # of hits in each chamber 00190 for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) { 00191 // for (trackingRecHit_iterator imrh = muon.recHitsBegin(); imrh != muon.recHitsEnd(); imrh++ ) { 00192 // for (ConstRecHitContainer::const_iterator imrh = muonRecHits.begin(); imrh != muonRecHits.end(); imrh++ ) { 00193 00194 if ( (*imrh != 0 ) && !(*imrh)->isValid() ) continue; 00195 00196 int station = 0; 00197 int detRecHits = 0; 00198 00199 DetId id = (*imrh)->geographicalId(); 00200 00201 // Skip tracker hits 00202 if (id.det()!=DetId::Muon) continue; 00203 00204 const DetLayer* layer = theService->detLayerGeometry()->idToLayer(id); 00205 00206 MuonRecHitContainer dRecHits = theLayerMeasurements->recHits(layer); 00207 00208 // get station of hit if it is in DT 00209 if ( id.subdetId() == MuonSubdetId::DT ) { 00210 DTChamberId did(id.rawId()); 00211 station = did.station(); 00212 float coneSize = 10.0; 00213 00214 bool hitUnique = false; 00215 ConstRecHitContainer all2dRecHits; 00216 for (MuonRecHitContainer::const_iterator ir = dRecHits.begin(); ir != dRecHits.end(); ir++ ) { 00217 if ( (**ir).dimension() == 2 ) { 00218 hitUnique = true; 00219 if ( all2dRecHits.size() > 0 ) { 00220 for (ConstRecHitContainer::const_iterator iir = all2dRecHits.begin(); iir != all2dRecHits.end(); iir++ ) 00221 if (((*iir)->localPosition()-(*ir)->localPosition()).mag()<0.01) hitUnique = false; 00222 } //end of if ( all2dRecHits.size() > 0 ) 00223 if ( hitUnique ) all2dRecHits.push_back((*ir).get()); //FIXME!! 00224 } else { 00225 ConstRecHitContainer sRecHits = (**ir).transientHits(); 00226 for (ConstRecHitContainer::const_iterator iir = sRecHits.begin(); iir != sRecHits.end(); iir++ ) { 00227 if ( (*iir)->dimension() == 2 ) { 00228 hitUnique = true; 00229 if ( !all2dRecHits.empty() ) { 00230 for (ConstRecHitContainer::const_iterator iiir = all2dRecHits.begin(); iiir != all2dRecHits.end(); iiir++ ) 00231 if (((*iiir)->localPosition()-(*iir)->localPosition()).mag()<0.01) hitUnique = false; 00232 }//end of if ( all2dRecHits.size() > 0 ) 00233 }//end of if ( (*iir).dimension() == 2 ) 00234 if ( hitUnique ) 00235 all2dRecHits.push_back(*iir); 00236 break; 00237 }//end of for sRecHits 00238 }// end of else 00239 }// end of for loop over dRecHits 00240 for (ConstRecHitContainer::const_iterator ir = all2dRecHits.begin(); ir != all2dRecHits.end(); ir++ ) { 00241 double rhitDistance = ((*ir)->localPosition()-(**imrh).localPosition()).mag(); 00242 if ( rhitDistance < coneSize ) detRecHits++; 00243 // LogTrace(theCategory) << " Station " << station << " DT "<<(*ir)->dimension()<<" " << (*ir)->localPosition() 00244 // << " Distance: "<< rhitDistance<<" recHits: "<< detRecHits; 00245 }// end of for all2dRecHits 00246 }// end of if DT 00247 // get station of hit if it is in CSC 00248 else if ( id.subdetId() == MuonSubdetId::CSC ) { 00249 CSCDetId did(id.rawId()); 00250 station = did.station(); 00251 00252 float coneSize = 10.0; 00253 00254 for (MuonRecHitContainer::const_iterator ir = dRecHits.begin(); ir != dRecHits.end(); ir++ ) { 00255 double rhitDistance = ((**ir).localPosition()-(**imrh).localPosition()).mag(); 00256 if ( rhitDistance < coneSize ) detRecHits++; 00257 // LogTrace(theCategory) << " Station " << station << " CSC "<<(**ir).dimension()<<" "<<(**ir).localPosition() 00258 // << " Distance: "<< rhitDistance<<" recHits: "<<detRecHits; 00259 } 00260 } 00261 // get station of hit if it is in RPC 00262 else if ( id.subdetId() == MuonSubdetId::RPC ) { 00263 RPCDetId rpcid(id.rawId()); 00264 station = rpcid.station(); 00265 float coneSize = 100.0; 00266 for (MuonRecHitContainer::const_iterator ir = dRecHits.begin(); ir != dRecHits.end(); ir++ ) { 00267 double rhitDistance = ((**ir).localPosition()-(**imrh).localPosition()).mag(); 00268 if ( rhitDistance < coneSize ) detRecHits++; 00269 // LogTrace(theCategory)<<" Station "<<station<<" RPC "<<(**ir).dimension()<<" "<< (**ir).localPosition() 00270 // <<" Distance: "<<rhitDistance<<" recHits: "<<detRecHits; 00271 } 00272 } 00273 else { 00274 LogError(theCategory)<<" Wrong Hit Type "; 00275 continue; 00276 } 00277 00278 if ( (station > 0) && (station < 5) ) { 00279 int detHits = dRecHits.size(); 00280 dethits[station-1] += detHits; 00281 if ( detRecHits > hits[station-1] ) hits[station-1] = detRecHits; 00282 } 00283 00284 // all.push_back((*imrh).get()); //FIXME: may need fast assignment on above 00285 00286 } // end of loop over muon rechits 00287 00288 for ( int i = 0; i < 4; i++ ) { 00289 LogTrace(theCategory) <<"Station "<<i+1<<": "<<hits[i]<<" "<<dethits[i] <<endl; 00290 } 00291 00292 // 00293 // check order of muon measurements 00294 // 00295 LogTrace(theCategory) << "CheckMuonHits: "<<all.size(); 00296 00297 if ( (all.size() > 1) && 00298 ( all.front()->globalPosition().mag() > 00299 all.back()->globalPosition().mag() ) ) { 00300 LogTrace(theCategory)<< "reverse order: "; 00301 stable_sort(all.begin(),all.end(),RecHitLessByDet(alongMomentum)); 00302 } 00303 00304 int station1 = -999; 00305 int station2 = -999; 00306 for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ihit++ ) { 00307 00308 if ( !(*ihit)->isValid() ) continue; 00309 station1 = -999; station2 = -999; 00310 // store muon hits one at a time. 00311 first.push_back(*ihit); 00312 DetId id = (*ihit)->geographicalId(); 00313 00314 // Skip tracker hits 00315 if (id.det()!=DetId::Muon) continue; 00316 00317 ConstMuonRecHitPointer immrh = dynamic_cast<const MuonTransientTrackingRecHit*>((*ihit).get()); //FIXME 00318 00319 // get station of 1st hit if it is in DT 00320 if ( (*immrh).isDT() ) { 00321 DTChamberId did(id.rawId()); 00322 station1 = did.station(); 00323 } 00324 // otherwise get station of 1st hit if it is in CSC 00325 else if ( (*immrh).isCSC() ) { 00326 CSCDetId did(id.rawId()); 00327 station1 = did.station(); 00328 } 00329 // check next RecHit 00330 ConstRecHitContainer::const_iterator nexthit(ihit); 00331 nexthit++; 00332 00333 if ( ( nexthit != all.end()) && (*nexthit)->isValid() ) { 00334 00335 ConstMuonRecHitPointer immrh2 = dynamic_cast<const MuonTransientTrackingRecHit*>((*nexthit).get()); 00336 DetId id2 = immrh2->geographicalId(); 00337 00338 // get station of 1st hit if it is in DT 00339 if ( (*immrh2).isDT() ) { 00340 DTChamberId did2(id2.rawId()); 00341 station2 = did2.station(); 00342 } 00343 // otherwise get station of 1st hit if it is in CSC 00344 else if ( (*immrh2).isCSC() ) { 00345 CSCDetId did2(id2.rawId()); 00346 station2 = did2.station(); 00347 } 00348 00349 // 1st hit is in station 1 and second hit is in a different station 00350 // or an rpc (if station = -999 it could be an rpc hit) 00351 if ( (station1 != -999) && ((station2 == -999) || (station2 > station1)) ) { 00352 LogTrace(theCategory) << " station 1 = "<<station1 00353 <<", r = "<< (*ihit)->globalPosition().perp() 00354 <<", z = "<< (*ihit)->globalPosition().z() << ", "; 00355 00356 LogTrace(theCategory) << " station 2 = " << station2 00357 <<", r = "<<(*(nexthit))->globalPosition().perp() 00358 <<", z = "<<(*(nexthit))->globalPosition().z() << ", "; 00359 return; 00360 } 00361 } 00362 else if ( (nexthit == all.end()) && (station1 != -999) ) { 00363 LogTrace(theCategory) << " station 1 = "<< station1 00364 << ", r = " << (*ihit)->globalPosition().perp() 00365 << ", z = " << (*ihit)->globalPosition().z() << ", "; 00366 return; 00367 } 00368 } 00369 // if none of the above is satisfied, return blank vector. 00370 first.clear(); 00371 00372 return; 00373 00374 }
RefitDirection GlobalMuonRefitter::checkRecHitsOrdering | ( | const ConstRecHitContainer & | ) | const [protected] |
void GlobalMuonRefitter::printHits | ( | const ConstRecHitContainer & | hits | ) | const [protected] |
print all RecHits of a trajectory
Definition at line 461 of file GlobalMuonRefitter.cc.
References LogTrace, funct::sqrt(), theCategory, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
00461 { 00462 00463 00464 LogTrace(theCategory) << "Used RecHits: " << hits.size(); 00465 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) { 00466 if ( !(*ir)->isValid() ) { 00467 LogTrace(theCategory) << "invalid RecHit"; 00468 continue; 00469 } 00470 00471 const GlobalPoint& pos = (*ir)->globalPosition(); 00472 00473 LogTrace(theCategory) 00474 << "r = " << sqrt(pos.x() * pos.x() + pos.y() * pos.y()) 00475 << " z = " << pos.z() 00476 << " dimension = " << (*ir)->dimension() 00477 << " " << (*ir)->det()->geographicalId().det() 00478 << " " << (*ir)->det()->subDetector(); 00479 } 00480 00481 }
vector< Trajectory > GlobalMuonRefitter::refit | ( | const reco::Track & | globalTrack, | |
const int | theMuonHitsOption | |||
) | const |
build combined trajectory from sta Track and tracker RecHits
Definition at line 109 of file GlobalMuonRefitter.cc.
References checkMuonHits(), lat::endl(), TrackTransformer::getTransientRecHits(), LogTrace, TrackTransformer::magneticField(), reco::TrackBase::pt(), selectMuonHits(), theCategory, track, TrackTransformer::trackingGeometry(), and TrackTransformer::transform().
Referenced by TevMuonProducer::produce().
00109 { 00110 00111 // MuonHitsOption: 0 - tracker only 00112 // 1 - include all muon hits 00113 // 2 - include only first muon hit(s) 00114 // 3 - include only selected muon hits 00115 00116 vector<int> stationHits(4,0); 00117 00118 ConstRecHitContainer allRecHits; // all muon rechits 00119 ConstRecHitContainer fmsRecHits; // only first muon rechits 00120 ConstRecHitContainer selectedRecHits; // selected muon rechits 00121 00122 LogTrace(theCategory) << " *** GlobalMuonRefitter *** " << endl; 00123 00124 LogTrace(theCategory) << " Track momentum before refit: " << globalTrack.pt() << endl; 00125 00126 reco::TransientTrack track(globalTrack,magneticField(),trackingGeometry()); 00127 00128 allRecHits = getTransientRecHits(track); 00129 00130 LogTrace(theCategory) << " Hits size: " << allRecHits.size() << endl; 00131 00132 // check and select muon measurements and 00133 // measure occupancy in muon stations 00134 checkMuonHits(globalTrack, allRecHits, fmsRecHits, stationHits); 00135 00136 // full track with all muon hits 00137 vector <Trajectory> globalTraj = transform(globalTrack, track, allRecHits); 00138 00139 if (!globalTraj.size()) { 00140 LogTrace(theCategory) << "No trajectory from the TrackTransformer!" << endl; 00141 return vector<Trajectory>(); 00142 } 00143 00144 LogTrace(theCategory) << " Initial trajectory state: " << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl; 00145 00146 // printHits(allRecHits); 00147 00148 vector <Trajectory> outputTraj; 00149 00150 if (theMuonHitsOption == 1 ) 00151 outputTraj.push_back(globalTraj.front()); 00152 00153 if (theMuonHitsOption == 2 ) 00154 outputTraj = transform(globalTrack, track, fmsRecHits); 00155 00156 if (theMuonHitsOption == 3 ) { 00157 selectedRecHits = selectMuonHits(globalTraj.front(),stationHits); 00158 LogTrace(theCategory) << " Selected hits size: " << selectedRecHits.size() << endl; 00159 outputTraj = transform(globalTrack, track, selectedRecHits); 00160 } 00161 00162 if (outputTraj.size()) { 00163 LogTrace(theCategory) << "Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp(); 00164 return outputTraj; 00165 } else { 00166 LogTrace(theCategory) << "No refitted Tracks... " << endl; 00167 return vector<Trajectory>(); 00168 } 00169 00170 }
GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::selectMuonHits | ( | const Trajectory & | traj, | |
const std::vector< int > & | hits | |||
) | const [protected] |
select muon hits compatible with trajectory; check hits in chambers with showers
Definition at line 382 of file GlobalMuonRefitter.cc.
References lat::endl(), keep, LogTrace, Trajectory::measurements(), DetId::Muon, RPCDetId::station(), DTChamberId::station(), CSCDetId::station(), theCategory, theCSCChi2Cut, theDTChi2Cut, theHitThreshold, theRPCChi2Cut, and dimuonsSequences_cff::threshold.
Referenced by refit().
00383 { 00384 00385 ConstRecHitContainer muonRecHits; 00386 const double globalChi2Cut = 200.0; 00387 00388 vector<TrajectoryMeasurement> muonMeasurements = traj.measurements(); 00389 00390 // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy 00391 for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) { 00392 00393 if ( !(*im).recHit()->isValid() ) continue; 00394 if ( (*im).recHit()->det()->geographicalId().det() != DetId::Muon ) { 00395 // if ( ( chi2ndf < globalChi2Cut ) ) 00396 muonRecHits.push_back((*im).recHit()); 00397 continue; 00398 } 00399 ConstMuonRecHitPointer immrh = dynamic_cast<const MuonTransientTrackingRecHit*>((*im).recHit().get()); 00400 00401 DetId id = immrh->geographicalId(); 00402 int station = 0; 00403 int threshold = 0; 00404 double chi2Cut = 0.0; 00405 00406 // get station of hit if it is in DT 00407 if ( (*immrh).isDT() ) { 00408 DTChamberId did(id.rawId()); 00409 station = did.station(); 00410 threshold = theHitThreshold; 00411 chi2Cut = theDTChi2Cut; 00412 } 00413 // get station of hit if it is in CSC 00414 else if ( (*immrh).isCSC() ) { 00415 CSCDetId did(id.rawId()); 00416 station = did.station(); 00417 threshold = theHitThreshold; 00418 chi2Cut = theCSCChi2Cut; 00419 } 00420 // get station of hit if it is in RPC 00421 else if ( (*immrh).isRPC() ) { 00422 RPCDetId rpcid(id.rawId()); 00423 station = rpcid.station(); 00424 threshold = theHitThreshold; 00425 chi2Cut = theRPCChi2Cut; 00426 } 00427 else { 00428 continue; 00429 } 00430 00431 double chi2ndf = (*im).estimate()/(*im).recHit()->dimension(); 00432 00433 bool keep = true; 00434 if ( (station > 0) && (station < 5) ) { 00435 if ( hits[station-1] > threshold ) keep = false; 00436 } 00437 00438 if ( (keep || ( chi2ndf < chi2Cut )) && ( chi2ndf < globalChi2Cut ) ) { 00439 muonRecHits.push_back((*im).recHit()); 00440 } else { 00441 LogTrace(theCategory) 00442 << "Skip hit: " << id.det() << " " << station << ", " 00443 << chi2ndf << " (" << chi2Cut << " chi2 threshold) " 00444 << hits[station-1] << endl; 00445 } 00446 00447 } 00448 00449 // 00450 // check order of rechits 00451 // 00452 reverse(muonRecHits.begin(),muonRecHits.end()); 00453 return muonRecHits; 00454 00455 }
const MuonServiceProxy* GlobalMuonRefitter::service | ( | ) | const [inline, protected] |
Definition at line 87 of file GlobalMuonRefitter.h.
References theService.
00087 { return theService; }
void GlobalMuonRefitter::setEvent | ( | const edm::Event & | event | ) | [virtual] |
pass the Event to the algo at each event
Definition at line 99 of file GlobalMuonRefitter.cc.
References MuonDetLayerMeasurements::setEvent(), TrackTransformer::setServices(), theEvent, theLayerMeasurements, and theService.
Referenced by TevMuonProducer::produce().
00099 { 00100 00101 theEvent = &event; 00102 theLayerMeasurements->setEvent(event); 00103 setServices(theService->eventSetup()); 00104 }
std::string GlobalMuonRefitter::theCategory [protected] |
Definition at line 90 of file GlobalMuonRefitter.h.
Referenced by checkMuonHits(), GlobalMuonRefitter(), printHits(), refit(), and selectMuonHits().
float GlobalMuonRefitter::theCSCChi2Cut [private] |
Definition at line 104 of file GlobalMuonRefitter.h.
Referenced by GlobalMuonRefitter(), and selectMuonHits().
float GlobalMuonRefitter::theDTChi2Cut [private] |
Definition at line 103 of file GlobalMuonRefitter.h.
Referenced by GlobalMuonRefitter(), and selectMuonHits().
const edm::Event* GlobalMuonRefitter::theEvent [private] |
int GlobalMuonRefitter::theHitThreshold [private] |
Definition at line 102 of file GlobalMuonRefitter.h.
Referenced by GlobalMuonRefitter(), and selectMuonHits().
Definition at line 96 of file GlobalMuonRefitter.h.
Referenced by checkMuonHits(), GlobalMuonRefitter(), setEvent(), and ~GlobalMuonRefitter().
int GlobalMuonRefitter::theMuonHitsOption [private] |
Definition at line 100 of file GlobalMuonRefitter.h.
float GlobalMuonRefitter::theProbCut [private] |
Definition at line 101 of file GlobalMuonRefitter.h.
float GlobalMuonRefitter::thePtCut [protected] |
Definition at line 92 of file GlobalMuonRefitter.h.
float GlobalMuonRefitter::theRPCChi2Cut [private] |
Definition at line 105 of file GlobalMuonRefitter.h.
Referenced by GlobalMuonRefitter(), and selectMuonHits().
const MuonServiceProxy* GlobalMuonRefitter::theService [private] |
Definition at line 97 of file GlobalMuonRefitter.h.
Referenced by checkMuonHits(), service(), and setEvent().
bool GlobalMuonRefitter::theTkTrajsAvailableFlag [protected] |
Definition at line 91 of file GlobalMuonRefitter.h.
Definition at line 98 of file GlobalMuonRefitter.h.