CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
CSCPairResidualsConstraint Class Reference

#include <CSCPairResidualsConstraint.h>

Inheritance diagram for CSCPairResidualsConstraint:
CSCPairConstraint

Public Types

enum  { kModePhiy, kModePhiPos, kModePhiz, kModeRadius }
 

Public Member Functions

bool addTrack (const std::vector< TrajectoryMeasurement > &measurements, const reco::TransientTrack &track, const TrackTransformer *trackTransformer)
 
void configure (CSCOverlapsAlignmentAlgorithm *parent)
 
 CSCPairResidualsConstraint (unsigned int identifier, int i, int j, CSCDetId id_i, CSCDetId id_j)
 
double error () const override
 
CSCDetId id_i () const
 
CSCDetId id_j () const
 
double radius (bool is_i) const
 
void read (std::vector< std::ifstream *> &input, std::vector< std::string > &filenames)
 
void setPropagator (const Propagator *propagator)
 
void setZplane (const CSCGeometry *cscGeometry)
 
bool valid () const override
 
double value () const override
 
void write (std::ofstream &output)
 
 ~CSCPairResidualsConstraint () override
 
- Public Member Functions inherited from CSCPairConstraint
 CSCPairConstraint (int i, int j, double value, double error)
 
virtual int i () const
 
virtual int j () const
 
virtual ~CSCPairConstraint ()
 

Protected Member Functions

void calculatePhi (const TransientTrackingRecHit *hit, double &phi, double &phierr2, bool doRphi=false, bool globalPhi=false)
 
bool dphidzFromTrack (const std::vector< TrajectoryMeasurement > &measurements, const reco::TransientTrack &track, const TrackTransformer *trackTransformer, double &drphidz)
 
bool isFiducial (std::vector< const TransientTrackingRecHit *> &hits, bool is_i)
 

Protected Attributes

double m_averageRadius
 
const CSCGeometrym_cscGeometry
 
CSCDetId m_id_i
 
CSCDetId m_id_j
 
unsigned int m_identifier
 
double m_iZ
 
double m_iZ1
 
double m_iZ6
 
double m_jZ
 
double m_jZ1
 
double m_jZ6
 
TH1F * m_offsetResiduals
 
CSCOverlapsAlignmentAlgorithmm_parent
 
const Propagatorm_propagator
 
TH1F * m_radial
 
TH1F * m_slopeResiduals
 
double m_sum1
 
int m_sumN
 
double m_sumx
 
double m_sumxx
 
double m_sumxy
 
double m_sumy
 
double m_sumyy
 
double m_Zplane
 
Plane::PlanePointer m_Zsurface
 
- Protected Attributes inherited from CSCPairConstraint
double m_error
 
int m_i
 
int m_j
 
double m_value
 

Detailed Description

Date
2010/05/06 05:57:33
Revision
1.4
Author
J. Pivarski - Texas A&M University pivar.nosp@m.ski@.nosp@m.physi.nosp@m.cs.t.nosp@m.amu.e.nosp@m.du

Definition at line 27 of file CSCPairResidualsConstraint.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Constructor & Destructor Documentation

◆ CSCPairResidualsConstraint()

CSCPairResidualsConstraint::CSCPairResidualsConstraint ( unsigned int  identifier,
int  i,
int  j,
CSCDetId  id_i,
CSCDetId  id_j 
)
inline

Definition at line 29 of file CSCPairResidualsConstraint.h.

30  : CSCPairConstraint(i, j, 0., 0.),
31  m_identifier(identifier),
32  m_id_i(id_i),
33  m_id_j(id_j),
34  m_sum1(0.),
35  m_sumx(0.),
36  m_sumy(0.),
37  m_sumxx(0.),
38  m_sumyy(0.),
39  m_sumxy(0.),
40  m_sumN(0),
41  m_Zplane(1000.),
42  m_iZ1(1000.),
43  m_iZ6(1000.),
44  m_jZ1(1000.),
45  m_jZ6(1000.),
46  m_cscGeometry(nullptr),
47  m_propagator(nullptr){};
CSCPairConstraint(int i, int j, double value, double error)
virtual int j() const
virtual int i() const

◆ ~CSCPairResidualsConstraint()

CSCPairResidualsConstraint::~CSCPairResidualsConstraint ( )
inlineoverride

Definition at line 48 of file CSCPairResidualsConstraint.h.

48 {};

Member Function Documentation

◆ addTrack()

bool CSCPairResidualsConstraint::addTrack ( const std::vector< TrajectoryMeasurement > &  measurements,
const reco::TransientTrack track,
const TrackTransformer trackTransformer 
)

Definition at line 89 of file CSCPairResidualsConstraint.cc.

References cms::cuda::assert(), calculatePhi(), CSCDetId::chamber(), MuonSubdetId::CSC, dphidzFromTrack(), CSCDetId::endcap(), isFiducial(), kModePhiPos, kModePhiy, kModePhiz, kModeRadius, m_averageRadius, CSCOverlapsAlignmentAlgorithm::m_combineME11, CSCOverlapsAlignmentAlgorithm::m_drdz, CSCOverlapsAlignmentAlgorithm::m_fiducial, CSCOverlapsAlignmentAlgorithm::m_hitsPerChamber, m_id_i, m_id_j, m_iZ, m_jZ, CSCOverlapsAlignmentAlgorithm::m_makeHistograms, CSCOverlapsAlignmentAlgorithm::m_maxdrdz, CSCOverlapsAlignmentAlgorithm::m_minHitsPerChamber, CSCOverlapsAlignmentAlgorithm::m_mode, CSCOverlapsAlignmentAlgorithm::m_occupancy, m_offsetResiduals, CSCOverlapsAlignmentAlgorithm::m_offsetResiduals, CSCOverlapsAlignmentAlgorithm::m_offsetResiduals_normalized, CSCOverlapsAlignmentAlgorithm::m_offsetResiduals_weighted, m_parent, m_radial, CSCOverlapsAlignmentAlgorithm::m_slope, CSCOverlapsAlignmentAlgorithm::m_slope_MEm1, CSCOverlapsAlignmentAlgorithm::m_slope_MEm2, CSCOverlapsAlignmentAlgorithm::m_slope_MEm3, CSCOverlapsAlignmentAlgorithm::m_slope_MEm4, CSCOverlapsAlignmentAlgorithm::m_slope_MEp1, CSCOverlapsAlignmentAlgorithm::m_slope_MEp2, CSCOverlapsAlignmentAlgorithm::m_slope_MEp3, CSCOverlapsAlignmentAlgorithm::m_slope_MEp4, CSCOverlapsAlignmentAlgorithm::m_slopeFromTrackRefit, m_slopeResiduals, CSCOverlapsAlignmentAlgorithm::m_slopeResiduals, CSCOverlapsAlignmentAlgorithm::m_slopeResiduals_normalized, CSCOverlapsAlignmentAlgorithm::m_slopeResiduals_weighted, m_sum1, m_sumN, m_sumx, m_sumxx, m_sumxy, m_sumy, m_sumyy, CSCOverlapsAlignmentAlgorithm::m_truncateOffsetResid, CSCOverlapsAlignmentAlgorithm::m_truncateSlopeResid, CSCOverlapsAlignmentAlgorithm::m_useHitWeights, CSCOverlapsAlignmentAlgorithm::m_useTrackWeights, m_Zplane, DetId::Muon, phi, funct::pow(), MjjMonitor_cfi::quantity, alignCSCRings::r, nano_mu_digi_cff::rawId, CSCDetId::ring(), mathSSE::sqrt(), CSCDetId::station(), HLT_2024v14_cff::track, mps_merge::weight, and z.

