ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
JiveXML::MuonGeometryWriter Class Reference

Writes the GeoModel muon geometry to an XML file for use with Atlantis. More...

#include <MuonGeometryWriter.h>

Inheritance diagram for JiveXML::MuonGeometryWriter:
Collaboration diagram for JiveXML::MuonGeometryWriter:

Public Member Functions

 MuonGeometryWriter (const std::string &t, const std::string &n, const IInterface *p)
 Constructor. More...
 
virtual StatusCode writeGeometry ()
 Writes the geometry of the ATLAS muon spectrometer to an XML file for use with Atlantis. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

void writeHeader (std::ofstream &out) const
 Writes the header of the XML file to a stream. More...
 
void writeStations (std::ofstream &out) const
 Retrieves all stations from GeoModel and writes the corresponding XML elements to a stream. More...
 
void processNSW (std::ofstream &out)
 process the geometry of New Small Wheel More...
 
void writeFooter (std::ofstream &out) const
 Writes the footer of the XML file to a stream. More...
 
void writeATrd (std::ofstream &out, const std::string &stationTech, const std::string &stationName, double zi, double zo, double ri, double ro, double wi, double wo, int eta, const std::string &phiString, double dphi, double shift, double alpha) const
 Writes a trapezoid station in XML to a stream. More...
 
HepGeom::Point3D< double > getPosition (const MuonGM::MuonStation *station, int maxPhi) const
 Returns the global position of the station, rotated to sector 1. More...
 
double getDeltaPhi (const HepGeom::Point3D< double > &pos, int maxPhi) const
 Returns the rotation of the station with respect to the center of the sector. More...
 
double getShift (const HepGeom::Point3D< double > &pos, double dphi) const
 Returns the shift of the station with respect to the center of the sector. More...
 
double getAlpha (const HepGeom::Transform3D &trans) const
 Returns the forward tilt angle of a station (for CSCs). More...
 
HepGeom::Point3D< double > getPositionNSW (Amg::Vector3D pos, int maxPhi) const
 Returns the global position of the NSW station, rotated to sector 1. More...
 
int getPhiIndex (double phi, int maxPhi) const
 Returns phi index of the sector. More...
 
void readNSWMMPars (const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, double &zi, double &zo, double &ri, double &ro, double &wi, double &wo, double &dphi, double &shift, int &phiIndex) const
 Reads the geometry parameters of a NSW Micromegas chamber. More...
 
void readNSWSTGCPars (const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, const GeoSimplePolygonBrep *&theBrep, int &nvtx, double &dz, double &dphi, double &shift, int &phiIndex) const
 Reads the geometry parameters of a NSW sTGC chamber. More...
 
void readBrepAsATrd (const GeoSimplePolygonBrep *theBrep, double rho, const int *vtx, double &ri, double &ro, double &wi, double &wo) const
 Takes four vetecies of a GeoSimplePolygonBrep to form a trapezoid shape and reads the parameters of the trapezoid shape. More...
 
bool equalAngle (double a, double b) const
 Compares two angles. More...
 
bool equalLength (double a, double b) const
 Compares two coordinates or lenghts. More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

const MuonGM::MuonDetectorManagerm_muon_manager
 Pointer to the muon detector manager (GeoModel) More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Static Private Attributes

static const double m_smallAngle = 0.05
 Maximum deviation from the reference value before the station is considered different. More...
 
static const double m_smallDistance = 100.
 

Detailed Description

Writes the GeoModel muon geometry to an XML file for use with Atlantis.

Definition at line 28 of file MuonGeometryWriter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonGeometryWriter()

JiveXML::MuonGeometryWriter::MuonGeometryWriter ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)
inline

Constructor.

Parameters
detStorepointer to the detector store service
loglog message stream

Definition at line 37 of file MuonGeometryWriter.h.

37  :
38  AthAlgTool(t,n,p){declareInterface<IGeometryWriter>(this);};

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ equalAngle()

bool JiveXML::MuonGeometryWriter::equalAngle ( double  a,
double  b 
) const
private

Compares two angles.

Returns
true if the difference is within a precision defined by m_smallAngle

Definition at line 750 of file MuonGeometryWriter.cxx.

750  {
751  return std::abs(a - b) < m_smallAngle;
752  }

◆ equalLength()

bool JiveXML::MuonGeometryWriter::equalLength ( double  a,
double  b 
) const
private

Compares two coordinates or lenghts.

Returns
true if the difference is within a precision defined by m_smallDistance

Definition at line 754 of file MuonGeometryWriter.cxx.

754  {
755  return std::abs(a - b) < m_smallDistance;
756  }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getAlpha()

double JiveXML::MuonGeometryWriter::getAlpha ( const HepGeom::Transform3D &  trans) const
private

Returns the forward tilt angle of a station (for CSCs).

Parameters
translocal to global coordinates transformation matrix
Returns
forward tilt angle (radians)

Definition at line 327 of file MuonGeometryWriter.cxx.

327  {
328 
329  // Extract the rotation from the transformation.
330  CLHEP::HepRotation rot = trans.getRotation();
331 
332  // The theta component is what we're interested in.
333  return M_PI/2. - rot.getTheta();
334  }

◆ getDeltaPhi()

double JiveXML::MuonGeometryWriter::getDeltaPhi ( const HepGeom::Point3D< double > &  pos,
int  maxPhi 
) const
private

Returns the rotation of the station with respect to the center of the sector.

Parameters
posposition of the station rotated to sector 1.
maxPhimaximum phi index for this station type
Returns
rotation of the station

Definition at line 312 of file MuonGeometryWriter.cxx.

312  {
313 
314  if (maxPhi > 8) {
315  // For TGCs there is no shift, so we can just return the angle.
316  return pos.phi();
317  } else if (std::abs(pos.phi() - M_PI/8.) < M_PI/16.) {
318  // For the others, rotate to the next sector if it's reasonably close to pi/8.
319  // Any further deviation will be put in as a shift.
320  return M_PI/8.;
321  } else {
322  // No rotation at all.
323  return 0.;
324  }
325  }

◆ getPhiIndex()

