CMS 3D CMS Logo

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

#include <CSCAlignmentCorrections.h>

Public Member Functions

void applyAlignment (AlignableNavigator *alignableNavigator, AlignmentParameterStore *alignmentParameterStore, int mode, bool combineME11)
 
 CSCAlignmentCorrections (std::string fitterName, double oldchi2, double newchi2)
 
void insertCorrection (std::string name, CSCDetId id, double value)
 
void insertMode (const std::vector< double > &coefficient, const std::vector< std::string > &modename, const std::vector< long > &modeid, double error)
 
void insertResidual (std::string i, std::string j, double before, double uncert, double residual, double pull)
 
void plot ()
 
void report (std::ofstream &report)
 
virtual ~CSCAlignmentCorrections ()
 

Protected Attributes

std::vector< double > m_before
 
std::vector< std::vector< double > > m_coefficient
 
std::vector< double > m_error
 
std::string m_fitterName
 
std::vector< std::string > m_i
 
std::vector< CSCDetIdm_id
 
std::vector< std::string > m_j
 
std::vector< std::vector< long > > m_modeid
 
std::vector< std::vector< std::string > > m_modename
 
std::vector< std::string > m_name
 
double m_newchi2
 
double m_oldchi2
 
std::vector< double > m_pull
 
std::vector< double > m_residual
 
std::vector< double > m_uncert
 
std::vector< double > m_value
 
std::vector< TH1F * > th1f_modes
 

Detailed Description

Date
2010/05/12 21:57:51
Revision
1.2
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 23 of file CSCAlignmentCorrections.h.

Constructor & Destructor Documentation

CSCAlignmentCorrections::CSCAlignmentCorrections ( std::string  fitterName,
double  oldchi2,
double  newchi2 
)
inline

Definition at line 25 of file CSCAlignmentCorrections.h.

virtual CSCAlignmentCorrections::~CSCAlignmentCorrections ( )
inlinevirtual

Definition at line 27 of file CSCAlignmentCorrections.h.

27 {};

Member Function Documentation

void CSCAlignmentCorrections::applyAlignment ( AlignableNavigator alignableNavigator,
AlignmentParameterStore alignmentParameterStore,
int  mode,
bool  combineME11 
)

Definition at line 80 of file CSCAlignmentCorrections.cc.

References AlignableDetOrUnitPtr::alignable(), AlignableNavigator::alignableFromDetId(), Alignable::alignmentParameters(), AlignmentParameterStore::applyParameters(), relativeConstraints::chamber, AlignmentParameters::cloneFromSelected(), funct::cos(), MillePedeFileConverter_cfg::e, makeMuonMisalignmentScenario::endcap, mps_fire::i, triggerObjects_cff::id, CSCPairResidualsConstraint::kModePhiPos, CSCPairResidualsConstraint::kModePhiy, CSCPairResidualsConstraint::kModePhiz, m_id, m_name, m_value, CalibrationSummaryClient_cfi::params, CosmicsPD_Skims::radius, relativeConstraints::ring, Alignable::setAlignmentParameters(), AlignmentParameters::setValid(), funct::sin(), mathSSE::sqrt(), relativeConstraints::station, Alignable::surface(), AlignableSurface::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by insertResidual().

83  {
84  for (unsigned int i = 0; i < m_name.size(); i++) {
85  // CSC sign conventions
86  bool backward =
87  ((m_id[i].endcap() == 1 && m_id[i].station() >= 3) || (m_id[i].endcap() == 2 && m_id[i].station() < 3));
88 
89  // get the alignable (or two alignables if in ME1/1)
90  const DetId id(m_id[i]);
91  Alignable *alignable = alignableNavigator->alignableFromDetId(id).alignable();
92  Alignable *also = nullptr;
93  if (combineME11 && m_id[i].station() == 1 && m_id[i].ring() == 1) {
94  CSCDetId alsoid(m_id[i].endcap(), 1, 4, m_id[i].chamber(), 0);
95  const DetId alsoid2(alsoid);
96  also = alignableNavigator->alignableFromDetId(alsoid2).alignable();
97  }
98 
100  AlgebraicSymMatrix cov(6);
101 
103  params[4] = m_value[i];
104  cov[4][4] = 1e-6;
106  align::GlobalPoint center = alignable->surface().toGlobal(align::LocalPoint(0., 0., 0.));
107  double radius = sqrt(center.x() * center.x() + center.y() * center.y());
108 
109  double phi_correction = m_value[i];
110  params[0] = -radius * sin(phi_correction) * (backward ? -1. : 1.);
111  params[1] = radius * (cos(phi_correction) - 1.);
112  params[5] = phi_correction * (backward ? -1. : 1.);
113 
114  cov[0][0] = 1e-6;
115  cov[1][1] = 1e-6;
116  cov[5][5] = 1e-6;
118  params[5] = m_value[i] * (backward ? -1. : 1.);
119  cov[5][5] = 1e-6;
120  } else
121  assert(false);
122 
123  AlignmentParameters *parnew = alignable->alignmentParameters()->cloneFromSelected(params, cov);
124  alignable->setAlignmentParameters(parnew);
125  alignmentParameterStore->applyParameters(alignable);
126  alignable->alignmentParameters()->setValid(true);
127  if (also != nullptr) {
129  also->setAlignmentParameters(parnew2);
130  alignmentParameterStore->applyParameters(also);
131  also->alignmentParameters()->setValid(true);
132  }
133  }
134 }
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
tuple combineME11
Definition: align_cfg.py:32
T y() const
Definition: PV3DBase.h:60
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:123
void setValid(bool v)
Set validity flag.
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
Definition: DetId.h:17
CLHEP::HepVector AlgebraicVector
std::vector< double > m_value
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< CSCDetId > m_id
T x() const
Definition: PV3DBase.h:59
std::vector< std::string > m_name
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
void CSCAlignmentCorrections::insertCorrection ( std::string  name,
CSCDetId  id,
double  value 
)
inline