91  {
92  std::vector<const TransientTrackingRecHit *> hits_i;
93  std::vector<const TransientTrackingRecHit *> hits_j;
94 
95  for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
96  measurement != measurements.end();
97  ++measurement) {
98  const TransientTrackingRecHit *hit = &*(measurement->recHit());
99 
100  DetId id = hit->geographicalId();
101  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
102  CSCDetId cscid(id.rawId());
103  CSCDetId chamberId(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 0);
104  if (m_parent->m_combineME11 && cscid.station() == 1 && cscid.ring() == 4)
105  chamberId = CSCDetId(cscid.endcap(), 1, 1, cscid.chamber(), 0);
106 
107  if (chamberId == m_id_i)
108  hits_i.push_back(hit);
109  if (chamberId == m_id_j)
110  hits_j.push_back(hit);
111  }
112  }
113 
114  if (m_parent->m_makeHistograms) {
115  m_parent->m_hitsPerChamber->Fill(hits_i.size());
116  m_parent->m_hitsPerChamber->Fill(hits_j.size());
117  }
118 
119  // require minimum number of hits (if the requirement is too low (~2), some NANs might result...)
120  if (int(hits_i.size()) < m_parent->m_minHitsPerChamber || int(hits_j.size()) < m_parent->m_minHitsPerChamber)
121  return false;
122 
123  // maybe require segments to be fiducial
124  if (m_parent->m_fiducial && !(isFiducial(hits_i, true) && isFiducial(hits_j, false)))
125  return false;
126 
127  double intercept_i = 0.;
128  double interceptError2_i = 0.;
129  double slope_i = 0.;
130  double slopeError2_i = 0.;
131  double intercept_j = 0.;
132  double interceptError2_j = 0.;
133  double slope_j = 0.;
134  double slopeError2_j = 0.;
135 
136  // if slopeFromTrackRefit, then you'll need to refit the whole track without this station's hits;
137  // need at least two other stations for that to be reliable
139  double dphidz;
140  if (dphidzFromTrack(measurements, track, trackTransformer, dphidz)) {
141  double sum1_i = 0.;
142  double sumy_i = 0.;
143  for (std::vector<const TransientTrackingRecHit *>::const_iterator hit = hits_i.begin(); hit != hits_i.end();
144  ++hit) {
145  double phi, phierr2;
146  calculatePhi(*hit, phi, phierr2, false, true);
147  double z = (*hit)->globalPosition().z() - m_Zplane;
148 
149  double weight = 1.;
151  weight = 1. / phierr2;
152  sum1_i += weight;
153  sumy_i += weight * (phi - z * dphidz);
154  }
155 
156  double sum1_j = 0.;
157  double sumy_j = 0.;
158  for (std::vector<const TransientTrackingRecHit *>::const_iterator hit = hits_j.begin(); hit != hits_j.end();
159  ++hit) {
160  double phi, phierr2;
161  calculatePhi(*hit, phi, phierr2, false, true);
162  double z = (*hit)->globalPosition().z() - m_Zplane;
163 
164  double weight = 1.;
166  weight = 1. / phierr2;
167  sum1_j += weight;
168  sumy_j += weight * (phi - z * dphidz);
169  }
170 
171  if (sum1_i != 0. && sum1_j != 0.) {
172  slope_i = slope_j = dphidz;
173 
174  intercept_i = sumy_i / sum1_i;
175  interceptError2_i = 1. / sum1_i;
176 
177  intercept_j = sumy_j / sum1_j;
178  interceptError2_j = 1. / sum1_j;
179  } else
180  return false;
181  }
182  }
183 
184  else { // not slopeFromTrackRefit
185  double sum1_i = 0.;
186  double sumx_i = 0.;
187  double sumy_i = 0.;
188  double sumxx_i = 0.;
189  double sumxy_i = 0.;
190  for (std::vector<const TransientTrackingRecHit *>::const_iterator hit = hits_i.begin(); hit != hits_i.end();
191  ++hit) {
192  double phi, phierr2;
193  calculatePhi(*hit, phi, phierr2, false, true);
194  double z = (*hit)->globalPosition().z() - m_Zplane;
195 
196  double weight = 1.;
198  weight = 1. / phierr2;
199  sum1_i += weight;
200  sumx_i += weight * z;
201  sumy_i += weight * phi;
202  sumxx_i += weight * z * z;
203  sumxy_i += weight * z * phi;
204  }
205 
206  double sum1_j = 0.;
207  double sumx_j = 0.;
208  double sumy_j = 0.;
209  double sumxx_j = 0.;
210  double sumxy_j = 0.;
211  for (std::vector<const TransientTrackingRecHit *>::const_iterator hit = hits_j.begin(); hit != hits_j.end();
212  ++hit) {
213  double phi, phierr2;
214  calculatePhi(*hit, phi, phierr2, false, true);
215  double z = (*hit)->globalPosition().z() - m_Zplane;
216 
217  double weight = 1.;
219  weight = 1. / phierr2;
220  sum1_j += weight;
221  sumx_j += weight * z;
222  sumy_j += weight * phi;
223  sumxx_j += weight * z * z;
224  sumxy_j += weight * z * phi;
225  }
226 
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;
234 
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;
239  } else
240  return false;
241  }
242 
243  // from hits on the two chambers, determine radial_intercepts separately and radial_slope together
244  double sum1_ri = 0.;
245  double sumx_ri = 0.;
246  double sumy_ri = 0.;
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;
252  sum1_ri += 1.;
253  sumx_ri += z;
254  sumy_ri += r;
255  sumxx_ri += z * z;
256  sumxy_ri += z * r;
257  }
258  double radial_delta_i = (sum1_ri * sumxx_ri) - (sumx_ri * sumx_ri);
259  if (radial_delta_i == 0.)
260  return false;
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);
264 
265  double sum1_rj = 0.;
266  double sumx_rj = 0.;
267  double sumy_rj = 0.;
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;
273  sum1_rj += 1.;
274  sumx_rj += z;
275  sumy_rj += r;
276  sumxx_rj += z * z;
277  sumxy_rj += z * r;
278  }
279  double radial_delta_j = (sum1_rj * sumxx_rj) - (sumx_rj * sumx_rj);
280  if (radial_delta_j == 0.)
281  return false;
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);
285 
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.)
288  return false;
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;
293 
294  if (m_parent->m_makeHistograms) {
295  m_parent->m_drdz->Fill(radial_slope);
296  }
297  if (m_parent->m_maxdrdz > 0. && fabs(radial_slope) > m_parent->m_maxdrdz)
298  return false;
299 
300  double quantity = 0.;
301  double quantityError2 = 0.;
302  if (m_parent->m_mode == kModePhiy) { // phiy comes from track d(rphi)/dz
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);
305  } else if (m_parent->m_mode == kModePhiPos || m_parent->m_mode == kModeRadius) { // phipos comes from phi intercepts
306  quantity = intercept_i - intercept_j;
307  quantityError2 = interceptError2_i + interceptError2_j;
308  } else if (m_parent->m_mode == kModePhiz) { // phiz comes from the slope of rphi intercepts
309  quantity = (intercept_i - intercept_j) * radial_intercept;
310  quantityError2 = (interceptError2_i + interceptError2_j) * pow(radial_intercept, 2);
311  } else
312  assert(false);
313 
314  if (quantityError2 == 0.)
315  return false;
316 
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.;
322 
323  if (m_parent->m_truncateSlopeResid > 0. && fabs(slopeResid) > m_parent->m_truncateSlopeResid)
324  return false;
325  if (m_parent->m_truncateOffsetResid > 0. && fabs(offsetResid) > m_parent->m_truncateOffsetResid)
326  return false;
327 
328  double weight = 1.;
330  weight = 1. / quantityError2;
331 
332  // fill the running sums for this CSCPairResidualsConstraint
333  m_sumN += 1;
334  m_sum1 += weight;
335  m_sumx += weight * (radial_intercept - m_averageRadius);
336  m_sumy += weight * quantity;
337  m_sumxx += weight * pow(radial_intercept - m_averageRadius, 2);
339  m_sumxy += weight * (radial_intercept - m_averageRadius) * quantity;
340 
341  if (m_parent->m_makeHistograms) {
342  double rphi_slope_i = slope_i * radial_intercept_i;
343  double rphi_slope_j = slope_j * radial_intercept_j;
344 
346  m_parent->m_slope->Fill(rphi_slope_i); // == rphi_slope_j
347 
348  if (m_id_i.endcap() == 1 && m_id_i.station() == 4)
349  m_parent->m_slope_MEp4->Fill(rphi_slope_i);
350  if (m_id_i.endcap() == 1 && m_id_i.station() == 3)
351  m_parent->m_slope_MEp3->Fill(rphi_slope_i);
352  if (m_id_i.endcap() == 1 && m_id_i.station() == 2)
353  m_parent->m_slope_MEp2->Fill(rphi_slope_i);
354  if (m_id_i.endcap() == 1 && m_id_i.station() == 1)
355  m_parent->m_slope_MEp1->Fill(rphi_slope_i);
356  if (m_id_i.endcap() == 2 && m_id_i.station() == 1)
357  m_parent->m_slope_MEm1->Fill(rphi_slope_i);
358  if (m_id_i.endcap() == 2 && m_id_i.station() == 2)
359  m_parent->m_slope_MEm2->Fill(rphi_slope_i);
360  if (m_id_i.endcap() == 2 && m_id_i.station() == 3)
361  m_parent->m_slope_MEm3->Fill(rphi_slope_i);
362  if (m_id_i.endcap() == 2 && m_id_i.station() == 4)
363  m_parent->m_slope_MEm4->Fill(rphi_slope_i);
364  } else {
365  m_parent->m_slope->Fill(rphi_slope_i);
366  m_parent->m_slope->Fill(rphi_slope_j);
367 
368  if (m_id_i.endcap() == 1 && m_id_i.station() == 4) {
369  m_parent->m_slope_MEp4->Fill(rphi_slope_i);
370  m_parent->m_slope_MEp4->Fill(rphi_slope_j);
371  }
372  if (m_id_i.endcap() == 1 && m_id_i.station() == 3) {
373  m_parent->m_slope_MEp3->Fill(rphi_slope_i);
374  m_parent->m_slope_MEp3->Fill(rphi_slope_j);
375  }
376  if (m_id_i.endcap() == 1 && m_id_i.station() == 2) {
377  m_parent->m_slope_MEp2->Fill(rphi_slope_i);
378  m_parent->m_slope_MEp2->Fill(rphi_slope_j);
379  }
380  if (m_id_i.endcap() == 1 && m_id_i.station() == 1) {
381  m_parent->m_slope_MEp1->Fill(rphi_slope_i);
382  m_parent->m_slope_MEp1->Fill(rphi_slope_j);
383  }
384  if (m_id_i.endcap() == 2 && m_id_i.station() == 1) {
385  m_parent->m_slope_MEm1->Fill(rphi_slope_i);
386  m_parent->m_slope_MEm1->Fill(rphi_slope_j);
387  }
388  if (m_id_i.endcap() == 2 && m_id_i.station() == 2) {
389  m_parent->m_slope_MEm2->Fill(rphi_slope_i);
390  m_parent->m_slope_MEm2->Fill(rphi_slope_j);
391  }
392  if (m_id_i.endcap() == 2 && m_id_i.station() == 3) {
393  m_parent->m_slope_MEm3->Fill(rphi_slope_i);
394  m_parent->m_slope_MEm3->Fill(rphi_slope_j);
395  }
396  if (m_id_i.endcap() == 2 && m_id_i.station() == 4) {
397  m_parent->m_slope_MEm4->Fill(rphi_slope_i);
398  m_parent->m_slope_MEm4->Fill(rphi_slope_j);
399  }
400  }
401 
402  m_slopeResiduals->Fill(slopeResid);
403  m_offsetResiduals->Fill(offsetResid);
404  m_radial->Fill(radial_intercept);
405 
406  m_parent->m_slopeResiduals->Fill(slopeResid);
407  m_parent->m_slopeResiduals_weighted->Fill(slopeResid, 1. / slopeResidError2);
408  m_parent->m_slopeResiduals_normalized->Fill(slopeResid / sqrt(slopeResidError2));
409 
410  m_parent->m_offsetResiduals->Fill(offsetResid);
411  m_parent->m_offsetResiduals_weighted->Fill(offsetResid, 1. / offsetResidError2);
412  m_parent->m_offsetResiduals_normalized->Fill(offsetResid / sqrt(offsetResidError2));
413 
414  double ringbin = 0;
415  if (m_id_i.endcap() == 2 && m_id_i.station() == 4 && m_id_i.ring() == 2)
416  ringbin = 1.5;
417  else if (m_id_i.endcap() == 2 && m_id_i.station() == 4 && m_id_i.ring() == 1)
418  ringbin = 2.5;
419  else if (m_id_i.endcap() == 2 && m_id_i.station() == 3 && m_id_i.ring() == 2)
420  ringbin = 3.5;
421  else if (m_id_i.endcap() == 2 && m_id_i.station() == 3 && m_id_i.ring() == 1)
422  ringbin = 4.5;
423  else if (m_id_i.endcap() == 2 && m_id_i.station() == 2 && m_id_i.ring() == 2)
424  ringbin = 5.5;
425  else if (m_id_i.endcap() == 2 && m_id_i.station() == 2 && m_id_i.ring() == 1)
426  ringbin = 6.5;
427  else if (m_id_i.endcap() == 2 && m_id_i.station() == 1 && m_id_i.ring() == 3)
428  ringbin = 7.5;
429  else if (m_id_i.endcap() == 2 && m_id_i.station() == 1 && m_id_i.ring() == 2)
430  ringbin = 8.5;
431  else if (m_id_i.endcap() == 2 && m_id_i.station() == 1 && m_id_i.ring() == 1)
432  ringbin = 9.5;
433  else if (m_id_i.endcap() == 2 && m_id_i.station() == 1 && m_id_i.ring() == 4)
434  ringbin = 10.5;
435  else if (m_id_i.endcap() == 1 && m_id_i.station() == 1 && m_id_i.ring() == 4)
436  ringbin = 11.5;
437  else if (m_id_i.endcap() == 1 && m_id_i.station() == 1 && m_id_i.ring() == 1)
438  ringbin = 12.5;
439  else if (m_id_i.endcap() == 1 && m_id_i.station() == 1 && m_id_i.ring() == 2)
440  ringbin = 13.5;
441  else if (m_id_i.endcap() == 1 && m_id_i.station() == 1 && m_id_i.ring() == 3)
442  ringbin = 14.5;
443  else if (m_id_i.endcap() == 1 && m_id_i.station() == 2 && m_id_i.ring() == 1)
444  ringbin = 15.5;
445  else if (m_id_i.endcap() == 1 && m_id_i.station() == 2 && m_id_i.ring() == 2)
446  ringbin = 16.5;
447  else if (m_id_i.endcap() == 1 && m_id_i.station() == 3 && m_id_i.ring() == 1)
448  ringbin = 17.5;
449  else if (m_id_i.endcap() == 1 && m_id_i.station() == 3 && m_id_i.ring() == 2)
450  ringbin = 18.5;
451  else if (m_id_i.endcap() == 1 && m_id_i.station() == 4 && m_id_i.ring() == 1)
452  ringbin = 19.5;
453  else if (m_id_i.endcap() == 1 && m_id_i.station() == 4 && m_id_i.ring() == 2)
454  ringbin = 20.5;
455  m_parent->m_occupancy->Fill(m_id_i.chamber() + 0.5, ringbin);
456  }
457 
458  return true;
459 }
bool isFiducial(std::vector< const TransientTrackingRecHit *> &hits, bool is_i)
Definition: weight.py:1
assert(be >=bs)
T sqrt(T t)
Definition: SSEVec.h:23
void calculatePhi(const TransientTrackingRecHit *hit, double &phi, double &phierr2, bool doRphi=false, bool globalPhi=false)
int chamber() const
Definition: CSCDetId.h:62
Definition: DetId.h:17
int station() const
Definition: CSCDetId.h:79
int endcap() const
Definition: CSCDetId.h:85
CSCOverlapsAlignmentAlgorithm * m_parent
int ring() const
Definition: CSCDetId.h:68
bool dphidzFromTrack(const std::vector< TrajectoryMeasurement > &measurements, const reco::TransientTrack &track, const TrackTransformer *trackTransformer, double &drphidz)
static constexpr int CSC
Definition: MuonSubdetId.h:12
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ calculatePhi()