int JiveXML::MuonGeometryWriter::getPhiIndex ( double  phi,
int  maxPhi 
) const
private

Returns phi index of the sector.

Parameters
phiphi of the sector
maxPhimaximum phi index for this station type
Returns
phi index of the sector

Definition at line 675 of file MuonGeometryWriter.cxx.

675  {
676  if (phi<0) phi += 2.*M_PI;
677  int phiIndex = std::round(phi * maxPhi / (2.*M_PI) - 0.1) + 1;
678  return phiIndex;
679  }

◆ getPosition()

HepGeom::Point3D< double > JiveXML::MuonGeometryWriter::getPosition ( const MuonGM::MuonStation station,
int  maxPhi 
) const
private

Returns the global position of the station, rotated to sector 1.

Parameters
stationunder consideration
maxPhimaximum phi index for this station type
Returns
position of the station

Definition at line 300 of file MuonGeometryWriter.cxx.

300  {
301 
302  // Take the position of the station.
303  HepGeom::Point3D<double> pos = Amg::EigenTransformToCLHEP(station->getTransform()) * HepGeom::Point3D<double>(0., 0., 0.);
304 
305  double phi = 2.*M_PI * ((double) station->getPhiIndex()-1.) / maxPhi;
306 
307  // Rotate it to sector 1.
308  //return HepGeom::RotateZ3D((1-phi) * M_PI/4.) * pos;
309  return HepGeom::RotateZ3D(-phi) * pos;
310  }

◆ getPositionNSW()

HepGeom::Point3D< double > JiveXML::MuonGeometryWriter::getPositionNSW ( Amg::Vector3D  pos,
int  maxPhi 
) const
private

Returns the global position of the NSW station, rotated to sector 1.

Parameters
positionof the station under consideration
maxPhimaximum phi index for this station type
Returns
position of the station after rotation

Definition at line 681 of file MuonGeometryWriter.cxx.

681  {
682  // get phi index of the sector
683  int phiIndex = getPhiIndex(pos.phi(), maxPhi);
684  // calculate phi of the sector center
685  double sectorPhi = 2.*M_PI * ((double) phiIndex-1.) / maxPhi;
686  // rotate to first sector
687  HepGeom::Point3D<double> pos_rot = HepGeom::RotateZ3D(-sectorPhi) * HepGeom::Point3D<double>(pos.x(), pos.y(), pos.z());
688 
689  return pos_rot;
690  }

◆ getShift()

double JiveXML::MuonGeometryWriter::getShift ( const HepGeom::Point3D< double > &  pos,
double  dphi 
) const
private

Returns the shift of the station with respect to the center of the sector.

Parameters
posposition of the station rotated to sector 1
dphirotation of the station with respect to the center of the sector
Returns
shift of the station

Definition at line 336 of file MuonGeometryWriter.cxx.

336  {
337 
338  HepGeom::Point3D<double> rotpos;
339 
340  // First we remove the shift caused by the rotation over dphi.
341  if (std::abs(dphi) < m_smallAngle) {
342  rotpos = pos;
343  } else {
344  rotpos = HepGeom::RotateZ3D(-dphi) * pos;
345  }
346 
347  // Then we return what is left as the shift.
348  if (std::abs(rotpos.y()) < m_smallDistance) {
349  return 0.;
350  } else {
351  return rotpos.y();
352  }
353  }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & JiveXML::IGeometryWriter::interfaceID ( )
inlinestaticinherited

Definition at line 27 of file IGeometryWriter.h.

27 { return IID_IGeometryWriter; }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ processNSW()

void JiveXML::MuonGeometryWriter::processNSW ( std::ofstream &  out)
private

process the geometry of New Small Wheel

Definition at line 391 of file MuonGeometryWriter.cxx.

