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;
109 if (listId != lastID) {
119 _alignTree =
new TTree(
"alignTree",
"alignTree");
168 std::vector<float> xp(
size + 1);
169 std::vector<float> yp(
size + 1);
178 TGraph* grx =
nullptr;
199 float smi =
minI - 1;
200 float sma =
maxI + 1;
221 "Local #delta X vs position",
247 "Local #delta Y vs position",
274 "Local #delta Z vs position",
300 "delphi_vs_position",
301 "#delta #phi vs position",
302 "Gdelphi_vs_position",
303 "#delta #phi in radians",
328 "#delta R vs position",
355 "delRphi_vs_position",
356 "R #delta #phi vs position",
357 "GdelRphi_vs_position",
358 "R #delta #phi in cm",
382 "delalpha_vs_position",
383 "#delta #alpha vs position",
384 "Gdelalpha_vs_position",
385 "#delta #alpha in rad",
409 "delbeta_vs_position",
410 "#delta #beta vs position",
411 "Gdelbeta_vs_position",
412 "#delta #beta in rad",
436 "delgamma_vs_position",
437 "#delta #gamma vs position",
438 "Gdelgamma_vs_position",
439 "#delta #gamma in rad",
463 "delrotX_vs_position",
464 "#delta rotX vs position",
465 "GdelrotX_vs_position",
466 "#delta rotX in rad",
490 "delrotY_vs_position",
491 "#delta rotY vs position",
492 "GdelrotY_vs_position",
493 "#delta rotY in rad",
517 "delrotZ_vs_position",
518 "#delta rotZ vs position",
519 "GdelrotZ_vs_position",
520 "#delta rotZ in rad",
530 float maxR = -9999999.;
541 float smallestVcm = .001;
542 if (maxV < smallestVcm)
545 float lside = 1.1 * maxR;
549 scale = .09 * lside / maxV;
552 int ret = snprintf(scalename, 50,
"#delta #bar{x} length =%f cm", maxV);
556 dxh =
new TH2F(
"vecdrplot", scalename, 80, -lside, lside, 80, -lside, lside);
558 dxh =
new TH2F(
"vecdrplot",
"delta #bar{x} Bad scale", 80, -lside, lside, 80, -lside, lside);
560 dxh->GetXaxis()->SetTitle(
"x in cm");
561 dxh->GetYaxis()->SetTitle(
"y in cm");
562 dxh->SetStats(kFALSE);
571 arrow->SetLineWidth(2);
572 arrow->SetArrowSize(ttemp * .2 * .05 / maxV);
573 arrow->SetLineColor(1);
574 arrow->SetLineStyle(1);
576 dxh->GetListOfFunctions()->Add(static_cast<TObject*>(arrow));
600 if (minV >= maxV || smi >= sma || sizeI <= 1 || xp ==
nullptr || yp ==
nullptr)
603 float diff = maxV - minV;
604 float over = .05 *
diff;
605 double ylo = minV - over;
606 double yhi = maxV + over;
610 dxh =
new TH2F(
name,
title, sizeI + 2, dsmi, dsma, 50, ylo, yhi);
611 dxh->GetXaxis()->SetTitle(
"Position around ring");
612 dxh->GetYaxis()->SetTitle(axis);
613 dxh->SetStats(kFALSE);
615 grx =
new TGraph(
size, xp, yp);
616 grx->SetName(titleg);
617 grx->SetTitle(
title);
618 grx->SetMarkerColor(2);
619 grx->SetMarkerStyle(3);
620 grx->GetXaxis()->SetLimits(dsmi, dsma);
621 grx->GetXaxis()->SetTitle(
"position number");
622 grx->GetYaxis()->SetLimits(ylo, yhi);
623 grx->GetYaxis()->SetTitle(axis);
671 theLevels.push_back(inputGeometry2Copy2->objectIdProvider().stringToId(
level));
692 if (refAli ==
nullptr) {
695 if (curAli ==
nullptr) {
701 const auto& curComp2 = curAliCopy2->
components();
704 int nComp = refComp.size();
705 for (
int i = 0;
i < nComp;
i++) {
714 if (refAli ==
nullptr) {
717 if (curAli ==
nullptr) {
731 if (refComp.size() != curComp.size()) {
740 int nComp = refComp.size();
743 CLHEP::Hep3Vector TotalX, TotalL;
744 TotalX.set(0., 0., 0.);
745 TotalL.set(0., 0., 0.);
747 std::vector<CLHEP::Hep3Vector> Positions;
748 std::vector<CLHEP::Hep3Vector> DelPositions;
750 double xrcenter = 0.;
751 double yrcenter = 0.;
752 double zrcenter = 0.;
753 double xccenter = 0.;
754 double yccenter = 0.;
755 double zccenter = 0.;
760 for (
int ich = 0; ich < nComp; ich++) {
771 originalVectors.push_back(pointsCM);
773 xrcenter += pointsCM.
x();
774 yrcenter += pointsCM.
y();
775 zrcenter += pointsCM.
z();
777 xrcenter = xrcenter / nUsed;
778 yrcenter = yrcenter / nUsed;
779 zrcenter = zrcenter / nUsed;
783 for (
int ich = 0; ich < nComp; ich++) {
794 currentVectors.push_back(pointsCM);
796 xccenter += pointsCM.
x();
797 yccenter += pointsCM.
y();
798 zccenter += pointsCM.
z();
800 xccenter = xccenter / nUsed;
801 yccenter = yccenter / nUsed;
802 zccenter = zccenter / nUsed;
807 int nCompR = currentVectors.size();
808 for (
int ich = 0; ich < nCompR; ich++) {
809 originalRelativeVectors.push_back(originalVectors[ich] - CRef);
810 currentRelativeVectors.push_back(currentVectors[ich] - CCur);
822 for (
int ich = 0; ich < nComp; ich++) {
827 CLHEP::Hep3Vector Rtotal, Wtotal;
828 Rtotal.set(0., 0., 0.);
829 Wtotal.set(0., 0., 0.);
830 for (
int i = 0;
i < 100;
i++) {
836 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
837 CLHEP::HepRotation drot(dW.unit(), dW.mag());
839 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
846 DetId detid(refComp[ich]->
id());
860 TotalX = TotalX / nUsed;
864 change(1) = TotalX.x();
865 change(2) = TotalX.y();
866 change(3) = TotalX.z();
876 for (
int ich = 0; ich < nComp; ich++) {
877 CLHEP::Hep3Vector Rtotal, Wtotal;
878 Rtotal.set(0., 0., 0.);
879 Wtotal.set(0., 0., 0.);
885 for (
int i = 0;
i < 100;
i++) {
891 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
892 CLHEP::HepRotation drot(dW.unit(), dW.mag());
894 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
907 TRtot(1) = Rtotal.x();
908 TRtot(2) = Rtotal.y();
909 TRtot(3) = Rtotal.z();
910 TRtot(4) = Wtotal.x();
911 TRtot(5) = Wtotal.y();
912 TRtot(6) = Wtotal.z();
932 int ringPhiPos = -99;
947 float ttt = -
rot.xz();
978 double xx =
rot.xx();
979 double xy =
rot.xy();
980 double xz =
rot.xz();
981 double yx =
rot.yx();
982 double yy =
rot.yy();
983 double yz =
rot.yz();
984 double zx =
rot.zx();
985 double zy =
rot.zy();
986 double zz =
rot.zz();
987 double detrot = (
zz *
yy - zy *
yz) *
xx + (-
zz * yx + zx *
yz) *
xy + (zy * yx - zx *
yy) *
xz;
989 double ixx = (
zz *
yy - zy *
yz) * detrot;
990 double ixy = (-
zz *
xy + zy *
xz) * detrot;
991 double ixz = (
yz *
xy -
yy *
xz) * detrot;
992 double iyx = (-
zz * yx + zx *
yz) * detrot;
993 double iyy = (
zz *
xx - zx *
xz) * detrot;
994 double iyz = (-
yz *
xx + yx *
xz) * detrot;
995 double izx = (zy * yx - zx *
yy) * detrot;
996 double izy = (-zy *
xx + zx *
xy) * detrot;
997 double izz = (
yy *
xx - yx *
xy) * detrot;
1002 protx = atan2(prot.
yz(), prot.
zz());
1113 for (
int i = 0;
i < 9;
i++) {
1116 holdit.
phipos = ringPhiPos;
1130 int size = aliComp.size();
1134 for (
int i = 0;
i <
size;
i++) {
1156 std::cout <<
"JNB " << ali->
id() <<
" " << cscId.endcap() <<
" " << cscId.station() <<
" " << cscId.ring() <<
" " 1186 int size = aliComp.size();
1190 for (
int i = 0;
i <
size;
i++) {
1206 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