CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 26 of file CSCAlignmentCorrections.h.

26 {};

Member Function Documentation

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

Definition at line 70 of file CSCAlignmentCorrections.cc.

References AlignableDetOrUnitPtr::alignable(), AlignableNavigator::alignableFromDetId(), Alignable::alignmentParameters(), AlignmentParameterStore::applyParameters(), assert(), AlignmentParameters::cloneFromSelected(), funct::cos(), alignCSCRings::e, Reference_intrackfit_cff::endcap, i, CSCPairResidualsConstraint::kModePhiPos, CSCPairResidualsConstraint::kModePhiy, CSCPairResidualsConstraint::kModePhiz, m_id, m_name, m_value, NULL, 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().

70  {
71  for (unsigned int i = 0; i < m_name.size(); i++) {
72  // CSC sign conventions
73  bool backward = ((m_id[i].endcap() == 1 && m_id[i].station() >= 3) || (m_id[i].endcap() == 2 && m_id[i].station() < 3));
74 
75  // get the alignable (or two alignables if in ME1/1)
76  const DetId id(m_id[i]);
77  Alignable *alignable = alignableNavigator->alignableFromDetId(id).alignable();
78  Alignable *also = NULL;
79  if (combineME11 && m_id[i].station() == 1 && m_id[i].ring() == 1) {
80  CSCDetId alsoid(m_id[i].endcap(), 1, 4, m_id[i].chamber(), 0);
81  const DetId alsoid2(alsoid);
82  also = alignableNavigator->alignableFromDetId(alsoid2).alignable();
83  }
84 
85  AlgebraicVector params(6);
86  AlgebraicSymMatrix cov(6);
87 
89  params[4] = m_value[i];
90  cov[4][4] = 1e-6;
91  }
93  align::GlobalPoint center = alignable->surface().toGlobal(align::LocalPoint(0., 0., 0.));
94  double radius = sqrt(center.x()*center.x() + center.y()*center.y());
95 
96  double phi_correction = m_value[i];
97  params[0] = -radius * sin(phi_correction) * (backward ? -1. : 1.);
98  params[1] = radius * (cos(phi_correction) - 1.);
99  params[5] = phi_correction * (backward ? -1. : 1.);
100 
101  cov[0][0] = 1e-6;
102  cov[1][1] = 1e-6;
103  cov[5][5] = 1e-6;
104  }
106  params[5] = m_value[i] * (backward ? -1. : 1.);
107  cov[5][5] = 1e-6;
108  }
109  else assert(false);
110 
111  AlignmentParameters *parnew = alignable->alignmentParameters()->cloneFromSelected(params, cov);
112  alignable->setAlignmentParameters(parnew);
113  alignmentParameterStore->applyParameters(alignable);
114  alignable->alignmentParameters()->setValid(true);
115  if (also != NULL) {
116  AlignmentParameters *parnew2 = also->alignmentParameters()->cloneFromSelected(params, cov);
117  also->setAlignmentParameters(parnew2);
118  alignmentParameterStore->applyParameters(also);
119  also->alignmentParameters()->setValid(true);
120  }
121  }
122 }
int i
Definition: DBlmapReader.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(m_qm.get())
T y() const
Definition: PV3DBase.h:63
#define NULL
Definition: scimark2.h:8
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:110
void setValid(bool v)
Set validity flag.
T sqrt(T t)
Definition: SSEVec.h:48
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:131
tuple combineME11
Definition: align_cfg.py:32
Definition: DetId.h:18
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
virtual AlignmentParameters * cloneFromSelected(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
T x() const
Definition: PV3DBase.h:62
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 28 of file CSCAlignmentCorrections.h.

References m_id, m_name, and m_value.

Referenced by CSCChamberFitter::fit().

28  {
29  m_name.push_back(name);
30  m_id.push_back(id);
31  m_value.push_back(value);
32  };
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 34 of file CSCAlignmentCorrections.h.

References m_coefficient, m_error, m_modeid, and m_modename.

Referenced by CSCChamberFitter::fit().

34  {
35  m_coefficient.push_back(coefficient);
36  m_modename.push_back(modename);
37  m_modeid.push_back(modeid);
38  m_error.push_back(error);
39  };
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 41 of file CSCAlignmentCorrections.h.

References m_before, m_i, m_j, m_pull, m_residual, and m_uncert.

Referenced by CSCChamberFitter::fit().

41  {
42  m_i.push_back(i);
43  m_j.push_back(j);
44  m_before.push_back(before);
45  m_uncert.push_back(uncert);
46  m_residual.push_back(residual);
47  m_pull.push_back(pull);
48  };
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > m_i
std::vector< double > m_before
int j
Definition: DBlmapReader.cc:9
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 estimatePileup::hist, i, j, m_coefficient, m_error, m_fitterName, m_modeid, m_modename, TFileService::make(), AlCaHLTBitMon_QueryRunRegistry::string, and th1f_modes.

Referenced by cuy.FindIssue::__init__().

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] == '-') modifiedName[2] = 'm';
14  else if (modifiedName[2] == '+') modifiedName[2] = 'p';
15  if (modifiedName[4] == '/') modifiedName[4] = '_';
16  if (modifiedName[6] == '/') modifiedName[6] = '_';
17  }
18  else if (modifiedName[0] == 'Y' && modifiedName[1] == 'E') {
19  if (modifiedName[2] == '-') modifiedName[2] = 'm';
20  else if (modifiedName[2] == '+') modifiedName[2] = 'p';
21  }
22 
23  std::stringstream histname, histtitle;
24  histname << modifiedName << "_mode_" << i;
25  histtitle << m_error[i];
26 
27  TH1F *hist = tFileService->make<TH1F>(histname.str().c_str(), histtitle.str().c_str(), m_coefficient[i].size(), 0.5, m_coefficient[i].size() + 0.5);
28 
29  bool showed_full_name = false;
30  for (unsigned int j = 0; j < m_coefficient[i].size(); j++) {
31  hist->SetBinContent(j+1, m_coefficient[i][j]);
32 
33  if (m_modeid[i][j] == -1 || !showed_full_name) {
34  hist->GetXaxis()->SetBinLabel(j+1, m_modename[i][j].c_str());
35  }
36  else {
37  std::stringstream shortname;
38  shortname << m_modename[i][j][7] << m_modename[i][j][8];
39  hist->GetXaxis()->SetBinLabel(j+1, shortname.str().c_str());
40  }
41  if (m_modeid[i][j] != -1) showed_full_name = true;
42  }
43 
44  th1f_modes.push_back(hist);
45  }
46 }
int i
Definition: DBlmapReader.cc:9
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
int j
Definition: DBlmapReader.cc:9
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 48 of file CSCAlignmentCorrections.cc.