391  {
392 
393  int maxPhi = 8;
394 
395  // Check if NSW exists in the GeoModel tree, and process it if exists
396  const GeoModelExperiment * theExpt = nullptr;
397  if (detStore()->retrieve(theExpt, "ATLAS").isFailure()) {
398  ATH_MSG_ERROR( "Could not retrieve the ATLAS GeoModelExperiment from detector store" );
399  return;
400  }
401 
402  PVConstLink world(theExpt->getPhysVol());
403  GeoVolumeCursor av(world);
404  while (!av.atEnd()) {
405  if ( av.getName()=="Muon") {
406  GeoVolumeCursor pv(av.getVolume());
407  while (!pv.atEnd()) { // Loop over Muon stations
408  if (pv.getVolume()->getLogVol()->getName()=="NewSmallWheel") {
409  ATH_MSG_INFO( "Found New Small Wheel geometry." );
410  GeoVolumeCursor pvnsw(pv.getVolume());
411 
412  while (!pvnsw.atEnd()){
413  std::string stationName = pvnsw.getVolume()->getLogVol()->getName();
414 
415  // Process MicroMegas chambers
416  if (stationName=="NSW_MM"){
417  ATH_MSG_DEBUG( "Processing NSW micromegas chambers." );
418 
419  GeoVolumeCursor pvnswsub(pvnsw.getVolume());
420  bool newChamber = true;
421  std::string phiString = "";
422  std::string phiString_mirrorEta = "";
423  double dphi=0, shift=0, zi=0, zo=0, ri=0, ro=0, wi=0, wo=0;
424  std::string chamberName="";
425  HepGeom::Point3D<double> pos_rot;
426 
427  while (!pvnswsub.atEnd()){
428  if (((pvnswsub.getVolume()->getLogVol())->getShape())->typeID() == GeoTrd::getClassTypeID() ) { // MicroMega
429 
430  if (newChamber){
431 
432  int phiIndex;
433  readNSWMMPars(&pvnswsub, maxPhi, chamberName, pos_rot, zi, zo, ri, ro, wi, wo, dphi, shift, phiIndex);
434  phiString = DataType(phiIndex).toString();
435 
436  newChamber = false;
437  pvnswsub.next();
438  } // end of processing the first chamber
439 
440  else{
441  std::string chamberName2;
442  HepGeom::Point3D<double> pos_rot2;
443  double zi2, zo2, ri2, ro2, wi2, wo2, dphi2, shift2;
444  int phiIndex2;
445  readNSWMMPars(&pvnswsub, maxPhi, chamberName2, pos_rot2, zi2, zo2, ri2, ro2, wi2, wo2, dphi2, shift2, phiIndex2);
446 
447  if (chamberName != chamberName2
448  || !equalAngle(dphi, dphi2)
449  || !equalLength(shift, shift2)
450  || !equalLength(ri, ri2)
451  || !equalLength(ro, ro2)
452  || !equalLength(wi, wi2)
453  || !equalLength(wo, wo2)) {
454  // This is a different chamber.
455  // Reset the new chamber flag so that it can be processed as a new chamber in the next loop
456  newChamber = true;
457  }
458  else if (pos_rot.distance(pos_rot2) < m_smallDistance
459  && equalLength(zi, zi2)
460  && equalLength(zo, zo2)
461  ) {
462  // same chamber in different phi sector, add it to the existing phi index list
463  std::string stationPhi = DataType(phiIndex2).toString();
464  if (phiString.find(stationPhi) == std::string::npos) phiString += " " + stationPhi;
465  pvnswsub.next();
466  }
467  else if (pos_rot.distance(HepGeom::Point3D<double>(pos_rot2.x(), pos_rot2.y(), -pos_rot2.z())) < m_smallDistance
468  && equalLength(zi, -zi2)
469  && equalLength(zo, -zo2)
470  ) {
471  // same chamber in oppposite eta region, add it to a separate phi index list
472  std::string stationPhi = DataType(phiIndex2).toString();
473  if (phiString_mirrorEta.find(stationPhi) == std::string::npos){
474  if (not phiString_mirrorEta.empty()) phiString_mirrorEta += " ";
475  phiString_mirrorEta += stationPhi;
476  }
477  pvnswsub.next();
478  }
479  else {
480  // This is a different chamber.
481  // Reset the new chamber flag so that it can be processed as a new chamber in the next loop
482  newChamber = true;
483  }
484 
485  } // end of processing another chamber and comparing it to the first chamber
486 
487 
488  if (phiString!="" && (newChamber || pvnswsub.atEnd())){
489  // if the next chamber is a different chamber, or this is the last chamber, write the geometry to output
490  ATH_MSG_DEBUG( "Writing " << chamberName );
491 
492  std::string stationTech = "MM";
493  std::string stationName = "MM"+chamberName.substr(7,1); // MMS: small sector. MML: large sector
494  int eta = std::stoi(chamberName.substr(8,1));
495  writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo, eta, phiString, dphi, shift, 0);
496  if (phiString_mirrorEta!="") {
497  writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -eta, phiString_mirrorEta, dphi, shift, 0);
498  }
499 
500  phiString = ""; // reset for new chambers
501  phiString_mirrorEta = ""; // reset for new chambers
502  }
503  }
504  else { // not MicroMegas; Move to the next chamber
505  pvnswsub.next();
506  }
507 
508  }
509  }
510 
511  // Process sTGC chambers
512  else if (stationName=="NSW_sTGC"){
513 
514  ATH_MSG_DEBUG( "Processing NSW sTGC chambers." );
515 
516  GeoVolumeCursor pvnswsub(pvnsw.getVolume());
517  bool newChamber = true;
518  std::string phiString = "";
519  std::string phiString_mirrorEta = "";
520  int nvtx=0;
521  double dz=0, dphi=0, shift=0;
522  std::string chamberName="";
523  HepGeom::Point3D<double> pos_rot;
524  const GeoSimplePolygonBrep* theBrep = nullptr;
525 
526  while (!pvnswsub.atEnd()){
527  if (((pvnswsub.getVolume()->getLogVol())->getShape())->typeID() == GeoShapeShift::getClassTypeID() ) {// sTGC
528 
529 
530  if (newChamber){
531 
532  int phiIndex;
533  readNSWSTGCPars(&pvnswsub, maxPhi, chamberName, pos_rot, theBrep, nvtx, dz, dphi, shift, phiIndex);
534  phiString = DataType(phiIndex).toString();
535 
536  newChamber = false;
537  pvnswsub.next();
538  } // end of processing the first chamber
539 
540  else{
541 
542  std::string chamberName2;
543  HepGeom::Point3D<double> pos_rot2;
544  const GeoSimplePolygonBrep* theBrep2;
545  int nvtx2, phiIndex2;
546  double dz2, dphi2, shift2;
547  readNSWSTGCPars(&pvnswsub, maxPhi, chamberName2, pos_rot2, theBrep2, nvtx2, dz2, dphi2, shift2, phiIndex2);
548 
549  // Check if it is the same shape as the first chamber
550  bool isSameShape = true;
551  if (nvtx == nvtx2 && equalLength(dz, dz2) ) { // Same Nvtx and thickness. Check vertices coordinates.
552  for (int i=0; i<nvtx; ++i){
553  if ( !equalLength(theBrep->getXVertex(i), theBrep2->getXVertex(i))
554  || !equalLength(theBrep->getYVertex(i), theBrep2->getYVertex(i)) )
555  {
556  isSameShape = false;
557  }
558  }
559  }
560  else { // Different Nvtx or thickness
561  isSameShape = false;
562  }
563 
564  // Check if it has the same name, offset and shape as the first chamber
565  if (chamberName != chamberName2
566  || !equalAngle(dphi, dphi2)
567  || !equalLength(shift, shift2)
568  || !isSameShape)
569  {
570  // This is a different chamber.
571  // Reset the new chamber flag so that it can be processed as a new chamber in the next loop
572  newChamber = true;
573  }
574  // check chamber position
575  else if (pos_rot.distance(pos_rot2) < m_smallDistance) {
576  // same chamber in different phi sector, add it to the existing phi index list
577  std::string stationPhi = DataType(phiIndex2).toString();
578  if (phiString.find(stationPhi) == std::string::npos) phiString += " " + stationPhi;
579  pvnswsub.next();
580  }
581  else if (pos_rot.distance(HepGeom::Point3D<double>(pos_rot2.x(), pos_rot2.y(), -pos_rot2.z())) < m_smallDistance) {
582  // same chamber in oppposite eta region, add it to a separate phi index list
583  std::string stationPhi = DataType(phiIndex2).toString();
584  if (phiString_mirrorEta.find(stationPhi) == std::string::npos) {
585  if (not phiString_mirrorEta.empty()) phiString_mirrorEta += " ";
586  phiString_mirrorEta += stationPhi;
587  }
588  pvnswsub.next();
589  }
590  else {
591  // This is a different chamber.
592  // Reset the new chamber flag so that it can be processed as a new chamber in the next loop
593  newChamber = true;
594  }
595  } // end of processing another chamber and comparing it to the first chamber
596 
597 
598  if (phiString!="" && (newChamber || pvnswsub.atEnd())){
599  // if the next chamber is a different chamber, or this is the last chamber, write the geometry to output
600  ATH_MSG_DEBUG( "Writing " << chamberName );
601 
602  std::string stationTech = "STGC";
603  std::string stationName = "ST"+chamberName.substr(8,1); // STS: small sector. STL: large sector
604  int eta = std::stoi(chamberName.substr(9,1));
605  double signed_dz = dz;
606  if (pos_rot.z()<0) dz *= -1;
607  double zi = pos_rot.z() - signed_dz;
608  double zo = pos_rot.z() + signed_dz;
609  double rho = pos_rot.perp();
610  double ri, ro, wi, wo;
611 
612  if (nvtx==4){ // write as a single ATrd
613  // vtx1-----vtx0 (outer)
614  // \ /
615  // vtx2--vtx3 (inner)
616  const int vtxList[] = {0, 1, 2, 3};
617  readBrepAsATrd(theBrep, rho, vtxList, ri, ro, wi, wo);
618  writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo, eta, phiString, dphi, shift, 0);
619  if (phiString_mirrorEta!="") {
620  writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -eta, phiString_mirrorEta, dphi, shift, 0);
621  }
622  }
623 
624  else if (nvtx==6){ // print as two ATrds
625  // vtx1-----vtx0 (outer)
626  // | |
627  // vtx2 vtx5
628  // \ /
629  // vtx3--vtx4 (inner)
630 
631  // First ATrd (inner part): vertex 2, 3, 4, 5
632  const int vtxList1[] = {5, 2, 3, 4};
633  readBrepAsATrd(theBrep, rho, vtxList1, ri, ro, wi, wo);
634  writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo, eta, phiString, dphi, shift, 0);
635  if (phiString_mirrorEta!="") {
636  writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -eta, phiString_mirrorEta, dphi, shift, 0);
637  }
638 
639  // Second ATrd (outter part): vertex 0, 1, 2, 5
640  const int vtxList2[] = {0, 1, 2, 5};
641  readBrepAsATrd(theBrep, rho, vtxList2, ri, ro, wi, wo);
642  writeATrd(out, stationTech, stationName, zi, zo, ri, ro, wi, wo, eta, phiString, dphi, shift, 0);
643  if (phiString_mirrorEta!="") {
644  writeATrd(out, stationTech, stationName, -zi, -zo, ri, ro, wi, wo, -eta, phiString_mirrorEta, dphi, shift, 0);
645  }
646 
647  }
648 
649  else{
650  ATH_MSG_ERROR( "Shape not supported by GeometryJiveXML: polygon shape with "<<nvtx <<" verticies in NSW sTGC." );
651  }
652  phiString = ""; // reset for new chambers
653  phiString_mirrorEta = ""; // reset for new chambers
654  }
655 
656  }
657  else { // not sTGC; Move to the next chamber
658  pvnswsub.next();
659  }
660 
661  }
662  }
663  pvnsw.next();
664  }
665  return; // Done with NSW. Skip other subdetectors
666  }
667 
668  pv.next();
669  }
670  }
671  av.next(); // increment volume cursor.
672  }
673  }