void CSCPairResidualsConstraint::calculatePhi ( const TransientTrackingRecHit hit,
double &  phi,
double &  phierr2,
bool  doRphi = false,
bool  globalPhi = false 
)
protected

Definition at line 626 of file CSCPairResidualsConstraint.cc.

References angle(), cms::cuda::assert(), funct::cos(), CSCDetId::endcap(), CSCLayer::geometry(), CSCGeometry::layer(), m_cscGeometry, M_PI, CSCLayerGeometry::nearestStrip(), phi, dttmaxenums::R, alignCSCRings::r, nano_mu_digi_cff::rawId, CSCDetId::ring(), funct::sin(), CSCDetId::station(), nano_mu_digi_cff::strip, CSCLayerGeometry::stripAngle(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and geometryCSVtoXML::yy.

Referenced by addTrack(), and isFiducial().

627  {
628  align::LocalPoint pos = hit->localPosition();
629  DetId id = hit->geographicalId();
630  CSCDetId cscid = CSCDetId(id.rawId());
631 
632  double r = 0.;
633  if (globalPhi) {
634  phi = hit->globalPosition().phi();
635  r = hit->globalPosition().perp();
636 
637  // double sinAngle = sin(phi);
638  // double cosAngle = cos(phi);
639  // double xx = hit->globalPositionError().cxx();
640  // double xy = hit->globalPositionError().cyx();
641  // double yy = hit->globalPositionError().cyy();
642  // phierr2 = (xx*cosAngle*cosAngle + 2.*xy*sinAngle*cosAngle + yy*sinAngle*sinAngle) / (r*r);
643  } else {
644  // these constants are related to the way CSC chambers are built--- really constant!
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;
651 
652  double R = 0.;
653  if (cscid.station() == 1 && (cscid.ring() == 1 || cscid.ring() == 4))
654  R = R_ME11;
655  else if (cscid.station() == 1 && cscid.ring() == 2)
656  R = R_ME12;
657  else if (cscid.station() == 2 && cscid.ring() == 1)
658  R = R_ME21;
659  else if (cscid.station() == 3 && cscid.ring() == 1)
660  R = R_ME31;
661  else if (cscid.station() == 4 && cscid.ring() == 1)
662  R = R_ME41;
663  else if (cscid.station() > 1 && cscid.ring() == 2)
664  R = R_MEx2;
665  else
666  assert(false);
667  r = (pos.y() + R);
668 
669  phi = atan2(pos.x(), r);
670 
671  if (cscid.endcap() == 1 && cscid.station() >= 3)
672  phi *= -1;
673  else if (cscid.endcap() == 2 && cscid.station() <= 2)
674  phi *= -1;
675  }
676 
678  double angle = m_cscGeometry->layer(id)->geometry()->stripAngle(strip) - M_PI / 2.;
679  double sinAngle = sin(angle);
680  double cosAngle = cos(angle);
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);
685 
686  if (doRphi) {
687  phi *= r;
688  phierr2 *= r * r;
689  }
690 }
int nearestStrip(const LocalPoint &lp) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(be >=bs)
float stripAngle(int strip) const
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
Definition: DetId.h:17
int station() const
Definition: CSCDetId.h:79
int endcap() const
Definition: CSCDetId.h:85
int ring() const
Definition: CSCDetId.h:68
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:105
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ configure()

