68 : thePruneCut_(iConfig.getParameter<double>(
"PruneCut")),
69 theStripTimeOffset_(iConfig.getParameter<double>(
"CSCStripTimeOffset")),
70 theWireTimeOffset_(iConfig.getParameter<double>(
"CSCWireTimeOffset")),
71 theStripError_(iConfig.getParameter<double>(
"CSCStripError")),
72 theWireError_(iConfig.getParameter<double>(
"CSCWireError")),
75 debug(iConfig.getParameter<
bool>(
"debug")) {
77 theService = std::make_unique<MuonServiceProxy>(serviceParameters);
88 const std::vector<const CSCSegment*>& segments,
103 if (
sqrt(muonTrack->innerPosition().mag2()) >
sqrt(muonTrack->outerPosition().mag2())) {
104 pos = muonTrack->outerPosition();
105 mom = -1 * muonTrack->outerMomentum();
112 std::vector<TimeMeasurement> tms;
113 for (
const auto& rechit : segments) {
115 DetId id = rechit->geographicalId();
119 if (rechit->specificRecHits().empty())
122 const std::vector<CSCRecHit2D>& hits2d(rechit->specificRecHits());
125 for (
const auto& hiti : hits2d) {
126 const GeomDet* cscDet = theTrackingGeometry->
idToDet(hiti.geographicalId());
129 std::pair<TrajectoryStateOnSurface, double> tsos;
133 if (tsos.first.isValid())
134 dist = tsos.second + posp.mag();
136 dist = cscDet->
toGlobal(hiti.localPosition()).
mag();
143 tms.push_back(thisHit);
150 tms.push_back(thisHit);
159 bool modified =
false;
160 std::vector<double> dstnc, local_t0, hitWeightInvbeta, hitWeightTimeVtx;
161 double totalWeightInvbeta = 0;
162 double totalWeightTimeVtx = 0;
169 hitWeightInvbeta.clear();
170 hitWeightTimeVtx.clear();
172 totalWeightInvbeta = 0;
173 totalWeightTimeVtx = 0;
175 for (
auto& tm : tms) {
176 dstnc.push_back(tm.distIP);
177 local_t0.push_back(tm.timeCorr);
178 hitWeightInvbeta.push_back(tm.weightInvbeta);
179 hitWeightTimeVtx.push_back(tm.weightTimeVtx);
180 totalWeightInvbeta += tm.weightInvbeta;
181 totalWeightTimeVtx += tm.weightTimeVtx;
184 if (totalWeightInvbeta == 0)
189 std::cout <<
" Points for global fit: " << dstnc.size() << std::endl;
191 double invbeta = 0, invbetaErr = 0;
192 double timeVtx = 0, timeVtxErr = 0;
194 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
195 invbeta += (1. + local_t0.at(
i) / dstnc.at(
i) * 30.) * hitWeightInvbeta.at(
i) / totalWeightInvbeta;
196 timeVtx += local_t0.at(
i) * hitWeightTimeVtx.at(
i) / totalWeightTimeVtx;
200 std::vector<TimeMeasurement>::iterator tmmax;
203 double diff_ibeta, diff_tvtx;
204 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
205 diff_ibeta = (1. + local_t0.at(
i) / dstnc.at(
i) * 30.) - invbeta;
206 diff_ibeta = diff_ibeta * diff_ibeta * hitWeightInvbeta.at(
i);
207 diff_tvtx = local_t0.at(
i) - timeVtx;
208 diff_tvtx = diff_tvtx * diff_tvtx * hitWeightTimeVtx.at(
i);
209 invbetaErr += diff_ibeta;
210 timeVtxErr += diff_tvtx;
214 if (diff_tvtx > chimax) {
215 tmmax = tms.begin() +
i;
227 double cf = 1. / (dstnc.size() - 1);
228 invbetaErr =
sqrt(invbetaErr / totalWeightInvbeta * cf);
229 timeVtxErr =
sqrt(timeVtxErr / totalWeightTimeVtx * cf);
230 std::cout <<
" Measured 1/beta: " << invbeta <<
" +/- " << invbetaErr << std::endl;
231 std::cout <<
" Measured time: " << timeVtx <<
" +/- " << timeVtxErr << std::endl;
236 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
237 tmSequence.
dstnc.push_back(dstnc.at(
i));
238 tmSequence.
local_t0.push_back(local_t0.at(
i));
253 std::cout <<
" *** CSC Timimng Extractor ***" << std::endl;
258 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