Definition at line 29 of file CSCAlignmentCorrections.h.

References m_id, m_name, and m_value.

Referenced by CSCChamberFitter::fit().

29  {
30  m_name.push_back(name);
31  m_id.push_back(id);
32  m_value.push_back(value);
33  };
Definition: value.py:1
std::vector< double > m_value
std::vector< CSCDetId > m_id
std::vector< std::string > m_name
void CSCAlignmentCorrections::insertMode ( const std::vector< double > &  coefficient,
const std::vector< std::string > &  modename,
const std::vector< long > &  modeid,
double  error 
)
inline

Definition at line 35 of file CSCAlignmentCorrections.h.

References m_coefficient, m_error, m_modeid, and m_modename.

Referenced by CSCChamberFitter::fit().

38  {
39  m_coefficient.push_back(coefficient);
40  m_modename.push_back(modename);
41  m_modeid.push_back(modeid);
42  m_error.push_back(error);
43  };
std::vector< std::vector< std::string > > m_modename
std::vector< std::vector< double > > m_coefficient
std::vector< std::vector< long > > m_modeid
std::vector< double > m_error
void CSCAlignmentCorrections::insertResidual ( std::string  i,
std::string  j,
double  before,
double  uncert,
double  residual,
double  pull 
)
inline

Definition at line 45 of file CSCAlignmentCorrections.h.

References applyAlignment(), align_cfg::combineME11, m_before, m_i, m_j, m_pull, m_residual, m_uncert, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, plot(), and report().

Referenced by CSCChamberFitter::fit().

45  {
46  m_i.push_back(i);
47  m_j.push_back(j);
48  m_before.push_back(before);
49  m_uncert.push_back(uncert);
50  m_residual.push_back(residual);
51  m_pull.push_back(pull);
52  };
std::vector< std::string > m_i
std::vector< double > m_before
std::vector< double > m_residual
std::vector< double > m_uncert
std::vector< double > m_pull
std::vector< std::string > m_j
void CSCAlignmentCorrections::plot ( )

Definition at line 7 of file CSCAlignmentCorrections.cc.

References compare::hist, mps_fire::i, dqmiolumiharvest::j, m_coefficient, m_error, m_fitterName, m_modeid, m_modename, TFileService::make(), AlCaHLTBitMon_QueryRunRegistry::string, and th1f_modes.

Referenced by insertResidual().

7  {
8  edm::Service<TFileService> tFileService;
9 
10  for (unsigned int i = 0; i < m_coefficient.size(); i++) {
11  std::string modifiedName = m_fitterName;
12  if (modifiedName[0] == 'M' && modifiedName[1] == 'E') {
13  if (modifiedName[2] == '-')
14  modifiedName[2] = 'm';
15  else if (modifiedName[2] == '+')
16  modifiedName[2] = 'p';
17  if (modifiedName[4] == '/')
18  modifiedName[4] = '_';
19  if (modifiedName[6] == '/')
20  modifiedName[6] = '_';
21  } else if (modifiedName[0] == 'Y' && modifiedName[1] == 'E') {
22  if (modifiedName[2] == '-')
23  modifiedName[2] = 'm';
24  else if (modifiedName[2] == '+')
25  modifiedName[2] = 'p';
26  }
27 
28  std::stringstream histname, histtitle;
29  histname << modifiedName << "_mode_" << i;
30  histtitle << m_error[i];
31 
32  TH1F *hist = tFileService->make<TH1F>(
33  histname.str().c_str(), histtitle.str().c_str(), m_coefficient[i].size(), 0.5, m_coefficient[i].size() + 0.5);
34 
35  bool showed_full_name = false;
36  for (unsigned int j = 0; j < m_coefficient[i].size(); j++) {
37  hist->SetBinContent(j + 1, m_coefficient[i][j]);
38 
39  if (m_modeid[i][j] == -1 || !showed_full_name) {
40  hist->GetXaxis()->SetBinLabel(j + 1, m_modename[i][j].c_str());
41  } else {
42  std::stringstream shortname;
43  shortname << m_modename[i][j][7] << m_modename[i][j][8];
44  hist->GetXaxis()->SetBinLabel(j + 1, shortname.str().c_str());
45  }
46  if (m_modeid[i][j] != -1)
47  showed_full_name = true;
48  }
49 
50  th1f_modes.push_back(hist);
51  }
52 }
std::vector< std::vector< std::string > > m_modename
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< TH1F * > th1f_modes
std::vector< std::vector< double > > m_coefficient
std::vector< std::vector< long > > m_modeid
std::vector< double > m_error
void CSCAlignmentCorrections::report ( std::ofstream &  report)