◆ readBrepAsATrd()

void JiveXML::MuonGeometryWriter::readBrepAsATrd ( const GeoSimplePolygonBrep *  theBrep,
double  rho,
const int *  vtx,
double &  ri,
double &  ro,
double &  wi,
double &  wo 
) const
private

Takes four vetecies of a GeoSimplePolygonBrep to form a trapezoid shape and reads the parameters of the trapezoid shape.

Parameters
theBreppointer to the GeoSimplePolygonBrep
rhoradius of the center of the GeoSimplePolygonBrep for calculating the inner and outer radius (ri and ro)
vtxa list of the indecies of the four verticies of GeoSimplePolygonBrep to be used in drawing the trapezoid other parameters are used to store the retrieved parameters

Definition at line 738 of file MuonGeometryWriter.cxx.

739  {
740  // vtx1-----vtx0 (outer)
741  // \ /
742  // vtx2--vtx3 (inner)
743  ri = rho + theBrep->getYVertex(vtx[3]);
744  ro = rho + theBrep->getYVertex(vtx[0]);
745  wi = theBrep->getXVertex(vtx[3]) - theBrep->getXVertex(vtx[2]);
746  wo = theBrep->getXVertex(vtx[0]) - theBrep->getXVertex(vtx[1]);
747  return;
748  }

◆ readNSWMMPars()

void JiveXML::MuonGeometryWriter::readNSWMMPars ( const GeoVolumeCursor *  pv,
int  maxPhi,
std::string &  chamberName,
HepGeom::Point3D< double > &  pos_rot,
double &  zi,
double &  zo,
double &  ri,
double &  ro,
double &  wi,
double &  wo,
double &  dphi,
double &  shift,
int &  phiIndex 
) const
private

Reads the geometry parameters of a NSW Micromegas chamber.

Parameters
pvpointer to the detector volume considered
maxPhimaximum number of phi sectors (=8 for NSW) other parameters are used to store the retrieved parameters

Definition at line 692 of file MuonGeometryWriter.cxx.

