CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &, edm::ConsumesCollector &iC)
 Constructor. More...
 
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_
 
MuonServiceProxytheService
 
double theStripError_
 
double theStripTimeOffset_
 
double theWireError_
 
double theWireTimeOffset_
 
bool UseStripTime
 
bool UseWireTime
 

Detailed Description

Extracts timing information associated to a muon track

Description: <one line="" class="" summary>="">

Definition at line 54 of file CSCTimingExtractor.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 69 of file CSCTimingExtractor.cc.

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

70  :
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 {
80  edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
81  theService = new MuonServiceProxy(serviceParameters);
82 
83  edm::ParameterSet matchParameters = iConfig.getParameter<edm::ParameterSet>("MatchParameters");
84 
85  theMatcher = new MuonSegmentMatcher(matchParameters, iC);
86 }
T getParameter(std::string const &) const
MuonSegmentMatcher * theMatcher
MuonServiceProxy * theService
CSCTimingExtractor::~CSCTimingExtractor ( )

Destructor.

Definition at line 89 of file CSCTimingExtractor.cc.

References theMatcher, and theService.

90 {
91  if (theService) delete theService;
92  if (theMatcher) delete theMatcher;
93 }
MuonSegmentMatcher * theMatcher
MuonServiceProxy * theService

Member Function Documentation

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

Definition at line 102 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(), edm::ESHandle< class >::product(), Propagator::propagateWithPath(), HLT_25ns14e33_v1_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, TimeMeasurementSequence::weightInvbeta, CSCTimingExtractor::TimeMeasurement::weightInvbeta, TimeMeasurementSequence::weightVertex, and CSCTimingExtractor::TimeMeasurement::weightVertex.

Referenced by MuonTimingFiller::fillTiming().

103 {
104 
105  if (debug)
106  std::cout << " *** CSC Timimng Extractor ***" << std::endl;
107 
108  theService->update(iSetup);
109 
110  const GlobalTrackingGeometry *theTrackingGeometry = &*theService->trackingGeometry();
111 
113  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator);
114  const Propagator *propag = propagator.product();
115 
116  double invbeta=0;
117  double invbetaerr=0;
118  double totalWeightInvbeta=0;
119  double totalWeightVertex=0;
120  std::vector<TimeMeasurement> tms;
121 
122  math::XYZPoint pos=muonTrack->innerPosition();
123  math::XYZVector mom=muonTrack->innerMomentum();
124 
125  if (sqrt(muonTrack->innerPosition().mag2()) > sqrt(muonTrack->outerPosition().mag2())){
126  pos=muonTrack->outerPosition();
127  mom=-1*muonTrack->outerMomentum();
128  }
129 
130  GlobalPoint posp(pos.x(), pos.y(), pos.z());
131  GlobalVector momv(mom.x(), mom.y(), mom.z());
132  FreeTrajectoryState muonFTS(posp, momv, (TrackCharge)muonTrack->charge(), theService->magneticField().product());
133 
134  // get the CSC segments that were used to construct the muon
135  std::vector<const CSCSegment*> range = theMatcher->matchCSC(*muonTrack,iEvent);
136 
137  // create a collection on TimeMeasurements for the track
138  for (std::vector<const CSCSegment*>::iterator rechit = range.begin(); rechit!=range.end();++rechit) {
139 
140  // Create the ChamberId
141  DetId id = (*rechit)->geographicalId();
142  CSCDetId chamberId(id.rawId());
143  // int station = chamberId.station();
144 
145  if (!(*rechit)->specificRecHits().size()) continue;
146 
147  const std::vector<CSCRecHit2D> hits2d = (*rechit)->specificRecHits();
148 
149  // store all the hits from the segment
150  for (std::vector<CSCRecHit2D>::const_iterator hiti=hits2d.begin(); hiti!=hits2d.end(); hiti++) {
151 
152  const GeomDet* cscDet = theTrackingGeometry->idToDet(hiti->geographicalId());
153  TimeMeasurement thisHit;
154 
155  std::pair< TrajectoryStateOnSurface, double> tsos;
156  tsos=propag->propagateWithPath(muonFTS,cscDet->surface());
157 
158  double dist;
159  if (tsos.first.isValid()) dist = tsos.second+posp.mag();
160  else dist = cscDet->toGlobal(hiti->localPosition()).mag();
161 
162  thisHit.distIP = dist;
163  if (UseStripTime) {
164  thisHit.weightInvbeta = dist*dist/(theStripError_*theStripError_*30.*30.);
165  thisHit.weightVertex = 1./(theStripError_*theStripError_);
166  thisHit.timeCorr = hiti->tpeak()-theStripTimeOffset_;
167  tms.push_back(thisHit);
168  }
169 
170  if (UseWireTime) {
171  thisHit.weightInvbeta = dist*dist/(theWireError_*theWireError_*30.*30.);
172  thisHit.weightVertex = 1./(theWireError_*theWireError_);
173  thisHit.timeCorr = hiti->wireTime()-theWireTimeOffset_;
174  tms.push_back(thisHit);
175  }
176 
177 
178 // std::cout << " CSC Hit. Dist= " << dist << " Time= " << thisHit.timeCorr
179 // << " invBeta= " << (1.+thisHit.timeCorr/dist*30.) << std::endl;
180  }
181 
182  } // rechit
183 
184  bool modified = false;
185  std::vector <double> dstnc, dsegm, dtraj, hitWeightInvbeta, hitWeightVertex;
186 
187  // Now loop over the measurements, calculate 1/beta and cut away outliers
188  do {
189 
190  modified = false;
191  dstnc.clear();
192  dsegm.clear();
193  dtraj.clear();
194  hitWeightInvbeta.clear();
195  hitWeightVertex.clear();
196 
197  totalWeightInvbeta=0;
198  totalWeightVertex=0;
199 
200  for (std::vector<TimeMeasurement>::iterator tm=tms.begin(); tm!=tms.end(); ++tm) {
201  dstnc.push_back(tm->distIP);
202  dsegm.push_back(tm->timeCorr);
203  hitWeightInvbeta.push_back(tm->weightInvbeta);
204  hitWeightVertex.push_back(tm->weightVertex);
205  totalWeightInvbeta+=tm->weightInvbeta;
206  totalWeightVertex+=tm->weightVertex;
207  }
208 
209  if (totalWeightInvbeta==0) break;
210 
211  // calculate the value and error of 1/beta from the complete set of 1D hits
212  if (debug)
213  std::cout << " Points for global fit: " << dstnc.size() << std::endl;
214 
215  // inverse beta - weighted average of the contributions from individual hits
216  invbeta=0;
217  for (unsigned int i=0;i<dstnc.size();i++)
218  invbeta+=(1.+dsegm.at(i)/dstnc.at(i)*30.)*hitWeightInvbeta.at(i)/totalWeightInvbeta;
219 
220  double chimax=0.;
221  std::vector<TimeMeasurement>::iterator tmmax;
222 
223  // the dispersion of inverse beta
224  double diff;
225  for (unsigned int i=0;i<dstnc.size();i++) {
226  diff=(1.+dsegm.at(i)/dstnc.at(i)*30.)-invbeta;
227  diff=diff*diff*hitWeightInvbeta.at(i);
228  invbetaerr+=diff;
229  if (diff>chimax) {
230  tmmax=tms.begin()+i;
231  chimax=diff;
232  }
233  }
234 
235  invbetaerr=sqrt(invbetaerr/totalWeightInvbeta);
236 
237  // cut away the outliers
238  if (chimax>thePruneCut_) {
239  tms.erase(tmmax);
240  modified=true;
241  }
242 
243  if (debug)
244  std::cout << " Measured 1/beta: " << invbeta << " +/- " << invbetaerr << std::endl;
245 
246  } while (modified);
247 
248  // std::cout << " *** FINAL Measured 1/beta: " << invbeta << " +/- " << invbetaerr << std::endl;
249 
250  for (unsigned int i=0;i<dstnc.size();i++) {
251  tmSequence.dstnc.push_back(dstnc.at(i));
252  tmSequence.local_t0.push_back(dsegm.at(i));
253  tmSequence.weightInvbeta.push_back(hitWeightInvbeta.at(i));
254  tmSequence.weightVertex.push_back(hitWeightVertex.at(i));
255  }
256 
257  tmSequence.totalWeightInvbeta=totalWeightInvbeta;
258  tmSequence.totalWeightVertex=totalWeightVertex;
259 
260 }
void update(const edm::EventSetup &setup)
update the services each event
int i
Definition: DBlmapReader.cc:9
std::vector< double > local_t0
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
edm::ESHandle< MagneticField > magneticField() const
get the magnetic field
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
int TrackCharge
Definition: TrackCharge.h:4
virtual const GeomDet * idToDet(DetId) const
MuonSegmentMatcher * theMatcher
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< double > weightInvbeta
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Definition: Propagator.cc:15
Definition: DetId.h:18
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
MuonServiceProxy * theService
tuple cout
Definition: gather_cfg.py:121
std::vector< double > dstnc
std::vector< double > weightVertex

