5 #include "CLHEP/Vector/RotationInterfaces.h" 42 #include "CLHEP/Vector/ThreeVector.h" 64 referenceTracker(nullptr),
65 dummyTracker(nullptr),
66 currentTracker(nullptr),
68 theSurveyValues(nullptr),
69 theSurveyErrors(nullptr),
71 fromDD4hep_(
cfg.getUntrackedParameter<
bool>(
"fromDD4hep")),
72 writeToDB_(
cfg.getUntrackedParameter<
bool>(
"writeToDB")),
73 commonTrackerLevel_(
align::invalid),
76 inputRootFile1_(nullptr),
77 inputRootFile2_(nullptr),
78 inputTree01_(nullptr),
79 inputTree02_(nullptr),
80 inputTree11_(nullptr),
81 inputTree12_(nullptr),
112 while (!
fin.eof() &&
fin.good()) {
186 for (
int ii = 0;
ii < 13; ++
ii) {
187 std::stringstream histname0;
188 histname0 <<
"SurfDeform_Par_" <<
ii;
189 m_h1_[histname0.str()] = subDir_All.
make<TH1D>(
192 std::stringstream histname1;
193 histname1 <<
"SurfDeform_PixelBarrel_Par_" <<
ii;
194 m_h1_[histname1.str()] = subDir_PXB.
make<TH1D>(
197 std::stringstream histname2;
198 histname2 <<
"SurfDeform_PixelEndcap_Par_" <<
ii;
199 m_h1_[histname2.str()] = subDir_PXF.
make<TH1D>(
206 desc.setComment(
"Validates alignment payloads by comparing positions of tracker modules positiona and orientations");
207 desc.addUntracked<std::vector<std::string> >(
"levels", {});
208 desc.addUntracked<
bool>(
"fromDD4hep",
false);
209 desc.addUntracked<
bool>(
"writeToDB",
false);
212 desc.addUntracked<
std::string>(
"inputROOTFile2",
"idealtracker2.root");
214 desc.addUntracked<
std::string>(
"treeNameDeform",
"alignTreeDeformations");
219 desc.addUntracked<
bool>(
"detIdFlag",
false);
221 desc.addUntracked<
bool>(
"weightById",
false);
231 std::stringstream mapname;
232 mapname <<
surfdir_ <<
"/TkMap_SurfDeform_0" << iname <<
".png";
233 it->save(
true, 0, 0, mapname.str());
236 mapname <<
surfdir_ <<
"/TkMap_SurfDeform_1" << iname <<
".pdf";
237 it->save(
true, 0, 0, mapname.str());
284 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
288 *myAlignmentErrorsExtended, poolDbService->
beginOfTime(),
"TrackerAlignmentErrorExtendedRcd");
296 int inputRawId1, inputRawId2;
297 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
298 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
312 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: Module list not found! Please verify that given list exists!";
331 for (
int i = 0;
i < nEntries1; ++
i) {
333 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
334 CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
335 uint32_t detid1 = inputRawId1;
337 alignments1->
m_align.push_back(transform1);
341 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
343 alignmentErrors1->
m_alignError.push_back(transformError);
366 for (
int i = 0;
i < nEntries2; ++
i) {
368 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
369 CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
370 uint32_t detid2 = inputRawId2;
372 alignments2->
m_align.push_back(transform2);
376 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
378 alignmentErrors2->
m_alignError.push_back(transformError);
402 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
418 int inputDtype1, inputDtype2;
419 std::vector<double> inputDpar1;
420 std::vector<double> inputDpar2;
421 std::vector<double>* p_inputDpar1 = &inputDpar1;
422 std::vector<double>* p_inputDpar2 = &inputDpar2;
434 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
435 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
440 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
441 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
451 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
465 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
466 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
471 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
472 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
478 delete alignmentErrors1;
480 delete alignmentErrors2;
487 int inputSubdetid1, inputSubdetid2;
488 int inputDtype1, inputDtype2;
489 std::vector<double> inputDpar1;
490 std::vector<double> inputDpar2;
491 std::vector<double>* p_inputDpar1 = &inputDpar1;
492 std::vector<double>* p_inputDpar2 = &inputDpar2;
495 refTree->SetBranchAddress(
"irawid", &inputRawid1);
496 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
497 refTree->SetBranchAddress(
"dtype", &inputDtype1);
498 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
501 curTree->SetBranchAddress(
"irawid", &inputRawid2);
502 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
503 curTree->SetBranchAddress(
"dtype", &inputDtype2);
504 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
506 unsigned int nEntries11 = refTree->GetEntries();
507 unsigned int nEntries12 = curTree->GetEntries();
509 if (nEntries11 != nEntries12) {
510 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
514 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
515 refTree->GetEntry(iEntry);
516 curTree->GetEntry(iEntry);
517 for (
int ii = 0;
ii < 13; ++
ii) {
520 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
521 if (inputRawid1 == inputRawid2) {
522 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
523 std::stringstream histname0;
524 histname0 <<
"SurfDeform_Par_" << npar;
527 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
528 std::stringstream histname1;
529 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
533 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
534 std::stringstream histname2;
535 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
544 if (!(inputSubdetid1 == 1 && inputSubdetid2 == 1) && !(inputSubdetid1 == 2 && inputSubdetid2 == 2)) {
557 std::vector<double> inputDpar2;
558 std::vector<double>* p_inputDpar2 = &inputDpar2;
561 curTree->SetBranchAddress(
"irawid", &inputRawid2);
562 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
563 curTree->SetBranchAddress(
"dtype", &inputDtype2);
564 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
566 unsigned int nEntries12 = curTree->GetEntries();
567 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
568 curTree->GetEntry(iEntry);
569 for (
int ii = 0;
ii < 12; ++
ii) {
572 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
574 std::stringstream histname0;
575 histname0 <<
"SurfDeform_Par_" << npar;
578 if (inputSubdetid2 == 1) {
579 std::stringstream histname1;
580 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
584 if (inputSubdetid2 == 2) {
585 std::stringstream histname2;
586 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
595 if (inputSubdetid2 != 1 && inputSubdetid2 != 2) {
607 std::vector<double> inputDpar1;
608 std::vector<double>* p_inputDpar1 = &inputDpar1;
611 refTree->SetBranchAddress(
"irawid", &inputRawid1);
612 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
613 refTree->SetBranchAddress(
"dtype", &inputDtype1);
614 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
615 unsigned int nEntries11 = refTree->GetEntries();
617 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
618 refTree->GetEntry(iEntry);
619 for (
int ii = 0;
ii < 12; ++
ii) {
622 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
624 std::stringstream histname0;
625 histname0 <<
"SurfDeform_Par_" << npar;
628 if (inputSubdetid1 == 1) {
629 std::stringstream histname1;
630 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
634 if (inputSubdetid1 == 2) {
635 std::stringstream histname2;
636 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
645 if (inputSubdetid1 != 1 && inputSubdetid1 != 2) {
654 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
663 using namespace align;
668 unsigned int nComp = refComp.size();
670 bool useLevel =
false;
683 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
684 Rtotal.set(0., 0., 0.);
685 Wtotal.set(0., 0., 0.);
686 lRtotal.set(0., 0., 0.);
687 lWtotal.set(0., 0., 0.);
689 bool converged =
false;
693 for (
int i = 0;
i < 100;
i++) {
704 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
712 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
713 CLHEP::HepRotation drot(dW.unit(), dW.mag());
715 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
717 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
718 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
719 rotLocal *= drotLocal;
720 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
721 rotLocal.axis().y() * rotLocal.delta(),
722 rotLocal.axis().z() * rotLocal.delta());
744 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
748 TRtot(1) = Rtotal.x();
749 TRtot(2) = Rtotal.y();
750 TRtot(3) = Rtotal.z();
751 TRtot(4) = Wtotal.x();
752 TRtot(5) = Wtotal.y();
753 TRtot(6) = Wtotal.z();
755 TRtot(7) = lRtotal.x();
756 TRtot(8) = lRtotal.y();
757 TRtot(9) = lRtotal.z();
758 TRtot(10) = lWtotal.x();
759 TRtot(11) = lWtotal.y();
760 TRtot(12) = lWtotal.z();
762 fillTree(refAli, TRtot, tTopo, iSetup);
766 for (
unsigned int i = 0;
i < nComp; ++
i)
771 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
786 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
802 TrackerCommonTR(1) = theRprime.x();
803 TrackerCommonTR(2) = theRprime.y();
804 TrackerCommonTR(3) = theRprime.z();
809 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
816 unsigned int nComp = refComp.size();
818 bool useLevel =
false;
824 CLHEP::Hep3Vector Rtotal, Wtotal;
825 Rtotal.set(0., 0., 0.);
826 Wtotal.set(0., 0., 0.);
832 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
833 CLHEP::HepRotation drot(dW.unit(), dW.mag());
835 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
842 for (
unsigned int i = 0;
i < nComp; ++
i)
970 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
971 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
972 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
973 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
974 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
975 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
978 for (
const auto&
i : allGeomDets) {
979 if (
i->components().size() == 1) {
980 rcdAlis.push_back(
i);
981 }
else if (
i->components().size() > 1) {
982 rcdAlis.push_back(
i);
983 const auto&
comp =
i->components();
984 for (
const auto&
j :
comp)
985 rcdAlis.push_back(
j);
990 for (
const auto&
k : rcdAlis) {
994 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
995 CLHEP::HepRotation clhepRotation(
1011 unsigned int nComp =
comp.size();
1013 for (
unsigned int i = 0;
i < nComp; ++
i)
1019 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
1041 for (
int i = 0;
i < nEntries;
i++) {
1050 switch (subdetlevel) {
1106 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
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
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_
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
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)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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)