693  {
694 
695  chamberName = pv->getVolume()->getLogVol()->getName();
696  const GeoTrd* theTrd = dynamic_cast<const GeoTrd*> ((pv->getVolume()->getLogVol())->getShape());
697  Amg::Vector3D pos = pv->getTransform().translation();
698 
699  pos_rot = getPositionNSW(pos, maxPhi);
700  dphi = getDeltaPhi(pos_rot, maxPhi);
701  shift = getShift(pos_rot, dphi);
702  double signed_dz = theTrd->getXHalfLength1();
703  if (pos_rot.z()<0) signed_dz *= -1;
704 
705  zi = pos_rot.z() - signed_dz;
706  zo = pos_rot.z() + signed_dz;
707  ri = pos_rot.perp() - theTrd->getZHalfLength();
708  ro = pos_rot.perp() + theTrd->getZHalfLength();
709  wi = 2.0 * theTrd->getYHalfLength1();
710  wo = 2.0 * theTrd->getYHalfLength2();
711 
712  phiIndex = getPhiIndex(pos.phi(), maxPhi);
713 
714  return;
715  }

◆ readNSWSTGCPars()

void JiveXML::MuonGeometryWriter::readNSWSTGCPars ( const GeoVolumeCursor *  pv,
int  maxPhi,
std::string &  chamberName,
HepGeom::Point3D< double > &  pos_rot,
const GeoSimplePolygonBrep *&  theBrep,
int &  nvtx,
double &  dz,
double &  dphi,
double &  shift,
int &  phiIndex 
) const
private

Reads the geometry parameters of a NSW sTGC chamber.

Parameters
pvpointer to the detector volume considered
maxPhimaximum number of phi sectors (=8 for NSW) other parameters are used to store the retrieved parameters

Definition at line 717 of file MuonGeometryWriter.cxx.

719  {
720 
721  chamberName = pv->getVolume()->getLogVol()->getName();
722 
723  const GeoShapeShift* theShift = dynamic_cast<const GeoShapeShift*> ((pv->getVolume()->getLogVol())->getShape());
724  theBrep = dynamic_cast<const GeoSimplePolygonBrep*> (theShift->getOp());
725  nvtx = theBrep->getNVertices();
726  dz = theBrep->getDZ();
727 
728  Amg::Vector3D pos = pv->getTransform().translation();
729  pos_rot = getPositionNSW(pos, maxPhi);
730  dphi = getDeltaPhi(pos_rot, maxPhi);
731  shift = getShift(pos_rot, dphi);
732 
733  phiIndex = getPhiIndex(pos.phi(), maxPhi);
734 
735  return;
736  }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

◆ writeATrd()

void JiveXML::MuonGeometryWriter::writeATrd ( std::ofstream &  out,
const std::string &  stationTech,
const std::string &  stationName,
double  zi,
double  zo,
double  ri,
double  ro,
double  wi,
double  wo,
int  eta,
const std::string &  phiString,
double  dphi,
double  shift,
double  alpha 
) const
private

Writes a trapezoid station in XML to a stream.

Parameters
outstream where the XML fragment is written to

Definition at line 361 of file MuonGeometryWriter.cxx.

365  {
366 
367  out << "<ATrd n=\"" << stationTech << "_" << stationName << std::abs(eta) << "\""
368  << " zi=\"" << zi/10. << "\"" << " zo=\"" << zo/10. << "\""
369  << " ri=\"" << ri/10. << "\"" << " ro=\"" << ro/10. << "\""
370  << " wi=\"" << wi/10. << "\"" << " wo=\"" << wo/10. << "\""
371  << " eta=\"" << eta << "\""
372  << " phi=\"" << phiString << "\"";
373 
374  // A rotation with respect to the large sector.
375  if (std::abs(dphi) > m_smallAngle)
376  out << " dphi=\"" << 180/M_PI * dphi << "\"";
377 
378  // A shift perpendicular to r in the xy-plane.
379  if (std::abs(shift) > m_smallDistance)
380  out << " sh=\"" << shift/10. << "\"";
381 
382  // A tilt in the rz-plane, for the CSCs.
383  if (std::abs(alpha) > m_smallAngle)
384  out << " a=\"" << 180/M_PI * alpha << "\"";
385 
386  out << " />" << std::endl;
387 
388 
389  }

◆ writeFooter()

void JiveXML::MuonGeometryWriter::writeFooter ( std::ofstream &  out) const
private

Writes the footer of the XML file to a stream.

Parameters
outstream where the XML fragment is written to

Definition at line 355 of file MuonGeometryWriter.cxx.

355  {
356 
357  out << "</AMuonGeometry>" << std::endl;
358 
359  }

◆ writeGeometry()

StatusCode JiveXML::MuonGeometryWriter::writeGeometry ( )
virtual

Writes the geometry of the ATLAS muon spectrometer to an XML file for use with Atlantis.

Implements JiveXML::IGeometryWriter.

Definition at line 30 of file MuonGeometryWriter.cxx.

30  {
31 
32  ATH_MSG_DEBUG( "writeGeometry()" );
33 
34  std::ofstream outputFile("AMuonGeometry.xml");
36 
37  if ( detStore()->retrieve(m_muon_manager).isFailure() ) {
38  ATH_MSG_ERROR( "Could not retrieve MuonGM::MuonDetectorManager" );
39  m_muon_manager = 0;
40  return StatusCode::FAILURE;
41  } else {
43  }
44 
46 
48  outputFile.close();
49 
50  return StatusCode::SUCCESS;
51  }

◆ writeHeader()

void JiveXML::MuonGeometryWriter::writeHeader ( std::ofstream &  out) const
private

Writes the header of the XML file to a stream.

Parameters
outstream where the XML fragment is written to

Definition at line 53 of file MuonGeometryWriter.cxx.

