Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD4Hep migration (SolidShapes) for TrackerNumberingBuilder (+TkAl & related CondTool/Geometry plugins) #29905

Merged
merged 24 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f40eb91
First shot at DD4HEP migration for CondTools/Geometry and TrackerGeom…
adewit Mar 23, 2020
2518ef8
Migrate TrackerNumberingBuilder to DD4HEP-SolidShapes
adewit May 13, 2020
20e87b6
Cast to cms::DDSolidShape in MTD GeometricTimingDet
adewit May 19, 2020
32a426c
PGeometricDetBuilder: code format
adewit May 19, 2020
9dc0976
Removing some old DD headers
adewit May 19, 2020
7b51564
Make Tk plugins handle both old DD and DD4hep
adewit May 26, 2020
98f81f1
Apply CodeFormat
adewit May 26, 2020
31f7356
Add reverse lookup for LegacySolidShape mape and define unsupported c…
adewit May 28, 2020
2b604b4
Apply code format
adewit May 28, 2020
71f85b4
Remove commented line
adewit May 28, 2020
2213b04
Make fromDD4hep a tracked parameter in GeometricDet/TrackerParameters…
adewit Jun 2, 2020
c46fd75
Cleanup in TrackerGeometryCompare
adewit Jun 2, 2020
dec61a7
SolidShapes enum back to original
adewit Jun 2, 2020
059a143
Code checks
adewit Jun 2, 2020
8801ff3
Removing TrackerNumberingBuilder/bin/stubs/GeometricDetLoader
adewit Jun 2, 2020
6645190
Reduce DDExpandedView use in GeometricDet and add shape_dd4hep
adewit Jun 4, 2020
8a2e981
Code format
adewit Jun 4, 2020
ed8b751
Match enums for Legacy and DD4hep SolidShapes
adewit Jun 18, 2020
dcff114
Update DDSolidLegacyShapes unit test
adewit Jun 18, 2020
af5c936
Apply code format
adewit Jun 18, 2020
fbe5d2a
DDSolidLegacyShapes conflict fix attempt
adewit Jun 18, 2020
285678b
GeometricDet: have shape_dd4hep return by value
adewit Jun 18, 2020
823074d
GeometricDet: fix include
adewit Jun 26, 2020
637ae06
Code format
adewit Jun 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
620 changes: 300 additions & 320 deletions Alignment/OfflineValidation/plugins/TrackerGeometryCompare.cc

Large diffs are not rendered by default.

