54 m_radial = tFileService->
make<TH1F>(name3.str().c_str(),
title.str().c_str(), 700, 0., 700.);
92 std::vector<const TransientTrackingRecHit *> hits_i;
93 std::vector<const TransientTrackingRecHit *> hits_j;
95 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
96 measurement != measurements.end();
108 hits_i.push_back(
hit);
110 hits_j.push_back(
hit);
127 double intercept_i = 0.;
128 double interceptError2_i = 0.;
130 double slopeError2_i = 0.;
131 double intercept_j = 0.;
132 double interceptError2_j = 0.;
134 double slopeError2_j = 0.;
143 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_i.begin();
hit != hits_i.end();
147 double z = (*hit)->globalPosition().z() -
m_Zplane;
158 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_j.begin();
hit != hits_j.end();
162 double z = (*hit)->globalPosition().z() -
m_Zplane;
171 if (sum1_i != 0. && sum1_j != 0.) {
172 slope_i = slope_j = dphidz;
174 intercept_i = sumy_i / sum1_i;
175 interceptError2_i = 1. / sum1_i;
177 intercept_j = sumy_j / sum1_j;
178 interceptError2_j = 1. / sum1_j;
190 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_i.begin();
hit != hits_i.end();
194 double z = (*hit)->globalPosition().z() -
m_Zplane;
211 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_j.begin();
hit != hits_j.end();
215 double z = (*hit)->globalPosition().z() -
m_Zplane;
227 double delta_i = (sum1_i * sumxx_i) - (sumx_i * sumx_i);
228 double delta_j = (sum1_j * sumxx_j) - (sumx_j * sumx_j);
229 if (delta_i != 0. && delta_j != 0.) {
230 intercept_i = ((sumxx_i * sumy_i) - (sumx_i * sumxy_i)) / delta_i;
231 interceptError2_i = sumxx_i / delta_i;
232 slope_i = ((sum1_i * sumxy_i) - (sumx_i * sumy_i)) / delta_i;
233 slopeError2_i = sum1_i / delta_i;
235 intercept_j = ((sumxx_j * sumy_j) - (sumx_j * sumxy_j)) / delta_j;
236 interceptError2_j = sumxx_j / delta_j;
237 slope_j = ((sum1_j * sumxy_j) - (sumx_j * sumy_j)) / delta_j;
238 slopeError2_j = sum1_j / delta_j;
247 double sumxx_ri = 0.;
248 double sumxy_ri = 0.;
249 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_i.begin();
hit != hits_i.end(); ++
hit) {
250 double r = (*hit)->globalPosition().perp();
251 double z = (*hit)->globalPosition().z() -
m_Zplane;
258 double radial_delta_i = (sum1_ri * sumxx_ri) - (sumx_ri * sumx_ri);
259 if (radial_delta_i == 0.)
261 double radial_slope_i = ((sum1_ri * sumxy_ri) - (sumx_ri * sumy_ri)) / radial_delta_i;
262 double radial_intercept_i =
263 ((sumxx_ri * sumy_ri) - (sumx_ri * sumxy_ri)) / radial_delta_i + radial_slope_i * (
m_iZ -
m_Zplane);
268 double sumxx_rj = 0.;
269 double sumxy_rj = 0.;
270 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit = hits_j.begin();
hit != hits_j.end(); ++
hit) {
271 double r = (*hit)->globalPosition().perp();
272 double z = (*hit)->globalPosition().z() -
m_Zplane;
279 double radial_delta_j = (sum1_rj * sumxx_rj) - (sumx_rj * sumx_rj);
280 if (radial_delta_j == 0.)
282 double radial_slope_j = ((sum1_rj * sumxy_rj) - (sumx_rj * sumy_rj)) / radial_delta_j;
283 double radial_intercept_j =
284 ((sumxx_rj * sumy_rj) - (sumx_rj * sumxy_rj)) / radial_delta_j + radial_slope_j * (
m_jZ -
m_Zplane);
286 double radial_delta = ((sum1_ri + sum1_rj) * (sumxx_ri + sumxx_rj)) - ((sumx_ri + sumx_rj) * (sumx_ri + sumx_rj));
287 if (radial_delta == 0.)
289 double radial_intercept =
290 (((sumxx_ri + sumxx_rj) * (sumy_ri + sumy_rj)) - ((sumx_ri + sumx_rj) * (sumxy_ri + sumxy_rj))) / radial_delta;
291 double radial_slope =
292 (((sum1_ri + sum1_rj) * (sumxy_ri + sumxy_rj)) - ((sumx_ri + sumx_rj) * (sumy_ri + sumy_rj))) / radial_delta;
301 double quantityError2 = 0.;
303 quantity = (slope_i * radial_intercept_i) - (slope_j * radial_intercept_j);
304 quantityError2 = (slopeError2_i)*
pow(radial_intercept_i, 2) + (slopeError2_j)*
pow(radial_intercept_j, 2);
306 quantity = intercept_i - intercept_j;
307 quantityError2 = interceptError2_i + interceptError2_j;
309 quantity = (intercept_i - intercept_j) * radial_intercept;
310 quantityError2 = (interceptError2_i + interceptError2_j) *
pow(radial_intercept, 2);
314 if (quantityError2 == 0.)
317 double slopeResid = ((slope_i * radial_intercept_i) - (slope_j * radial_intercept_j)) * 1000.;
318 double slopeResidError2 =
319 ((slopeError2_i)*
pow(radial_intercept_i, 2) + (slopeError2_j)*
pow(radial_intercept_j, 2)) * 1000. * 1000.;
320 double offsetResid = (intercept_i - intercept_j) * radial_intercept * 10.;
321 double offsetResidError2 = (interceptError2_i + interceptError2_j) *
pow(radial_intercept, 2) * 10. * 10.;
330 weight = 1. / quantityError2;
342 double rphi_slope_i = slope_i * radial_intercept_i;
343 double rphi_slope_j = slope_j * radial_intercept_j;
466 std::map<int, int> stations;
468 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
469 measurement != measurements.end();
471 DetId id = measurement->recHit()->geographicalId();
480 if (stations.find(
station) == stations.end()) {
485 cscHits.push_back(measurement->recHit());
492 for (std::map<int, int>::const_iterator
station = stations.begin();
station != stations.end(); ++
station) {
503 const std::vector<TrajectoryMeasurement> &measurements2 =
trajectories.begin()->measurements();
506 bool found_plus =
false;
507 bool found_minus =
false;
509 for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements2.begin();
510 measurement != measurements2.end();
512 double z = measurement->recHit()->globalPosition().z();
516 measurement->backwardPredictedState());
523 measurement->backwardPredictedState());
541 if (found_plus && from_plus.
isValid() && found_minus && from_minus.
isValid()) {
543 }
else if (found_plus && from_plus.
isValid()) {
545 }
else if (found_minus && from_minus.
isValid()) {
554 double dxdz = direction.
x() / direction.
z();
555 double dydz = direction.
y() / direction.
z();
581 std::vector<std::ifstream *>::const_iterator inputiter =
input.begin();
582 std::vector<std::string>::const_iterator
filename = filenames.begin();
585 bool touched =
false;
586 while (!(*inputiter)->eof()) {
589 unsigned int identifier;
592 double sum1, sumx, sumy, sumxx, sumyy, sumxy;
594 (**inputiter) >>
name >> identifier >>
i >>
j >> sumN >> sum1 >> sumx >> sumy >> sumxx >> sumyy >> sumxy >> eoln;
596 if (!(*inputiter)->eof() && (
name !=
"CSCPairResidualsConstraint" || eoln !=
"EOLN"))
598 <<
"Temporary file " << *
filename <<
" is incorrectly formatted on line " << linenumber << std::endl;
603 <<
"Wrong (i,j) for CSCPairResidualsConstraint " <<
m_identifier <<
" (" <<
m_i <<
"," <<
m_j 604 <<
") in file " << *
filename <<
" on line " << linenumber << std::endl;
617 (*inputiter)->clear();
618 (*inputiter)->seekg(0, std::ios::beg);
622 <<
"CSCPairResidualsConstraint " <<
m_identifier <<
" is missing from file " << *
filename << std::endl;
634 phi =
hit->globalPosition().phi();
635 r =
hit->globalPosition().perp();
645 const double R_ME11 = 181.5;
646 const double R_ME12 = 369.7;
647 const double R_ME21 = 242.7;
648 const double R_ME31 = 252.7;
649 const double R_ME41 = 262.65;
650 const double R_MEx2 = 526.5;
655 else if (cscid.
station() == 1 && cscid.
ring() == 2)
657 else if (cscid.
station() == 2 && cscid.
ring() == 1)
659 else if (cscid.
station() == 3 && cscid.
ring() == 1)
661 else if (cscid.
station() == 4 && cscid.
ring() == 1)
681 double xx =
hit->localPositionError().xx();
682 double xy =
hit->localPositionError().xy();
683 double yy =
hit->localPositionError().yy();
684 phierr2 = (
xx * cosAngle * cosAngle + 2. *
xy * sinAngle * cosAngle +
yy * sinAngle * sinAngle) / (
r *
r);
694 const double cut_ME11 = 0.086;
695 const double cut_ME12 = 0.090;
696 const double cut_MEx1 = 0.180;
697 const double cut_MEx2 = 0.090;
704 for (std::vector<const TransientTrackingRecHit *>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
708 .
toLocal((*hit)->globalPosition())
732 double delta = (sum1 * sumxx) - (sumx * sumx);
735 double intercept = ((sumxx * sumy) - (sumx * sumxy)) /
delta;
736 double slope = ((sum1 * sumxy) - (sumx * sumy)) /
delta;
742 return (fabs(phi1) < cut_ME11 && fabs(phi6) < cut_ME11);
744 return (fabs(phi1) < cut_ME12 && fabs(phi6) < cut_ME12);
746 return (fabs(phi1) < cut_MEx1 && fabs(phi6) < cut_MEx1);
748 return (fabs(phi1) < cut_MEx2 && fabs(phi6) < cut_MEx2);
double m_truncateSlopeResid
bool isFiducial(std::vector< const TransientTrackingRecHit *> &hits, bool is_i)
int nearestStrip(const LocalPoint &lp) const
Geom::Phi< T > phi() const
static const double slope[3]
Sin< T >::type sin(const T &t)
const Propagator * m_propagator
void setZplane(const CSCGeometry *cscGeometry)
double m_truncateOffsetResid
LocalPoint toLocal(const GlobalPoint &gp) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
float stripAngle(int strip) const
const CSCLayerGeometry * geometry() const
static std::string const input
TH1F * m_slopeResiduals_weighted
double error() const override
static PlanePointer build(Args &&... args)
GlobalPoint globalPosition() const
int m_minStationsInTrackRefits
double value() const override
Cos< T >::type cos(const T &t)
void configure(CSCOverlapsAlignmentAlgorithm *parent)
void write(std::ofstream &output)
TProfile * m_fiducial_MEx2
TH1F * m_offsetResiduals_weighted
void read(std::vector< std::ifstream *> &input, std::vector< std::string > &filenames)
void calculatePhi(const TransientTrackingRecHit *hit, double &phi, double &phierr2, bool doRphi=false, bool globalPhi=false)
TH1F * m_offsetResiduals_normalized
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
std::vector< ConstRecHitPointer > ConstRecHitContainer
const Plane & surface() const
The nominal surface of the GeomDet.
const PositionType & position() const
bool valid() const override
TProfile * m_fiducial_MEx1
GlobalVector globalDirection() const
bool addTrack(const std::vector< TrajectoryMeasurement > &measurements, const reco::TransientTrack &track, const TrackTransformer *trackTransformer)
bool m_slopeFromTrackRefit
CSCOverlapsAlignmentAlgorithm * m_parent
int m_minTracksPerOverlap
unsigned int m_identifier
T * make(const Args &...args) const
make new ROOT object
Plane::PlanePointer m_Zsurface
bool dphidzFromTrack(const std::vector< TrajectoryMeasurement > &measurements, const reco::TransientTrack &track, const TrackTransformer *trackTransformer, double &drphidz)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
TProfile * m_fiducial_ME12
TProfile * m_fiducial_ME11
void setPropagator(const Propagator *propagator)
TH1F * m_slopeResiduals_normalized
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
const CSCGeometry * m_cscGeometry
const GeomDet * idToDet(DetId) const override