Skip to content

Commit

Permalink
Use HcalTopology mode as defined in SLHC releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Apr 14, 2015
1 parent d24fca5 commit 1d08054
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions Geometry/HcalTowerAlgo/src/HcalParametersFromDD.cc
@@ -1,12 +1,37 @@
#include "Geometry/HcalTowerAlgo/interface/HcalParametersFromDD.h"
#include "Geometry/CaloTopology/interface/HcalTopologyMode.h"
#include "CondFormats/GeometryObjects/interface/PHcalParameters.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/Core/interface/DDVectorGetter.h"
#include "DetectorDescription/Base/interface/DDutils.h"

namespace
{
double getTopologyMode( const char* s, const DDsvalues_type & sv )
{
DDValue val( s );
if( DDfetch( &sv, val ))
{
const std::vector<std::string> & fvec = val.strings();
if( fvec.size() == 0 )
{
throw cms::Exception( "HcalParametersFromDD" ) << "Failed to get " << s << " tag.";
}

StringToEnumParser<HcalTopologyMode::Mode> eparser;
HcalTopologyMode::Mode mode = (HcalTopologyMode::Mode) eparser.parseString( fvec[0] );

return double( mode );
}
else
throw cms::Exception( "HcalParametersFromDD" ) << "Failed to get "<< s << " tag.";
}
}

bool
HcalParametersFromDD::build( const DDCompactView* cvp,
PHcalParameters& php)
HcalParametersFromDD::build( const DDCompactView* cpv,
PHcalParameters& php )
{
php.phioff = DDVectorGetter::get( "phioff" );
php.etaTable = DDVectorGetter::get( "etaTable" );
Expand Down Expand Up @@ -45,8 +70,27 @@ HcalParametersFromDD::build( const DDCompactView* cvp,
}
}

int topologyMode = 0;
php.topologyMode = topologyMode;
// FIXME: HcalTopology mode can be defined as double.
// This is for consistency with SLHC releases.
//
std::string attribute = "OnlyForHcalRecNumbering";
std::string value = "any";
DDValue val( attribute, value, 0.0 );

DDSpecificsFilter filter;
filter.setCriteria( val, DDSpecificsFilter::not_equals,
DDSpecificsFilter::AND, true, // compare strings
true // use merged-specifics or simple-specifics
);
DDFilteredView fv( *cpv );
fv.addFilter( filter );
bool ok = fv.firstChild();

if( !ok ) throw cms::Exception( "HcalParametersFromDD" ) << "Not found "<< attribute.c_str() << " but needed.";

DDsvalues_type sv( fv.mergedSpecifics());

php.topologyMode = getTopologyMode( "TopologyMode", sv );

return true;
}

0 comments on commit 1d08054

Please sign in to comment.