95 changes: 48 additions & 47 deletions Alignment/OfflineValidation/plugins/TrackerGeometryCompare.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,64 +100,65 @@ class TrackerGeometryCompare : public edm::EDAnalyzer {
const SurveyErrors* theSurveyErrors;

// configurables
const std::vector<std::string> _levelStrings;
std::string _moduleListName;
std::string _inputFilename1;
std::string _inputFilename2;
std::string _inputTreenameAlign;
std::string _inputTreenameDeform;
bool _writeToDB;
std::string _weightBy;
std::string _setCommonTrackerSystem;
bool _detIdFlag;
std::string _detIdFlagFile;
bool _weightById;
std::string _weightByIdFile;
std::vector<unsigned int> _weightByIdVector;

std::vector<uint32_t> _detIdFlagVector;
align::StructureType _commonTrackerLevel;
align::GlobalVector _TrackerCommonT;
align::GlobalVector _TrackerCommonR;
align::PositionType _TrackerCommonCM;

std::ifstream _moduleListFile;
std::vector<int> _moduleList;
int _moduleInList;
const std::vector<std::string> levelStrings_;
std::string moduleListName_;
std::string inputFilename1_;
std::string inputFilename2_;
std::string inputTreenameAlign_;
std::string inputTreenameDeform_;
bool fromDD4hep_;
bool writeToDB_;
std::string weightBy_;
std::string setCommonTrackerSystem_;
bool detIdFlag_;
std::string detIdFlagFile_;
bool weightById_;
std::string weightByIdFile_;
std::vector<unsigned int> weightByIdVector_;

std::vector<uint32_t> detIdFlagVector_;
align::StructureType commonTrackerLevel_;
align::GlobalVector TrackerCommonT_;
align::GlobalVector TrackerCommonR_;
align::PositionType TrackerCommonCM_;

std::ifstream moduleListFile_;
std::vector<int> moduleList_;
int moduleInList_;

//root configuration
std::string _filename;
TFile* _theFile;
TTree* _alignTree;
TFile* _inputRootFile1;
TFile* _inputRootFile2;
TTree* _inputTree01;
TTree* _inputTree02;
TTree* _inputTree11;
TTree* _inputTree12;
std::string filename_;
TFile* theFile_;
TTree* alignTree_;
TFile* inputRootFile1_;
TFile* inputRootFile2_;
TTree* inputTree01_;
TTree* inputTree02_;
TTree* inputTree11_;
TTree* inputTree12_;

/**\ Tree variables */
int _id, _badModuleQuality, _inModuleList, _level, _mid, _mlevel, _sublevel, _useDetId, _detDim;
float _xVal, _yVal, _zVal, _rVal, _etaVal, _phiVal, _alphaVal, _betaVal, _gammaVal;
int id_, badModuleQuality_, inModuleList_, level_, mid_, mlevel_, sublevel_, useDetId_, detDim_;
float xVal_, yVal_, zVal_, rVal_, etaVal_, phiVal_, alphaVal_, betaVal_, gammaVal_;
// changes in global variables
float _dxVal, _dyVal, _dzVal, _drVal, _dphiVal, _dalphaVal, _dbetaVal, _dgammaVal;
float dxVal_, dyVal_, dzVal_, drVal_, dphiVal_, dalphaVal_, dbetaVal_, dgammaVal_;
// changes local variables: u, v, w, alpha, beta, gamma
float _duVal, _dvVal, _dwVal, _daVal, _dbVal, _dgVal;
float _surWidth, _surLength;
uint32_t _identifiers[6];
double _surRot[9];
int _type;
double _surfDeform[13];
float duVal_, dvVal_, dwVal_, daVal_, dbVal_, dgVal_;
float surWidth_, surLength_;
uint32_t identifiers_[6];
double surRot_[9];
int type_;
double surfDeform_[13];

int m_nBins;
double m_rangeLow;
double m_rangeHigh;
int m_nBins_;
double m_rangeLow_;
double m_rangeHigh_;

bool firstEvent_;

std::vector<TrackerMap> m_vtkmap;
std::vector<TrackerMap> m_vtkmap_;

std::map<std::string, TH1D*> m_h1;
std::map<std::string, TH1D*> m_h1_;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Full configuration for Tracker Geometry Comparison Tool
TrackerGeometryCompare = cms.EDAnalyzer("TrackerGeometryCompare",
fromDD4hep = cms.untracked.bool(False),
writeToDB = cms.untracked.bool(False),
outputFile = cms.untracked.string('output.root'),
setCommonTrackerSystem = cms.untracked.string('NONE'), ##must be "NONE" if you don't want to use this option
Expand Down
31 changes: 23 additions & 8 deletions CondTools/Geometry/plugins/PGeometricDetBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,48 @@
#include "CondFormats/GeometryObjects/interface/PGeometricDet.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here ase well

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <vector>

using DD3Vector = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
using Translation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
using RotationMatrix = ROOT::Math::Rotation3D;

class PGeometricDetBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
PGeometricDetBuilder(const edm::ParameterSet&) {}
PGeometricDetBuilder(const edm::ParameterSet&);

void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}

private:
void putOne(const GeometricDet* gd, PGeometricDet* pgd, int lev);
bool fromDD4hep_;
};

PGeometricDetBuilder::PGeometricDetBuilder(const edm::ParameterSet& iConfig) {
fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
}

