1 #include "gearxml/CalorimeterParametersXML.h"
3 #include "gearxml/XMLHandlerMgr.h"
4 #include "gearxml/GearParametersXML.h"
6 #include "gearxml/tinyxml.h"
7 #include "gearimpl/CalorimeterParametersImpl.h"
9 #include "gear/GearMgr.h"
11 #include "gearimpl/FixedPadSizeDiskLayout.h"
19 #define _EPSILON 0.0001
32 throw Exception(
"CaloriemterParametersXML::toXML given parmeters not of correct type. "
33 "needs to be gear::CaloriemeterParameters." );
40 const std::vector<double> vecDim=param->
getExtent();
48 case CalorimeterParameters::BARREL :
55 case CalorimeterParameters::ENDCAP :
86 double curThickness = 0.0 ;
87 double curAbsorber = 0.0 ;
88 double curCell0 = 0.0 ;
89 double curCell1 = 0.0 ;
98 ( ! isEqual( curThickness, layerLayout.
getThickness(i) ) ) ||
100 ( ! isEqual( curCell0, layerLayout.
getCellSize0(i) ) ) ||
101 ( ! isEqual( curCell1, layerLayout.
getCellSize1(i) ) ) ;
103 if( layerChanged && repN > 0 ) {
163 std::stringstream str ;
164 str <<
"XMLParser::getChildElementValue missing element \"layout\" "
165 <<
" in element <" << xmlElement->
Value() <<
"/> " ;
172 std::transform( layoutType.begin() , layoutType.end() , layoutType.begin(), tolower ) ;
174 if( layoutType !=
"barrel" && layoutType !=
"endcap" ) {
176 throw ParseException(
"CalorimeterParametersXML::toXML: currently only barrel and endcap type layouts implemented ! " ) ;
183 if( dimensions == 0 ) {
185 std::stringstream str ;
186 str <<
"XMLParser::getChildElementValue missing element \"dimensions\" "
187 <<
" in element <" << xmlElement->
Value() <<
"/> " ;
192 int symmetry = atoi(
getXMLAttribute( layout ,
"symmetry" ) .c_str() ) ;
197 double firstLayerDistance = 0. ;
198 bool isBarrelCalorimeter = false ;
200 if( layoutType ==
"barrel" ) {
202 isBarrelCalorimeter = true ;
205 double rMin = atof(
getXMLAttribute( dimensions ,
"inner_r" ) .c_str() ) ;
206 double zMax = atof(
getXMLAttribute( dimensions ,
"outer_z" ) .c_str() ) ;
210 firstLayerDistance = rMin ;
212 }
else if( layoutType ==
"endcap" ) {
215 double rMin = atof(
getXMLAttribute( dimensions ,
"inner_r" ) .c_str() ) ;
216 double rMax = atof(
getXMLAttribute( dimensions ,
"outer_r" ) .c_str() ) ;
217 double zMin = atof(
getXMLAttribute( dimensions ,
"inner_z" ) .c_str() ) ;
221 firstLayerDistance = zMin ;
233 while( ( layer = xmlElement->
IterateChildren(
"layer", layer ) ) != 0 ){
236 double thickness = atof(
getXMLAttribute( layer ,
"thickness" ) .c_str() ) ;
237 double absorberThickness = atof(
getXMLAttribute( layer ,
"absorberThickness" ) .c_str() ) ;
238 double cellSize0 = atof(
getXMLAttribute( layer ,
"cellSize0" ) .c_str() ) ;
239 double cellSize1 = atof(
getXMLAttribute( layer ,
"cellSize1" ) .c_str() ) ;
241 for(
int i=0 ; i < nLayer ; ++i ) {
244 caloParams->layerLayout().
positionLayer( firstLayerDistance , thickness,
245 cellSize0, cellSize1, absorberThickness ) ;
247 caloParams->layerLayout().
addLayer( thickness,
248 cellSize0, cellSize1, absorberThickness ) ;
263 std::transform( caloName.begin() , caloName.end() ,
264 caloName.begin(), tolower ) ;
267 if( caloName.find(
"ecal") != std::string::npos ){
269 if( caloName.find(
"plug" ) != std::string::npos ){
273 else if( isBarrelCalorimeter )
278 }
else if( caloName.find(
"yoke") != std::string::npos ){
280 if( caloName.find(
"plug" ) != std::string::npos ){
284 else if( isBarrelCalorimeter )
289 }
else if( caloName.find(
"lcal" ) != std::string::npos ) {
293 }
else if( caloName.find(
"lhcal" ) != std::string::npos ) {
297 }
else if( caloName.find(
"beamcal" ) != std::string::npos ) {
301 }
else if( caloName.find(
"hcal" ) != std::string::npos ) {
304 if( caloName.find(
"ring" ) != std::string::npos ){
308 else if( isBarrelCalorimeter )
320 bool CalorimeterParametersXML::isEqual(
const double valueOne,
const double valueTwo )
const {
323 if ( valueOne == valueTwo )
return true ;
326 double maxDelta = fabs( ( valueOne + valueTwo ) / 2 * _EPSILON ) ;
329 bool differsLess = ( fabs( valueOne - valueTwo ) < maxDelta ) ;
virtual int getLayoutType() const =0
The type of the calorimeter layout: CalorimeterParameters.BARREL or CalorimeterParameters.ENDCAP.
virtual void setEcalEndcapParameters(CalorimeterParameters *ecalEndcapParameters)=0
Set the EcalEndcapParameters.
Base exception class for GEAR - all other exceptions extend this.
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Proposal for an abstract interface that defines geometry properties of a typical sampling calorimeter...
virtual double getAbsorberThickness(int layerIndex) const =0
The thickness of the absorber part of the layer layerIndex - layer indexing starts at 0 for the layer...
Abstract description of a layered layout detector - typically a a sampling calorimeter.
virtual double getCellSize0(int layerIndex) const =0
The cell size along the first axis where first is either along the beam (barrel type) or up (endcap) ...
virtual void setEcalPlugParameters(CalorimeterParameters *ecalPlugParameters)=0
Set the EcalPlugParameters.
virtual const std::vector< double > & getExtent() const =0
Extent of the calorimeter in the r-z-plane [ rmin, rmax, zmin, zmax ] in mm.
virtual void setHcalBarrelParameters(CalorimeterParameters *hcalBarrelParameters)=0
Set the HcalBarrelParameters.
virtual void setYokeBarrelParameters(CalorimeterParameters *ecalBarrelParameters)=0
Set the YokeBarrelParameters.
static void setParametersFromXML(const TiXmlElement *xmlElement, GearParametersImpl *gearParams)
Static helper function that can be used by other subclass handlers to read parameters.
Abstract interface for a set of parameters that can be used to describe the geometrical properties of...
virtual double getThickness(int layerIndex) const =0
The thickness of the layer layerIndex - layer indexing starts at 0 for the layer closest to the origi...
virtual void positionLayer(double distance, double thickness, double cellSize0, double cellSize1, double absorberThickness=0.)
Position new layer at the given distance (after the last layer) - typically this will be used for the...
virtual int getNLayers() const =0
The total number of layers.
static void getXMLForParameters(TiXmlElement *xmlElement, const GearParameters *gearParams)
Static helper function that can be used by other subclass handlers to create XML for parameters...
virtual void setBeamCalParameters(CalorimeterParameters *beamcalParameters)=0
Set the BeamCalParameters.
The parent class for everything in the Document Object Model.
virtual void setHcalEndcapParameters(CalorimeterParameters *hcalEndcapParameters)=0
Set the HcalEndcapParameters.
ParseException used for parse errors, e.g.
std::string getXMLAttribute(const TiXmlNode *node, const std::string &name)
Helper method used for parsing XML.
virtual void setHcalRingParameters(CalorimeterParameters *hcalRingParameters)=0
Set the HcalRingParameters.
The element is a container class.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
virtual void setLHcalParameters(CalorimeterParameters *lhcalParameters)=0
Set the LHcalParameters.
virtual TiXmlElement toXML(const GearParameters ¶meters) const
Creates an XML node for the given parameters.
virtual const LayerLayout & getLayerLayout() const =0
The layer layout in the calorimeter.
virtual void setYokePlugParameters(CalorimeterParameters *ecalPlugParameters)=0
Set the YokePlugParameters.
virtual void addLayer(double thickness, double cellSize0, double cellSize1, double absorberThickness=0.)
Add a new layer right after the last layer - at distance 0.
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
virtual void setYokeEndcapParameters(CalorimeterParameters *ecalEndcapParameters)=0
Set the YokeEndcapParameters.
virtual int getSymmetryOrder() const =0
The order of the rotational symmetry 8 for an octagonal barrel calorimeter 2 for an endcap calorim...
virtual GearParameters * fromXML(const TiXmlElement *xmlElement, GearMgr *gearMgr=0) const
Creates the appropriate GearParameters subclass from the given XML element (node) ...
virtual double getCellSize1(int layerIndex) const =0
The second cell size, perpendicular to the first direction (getCellSize0()) and the depth of the laye...
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
virtual void setEcalBarrelParameters(CalorimeterParameters *ecalBarrelParameters)=0
Set the EcalBarrelParameters.
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual void setLcalParameters(CalorimeterParameters *lcalParameters)=0
Set the LcalParameters.
virtual double getPhi0() const =0
The azimuthal angle of the first module if symmetryOrder > 0.