Member Data Documentation

edm::InputTag CSCTimingExtractor::CSCSegmentTags_
private

Definition at line 77 of file CSCTimingExtractor.h.

bool CSCTimingExtractor::debug
private

Definition at line 86 of file CSCTimingExtractor.h.

Referenced by fillTiming().

unsigned int CSCTimingExtractor::theHitsMin_
private

Definition at line 78 of file CSCTimingExtractor.h.

MuonSegmentMatcher* CSCTimingExtractor::theMatcher
private

Definition at line 90 of file CSCTimingExtractor.h.

Referenced by CSCTimingExtractor(), fillTiming(), and ~CSCTimingExtractor().

double CSCTimingExtractor::thePruneCut_
private

Definition at line 79 of file CSCTimingExtractor.h.

Referenced by fillTiming().

MuonServiceProxy* CSCTimingExtractor::theService
private

Definition at line 88 of file CSCTimingExtractor.h.

Referenced by CSCTimingExtractor(), fillTiming(), and ~CSCTimingExtractor().

double CSCTimingExtractor::theStripError_
private

Definition at line 82 of file CSCTimingExtractor.h.

Referenced by fillTiming().

double CSCTimingExtractor::theStripTimeOffset_
private

Definition at line 80 of file CSCTimingExtractor.h.

Referenced by fillTiming().

double CSCTimingExtractor::theWireError_
private

Definition at line 83 of file CSCTimingExtractor.h.

Referenced by fillTiming().

double CSCTimingExtractor::theWireTimeOffset_
private

Definition at line 81 of file CSCTimingExtractor.h.

Referenced by fillTiming().

bool CSCTimingExtractor::UseStripTime
private

Definition at line 85 of file CSCTimingExtractor.h.

Referenced by fillTiming().

bool CSCTimingExtractor::UseWireTime
private

Definition at line 84 of file CSCTimingExtractor.h.

Referenced by fillTiming().