Definition at line 54 of file CSCAlignmentCorrections.cc.

References mps_fire::i, dqmiolumiharvest::j, m_before, m_coefficient, m_error, m_fitterName, m_i, m_id, m_j, m_modeid, m_modename, m_name, m_newchi2, m_oldchi2, m_pull, m_residual, m_uncert, and m_value.

Referenced by insertResidual().

54  {
55  report << "cscReports.append(CSCFitterReport(\"" << m_fitterName << "\", " << m_oldchi2 << ", " << m_newchi2 << "))"
56  << std::endl;
57 
58  for (unsigned int i = 0; i < m_name.size(); i++) {
59  report << "cscReports[-1].addChamberCorrection(\"" << m_name[i] << "\", " << m_id[i].rawId() << ", " << m_value[i]
60  << ")" << std::endl;
61  }
62 
63  for (unsigned int i = 0; i < m_coefficient.size(); i++) {
64  report << "cscReports[-1].addErrorMode(" << m_error[i] << ")" << std::endl;
65 
66  for (unsigned int j = 0; j < m_coefficient[i].size(); j++) {
67  report << "cscReports[-1].addErrorModeTerm(\"" << m_modename[i][j] << "\", " << m_modeid[i][j] << ", "
68  << m_coefficient[i][j] << ")" << std::endl;
69  }
70  }
71 
72  for (unsigned int i = 0; i < m_i.size(); i++) {
73  report << "cscReports[-1].addCSCConstraintResidual(\"" << m_i[i] << "\", \"" << m_j[i] << "\", " << m_before[i]
74  << ", " << m_uncert[i] << ", " << m_residual[i] << ", " << m_pull[i] << ")" << std::endl;
75  }
76 
77  report << std::endl;
78 }
std::vector< std::vector< std::string > > m_modename
void report(std::ofstream &report)
std::vector< std::string > m_i
std::vector< double > m_before
std::vector< std::vector< double > > m_coefficient
std::vector< std::vector< long > > m_modeid
std::vector< double > m_residual
std::vector< double > m_uncert
std::vector< double > m_pull
std::vector< double > m_value
std::vector< std::string > m_j
std::vector< CSCDetId > m_id
std::vector< double > m_error
std::vector< std::string > m_name

Member Data Documentation

std::vector<double> CSCAlignmentCorrections::m_before
protected

Definition at line 79 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<std::vector<double> > CSCAlignmentCorrections::m_coefficient
protected

Definition at line 71 of file CSCAlignmentCorrections.h.

Referenced by insertMode(), plot(), and report().

std::vector<double> CSCAlignmentCorrections::m_error
protected

Definition at line 74 of file CSCAlignmentCorrections.h.

Referenced by insertMode(), plot(), and report().

std::string CSCAlignmentCorrections::m_fitterName
protected

Definition at line 62 of file CSCAlignmentCorrections.h.

Referenced by plot(), and report().

std::vector<std::string> CSCAlignmentCorrections::m_i
protected

Definition at line 77 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<CSCDetId> CSCAlignmentCorrections::m_id
protected

Definition at line 67 of file CSCAlignmentCorrections.h.

Referenced by applyAlignment(), insertCorrection(), and report().

std::vector<std::string> CSCAlignmentCorrections::m_j
protected

Definition at line 78 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<std::vector<long> > CSCAlignmentCorrections::m_modeid
protected

Definition at line 73 of file CSCAlignmentCorrections.h.

Referenced by insertMode(), plot(), and report().

std::vector<std::vector<std::string> > CSCAlignmentCorrections::m_modename
protected

Definition at line 72 of file CSCAlignmentCorrections.h.

Referenced by insertMode(), plot(), and report().

std::vector<std::string> CSCAlignmentCorrections::m_name
protected

Definition at line 66 of file CSCAlignmentCorrections.h.

Referenced by applyAlignment(), insertCorrection(), and report().

double CSCAlignmentCorrections::m_newchi2
protected

Definition at line 63 of file CSCAlignmentCorrections.h.

Referenced by report().

double CSCAlignmentCorrections::m_oldchi2
protected

Definition at line 63 of file CSCAlignmentCorrections.h.

Referenced by report().

std::vector<double> CSCAlignmentCorrections::m_pull
protected

Definition at line 82 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<double> CSCAlignmentCorrections::m_residual
protected

Definition at line 81 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<double> CSCAlignmentCorrections::m_uncert
protected

Definition at line 80 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

std::vector<double> CSCAlignmentCorrections::m_value
protected

Definition at line 68 of file CSCAlignmentCorrections.h.

Referenced by applyAlignment(), insertCorrection(), and report().

std::vector<TH1F*> CSCAlignmentCorrections::th1f_modes
protected

Definition at line 84 of file CSCAlignmentCorrections.h.

Referenced by plot().