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),
112 while (!
fin.eof() &&
fin.good()) {
179 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
188 for (
int ii = 0;
ii < 13; ++
ii) {
189 std::stringstream histname0;
190 histname0 <<
"SurfDeform_Par_" <<
ii;
191 m_h1_[histname0.str()] = subDir_All.
make<TH1D>(
194 std::stringstream histname1;
195 histname1 <<
"SurfDeform_PixelBarrel_Par_" <<
ii;
196 m_h1_[histname1.str()] = subDir_PXB.
make<TH1D>(
199 std::stringstream histname2;
200 histname2 <<
"SurfDeform_PixelEndcap_Par_" <<
ii;
201 m_h1_[histname2.str()] = subDir_PXF.
make<TH1D>(
210 for (std::vector<TrackerMap>::iterator it =
m_vtkmap_.begin(); it !=
m_vtkmap_.end(); ++it) {
211 std::stringstream mapname;
212 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << iname <<
".png";
213 it->save(
true, 0, 0, mapname.str());
216 mapname <<
surfdir_ <<
"/TkMap_SurfDeform" << iname <<
".pdf";
217 it->save(
true, 0, 0, mapname.str());
264 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available";
268 *myAlignmentErrorsExtended, poolDbService->
beginOfTime(),
"TrackerAlignmentErrorExtendedRcd");
276 int inputRawId1, inputRawId2;
277 double inputX1, inputY1, inputZ1, inputX2, inputY2, inputZ2;
278 double inputAlpha1, inputBeta1, inputGamma1, inputAlpha2, inputBeta2, inputGamma2;
292 edm::LogInfo(
"TrackerGeometryCompare") <<
"Error: Module list not found! Please verify that given list exists!";
311 for (
int i = 0;
i < nEntries1; ++
i) {
313 CLHEP::Hep3Vector translation1(inputX1, inputY1, inputZ1);
314 CLHEP::HepEulerAngles eulerangles1(inputAlpha1, inputBeta1, inputGamma1);
315 uint32_t detid1 = inputRawId1;
317 alignments1->
m_align.push_back(transform1);
320 CLHEP::HepSymMatrix clhepSymMatrix(3, 0);
322 alignmentErrors1->
m_alignError.push_back(transformError);
345 for (
int i = 0;
i < nEntries2; ++
i) {
347 CLHEP::Hep3Vector translation2(inputX2, inputY2, inputZ2);
348 CLHEP::HepEulerAngles eulerangles2(inputAlpha2, inputBeta2, inputGamma2);
349 uint32_t detid2 = inputRawId2;
351 alignments2->
m_align.push_back(transform2);
354 CLHEP::HepSymMatrix clhepSymMatrix(3, 0);
356 alignmentErrors2->
m_alignError.push_back(transformError);
381 &(*theRefTracker), &(*alignments1), &(*alignmentErrors1),
AlignTransform());
388 int inputDtype1, inputDtype2;
389 std::vector<double> inputDpar1;
390 std::vector<double> inputDpar2;
391 std::vector<double>* p_inputDpar1 = &inputDpar1;
392 std::vector<double>* p_inputDpar2 = &inputDpar2;
404 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries11 = " << nEntries11;
405 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
410 if (
int(comp1[iEntry]->
id()) == inputRawid1) {
411 comp1[iEntry]->setSurfaceDeformation(surfDef1,
true);
421 &(*theCurTracker), &(*alignments2), &(*alignmentErrors2),
AlignTransform());
435 edm::LogInfo(
"TrackerGeometryCompare") <<
" nentries12 = " << nEntries12;
436 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
441 if (
int(comp2[iEntry]->
id()) == inputRawid2) {
442 comp2[iEntry]->setSurfaceDeformation(surfDef2,
true);
448 delete alignmentErrors1;
450 delete alignmentErrors2;
457 int inputSubdetid1, inputSubdetid2;
458 int inputDtype1, inputDtype2;
459 std::vector<double> inputDpar1;
460 std::vector<double> inputDpar2;
461 std::vector<double>* p_inputDpar1 = &inputDpar1;
462 std::vector<double>* p_inputDpar2 = &inputDpar2;
465 refTree->SetBranchAddress(
"irawid", &inputRawid1);
466 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
467 refTree->SetBranchAddress(
"dtype", &inputDtype1);
468 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
471 curTree->SetBranchAddress(
"irawid", &inputRawid2);
472 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
473 curTree->SetBranchAddress(
"dtype", &inputDtype2);
474 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
476 unsigned int nEntries11 = refTree->GetEntries();
477 unsigned int nEntries12 = curTree->GetEntries();
479 if (nEntries11 != nEntries12) {
480 edm::LogError(
"TrackerGeometryCompare") <<
" Surface deformation parameters in two geometries differ!\n";
484 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
485 refTree->GetEntry(iEntry);
486 curTree->GetEntry(iEntry);
487 for (
int ii = 0;
ii < 13; ++
ii) {
490 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
491 if (inputRawid1 == inputRawid2) {
492 surfDeform_[npar] = inputDpar2.at(npar) - inputDpar1.at(npar);
493 std::stringstream histname0;
494 histname0 <<
"SurfDeform_Par_" << npar;
497 if (inputSubdetid1 == 1 && inputSubdetid2 == 1) {
498 std::stringstream histname1;
499 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
503 if (inputSubdetid1 == 2 && inputSubdetid2 == 2) {
504 std::stringstream histname2;
505 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
518 std::vector<double> inputDpar2;
519 std::vector<double>* p_inputDpar2 = &inputDpar2;
522 curTree->SetBranchAddress(
"irawid", &inputRawid2);
523 curTree->SetBranchAddress(
"subdetid", &inputSubdetid2);
524 curTree->SetBranchAddress(
"dtype", &inputDtype2);
525 curTree->SetBranchAddress(
"dpar", &p_inputDpar2);
527 unsigned int nEntries12 = curTree->GetEntries();
529 for (
unsigned int iEntry = 0; iEntry < nEntries12; ++iEntry) {
530 curTree->GetEntry(iEntry);
531 for (
int ii = 0;
ii < 12; ++
ii) {
534 for (
int npar = 0; npar <
int(inputDpar2.size()); ++npar) {
536 std::stringstream histname0;
537 histname0 <<
"SurfDeform_Par_" << npar;
540 if (inputSubdetid2 == 1) {
541 std::stringstream histname1;
542 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
546 if (inputSubdetid2 == 2) {
547 std::stringstream histname2;
548 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
560 std::vector<double> inputDpar1;
561 std::vector<double>* p_inputDpar1 = &inputDpar1;
564 refTree->SetBranchAddress(
"irawid", &inputRawid1);
565 refTree->SetBranchAddress(
"subdetid", &inputSubdetid1);
566 refTree->SetBranchAddress(
"dtype", &inputDtype1);
567 refTree->SetBranchAddress(
"dpar", &p_inputDpar1);
569 unsigned int nEntries11 = refTree->GetEntries();
571 for (
unsigned int iEntry = 0; iEntry < nEntries11; ++iEntry) {
572 refTree->GetEntry(iEntry);
573 for (
int ii = 0;
ii < 12; ++
ii) {
576 for (
int npar = 0; npar <
int(inputDpar1.size()); ++npar) {
578 std::stringstream histname0;
579 histname0 <<
"SurfDeform_Par_" << npar;
582 if (inputSubdetid1 == 1) {
583 std::stringstream histname1;
584 histname1 <<
"SurfDeform_PixelBarrel_Par_" << npar;
588 if (inputSubdetid1 == 2) {
589 std::stringstream histname2;
590 histname2 <<
"SurfDeform_PixelEndcap_Par_" << npar;
599 edm::LogInfo(
"TrackerGeometryCompare") <<
">>>> Comparing IDEAL with IDEAL: nothing to do! <<<<\n";
609 using namespace align;
614 unsigned int nComp = refComp.size();
616 bool useLevel =
false;
629 CLHEP::Hep3Vector Rtotal, Wtotal, lRtotal, lWtotal;
630 Rtotal.set(0., 0., 0.);
631 Wtotal.set(0., 0., 0.);
632 lRtotal.set(0., 0., 0.);
633 lWtotal.set(0., 0., 0.);
635 bool converged =
false;
639 for (
int i = 0;
i < 100;
i++) {
650 CLHEP::Hep3Vector dRLocal(-
diff[6], -
diff[7], -
diff[8]);
658 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
659 CLHEP::HepRotation drot(dW.unit(), dW.mag());
661 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
663 CLHEP::HepRotation rotLocal(lWtotal.unit(), lWtotal.mag());
664 CLHEP::HepRotation drotLocal(dWLocal.unit(), dWLocal.mag());
665 rotLocal *= drotLocal;
666 lWtotal.set(rotLocal.axis().x() * rotLocal.delta(),
667 rotLocal.axis().y() * rotLocal.delta(),
668 rotLocal.axis().z() * rotLocal.delta());
690 throw cms::Exception(
"Tolerance in TrackerGeometryCompare exceeded");
695 TRtot(1) = Rtotal.x();
696 TRtot(2) = Rtotal.y();
697 TRtot(3) = Rtotal.z();
698 TRtot(4) = Wtotal.x();
699 TRtot(5) = Wtotal.y();
700 TRtot(6) = Wtotal.z();
702 TRtot(7) = lRtotal.x();
703 TRtot(8) = lRtotal.y();
704 TRtot(9) = lRtotal.z();
705 TRtot(10) = lWtotal.x();
706 TRtot(11) = lWtotal.y();
707 TRtot(12) = lWtotal.z();
709 fillTree(refAli, TRtot, tTopo, iSetup);
713 for (
unsigned int i = 0;
i < nComp; ++
i)
718 edm::LogInfo(
"TrackerGeometryCompare") <<
"Setting Common Tracker System....";
733 edm::LogInfo(
"TrackerGeometryCompare") <<
"what we get from overlaying the pixels..." << theR <<
", " <<
rot;
749 TrackerCommonTR(1) = theRprime.x();
750 TrackerCommonTR(2) = theRprime.y();
751 TrackerCommonTR(3) = theRprime.z();
756 edm::LogInfo(
"TrackerGeometryCompare") <<
"and after the transformation: " << TrackerCommonTR;
765 unsigned int nComp = refComp.size();
767 bool useLevel =
false;
773 CLHEP::Hep3Vector Rtotal, Wtotal;
774 Rtotal.set(0., 0., 0.);
775 Wtotal.set(0., 0., 0.);
781 CLHEP::HepRotation
rot(Wtotal.unit(), Wtotal.mag());
782 CLHEP::HepRotation drot(dW.unit(), dW.mag());
784 Wtotal.set(
rot.axis().x() *
rot.delta(),
rot.axis().y() *
rot.delta(),
rot.axis().z() *
rot.delta());
791 for (
unsigned int i = 0;
i < nComp; ++
i)
920 std::copy(detPB.begin(), detPB.end(), std::back_inserter(allGeomDets));
921 std::copy(detPEC.begin(), detPEC.end(), std::back_inserter(allGeomDets));
922 std::copy(detTIB.begin(), detTIB.end(), std::back_inserter(allGeomDets));
923 std::copy(detTID.begin(), detTID.end(), std::back_inserter(allGeomDets));
924 std::copy(detTOB.begin(), detTOB.end(), std::back_inserter(allGeomDets));
925 std::copy(detTEC.begin(), detTEC.end(), std::back_inserter(allGeomDets));
928 for (
const auto&
i : allGeomDets) {
929 if (
i->components().size() == 1) {
930 rcdAlis.push_back(
i);
931 }
else if (
i->components().size() > 1) {
932 rcdAlis.push_back(
i);
933 const auto&
comp =
i->components();
934 for (
const auto&
j :
comp)
935 rcdAlis.push_back(
j);
940 for (
const auto&
k : rcdAlis) {
944 CLHEP::Hep3Vector clhepVector(
pos.x(),
pos.y(),
pos.z());
945 CLHEP::HepRotation clhepRotation(
961 unsigned int nComp =
comp.size();
963 for (
unsigned int i = 0;
i < nComp; ++
i)
969 throw cms::Exception(
"DatabaseError") <<
"Error reading survey info from DB. Mismatched id!";
991 for (
int i = 0;
i < nEntries;
i++) {
1000 switch (subdetlevel) {
1056 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
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
#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.
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_