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()) {
185 for (
int ii = 0;
ii < 13; ++
ii) {
186 std::stringstream histname0;
187 histname0 <<
"SurfDeform_Par_" <<
ii;
188 m_h1_[histname0.str()] = subDir_All.
make<TH1D>(
191 std::stringstream histname1;
192 histname1 <<
"SurfDeform_PixelBarrel_Par_" <<
ii;
193 m_h1_[histname1.str()] = subDir_PXB.
make<TH1D>(
196 std::stringstream histname2;
197 histname2 <<
"SurfDeform_PixelEndcap_Par_" <<
ii;
198 m_h1_[histname2.str()] = subDir_PXF.
make<TH1D>(
205 desc.setComment(
"Validates alignment payloads by comparing positions of tracker modules positiona and orientations");
206 desc.addUntracked<std::vector<std::string> >(
"levels", {});
207 desc.addUntracked<
bool>(
"fromDD4hep",
false);
208 desc.addUntracked<
bool>(
"writeToDB",
false);
211 desc.addUntracked<
std::string>(
"inputROOTFile2",
"idealtracker2.root");
213 desc.addUntracked<
std::string>(
"treeNameDeform",
"alignTreeDeformations");
218 desc.addUntracked<
bool>(
"detIdFlag",
false);
220 desc.addUntracked<
bool>(
"weightById",
false);
230 std::stringstream mapname;
231 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << iname <<
".png";
232 it->save(
true, 0, 0, mapname.str());
235 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << iname <<
".pdf";
236 it->save(
true, 0, 0, mapname.str());
283 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
287 *myAlignmentErrorsExtended, poolDbService->
beginOfTime(),
"TrackerAlignmentErrorExtendedRcd");
295 int inputRawId1, inputRawId2;
296 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
297 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
311 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: Module list not found! Please verify that given list exists!";
330 for (
int i = 0;
i < nEntries1; ++
i) {
332 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
333 CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
334 uint32_t detid1 = inputRawId1;
336 alignments1->
m_align.push_back(transform1);
340 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
342 alignmentErrors1->
m_alignError.push_back(transformError);
365 for (
int i = 0;
i < nEntries2; ++
i) {
367 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
368 CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
369 uint32_t detid2 = inputRawId2;
371 alignments2->
m_align.push_back(transform2);
375 CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
377 alignmentErrors2->
m_alignError.push_back(transformError);
401 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
408 int inputDtype1, inputDtype2;
409 std::vector<double> inputDpar1;
410 std::vector<double> inputDpar2;
411 std::vector<double>* p_inputDpar1 = &inputDpar1;
412 std::vector<double>* p_inputDpar2 = &inputDpar2;
424 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
425 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
430 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
431 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
441 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
455 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
456 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
461 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
462 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
468 delete alignmentErrors1;
470 delete alignmentErrors2;
477 int inputSubdetid1, inputSubdetid2;
478 int inputDtype1, inputDtype2;
479 std::vector<double> inputDpar1;
480 std::vector<double> inputDpar2;
481 std::vector<double>* p_inputDpar1 = &inputDpar1;
482 std::vector<double>* p_inputDpar2 = &inputDpar2;
485 refTree->SetBranchAddress(
"irawid", &inputRawid1);
486 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
487 refTree->SetBranchAddress(
"dtype", &inputDtype1);
488 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
491 curTree->SetBranchAddress(
"irawid", &inputRawid2);
492 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
493 curTree->SetBranchAddress(
"dtype", &inputDtype2);
494 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
496 unsigned int nEntries11 = refTree->GetEntries();
497 unsigned int nEntries12 = curTree->GetEntries();
499 if (nEntries11 != nEntries12) {
500 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
504 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
505 refTree->GetEntry(iEntry);
506 curTree->GetEntry(iEntry);
507 for (
int ii = 0;
ii < 13; ++
ii) {
510 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
511 if (inputRawid1 == inputRawid2) {
512 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
513 std::stringstream histname0;
514 histname0 <<
"SurfDeform_Par_" << npar;
517 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
518 std::stringstream histname1;
519 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
523 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
524 std::stringstream histname2;
525 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
538 std::vector<double> inputDpar2;
539 std::vector<double>* p_inputDpar2 = &inputDpar2;
542 curTree->SetBranchAddress(
"irawid", &inputRawid2);
543 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
544 curTree->SetBranchAddress(
"dtype", &inputDtype2);
545 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
547 unsigned int nEntries12 = curTree->GetEntries();
549 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
550 curTree->GetEntry(iEntry);
551 for (
int ii = 0;
ii < 12; ++
ii) {
554 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
556 std::stringstream histname0;
557 histname0 <<
"SurfDeform_Par_" << npar;
560 if (inputSubdetid2 == 1) {
561 std::stringstream histname1;
562 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
566 if (inputSubdetid2 == 2) {
567 std::stringstream histname2;
568 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
580 std::vector<double> inputDpar1;
581 std::vector<double>* p_inputDpar1 = &inputDpar1;
584 refTree->SetBranchAddress(
"irawid", &inputRawid1);
585 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
586 refTree->SetBranchAddress(
"dtype", &inputDtype1);
587 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
589 unsigned int nEntries11 = refTree->GetEntries();
591 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
592 refTree->GetEntry(iEntry);
593 for (
int ii = 0;
ii < 12; ++
ii) {
596 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
598 std::stringstream histname0;
599 histname0 <<
"SurfDeform_Par_" << npar;
602 if (inputSubdetid1 == 1) {
603 std::stringstream histname1;
604 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
608 if (inputSubdetid1 == 2) {
609 std::stringstream histname2;
610 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
619 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
629 using namespace align;
634 unsigned int nComp = refComp.size();
636 bool useLevel =
false;
649 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
650 Rtotal.set(0., 0., 0.);
651 Wtotal.set(0., 0., 0.);
652 lRtotal.set(0., 0., 0.);
653 lWtotal.set(0., 0., 0.);
655 bool converged =
false;
659 for (
int i = 0;
i < 100;
i++) {
670 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
678 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
679 CLHEP::HepRotation drot(dW.unit(), dW.mag());
681 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
683 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
684 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
685 rotLocal *= drotLocal;
686 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
687 rotLocal.axis().y() * rotLocal.delta(),
688 rotLocal.axis().z() * rotLocal.delta());
710 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
715 TRtot(1) = Rtotal.x();
716 TRtot(2) = Rtotal.y();
717 TRtot(3) = Rtotal.z();
718 TRtot(4) = Wtotal.x();
719 TRtot(5) = Wtotal.y();
720 TRtot(6) = Wtotal.z();
722 TRtot(7) = lRtotal.x();
723 TRtot(8) = lRtotal.y();
724 TRtot(9) = lRtotal.z();
725 TRtot(10) = lWtotal.x();
726 TRtot(11) = lWtotal.y();
727 TRtot(12) = lWtotal.z();
729 fillTree(refAli, TRtot, tTopo, iSetup);
733 for (
unsigned int i = 0;
i < nComp; ++
i)
738 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
753 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
769 TrackerCommonTR(1) = theRprime.x();
770 TrackerCommonTR(2) = theRprime.y();
771 TrackerCommonTR(3) = theRprime.z();
776 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
785 unsigned int nComp = refComp.size();
787 bool useLevel =
false;
793 CLHEP::Hep3Vector Rtotal, Wtotal;
794 Rtotal.set(0., 0., 0.);
795 Wtotal.set(0., 0., 0.);
801 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
802 CLHEP::HepRotation drot(dW.unit(), dW.mag());
804 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
811 for (
unsigned int i = 0;
i < nComp; ++
i)
940 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
941 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
942 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
943 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
944 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
945 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
948 for (
const auto&
i : allGeomDets) {
949 if (
i->components().size() == 1) {
950 rcdAlis.push_back(
i);
951 }
else if (
i->components().size() > 1) {
952 rcdAlis.push_back(
i);
953 const auto&
comp =
i->components();
954 for (
const auto&
j :
comp)
955 rcdAlis.push_back(
j);
960 for (
const auto&
k : rcdAlis) {
964 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
965 CLHEP::HepRotation clhepRotation(
981 unsigned int nComp =
comp.size();
983 for (
unsigned int i = 0;
i < nComp; ++
i)
989 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
1011 for (
int i = 0;
i < nEntries;
i++) {
1020 switch (subdetlevel) {
1076 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)