23 #define SQR(x) ((x)*(x))
26 : m_pinPositions(cfg.getParameter<std::string>(
"pinPositions"))
27 , m_rootFile(cfg.getParameter<std::string>(
"rootFile"))
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"))
43 double cosPhX, sinPhX, cosPhZ, sinPhZ;
48 LocalPoint P((LP1.x() - LP2.x())/(2.*a), (LP1.y() - LP2.y())/(2.*a), (LP1.z() - LP2.z())/(2.*a));
49 LocalPoint Pp((LP1.x() + LP2.x())/(2.), (LP1.y() + LP2.y())/(2.), (LP1.z() + LP2.z())/(2.));
55 cosPhZ=
P.y()/(T*cosPhX);
56 sinPhZ=-
P.x()/(T*cosPhZ);
58 PhX=atan2(sinPhX,cosPhX);
60 PhZ=atan2(sinPhZ,cosPhZ);
62 dx=Pp.x()-sinPhZ*sinPhX*
b;
63 dy=Pp.y()+cosPhZ*sinPhX*
b;
67 void SurveyInputCSCfromPins::errors(
double a,
double b,
bool missing1,
bool missing2,
double &dx_dx,
double &dy_dy,
double &dz_dz,
double &phix_phix,
double &phiz_phiz,
double &dy_phix) {
75 const double trials = 10000.;
77 for (
int i = 0;
i < trials;
i++) {
93 double dx, dy, dz, PhX, PhZ,
T;
94 orient(LC1, LC2, a, b, T, dx, dy, dz, PhX, PhZ);
99 phix_phix += PhX * PhX;
100 phiz_phiz += PhZ * PhZ;
116 edm::LogInfo(
"SurveyInputCSCfromPins") <<
"***************ENTERING INITIALIZATION******************" <<
" \n";
121 Double_t x1, y1, z1, x2, y2, z2,
a,
b, tot=0.0, maxErr=0.0,
h, s1, dx, dy, dz, PhX, PhZ,
T;
123 int ID1, ID2, ID3, ID4, ID5,
i=1, ii=0;
126 TTree *tree1 =
new TTree(
"tree1",
"alignment pins");
130 tree1->Branch(
"displacement_x_pin1_cm", &x1,
"x1/D");
131 tree1->Branch(
"displacement_y_pin1_cm", &y1,
"y1/D");
132 tree1->Branch(
"displacement_z_pin1_cm", &z1,
"z1/D");
133 tree1->Branch(
"displacement_x_pin2_cm", &x2,
"x2/D");
134 tree1->Branch(
"displacement_y_pin2_cm", &y2,
"y2/D");
135 tree1->Branch(
"displacement_z_pin2_cm", &z2,
"z2/D");
136 tree1->Branch(
"error_vector_length_cm",&
h,
"h/D");
137 tree1->Branch(
"stretch_diff_cm",&s1,
"s1/D");
138 tree1->Branch(
"stretch_factor",&T,
"T/D");
139 tree1->Branch(
"chamber_displacement_x_cm",&dx,
"dx/D");
140 tree1->Branch(
"chamber_displacement_y_cm",&dy,
"dy/D");
141 tree1->Branch(
"chamber_displacement_z_cm",&dz,
"dz/D");
142 tree1->Branch(
"chamber_rotation_x_rad",&PhX,
"PhX/D");
143 tree1->Branch(
"chamber_rotation_z_rad",&PhZ,
"PhZ/D");
154 std::vector<Alignable*> theEndcaps = theAlignableMuon->
CSCEndcaps();
156 for (std::vector<Alignable*>::const_iterator aliiter = theEndcaps.begin(); aliiter != theEndcaps.end(); ++aliiter) {
164 bool missing1 =
false;
165 bool missing2 =
false;
167 in >> ID1 >> ID2 >> ID3 >> ID4 >> ID5 >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> a >>
b;
169 if (fabs(x1 - 1000.) < 1e5 && fabs(y1 - 1000.) < 1e5 && fabs(z1 - 1000.) < 1e5) {
176 if (fabs(x2 - 1000.) < 1e5 && fabs(y2 - 1000.) < 1e5 && fabs(z2 - 1000.) < 1e5) {
190 CSCDetId layerID(ID1, ID2, ID3, ID4, 1);
201 orient(LC1, LC2, a, b, T, dx, dy, dz, PhX, PhZ);
209 chamberAli->
move( gvector );
214 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
215 errors(a, b, missing1, missing2, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
220 error(3,3) = phix_phix;
222 error(5,5) = phiz_phiz;
223 error(1,3) = dy_phix;
224 error(3,1) = dy_phix;
230 edm::LogInfo(
"SurveyInputCSCfromPins") <<
" survey information = " << chamberAli->
survey() <<
" \n";
239 if (h>maxErr) { maxErr=
h;
245 <<
"i " << i++ <<
" " << ID1 <<
" " << ID2 <<
" " << ID3 <<
" " << ID4 <<
" " << ID5 <<
" error " << h <<
" \n"
246 <<
" x1 " << x1 <<
" y1 " << y1 <<
" z1 " << z1 <<
" x2 " << x2 <<
" y2 " << y2 <<
" z2 " << z2 <<
" \n"
247 <<
" error " << h <<
" S1 " << s1 <<
" \n"
248 <<
" dx " << dx <<
" dy " << dy <<
" dz " << dz <<
" PhX " << PhX <<
" PhZ " << PhZ <<
" \n";
262 edm::LogInfo(
"SurveyInputCSCfromPins") <<
" Total error " << tot <<
" Max Error " << maxErr <<
" N " << ii <<
" \n";
267 for (std::vector<Alignable*>::const_iterator aliiter = theEndcaps.begin(); aliiter != theEndcaps.end(); ++aliiter) {
272 delete theAlignableMuon;
273 delete theAlignableNavigator;
275 edm::LogInfo(
"SurveyInputCSCfromPins") <<
"*************END INITIALIZATION***************" <<
" \n";
288 if (ali_AlignableCSCChamber != 0) {
304 if (
abs(
detid.station()) == 1 &&
detid.ring() == 2) a = -90.260;
305 else if (
abs(
detid.station()) == 1 &&
detid.ring() == 3) a = -85.205;
306 else if (
abs(
detid.station()) == 2 &&
detid.ring() == 1) a = -97.855;
307 else if (
abs(
detid.station()) == 2 &&
detid.ring() == 2) a = -164.555;
308 else if (
abs(
detid.station()) == 3 &&
detid.ring() == 1) a = -87.870;
309 else if (
abs(
detid.station()) == 3 &&
detid.ring() == 2) a = -164.555;
310 else if (
abs(
detid.station()) == 4 &&
detid.ring() == 1) a = -77.890;
312 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
313 errors(a, b,
true,
true, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
318 error(3,3) = phix_phix;
320 error(5,5) = phiz_phiz;
321 error(1,3) = dy_phix;
322 error(3,1) = dy_phix;
328 else if (ali_AlignableCSCStation != 0) {
347 for (std::vector<Alignable*>::const_iterator iter = components.begin(); iter != components.end(); ++iter) {
Local3DVector LocalVector
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
#define DEFINE_FWK_MODULE(type)
const SurveyDet * survey() const
Return survey info.
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
virtual Alignables components() const =0
Return vector of all direct components.
align::Alignables CSCEndcaps()
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void setSurvey(const SurveyDet *)
Set survey info.
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
math::Error< 6 >::type ErrorMatrix
Constructor of the full muon geometry.
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
Alignable * mother() const
Return pointer to container alignable (if any)
const DetId & geomDetId() const
Global3DVector GlobalVector
A muon CSC Chamber( an AlignableDet )