References i, 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.

48  {
49  report << "cscReports.append(CSCFitterReport(\"" << m_fitterName << "\", " << m_oldchi2 << ", " << m_newchi2 << "))" << std::endl;
50 
51  for (unsigned int i = 0; i < m_name.size(); i++) {
52  report << "cscReports[-1].addChamberCorrection(\"" << m_name[i] << "\", " << m_id[i].rawId() << ", " << m_value[i] << ")" << std::endl;
53  }
54 
55  for (unsigned int i = 0; i < m_coefficient.size(); i++) {
56  report << "cscReports[-1].addErrorMode(" << m_error[i] << ")" << std::endl;
57 
58  for (unsigned int j = 0; j < m_coefficient[i].size(); j++) {
59  report << "cscReports[-1].addErrorModeTerm(\"" << m_modename[i][j] << "\", " << m_modeid[i][j] << ", " << m_coefficient[i][j] << ")" << std::endl;
60  }
61  }
62 
63  for (unsigned int i = 0; i < m_i.size(); i++) {
64  report << "cscReports[-1].addCSCConstraintResidual(\"" << m_i[i] << "\", \"" << m_j[i] << "\", " << m_before[i] << ", " << m_uncert[i] << ", " << m_residual[i] << ", " << m_pull[i] << ")" << std::endl;
65  }
66 
67  report << std::endl;
68 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< std::string > > m_modename
void report(std::ofstream &report)
std::vector< std::string > m_i
std::vector< double > m_before
int j
Definition: DBlmapReader.cc:9
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 72 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 64 of file CSCAlignmentCorrections.h.

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

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

Definition at line 67 of file CSCAlignmentCorrections.h.

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

std::string CSCAlignmentCorrections::m_fitterName
protected

Definition at line 55 of file CSCAlignmentCorrections.h.

Referenced by plot(), and report().

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

Definition at line 70 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 60 of file CSCAlignmentCorrections.h.

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

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

Definition at line 71 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 66 of file CSCAlignmentCorrections.h.

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

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

Definition at line 65 of file CSCAlignmentCorrections.h.

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

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

Definition at line 59 of file CSCAlignmentCorrections.h.

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

double CSCAlignmentCorrections::m_newchi2
protected

Definition at line 56 of file CSCAlignmentCorrections.h.

Referenced by report().

double CSCAlignmentCorrections::m_oldchi2
protected

Definition at line 56 of file CSCAlignmentCorrections.h.

Referenced by report().

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

Definition at line 75 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 74 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 73 of file CSCAlignmentCorrections.h.

Referenced by insertResidual(), and report().

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

Definition at line 61 of file CSCAlignmentCorrections.h.

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

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

Definition at line 77 of file CSCAlignmentCorrections.h.

Referenced by plot().