53  {
54 
55  out << "<?xml version=\"1.0\"?>" << std::endl
56  << "<!DOCTYPE AMuonGeometry [" << std::endl
57  << "<!ELEMENT AMuonGeometry (ABox | ATBx | ATrd)*>" << std::endl
58  << "<!ELEMENT ABox EMPTY >" << std::endl
59  << "<!ATTLIST ABox" << std::endl
60  << " n CDATA #REQUIRED" << std::endl
61  << " zi CDATA #REQUIRED" << std::endl
62  << " zo CDATA #REQUIRED" << std::endl
63  << " ri CDATA #REQUIRED" << std::endl
64  << " ro CDATA #REQUIRED" << std::endl
65  << " w CDATA #REQUIRED" << std::endl
66  << " eta CDATA #REQUIRED" << std::endl
67  << " phi CDATA #REQUIRED" << std::endl
68  << " dphi CDATA \"0\"" << std::endl
69  << " sh CDATA \"0\"" << std::endl
70  << " RPCi CDATA \"0\"" << std::endl
71  << " RPCo CDATA \"0\">" << std::endl
72  << "<!ELEMENT ATBx EMPTY >" << std::endl
73  << "<!ATTLIST ATBx" << std::endl
74  << " n CDATA #REQUIRED" << std::endl
75  << " zi CDATA #REQUIRED" << std::endl
76  << " zo CDATA #REQUIRED" << std::endl
77  << " ri CDATA #REQUIRED" << std::endl
78  << " ro CDATA #REQUIRED" << std::endl
79  << " w CDATA #REQUIRED" << std::endl
80  << " eta CDATA #REQUIRED" << std::endl
81  << " phi CDATA #REQUIRED" << std::endl
82  << " sh CDATA \"0\"" << std::endl
83  << " dphi CDATA \"0\"" << std::endl
84  << " RPCi CDATA \"0\"" << std::endl
85  << " RPCo CDATA \"0\"" << std::endl
86  << " zis CDATA #REQUIRED" << std::endl
87  << " zos CDATA #REQUIRED" << std::endl
88  << " ws CDATA #REQUIRED" << std::endl
89  << " or CDATA \"0\">" << std::endl
90  << "<!ELEMENT ATrd EMPTY >" << std::endl
91  << "<!ATTLIST ATrd" << std::endl
92  << " n CDATA #REQUIRED" << std::endl
93  << " zi CDATA #REQUIRED" << std::endl
94  << " zo CDATA #REQUIRED" << std::endl
95  << " ri CDATA #REQUIRED" << std::endl
96  << " ro CDATA #REQUIRED" << std::endl
97  << " wi CDATA #REQUIRED" << std::endl
98  << " wo CDATA #REQUIRED" << std::endl
99  << " eta CDATA #REQUIRED" << std::endl
100  << " phi CDATA #REQUIRED" << std::endl
101  << " dphi CDATA \"0\"" << std::endl
102  << " sh CDATA \"0\"" << std::endl
103  << " a CDATA \"0\">" << std::endl
104  << "]>" << std::endl
105  << "<AMuonGeometry>" << std::endl;
106  }

◆ writeStations()

void JiveXML::MuonGeometryWriter::writeStations ( std::ofstream &  out) const
private

Retrieves all stations from GeoModel and writes the corresponding XML elements to a stream.

Parameters
outstream where the XML fragment is written to

Definition at line 108 of file MuonGeometryWriter.cxx.

