23 #define SQR(x) ((x) * (x))
26 : m_pinPositions(
cfg.getParameter<
std::
string>(
"pinPositions")),
28 m_verbose(
cfg.getParameter<
bool>(
"verbose")),
29 m_errorX(
cfg.getParameter<double>(
"errorX")),
30 m_errorY(
cfg.getParameter<double>(
"errorY")),
31 m_errorZ(
cfg.getParameter<double>(
"errorZ")),
32 m_missingErrorTranslation(
cfg.getParameter<double>(
"missingErrorTranslation")),
33 m_missingErrorAngle(
cfg.getParameter<double>(
"missingErrorAngle")),
34 m_stationErrorX(
cfg.getParameter<double>(
"stationErrorX")),
35 m_stationErrorY(
cfg.getParameter<double>(
"stationErrorY")),
36 m_stationErrorZ(
cfg.getParameter<double>(
"stationErrorZ")),
37 m_stationErrorPhiX(
cfg.getParameter<double>(
"stationErrorPhiX")),
38 m_stationErrorPhiY(
cfg.getParameter<double>(
"stationErrorPhiY")),
39 m_stationErrorPhiZ(
cfg.getParameter<double>(
"stationErrorPhiZ")) {}
51 double cosPhX, sinPhX, cosPhZ, sinPhZ;
56 LocalPoint P((LP1.x() - LP2.x()) / (2. *
a), (LP1.y() - LP2.y()) / (2. *
a), (LP1.z() - LP2.z()) / (2. *
a));
57 LocalPoint Pp((LP1.x() + LP2.x()) / (2.), (LP1.y() + LP2.y()) / (2.), (LP1.z() + LP2.z()) / (2.));
63 cosPhZ =
P.y() / (
T * cosPhX);
64 sinPhZ = -
P.x() / (
T * cosPhZ);
66 PhX = atan2(sinPhX, cosPhX);
68 PhZ = atan2(sinPhZ, cosPhZ);
70 dx = Pp.x() - sinPhZ * sinPhX *
b;
71 dy = Pp.y() + cosPhZ * sinPhX *
b;
72 dz = Pp.z() - cosPhX *
b;
92 const double trials = 10000.;
94 for (
int i = 0;
i < trials;
i++) {
112 double dx,
dy,
dz, PhX, PhZ,
T;
118 phix_phix += PhX * PhX;
119 phiz_phiz += PhZ * PhZ;
133 edm::LogInfo(
"SurveyInputCSCfromPins") <<
"***************ENTERING INITIALIZATION******************"
139 Double_t
x1,
y1, z1,
x2,
y2,
z2,
a,
b, tot = 0.0, maxErr = 0.0,
h, s1,
dx,
dy,
dz, PhX, PhZ,
T;
141 int ID1, ID2, ID3, ID4, ID5,
i = 1,
ii = 0;
144 TTree *tree1 =
new TTree(
"tree1",
"alignment pins");
147 tree1->Branch(
"displacement_x_pin1_cm", &
x1,
"x1/D");
148 tree1->Branch(
"displacement_y_pin1_cm", &
y1,
"y1/D");
149 tree1->Branch(
"displacement_z_pin1_cm", &z1,
"z1/D");
150 tree1->Branch(
"displacement_x_pin2_cm", &
x2,
"x2/D");
151 tree1->Branch(
"displacement_y_pin2_cm", &
y2,
"y2/D");
152 tree1->Branch(
"displacement_z_pin2_cm", &
z2,
"z2/D");
153 tree1->Branch(
"error_vector_length_cm", &
h,
"h/D");
154 tree1->Branch(
"stretch_diff_cm", &s1,
"s1/D");
155 tree1->Branch(
"stretch_factor", &
T,
"T/D");
156 tree1->Branch(
"chamber_displacement_x_cm", &
dx,
"dx/D");
157 tree1->Branch(
"chamber_displacement_y_cm", &
dy,
"dy/D");
158 tree1->Branch(
"chamber_displacement_z_cm", &
dz,
"dz/D");
159 tree1->Branch(
"chamber_rotation_x_rad", &PhX,
"PhX/D");
160 tree1->Branch(
"chamber_rotation_z_rad", &PhZ,
"PhZ/D");
171 const auto &theEndcaps = theAlignableMuon->
CSCEndcaps();
173 for (
const auto &aliiter : theEndcaps) {
178 bool missing1 =
false;
179 bool missing2 =
false;
181 in >> ID1 >> ID2 >> ID3 >> ID4 >> ID5 >>
x1 >>
y1 >> z1 >>
x2 >>
y2 >>
z2 >>
a >>
b;
183 if (fabs(
x1 - 1000.) < 1e5 && fabs(
y1 - 1000.) < 1e5 && fabs(z1 - 1000.) < 1e5) {
190 if (fabs(
x2 - 1000.) < 1e5 && fabs(
y2 - 1000.) < 1e5 && fabs(
z2 - 1000.) < 1e5) {
204 CSCDetId layerID(ID1, ID2, ID3, ID4, 1);
221 chamberAli->
move(gvector);
226 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
227 errors(
a,
b, missing1, missing2, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
232 error(3, 3) = phix_phix;
234 error(5, 5) = phiz_phiz;
235 error(1, 3) = dy_phix;
236 error(3, 1) = dy_phix;
241 edm::LogInfo(
"SurveyInputCSCfromPins") <<
" survey information = " << chamberAli->
survey() <<
" \n";
258 <<
"i " <<
i++ <<
" " << ID1 <<
" " << ID2 <<
" " << ID3 <<
" " << ID4 <<
" " << ID5 <<
" error " <<
h
260 <<
" x1 " <<
x1 <<
" y1 " <<
y1 <<
" z1 " << z1 <<
" x2 " <<
x2 <<
" y2 " <<
y2 <<
" z2 " <<
z2 <<
" \n"
261 <<
" error " <<
h <<
" S1 " << s1 <<
" \n"
262 <<
" dx " <<
dx <<
" dy " <<
dy <<
" dz " <<
dz <<
" PhX " << PhX <<
" PhZ " << PhZ <<
" \n";
275 <<
" Total error " << tot <<
" Max Error " << maxErr <<
" N " <<
ii <<
" \n";
280 for (
const auto &aliiter : theEndcaps) {
284 delete theAlignableMuon;
285 delete theAlignableNavigator;
287 edm::LogInfo(
"SurveyInputCSCfromPins") <<
"*************END INITIALIZATION***************"
295 if (ali->
survey() ==
nullptr) {
299 if (ali_AlignableCSCChamber !=
nullptr) {
301 if (
abs(detid.station()) == 1 && (detid.ring() == 1 || detid.ring() == 4)) {
314 if (
abs(detid.station()) == 1 && detid.ring() == 2)
316 else if (
abs(detid.station()) == 1 && detid.ring() == 3)
318 else if (
abs(detid.station()) == 2 && detid.ring() == 1)
320 else if (
abs(detid.station()) == 2 && detid.ring() == 2)
322 else if (
abs(detid.station()) == 3 && detid.ring() == 1)
324 else if (
abs(detid.station()) == 3 && detid.ring() == 2)
326 else if (
abs(detid.station()) == 4 && detid.ring() == 1)
329 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
330 errors(
a,
b,
true,
true, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
335 error(3, 3) = phix_phix;
337 error(5, 5) = phiz_phiz;
338 error(1, 3) = dy_phix;
339 error(3, 1) = dy_phix;
345 else if (ali_AlignableCSCStation !=
nullptr) {