#include <RecoMuon/MuonIdentification/src/CSCTimingExtractor.cc>
Classes | |
class | TimeMeasurement |
Public Member Functions | |
CSCTimingExtractor (const edm::ParameterSet &) | |
Constructor. | |
void | fillTiming (TimeMeasurementSequence &tmSequence, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup) |
~CSCTimingExtractor () | |
Destructor. | |
Private Attributes | |
edm::InputTag | CSCSegmentTags_ |
bool | debug |
unsigned int | theHitsMin_ |
MuonSegmentMatcher * | theMatcher |
double | thePruneCut_ |
MuonServiceProxy * | theService |
double | theStripError_ |
double | theStripTimeOffset_ |
double | theWireError_ |
double | theWireTimeOffset_ |
bool | UseStripTime |
bool | UseWireTime |
Extracts timing information associated to a muon track
Description: <one line="" class="" summary>="">
Definition at line 55 of file CSCTimingExtractor.h.
CSCTimingExtractor::CSCTimingExtractor | ( | const edm::ParameterSet & | iConfig | ) |
Constructor.
Definition at line 70 of file CSCTimingExtractor.cc.
References edm::ParameterSet::getParameter(), MuonSegmentMatcher_cff::MuonSegmentMatcher, MuonServiceProxy_cff::MuonServiceProxy, theMatcher, and theService.
: CSCSegmentTags_(iConfig.getParameter<edm::InputTag>("CSCsegments")), thePruneCut_(iConfig.getParameter<double>("PruneCut")), theStripTimeOffset_(iConfig.getParameter<double>("CSCStripTimeOffset")), theWireTimeOffset_(iConfig.getParameter<double>("CSCWireTimeOffset")), theStripError_(iConfig.getParameter<double>("CSCStripError")), theWireError_(iConfig.getParameter<double>("CSCWireError")), UseWireTime(iConfig.getParameter<bool>("UseWireTime")), UseStripTime(iConfig.getParameter<bool>("UseStripTime")), debug(iConfig.getParameter<bool>("debug")) { edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters"); theService = new MuonServiceProxy(serviceParameters); edm::ParameterSet matchParameters = iConfig.getParameter<edm::ParameterSet>("MatchParameters"); theMatcher = new MuonSegmentMatcher(matchParameters, theService); }
CSCTimingExtractor::~CSCTimingExtractor | ( | ) |
Destructor.
Definition at line 91 of file CSCTimingExtractor.cc.
References theMatcher, and theService.
{ if (theService) delete theService; if (theMatcher) delete theMatcher; }
void CSCTimingExtractor::fillTiming | ( | TimeMeasurementSequence & | tmSequence, |
reco::TrackRef | muonTrack, | ||
const edm::Event & | iEvent, | ||
const edm::EventSetup & | iSetup | ||
) |
Definition at line 104 of file CSCTimingExtractor.cc.
References gather_cfg::cout, debug, diffTreeTool::diff, CSCTimingExtractor::TimeMeasurement::distIP, TimeMeasurementSequence::dstnc, edm::EventSetup::get(), i, GlobalTrackingGeometry::idToDet(), TimeMeasurementSequence::local_t0, mag(), MuonServiceProxy::magneticField(), MuonSegmentMatcher::matchCSC(), pos, edm::ESHandle< T >::product(), Propagator::propagateWithPath(), LargeD0_PixelPairStep_cff::propagator, mathSSE::sqrt(), GeomDet::surface(), theMatcher, thePruneCut_, theService, theStripError_, theStripTimeOffset_, MuonServiceProxy::theTrackingGeometry, theWireError_, theWireTimeOffset_, CSCTimingExtractor::TimeMeasurement::timeCorr, GeomDet::toGlobal(), TimeMeasurementSequence::totalWeightInvbeta, TimeMeasurementSequence::totalWeightVertex, MuonServiceProxy::trackingGeometry(), MuonServiceProxy::update(), UseStripTime, UseWireTime, CSCTimingExtractor::TimeMeasurement::weightInvbeta, TimeMeasurementSequence::weightInvbeta, CSCTimingExtractor::TimeMeasurement::weightVertex, and TimeMeasurementSequence::weightVertex.
Referenced by MuonTimingFiller::fillTiming().
{ if (debug) std::cout << " *** CSC Timimng Extractor ***" << std::endl; theService->update(iSetup); const GlobalTrackingGeometry *theTrackingGeometry = &*theService->trackingGeometry(); edm::ESHandle<Propagator> propagator; iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator); const Propagator *propag = propagator.product(); double invbeta=0; double invbetaerr=0; double totalWeightInvbeta=0; double totalWeightVertex=0; std::vector<TimeMeasurement> tms; math::XYZPoint pos=muonTrack->innerPosition(); math::XYZVector mom=muonTrack->innerMomentum(); if (sqrt(muonTrack->innerPosition().mag2()) > sqrt(muonTrack->outerPosition().mag2())){ pos=muonTrack->outerPosition(); mom=-1*muonTrack->outerMomentum(); } GlobalPoint posp(pos.x(), pos.y(), pos.z()); GlobalVector momv(mom.x(), mom.y(), mom.z()); FreeTrajectoryState muonFTS(posp, momv, (TrackCharge)muonTrack->charge(), theService->magneticField().product()); // get the CSC segments that were used to construct the muon std::vector<const CSCSegment*> range = theMatcher->matchCSC(*muonTrack,iEvent); // create a collection on TimeMeasurements for the track for (std::vector<const CSCSegment*>::iterator rechit = range.begin(); rechit!=range.end();++rechit) { // Create the ChamberId DetId id = (*rechit)->geographicalId(); CSCDetId chamberId(id.rawId()); // int station = chamberId.station(); if (!(*rechit)->specificRecHits().size()) continue; const std::vector<CSCRecHit2D> hits2d = (*rechit)->specificRecHits(); // store all the hits from the segment for (std::vector<CSCRecHit2D>::const_iterator hiti=hits2d.begin(); hiti!=hits2d.end(); hiti++) { const GeomDet* cscDet = theTrackingGeometry->idToDet(hiti->geographicalId()); TimeMeasurement thisHit; std::pair< TrajectoryStateOnSurface, double> tsos; tsos=propag->propagateWithPath(muonFTS,cscDet->surface()); double dist; if (tsos.first.isValid()) dist = tsos.second+posp.mag(); else dist = cscDet->toGlobal(hiti->localPosition()).mag(); thisHit.distIP = dist; if (UseStripTime) { thisHit.weightInvbeta = dist*dist/(theStripError_*theStripError_*30.*30.); thisHit.weightVertex = 1./(theStripError_*theStripError_); thisHit.timeCorr = hiti->tpeak()-theStripTimeOffset_; tms.push_back(thisHit); } if (UseWireTime) { thisHit.weightInvbeta = dist*dist/(theWireError_*theWireError_*30.*30.); thisHit.weightVertex = 1./(theWireError_*theWireError_); thisHit.timeCorr = hiti->wireTime()-theWireTimeOffset_; tms.push_back(thisHit); } // std::cout << " CSC Hit. Dist= " << dist << " Time= " << thisHit.timeCorr // << " invBeta= " << (1.+thisHit.timeCorr/dist*30.) << std::endl; } } // rechit bool modified = false; std::vector <double> dstnc, dsegm, dtraj, hitWeightInvbeta, hitWeightVertex; // Now loop over the measurements, calculate 1/beta and cut away outliers do { modified = false; dstnc.clear(); dsegm.clear(); dtraj.clear(); hitWeightInvbeta.clear(); hitWeightVertex.clear(); totalWeightInvbeta=0; totalWeightVertex=0; for (std::vector<TimeMeasurement>::iterator tm=tms.begin(); tm!=tms.end(); ++tm) { dstnc.push_back(tm->distIP); dsegm.push_back(tm->timeCorr); hitWeightInvbeta.push_back(tm->weightInvbeta); hitWeightVertex.push_back(tm->weightVertex); totalWeightInvbeta+=tm->weightInvbeta; totalWeightVertex+=tm->weightVertex; } if (totalWeightInvbeta==0) break; // calculate the value and error of 1/beta from the complete set of 1D hits if (debug) std::cout << " Points for global fit: " << dstnc.size() << std::endl; // inverse beta - weighted average of the contributions from individual hits invbeta=0; for (unsigned int i=0;i<dstnc.size();i++) invbeta+=(1.+dsegm.at(i)/dstnc.at(i)*30.)*hitWeightInvbeta.at(i)/totalWeightInvbeta; double chimax=0.; std::vector<TimeMeasurement>::iterator tmmax; // the dispersion of inverse beta double diff; for (unsigned int i=0;i<dstnc.size();i++) { diff=(1.+dsegm.at(i)/dstnc.at(i)*30.)-invbeta; diff=diff*diff*hitWeightInvbeta.at(i); invbetaerr+=diff; if (diff>chimax) { tmmax=tms.begin()+i; chimax=diff; } } invbetaerr=sqrt(invbetaerr/totalWeightInvbeta); // cut away the outliers if (chimax>thePruneCut_) { tms.erase(tmmax); modified=true; } if (debug) std::cout << " Measured 1/beta: " << invbeta << " +/- " << invbetaerr << std::endl; } while (modified); // std::cout << " *** FINAL Measured 1/beta: " << invbeta << " +/- " << invbetaerr << std::endl; for (unsigned int i=0;i<dstnc.size();i++) { tmSequence.dstnc.push_back(dstnc.at(i)); tmSequence.local_t0.push_back(dsegm.at(i)); tmSequence.weightInvbeta.push_back(hitWeightInvbeta.at(i)); tmSequence.weightVertex.push_back(hitWeightVertex.at(i)); } tmSequence.totalWeightInvbeta=totalWeightInvbeta; tmSequence.totalWeightVertex=totalWeightVertex; }
Definition at line 78 of file CSCTimingExtractor.h.
bool CSCTimingExtractor::debug [private] |
Definition at line 87 of file CSCTimingExtractor.h.
Referenced by fillTiming().
unsigned int CSCTimingExtractor::theHitsMin_ [private] |
Definition at line 79 of file CSCTimingExtractor.h.
MuonSegmentMatcher* CSCTimingExtractor::theMatcher [private] |
Definition at line 91 of file CSCTimingExtractor.h.
Referenced by CSCTimingExtractor(), fillTiming(), and ~CSCTimingExtractor().
double CSCTimingExtractor::thePruneCut_ [private] |
Definition at line 80 of file CSCTimingExtractor.h.
Referenced by fillTiming().
MuonServiceProxy* CSCTimingExtractor::theService [private] |
Definition at line 89 of file CSCTimingExtractor.h.
Referenced by CSCTimingExtractor(), fillTiming(), and ~CSCTimingExtractor().
double CSCTimingExtractor::theStripError_ [private] |
Definition at line 83 of file CSCTimingExtractor.h.
Referenced by fillTiming().
double CSCTimingExtractor::theStripTimeOffset_ [private] |
Definition at line 81 of file CSCTimingExtractor.h.
Referenced by fillTiming().
double CSCTimingExtractor::theWireError_ [private] |
Definition at line 84 of file CSCTimingExtractor.h.
Referenced by fillTiming().
double CSCTimingExtractor::theWireTimeOffset_ [private] |
Definition at line 82 of file CSCTimingExtractor.h.
Referenced by fillTiming().
bool CSCTimingExtractor::UseStripTime [private] |
Definition at line 86 of file CSCTimingExtractor.h.
Referenced by fillTiming().
bool CSCTimingExtractor::UseWireTime [private] |
Definition at line 85 of file CSCTimingExtractor.h.
Referenced by fillTiming().