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++) {
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 const auto& theEndcaps = theAlignableMuon->
CSCEndcaps();
156 for (
const auto& aliiter: theEndcaps) {
163 bool missing1 =
false;
164 bool missing2 =
false;
166 in >> ID1 >> ID2 >> ID3 >> ID4 >> ID5 >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> a >>
b;
168 if (fabs(x1 - 1000.) < 1e5 && fabs(y1 - 1000.) < 1e5 && fabs(z1 - 1000.) < 1e5) {
175 if (fabs(x2 - 1000.) < 1e5 && fabs(y2 - 1000.) < 1e5 && fabs(z2 - 1000.) < 1e5) {
189 CSCDetId layerID(ID1, ID2, ID3, ID4, 1);
200 orient(LC1, LC2, a, b, T, dx, dy, dz, PhX, PhZ);
208 chamberAli->
move( gvector );
213 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
214 errors(a, b, missing1, missing2, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
219 error(3,3) = phix_phix;
221 error(5,5) = phiz_phiz;
222 error(1,3) = dy_phix;
223 error(3,1) = dy_phix;
229 edm::LogInfo(
"SurveyInputCSCfromPins") <<
" survey information = " << chamberAli->
survey() <<
" \n";
238 if (h>maxErr) { maxErr=
h;
244 <<
"i " << i++ <<
" " << ID1 <<
" " << ID2 <<
" " << ID3 <<
" " << ID4 <<
" " << ID5 <<
" error " << h <<
" \n" 245 <<
" x1 " << x1 <<
" y1 " << y1 <<
" z1 " << z1 <<
" x2 " << x2 <<
" y2 " << y2 <<
" z2 " << z2 <<
" \n" 246 <<
" error " << h <<
" S1 " << s1 <<
" \n" 247 <<
" dx " << dx <<
" dy " << dy <<
" dz " << dz <<
" PhX " << PhX <<
" PhZ " << PhZ <<
" \n";
261 edm::LogInfo(
"SurveyInputCSCfromPins") <<
" Total error " << tot <<
" Max Error " << maxErr <<
" N " <<
ii <<
" \n";
266 for (
const auto& aliiter: theEndcaps) {
270 delete theAlignableMuon;
271 delete theAlignableNavigator;
273 edm::LogInfo(
"SurveyInputCSCfromPins") <<
"*************END INITIALIZATION***************" <<
" \n";
281 if (ali->
survey() ==
nullptr) {
286 if (ali_AlignableCSCChamber !=
nullptr) {
288 if (
abs(detid.station()) == 1 && (detid.ring() == 1 || detid.ring() == 4)) {
302 if (
abs(detid.station()) == 1 && detid.ring() == 2) a = -90.260;
303 else if (
abs(detid.station()) == 1 && detid.ring() == 3) a = -85.205;
304 else if (
abs(detid.station()) == 2 && detid.ring() == 1) a = -97.855;
305 else if (
abs(detid.station()) == 2 && detid.ring() == 2) a = -164.555;
306 else if (
abs(detid.station()) == 3 && detid.ring() == 1) a = -87.870;
307 else if (
abs(detid.station()) == 3 && detid.ring() == 2) a = -164.555;
308 else if (
abs(detid.station()) == 4 && detid.ring() == 1) a = -77.890;
310 double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
311 errors(a, b,
true,
true, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
316 error(3,3) = phix_phix;
318 error(5,5) = phiz_phiz;
319 error(1,3) = dy_phix;
320 error(3,1) = dy_phix;
326 else if (ali_AlignableCSCStation !=
nullptr) {
Local3DVector LocalVector
Point3DBase< Scalar, LocalTag > LocalPoint
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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 const 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.
Abs< T >::type abs(const T &t)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
void setSurvey(const SurveyDet *)
Set survey info.
std::pair< OmniClusterRef, TrackingParticleRef > P
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 )