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")),
76 UseWireTime(iConfig.getParameter<bool>(
"UseWireTime")),
77 UseStripTime(iConfig.getParameter<bool>(
"UseStripTime")),
78 debug(iConfig.getParameter<bool>(
"debug"))
81 theService = std::make_unique<MuonServiceProxy>(serviceParameters);
102 std::cout <<
" *** CSC Timimng Extractor ***" << std::endl;
115 if (
sqrt(muonTrack->innerPosition().mag2()) >
sqrt(muonTrack->outerPosition().mag2())){
116 pos=muonTrack->outerPosition();
117 mom=-1*muonTrack->outerMomentum();
127 std::vector<TimeMeasurement> tms;
128 for (std::vector<const CSCSegment*>::iterator rechit = range.begin(); rechit!=range.end();++rechit) {
131 DetId id = (*rechit)->geographicalId();
135 if (!(*rechit)->specificRecHits().size())
continue;
137 const std::vector<CSCRecHit2D> hits2d = (*rechit)->specificRecHits();
140 for (std::vector<CSCRecHit2D>::const_iterator hiti=hits2d.begin(); hiti!=hits2d.end(); hiti++) {
142 const GeomDet* cscDet = theTrackingGeometry->
idToDet(hiti->geographicalId());
145 std::pair< TrajectoryStateOnSurface, double> tsos;
149 if (tsos.first.isValid()) dist = tsos.second+posp.mag();
150 else dist = cscDet->
toGlobal(hiti->localPosition()).
mag();
157 tms.push_back(thisHit);
164 tms.push_back(thisHit);
173 bool modified =
false;
174 std::vector <double> dstnc, local_t0, hitWeightInvbeta, hitWeightTimeVtx;
175 double totalWeightInvbeta=0;
176 double totalWeightTimeVtx=0;
184 hitWeightInvbeta.clear();
185 hitWeightTimeVtx.clear();
187 totalWeightInvbeta=0;
188 totalWeightTimeVtx=0;
190 for (std::vector<TimeMeasurement>::iterator tm=tms.begin(); tm!=tms.end(); ++tm) {
191 dstnc.push_back(tm->distIP);
192 local_t0.push_back(tm->timeCorr);
193 hitWeightInvbeta.push_back(tm->weightInvbeta);
194 hitWeightTimeVtx.push_back(tm->weightTimeVtx);
195 totalWeightInvbeta+=tm->weightInvbeta;
196 totalWeightTimeVtx+=tm->weightTimeVtx;
199 if (totalWeightInvbeta==0)
break;
203 std::cout <<
" Points for global fit: " << dstnc.size() << std::endl;
205 double invbeta=0,invbetaErr=0;
206 double timeVtx=0,timeVtxErr=0;
208 for (
unsigned int i=0;
i<dstnc.size();
i++) {
209 invbeta+=(1.+local_t0.at(
i)/dstnc.at(
i)*30.)*hitWeightInvbeta.at(
i)/totalWeightInvbeta;
210 timeVtx+=local_t0.at(
i)*hitWeightTimeVtx.at(
i)/totalWeightTimeVtx;
214 std::vector<TimeMeasurement>::iterator tmmax;
217 double diff_ibeta,diff_tvtx;
218 for (
unsigned int i=0;
i<dstnc.size();
i++) {
219 diff_ibeta=(1.+local_t0.at(
i)/dstnc.at(
i)*30.)-invbeta;
220 diff_ibeta=diff_ibeta*diff_ibeta*hitWeightInvbeta.at(
i);
221 diff_tvtx=local_t0.at(
i)-timeVtx;
222 diff_tvtx=diff_tvtx*diff_tvtx*hitWeightTimeVtx.at(
i);
223 invbetaErr+=diff_ibeta;
224 timeVtxErr+=diff_tvtx;
228 if (diff_tvtx>chimax) {
241 double cf = 1./(dstnc.size()-1);
242 invbetaErr=
sqrt(invbetaErr/totalWeightInvbeta*cf);
243 timeVtxErr=
sqrt(timeVtxErr/totalWeightTimeVtx*cf);
244 std::cout <<
" Measured 1/beta: " << invbeta <<
" +/- " << invbetaErr << std::endl;
245 std::cout <<
" Measured time: " << timeVtx <<
" +/- " << timeVtxErr << std::endl;
250 for (
unsigned int i=0;
i<dstnc.size();
i++) {
251 tmSequence.
dstnc.push_back(dstnc.at(
i));
252 tmSequence.
local_t0.push_back(local_t0.at(
i));
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 const GeomDet * idToDet(DetId) const
edm::ESHandle< GlobalTrackingGeometry > theTrackingGeometry
std::vector< double > weightInvbeta
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
double totalWeightInvbeta
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< double > weightTimeVtx
T const * product() const
std::vector< double > dstnc