3 #include "CLHEP/Vector/RotationInterfaces.h"
34 #include "CLHEP/Vector/ThreeVector.h"
44 _levelStrings(cfg.getUntrackedParameter<std::
vector<std::
string> >(
"levels")),
46 _commonMuonLevel(align::invalid),
48 idealInputLabel1(
"MuonGeometryArrangeLabel1"),
49 idealInputLabel2(
"MuonGeometryArrangeLabel2"),
50 idealInputLabel2a(
"MuonGeometryArrangeLabel2a"),
51 geomIdeal(
"MuonGeometryArrangeGeomIdeal"),
90 fin.open(_detIdFlagFile.c_str());
92 while (!fin.eof() && fin.good()) {
101 unsigned int lastID = 999999999;
103 std::ifstream inFile;
104 inFile.open(_weightByIdFile.c_str());
106 while (!inFile.eof()) {
110 inFile.ignore(256,
'\n');
111 if (listId != lastID) {
120 _theFile =
new TFile(_filename.c_str(),
"RECREATE");
121 _alignTree =
new TTree(
"alignTree",
"alignTree");
122 _alignTree->Branch(
"id", &
_id,
"id/I");
123 _alignTree->Branch(
"level", &
_level,
"level/I");
124 _alignTree->Branch(
"mid", &
_mid,
"mid/I");
125 _alignTree->Branch(
"mlevel", &
_mlevel,
"mlevel/I");
126 _alignTree->Branch(
"sublevel", &
_sublevel,
"sublevel/I");
127 _alignTree->Branch(
"x", &
_xVal,
"x/F");
128 _alignTree->Branch(
"y", &
_yVal,
"y/F");
129 _alignTree->Branch(
"z", &
_zVal,
"z/F");
130 _alignTree->Branch(
"r", &
_rVal,
"r/F");
131 _alignTree->Branch(
"phi", &
_phiVal,
"phi/F");
132 _alignTree->Branch(
"eta", &
_etaVal,
"eta/F");
133 _alignTree->Branch(
"alpha", &
_alphaVal,
"alpha/F");
134 _alignTree->Branch(
"beta", &
_betaVal,
"beta/F");
135 _alignTree->Branch(
"gamma", &
_gammaVal,
"gamma/F");
136 _alignTree->Branch(
"dx", &
_dxVal,
"dx/F");
137 _alignTree->Branch(
"dy", &
_dyVal,
"dy/F");
138 _alignTree->Branch(
"dz", &
_dzVal,
"dz/F");
139 _alignTree->Branch(
"dr", &
_drVal,
"dr/F");
140 _alignTree->Branch(
"dphi", &
_dphiVal,
"dphi/F");
141 _alignTree->Branch(
"dalpha", &
_dalphaVal,
"dalpha/F");
142 _alignTree->Branch(
"dbeta", &
_dbetaVal,
"dbeta/F");
143 _alignTree->Branch(
"dgamma", &
_dgammaVal,
"dgamma/F");
144 _alignTree->Branch(
"ldx", &
_ldxVal,
"ldx/F");
145 _alignTree->Branch(
"ldy", &
_ldyVal,
"ldy/F");
146 _alignTree->Branch(
"ldz", &
_ldzVal,
"ldz/F");
147 _alignTree->Branch(
"ldr", &
_ldrVal,
"ldr/F");
148 _alignTree->Branch(
"ldphi", &
_ldphiVal,
"ldphi/F");
149 _alignTree->Branch(
"useDetId", &
_useDetId,
"useDetId/I");
150 _alignTree->Branch(
"detDim", &
_detDim,
"detDim/I");
151 _alignTree->Branch(
"rotx", &
_rotxVal,
"rotx/F");
152 _alignTree->Branch(
"roty", &
_rotyVal,
"roty/F");
153 _alignTree->Branch(
"rotz", &
_rotzVal,
"rotz/F");
154 _alignTree->Branch(
"drotx", &
_drotxVal,
"drotx/F");
155 _alignTree->Branch(
"droty", &
_drotyVal,
"droty/F");
156 _alignTree->Branch(
"drotz", &
_drotzVal,
"drotz/F");
157 _alignTree->Branch(
"surW", &
_surWidth,
"surW/F");
158 _alignTree->Branch(
"surL", &
_surLength,
"surL/F");
159 _alignTree->Branch(
"surRot", &
_surRot,
"surRot[9]/D");
170 std::vector<float> xp(size + 1);
171 std::vector<float> yp(size + 1);
180 TGraph* grx =
nullptr;
184 for (i = 0; i <
size; i++) {
193 xp[
size] = xp[size - 1] + 1;
200 int sizeI = maxI + 1 -
minI;
201 float smi = minI - 1;
202 float sma = maxI + 1;
206 for (i = 0; i <
size; i++) {
223 "Local #delta X vs position",
232 for (i = 0; i <
size; i++) {
249 "Local #delta Y vs position",
259 for (i = 0; i <
size; i++) {
276 "Local #delta Z vs position",
286 for (i = 0; i <
size; i++) {
302 "delphi_vs_position",
303 "#delta #phi vs position",
304 "Gdelphi_vs_position",
305 "#delta #phi in radians",
313 for (i = 0; i <
size; i++) {
330 "#delta R vs position",
340 for (i = 0; i <
size; i++) {
357 "delRphi_vs_position",
358 "R #delta #phi vs position",
359 "GdelRphi_vs_position",
360 "R #delta #phi in cm",
368 for (i = 0; i <
size; i++) {
384 "delalpha_vs_position",
385 "#delta #alpha vs position",
386 "Gdelalpha_vs_position",
387 "#delta #alpha in rad",
395 for (i = 0; i <
size; i++) {
411 "delbeta_vs_position",
412 "#delta #beta vs position",
413 "Gdelbeta_vs_position",
414 "#delta #beta in rad",
422 for (i = 0; i <
size; i++) {
438 "delgamma_vs_position",
439 "#delta #gamma vs position",
440 "Gdelgamma_vs_position",
441 "#delta #gamma in rad",
449 for (i = 0; i <
size; i++) {
465 "delrotX_vs_position",
466 "#delta rotX vs position",
467 "GdelrotX_vs_position",
468 "#delta rotX in rad",
476 for (i = 0; i <
size; i++) {
492 "delrotY_vs_position",
493 "#delta rotY vs position",
494 "GdelrotY_vs_position",
495 "#delta rotY in rad",
503 for (i = 0; i <
size; i++) {
519 "delrotZ_vs_position",
520 "#delta rotZ vs position",
521 "GdelrotZ_vs_position",
522 "#delta rotZ in rad",
532 float maxR = -9999999.;
533 for (i = 0; i <
size; i++) {
543 float smallestVcm = .001;
544 if (maxV < smallestVcm)
547 float lside = 1.1 * maxR;
551 scale = .09 * lside / maxV;
554 int ret = snprintf(scalename, 50,
"#delta #bar{x} length =%f cm", maxV);
558 dxh =
new TH2F(
"vecdrplot", scalename, 80, -lside, lside, 80, -lside, lside);
560 dxh =
new TH2F(
"vecdrplot",
"delta #bar{x} Bad scale", 80, -lside, lside, 80, -lside, lside);
562 dxh->GetXaxis()->SetTitle(
"x in cm");
563 dxh->GetYaxis()->SetTitle(
"y in cm");
564 dxh->SetStats(kFALSE);
567 for (i = 0; i <
size; i++) {
573 arrow->SetLineWidth(2);
574 arrow->SetArrowSize(ttemp * .2 * .05 / maxV);
575 arrow->SetLineColor(1);
576 arrow->SetLineStyle(1);
578 dxh->GetListOfFunctions()->Add(static_cast<TObject*>(arrow));
602 if (minV >= maxV || smi >= sma || sizeI <= 1 || xp ==
nullptr || yp ==
nullptr)
605 float diff = maxV - minV;
606 float over = .05 *
diff;
607 double ylo = minV - over;
608 double yhi = maxV + over;
612 dxh =
new TH2F(name, title, sizeI + 2, dsmi, dsma, 50, ylo, yhi);
613 dxh->GetXaxis()->SetTitle(
"Position around ring");
614 dxh->GetYaxis()->SetTitle(axis);
615 dxh->SetStats(kFALSE);
617 grx =
new TGraph(size, xp, yp);
618 grx->SetName(titleg);
619 grx->SetTitle(title);
620 grx->SetMarkerColor(2);
621 grx->SetMarkerStyle(3);
622 grx->GetXaxis()->SetLimits(dsmi, dsma);
623 grx->GetXaxis()->SetTitle(
"position number");
624 grx->GetYaxis()->SetLimits(ylo, yhi);
625 grx->GetYaxis()->SetTitle(axis);
646 inputAlign1->fillGapsInSurvey(0, 0);
655 inputAlign2->fillGapsInSurvey(0, 0);
664 inputAlign2a->fillGapsInSurvey(0, 0);
668 auto inputGeometry2Copy2 = inputAlign2a->getAlignableMuon();
673 theLevels.push_back(inputGeometry2Copy2->objectIdProvider().stringToId(
level));
694 if (refAli ==
nullptr) {
697 if (curAli ==
nullptr) {
703 const auto& curComp2 = curAliCopy2->
components();
706 int nComp = refComp.size();
707 for (
int i = 0;
i < nComp;
i++) {
708 compare(refComp[
i], curComp[i], curComp2[i]);
716 if (refAli ==
nullptr) {
719 if (curAli ==
nullptr) {
733 if (refComp.size() != curComp.size()) {
742 int nComp = refComp.size();
745 CLHEP::Hep3Vector TotalX, TotalL;
746 TotalX.set(0., 0., 0.);
747 TotalL.set(0., 0., 0.);
749 std::vector<CLHEP::Hep3Vector> Positions;
750 std::vector<CLHEP::Hep3Vector> DelPositions;
752 double xrcenter = 0.;
753 double yrcenter = 0.;
754 double zrcenter = 0.;
755 double xccenter = 0.;
756 double yccenter = 0.;
757 double zccenter = 0.;
762 for (
int ich = 0; ich < nComp; ich++) {
773 originalVectors.push_back(pointsCM);
775 xrcenter += pointsCM.
x();
776 yrcenter += pointsCM.
y();
777 zrcenter += pointsCM.
z();
779 xrcenter = xrcenter / nUsed;
780 yrcenter = yrcenter / nUsed;
781 zrcenter = zrcenter / nUsed;
785 for (
int ich = 0; ich < nComp; ich++) {
796 currentVectors.push_back(pointsCM);
798 xccenter += pointsCM.
x();
799 yccenter += pointsCM.
y();
800 zccenter += pointsCM.
z();
802 xccenter = xccenter / nUsed;
803 yccenter = yccenter / nUsed;
804 zccenter = zccenter / nUsed;
809 int nCompR = currentVectors.size();
810 for (
int ich = 0; ich < nCompR; ich++) {
811 originalRelativeVectors.push_back(originalVectors[ich] - CRef);
812 currentRelativeVectors.push_back(currentVectors[ich] - CCur);
824 for (
int ich = 0; ich < nComp; ich++) {
829 CLHEP::Hep3Vector Rtotal, Wtotal;
830 Rtotal.set(0., 0., 0.);
831 Wtotal.set(0., 0., 0.);
832 for (
int i = 0;
i < 100;
i++) {
835 CLHEP::Hep3Vector dR(diff[0], diff[1], diff[2]);
837 CLHEP::Hep3Vector dW(diff[3], diff[4], diff[5]);
838 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
839 CLHEP::HepRotation drot(dW.unit(), dW.mag());
841 Wtotal.set(rot.axis().x() * rot.delta(), rot.axis().y() * rot.delta(), rot.axis().z() * rot.delta());
848 DetId detid(refComp[ich]->
id());
862 TotalX = TotalX / nUsed;
866 change(1) = TotalX.x();
867 change(2) = TotalX.y();
868 change(3) = TotalX.z();
870 change(4) = angles[0];
871 change(5) = angles[1];
872 change(6) = angles[2];
878 for (
int ich = 0; ich < nComp; ich++) {
879 CLHEP::Hep3Vector Rtotal, Wtotal;
880 Rtotal.set(0., 0., 0.);
881 Wtotal.set(0., 0., 0.);
887 for (
int i = 0;
i < 100;
i++) {
890 CLHEP::Hep3Vector dR(diff[0], diff[1], diff[2]);
892 CLHEP::Hep3Vector dW(diff[3], diff[4], diff[5]);
893 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
894 CLHEP::HepRotation drot(dW.unit(), dW.mag());
896 Wtotal.set(rot.axis().x() * rot.delta(), rot.axis().y() * rot.delta(), rot.axis().z() * rot.delta());
909 TRtot(1) = Rtotal.x();
910 TRtot(2) = Rtotal.y();
911 TRtot(3) = Rtotal.z();
912 TRtot(4) = Wtotal.x();
913 TRtot(5) = Wtotal.y();
914 TRtot(6) = Wtotal.z();
934 int ringPhiPos = -99;
949 float ttt = -rot.
xz();
980 double xx = rot.
xx();
981 double xy = rot.
xy();
982 double xz = rot.
xz();
983 double yx = rot.
yx();
984 double yy = rot.
yy();
985 double yz = rot.
yz();
986 double zx = rot.
zx();
987 double zy = rot.
zy();
988 double zz = rot.
zz();
989 double detrot = (zz * yy - zy * yz) * xx + (-zz * yx + zx * yz) * xy + (zy * yx - zx * yy) * xz;
991 double ixx = (zz * yy - zy * yz) * detrot;
992 double ixy = (-zz * xy + zy * xz) * detrot;
993 double ixz = (yz * xy - yy * xz) * detrot;
994 double iyx = (-zz * yx + zx * yz) * detrot;
995 double iyy = (zz * xx - zx * xz) * detrot;
996 double iyz = (-yz * xx + yx * xz) * detrot;
997 double izx = (zy * yx - zx * yy) * detrot;
998 double izy = (-zy * xx + zx *
xy) * detrot;
999 double izz = (yy * xx - yx *
xy) * detrot;
1004 protx = atan2(prot.
yz(), prot.
zz());
1015 if (_drotxVal > 3.141592656)
1017 if (_drotxVal < -3.141592656)
1115 for (
int i = 0;
i < 9;
i++) {
1118 holdit.
phipos = ringPhiPos;
1132 int size = aliComp.size();
1136 for (
int i = 0;
i <
size;
i++) {
1158 std::cout <<
"JNB " << ali->
id() <<
" " << cscId.endcap() <<
" " << cscId.station() <<
" " << cscId.ring() <<
" "
1188 int size = aliComp.size();
1192 for (
int i = 0;
i <
size;
i++) {
1208 for (
int i = 0;
i < nEntries;
i++) {
align::Scalar width() const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
T getUntrackedParameter(std::string const &, T const &) const
std::string _inputTreename
tuple ret
prodAgent to be discontinued
bool passChosen(Alignable *ali)
std::vector< align::StructureType > theLevels
Alignable * inputGeometry1
std::string _inputFilename1
uint16_t *__restrict__ id
void compareGeometries(Alignable *refAli, Alignable *curAli, Alignable *curAliCopy2)
bool isMother(Alignable *ali)
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
MuonGeometryArrange(const edm::ParameterSet &)
Do nothing. Required by framework.
constexpr uint32_t rawId() const
get the raw id
bool checkChosen(Alignable *ali)
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
const RotationType & globalRotation() const
Return the global orientation of the object.
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken3_
void analyze(const edm::Event &, const edm::EventSetup &) override
void createPoints(GlobalVectors *Vs, Alignable *ali, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
MuonAlignment * inputAlign2a
MuonAlignment * inputAlign2
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken3_
RotationType diffRot(const GlobalVectors ¤t, const GlobalVectors &nominal)
std::vector< unsigned int > _weightByIdVector
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken2_
std::string _inputXMLReference
bool getData(T &iHolder) const
void createROOTGeometry(const edm::EventSetup &iSetup)
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken1_
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
void makeGraph(int sizeI, float smi, float sma, float minV, float maxV, TH2F *dxh, TGraph *grx, const char *name, const char *title, const char *titleg, const char *axis, const float *xp, const float *yp, int numEntries)
void compare(Alignable *refAli, Alignable *curAli, Alignable *curAliCopy2)
std::string _inputFilename2
bool readModuleList(unsigned int, unsigned int, const std::vector< unsigned int > &)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken2_
std::string _weightByIdFile
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
virtual const Alignables & components() const =0
Return vector of all direct components.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
MuonAlignment * inputAlign1
GlobalVector centerOfMass(const GlobalVectors &theVs)
Find the CM of a set of points.
void fillTree(Alignable *refAli, const AlgebraicVector &diff)
Log< level::Info, false > LogInfo
Basic2DVector< T > xy() const
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
align::Scalar length() const
const std::vector< std::string > _levelStrings
AlignableMuon * referenceMuon
std::vector< GlobalVector > GlobalVectors
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken1_
AlignableMuon * currentMuon
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
std::string _detIdFlagFile
Alignable * inputGeometry2
const PositionType & globalPosition() const
Return the global position of the object.
std::string _inputXMLCurrent
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken2_
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
Alignable * mother() const
Return pointer to container alignable (if any)
const DetId & geomDetId() const
tuple size
Write out results.
void beginJob() override
Read from DB and print survey info.
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken1_
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken3_
std::vector< uint32_t > _detIdFlagVector
constexpr Detector det() const
get the detector field from this detid
std::vector< MGACollection > _mgacollection