108  {
109 
110  // While we retrieve the MdtIdHelper, we use the functionality provided by its parent class MuonIdHelper
111  // this is not MDT specific and any of the other IdHelpers would have worked as well.
112  const MdtIdHelper *mdtIdHelper = m_muon_manager->mdtIdHelper();
113  int snMax = mdtIdHelper->stationNameIndexMax();
114 
115  ATH_MSG_DEBUG( " Station types: " << snMax );
116 
117  // Loop over all station types.
118  for (int sn=0; sn<=snMax; sn++) {
119  std::string stationName = mdtIdHelper->stationNameString(sn);
120  // some stationNames no longer exist
121  if (!stationName.compare(MuonIdHelper::BAD_NAME)) continue;
122 
123  // Determine the type of chamber from the stationName string.
124  std::string stationTech;
125  switch(stationName[0]) {
126  case 'B':
127  case 'E':
128  stationTech = "MDT";
129  break;
130  case 'C':
131  stationTech = "CSC";
132  break;
133  case 'T':
134  stationTech = "TGC";
135  break;
136  default:
137  stationTech = "???";
138  break;
139  }
140 
141  // The TGCs contain several stations in one sector. As this would create several stations with the same
142  // identifier, people apparently chose to let the phi index of the stations continue up to 3 or even 6
143  // times the "real" maximum value. We need to determine this maximum value in order to calculate the real
144  // phi index.
145  int maxPhi;
146  if (stationTech == "TGC") {
147  if (stationName[2] == 'E' && stationName[1] != '4') {
148  maxPhi = 48;
149  } else {
150  maxPhi = 24;
151  }
152  } else {
153  maxPhi = 8;
154  }
155 
156  // Loop over all eta values.
157  for (int eta=-16; eta<=16; eta++) {
158  std::vector<const MuonGM::MuonStation *> *stations = new std::vector<const MuonGM::MuonStation *>;
159 
160  // And loop over all possible phi values.
161  for (int phi=maxPhi; phi>0; phi--) {
162 
163  // Try to retrieve the station, it might not exist, but this seems to be the most
164  // reliable way to find out.
166 
167  // If station != 0, the station exists and we add it to our vector.
168  if (station) stations->push_back(station);
169  }
170 
171  // While there are stations that haven't been written to XML, stay in this loop.
172  while (stations->size() > 0) {
173 
174  // Take the parameters of a station and store them in the variables with the "1" suffix.
175  const MuonGM::MuonStation *station1 = *(stations->end()-1);
176 
177  HepGeom::Point3D<double> pos1 = getPosition(station1, maxPhi);
178  int phi1 = station1->getPhiIndex();
179  double dphi1 = getDeltaPhi(pos1, maxPhi);
180  double shift1 = getShift(pos1, dphi1);
181  double alpha1 = getAlpha(Amg::EigenTransformToCLHEP(station1->getTransform()));
182 
183  // Now determine the dimensions of a station of this station.
184  double signed_dz = station1->Zsize()/2.;
185  if (pos1.z()<0) signed_dz *= -1;
186  double zi1 = pos1.z() - signed_dz; // inner z
187  double zo1 = pos1.z() + signed_dz; // outer z
188  double ri1 = pos1.perp() - station1->Rsize()/2.; // inner r
189  double ro1 = pos1.perp() + station1->Rsize()/2.; // outer r
190  double wi1 = station1->Ssize(); // width at inner r
191  double wo1 = station1->LongSsize(); // width at outer r
192 
193  // Create the string containing the phi sectors this station is in.
194  std::string phiString = DataType(phi1).toString();
195 
196  // Remove this station from the to-be-processed list.
197  stations->erase(stations->end()-1, stations->end());
198 
199  // Now loop over the other stations and see if any of them have the same parameters. Do
200  // this in reverse order to allow the current station to be erased from the vector.
202  for (it=stations->end()-1; it>=stations->begin(); --it) {
203  HepGeom::Point3D<double> pos2 = getPosition(*it, maxPhi);
204  int phi2 = (*it)->getPhiIndex();
205  double dphi2 = getDeltaPhi(pos2, maxPhi);
206  double shift2 = getShift(pos2, dphi2);
207  double alpha2 = getAlpha(Amg::EigenTransformToCLHEP((*it)->getTransform()));
208 
209  double signed_dz2 = (*it)->Zsize()/2.;
210  if (pos2.z()<0) signed_dz2 *= -1;
211  double zi2 = pos2.z() - signed_dz2; // inner z
212  double zo2 = pos2.z() + signed_dz2; // outer z
213  double ri2 = pos2.perp() - (*it)->Rsize()/2.; // inner r
214  double ro2 = pos2.perp() + (*it)->Rsize()/2.; // outer r
215  double wi2 = (*it)->Ssize(); // width at inner r
216  double wo2 = (*it)->LongSsize(); // width at outer r
217 
218  // If the parameters are indeed the same (within reasonable limits), then we
219  // can simply add this chamber to the sectors attribute of the first one.
220  if (pos1.distance(pos2) < m_smallDistance
221  && equalAngle(dphi1, dphi2)
222  && equalLength(shift1, shift2)
223  && equalAngle(alpha1, alpha2)
224  && equalLength(zi1, zi2)
225  && equalLength(zo1, zo2)
226  && equalLength(ri1, ri2)
227  && equalLength(ro1, ro2)
228  && equalLength(wi1, wi2)
229  && equalLength(wo1, wo2)) {
230 
231  // Add the station to the phi sector string and remove it from the
232  // to-be-processed list.
233  phiString += " " + DataType(phi2).toString();
234 
235  stations->erase(it, it+1);
236  }
237  }
238 
239  // From here onwards we need to treat barrel chambers and endcap chambers differently.
240  if (stationName[0] == 'B') {
241 
242  // Barrel chambers can have inner and/or outer RPCs.
243  // Let's take a default of 0. (no RPCs).
244  double rpci = 0.;
245  double rpco = 0.;
246 
247  // Determine the thickness of the RPC layer on this station.
248  if (stationName[1] == 'M') {
249  // Middle (BM*) stations have RPCs on both sides.
250  rpci = rpco = 15.;
251  } else if (stationName[1] == 'O') {
252  // Outer (BO*) stations have RPCs on one side.
253  if (stationName[2] == 'S') {
254  // On the side facing the IP for small sectors (BOS).
255  rpci = 15.;
256  } else {
257  // On the outside for large sectors (BOL, BOF, BOG, BOH).
258  rpco = 15.;
259  }
260  } else if (stationName[1] == 'I' && eta==7 && wi1>1800) {
261  // Run3 BIS7/8 stations have RPCs on the inner side and they are wider than the Run2 BIS7 and BIS8 stations.
262  rpci = 4.;
263  }
264 
265  // Barrel chambers are written as <ABox> elements.
266  out << "<ABox n=\"" << stationTech << "_" << stationName << "\""
267  << " zi=\"" << zi1/10. << "\"" << " zo=\"" << zo1/10. << "\""
268  << " ri=\"" << ri1/10. << "\"" << " ro=\"" << ro1/10. << "\""
269  << " w=\"" << wi1/10. << "\""
270  << " eta=\"" << eta << "\""
271  << " phi=\"" << phiString << "\"";
272 
273  // A rotation with respect to the large sector.
274  if (std::abs(dphi1) > m_smallAngle)
275  out << " dphi=\"" << 180/M_PI * dphi1 << "\"";
276 
277  // A shift perpendicular to r in the xy-plane.
278  if (std::abs(shift1) > m_smallDistance)
279  out << " sh=\"" << shift1/10. << "\"";
280 
281  // RPCs.
282  if (rpci > 0.)
283  out << " RPCi=\"" << rpci << "\"";
284  if (rpco > 0.)
285  out << " RPCo=\"" << rpco << "\"";
286  out << " />" << std::endl;
287 
288  } else {
289 
290  // Endcap chambers are written as <ATrd> elements, parameters are similar to <ABox>.
291  writeATrd(out, stationTech, stationName, zi1, zo1, ri1, ro1, wi1, wo1, eta, phiString, dphi1, shift1, alpha1);
292  }
293  }
294 
295  delete stations;
296  }
297  }
298  }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_muon_manager

const MuonGM::MuonDetectorManager* JiveXML::MuonGeometryWriter::m_muon_manager
private

Pointer to the muon detector manager (GeoModel)

Definition at line 170 of file MuonGeometryWriter.h.

◆ m_smallAngle

const double JiveXML::MuonGeometryWriter::m_smallAngle = 0.05
staticprivate

Maximum deviation from the reference value before the station is considered different.

Definition at line 173 of file MuonGeometryWriter.h.

◆ m_smallDistance

const double JiveXML::MuonGeometryWriter::m_smallDistance = 100.
staticprivate