void PGeometricDetBuilder::beginRun(const edm::Run&, edm::EventSetup const& es) {
PGeometricDet* pgd = new PGeometricDet;
edm::Service<cond::service::PoolDBOutputService> mydbservice;
if (!mydbservice.isAvailable()) {
edm::LogError("PGeometricDetBuilder") << "PoolDBOutputService unavailable";
return;
}
edm::ESTransientHandle<DDCompactView> pDD;
if (!fromDD4hep_) {
edm::ESTransientHandle<DDCompactView> pDD;
es.get<IdealGeometryRecord>().get(pDD);
} else {
edm::ESTransientHandle<cms::DDCompactView> pDD;
es.get<IdealGeometryRecord>().get(pDD);
}
edm::ESHandle<GeometricDet> rDD;
es.get<IdealGeometryRecord>().get(pDD);
es.get<IdealGeometryRecord>().get(rDD);
const GeometricDet* tracker = &(*rDD);

Expand Down Expand Up @@ -114,8 +129,8 @@ void PGeometricDetBuilder::beginRun(const edm::Run&, edm::EventSetup const& es)

void PGeometricDetBuilder::putOne(const GeometricDet* gd, PGeometricDet* pgd, int lev) {
PGeometricDet::Item item;
const DDTranslation& tran = gd->translation();
const DDRotationMatrix& rot = gd->rotation();
const Translation& tran = gd->translation();
const RotationMatrix& rot = gd->rotation();
DD3Vector x, y, z;
rot.GetComponents(x, y, z);
item._name = gd->name();
Expand All @@ -135,9 +150,9 @@ void PGeometricDetBuilder::putOne(const GeometricDet* gd, PGeometricDet* pgd, in
item._a31 = x.Z();
item._a32 = y.Z();
item._a33 = z.Z();
item._shape = static_cast<int>(gd->shape());
item._shape = static_cast<int>(gd->shape_dd4hep());
item._type = gd->type();
if (gd->shape() == DDSolidShape::ddbox) {
if (gd->shape_dd4hep() == cms::DDSolidShape::ddbox) {
item._params0 = gd->params()[0];
item._params1 = gd->params()[1];
item._params2 = gd->params()[2];
Expand All @@ -149,7 +164,7 @@ void PGeometricDetBuilder::putOne(const GeometricDet* gd, PGeometricDet* pgd, in
item._params8 = 0;
item._params9 = 0;
item._params10 = 0;
} else if (gd->shape() == DDSolidShape::ddtrap) {
} else if (gd->shape_dd4hep() == cms::DDSolidShape::ddtrap) {
item._params0 = gd->params()[0];
item._params1 = gd->params()[1];
item._params2 = gd->params()[2];
Expand Down
18 changes: 15 additions & 3 deletions CondTools/Geometry/plugins/PGeometricDetExtraBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,45 @@
#include "CondFormats/GeometryObjects/interface/PGeometricDetExtra.h"
#include "Geometry/Records/interface/PGeometricDetExtraRcd.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDetExtra.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <vector>

class PGeometricDetExtraBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
PGeometricDetExtraBuilder(const edm::ParameterSet&) {}
PGeometricDetExtraBuilder(const edm::ParameterSet&);

void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}

private:
void putOne(const GeometricDetExtra& gde, PGeometricDetExtra* pgde);
bool fromDD4hep_;
};

PGeometricDetExtraBuilder::PGeometricDetExtraBuilder(const edm::ParameterSet& iConfig) {
fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
}

void PGeometricDetExtraBuilder::beginRun(const edm::Run&, edm::EventSetup const& es) {
PGeometricDetExtra* pgde = new PGeometricDetExtra;
edm::Service<cond::service::PoolDBOutputService> mydbservice;
if (!mydbservice.isAvailable()) {
edm::LogError("PGeometricDetExtraBuilder") << "PoolDBOutputService unavailable";
return;
}
edm::ESTransientHandle<DDCompactView> cpvH;

if (!fromDD4hep_) {
edm::ESTransientHandle<DDCompactView> cpvH;
es.get<IdealGeometryRecord>().get(cpvH);
} else {
edm::ESTransientHandle<cms::DDCompactView> cpvH;
es.get<IdealGeometryRecord>().get(cpvH);
}
edm::ESHandle<std::vector<GeometricDetExtra> > gdeH;
es.get<IdealGeometryRecord>().get(cpvH);
es.get<IdealGeometryRecord>().get(gdeH);
const std::vector<GeometricDetExtra>& gdes = (*gdeH);

Expand Down
23 changes: 19 additions & 4 deletions CondTools/Geometry/plugins/PTrackerParametersDBBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,46 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerParametersFromDD.h"

class PTrackerParametersDBBuilder : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
PTrackerParametersDBBuilder(const edm::ParameterSet&) {}
PTrackerParametersDBBuilder(const edm::ParameterSet&);

void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override;
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override {}
void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}

private:
bool fromDD4hep_;
};

PTrackerParametersDBBuilder::PTrackerParametersDBBuilder(const edm::ParameterSet& iConfig) {
fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
}

void PTrackerParametersDBBuilder::beginRun(const edm::Run&, edm::EventSetup const& es) {
PTrackerParameters* ptp = new PTrackerParameters;
edm::Service<cond::service::PoolDBOutputService> mydbservice;
if (!mydbservice.isAvailable()) {
edm::LogError("PTrackerParametersDBBuilder") << "PoolDBOutputService unavailable";
return;
}
edm::ESTransientHandle<DDCompactView> cpv;
es.get<IdealGeometryRecord>().get(cpv);

TrackerParametersFromDD builder;
builder.build(&(*cpv), *ptp);

if (!fromDD4hep_) {
edm::ESTransientHandle<DDCompactView> cpv;
es.get<IdealGeometryRecord>().get(cpv);
builder.build(&(*cpv), *ptp);
} else {
edm::ESTransientHandle<cms::DDCompactView> cpv;
es.get<IdealGeometryRecord>().get(cpv);
builder.build(&(*cpv), *ptp);
}

if (mydbservice->isNewTagRequest("PTrackerParametersRcd")) {
mydbservice->createNewIOV<PTrackerParameters>(
Expand Down
6 changes: 3 additions & 3 deletions CondTools/Geometry/test/geometrywriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
fromDDD = cms.bool( True )
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool( False ))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder", fromDD4hep=cms.bool( False ))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder", fromDD4hep=cms.bool( False ))

process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder")

Expand Down
6 changes: 3 additions & 3 deletions CondTools/Geometry/test/trackergeometrywriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
fromDDD = cms.bool( True )
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder", fromDD4hep=cms.bool(False))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder", fromDD4hep=cms.bool(False))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder", fromDD4hep=cms.bool(False))

process.CondDB.timetype = cms.untracked.string('runnumber')
process.CondDB.connect = cms.string('sqlite_file:myfile.db')
Expand Down
6 changes: 3 additions & 3 deletions CondTools/Geometry/test/trackergeometrywriterRun2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
fromDDD = cms.bool( True )
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool( False ))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder",fromDD4hep=cms.bool( False ))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool( False ))

process.CondDB.timetype = cms.untracked.string('runnumber')
process.CondDB.connect = cms.string('sqlite_file:myfilerun2.db')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
fromDDD = cms.bool( True ),
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool(False))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder",fromDD4hep=cms.bool(False))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool(False))

process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
fromDDD = cms.bool( True ),
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool(False))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder",fromDD4hep=cms.bool(False))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool(False))

process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
fromDDD = cms.bool( True ),
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool(False))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder",fromDD4hep=cms.bool(False))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool(False))

process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
fromDDD = cms.bool( True ),
)

process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder")
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder")
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder")
process.TrackerGeometryWriter = cms.EDAnalyzer("PGeometricDetBuilder",fromDD4hep=cms.bool(False))
process.TrackerGeometryExtraWriter = cms.EDAnalyzer("PGeometricDetExtraBuilder",fromDD4hep=cms.bool(False))
process.TrackerParametersWriter = cms.EDAnalyzer("PTrackerParametersDBBuilder",fromDD4hep=cms.bool(False))

process.CaloGeometryWriter = cms.EDAnalyzer("PCaloGeometryBuilder")

Expand Down
Loading