void CSCPairResidualsConstraint::configure ( CSCOverlapsAlignmentAlgorithm parent)

Definition at line 38 of file CSCPairResidualsConstraint.cc.

References m_id_i, m_id_j, m_identifier, CSCOverlapsAlignmentAlgorithm::m_makeHistograms, m_offsetResiduals, m_parent, m_radial, m_slopeResiduals, TFileService::make(), Skims_PA_cff::name, hfnoseParametersInitialization_cfi::name2, class-composition::parent, and runGCPTkAlMap::title.

38  {
39  m_parent = parent;
40 
42  edm::Service<TFileService> tFileService;
43 
44  std::stringstream name, name2, name3, title;
45  title << "i =" << m_id_i << " j =" << m_id_j;
46 
47  name << "slopeResiduals_" << m_identifier;
48  m_slopeResiduals = tFileService->make<TH1F>(name.str().c_str(), title.str().c_str(), 300, -30., 30.);
49 
50  name2 << "offsetResiduals_" << m_identifier;
51  m_offsetResiduals = tFileService->make<TH1F>(name2.str().c_str(), title.str().c_str(), 300, -30., 30.);
52 
53  name3 << "radial_" << m_identifier;
54  m_radial = tFileService->make<TH1F>(name3.str().c_str(), title.str().c_str(), 700, 0., 700.);
55  } else {
56  m_slopeResiduals = nullptr;
57  m_offsetResiduals = nullptr;
58  m_radial = nullptr;
59  }
60 }
CSCOverlapsAlignmentAlgorithm * m_parent
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ dphidzFromTrack()

