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")),
78 debug(iConfig.getParameter<
bool>(
"debug"))
81 theService = std::make_unique<MuonServiceProxy>(serviceParameters);
96 const std::vector<const CSCSegment*> &segments,
111 if (
sqrt(muonTrack->innerPosition().mag2()) >
sqrt(muonTrack->outerPosition().mag2())){
112 pos=muonTrack->outerPosition();
113 mom=-1*muonTrack->outerMomentum();
120 std::vector<TimeMeasurement> tms;
121 for (
const auto& rechit : segments) {
124 DetId id = rechit->geographicalId();
128 if (rechit->specificRecHits().empty())
continue;
130 const std::vector<CSCRecHit2D>& hits2d(rechit->specificRecHits());
133 for (
const auto& hiti : hits2d) {
135 const GeomDet* cscDet = theTrackingGeometry->
idToDet(hiti.geographicalId());
138 std::pair< TrajectoryStateOnSurface, double> tsos;
142 if (tsos.first.isValid()) dist = tsos.second+posp.mag();
143 else dist = cscDet->
toGlobal(hiti.localPosition()).
mag();
150 tms.push_back(thisHit);
157 tms.push_back(thisHit);
166 bool modified =
false;
167 std::vector <double> dstnc, local_t0, hitWeightInvbeta, hitWeightTimeVtx;
168 double totalWeightInvbeta=0;
169 double totalWeightTimeVtx=0;
177 hitWeightInvbeta.clear();
178 hitWeightTimeVtx.clear();
180 totalWeightInvbeta=0;
181 totalWeightTimeVtx=0;
183 for (
auto& tm : tms) {
184 dstnc.push_back(tm.distIP);
185 local_t0.push_back(tm.timeCorr);
186 hitWeightInvbeta.push_back(tm.weightInvbeta);
187 hitWeightTimeVtx.push_back(tm.weightTimeVtx);
188 totalWeightInvbeta+=tm.weightInvbeta;
189 totalWeightTimeVtx+=tm.weightTimeVtx;
192 if (totalWeightInvbeta==0)
break;
196 std::cout <<
" Points for global fit: " << dstnc.size() << std::endl;
198 double invbeta=0,invbetaErr=0;
199 double timeVtx=0,timeVtxErr=0;
201 for (
unsigned int i=0;
i<dstnc.size();
i++) {
202 invbeta+=(1.+local_t0.at(
i)/dstnc.at(
i)*30.)*hitWeightInvbeta.at(
i)/totalWeightInvbeta;
203 timeVtx+=local_t0.at(
i)*hitWeightTimeVtx.at(
i)/totalWeightTimeVtx;
207 std::vector<TimeMeasurement>::iterator tmmax;
210 double diff_ibeta,diff_tvtx;
211 for (
unsigned int i=0;
i<dstnc.size();
i++) {
212 diff_ibeta=(1.+local_t0.at(
i)/dstnc.at(
i)*30.)-invbeta;
213 diff_ibeta=diff_ibeta*diff_ibeta*hitWeightInvbeta.at(
i);
214 diff_tvtx=local_t0.at(
i)-timeVtx;
215 diff_tvtx=diff_tvtx*diff_tvtx*hitWeightTimeVtx.at(
i);
216 invbetaErr+=diff_ibeta;
217 timeVtxErr+=diff_tvtx;
221 if (diff_tvtx>chimax) {
234 double cf = 1./(dstnc.size()-1);
235 invbetaErr=
sqrt(invbetaErr/totalWeightInvbeta*cf);
236 timeVtxErr=
sqrt(timeVtxErr/totalWeightTimeVtx*cf);
237 std::cout <<
" Measured 1/beta: " << invbeta <<
" +/- " << invbetaErr << std::endl;
238 std::cout <<
" Measured time: " << timeVtx <<
" +/- " << timeVtxErr << std::endl;
243 for (
unsigned int i=0;
i<dstnc.size();
i++) {
244 tmSequence.
dstnc.push_back(dstnc.at(
i));
245 tmSequence.
local_t0.push_back(local_t0.at(
i));
262 std::cout <<
" *** CSC Timimng Extractor ***" << std::endl;
267 fillTiming(tmSequence, range, muonTrack, iEvent, iSetup);
T getParameter(std::string const &) const
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.
double totalWeightTimeVtx
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
const Plane & surface() const
The nominal surface of the GeomDet.
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
std::vector< double > weightInvbeta
double totalWeightInvbeta
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< double > weightTimeVtx
const GeomDet * idToDet(DetId) const override
std::vector< double > dstnc
T const * product() const