5 #include "CLHEP/Vector/RotationInterfaces.h" 41 #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),
74 moduleListFile_(nullptr),
76 inputRootFile1_(nullptr),
77 inputRootFile2_(nullptr),
78 inputTree01_(nullptr),
79 inputTree02_(nullptr),
80 inputTree11_(nullptr),
81 inputTree12_(nullptr),
110 while (!
fin.eof() &&
fin.good()) {
120 std::ifstream inFile;
123 while (!inFile.eof()) {
127 inFile.ignore(256,
'\n');
177 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
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>(
208 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
209 std::stringstream mapname;
210 mapname <<
"TkMap_SurfDeform" << iname <<
".png";
211 it->save(
true, 0, 0, mapname.str());
214 mapname <<
"TkMap_SurfDeform" << iname <<
".pdf";
215 it->save(
true, 0, 0, mapname.str());
262 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
266 *myAlignmentErrorsExtended, poolDbService->
beginOfTime(),
"TrackerAlignmentErrorExtendedRcd");
274 int inputRawId1, inputRawId2;
275 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
276 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
290 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: Module list not found! Please verify that given list exists!";
309 for (
int i = 0;
i < nEntries1; ++
i) {
311 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
312 CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
313 uint32_t detid1 = inputRawId1;
315 alignments1->
m_align.push_back(transform1);
318 CLHEP::HepSymMatrix clhepSymMatrix(3, 0);
320 alignmentErrors1->
m_alignError.push_back(transformError);
343 for (
int i = 0;
i < nEntries2; ++
i) {
345 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
346 CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
347 uint32_t detid2 = inputRawId2;
349 alignments2->
m_align.push_back(transform2);
352 CLHEP::HepSymMatrix clhepSymMatrix(3, 0);
354 alignmentErrors2->
m_alignError.push_back(transformError);
379 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
386 int inputDtype1, inputDtype2;
387 std::vector<double> inputDpar1;
388 std::vector<double> inputDpar2;
389 std::vector<double>* p_inputDpar1 = &inputDpar1;
390 std::vector<double>* p_inputDpar2 = &inputDpar2;
402 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
403 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
408 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
409 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
419 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
433 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
434 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
439 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
440 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
446 delete alignmentErrors1;
448 delete alignmentErrors2;
455 int inputSubdetid1, inputSubdetid2;
456 int inputDtype1, inputDtype2;
457 std::vector<double> inputDpar1;
458 std::vector<double> inputDpar2;
459 std::vector<double>* p_inputDpar1 = &inputDpar1;
460 std::vector<double>* p_inputDpar2 = &inputDpar2;
463 refTree->SetBranchAddress(
"irawid", &inputRawid1);
464 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
465 refTree->SetBranchAddress(
"dtype", &inputDtype1);
466 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
469 curTree->SetBranchAddress(
"irawid", &inputRawid2);
470 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
471 curTree->SetBranchAddress(
"dtype", &inputDtype2);
472 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
474 unsigned int nEntries11 = refTree->GetEntries();
475 unsigned int nEntries12 = curTree->GetEntries();
477 if (nEntries11 != nEntries12) {
478 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
482 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
483 refTree->GetEntry(iEntry);
484 curTree->GetEntry(iEntry);
485 for (
int ii = 0;
ii < 13; ++
ii) {
488 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
489 if (inputRawid1 == inputRawid2) {
490 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
491 std::stringstream histname0;
492 histname0 <<
"SurfDeform_Par_" << npar;
495 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
496 std::stringstream histname1;
497 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
501 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
502 std::stringstream histname2;
503 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
516 std::vector<double> inputDpar2;
517 std::vector<double>* p_inputDpar2 = &inputDpar2;
520 curTree->SetBranchAddress(
"irawid", &inputRawid2);
521 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
522 curTree->SetBranchAddress(
"dtype", &inputDtype2);
523 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
525 unsigned int nEntries12 = curTree->GetEntries();
527 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
528 curTree->GetEntry(iEntry);
529 for (
int ii = 0;
ii < 12; ++
ii) {
532 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
534 std::stringstream histname0;
535 histname0 <<
"SurfDeform_Par_" << npar;
538 if (inputSubdetid2 == 1) {
539 std::stringstream histname1;
540 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
544 if (inputSubdetid2 == 2) {
545 std::stringstream histname2;
546 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
558 std::vector<double> inputDpar1;
559 std::vector<double>* p_inputDpar1 = &inputDpar1;
562 refTree->SetBranchAddress(
"irawid", &inputRawid1);
563 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
564 refTree->SetBranchAddress(
"dtype", &inputDtype1);
565 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
567 unsigned int nEntries11 = refTree->GetEntries();
569 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
570 refTree->GetEntry(iEntry);
571 for (
int ii = 0;
ii < 12; ++
ii) {
574 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
576 std::stringstream histname0;
577 histname0 <<
"SurfDeform_Par_" << npar;
580 if (inputSubdetid1 == 1) {
581 std::stringstream histname1;
582 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
586 if (inputSubdetid1 == 2) {
587 std::stringstream histname2;
588 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
597 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
607 using namespace align;
612 unsigned int nComp = refComp.size();
614 bool useLevel =
false;
627 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
628 Rtotal.set(0., 0., 0.);
629 Wtotal.set(0., 0., 0.);
630 lRtotal.set(0., 0., 0.);
631 lWtotal.set(0., 0., 0.);
633 bool converged =
false;
637 for (
int i = 0;
i < 100;
i++) {
648 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
656 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
657 CLHEP::HepRotation drot(dW.unit(), dW.mag());
659 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
661 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
662 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
663 rotLocal *= drotLocal;
664 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
665 rotLocal.axis().y() * rotLocal.delta(),
666 rotLocal.axis().z() * rotLocal.delta());
688 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
693 TRtot(1) = Rtotal.x();
694 TRtot(2) = Rtotal.y();
695 TRtot(3) = Rtotal.z();
696 TRtot(4) = Wtotal.x();
697 TRtot(5) = Wtotal.y();
698 TRtot(6) = Wtotal.z();
700 TRtot(7) = lRtotal.x();
701 TRtot(8) = lRtotal.y();
702 TRtot(9) = lRtotal.z();
703 TRtot(10) = lWtotal.x();
704 TRtot(11) = lWtotal.y();
705 TRtot(12) = lWtotal.z();
707 fillTree(refAli, TRtot, tTopo, iSetup);
711 for (
unsigned int i = 0;
i < nComp; ++
i)
716 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
731 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
747 TrackerCommonTR(1) = theRprime.x();
748 TrackerCommonTR(2) = theRprime.y();
749 TrackerCommonTR(3) = theRprime.z();
754 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
763 unsigned int nComp = refComp.size();
765 bool useLevel =
false;
771 CLHEP::Hep3Vector Rtotal, Wtotal;
772 Rtotal.set(0., 0., 0.);
773 Wtotal.set(0., 0., 0.);
779 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
780 CLHEP::HepRotation drot(dW.unit(), dW.mag());
782 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
789 for (
unsigned int i = 0;
i < nComp; ++
i)
918 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
919 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
920 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
921 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
922 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
923 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
926 for (
const auto&
i : allGeomDets) {
927 if (
i->components().size() == 1) {
928 rcdAlis.push_back(
i);
929 }
else if (
i->components().size() > 1) {
930 rcdAlis.push_back(
i);
931 const auto&
comp =
i->components();
932 for (
const auto&
j :
comp)
933 rcdAlis.push_back(
j);
938 for (
const auto&
k : rcdAlis) {
942 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
943 CLHEP::HepRotation clhepRotation(
959 unsigned int nComp =
comp.size();
961 for (
unsigned int i = 0;
i < nComp; ++
i)
967 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
989 for (
int i = 0;
i < nEntries;
i++) {
998 switch (subdetlevel) {
1054 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: bad subdetid!!";
std::ifstream moduleListFile_
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)
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
#define DEFINE_FWK_MODULE(type)
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
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
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.
bool getData(T &iHolder) const
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_