5 #include "CLHEP/Vector/RotationInterfaces.h" 41 #include "CLHEP/Vector/ThreeVector.h" 63 referenceTracker(nullptr),
64 dummyTracker(nullptr),
65 currentTracker(nullptr),
67 theSurveyValues(nullptr),
68 theSurveyErrors(nullptr),
70 fromDD4hep_(
cfg.getUntrackedParameter<
bool>(
"fromDD4hep")),
71 writeToDB_(
cfg.getUntrackedParameter<
bool>(
"writeToDB")),
72 commonTrackerLevel_(
align::invalid),
75 inputRootFile1_(nullptr),
76 inputRootFile2_(nullptr),
77 inputTree01_(nullptr),
78 inputTree02_(nullptr),
79 inputTree11_(nullptr),
80 inputTree12_(nullptr),
111 while (!
fin.eof() &&
fin.good()) {
178 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
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);
231 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
232 std::stringstream mapname;
233 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << iname <<
".png";
234 it->save(
true, 0, 0, mapname.str());
237 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << 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);
403 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
410 int inputDtype1, inputDtype2;
411 std::vector<double> inputDpar1;
412 std::vector<double> inputDpar2;
413 std::vector<double>* p_inputDpar1 = &inputDpar1;
414 std::vector<double>* p_inputDpar2 = &inputDpar2;
426 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
427 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
432 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
433 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
443 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
457 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
458 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
463 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
464 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
470 delete alignmentErrors1;
472 delete alignmentErrors2;
479 int inputSubdetid1, inputSubdetid2;
480 int inputDtype1, inputDtype2;
481 std::vector<double> inputDpar1;
482 std::vector<double> inputDpar2;
483 std::vector<double>* p_inputDpar1 = &inputDpar1;
484 std::vector<double>* p_inputDpar2 = &inputDpar2;
487 refTree->SetBranchAddress(
"irawid", &inputRawid1);
488 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
489 refTree->SetBranchAddress(
"dtype", &inputDtype1);
490 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
493 curTree->SetBranchAddress(
"irawid", &inputRawid2);
494 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
495 curTree->SetBranchAddress(
"dtype", &inputDtype2);
496 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
498 unsigned int nEntries11 = refTree->GetEntries();
499 unsigned int nEntries12 = curTree->GetEntries();
501 if (nEntries11 != nEntries12) {
502 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
506 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
507 refTree->GetEntry(iEntry);
508 curTree->GetEntry(iEntry);
509 for (
int ii = 0;
ii < 13; ++
ii) {
512 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
513 if (inputRawid1 == inputRawid2) {
514 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
515 std::stringstream histname0;
516 histname0 <<
"SurfDeform_Par_" << npar;
519 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
520 std::stringstream histname1;
521 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
525 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
526 std::stringstream histname2;
527 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
540 std::vector<double> inputDpar2;
541 std::vector<double>* p_inputDpar2 = &inputDpar2;
544 curTree->SetBranchAddress(
"irawid", &inputRawid2);
545 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
546 curTree->SetBranchAddress(
"dtype", &inputDtype2);
547 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
549 unsigned int nEntries12 = curTree->GetEntries();
551 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
552 curTree->GetEntry(iEntry);
553 for (
int ii = 0;
ii < 12; ++
ii) {
556 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
558 std::stringstream histname0;
559 histname0 <<
"SurfDeform_Par_" << npar;
562 if (inputSubdetid2 == 1) {
563 std::stringstream histname1;
564 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
568 if (inputSubdetid2 == 2) {
569 std::stringstream histname2;
570 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
582 std::vector<double> inputDpar1;
583 std::vector<double>* p_inputDpar1 = &inputDpar1;
586 refTree->SetBranchAddress(
"irawid", &inputRawid1);
587 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
588 refTree->SetBranchAddress(
"dtype", &inputDtype1);
589 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
591 unsigned int nEntries11 = refTree->GetEntries();
593 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
594 refTree->GetEntry(iEntry);
595 for (
int ii = 0;
ii < 12; ++
ii) {
598 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
600 std::stringstream histname0;
601 histname0 <<
"SurfDeform_Par_" << npar;
604 if (inputSubdetid1 == 1) {
605 std::stringstream histname1;
606 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
610 if (inputSubdetid1 == 2) {
611 std::stringstream histname2;
612 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
621 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
631 using namespace align;
636 unsigned int nComp = refComp.size();
638 bool useLevel =
false;
651 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
652 Rtotal.set(0., 0., 0.);
653 Wtotal.set(0., 0., 0.);
654 lRtotal.set(0., 0., 0.);
655 lWtotal.set(0., 0., 0.);
657 bool converged =
false;
661 for (
int i = 0;
i < 100;
i++) {
672 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
680 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
681 CLHEP::HepRotation drot(dW.unit(), dW.mag());
683 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
685 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
686 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
687 rotLocal *= drotLocal;
688 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
689 rotLocal.axis().y() * rotLocal.delta(),
690 rotLocal.axis().z() * rotLocal.delta());
712 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
717 TRtot(1) = Rtotal.x();
718 TRtot(2) = Rtotal.y();
719 TRtot(3) = Rtotal.z();
720 TRtot(4) = Wtotal.x();
721 TRtot(5) = Wtotal.y();
722 TRtot(6) = Wtotal.z();
724 TRtot(7) = lRtotal.x();
725 TRtot(8) = lRtotal.y();
726 TRtot(9) = lRtotal.z();
727 TRtot(10) = lWtotal.x();
728 TRtot(11) = lWtotal.y();
729 TRtot(12) = lWtotal.z();
731 fillTree(refAli, TRtot, tTopo, iSetup);
735 for (
unsigned int i = 0;
i < nComp; ++
i)
740 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
755 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
771 TrackerCommonTR(1) = theRprime.x();
772 TrackerCommonTR(2) = theRprime.y();
773 TrackerCommonTR(3) = theRprime.z();
778 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
787 unsigned int nComp = refComp.size();
789 bool useLevel =
false;
795 CLHEP::Hep3Vector Rtotal, Wtotal;
796 Rtotal.set(0., 0., 0.);
797 Wtotal.set(0., 0., 0.);
803 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
804 CLHEP::HepRotation drot(dW.unit(), dW.mag());
806 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
813 for (
unsigned int i = 0;
i < nComp; ++
i)
942 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
943 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
944 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
945 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
946 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
947 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
950 for (
const auto&
i : allGeomDets) {
951 if (
i->components().size() == 1) {
952 rcdAlis.push_back(
i);
953 }
else if (
i->components().size() > 1) {
954 rcdAlis.push_back(
i);
955 const auto&
comp =
i->components();
956 for (
const auto&
j :
comp)
957 rcdAlis.push_back(
j);
962 for (
const auto&
k : rcdAlis) {
966 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
967 CLHEP::HepRotation clhepRotation(
983 unsigned int nComp =
comp.size();
985 for (
unsigned int i = 0;
i < nComp; ++
i)
991 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
1013 for (
int i = 0;
i < nEntries;
i++) {
1022 switch (subdetlevel) {
1078 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
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)