bool CSCPairResidualsConstraint::dphidzFromTrack ( const std::vector< TrajectoryMeasurement > &  measurements,
const reco::TransientTrack track,
const TrackTransformer trackTransformer,
double &  drphidz 
)
protected

Definition at line 461 of file CSCPairResidualsConstraint.cc.

References angle(), CSCDetId::chamber(), TrajectoryStateCombiner::combine(), funct::cos(), MuonSubdetId::CSC, dxdz, dydz, CSCDetId::endcap(), TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), CSCOverlapsAlignmentAlgorithm::m_combineME11, m_id_i, m_id_j, CSCOverlapsAlignmentAlgorithm::m_minHitsPerChamber, CSCOverlapsAlignmentAlgorithm::m_minStationsInTrackRefits, m_parent, M_PI, m_propagator, m_Zplane, m_Zsurface, DetId::Muon, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), Propagator::propagate(), nano_mu_digi_cff::rawId, CSCDetId::ring(), funct::sin(), relativeConstraints::station, CSCDetId::station(), HLT_2024v14_cff::track, FastTrackerRecHitMaskProducer_cfi::trajectories, TrackTransformer::transform(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by addTrack().

464  {
465  // make a list of hits on all chambers *other* than the ones associated with this constraint
466  std::map<int, int> stations;
468  for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements.begin();
469  measurement != measurements.end();
470  ++measurement) {
471  DetId id = measurement->recHit()->geographicalId();
472  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
473  CSCDetId cscid(id.rawId());
474  CSCDetId chamberId(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber(), 0);
475  if (m_parent->m_combineME11 && cscid.station() == 1 && cscid.ring() == 4)
476  chamberId = CSCDetId(cscid.endcap(), 1, 1, cscid.chamber(), 0);
477 
478  if (chamberId != m_id_i && chamberId != m_id_j) {
479  int station = (cscid.endcap() == 1 ? 1 : -1) * cscid.station();
480  if (stations.find(station) == stations.end()) {
481  stations[station] = 0;
482  }
483  stations[station]++;
484 
485  cscHits.push_back(measurement->recHit());
486  }
487  }
488  }
489 
490  // for the fit to be reliable, it needs to cross multiple stations
491  int numStations = 0;
492  for (std::map<int, int>::const_iterator station = stations.begin(); station != stations.end(); ++station) {
493  if (station->second >= m_parent->m_minHitsPerChamber) {
494  numStations++;
495  }
496  }
497 
498  if (numStations >= m_parent->m_minStationsInTrackRefits) {
499  // refit the track with these hits
500  std::vector<Trajectory> trajectories = trackTransformer->transform(track, cscHits);
501 
502  if (!trajectories.empty()) {
503  const std::vector<TrajectoryMeasurement> &measurements2 = trajectories.begin()->measurements();
504 
505  // find the closest TSOS to the Z plane (on both sides)
506  bool found_plus = false;
507  bool found_minus = false;
508  TrajectoryStateOnSurface tsos_plus, tsos_minus;
509  for (std::vector<TrajectoryMeasurement>::const_iterator measurement = measurements2.begin();
510  measurement != measurements2.end();
511  ++measurement) {
512  double z = measurement->recHit()->globalPosition().z();
513  if (z > m_Zplane) {
514  if (!found_plus || fabs(z - m_Zplane) < fabs(tsos_plus.globalPosition().z() - m_Zplane)) {
515  tsos_plus = TrajectoryStateCombiner().combine(measurement->forwardPredictedState(),
516  measurement->backwardPredictedState());
517  }
518  if (tsos_plus.isValid())
519  found_plus = true;
520  } else {
521  if (!found_minus || fabs(z - m_Zplane) < fabs(tsos_minus.globalPosition().z() - m_Zplane)) {
522  tsos_minus = TrajectoryStateCombiner().combine(measurement->forwardPredictedState(),
523  measurement->backwardPredictedState());
524  }
525  if (tsos_minus.isValid())
526  found_minus = true;
527  }
528  }
529 
530  // propagate from the closest TSOS to the Z plane (from both sides, if possible)
531  TrajectoryStateOnSurface from_plus, from_minus;
532  if (found_plus) {
533  from_plus = m_propagator->propagate(tsos_plus, *m_Zsurface);
534  }
535  if (found_minus) {
536  from_minus = m_propagator->propagate(tsos_minus, *m_Zsurface);
537  }
538 
539  // if you have two sides, merge them
541  if (found_plus && from_plus.isValid() && found_minus && from_minus.isValid()) {
542  merged = TrajectoryStateCombiner().combine(from_plus, from_minus);
543  } else if (found_plus && from_plus.isValid()) {
544  merged = from_plus;
545  } else if (found_minus && from_minus.isValid()) {
546  merged = from_minus;
547  } else
548  return false;
549 
550  // if, after all that, we have a good fit-and-propagation, report the direction
551  if (merged.isValid()) {
552  double angle = merged.globalPosition().phi() + M_PI / 2.;
553  GlobalVector direction = merged.globalDirection();
554  double dxdz = direction.x() / direction.z();
555  double dydz = direction.y() / direction.z();
556  dphidz = (dxdz * cos(angle) + dydz * sin(angle)) / merged.globalPosition().perp();
557  return true;
558  }
559 
560  } // end if refit successful
561  } // end if enough hits
562  return false;
563 }
float dydz
T perp() const
Definition: PV3DBase.h:69
float dxdz
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:17
GlobalVector globalDirection() const
CSCOverlapsAlignmentAlgorithm * m_parent
static constexpr int CSC
Definition: MuonSubdetId.h:12
std::vector< Trajectory > transform(const reco::Track &) const override
Convert a reco::Track into Trajectory.
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ error()

