CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
CSCTimingExtractor Class Reference

#include <RecoMuon/MuonIdentification/src/CSCTimingExtractor.cc>

Classes

class  TimeMeasurement
 

Public Member Functions

 CSCTimingExtractor (const edm::ParameterSet &, MuonSegmentMatcher *segMatcher, edm::ConsumesCollector &)
 Constructor. More...
 
void fillTiming (TimeMeasurementSequence &tmSequence, const std::vector< const CSCSegment * > &segments, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void fillTiming (TimeMeasurementSequence &tmSequence, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~CSCTimingExtractor ()
 Destructor. More...
 

Private Attributes

edm::InputTag CSCSegmentTags_
 
bool debug
 
unsigned int theHitsMin_
 
MuonSegmentMatchertheMatcher
 
double thePruneCut_
 
std::unique_ptr< MuonServiceProxytheService
 
double theStripError_
 
double theStripTimeOffset_
 
double theWireError_
 
double theWireTimeOffset_
 
bool UseStripTime
 
bool UseWireTime
 

Detailed Description

Extracts timing information associated to a muon track

Description: Produce timing information for a muon track using CSC hits from segments used to build the track

Definition at line 54 of file CSCTimingExtractor.h.

Constructor & Destructor Documentation

◆ CSCTimingExtractor()

CSCTimingExtractor::CSCTimingExtractor ( const edm::ParameterSet iConfig,
MuonSegmentMatcher segMatcher,
edm::ConsumesCollector iC 
)

Constructor.

Definition at line 68 of file CSCTimingExtractor.cc.

71  : thePruneCut_(iConfig.getParameter<double>("PruneCut")),
72  theStripTimeOffset_(iConfig.getParameter<double>("CSCStripTimeOffset")),
73  theWireTimeOffset_(iConfig.getParameter<double>("CSCWireTimeOffset")),
74  theStripError_(iConfig.getParameter<double>("CSCStripError")),
75  theWireError_(iConfig.getParameter<double>("CSCWireError")),
76  UseWireTime(iConfig.getParameter<bool>("UseWireTime")),
77  UseStripTime(iConfig.getParameter<bool>("UseStripTime")),
78  debug(iConfig.getParameter<bool>("debug")) {
79  edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
80  theService = std::make_unique<MuonServiceProxy>(serviceParameters, edm::ConsumesCollector(iC));
81  theMatcher = segMatcher;
82 }

References edm::ParameterSet::getParameter(), theMatcher, and theService.

◆ ~CSCTimingExtractor()

CSCTimingExtractor::~CSCTimingExtractor ( )

Destructor.

Definition at line 84 of file CSCTimingExtractor.cc.

84 {}

Member Function Documentation

◆ fillTiming() [1/2]

void CSCTimingExtractor::fillTiming ( TimeMeasurementSequence tmSequence,
const std::vector< const CSCSegment * > &  segments,
reco::TrackRef  muonTrack,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 90 of file CSCTimingExtractor.cc.

94  {
95  theService->update(iSetup);
96 
97  const GlobalTrackingGeometry* theTrackingGeometry = &*theService->trackingGeometry();
98 
99  // get the propagator
101  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator);
102  const Propagator* propag = propagator.product();
103 
104  math::XYZPoint pos = muonTrack->innerPosition();
105  math::XYZVector mom = muonTrack->innerMomentum();
106  if (sqrt(muonTrack->innerPosition().mag2()) > sqrt(muonTrack->outerPosition().mag2())) {
107  pos = muonTrack->outerPosition();
108  mom = -1 * muonTrack->outerMomentum();
109  }
110  GlobalPoint posp(pos.x(), pos.y(), pos.z());
111  GlobalVector momv(mom.x(), mom.y(), mom.z());
112  FreeTrajectoryState muonFTS(posp, momv, (TrackCharge)muonTrack->charge(), theService->magneticField().product());
113 
114  // create a collection on TimeMeasurements for the track
115  std::vector<TimeMeasurement> tms;
116  for (const auto& rechit : segments) {
117  // Create the ChamberId
118  DetId id = rechit->geographicalId();
119  CSCDetId chamberId(id.rawId());
120  // int station = chamberId.station();
121 
122  if (rechit->specificRecHits().empty())
123  continue;
124 
125  const std::vector<CSCRecHit2D>& hits2d(rechit->specificRecHits());
126 
127  // store all the hits from the segment
128  for (const auto& hiti : hits2d) {
129  const GeomDet* cscDet = theTrackingGeometry->idToDet(hiti.geographicalId());
130  TimeMeasurement thisHit;
131 
132  std::pair<TrajectoryStateOnSurface, double> tsos;
133  tsos = propag->propagateWithPath(muonFTS, cscDet->surface());
134 
135  double dist;
136  if (tsos.first.isValid())
137  dist = tsos.second + posp.mag();
138  else
139  dist = cscDet->toGlobal(hiti.localPosition()).mag();
140 
141  thisHit.distIP = dist;
142  if (UseStripTime) {
143  thisHit.weightInvbeta = dist * dist / (theStripError_ * theStripError_ * 30. * 30.);
144  thisHit.weightTimeVtx = 1. / (theStripError_ * theStripError_);
145  thisHit.timeCorr = hiti.tpeak() - theStripTimeOffset_;
146  tms.push_back(thisHit);
147  }
148 
149  if (UseWireTime) {
150  thisHit.weightInvbeta = dist * dist / (theWireError_ * theWireError_ * 30. * 30.);
151  thisHit.weightTimeVtx = 1. / (theWireError_ * theWireError_);
152  thisHit.timeCorr = hiti.wireTime() - theWireTimeOffset_;
153  tms.push_back(thisHit);
154  }
155 
156  // std::cout << " CSC Hit. Dist= " << dist << " Time= " << thisHit.timeCorr
157  // << " invBeta= " << (1.+thisHit.timeCorr/dist*30.) << std::endl;
158  }
159 
160  } // rechit
161 
162  bool modified = false;
163  std::vector<double> dstnc, local_t0, hitWeightInvbeta, hitWeightTimeVtx;
164  double totalWeightInvbeta = 0;
165  double totalWeightTimeVtx = 0;
166 
167  // Now loop over the measurements, calculate 1/beta and cut away outliers
168  do {
169  modified = false;
170  dstnc.clear();
171  local_t0.clear();
172  hitWeightInvbeta.clear();
173  hitWeightTimeVtx.clear();
174 
175  totalWeightInvbeta = 0;
176  totalWeightTimeVtx = 0;
177 
178  for (auto& tm : tms) {
179  dstnc.push_back(tm.distIP);
180  local_t0.push_back(tm.timeCorr);
181  hitWeightInvbeta.push_back(tm.weightInvbeta);
182  hitWeightTimeVtx.push_back(tm.weightTimeVtx);
183  totalWeightInvbeta += tm.weightInvbeta;
184  totalWeightTimeVtx += tm.weightTimeVtx;
185  }
186 
187  if (totalWeightInvbeta == 0)
188  break;
189 
190  // calculate the value and error of 1/beta and timeVtx from the complete set of 1D hits
191  if (debug)
192  std::cout << " Points for global fit: " << dstnc.size() << std::endl;
193 
194  double invbeta = 0, invbetaErr = 0;
195  double timeVtx = 0, timeVtxErr = 0;
196 
197  for (unsigned int i = 0; i < dstnc.size(); i++) {
198  invbeta += (1. + local_t0.at(i) / dstnc.at(i) * 30.) * hitWeightInvbeta.at(i) / totalWeightInvbeta;
199  timeVtx += local_t0.at(i) * hitWeightTimeVtx.at(i) / totalWeightTimeVtx;
200  }
201 
202  double chimax = 0.;
203  std::vector<TimeMeasurement>::iterator tmmax;
204 
205  // Calculate the inv beta and time at vertex dispersion
206  double diff_ibeta, diff_tvtx;
207  for (unsigned int i = 0; i < dstnc.size(); i++) {
208  diff_ibeta = (1. + local_t0.at(i) / dstnc.at(i) * 30.) - invbeta;
209  diff_ibeta = diff_ibeta * diff_ibeta * hitWeightInvbeta.at(i);
210  diff_tvtx = local_t0.at(i) - timeVtx;
211  diff_tvtx = diff_tvtx * diff_tvtx * hitWeightTimeVtx.at(i);
212  invbetaErr += diff_ibeta;
213  timeVtxErr += diff_tvtx;
214 
215  // decide if we cut away time at vertex outliers or inverse beta outliers
216  // currently not configurable.
217  if (diff_tvtx > chimax) {
218  tmmax = tms.begin() + i;
219  chimax = diff_tvtx;
220  }
221  }
222 
223  // cut away the outliers
224  if (chimax > thePruneCut_) {
225  tms.erase(tmmax);
226  modified = true;
227  }
228 
229  if (debug) {
230  double cf = 1. / (dstnc.size() - 1);
231  invbetaErr = sqrt(invbetaErr / totalWeightInvbeta * cf);
232  timeVtxErr = sqrt(timeVtxErr / totalWeightTimeVtx * cf);
233  std::cout << " Measured 1/beta: " << invbeta << " +/- " << invbetaErr << std::endl;
234  std::cout << " Measured time: " << timeVtx << " +/- " << timeVtxErr << std::endl;
235  }
236 
237  } while (modified);
238 
239  for (unsigned int i = 0; i < dstnc.size(); i++) {
240  tmSequence.dstnc.push_back(dstnc.at(i));
241  tmSequence.local_t0.push_back(local_t0.at(i));
242  tmSequence.weightInvbeta.push_back(hitWeightInvbeta.at(i));
243  tmSequence.weightTimeVtx.push_back(hitWeightTimeVtx.at(i));
244  }
245 
246  tmSequence.totalWeightInvbeta = totalWeightInvbeta;
247  tmSequence.totalWeightTimeVtx = totalWeightTimeVtx;
248 }

References gather_cfg::cout, debug, CSCTimingExtractor::TimeMeasurement::distIP, TimeMeasurementSequence::dstnc, edm::EventSetup::get(), get, mps_fire::i, GlobalTrackingGeometry::idToDet(), TimeMeasurementSequence::local_t0, mag(), Propagator::propagateWithPath(), TrackCandidateProducer_cfi::propagator, mathSSE::sqrt(), GeomDet::surface(), thePruneCut_, theService, theStripError_, theStripTimeOffset_, MuonServiceProxy::theTrackingGeometry, theWireError_, theWireTimeOffset_, CSCTimingExtractor::TimeMeasurement::timeCorr, GeomDet::toGlobal(), TimeMeasurementSequence::totalWeightInvbeta, TimeMeasurementSequence::totalWeightTimeVtx, UseStripTime, UseWireTime, TimeMeasurementSequence::weightInvbeta, CSCTimingExtractor::TimeMeasurement::weightInvbeta, TimeMeasurementSequence::weightTimeVtx, and CSCTimingExtractor::TimeMeasurement::weightTimeVtx.

Referenced by fillTiming().

◆ fillTiming() [2/2]

void CSCTimingExtractor::fillTiming ( TimeMeasurementSequence tmSequence,
reco::TrackRef  muonTrack,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 251 of file CSCTimingExtractor.cc.

254  {
255  if (debug)
256  std::cout << " *** CSC Timimng Extractor ***" << std::endl;
257 
258  // get the CSC segments that were used to construct the muon
259  std::vector<const CSCSegment*> range = theMatcher->matchCSC(*muonTrack, iEvent);
260 
261  fillTiming(tmSequence, range, muonTrack, iEvent, iSetup);
262 }

References gather_cfg::cout, debug, fillTiming(), iEvent, MuonSegmentMatcher::matchCSC(), FastTimerService_cff::range, and theMatcher.

Member Data Documentation

◆ CSCSegmentTags_

edm::InputTag CSCTimingExtractor::CSCSegmentTags_
private

Definition at line 82 of file CSCTimingExtractor.h.

◆ debug

bool CSCTimingExtractor::debug
private

◆ theHitsMin_

unsigned int CSCTimingExtractor::theHitsMin_
private

Definition at line 83 of file CSCTimingExtractor.h.

◆ theMatcher

MuonSegmentMatcher* CSCTimingExtractor::theMatcher
private

Definition at line 94 of file CSCTimingExtractor.h.

Referenced by CSCTimingExtractor(), and fillTiming().

◆ thePruneCut_

double CSCTimingExtractor::thePruneCut_
private

Definition at line 84 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ theService

std::unique_ptr<MuonServiceProxy> CSCTimingExtractor::theService
private

Definition at line 93 of file CSCTimingExtractor.h.

Referenced by CSCTimingExtractor(), and fillTiming().

◆ theStripError_

double CSCTimingExtractor::theStripError_
private

Definition at line 87 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ theStripTimeOffset_

double CSCTimingExtractor::theStripTimeOffset_
private

Definition at line 85 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ theWireError_

double CSCTimingExtractor::theWireError_
private

Definition at line 88 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ theWireTimeOffset_

double CSCTimingExtractor::theWireTimeOffset_
private

Definition at line 86 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ UseStripTime

bool CSCTimingExtractor::UseStripTime
private

Definition at line 90 of file CSCTimingExtractor.h.

Referenced by fillTiming().

◆ UseWireTime

bool CSCTimingExtractor::UseWireTime
private

Definition at line 89 of file CSCTimingExtractor.h.

Referenced by fillTiming().

Vector3DBase
Definition: Vector3DBase.h:8
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:355
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
GeomDet
Definition: GeomDet.h:27
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
CSCTimingExtractor::fillTiming
void fillTiming(TimeMeasurementSequence &tmSequence, const std::vector< const CSCSegment * > &segments, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: CSCTimingExtractor.cc:90
CSCTimingExtractor::thePruneCut_
double thePruneCut_
Definition: CSCTimingExtractor.h:84
TimeMeasurementSequence::local_t0
std::vector< double > local_t0
Definition: TimeMeasurementSequence.h:18
MuonSegmentMatcher::matchCSC
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
Definition: MuonSegmentMatcher.cc:237
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
CSCTimingExtractor::theStripTimeOffset_
double theStripTimeOffset_
Definition: CSCTimingExtractor.h:85
TimeMeasurementSequence::totalWeightTimeVtx
double totalWeightTimeVtx
Definition: TimeMeasurementSequence.h:23
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
GlobalTrackingGeometry
Definition: GlobalTrackingGeometry.h:20
CSCTimingExtractor::UseWireTime
bool UseWireTime
Definition: CSCTimingExtractor.h:89
CSCTimingExtractor::theWireError_
double theWireError_
Definition: CSCTimingExtractor.h:88
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< Propagator >
Point3DBase< float, GlobalTag >
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TimeMeasurementSequence::totalWeightInvbeta
double totalWeightInvbeta
Definition: TimeMeasurementSequence.h:22
CSCTimingExtractor::theStripError_
double theStripError_
Definition: CSCTimingExtractor.h:87
CSCDetId
Definition: CSCDetId.h:26
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
TimeMeasurementSequence::weightTimeVtx
std::vector< double > weightTimeVtx
Definition: TimeMeasurementSequence.h:19
TimeMeasurementSequence::weightInvbeta
std::vector< double > weightInvbeta
Definition: TimeMeasurementSequence.h:20
get
#define get
CSCTimingExtractor::UseStripTime
bool UseStripTime
Definition: CSCTimingExtractor.h:90
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
Propagator::propagateWithPath
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Definition: Propagator.cc:10
CSCTimingExtractor::debug
bool debug
Definition: CSCTimingExtractor.h:91
TimeMeasurementSequence::dstnc
std::vector< double > dstnc
Definition: TimeMeasurementSequence.h:17
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
CSCTimingExtractor::theService
std::unique_ptr< MuonServiceProxy > theService
Definition: CSCTimingExtractor.h:93
CSCTimingExtractor::theWireTimeOffset_
double theWireTimeOffset_
Definition: CSCTimingExtractor.h:86
CSCTimingExtractor::theMatcher
MuonSegmentMatcher * theMatcher
Definition: CSCTimingExtractor.h:94
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12