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] start on geometry XML payload producer #33548

Closed
wants to merge 6 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BarrelDigis=cms.InputTag('ecalDigis','ebDigis'),
EndcapDigis=cms.InputTag('ecalDigis','eeDigis'),
tcdsRecord =cms.InputTag('tcdsDigis','tcdsRecord'),
requireStableBeam = cms.bool(True),
requireStableBeam = cms.bool(False),
pedestalSamples=cms.uint32(2), # number of presamples to be used for pedestal determination
checkSignal = cms.bool(False), # whether or not to exclude digis containing a signal
sThresholdEB = cms.uint32(10), # threshold to define a digi as containing signal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<open_geometry/>
<close_geometry/>
<xml_geometry_payload/>

<ConstantsSection label="" eval="true">
<Constant name="world_x" value="5*m"/>
Expand Down
5 changes: 3 additions & 2 deletions DetectorDescription/DDCMS/data/cms-test-shapes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
<debug_includes/>
<debug_volumes/>
<debug_constants/>
<debug_namespaces/-->
<debug_namespaces/
<debug_placements/>
<!--debug_algorithms/>
<debug_algorithms/>
<debug_materials/>
<debug_visattr/-->
</debug>

<open_geometry/>
<!--close_geometry/-->
<xml_geometry_payload/>

