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

MTD geometry: move topology parameters from PSet to xml, adapt the code #25417

Merged
merged 7 commits into from Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,6 +17,7 @@ int main()
testSerialization<PTrackerParameters::Item>();
testSerialization<HcalParameters>();
testSerialization<PHGCalParameters>();
testSerialization<PMTDParameters>();

return 0;
}
4 changes: 4 additions & 0 deletions Configuration/Geometry/python/dict2023Geometry.py
Expand Up @@ -813,6 +813,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtd.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtdParameters.xml',
],
3 : [
'Geometry/MTDSimData/data/CrystalTile/mtdsens.xml'
Expand Down Expand Up @@ -840,6 +841,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtdParameters.xml',
],
3 : [
'Geometry/MTDSimData/data/CrystalBar/mtdsens.xml'
Expand Down Expand Up @@ -867,6 +869,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdParameters.xml',
],
3 : [
'Geometry/MTDSimData/data/CrystalBarZflat/mtdsens.xml'
Expand Down Expand Up @@ -894,6 +897,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtdParameters.xml',
],
3 : [
'Geometry/MTDSimData/data/CrystalBarZflat/mtdsens.xml'
Expand Down
Expand Up @@ -92,6 +92,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtd.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalTile/mtdParameters.xml',
)+
cms.vstring(
'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml',
Expand Down
Expand Up @@ -92,6 +92,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBar/mtdParameters.xml',
)+
cms.vstring(
'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml',
Expand Down
Expand Up @@ -92,6 +92,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdParameters.xml',
)+
cms.vstring(
'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml',
Expand Down
Expand Up @@ -92,6 +92,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBarZflatNOhole/mtdParameters.xml',
)+
cms.vstring(
'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml',
Expand Down
Expand Up @@ -94,6 +94,7 @@
'Geometry/MTDCommonData/data/etl.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtd.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdStructureTopology.xml',
'Geometry/MTDCommonData/data/CrystalBarZflat/mtdParameters.xml',
)+
cms.vstring(
'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml',
Expand Down
16 changes: 16 additions & 0 deletions Geometry/MTDCommonData/data/CrystalBar/mtdParameters.xml
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
<ConstantsSection label="mtdParameters.xml" eval="true">

<Vector name="vPars" type="numeric" nEntries="4">
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 1, 16, 4, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
</DDDefinition>
16 changes: 16 additions & 0 deletions Geometry/MTDCommonData/data/CrystalBarZflat/mtdParameters.xml
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
<ConstantsSection label="mtdParameters.xml" eval="true">

<Vector name="vPars" type="numeric" nEntries="4">
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 1, 16, 4, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
</DDDefinition>
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
<ConstantsSection label="mtdParameters.xml" eval="true">

<Vector name="vPars" type="numeric" nEntries="4">
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 1, 16, 4, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
</DDDefinition>
16 changes: 16 additions & 0 deletions Geometry/MTDCommonData/data/CrystalTile/mtdParameters.xml
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
<ConstantsSection label="mtdParameters.xml" eval="true">

<Vector name="vPars" type="numeric" nEntries="4">
4, 4, 4, 24
</Vector>
<Vector name="BTL" type="numeric" nEntries="12">
22, 24, 16, 10, 0x1, 0x3, 0x3F, 0x3F, 4, 4, 4, 1
</Vector>
<Vector name="ETL" type="numeric" nEntries="12">
22, 24, 16, 7, 0x1, 0x3, 0x3F, 0xFF, 24, 4, 2, 8
</Vector>

</ConstantsSection>
</DDDefinition>
26 changes: 7 additions & 19 deletions Geometry/MTDCommonData/interface/MTDTopologyMode.h
Expand Up @@ -6,25 +6,13 @@
#include <string>
#include <algorithm>

template< typename T >
class MTDStringToEnumParser {
std::map< std::string, T > enumMap;
public:

MTDStringToEnumParser( void );

T parseString( const std::string &value ) {
typename std::map<std::string, T>::const_iterator iValue = enumMap.find( value );
if (iValue == enumMap.end())
throw cms::Exception( "Configuration" )
<< "the value " << value << " is not defined.";

return iValue->second;
}
};


namespace MTDTopologyMode {
enum Mode { tile=1, bar=2, barzflat=3 };

enum class Mode { undefined=0, tile=1, bar=2, barzflat=3 };

Mode MTDStringToEnumParser( const std::string & ) ;

}

#endif // Geometry_MTDCommonData_MTDTopologyMode_H
20 changes: 20 additions & 0 deletions Geometry/MTDCommonData/src/MTDTopologyMode.cc
@@ -0,0 +1,20 @@
#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h"

#include <string>

namespace MTDTopologyMode {

Mode MTDStringToEnumParser( const std::string &value ) {

std::string prefix("MTDTopologyMode::");
Mode output = Mode::undefined;
if ( value == prefix+"tile" ) { output = Mode::tile; }
else if ( value == prefix+"bar" ) { output = Mode::bar; }
else if ( value == prefix+"barzflat" ) { output = Mode::barzflat; }
else { throw cms::Exception( "MTDTopologyModeError" )
<< "the value " << value << " is not defined."; }
return output;

}

}
8 changes: 0 additions & 8 deletions Geometry/MTDCommonData/src/MtdTopologyMode.cc

This file was deleted.

3 changes: 0 additions & 3 deletions Geometry/MTDGeometryBuilder/interface/MTDParametersFromDD.h
Expand Up @@ -11,15 +11,12 @@ class PMTDParameters;
class MTDParametersFromDD {
public:
MTDParametersFromDD() {}
MTDParametersFromDD(const edm::ParameterSet& );
virtual ~MTDParametersFromDD() {}

bool build( const DDCompactView*,
PMTDParameters& );
private:
void putOne( int, std::vector<int> &, PMTDParameters& );
std::vector<PMTDParameters::Item> items_;
std::vector<int> pars_;
};

#endif
9 changes: 2 additions & 7 deletions Geometry/MTDGeometryBuilder/plugins/MTDParametersESModule.cc
Expand Up @@ -10,8 +10,7 @@
#include "Geometry/MTDGeometryBuilder/interface/MTDParametersFromDD.h"
#include "CondFormats/GeometryObjects/interface/PMTDParameters.h"

MTDParametersESModule::MTDParametersESModule( const edm::ParameterSet& pset) :
builder(pset)
MTDParametersESModule::MTDParametersESModule( const edm::ParameterSet& pset)
{
edm::LogInfo("TRACKER") << "MTDParametersESModule::MTDParametersESModule";

Expand All @@ -26,11 +25,7 @@ void
MTDParametersESModule::fillDescriptions( edm::ConfigurationDescriptions & descriptions )
{
edm::ParameterSetDescription desc;
edm::ParameterSetDescription vpdesc;
vpdesc.add("subdetPars",std::vector<int>());
desc.addVPSet("vitems",vpdesc,edm::VParameterSet());
desc.add("vpars",std::vector<int>());
descriptions.add( "mtdParametersBase", desc );
descriptions.add( "mtdParameters", desc );
}

MTDParametersESModule::ReturnType
Expand Down
20 changes: 0 additions & 20 deletions Geometry/MTDGeometryBuilder/python/mtdParameters_cfi.py

This file was deleted.

55 changes: 17 additions & 38 deletions Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc
Expand Up @@ -6,6 +6,8 @@
#include "DetectorDescription/Core/interface/DDVectorGetter.h"
#include "DetectorDescription/Core/interface/DDutils.h"

using namespace MTDTopologyMode;

namespace {
int getMTDTopologyMode(const char* s, const DDsvalues_type & sv) {
DDValue val( s );
Expand All @@ -16,55 +18,32 @@ namespace {
}

int result(-1);
MTDStringToEnumParser<MTDTopologyMode::Mode> eparser;
MTDTopologyMode::Mode mode = (MTDTopologyMode::Mode) eparser.parseString(fvec[0]);
result = (int)(mode);
MTDTopologyMode::Mode eparser = MTDTopologyMode::MTDStringToEnumParser(fvec[0]);
result = (int)(eparser);
Copy link
Contributor

@cvuosalo cvuosalo Dec 5, 2018

Choose a reason for hiding this comment

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

If cast cannot be avoided, it would be better to use a named cast:
result = static_cast<int>(eparser);

These links have more info:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es49-if-you-must-use-a-cast-use-a-named-cast
https://www.geeksforgeeks.org/static_cast-in-c-type-casting-operators/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cvuosalo thanks for the suggestion, I implement it assuming that the resi is ok for you and @ianna

return result;
} else {
throw cms::Exception( "MTDParametersFromDD" ) << "Failed to get "<< s << " tag.";
}
}
}

MTDParametersFromDD::MTDParametersFromDD(const edm::ParameterSet& pset) {
const edm::VParameterSet& items =
pset.getParameterSetVector("vitems");
pars_ = pset.getParameter<std::vector<int32_t> >("vpars");

items_.resize(items.size());
for( unsigned i = 0; i < items.size(); ++i) {
auto& item = items_[i];
item.id_ = i+1;
item.vpars_ = items[i].getParameter<std::vector<int32_t> >("subdetPars");
}
}

bool
MTDParametersFromDD::build( const DDCompactView* cvp,
PMTDParameters& ptp)
{
if( items_.empty() ) {
for( int subdet = 1; subdet <= 6; ++subdet )
{
std::stringstream sstm;
sstm << "Subdetector" << subdet;
std::string name = sstm.str();

if( DDVectorGetter::check( name ))
{
std::vector<int> subdetPars = dbl_to_int( DDVectorGetter::get( name ));
putOne( subdet, subdetPars, ptp );
}
}
} else {
ptp.vitems_ = items_;
}

if( pars_.empty() ) {
ptp.vpars_ = dbl_to_int( DDVectorGetter::get( "vPars" ));
} else {
ptp.vpars_ = pars_;
}
std::array<std::string,2> mtdSubdet { { "BTL", "ETL" } };
int subdet(0);
for( const auto& name : mtdSubdet )
{
if( DDVectorGetter::check( name ))
{
subdet += 1;
std::vector<int> subdetPars = dbl_to_int( DDVectorGetter::get( name ));
putOne( subdet, subdetPars, ptp );
}
}

ptp.vpars_ = dbl_to_int( DDVectorGetter::get( "vPars" ));

std::string attribute = "OnlyForMTDRecNumbering";
DDSpecificsHasNamedValueFilter filter1{attribute};
Expand Down
26 changes: 26 additions & 0 deletions Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc
Expand Up @@ -7,6 +7,8 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "Geometry/Records/interface/PMTDParametersRcd.h"

//#define EDM_ML_DEBUG

MTDTopologyEP::MTDTopologyEP( const edm::ParameterSet& conf )
{
edm::LogInfo("MTD") << "MTDTopologyEP::MTDTopologyEP";
Expand Down Expand Up @@ -58,6 +60,30 @@ MTDTopologyEP::fillParameters( const PMTDParameters& ptp )
etlVals_.layerMask_ = ptp.vitems_[1].vpars_[5];
etlVals_.ringMask_ = ptp.vitems_[1].vpars_[6];
etlVals_.moduleMask_ = ptp.vitems_[1].vpars_[7];

#ifdef EDM_ML_DEBUG

edm::LogInfo("MTDTopologyEP") << "BTL values = "
<< btlVals_.sideStartBit_ << " "
<< btlVals_.layerStartBit_ << " "
<< btlVals_.trayStartBit_ << " "
<< btlVals_.moduleStartBit_ << " "
<< std::hex << btlVals_.sideMask_ << " "
<< std::hex << btlVals_.layerMask_ << " "
<< std::hex << btlVals_.trayMask_ << " "
<< std::hex << btlVals_.moduleMask_ << " " ;
edm::LogInfo("MTDTopologyEP") << "ETL values = "
<< etlVals_.sideStartBit_ << " "
<< etlVals_.layerStartBit_ << " "
<< etlVals_.ringStartBit_ << " "
<< etlVals_.moduleStartBit_ << " "
<< std::hex << etlVals_.sideMask_ << " "
<< std::hex << etlVals_.layerMask_ << " "
<< std::hex << etlVals_.ringMask_ << " "
<< std::hex << etlVals_.moduleMask_ << " " ;

#endif

}

DEFINE_FWK_EVENTSETUP_MODULE( MTDTopologyEP);
Expand Down