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 &)
 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 55 of file CSCTimingExtractor.h.

Constructor & Destructor Documentation

CSCTimingExtractor::CSCTimingExtractor ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 70 of file CSCTimingExtractor.cc.

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

71  :
72  CSCSegmentTags_(iConfig.getParameter<edm::InputTag>("CSCsegments")),
73  thePruneCut_(iConfig.getParameter<double>("PruneCut")),
74  theStripTimeOffset_(iConfig.getParameter<double>("CSCStripTimeOffset")),
75  theWireTimeOffset_(iConfig.getParameter<double>("CSCWireTimeOffset")),
76  theStripError_(iConfig.getParameter<double>("CSCStripError")),
77  theWireError_(iConfig.getParameter<double>("CSCWireError")),
78  UseWireTime(iConfig.getParameter<bool>("UseWireTime")),
79  UseStripTime(iConfig.getParameter<bool>("UseStripTime")),
80  debug(iConfig.getParameter<bool>("debug"))
81 {
82  edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
83  theService = new MuonServiceProxy(serviceParameters);
84 
85  edm::ParameterSet matchParameters = iConfig.getParameter<edm::ParameterSet>("MatchParameters");
86 
87  theMatcher = new MuonSegmentMatcher(matchParameters, theService);
88 }
T getParameter(std::string const &) const
edm::InputTag CSCSegmentTags_
MuonSegmentMatcher * theMatcher
MuonServiceProxy * theService
CSCTimingExtractor::~CSCTimingExtractor ( )

Destructor.

Definition at line 91 of file CSCTimingExtractor.cc.

References theMatcher, and theService.

92 {
93  if (theService) delete theService;
94  if (theMatcher) delete theMatcher;
95 }
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 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< class >::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, TimeMeasurementSequence::weightInvbeta, CSCTimingExtractor::TimeMeasurement::weightInvbeta, TimeMeasurementSequence::weightVertex, and CSCTimingExtractor::TimeMeasurement::weightVertex.

Referenced by MuonTimingFiller::fillTiming().

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