double CSCPairResidualsConstraint::error ( ) const
overridevirtual

Reimplemented from CSCPairConstraint.

Definition at line 20 of file CSCPairResidualsConstraint.cc.

References cms::cuda::assert(), dumpMFGeometry_cfg::delta, kModePhiPos, kModePhiy, kModePhiz, kModeRadius, CSCOverlapsAlignmentAlgorithm::m_errorFromRMS, CSCOverlapsAlignmentAlgorithm::m_mode, m_parent, m_sum1, m_sumN, m_sumx, m_sumxx, m_sumy, m_sumyy, funct::pow(), and mathSSE::sqrt().

Referenced by Page1Parser.Page1Parser::check_for_whole_start_tag().

20  {
21  if (m_parent->m_errorFromRMS) {
22  assert(m_sum1 > 0.);
23  return sqrt((m_sumyy / m_sum1) - pow(m_sumy / m_sum1, 2)) / sqrt(m_sumN);
24  } else {
25  double delta = (m_sum1 * m_sumxx) - (m_sumx * m_sumx);
26  assert(delta > 0.);
28  return sqrt(m_sumxx / delta);
29  } else if (m_parent->m_mode == kModePhiz) {
30  return sqrt(m_sum1 / delta);
31  } else
32  assert(false);
33  }
34 }
assert(be >=bs)
T sqrt(T t)
Definition: SSEVec.h:23
CSCOverlapsAlignmentAlgorithm * m_parent
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ id_i()

CSCDetId CSCPairResidualsConstraint::id_i ( ) const
inline

Definition at line 54 of file CSCPairResidualsConstraint.h.

References m_id_i.

Referenced by CSCChamberFitter::radiusCorrection().

◆ id_j()

CSCDetId CSCPairResidualsConstraint::id_j ( ) const
inline

Definition at line 55 of file CSCPairResidualsConstraint.h.

References m_id_j.

◆ isFiducial()

bool CSCPairResidualsConstraint::isFiducial ( std::vector< const TransientTrackingRecHit *> &  hits,
bool  is_i 
)
protected

Definition at line 692 of file CSCPairResidualsConstraint.cc.

References cms::cuda::assert(), calculatePhi(), dumpMFGeometry_cfg::delta, hfClusterShapes_cfi::hits, CSCGeometry::idToDet(), m_cscGeometry, CSCOverlapsAlignmentAlgorithm::m_fiducial_ME11, CSCOverlapsAlignmentAlgorithm::m_fiducial_ME12, CSCOverlapsAlignmentAlgorithm::m_fiducial_MEx1, CSCOverlapsAlignmentAlgorithm::m_fiducial_MEx2, m_id_i, m_id_j, m_iZ1, m_iZ6, m_jZ1, m_jZ6, CSCOverlapsAlignmentAlgorithm::m_makeHistograms, m_parent, CSCOverlapsAlignmentAlgorithm::m_useHitWeights, phi, CSCDetId::ring(), slope, mathSSE::sqrt(), CSCDetId::station(), GeomDet::surface(), toLocal(), mps_merge::weight, and z.

Referenced by addTrack().

