3 #include "CLHEP/Vector/RotationInterfaces.h" 34 #include "CLHEP/Vector/ThreeVector.h" 46 _commonMuonLevel(
align::invalid),
48 idealInputLabel1(
"MuonGeometryArrangeLabel1"),
49 idealInputLabel2(
"MuonGeometryArrangeLabel2"),
50 idealInputLabel2a(
"MuonGeometryArrangeLabel2a"),
51 geomIdeal(
"MuonGeometryArrangeGeomIdeal"),
83 _endcap =
cfg.getUntrackedParameter<
int>(
"endcapNumber");
84 _station =
cfg.getUntrackedParameter<
int>(
"stationNumber");
85 _ring =
cfg.getUntrackedParameter<
int>(
"ringNumber");
92 while (!
fin.eof() &&
fin.good()) {
101 unsigned int lastID = 999999999;
111 if (listId != lastID) {
121 _alignTree =
new TTree(
"alignTree",
"alignTree");
170 std::vector<float> xp(
size + 1);
171 std::vector<float> yp(
size + 1);
180 TGraph* grx =
nullptr;
201 float smi =
minI - 1;
202 float sma =
maxI + 1;
223 "Local #delta X vs position",
249 "Local #delta Y vs position",
276 "Local #delta Z vs position",
302 "delphi_vs_position",
303 "#delta #phi vs position",
304 "Gdelphi_vs_position",
305 "#delta #phi in radians",
330 "#delta R vs position",
357 "delRphi_vs_position",
358 "R #delta #phi vs position",
359 "GdelRphi_vs_position",
360 "R #delta #phi in cm",
384 "delalpha_vs_position",
385 "#delta #alpha vs position",
386 "Gdelalpha_vs_position",
387 "#delta #alpha in rad",
411 "delbeta_vs_position",
412 "#delta #beta vs position",
413 "Gdelbeta_vs_position",
414 "#delta #beta in rad",
438 "delgamma_vs_position",
439 "#delta #gamma vs position",
440 "Gdelgamma_vs_position",
441 "#delta #gamma in rad",
465 "delrotX_vs_position",
466 "#delta rotX vs position",
467 "GdelrotX_vs_position",
468 "#delta rotX in rad",
492 "delrotY_vs_position",
493 "#delta rotY vs position",
494 "GdelrotY_vs_position",
495 "#delta rotY in rad",
519 "delrotZ_vs_position",
520 "#delta rotZ vs position",
521 "GdelrotZ_vs_position",
522 "#delta rotZ in rad",
532 float maxR = -9999999.;
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);
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);
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++) {
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++) {
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();
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++) {
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());
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++) {
std::string _inputTreename
Alignable * mother() const
Return pointer to container alignable (if any)
bool passChosen(Alignable *ali)
std::vector< align::StructureType > theLevels
Alignable * inputGeometry1
std::string _inputFilename1
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
void compareGeometries(Alignable *refAli, Alignable *curAli, Alignable *curAliCopy2)
bool isMother(Alignable *ali)
ret
prodAgent to be discontinued
Geom::Phi< T > phi() const
MuonGeometryArrange(const edm::ParameterSet &)
Do nothing. Required by framework.
bool checkChosen(Alignable *ali)
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
align::Scalar width() const
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
constexpr Detector det() const
get the detector field from this detid
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
void createROOTGeometry(const edm::EventSetup &iSetup)
const PositionType & globalPosition() const
Return the global position of the object.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken1_
AlignableMuon * getAlignableMuon()
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 > &)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken2_
#define DEFINE_FWK_MODULE(type)
std::string _weightByIdFile
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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.
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
CLHEP::HepVector AlgebraicVector
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
AlgebraicVector EulerAngles
void fillGapsInSurvey(double shiftErr, double angleErr)
const DetId & geomDetId() const
constexpr uint32_t rawId() const
get the raw id
const std::vector< std::string > _levelStrings
AlignableMuon * referenceMuon
align::Scalar length() const
std::vector< GlobalVector > GlobalVectors
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken1_
AlignableMuon * currentMuon
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
std::string _detIdFlagFile
const RotationType & globalRotation() const
Return the global orientation of the object.
Alignable * inputGeometry2
std::string _inputXMLCurrent
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken2_
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
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
std::vector< MGACollection > _mgacollection