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")) {
91 const std::vector<const CSCSegment*>& segments,
106 if (
sqrt(muonTrack->innerPosition().mag2()) >
sqrt(muonTrack->outerPosition().mag2())) {
107 pos = muonTrack->outerPosition();
108 mom = -1 * muonTrack->outerMomentum();
115 std::vector<TimeMeasurement> tms;
116 for (
const auto& rechit : segments) {
118 DetId id = rechit->geographicalId();
122 if (rechit->specificRecHits().empty())
125 const std::vector<CSCRecHit2D>& hits2d(rechit->specificRecHits());
128 for (
const auto& hiti : hits2d) {
132 std::pair<TrajectoryStateOnSurface, double> tsos;
136 if (tsos.first.isValid())
137 dist = tsos.second + posp.mag();
139 dist = cscDet->
toGlobal(hiti.localPosition()).
mag();
146 tms.push_back(thisHit);
153 tms.push_back(thisHit);
162 bool modified =
false;
163 std::vector<double> dstnc, local_t0, hitWeightInvbeta, hitWeightTimeVtx;
164 double totalWeightInvbeta = 0;
165 double totalWeightTimeVtx = 0;
172 hitWeightInvbeta.clear();
173 hitWeightTimeVtx.clear();
175 totalWeightInvbeta = 0;
176 totalWeightTimeVtx = 0;
178 for (
auto& tm : tms) {
179 dstnc.push_back(tm.distIP);
180 local_t0.push_back(tm.timeCorr);
181 hitWeightInvbeta.push_back(tm.weightInvbeta);
182 hitWeightTimeVtx.push_back(tm.weightTimeVtx);
183 totalWeightInvbeta += tm.weightInvbeta;
184 totalWeightTimeVtx += tm.weightTimeVtx;
187 if (totalWeightInvbeta == 0)
192 std::cout <<
" Points for global fit: " << dstnc.size() << std::endl;
194 double invbeta = 0, invbetaErr = 0;
195 double timeVtx = 0, timeVtxErr = 0;
197 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
198 invbeta += (1. + local_t0.at(
i) / dstnc.at(
i) * 30.) * hitWeightInvbeta.at(
i) / totalWeightInvbeta;
199 timeVtx += local_t0.at(
i) * hitWeightTimeVtx.at(
i) / totalWeightTimeVtx;
203 std::vector<TimeMeasurement>::iterator tmmax;
206 double diff_ibeta, diff_tvtx;
207 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
208 diff_ibeta = (1. + local_t0.at(
i) / dstnc.at(
i) * 30.) - invbeta;
209 diff_ibeta = diff_ibeta * diff_ibeta * hitWeightInvbeta.at(
i);
210 diff_tvtx = local_t0.at(
i) - timeVtx;
211 diff_tvtx = diff_tvtx * diff_tvtx * hitWeightTimeVtx.at(
i);
212 invbetaErr += diff_ibeta;
213 timeVtxErr += diff_tvtx;
217 if (diff_tvtx > chimax) {
218 tmmax = tms.begin() +
i;
230 double cf = 1. / (dstnc.size() - 1);
231 invbetaErr =
sqrt(invbetaErr / totalWeightInvbeta * cf);
232 timeVtxErr =
sqrt(timeVtxErr / totalWeightTimeVtx * cf);
233 std::cout <<
" Measured 1/beta: " << invbeta <<
" +/- " << invbetaErr << std::endl;
234 std::cout <<
" Measured time: " << timeVtx <<
" +/- " << timeVtxErr << std::endl;
239 for (
unsigned int i = 0;
i < dstnc.size();
i++) {
240 tmSequence.
dstnc.push_back(dstnc.at(
i));
241 tmSequence.
local_t0.push_back(local_t0.at(
i));
256 std::cout <<
" *** CSC Timimng Extractor ***" << std::endl;