692  {
693  // these constants are related to the way CSC chambers are built--- really constant!
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;
698 
699  double sum1 = 0.;
700  double sumx = 0.;
701  double sumy = 0.;
702  double sumxx = 0.;
703  double sumxy = 0.;
704  for (std::vector<const TransientTrackingRecHit *>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
705  double phi, phierr2;
706  calculatePhi(*hit, phi, phierr2);
707  double z = (is_i ? m_cscGeometry->idToDet(m_id_i)->surface() : m_cscGeometry->idToDet(m_id_j)->surface())
708  .toLocal((*hit)->globalPosition())
709  .z();
710 
711  if (m_parent->m_makeHistograms) {
712  if (m_id_i.station() == 1 && (m_id_i.ring() == 1 || m_id_i.ring() == 4)) {
713  m_parent->m_fiducial_ME11->Fill(fabs(phi), sqrt(phierr2));
714  } else if (m_id_i.station() == 1 && m_id_i.ring() == 2) {
715  m_parent->m_fiducial_ME12->Fill(fabs(phi), sqrt(phierr2));
716  } else if (m_id_i.station() > 1 && m_id_i.ring() == 1) {
717  m_parent->m_fiducial_MEx1->Fill(fabs(phi), sqrt(phierr2));
718  } else if (m_id_i.station() > 1 && m_id_i.ring() == 2) {
719  m_parent->m_fiducial_MEx2->Fill(fabs(phi), sqrt(phierr2));
720  }
721  }
722 
723  double weight = 1.;
725  weight = 1. / phierr2;
726  sum1 += weight;
727  sumx += weight * z;
728  sumy += weight * phi;
729  sumxx += weight * z * z;
730  sumxy += weight * z * phi;
731  }
732  double delta = (sum1 * sumxx) - (sumx * sumx);
733  if (delta == 0.)
734  return false;
735  double intercept = ((sumxx * sumy) - (sumx * sumxy)) / delta;
736  double slope = ((sum1 * sumxy) - (sumx * sumy)) / delta;
737 
738  double phi1 = intercept + slope * (is_i ? m_iZ1 : m_jZ1);
739  double phi6 = intercept + slope * (is_i ? m_iZ6 : m_jZ6);
740 
741  if (m_id_i.station() == 1 && (m_id_i.ring() == 1 || m_id_i.ring() == 4)) {
742  return (fabs(phi1) < cut_ME11 && fabs(phi6) < cut_ME11);
743  } else if (m_id_i.station() == 1 && m_id_i.ring() == 2) {
744  return (fabs(phi1) < cut_ME12 && fabs(phi6) < cut_ME12);
745  } else if (m_id_i.station() > 1 && m_id_i.ring() == 1) {
746  return (fabs(phi1) < cut_MEx1 && fabs(phi6) < cut_MEx1);
747  } else if (m_id_i.station() > 1 && m_id_i.ring() == 2) {
748  return (fabs(phi1) < cut_MEx2 && fabs(phi6) < cut_MEx2);
749  } else
750  assert(false);
751 }
static const double slope[3]
Definition: weight.py:1
assert(be >=bs)
T sqrt(T t)
Definition: SSEVec.h:23
void calculatePhi(const TransientTrackingRecHit *hit, double &phi, double &phierr2, bool doRphi=false, bool globalPhi=false)
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
int station() const
Definition: CSCDetId.h:79
CSCOverlapsAlignmentAlgorithm * m_parent
int ring() const
Definition: CSCDetId.h:68
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91

◆ radius()

double CSCPairResidualsConstraint::radius ( bool  is_i) const
inline

Definition at line 57 of file CSCPairResidualsConstraint.h.

References CSCGeometry::idToDet(), m_cscGeometry, m_id_i, m_id_j, PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), and GeomDet::surface().

Referenced by CSCChamberFitter::radiusCorrection().

57  {
58  return m_cscGeometry->idToDet((is_i ? m_id_i : m_id_j))->surface().position().perp();
59  };
T perp() const
Definition: PV3DBase.h:69
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91

◆ read()

void CSCPairResidualsConstraint::read ( std::vector< std::ifstream *> &  input,
std::vector< std::string > &  filenames 
)

Definition at line 572 of file CSCPairResidualsConstraint.cc.

References Exception, corrVsCorr::filename, CSCPairConstraint::i(), input, CSCPairConstraint::j(), CSCPairConstraint::m_i, m_identifier, CSCPairConstraint::m_j, m_sum1, m_sumN, m_sumx, m_sumxx, m_sumxy, m_sumy, m_sumyy, Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

572  {
573  m_sumN = 0;
574  m_sum1 = 0.;
575  m_sumx = 0.;
576  m_sumy = 0.;
577  m_sumxx = 0.;
578  m_sumyy = 0.;
579  m_sumxy = 0.;
580 
581  std::vector<std::ifstream *>::const_iterator inputiter = input.begin();
582  std::vector<std::string>::const_iterator filename = filenames.begin();
583  for (; inputiter != input.end(); ++inputiter, ++filename) {
584  int linenumber = 0;
585  bool touched = false;
586  while (!(*inputiter)->eof()) {
587  linenumber++;
588  std::string name, eoln;
589  unsigned int identifier;
590  int i, j;
591  int sumN;
592  double sum1, sumx, sumy, sumxx, sumyy, sumxy;
593 
594  (**inputiter) >> name >> identifier >> i >> j >> sumN >> sum1 >> sumx >> sumy >> sumxx >> sumyy >> sumxy >> eoln;
595 
596  if (!(*inputiter)->eof() && (name != "CSCPairResidualsConstraint" || eoln != "EOLN"))
597  throw cms::Exception("CorruptTempFile")
598  << "Temporary file " << *filename << " is incorrectly formatted on line " << linenumber << std::endl;
599 
600  if (identifier == m_identifier) {
601  if (i != m_i || j != m_j)
602  throw cms::Exception("CorruptTempFile")
603  << "Wrong (i,j) for CSCPairResidualsConstraint " << m_identifier << " (" << m_i << "," << m_j
604  << ") in file " << *filename << " on line " << linenumber << std::endl;
605  touched = true;
606 
607  m_sumN += sumN;
608  m_sum1 += sum1;
609  m_sumx += sumx;
610  m_sumy += sumy;
611  m_sumxx += sumxx;
612  m_sumyy += sumyy;
613  m_sumxy += sumxy;
614  }
615  }
616 
617  (*inputiter)->clear();
618  (*inputiter)->seekg(0, std::ios::beg);
619 
620  if (!touched)
621  throw cms::Exception("CorruptTempFile")
622  << "CSCPairResidualsConstraint " << m_identifier << " is missing from file " << *filename << std::endl;
623  }
624 }
static std::string const input
Definition: EdmProvDump.cc:50
virtual int j() const
virtual int i() const

◆ setPropagator()

void CSCPairResidualsConstraint::setPropagator ( const Propagator propagator)

◆ setZplane()

void CSCPairResidualsConstraint::setZplane ( const CSCGeometry cscGeometry)

Definition at line 62 of file CSCPairResidualsConstraint.cc.

