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

Update L1TrackTrigger step to DD4hep #37005

Merged
merged 4 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion L1Trigger/TrackerDTC/interface/Setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Geometry/CommonTopologies/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/DDCMS/interface/DDCompactView.h"
#include "L1Trigger/TrackTrigger/interface/TTStubAlgorithm_official.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h"
Expand Down Expand Up @@ -453,6 +454,9 @@ namespace trackerDTC {
// pset id of current geometry configuration
edm::ParameterSetID pSetIdGeometryConfiguration_;

// DD4hep
bool fromDD4hep_;

// Parameter to check if configured Tracker Geometry is supported
edm::ParameterSet pSetSG_;
// label of ESProducer/ESSource
Expand Down Expand Up @@ -936,4 +940,4 @@ namespace trackerDTC {

EVENTSETUP_DATA_DEFAULT_RECORD(trackerDTC::Setup, trackerDTC::SetupRcd);

#endif
#endif
52 changes: 37 additions & 15 deletions L1Trigger/TrackerDTC/plugins/ProducerES.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ namespace trackerDTC {
ESGetToken<TrackerTopology, TrackerTopologyRcd> getTokenTrackerTopology_;
ESGetToken<TrackerDetToDTCELinkCablingMap, TrackerDetToDTCELinkCablingMapRcd> getTokenCablingMap_;
ESGetToken<DDCompactView, IdealGeometryRecord> getTokenGeometryConfiguration_;
ESGetToken<cms::DDCompactView, IdealGeometryRecord> getTokenGeometryConfigurationDD4hep_;
bool fromDD4hep_;
};

ProducerES::ProducerES(const ParameterSet& iConfig) : iConfig_(iConfig) {
fromDD4hep_ = iConfig.getParameter<bool>("fromDD4hep");
auto cc = setWhatProduced(this);
getTokenTTStubAlgorithm_ = cc.consumes();
getTokenMagneticField_ = cc.consumes();
getTokenTrackerGeometry_ = cc.consumes();
getTokenTrackerTopology_ = cc.consumes();
getTokenCablingMap_ = cc.consumes();
getTokenGeometryConfiguration_ = cc.consumes();
if (fromDD4hep_)
getTokenGeometryConfigurationDD4hep_ = cc.consumes();
else
getTokenGeometryConfiguration_ = cc.consumes();
}

unique_ptr<Setup> ProducerES::produce(const SetupRcd& setupRcd) {
Expand All @@ -52,25 +58,41 @@ namespace trackerDTC {
const TrackerTopology& trackerTopology = setupRcd.get(getTokenTrackerTopology_);
const TrackerDetToDTCELinkCablingMap& cablingMap = setupRcd.get(getTokenCablingMap_);
const ESHandle<StubAlgorithm> handleStubAlgorithm = setupRcd.getHandle(getTokenTTStubAlgorithm_);
const ESHandle<DDCompactView> handleGeometryConfiguration = setupRcd.getHandle(getTokenGeometryConfiguration_);
const ParameterSetID& pSetIdTTStubAlgorithm = handleStubAlgorithm.description()->pid_;
const ParameterSetID& pSetIdGeometryConfiguration = handleGeometryConfiguration.description()->pid_;
const StubAlgorithmOfficial& stubAlgoritm =
*dynamic_cast<const StubAlgorithmOfficial*>(&setupRcd.get(getTokenTTStubAlgorithm_));
const ParameterSet& pSetStubAlgorithm = getParameterSet(handleStubAlgorithm.description()->pid_);
const ParameterSet& pSetGeometryConfiguration = getParameterSet(handleGeometryConfiguration.description()->pid_);
return make_unique<Setup>(iConfig_,
magneticField,
trackerGeometry,
trackerTopology,
cablingMap,
stubAlgoritm,
pSetStubAlgorithm,
pSetGeometryConfiguration,
pSetIdTTStubAlgorithm,
pSetIdGeometryConfiguration);
if (fromDD4hep_) {
const ESHandle<cms::DDCompactView> handleGeometryConfiguration =
setupRcd.getHandle(getTokenGeometryConfigurationDD4hep_);
const ParameterSetID& pSetIdGeometryConfiguration = handleGeometryConfiguration.description()->pid_;
const ParameterSet& pSetGeometryConfiguration = getParameterSet(handleGeometryConfiguration.description()->pid_);
return make_unique<Setup>(iConfig_,
magneticField,
trackerGeometry,
trackerTopology,
cablingMap,
stubAlgoritm,
pSetStubAlgorithm,
pSetGeometryConfiguration,
pSetIdTTStubAlgorithm,
pSetIdGeometryConfiguration);
} else {
const ESHandle<DDCompactView> handleGeometryConfiguration = setupRcd.getHandle(getTokenGeometryConfiguration_);
const ParameterSetID& pSetIdGeometryConfiguration = handleGeometryConfiguration.description()->pid_;
const ParameterSet& pSetGeometryConfiguration = getParameterSet(handleGeometryConfiguration.description()->pid_);
return make_unique<Setup>(iConfig_,
magneticField,
trackerGeometry,
trackerTopology,
cablingMap,
stubAlgoritm,
pSetStubAlgorithm,
pSetGeometryConfiguration,
pSetIdTTStubAlgorithm,
pSetIdGeometryConfiguration);
}
}

} // namespace trackerDTC

DEFINE_FWK_EVENTSETUP_MODULE(trackerDTC::ProducerES);
11 changes: 10 additions & 1 deletion L1Trigger/TrackerDTC/python/ProducerES_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@

from L1Trigger.TrackerDTC.ProducerES_cfi import TrackTrigger_params

TrackTriggerSetup = cms.ESProducer("trackerDTC::ProducerES", TrackTrigger_params)
from Configuration.ProcessModifiers.dd4hep_cff import dd4hep
dd4hep.toModify(TrackTrigger_params,
fromDD4hep = cms.bool(True),
ProcessHistory = cms.PSet (
GeometryConfiguration = cms.string("DDDetectorESProducer@"),
TTStubAlgorithm = cms.string("TTStubAlgorithm_official_Phase2TrackerDigi_@")
)
)

TrackTriggerSetup = cms.ESProducer("trackerDTC::ProducerES", TrackTrigger_params)
2 changes: 2 additions & 0 deletions L1Trigger/TrackerDTC/python/ProducerES_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

TrackTrigger_params = cms.PSet (

fromDD4hep = cms.bool(False),

# Parameter to check if configured Tracker Geometry is supported
SupportedGeometry = cms.PSet (
XMLLabel = cms.string ("geomXMLFiles" ), # label of ESProducer/ESSource
Expand Down
43 changes: 24 additions & 19 deletions L1Trigger/TrackerDTC/src/Setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace trackerDTC {
pSetGC_(&pSetGeometryConfiguration),
pSetIdTTStubAlgorithm_(pSetIdTTStubAlgorithm),
pSetIdGeometryConfiguration_(pSetIdGeometryConfiguration),
// DD4hep
fromDD4hep_(iConfig.getParameter<bool>("fromDD4hep")),
// Parameter to check if configured Tracker Geometry is supported
pSetSG_(iConfig.getParameter<ParameterSet>("SupportedGeometry")),
sgXMLLabel_(pSetSG_.getParameter<string>("XMLLabel")),
Expand Down Expand Up @@ -354,24 +356,27 @@ namespace trackerDTC {

// check if geometry is supported
void Setup::checkGeometry() {
const vector<string>& geomXMLFiles = pSetGC_->getParameter<vector<string>>(sgXMLLabel_);
string version;
for (const string& geomXMLFile : geomXMLFiles) {
const auto begin = geomXMLFile.find(sgXMLPath_) + sgXMLPath_.size();
const auto end = geomXMLFile.find(sgXMLFile_);
if (begin != string::npos && end != string::npos)
version = geomXMLFile.substr(begin, end - begin - 1);
}
if (version.empty()) {
cms::Exception exception("LogicError");
exception << "No " << sgXMLPath_ << "*/" << sgXMLFile_ << " found in GeometryConfiguration";
exception.addContext("tt::Setup::checkGeometry");
throw exception;
}
if (find(sgXMLVersions_.begin(), sgXMLVersions_.end(), version) == sgXMLVersions_.end()) {
configurationSupported_ = false;
LogWarning("ConfigurationNotSupported")
<< "Geometry Configuration " << sgXMLPath_ << version << "/" << sgXMLFile_ << " is not supported. ";
//FIX ME: Can we assume that geometry used in dd4hep wf supports L1Track?
if (!fromDD4hep_) {
const vector<string>& geomXMLFiles = pSetGC_->getParameter<vector<string>>(sgXMLLabel_);
string version;
for (const string& geomXMLFile : geomXMLFiles) {
const auto begin = geomXMLFile.find(sgXMLPath_) + sgXMLPath_.size();
const auto end = geomXMLFile.find(sgXMLFile_);
if (begin != string::npos && end != string::npos)
version = geomXMLFile.substr(begin, end - begin - 1);
}
if (version.empty()) {
cms::Exception exception("LogicError");
exception << "No " << sgXMLPath_ << "*/" << sgXMLFile_ << " found in GeometryConfiguration";
exception.addContext("tt::Setup::checkGeometry");
throw exception;
}
if (find(sgXMLVersions_.begin(), sgXMLVersions_.end(), version) == sgXMLVersions_.end()) {
configurationSupported_ = false;
LogWarning("ConfigurationNotSupported")
<< "Geometry Configuration " << sgXMLPath_ << version << "/" << sgXMLFile_ << " is not supported. ";
}
}
}

Expand Down Expand Up @@ -727,4 +732,4 @@ namespace trackerDTC {
}
}

} // namespace trackerDTC
} // namespace trackerDTC