5 #include "CLHEP/Vector/RotationInterfaces.h" 42 #include "CLHEP/Vector/ThreeVector.h" 65 referenceTracker(nullptr),
66 dummyTracker(nullptr),
67 currentTracker(nullptr),
69 theSurveyValues(nullptr),
70 theSurveyErrors(nullptr),
72 fromDD4hep_(
cfg.getUntrackedParameter<
bool>(
"fromDD4hep")),
73 writeToDB_(
cfg.getUntrackedParameter<
bool>(
"writeToDB")),
74 commonTrackerLevel_(
align::invalid),
77 inputRootFile1_(nullptr),
78 inputRootFile2_(nullptr),
79 inputTree01_(nullptr),
80 inputTree02_(nullptr),
81 inputTree11_(nullptr),
82 inputTree12_(nullptr),
113 while (!
fin.eof() &&
fin.good()) {
187 for (
int ii = 0;
ii < 13; ++
ii) {
188 std::stringstream histname0;
189 histname0 <<
"SurfDeform_Par_" <<
ii;
190 m_h1_[histname0.str()] = subDir_All.
make<TH1D>(
193 std::stringstream histname1;
194 histname1 <<
"SurfDeform_PixelBarrel_Par_" <<
ii;
195 m_h1_[histname1.str()] = subDir_PXB.
make<TH1D>(
198 std::stringstream histname2;
199 histname2 <<
"SurfDeform_PixelEndcap_Par_" <<
ii;
200 m_h1_[histname2.str()] = subDir_PXF.
make<TH1D>(
207 desc.setComment(
"Validates alignment payloads by comparing positions of tracker modules positiona and orientations");
208 desc.addUntracked<std::vector<std::string> >(
"levels", {});
209 desc.addUntracked<
bool>(
"fromDD4hep",
false);
210 desc.addUntracked<
bool>(
"writeToDB",
false);
213 desc.addUntracked<
std::string>(
"inputROOTFile2",
"idealtracker2.root");
215 desc.addUntracked<
std::string>(
"treeNameDeform",
"alignTreeDeformations");
220 desc.addUntracked<
bool>(
"detIdFlag",
false);
222 desc.addUntracked<
bool>(
"weightById",
false);
232 std::stringstream mapname;
233 mapname <<
surfdir_ <<
"/TkMap_SurfDeform_0" << iname <<
".png";
234 it->save(
true, 0, 0, mapname.str());
237 mapname <<
surfdir_ <<
"/TkMap_SurfDeform_1" << iname <<
".pdf";
238 it->save(
true, 0, 0, mapname.str());
285 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
289 *myAlignmentErrorsExtended, poolDbService->
beginOfTime(),
"TrackerAlignmentErrorExtendedRcd");
297 int inputRawId1, inputRawId2;
298 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
299 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
313 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: Module list not found! Please verify that given list exists!";
332 for (
int i = 0;
i < nEntries1; ++
i) {
334 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
335 CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
336 uint32_t detid1 = inputRawId1;
338 alignments1->
m_align.push_back(transform1);
342 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
344 alignmentErrors1->
m_alignError.push_back(transformError);
367 for (
int i = 0;
i < nEntries2; ++
i) {
369 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
370 CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
371 uint32_t detid2 = inputRawId2;
373 alignments2->
m_align.push_back(transform2);
377 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
379 alignmentErrors2->
m_alignError.push_back(transformError);
404 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
420 int inputDtype1, inputDtype2;
421 std::vector<double> inputDpar1;
422 std::vector<double> inputDpar2;
423 std::vector<double>* p_inputDpar1 = &inputDpar1;
424 std::vector<double>* p_inputDpar2 = &inputDpar2;
436 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
437 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
442 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
443 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
453 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
467 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
468 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
473 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
474 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
480 delete alignmentErrors1;
482 delete alignmentErrors2;
489 int inputSubdetid1, inputSubdetid2;
490 int inputDtype1, inputDtype2;
491 std::vector<double> inputDpar1;
492 std::vector<double> inputDpar2;
493 std::vector<double>* p_inputDpar1 = &inputDpar1;
494 std::vector<double>* p_inputDpar2 = &inputDpar2;
497 refTree->SetBranchAddress(
"irawid", &inputRawid1);
498 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
499 refTree->SetBranchAddress(
"dtype", &inputDtype1);
500 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
503 curTree->SetBranchAddress(
"irawid", &inputRawid2);
504 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
505 curTree->SetBranchAddress(
"dtype", &inputDtype2);
506 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
508 unsigned int nEntries11 = refTree->GetEntries();
509 unsigned int nEntries12 = curTree->GetEntries();
511 if (nEntries11 != nEntries12) {
512 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
516 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
517 refTree->GetEntry(iEntry);
518 curTree->GetEntry(iEntry);
519 for (
int ii = 0;
ii < 13; ++
ii) {
522 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
523 if (inputRawid1 == inputRawid2) {
524 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
525 std::stringstream histname0;
526 histname0 <<
"SurfDeform_Par_" << npar;
529 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
530 std::stringstream histname1;
531 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
535 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
536 std::stringstream histname2;
537 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
546 if (!(inputSubdetid1 == 1 && inputSubdetid2 == 1) && !(inputSubdetid1 == 2 && inputSubdetid2 == 2)) {
559 std::vector<double> inputDpar2;
560 std::vector<double>* p_inputDpar2 = &inputDpar2;
563 curTree->SetBranchAddress(
"irawid", &inputRawid2);
564 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
565 curTree->SetBranchAddress(
"dtype", &inputDtype2);
566 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
568 unsigned int nEntries12 = curTree->GetEntries();
569 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
570 curTree->GetEntry(iEntry);
571 for (
int ii = 0;
ii < 12; ++
ii) {
574 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
576 std::stringstream histname0;
577 histname0 <<
"SurfDeform_Par_" << npar;
580 if (inputSubdetid2 == 1) {
581 std::stringstream histname1;
582 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
586 if (inputSubdetid2 == 2) {
587 std::stringstream histname2;
588 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
597 if (inputSubdetid2 != 1 && inputSubdetid2 != 2) {
609 std::vector<double> inputDpar1;
610 std::vector<double>* p_inputDpar1 = &inputDpar1;
613 refTree->SetBranchAddress(
"irawid", &inputRawid1);
614 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
615 refTree->SetBranchAddress(
"dtype", &inputDtype1);
616 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
617 unsigned int nEntries11 = refTree->GetEntries();
619 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
620 refTree->GetEntry(iEntry);
621 for (
int ii = 0;
ii < 12; ++
ii) {
624 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
626 std::stringstream histname0;
627 histname0 <<
"SurfDeform_Par_" << npar;
630 if (inputSubdetid1 == 1) {
631 std::stringstream histname1;
632 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
636 if (inputSubdetid1 == 2) {
637 std::stringstream histname2;
638 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
647 if (inputSubdetid1 != 1 && inputSubdetid1 != 2) {
656 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
665 using namespace align;
670 unsigned int nComp = refComp.size();
672 bool useLevel =
false;
685 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
686 Rtotal.set(0., 0., 0.);
687 Wtotal.set(0., 0., 0.);
688 lRtotal.set(0., 0., 0.);
689 lWtotal.set(0., 0., 0.);
691 bool converged =
false;
695 for (
int i = 0;
i < 100;
i++) {
706 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
714 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
715 CLHEP::HepRotation drot(dW.unit(), dW.mag());
717 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
719 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
720 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
721 rotLocal *= drotLocal;
722 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
723 rotLocal.axis().y() * rotLocal.delta(),
724 rotLocal.axis().z() * rotLocal.delta());
746 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
750 TRtot(1) = Rtotal.x();
751 TRtot(2) = Rtotal.y();
752 TRtot(3) = Rtotal.z();
753 TRtot(4) = Wtotal.x();
754 TRtot(5) = Wtotal.y();
755 TRtot(6) = Wtotal.z();
757 TRtot(7) = lRtotal.x();
758 TRtot(8) = lRtotal.y();
759 TRtot(9) = lRtotal.z();
760 TRtot(10) = lWtotal.x();
761 TRtot(11) = lWtotal.y();
762 TRtot(12) = lWtotal.z();
764 fillTree(refAli, TRtot, tTopo, iSetup);
768 for (
unsigned int i = 0;
i < nComp; ++
i)
773 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
788 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
804 TrackerCommonTR(1) = theRprime.x();
805 TrackerCommonTR(2) = theRprime.y();
806 TrackerCommonTR(3) = theRprime.z();
811 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
818 unsigned int nComp = refComp.size();
820 bool useLevel =
false;
826 CLHEP::Hep3Vector Rtotal, Wtotal;
827 Rtotal.set(0., 0., 0.);
828 Wtotal.set(0., 0., 0.);
834 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
835 CLHEP::HepRotation drot(dW.unit(), dW.mag());
837 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
844 for (
unsigned int i = 0;
i < nComp; ++
i)
972 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
973 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
974 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
975 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
976 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
977 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
980 for (
const auto&
i : allGeomDets) {
981 if (
i->components().size() == 1) {
982 rcdAlis.push_back(
i);
983 }
else if (
i->components().size() > 1) {
984 rcdAlis.push_back(
i);
985 const auto&
comp =
i->components();
986 for (
const auto&
j :
comp)
987 rcdAlis.push_back(
j);
992 for (
const auto&
k : rcdAlis) {
996 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
997 CLHEP::HepRotation clhepRotation(
1013 unsigned int nComp =
comp.size();
1015 for (
unsigned int i = 0;
i < nComp; ++
i)
1021 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
1043 for (
int i = 0;
i < nEntries;
i++) {
1052 switch (subdetlevel) {
1108 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: bad subdetid!!";
std::ifstream moduleListFile_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Alignables & pixelHalfBarrelGeomDets()
Return pixel barrel GeomDets.
std::string inputFilename2_
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
Alignable * mother() const
Return pointer to container alignable (if any)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
align::GlobalVector TrackerCommonR_
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
Alignments * alignments() const override
Return alignments, sorted by DetId.
Vector3DBase< Scalar, GlobalTag > GlobalVector
void compareGeometries(Alignable *refAli, Alignable *curAli, const TrackerTopology *tTopo, const edm::EventSetup &iSetup)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
unsigned int pxfBlade(const DetId &id) const
Class to update a given geometry with a set of alignments.
unsigned int tibModule(const DetId &id) const
unsigned int tidSide(const DetId &id) const
std::vector< align::StructureType > m_theLevels
const std::vector< std::string > levelStrings_
const Alignments * theSurveyValues
Geom::Phi< T > phi() const
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
unsigned int pxfModule(const DetId &id) const
void addSurveyInfo(Alignable *ali)
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
cond::Time_t beginOfTime() const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
const edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_
bool IsModuleBad(uint32_t detid) const
AlgebraicVector diffAlignables(Alignable *refAli, Alignable *curAli, const std::string &weightBy, bool weightById, const std::vector< unsigned int > &weightByIdVector)
align::Scalar width() const
std::vector< TrackerMap > m_vtkmap_
void diffCommonTrackerSystem(Alignable *refAli, Alignable *curAli)
bool IsModuleBad(const uint32_t &detid) const
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
void setWidth(align::Scalar width)
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
const Alignables & deepComponents() const
std::map< std::string, TH1D * > m_h1_
std::vector< int > moduleList_
std::vector< AlignTransform > m_align
unsigned int tecRing(const DetId &id) const
ring id
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void setLength(align::Scalar length)
T * make(const Args &...args) const
make new ROOT object
unsigned int tecModule(const DetId &id) const
std::vector< uint32_t > detIdFlagVector_
const PositionType & globalPosition() const
Return the global position of the object.
const align::RotationType & rotation() const
Alignables & innerBarrelGeomDets()
Return inner barrel GeomDets.
unsigned int tecSide(const DetId &id) const
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvTokenDDD_
std::vector< unsigned int > weightByIdVector_
Alignables & TIDGeomDets()
Return TID GeomDets.
unsigned int pxfDisk(const DetId &id) const
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
void beginJob() override
Read from DB and print survey info.
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
std::string inputFilename1_
TrackerGeometryCompare(const edm::ParameterSet &)
Do nothing. Required by framework.
const align::PositionType & position() const
align::GlobalVector TrackerCommonT_
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.
std::string inputTreenameAlign_
Alignables & endcapGeomDets()
Return endcap GeomDets.
Alignables & pixelEndcapGeomDets()
Return pixel endcap GeomDets.
void fillTree(Alignable *refAli, const AlgebraicVector &diff, const TrackerTopology *tTopo, const edm::EventSetup &iSetup)
unsigned int pxfPanel(const DetId &id) const
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).
unsigned int pxfSide(const DetId &id) const
AlgebraicVector EulerAngles
std::vector< unsigned int > tibStringInfo(const DetId &id) const
Alignables & outerBarrelGeomDets()
Return outer barrel GeomDets.
AlignableTracker * currentTracker
void surveyToTracker(AlignableTracker *ali, Alignments *alignVals, AlignmentErrorsExtended *alignErrors)
std::vector< AlignTransformErrorExtended > m_alignError
const DetId & geomDetId() const
constexpr uint32_t rawId() const
get the raw id
void setSurvey(const SurveyDet *)
Set survey info.
void setCommonTrackerSystem()
std::string setCommonTrackerSystem_
const edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokenDD4hep_
align::Scalar length() const
align::StructureType commonTrackerLevel_
void fillIdentifiers(int subdetlevel, int rawid, const TrackerTopology *tTopo)
AlignmentErrorsExtended * alignmentErrors() const override
Return alignment errors, sorted by DetId.
unsigned int theSurveyIndex
std::vector< Alignable * > Alignables
align::StructureType stringToId(const char *) const
AlignableTracker * referenceTracker
std::vector< unsigned int > tobRodInfo(const DetId &id) const
std::string moduleListName_
std::string detIdFlagFile_
void createROOTGeometry(const edm::EventSetup &iSetup)
align::PositionType TrackerCommonCM_
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
std::string inputTreenameDeform_
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
const AlignableObjectId & objectIdProvider() const
Return tracker alignable object ID provider derived from the tracker's geometry.
unsigned int tidRing(const DetId &id) const
const SurveyErrors * theSurveyErrors
const RotationType & globalRotation() const
Return the global orientation of the object.
unsigned int tibLayer(const DetId &id) const
unsigned int tobModule(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
std::vector< SurveyError > m_surveyErrors
void moveAlignable(Alignable *ali, AlgebraicVector diff)
Moves the alignable by the AlgebraicVector.
std::string weightByIdFile_
void compareSurfaceDeformations(TTree *_inputTree11, TTree *_inputTree12)
const edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > pixQualityToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)