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

Destructor.

Definition at line 90 of file CSCTimingExtractor.cc.

References theMatcher, and theService.

91 {
92  if (theService) delete theService;
93  if (theMatcher) delete theMatcher;
94 }
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 103 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(), MuonServiceProxy::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().

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