Definition at line 173 of file MuonGeometryWriter.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
JiveXML::MuonGeometryWriter::processNSW
void processNSW(std::ofstream &out)
process the geometry of New Small Wheel
Definition: MuonGeometryWriter.cxx:391
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:129
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
JiveXML::MuonGeometryWriter::m_smallAngle
static const double m_smallAngle
Maximum deviation from the reference value before the station is considered different.
Definition: MuonGeometryWriter.h:173
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
JiveXML::MuonGeometryWriter::readBrepAsATrd
void readBrepAsATrd(const GeoSimplePolygonBrep *theBrep, double rho, const int *vtx, double &ri, double &ro, double &wi, double &wo) const
Takes four vetecies of a GeoSimplePolygonBrep to form a trapezoid shape and reads the parameters of t...
Definition: MuonGeometryWriter.cxx:738
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::MuonGeometryWriter::getPhiIndex
int getPhiIndex(double phi, int maxPhi) const
Returns phi index of the sector.
Definition: MuonGeometryWriter.cxx:675
MuonGM::MuonStation::getTransform
Amg::Transform3D getTransform() const
Definition: MuonStation.h:169
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
skel.it
it
Definition: skel.GENtoEVGEN.py:423
JiveXML::MuonGeometryWriter::readNSWSTGCPars
void readNSWSTGCPars(const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, const GeoSimplePolygonBrep *&theBrep, int &nvtx, double &dz, double &dphi, double &shift, int &phiIndex) const
Reads the geometry parameters of a NSW sTGC chamber.
Definition: MuonGeometryWriter.cxx:717
GeoModelExperiment
Definition: GeoModelExperiment.h:32
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
JiveXML::MuonGeometryWriter::getPosition
HepGeom::Point3D< double > getPosition(const MuonGM::MuonStation *station, int maxPhi) const
Returns the global position of the station, rotated to sector 1.
Definition: MuonGeometryWriter.cxx:300
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MuonIdHelper::stationNameIndexMax
int stationNameIndexMax() const
Definition: MuonIdHelper.cxx:824
JiveXML::MuonGeometryWriter::getPositionNSW
HepGeom::Point3D< double > getPositionNSW(Amg::Vector3D pos, int maxPhi) const
Returns the global position of the NSW station, rotated to sector 1.
Definition: MuonGeometryWriter.cxx:681
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
MuonGM::MuonStation::Ssize
double Ssize() const
Definition: MuonStation.h:174
MuonGM::MuonStation::getPhiIndex
int getPhiIndex() const
a la AMDB
Definition: MuonStation.h:162
MuonGM::MuonStation::Zsize
double Zsize() const
Definition: MuonStation.h:175
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonGM::MuonStation::Rsize
double Rsize() const
Definition: MuonStation.h:173
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::MuonStation
Definition: MuonStation.h:51
MdtIdHelper
Definition: MdtIdHelper.h:61
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
MuonGM::MuonDetectorManager::mdtIdHelper
const MdtIdHelper * mdtIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:221
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
MuonIdHelper::stationNameString
const std::string & stationNameString(const int &index) const
Definition: MuonIdHelper.cxx:858
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
JiveXML::MuonGeometryWriter::m_smallDistance
static const double m_smallDistance
Definition: MuonGeometryWriter.h:173
JiveXML::MuonGeometryWriter::writeFooter
void writeFooter(std::ofstream &out) const
Writes the footer of the XML file to a stream.
Definition: MuonGeometryWriter.cxx:355
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
MuonGM::MuonDetectorManager::getMuonStation
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:137
JiveXML::MuonGeometryWriter::equalLength
bool equalLength(double a, double b) const
Compares two coordinates or lenghts.
Definition: MuonGeometryWriter.cxx:754
JiveXML::MuonGeometryWriter::readNSWMMPars
void readNSWMMPars(const GeoVolumeCursor *pv, int maxPhi, std::string &chamberName, HepGeom::Point3D< double > &pos_rot, double &zi, double &zo, double &ri, double &ro, double &wi, double &wo, double &dphi, double &shift, int &phiIndex) const
Reads the geometry parameters of a NSW Micromegas chamber.
Definition: MuonGeometryWriter.cxx:692
a
TList * a
Definition: liststreamerinfos.cxx:10
h
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120
JiveXML::MuonGeometryWriter::getShift
double getShift(const HepGeom::Point3D< double > &pos, double dphi) const
Returns the shift of the station with respect to the center of the sector.
Definition: MuonGeometryWriter.cxx:336
JiveXML::MuonGeometryWriter::writeATrd
void writeATrd(std::ofstream &out, const std::string &stationTech, const std::string &stationName, double zi, double zo, double ri, double ro, double wi, double wo, int eta, const std::string &phiString, double dphi, double shift, double alpha) const
Writes a trapezoid station in XML to a stream.
Definition: MuonGeometryWriter.cxx:361
python.changerun.pv
pv
Definition: changerun.py:81
JiveXML::MuonGeometryWriter::m_muon_manager
const MuonGM::MuonDetectorManager * m_muon_manager
Pointer to the muon detector manager (GeoModel)
Definition: MuonGeometryWriter.h:170
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
JiveXML::MuonGeometryWriter::getAlpha
double getAlpha(const HepGeom::Transform3D &trans) const
Returns the forward tilt angle of a station (for CSCs).
Definition: MuonGeometryWriter.cxx:327
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
JiveXML::MuonGeometryWriter::writeHeader
void writeHeader(std::ofstream &out) const
Writes the header of the XML file to a stream.
Definition: MuonGeometryWriter.cxx:53
JiveXML::MuonGeometryWriter::equalAngle
bool equalAngle(double a, double b) const
Compares two angles.
Definition: MuonGeometryWriter.cxx:750
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
MuonGM::MuonStation::LongSsize
double LongSsize() const
Definition: MuonStation.h:177
fitman.rho
rho
Definition: fitman.py:532
JiveXML::MuonGeometryWriter::getDeltaPhi
double getDeltaPhi(const HepGeom::Point3D< double > &pos, int maxPhi) const
Returns the rotation of the station with respect to the center of the sector.
Definition: MuonGeometryWriter.cxx:312
fitman.k
k
Definition: fitman.py:528
JiveXML::MuonGeometryWriter::writeStations
void writeStations(std::ofstream &out) const
Retrieves all stations from GeoModel and writes the corresponding XML elements to a stream.
Definition: MuonGeometryWriter.cxx:108
MuonIdHelper::BAD_NAME
static const std::string BAD_NAME
Definition: MuonIdHelper.h:224