References Plane::build(), CSCDetId::chamber(), CSCDetId::endcap(), testProducerWithPsetDescEmpty_cfi::i1, CSCGeometry::idToDet(), m_averageRadius, m_cscGeometry, m_id_i, m_id_j, m_iZ, m_iZ1, m_iZ6, m_jZ, m_jZ1, m_jZ6, m_Zplane, m_Zsurface, PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), CSCDetId::ring(), CSCDetId::station(), GeomDet::surface(), GloballyPositioned< T >::toLocal(), z, and PV3DBase< T, PVType, FrameType >::z().

62  {
63  m_cscGeometry = cscGeometry;
64 
67  2.;
70  2.;
71 
74 
83 
85 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
LocalPoint toLocal(const GlobalPoint &gp) const
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
int chamber() const
Definition: CSCDetId.h:62
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const
int station() const
Definition: CSCDetId.h:79
int endcap() const
Definition: CSCDetId.h:85
int ring() const
Definition: CSCDetId.h:68
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91

◆ valid()

bool CSCPairResidualsConstraint::valid ( ) const
overridevirtual

◆ value()

double CSCPairResidualsConstraint::value ( ) const
overridevirtual

Reimplemented from CSCPairConstraint.

Definition at line 9 of file CSCPairResidualsConstraint.cc.

References cms::cuda::assert(), dumpMFGeometry_cfg::delta, kModePhiPos, kModePhiy, kModePhiz, kModeRadius, CSCOverlapsAlignmentAlgorithm::m_mode, m_parent, m_sum1, m_sumx, m_sumxx, m_sumxy, and m_sumy.

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), average.Average::average(), Types.string::configValue(), Types.FileInPath::configValue(), Mixins.UsingBlock::dumpPython(), Mixins.UsingBlock::insertInto(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), and CSCChamberFitter::radiusCorrection().

9  {
10  double delta = (m_sum1 * m_sumxx) - (m_sumx * m_sumx);
11  assert(delta > 0.);
13  return ((m_sumxx * m_sumy) - (m_sumx * m_sumxy)) / delta;
14  } else if (m_parent->m_mode == kModePhiz) {
15  return ((m_sum1 * m_sumxy) - (m_sumx * m_sumy)) / delta;
16  } else
17  assert(false);
18 }
assert(be >=bs)
CSCOverlapsAlignmentAlgorithm * m_parent

◆ write()

void CSCPairResidualsConstraint::write ( std::ofstream &  output)

Definition at line 565 of file CSCPairResidualsConstraint.cc.

References alignBH_cfg::fixed, CSCPairConstraint::i(), CSCPairConstraint::j(), m_identifier, m_sum1, m_sumN, m_sumx, m_sumxx, m_sumxy, m_sumy, and m_sumyy.

Referenced by pkg.AbstractPkg::generate(), and querying.connection::write_and_commit().

565  {
566  output << std::setprecision(14) << std::fixed;
567  output << "CSCPairResidualsConstraint " << m_identifier << " " << i() << " " << j() << " " << m_sumN << " " << m_sum1
568  << " " << m_sumx << " " << m_sumy << " " << m_sumxx << " " << m_sumyy << " " << m_sumxy << " EOLN"
569  << std::endl;
570 }
virtual int j() const
Definition: output.py:1
virtual int i() const

Member Data Documentation

◆ m_averageRadius

double CSCPairResidualsConstraint::m_averageRadius
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and setZplane().

◆ m_cscGeometry

const CSCGeometry* CSCPairResidualsConstraint::m_cscGeometry
protected

Definition at line 88 of file CSCPairResidualsConstraint.h.

Referenced by calculatePhi(), isFiducial(), radius(), and setZplane().

◆ m_id_i

CSCDetId CSCPairResidualsConstraint::m_id_i
protected

◆ m_id_j

CSCDetId CSCPairResidualsConstraint::m_id_j
protected

◆ m_identifier

unsigned int CSCPairResidualsConstraint::m_identifier
protected

Definition at line 80 of file CSCPairResidualsConstraint.h.

Referenced by configure(), read(), and write().

◆ m_iZ

double CSCPairResidualsConstraint::m_iZ
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and setZplane().

◆ m_iZ1

double CSCPairResidualsConstraint::m_iZ1
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by isFiducial(), and setZplane().

◆ m_iZ6

double CSCPairResidualsConstraint::m_iZ6
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by isFiducial(), and setZplane().

◆ m_jZ

double CSCPairResidualsConstraint::m_jZ
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and setZplane().

◆ m_jZ1

double CSCPairResidualsConstraint::m_jZ1
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by isFiducial(), and setZplane().

◆ m_jZ6

double CSCPairResidualsConstraint::m_jZ6
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by isFiducial(), and setZplane().

◆ m_offsetResiduals

TH1F* CSCPairResidualsConstraint::m_offsetResiduals
protected

Definition at line 93 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and configure().

◆ m_parent

CSCOverlapsAlignmentAlgorithm* CSCPairResidualsConstraint::m_parent
protected

◆ m_propagator

const Propagator* CSCPairResidualsConstraint::m_propagator
protected

Definition at line 89 of file CSCPairResidualsConstraint.h.

Referenced by dphidzFromTrack(), and setPropagator().

◆ m_radial

TH1F* CSCPairResidualsConstraint::m_radial
protected

Definition at line 94 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and configure().

◆ m_slopeResiduals

TH1F* CSCPairResidualsConstraint::m_slopeResiduals
protected

Definition at line 92 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), and configure().

◆ m_sum1

double CSCPairResidualsConstraint::m_sum1
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), value(), and write().

◆ m_sumN

int CSCPairResidualsConstraint::m_sumN
protected

Definition at line 83 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), valid(), and write().

◆ m_sumx

double CSCPairResidualsConstraint::m_sumx
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), value(), and write().

◆ m_sumxx

double CSCPairResidualsConstraint::m_sumxx
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), value(), and write().

◆ m_sumxy

double CSCPairResidualsConstraint::m_sumxy
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), read(), value(), and write().

◆ m_sumy

double CSCPairResidualsConstraint::m_sumy
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), value(), and write().

◆ m_sumyy

double CSCPairResidualsConstraint::m_sumyy
protected

Definition at line 82 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), error(), read(), and write().

◆ m_Zplane

double CSCPairResidualsConstraint::m_Zplane
protected

Definition at line 87 of file CSCPairResidualsConstraint.h.

Referenced by addTrack(), dphidzFromTrack(), and setZplane().

◆ m_Zsurface

Plane::PlanePointer CSCPairResidualsConstraint::m_Zsurface
protected

Definition at line 90 of file CSCPairResidualsConstraint.h.

Referenced by dphidzFromTrack(), and setZplane().