<ConstantsSection label="" eval="true">
<Constant name="world_x" value="5*m"/>
Expand Down
1 change: 1 addition & 0 deletions DetectorDescription/DDCMS/interface/DDParsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace cms {
bool debug_namespaces = false;
bool debug_algorithms = false;
bool debug_specpars = false;
bool xml_geometry_payload = false;

dd4hep::Detector& description;

Expand Down
1 change: 1 addition & 0 deletions DetectorDescription/DDCMS/interface/DDXMLTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace cms {
UNICODE(close_geometry);
UNICODE(IncludeSection);
UNICODE(Include);
UNICODE(xml_geometry_payload);

} // namespace cms

Expand Down
63 changes: 63 additions & 0 deletions DetectorDescription/DDCMS/plugins/dd4hep/DDDefinitions2Objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "XML/Utilities.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DataFormats/Math/interface/CMSUnits.h"
#include "DetectorDescription/DDCMS/interface/DDAlgoArguments.h"
#include "DetectorDescription/DDCMS/interface/DDNamespace.h"
Expand All @@ -35,6 +36,7 @@ using namespace std;
using namespace dd4hep;
using namespace cms;
using namespace cms_units::operators;
using namespace geant_units::operators;

namespace dd4hep {

Expand Down Expand Up @@ -469,6 +471,13 @@ void Converter<DDLElementaryMaterial>::operator()(xml_h element) const {
TGeoElementTable* tab = mgr.GetElementTable();
int nElem = tab->GetNelements();

if (ns.context()->xml_geometry_payload) {
std::cout << "<ElementaryMaterial name=\"" << matname << "\""
<< " density=\"" << std::scientific << std::setprecision(5) << density << "*mg/cm3\""
<< " atomicWeight=\"" << std::fixed << atomicWeight << "*g/mole\"" << std::setprecision(0) << std::fixed
<< " atomicNumber=\"" << atomicNumber << "\"/>" << std::endl;
}

#ifdef EDM_ML_DEBUG

printout(ns.context()->debug_materials ? ALWAYS : DEBUG, "DD4CMS", "+++ Element table size = %d", nElem);
Expand Down Expand Up @@ -582,6 +591,13 @@ void Converter<DDLCompositeMaterial>::operator()(xml_h element) const {
if (nullptr == mat) {
const char* matname = nam.c_str();
double density = xmat.attr<double>(DD_CMU(density)) / (dd4hep::g / dd4hep::cm3);
if (ns.context()->xml_geometry_payload) {
std::cout << "<CompositeMaterial name=\"" << nam << "\""
<< " density=\"" << std::scientific << std::setprecision(5) << convertUnitsTo(1._mg_per_cm3, density)
<< "*mg/cm3\""
<< " method=\"mixture by weight\">" << std::endl;
}

xml_coll_t composites(xmat, DD_CMU(MaterialFraction));
TGeoMixture* mix = new TGeoMixture(nam.c_str(), composites.size(), density);

Expand All @@ -601,6 +617,12 @@ void Converter<DDLCompositeMaterial>::operator()(xml_h element) const {
xml_dim_t xfrac_mat(xfrac.child(DD_CMU(rMaterial)));
double fraction = xfrac.fraction();
string fracname = ns.realName(xfrac_mat.nameStr());
if (ns.context()->xml_geometry_payload) {
std::cout << "<MaterialFraction fraction=\"" << std::fixed << std::setprecision(9) << fraction << "\">"
<< std::endl;
std::cout << "<rMaterial name=\"" << fracname << "\"/>" << std::endl;
std::cout << "</MaterialFraction>" << std::endl;
}

TGeoMaterial* frac_mat = mgr.GetMaterial(fracname.c_str());
if (frac_mat == nullptr) // Try to find it within this namespace
Expand Down Expand Up @@ -634,6 +656,9 @@ void Converter<DDLCompositeMaterial>::operator()(xml_h element) const {
medium->SetTitle("material");
medium->SetUniqueID(unique_mat_id);
}
if (ns.context()->xml_geometry_payload) {
std::cout << "</CompositeMaterial>" << std::endl;
}
}
}

Expand Down Expand Up @@ -834,6 +859,11 @@ void Converter<DDLTransform3D>::operator()(xml_h element) const {
double y = ns.attr<double>(translation, _U(y));
double z = ns.attr<double>(translation, _U(z));
pos = Position(x, y, z);
if (ns.context()->xml_geometry_payload) {
std::cout << "<Translation x=\"" << x << "*mm\""
<< " y=\"" << y << "*mm\""
<< " z=\"" << z << "*mm\"/>" << std::endl;
}
}
if (rotation.ptr()) {
double x = ns.attr<double>(rotation, _U(x));
Expand All @@ -843,6 +873,9 @@ void Converter<DDLTransform3D>::operator()(xml_h element) const {
} else if (refRotation.ptr()) {
string rotName = ns.prepend(refRotation.nameStr());
rot = ns.rotation(rotName);
if (ns.context()->xml_geometry_payload) {
std::cout << "<rRotation name=\"" << rotName << "\"/>" << std::endl;
}
} else if (refReflectionRotation.ptr()) {
string rotName = ns.prepend(refReflectionRotation.nameStr());
rot = ns.rotation(rotName);
Expand Down Expand Up @@ -897,6 +930,11 @@ void Converter<DDLPosPart>::operator()(xml_h element) const {

#endif

if (ns.context()->xml_geometry_payload) {
std::cout << "<PosPart copyNumber=\"" << copy << "\">" << std::endl;
std::cout << "<rParent name=\"" << parentName << "\"/>" << std::endl;
std::cout << "<rChild name=\"" << childName << "\"/>" << std::endl;
}
PlacedVolume pv;
if (child.isValid()) {
Transform3D transform;
Expand Down Expand Up @@ -948,6 +986,9 @@ void Converter<DDLPosPart>::operator()(xml_h element) const {
childName.c_str(),
yes_no(child.isValid()));
}
if (ns.context()->xml_geometry_payload) {
std::cout << "</PosPart>" << std::endl;
}
}

/// Converter for <PartSelector/> tags
Expand Down Expand Up @@ -2068,6 +2109,9 @@ static long load_dddefinition(Detector& det, xml_h element) {
bool open_geometry = dddef.hasChild(DD_CMU(open_geometry)) ? dddef.child(DD_CMU(open_geometry)) : true;
bool close_geometry = dddef.hasChild(DD_CMU(close_geometry)) ? dddef.hasChild(DD_CMU(close_geometry)) : true;

// if (dddef.hasChild(DD_CMU(xml_geometry_payload)))
// context.xml_geometry_payload = true;

xml_coll_t(dddef, _U(debug)).for_each(Converter<debug>(det, &context));

// Here we define the order how XML elements are processed.
Expand All @@ -2087,6 +2131,8 @@ static long load_dddefinition(Detector& det, xml_h element) {
xml_coll_t(dddef, DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));

xml_coll_t(dddef, DD_CMU(IncludeSection)).for_each(DD_CMU(Include), Converter<include_load>(det, &context, &res));
if (dddef.hasChild(DD_CMU(xml_geometry_payload)))
context.xml_geometry_payload = true;

for (xml::Document d : res.includes) {
print_doc((doc = d).root());
Expand Down Expand Up @@ -2115,6 +2161,11 @@ static long load_dddefinition(Detector& det, xml_h element) {
}
}
// Now we can process the include files one by one.....
if (ns.context()->xml_geometry_payload) {
std::cout << "<MaterialSection label=\""
<< "FIXME: file name!"
<< "\">" << std::endl;
}
for (xml::Document d : res.includes) {
print_doc((doc = d).root());
xml_coll_t(d.root(), DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det, &context));
Expand Down Expand Up @@ -2164,6 +2215,10 @@ static long load_dddefinition(Detector& det, xml_h element) {
// materials left after this pass
}
}
if (ns.context()->xml_geometry_payload) {
std::cout << "</MaterialSection>" << std::endl;
}

if (open_geometry) {
det.init();
ns.addVolume(det.worldVolume());
Expand All @@ -2184,10 +2239,18 @@ static long load_dddefinition(Detector& det, xml_h element) {
print_doc((doc = d).root());
xml_coll_t(d.root(), DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det, &context));
}
if (ns.context()->xml_geometry_payload) {
std::cout << "<PosPartSection label=\""
<< "FIXME: file name!"
<< "\">" << std::endl;
}
for (xml::Document d : res.includes) {
print_doc((doc = d).root());
xml_coll_t(d.root(), DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det, &context));
}
if (ns.context()->xml_geometry_payload) {
std::cout << "</PosPartSection>" << std::endl;
}
for (xml::Document d : res.includes) {
print_doc((doc = d).root());
xml_coll_t(d.root(), DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det, &context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 3, 1
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 1, 16, 3, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
0, 0, 0, 0, 0, 0, 0, 0, 24, 4, 2, 8
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 3, 1
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 1, 16, 3, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
0, 0, 0, 0, 0, 0, 0, 0, 24, 4, 2, 8
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ void PixelCPEFastESProducer::fillDescriptions(edm::ConfigurationDescriptions& de
// specific to PixelCPEFastESProducer
desc.add<std::string>("ComponentName", "PixelCPEFast");
desc.add<edm::ESInputTag>("MagneticFieldRecord", edm::ESInputTag());
desc.addOptional<bool>("useLAAlignmentOffsets", false)->setComment("deprecated");
Copy link
Contributor

Choose a reason for hiding this comment

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

@ianna why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think rebase didn't take into an account reverted changes :-(

desc.addOptional<bool>("DoLorentz", false)->setComment("deprecated");

descriptions.add("PixelCPEFastESProducer", desc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ void PixelCPEGenericESProducer::fillDescriptions(edm::ConfigurationDescriptions&
// specific to PixelCPEGenericESProducer
desc.add<std::string>("ComponentName", "PixelCPEGeneric");
desc.add<edm::ESInputTag>("MagneticFieldRecord", edm::ESInputTag(""));
desc.addOptional<bool>("useLAAlignmentOffsets", false)->setComment("deprecated");
Copy link
Contributor

Choose a reason for hiding this comment

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

@ianna why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think rebase didn't take into an account reverted changes:


Revert "Update mtdParameters for D49 and D60 (Bug fix)", This reverts…  … 1307d75

Revert "[backport] MTD geometry and reconstruction: synchronise with …  … faf18ac

change ECAL pedestals requireStableBeam flag for MWGR test        2a9cbcd

Revert "Revert "[backport] MTD geometry and reconstruction: synchroni…  …f2a994f

revert changes breaking online HLT menu in production release         93afbed

desc.addOptional<bool>("DoLorentz", false)->setComment("deprecated");
descriptions.add("_generic_default", desc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void PixelCPETemplateRecoESProducer::fillDescriptions(edm::ConfigurationDescript

// specific to PixelCPETemplateRecoESProducer
desc.add<std::string>("ComponentName", "PixelCPETemplateReco");
desc.addOptional<bool>("DoLorentz", true)->setComment("deprecated");
Copy link
Contributor

Choose a reason for hiding this comment

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

@ianna why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same reason as above

descriptions.add("_templates_default", desc);
}

Expand Down