From d99176e3ec4dc23d1c43e868f201cb273c6b282d Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Tue, 13 Jun 2023 16:29:31 +0200 Subject: [PATCH 01/12] implement module-theta (with per-layer merging) readout --- .../FCCee_ECalBarrel_thetamodulemerged.xml | 156 +++++++++++++++ .../FCCee_DectMaster_thetamodulemerged.xml | 45 +++++ .../FCCSWGridModuleThetaMerged.h | 103 ++++++++++ .../FCCSWGridModuleThetaMergedHandle.h | 127 ++++++++++++ .../include/DetSegmentation/GridTheta.h | 2 +- .../src/FCCSWGridModuleThetaMerged.cpp | 188 ++++++++++++++++++ .../src/FCCSWGridModuleThetaMergedHandle.cpp | 4 + .../src/plugins/SegmentationFactories.cpp | 3 + 8 files changed, 627 insertions(+), 1 deletion(-) create mode 100644 Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml create mode 100644 Detector/DetFCCeeIDEA-LAr/compact/FCCee_DectMaster_thetamodulemerged.xml create mode 100644 Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h create mode 100644 Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h create mode 100644 Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp create mode 100644 Detector/DetSegmentation/src/FCCSWGridModuleThetaMergedHandle.cpp diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml new file mode 100644 index 00000000..bb4f6017 --- /dev/null +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -0,0 +1,156 @@ + + + + + + Settings for the inclined EM calorimeter. + The barrel is filled with liquid argon. Passive material includes lead in the middle and steal on the outside, glued together. + Passive plates are inclined by a certain angle from the radial direction. + In between of two passive plates there is a readout. + Space between the plate and readout is of trapezoidal shape and filled with liquid argon. + Definition of sizes, visualization settings, readout and longitudinal segmentation are specified. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 + + + + + + + + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 + + + + + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCCeeIDEA-LAr/compact/FCCee_DectMaster_thetamodulemerged.xml b/Detector/DetFCCeeIDEA-LAr/compact/FCCee_DectMaster_thetamodulemerged.xml new file mode 100644 index 00000000..d6afbbda --- /dev/null +++ b/Detector/DetFCCeeIDEA-LAr/compact/FCCee_DectMaster_thetamodulemerged.xml @@ -0,0 +1,45 @@ + + + + + + Master compact file describing the latest developments of the FCCee IDEA detector concept with a LAr calorimeter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h new file mode 100644 index 00000000..0c129b5a --- /dev/null +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h @@ -0,0 +1,103 @@ +#ifndef DETSEGMENTATION_FCCSWGRIDMODULETHETAMERGED_H +#define DETSEGMENTATION_FCCSWGRIDMODULETHETAMERGED_H + +// FCCSW +#include "DetSegmentation/GridTheta.h" +#include "DD4hep/VolumeManager.h" + +/** FCCSWGridModuleThetaMerged Detector/DetSegmentation/DetSegmentation/FCCSWGridModuleThetaMerged.h FCCSWGridModuleThetaMerged.h + * + * Segmentation in theta and module. + * Based on GridTheta, merges modules and theta cells based on layer number + * + */ + +namespace dd4hep { +namespace DDSegmentation { +class FCCSWGridModuleThetaMerged : public GridTheta { +public: + /// default constructor using an arbitrary type + FCCSWGridModuleThetaMerged(const std::string& aCellEncoding); + /// Default constructor used by derived classes passing an existing decoder + FCCSWGridModuleThetaMerged(const BitFieldCoder* decoder); + + /// destructor + virtual ~FCCSWGridModuleThetaMerged() = default; + + /** Determine the local position based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Position (relative to R, phi of Geant4 volume it belongs to, scaled for R=1). + */ + virtual Vector3D position(const CellID& aCellID) const; + /** Determine the cell ID based on the position. + * @param[in] aLocalPosition (not used). + * @param[in] aGlobalPosition + * @param[in] aVolumeId ID of the Geant4 volume + * return Cell ID. + */ + virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition, + const VolumeID& aVolumeID) const; + /** Determine the azimuthal angle (relative to the G4 volume) based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Phi. + */ + double phi(const CellID& aCellID) const; + /** Determine the polar angle (relative to the G4 volume) based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Theta. + */ + double theta(const CellID& aCellID) const; + /** Determine the radius based on the cell ID. + * @param[in] aCellId ID of a cell. + * return Radius. + */ + // double radius(const CellID& aCellID) const; + /** Get the number of merged cells in theta for given layer + * @param[in] layer + * return The number of merged cells in theta + */ + inline int mergedThetaCells(const unsigned int layer) const { return m_mergedCellsTheta[layer]; } + /** Get the number of merged modules (inclined in phi) + * @param[in] layer + * return The number of merged cells in theta + */ + inline int mergedModules(const unsigned int layer) const { return m_mergedModules[layer]; } + /** Get the number of modules + * return The number of modules (as it was set by the user in the xml file..) + */ + inline int nModules() const { return m_nModules; } + /** Set the number of modules + * return The number of modules (as it was set by the user in the xml file..) + */ + inline int setNModules(const int nModules) { m_nModules = nModules; } + /** Get the field name used for the layer + * return The field name for the layer. + */ + inline const std::string& fieldNameLayer() const { return m_layerID; } + /** Get the field name used for the module number + * return The field name for the module. + */ + inline const std::string& fieldNameModule() const { return m_moduleID; } + +protected: + /// the field name used for layer + std::string m_layerID; + /// the field name used for the read-out module (can differ from module due to merging) + std::string m_moduleID; + /// vector of number of cells to be merged along theta for each layer + std::vector m_mergedCellsTheta; + /// vector of number of modules to be merged for each layer + std::vector m_mergedModules; + + /// to be seen if we need these + /// and how to retrieve them at initialization step from the geometry + /// number of modules (or, equivalently, the deltaPhi between adjacent modules) + int m_nModules; + /// innermost radius of electrodes (not needed) + /// std::vector m_rLayers; + /// inclination in phi of electrodes (not needed) + //// double m_alpha; +}; +} +} +#endif /* DETSEGMENTATION_FCCSWGRIDMODULETHETAMERGED_H */ diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h new file mode 100644 index 00000000..2a3a3f20 --- /dev/null +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h @@ -0,0 +1,127 @@ +#ifndef DD4HEP_DDCORE_GRIDMODULETHETAMERGED_H +#define DD4HEP_DDCORE_GRIDMODULETHETAMERGED_H 1 + +// FCCSW +#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" + +// DD4hep +#include "DD4hep/Segmentations.h" +#include "DD4hep/detail/SegmentationsInterna.h" + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + +/// Namespace for base segmentations + + +// Forward declarations +class Segmentation; +template +class SegmentationWrapper; + +/// We need some abbreviation to make the code more readable. +typedef Handle> FCCSWGridModuleThetaMergedHandle; + +/// Implementation class for the module-theta (with per-layer merging) segmentation. +/** + * Concrete user handle to serve specific needs of client code + * which requires access to the base functionality not served + * by the super-class Segmentation. + * + * Note: + * We only check the validity of the underlying handle. + * If for whatever reason the implementation object is not valid + * This is not checked. + * In principle this CANNOT happen unless some brain-dead has + * fiddled with the handled object directly..... + * + * Note: + * The handle base corrsponding to this object in for + * conveniance reasons instantiated in DD4hep/src/Segmentations.cpp. + * + */ +class FCCSWGridModuleThetaMerged : public FCCSWGridModuleThetaMergedHandle { +public: + /// Definition of the basic handled object + typedef FCCSWGridModuleThetaMergedHandle::Object Object; + +public: + /// Default constructor + FCCSWGridModuleThetaMerged() = default; + /// Copy constructor + FCCSWGridModuleThetaMerged(const FCCSWGridModuleThetaMerged& e) = default; + /// Copy Constructor from segmentation base object + FCCSWGridModuleThetaMerged(const Segmentation& e) : Handle(e) {} + /// Copy constructor from handle + FCCSWGridModuleThetaMerged(const Handle& e) : Handle(e) {} + /// Copy constructor from other polymorph/equivalent handle + template + FCCSWGridModuleThetaMerged(const Handle& e) : Handle(e) {} + /// Assignment operator + FCCSWGridModuleThetaMerged& operator=(const FCCSWGridModuleThetaMerged& seg) = default; + /// Equality operator + bool operator==(const FCCSWGridModuleThetaMerged& seg) const { return m_element == seg.m_element; } + + /// determine the position based on the cell ID + inline Position position(const CellID& id) const { return Position(access()->implementation->position(id)); } + + /// determine the cell ID based on the position + inline dd4hep::CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const { + return access()->implementation->cellID(local, global, volID); + } + + + /// access the grid size in theta + inline double gridSizeTheta() const { return access()->implementation->gridSizeTheta(); } + + /// access the coordinate offset in theta + inline double offsetTheta() const { return access()->implementation->offsetTheta(); } + + /// access the number of theta cells merged for given layer + inline int mergedThetaCells(const unsigned int layer) const { return access()->implementation->mergedThetaCells(layer); } + + /// access the number of modules + inline int nModules() const { return access()->implementation->nModules(); } + + /// access the number of merged modules for given layer + inline int mergedModules(const unsigned int layer) const { return access()->implementation->mergedModules(layer); } + + + /// set the coordinate offset in theta + inline void setOffsetTheta(double offset) const { access()->implementation->setOffsetTheta(offset); } + + /// set the grid size in theta + inline void setGridSizeTheta(double cellSize) const { access()->implementation->setGridSizeTheta(cellSize); } + + /// set the number of modules + inline void setNModules(int nModules) const { access()->implementation->setNModules(nModules); } + + + /// access the field name used for theta + inline const std::string& fieldNameTheta() const { return access()->implementation->fieldNameTheta(); } + + /// access the field name used for module + inline const std::string& fieldNameModule() const { return access()->implementation->fieldNameModule(); } + + /// access the field name used for layer + inline const std::string& fieldNameLayer() const { return access()->implementation->fieldNameLayer(); } + + + /** \brief Returns a std::vector of the cellDimensions of the given cell ID + in natural order of dimensions (dPhi, dTheta) + + Returns a std::vector of the cellDimensions of the given cell ID + \param cellID is ignored as all cells have the same dimension + \return std::vector size 2: + -# size in phi + -# size in theta + */ + inline std::vector cellDimensions(const CellID& /*id*/) const { + //return {access()->implementation->gridSizePhi(), access()->implementation->gridSizeTheta()}; + // not implemented + return {0., 0.}; + } +}; + +} /* End namespace dd4hep */ +#endif // DD4HEP_DDCORE_GRIDMODULETHETAMERGED_H diff --git a/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h b/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h index cc8c6cdd..e8f086ea 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h +++ b/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h @@ -69,7 +69,7 @@ class GridTheta : public Segmentation { inline void setFieldNameTheta(const std::string& fieldName) { m_thetaID = fieldName; } /// calculates the Cartesian position from cylindrical coordinates (r, phi, theta) inline Vector3D positionFromRThetaPhi(double ar, double atheta, double aphi) const { - return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar / std::tan(atheta)); + return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar * std::cos(atheta)/std::sin(atheta)); } /// calculates the theta angle from Cartesian coordinates inline double thetaFromXYZ(const Vector3D& aposition) const { diff --git a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp new file mode 100644 index 00000000..8c5271cf --- /dev/null +++ b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp @@ -0,0 +1,188 @@ +#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" + +#include + +namespace dd4hep { +namespace DDSegmentation { + +/// default constructor using an encoding string +FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const std::string& cellEncoding) : GridTheta(cellEncoding) { + // define type and description + _type = "FCCSWGridModuleThetaMerged"; + _description = "Module-theta segmentation with per-layer merging along theta and/or module"; + + // register all necessary parameters (additional to those registered in GridTheta) + registerIdentifier("identifier_layer", "Cell ID identifier for layer", m_layerID, "layer"); + registerIdentifier("identifier_module", "Cell ID identifier for readout module", m_moduleID, "module"); + registerParameter("mergedCells_Theta", "Numbers of merged cells in theta per layer", m_mergedCellsTheta, std::vector()); + registerParameter("mergedModules", "Numbers of merged modules per layer", m_mergedModules, std::vector()); + registerParameter("nModules", "Number of modules", m_nModules, 1545); + //m_nModules = 1545; + //m_alpha = 50./180.*M_PI; + //m_rLayers = {217.28, 218.78, 222.28, 225.78, 229.28, 232.78, 236.28, 239.78, 243.28, 246.78, 250.28, 253.78, 257.33}; +} + +FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const BitFieldCoder* decoder) : GridTheta(decoder) { + // define type and description + _type = "FCCSWGridModuleThetaMerged"; + _description = "Module-theta segmentation with per-layer merging along theta and/or module"; + + // register all necessary parameters (additional to those registered in GridTheta) + registerIdentifier("identifier_layer", "Cell ID identifier for layer", m_layerID, "layer"); + registerIdentifier("identifier_module", "Cell ID identifier for module", m_moduleID, "module"); + registerParameter("mergedCells_Theta", "Numbers of merged cells in theta per layer", m_mergedCellsTheta, std::vector()); + registerParameter("mergedModules", "Numbers of merged cells in phi per layer", m_mergedModules, std::vector()); + registerParameter("nModules", "Number of modules", m_nModules, 1545); + + //m_nModules = 1545; + //m_alpha = 50./180.*M_PI; + //m_rLayers = {217.28, 218.78, 222.28, 225.78, 229.28, 232.78, 236.28, 239.78, 243.28, 246.78, 250.28, 253.78, 257.33}; +} + +/// determine the local position based on the cell ID +Vector3D FCCSWGridModuleThetaMerged::position(const CellID& cID) const { + + //debug + std::cout << "cellID: " << cID << std::endl; + + // cannot return for R=0 otherwise will lose phi info, return for R=1 + return positionFromRThetaPhi(1.0, theta(cID), phi(cID)); + + // version 1: determine radius/theta/phi from cellID + // return positionFromRThetaPhi(radius(cID), theta(cID), phi(cID)); + + // version 2: use detector position + // read in outGlobal the x-y-z coordinates of the 1st of the merged group of cells + /* + VolumeID vID = cID; + _decoder->set(vID, m_thetaID, 0); + auto detelement = m_volman.lookupDetElement(vID); + const auto& transformMatrix = detelement.nominal().worldTransformation(); + double outGlobal[3]; + double inLocal[] = {0, 0, 0}; + transformMatrix.LocalToMaster(inLocal, outGlobal); + // now get R-phi + Vector3D position(outGlobal[0],outGlobal[1],outGlobal[2]); + double _radius = std::sqrt(outGlobal[0]*outGlobal[0] + outGlobal[1]*outGlobal[1]); + double _phi = std::atan2(outGlobal[1], outGlobal[0]); + // now add shifts in phi due to merging of modules and theta cells + int layer = _decoder->get(cID, m_layerID); + if (m_mergedModules[layer]>1) { + _phi += (m_mergedModules[layer]-1) * M_PI / m_nModules ; + // should we check (and adjust) that phi is in -pi..pi? or 0..2pi? + } + // get theta from grid + double _theta = theta(cID); + return positionFromRThetaPhi(_radius, _theta, _phi); + */ +} + +/// determine the cell ID based on the global position +CellID FCCSWGridModuleThetaMerged::cellID(const Vector3D& /* localPosition */, const Vector3D& globalPosition, + const VolumeID& vID) const { + CellID cID = vID; + + // retrieve layer (since merging depends on layer) + int layer = _decoder->get(vID, m_layerID); + + // retrieve theta + double lTheta = thetaFromXYZ(globalPosition); + + // calculate theta bin with original segmentation + int thetaBin = positionToBin(lTheta, m_gridSizeTheta, m_offsetTheta); + + // adjust theta bin if cells are merged along theta in this layer + if (m_mergedCellsTheta[layer]>1) { + if ((thetaBin % m_mergedCellsTheta[layer])>0) + thetaBin -= (thetaBin % m_mergedCellsTheta[layer]); + } + + // set theta field of cellID + _decoder->set(cID, m_thetaID, thetaBin); + + // retrieve module number + int module = _decoder->get(vID, m_moduleID); + + // adjust module number if modules are merged in this layer + if (m_mergedModules[layer]>1) { + if ((module % m_mergedModules[layer])>0) + module -= (module % m_mergedModules[layer]); + } + + // set module field of cellID + _decoder->set(cID, m_moduleID, module); + + return cID; +} + +/// determine the radius based on the cell ID +/* +double FCCSWGridModuleThetaMerged::radius(const CellID& cID) const { + + int layer = _decoder->get(cID, m_layerID); + + return (m_rLayers[layer+1]+m_rLayers[layer])/2.0; +} +*/ + +/// determine the azimuth based on the cell ID +double FCCSWGridModuleThetaMerged::phi(const CellID& cID) const { + + // retrieve layer, radius and module + int layer = _decoder->get(cID, m_layerID); + + /* + // calculate phi of volume + int module = _decoder->get(cID, m_moduleID); + double r = radius(cID); + + // calculate initial phi + // not sure this is fully consistent with Geant4 positioning!!!! + // I need to find out which phi is module=0 + double phi = 2.0*M_PI/m_nModules * (module) - m_alpha; + + // calculate phi offset due to electrode inclination + double r0 = m_rLayers[0]; + double L = -r0*cos(m_alpha) + std::sqrt(r*r-r0*r0*std::sin(m_alpha)*std::sin(m_alpha)); + double dphi = std::acos((r*r+r0*r0-L*L)/(2*r*r0)); + phi += dphi; + */ + + // calculate phi offset due to merging + double phi = 0.0; + if (m_mergedModules[layer]>1) { + phi += (m_mergedModules[layer]-1) * M_PI / m_nModules ; + // should we check (and adjust) that phi is in -pi..pi? or 0..2pi? + } + + //debug + std::cout << "layer: " << layer << std::endl; + std::cout << "merged modules: " << m_mergedModules[layer] << std::endl; + std::cout << "phi: " << phi << std::endl; + + return phi; +} + +double FCCSWGridModuleThetaMerged::theta(const CellID& cID) const { + + // retrieve layer + int layer = _decoder->get(cID, m_layerID); + + // retrieve theta bin from cellID and determine theta position + CellID thetaValue = _decoder->get(cID, m_thetaID); + // debug + std::cout << "theta bin: " << thetaValue << std::endl; + double _theta = binToPosition(thetaValue, m_gridSizeTheta, m_offsetTheta); + std::cout << "gridSizeTheta, offsetTheta: " << m_gridSizeTheta << " , " << m_offsetTheta << std::endl; + // adjust return value if cells are merged along theta in this layer + // shift by (N-1)*half theta grid size + if (m_mergedCellsTheta[layer]>1) { + _theta += (m_mergedCellsTheta[layer]-1) * m_gridSizeTheta / 2.0 ; + } + + std::cout << "theta: " << _theta << std::endl; + return _theta; +} + +} +} diff --git a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMergedHandle.cpp b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMergedHandle.cpp new file mode 100644 index 00000000..e4b49941 --- /dev/null +++ b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMergedHandle.cpp @@ -0,0 +1,4 @@ +#include "DetSegmentation/FCCSWGridModuleThetaMergedHandle.h" +#include "DD4hep/detail/Handle.inl" + +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged); diff --git a/Detector/DetSegmentation/src/plugins/SegmentationFactories.cpp b/Detector/DetSegmentation/src/plugins/SegmentationFactories.cpp index 4758e476..7a1f8c15 100644 --- a/Detector/DetSegmentation/src/plugins/SegmentationFactories.cpp +++ b/Detector/DetSegmentation/src/plugins/SegmentationFactories.cpp @@ -17,6 +17,9 @@ DECLARE_SEGMENTATION(GridTheta, create_segmentation) +#include "DetSegmentation/FCCSWGridModuleThetaMerged.h" +DECLARE_SEGMENTATION(FCCSWGridModuleThetaMerged, create_segmentation) + #include "DetSegmentation/FCCSWGridPhiEta.h" DECLARE_SEGMENTATION(FCCSWGridPhiEta, create_segmentation) From 2407b6606e3cac64d61dee416872747723a4133a Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Tue, 13 Jun 2023 17:10:58 +0200 Subject: [PATCH 02/12] implement module-theta (with per-layer merging) readout --- .../compact/FCCee_ECalBarrel_thetamodulemerged.xml | 4 ++-- .../include/DetSegmentation/FCCSWGridModuleThetaMerged.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index bb4f6017..7305dd76 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -94,13 +94,13 @@ - + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 - + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h index 0c129b5a..70ccbb19 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h @@ -69,7 +69,7 @@ class FCCSWGridModuleThetaMerged : public GridTheta { /** Set the number of modules * return The number of modules (as it was set by the user in the xml file..) */ - inline int setNModules(const int nModules) { m_nModules = nModules; } + inline void setNModules(const int nModules) { m_nModules = nModules; } /** Get the field name used for the layer * return The field name for the layer. */ From d5a39a5a4400ad9165f40fbb0e67372152c4963c Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 14 Jun 2023 11:41:59 +0200 Subject: [PATCH 03/12] cleanup --- .../src/FCCSWGridModuleThetaMerged.cpp | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp index 8c5271cf..5008eb20 100644 --- a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp +++ b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp @@ -17,6 +17,7 @@ FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const std::string& cellEn registerParameter("mergedCells_Theta", "Numbers of merged cells in theta per layer", m_mergedCellsTheta, std::vector()); registerParameter("mergedModules", "Numbers of merged modules per layer", m_mergedModules, std::vector()); registerParameter("nModules", "Number of modules", m_nModules, 1545); + //m_nModules = 1545; //m_alpha = 50./180.*M_PI; //m_rLayers = {217.28, 218.78, 222.28, 225.78, 229.28, 232.78, 236.28, 239.78, 243.28, 246.78, 250.28, 253.78, 257.33}; @@ -42,39 +43,11 @@ FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const BitFieldCoder* deco /// determine the local position based on the cell ID Vector3D FCCSWGridModuleThetaMerged::position(const CellID& cID) const { - //debug - std::cout << "cellID: " << cID << std::endl; + // debug + // std::cout << "cellID: " << cID << std::endl; // cannot return for R=0 otherwise will lose phi info, return for R=1 return positionFromRThetaPhi(1.0, theta(cID), phi(cID)); - - // version 1: determine radius/theta/phi from cellID - // return positionFromRThetaPhi(radius(cID), theta(cID), phi(cID)); - - // version 2: use detector position - // read in outGlobal the x-y-z coordinates of the 1st of the merged group of cells - /* - VolumeID vID = cID; - _decoder->set(vID, m_thetaID, 0); - auto detelement = m_volman.lookupDetElement(vID); - const auto& transformMatrix = detelement.nominal().worldTransformation(); - double outGlobal[3]; - double inLocal[] = {0, 0, 0}; - transformMatrix.LocalToMaster(inLocal, outGlobal); - // now get R-phi - Vector3D position(outGlobal[0],outGlobal[1],outGlobal[2]); - double _radius = std::sqrt(outGlobal[0]*outGlobal[0] + outGlobal[1]*outGlobal[1]); - double _phi = std::atan2(outGlobal[1], outGlobal[0]); - // now add shifts in phi due to merging of modules and theta cells - int layer = _decoder->get(cID, m_layerID); - if (m_mergedModules[layer]>1) { - _phi += (m_mergedModules[layer]-1) * M_PI / m_nModules ; - // should we check (and adjust) that phi is in -pi..pi? or 0..2pi? - } - // get theta from grid - double _theta = theta(cID); - return positionFromRThetaPhi(_radius, _theta, _phi); - */ } /// determine the cell ID based on the global position @@ -152,13 +125,12 @@ double FCCSWGridModuleThetaMerged::phi(const CellID& cID) const { double phi = 0.0; if (m_mergedModules[layer]>1) { phi += (m_mergedModules[layer]-1) * M_PI / m_nModules ; - // should we check (and adjust) that phi is in -pi..pi? or 0..2pi? } - //debug - std::cout << "layer: " << layer << std::endl; - std::cout << "merged modules: " << m_mergedModules[layer] << std::endl; - std::cout << "phi: " << phi << std::endl; + // debug + // std::cout << "layer: " << layer << std::endl; + // std::cout << "merged modules: " << m_mergedModules[layer] << std::endl; + // std::cout << "phi: " << phi << std::endl; return phi; } @@ -170,17 +142,21 @@ double FCCSWGridModuleThetaMerged::theta(const CellID& cID) const { // retrieve theta bin from cellID and determine theta position CellID thetaValue = _decoder->get(cID, m_thetaID); - // debug - std::cout << "theta bin: " << thetaValue << std::endl; double _theta = binToPosition(thetaValue, m_gridSizeTheta, m_offsetTheta); - std::cout << "gridSizeTheta, offsetTheta: " << m_gridSizeTheta << " , " << m_offsetTheta << std::endl; + // adjust return value if cells are merged along theta in this layer // shift by (N-1)*half theta grid size if (m_mergedCellsTheta[layer]>1) { _theta += (m_mergedCellsTheta[layer]-1) * m_gridSizeTheta / 2.0 ; } - std::cout << "theta: " << _theta << std::endl; + // debug + // std::cout << "layer: " << layer << std::endl; + // std::cout << "theta bin: " << thetaValue << std::endl; + // std::cout << "gridSizeTheta, offsetTheta: " << m_gridSizeTheta << " , " << m_offsetTheta << std::endl; + // std::cout << "merged cells: " << m_mergedCellsTheta[layer] << std::endl; + // std::cout << "theta: " << _theta << std::endl; + return _theta; } From 6ad00712e39dc0e6f579efb1fa00a8871d82b476 Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 21 Jun 2023 17:52:45 +0200 Subject: [PATCH 04/12] cleanup --- .../compact/FCCee_ECalBarrel_thetamodulemerged.xml | 2 +- .../include/DetSegmentation/FCCSWGridModuleThetaMerged.h | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index 7305dd76..bf066c41 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -100,7 +100,7 @@ - + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h index 70ccbb19..3862ed7f 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h @@ -89,14 +89,9 @@ class FCCSWGridModuleThetaMerged : public GridTheta { /// vector of number of modules to be merged for each layer std::vector m_mergedModules; - /// to be seen if we need these - /// and how to retrieve them at initialization step from the geometry + /// to be seen how to retrieve this initialization step from the geometry /// number of modules (or, equivalently, the deltaPhi between adjacent modules) int m_nModules; - /// innermost radius of electrodes (not needed) - /// std::vector m_rLayers; - /// inclination in phi of electrodes (not needed) - //// double m_alpha; }; } } From fb230a1fd8b24d52c41cc6bd54b7513ef9bf05b2 Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 21 Jun 2023 17:54:22 +0200 Subject: [PATCH 05/12] cleanup --- .../src/FCCSWGridModuleThetaMerged.cpp | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp index 5008eb20..02fe1d44 100644 --- a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp +++ b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp @@ -17,10 +17,6 @@ FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const std::string& cellEn registerParameter("mergedCells_Theta", "Numbers of merged cells in theta per layer", m_mergedCellsTheta, std::vector()); registerParameter("mergedModules", "Numbers of merged modules per layer", m_mergedModules, std::vector()); registerParameter("nModules", "Number of modules", m_nModules, 1545); - - //m_nModules = 1545; - //m_alpha = 50./180.*M_PI; - //m_rLayers = {217.28, 218.78, 222.28, 225.78, 229.28, 232.78, 236.28, 239.78, 243.28, 246.78, 250.28, 253.78, 257.33}; } FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const BitFieldCoder* decoder) : GridTheta(decoder) { @@ -34,10 +30,6 @@ FCCSWGridModuleThetaMerged::FCCSWGridModuleThetaMerged(const BitFieldCoder* deco registerParameter("mergedCells_Theta", "Numbers of merged cells in theta per layer", m_mergedCellsTheta, std::vector()); registerParameter("mergedModules", "Numbers of merged cells in phi per layer", m_mergedModules, std::vector()); registerParameter("nModules", "Number of modules", m_nModules, 1545); - - //m_nModules = 1545; - //m_alpha = 50./180.*M_PI; - //m_rLayers = {217.28, 218.78, 222.28, 225.78, 229.28, 232.78, 236.28, 239.78, 243.28, 246.78, 250.28, 253.78, 257.33}; } /// determine the local position based on the cell ID @@ -88,39 +80,17 @@ CellID FCCSWGridModuleThetaMerged::cellID(const Vector3D& /* localPosition */, c return cID; } -/// determine the radius based on the cell ID -/* -double FCCSWGridModuleThetaMerged::radius(const CellID& cID) const { - - int layer = _decoder->get(cID, m_layerID); - - return (m_rLayers[layer+1]+m_rLayers[layer])/2.0; -} -*/ - /// determine the azimuth based on the cell ID +/// the value returned is the relative shift in phi +/// with respect to the first module in the group of +/// merged ones - which will be then added on top of +/// the phi of the volume containing the first cell +/// by the positioning tool double FCCSWGridModuleThetaMerged::phi(const CellID& cID) const { // retrieve layer, radius and module int layer = _decoder->get(cID, m_layerID); - /* - // calculate phi of volume - int module = _decoder->get(cID, m_moduleID); - double r = radius(cID); - - // calculate initial phi - // not sure this is fully consistent with Geant4 positioning!!!! - // I need to find out which phi is module=0 - double phi = 2.0*M_PI/m_nModules * (module) - m_alpha; - - // calculate phi offset due to electrode inclination - double r0 = m_rLayers[0]; - double L = -r0*cos(m_alpha) + std::sqrt(r*r-r0*r0*std::sin(m_alpha)*std::sin(m_alpha)); - double dphi = std::acos((r*r+r0*r0-L*L)/(2*r*r0)); - phi += dphi; - */ - // calculate phi offset due to merging double phi = 0.0; if (m_mergedModules[layer]>1) { @@ -135,6 +105,8 @@ double FCCSWGridModuleThetaMerged::phi(const CellID& cID) const { return phi; } +/// determine the polar angle based on the cell ID and the +/// number of merged theta cells double FCCSWGridModuleThetaMerged::theta(const CellID& cID) const { // retrieve layer From 7e5242734072b3f905dab5bfdd061f4dee3e78df Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 28 Jun 2023 08:31:10 +0200 Subject: [PATCH 06/12] performance improvements --- .../FCCee_ECalBarrel_thetamodulemerged.xml | 14 +++++----- .../FCCSWGridModuleThetaMerged.h | 4 +-- .../FCCSWGridModuleThetaMergedHandle.h | 4 +-- .../src/FCCSWGridModuleThetaMerged.cpp | 27 +++++++------------ Detector/DetSegmentation/src/GridEta.cpp | 8 +++--- 5 files changed, 26 insertions(+), 31 deletions(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index bf066c41..6cfb3e09 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -81,10 +81,10 @@ - - + - + - + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 - + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h index 3862ed7f..cad7d607 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMerged.h @@ -56,12 +56,12 @@ class FCCSWGridModuleThetaMerged : public GridTheta { * @param[in] layer * return The number of merged cells in theta */ - inline int mergedThetaCells(const unsigned int layer) const { return m_mergedCellsTheta[layer]; } + inline int mergedThetaCells(const int layer) const { return m_mergedCellsTheta[layer]; } /** Get the number of merged modules (inclined in phi) * @param[in] layer * return The number of merged cells in theta */ - inline int mergedModules(const unsigned int layer) const { return m_mergedModules[layer]; } + inline int mergedModules(const int layer) const { return m_mergedModules[layer]; } /** Get the number of modules * return The number of modules (as it was set by the user in the xml file..) */ diff --git a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h index 2a3a3f20..0d4f561f 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h +++ b/Detector/DetSegmentation/include/DetSegmentation/FCCSWGridModuleThetaMergedHandle.h @@ -78,13 +78,13 @@ class FCCSWGridModuleThetaMerged : public FCCSWGridModuleThetaMergedHandle { inline double offsetTheta() const { return access()->implementation->offsetTheta(); } /// access the number of theta cells merged for given layer - inline int mergedThetaCells(const unsigned int layer) const { return access()->implementation->mergedThetaCells(layer); } + inline int mergedThetaCells(const int layer) const { return access()->implementation->mergedThetaCells(layer); } /// access the number of modules inline int nModules() const { return access()->implementation->nModules(); } /// access the number of merged modules for given layer - inline int mergedModules(const unsigned int layer) const { return access()->implementation->mergedModules(layer); } + inline int mergedModules(const int layer) const { return access()->implementation->mergedModules(layer); } /// set the coordinate offset in theta diff --git a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp index 02fe1d44..ea949f1c 100644 --- a/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp +++ b/Detector/DetSegmentation/src/FCCSWGridModuleThetaMerged.cpp @@ -57,10 +57,8 @@ CellID FCCSWGridModuleThetaMerged::cellID(const Vector3D& /* localPosition */, c int thetaBin = positionToBin(lTheta, m_gridSizeTheta, m_offsetTheta); // adjust theta bin if cells are merged along theta in this layer - if (m_mergedCellsTheta[layer]>1) { - if ((thetaBin % m_mergedCellsTheta[layer])>0) - thetaBin -= (thetaBin % m_mergedCellsTheta[layer]); - } + // assume that m_mergedCellsTheta[layer]>=1 + thetaBin -= (thetaBin % m_mergedCellsTheta[layer]); // set theta field of cellID _decoder->set(cID, m_thetaID, thetaBin); @@ -69,10 +67,8 @@ CellID FCCSWGridModuleThetaMerged::cellID(const Vector3D& /* localPosition */, c int module = _decoder->get(vID, m_moduleID); // adjust module number if modules are merged in this layer - if (m_mergedModules[layer]>1) { - if ((module % m_mergedModules[layer])>0) - module -= (module % m_mergedModules[layer]); - } + // assume that m_mergedModules[layer]>=1 + module -= (module % m_mergedModules[layer]); // set module field of cellID _decoder->set(cID, m_moduleID, module); @@ -88,14 +84,12 @@ CellID FCCSWGridModuleThetaMerged::cellID(const Vector3D& /* localPosition */, c /// by the positioning tool double FCCSWGridModuleThetaMerged::phi(const CellID& cID) const { - // retrieve layer, radius and module + // retrieve layer int layer = _decoder->get(cID, m_layerID); - // calculate phi offset due to merging - double phi = 0.0; - if (m_mergedModules[layer]>1) { - phi += (m_mergedModules[layer]-1) * M_PI / m_nModules ; - } + // calculate phi offset due to merging + // assume that m_mergedModules[layer]>=1 + double phi = (m_mergedModules[layer]-1) * M_PI / m_nModules ; // debug // std::cout << "layer: " << layer << std::endl; @@ -118,9 +112,8 @@ double FCCSWGridModuleThetaMerged::theta(const CellID& cID) const { // adjust return value if cells are merged along theta in this layer // shift by (N-1)*half theta grid size - if (m_mergedCellsTheta[layer]>1) { - _theta += (m_mergedCellsTheta[layer]-1) * m_gridSizeTheta / 2.0 ; - } + // assume that m_mergedCellsTheta[layer]>=1 + _theta += (m_mergedCellsTheta[layer]-1) * m_gridSizeTheta / 2.0 ; // debug // std::cout << "layer: " << layer << std::endl; diff --git a/Detector/DetSegmentation/src/GridEta.cpp b/Detector/DetSegmentation/src/GridEta.cpp index 6e118d4d..232d0b50 100644 --- a/Detector/DetSegmentation/src/GridEta.cpp +++ b/Detector/DetSegmentation/src/GridEta.cpp @@ -11,7 +11,7 @@ GridEta::GridEta(const std::string& cellEncoding) : Segmentation(cellEncoding) { _description = "Eeta segmentation in the global coordinates"; // register all necessary parameters - registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_eta", "Cell size in eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true); registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta"); } @@ -19,10 +19,10 @@ GridEta::GridEta(const std::string& cellEncoding) : Segmentation(cellEncoding) { GridEta::GridEta(const BitFieldCoder* decoder) : Segmentation(decoder) { // define type and description _type = "GridEta"; - _description = "Eeta segmentation in the global coordinates"; + _description = "Eta segmentation in the global coordinates"; // register all necessary parameters - registerParameter("grid_size_eta", "Cell size in Eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); + registerParameter("grid_size_eta", "Cell size in eta", m_gridSizeEta, 1., SegmentationParameter::LengthUnit); registerParameter("offset_eta", "Angular offset in eta", m_offsetEta, 0., SegmentationParameter::AngleUnit, true); registerIdentifier("identifier_eta", "Cell ID identifier for eta", m_etaID, "eta"); } @@ -46,7 +46,7 @@ CellID GridEta::cellID(const Vector3D& /* localPosition */, const Vector3D& glob // return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); //} -/// determine the polar angle theta based on the cell ID +/// determine the pseudorapidity based on the cell ID double GridEta::eta(const CellID& cID) const { CellID etaValue = _decoder->get(cID, m_etaID); return binToPosition(etaValue, m_gridSizeEta, m_offsetEta); From 171dad96b92131977ff2c0b700ad70140b67bd56 Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 12 Jul 2023 09:30:02 +0200 Subject: [PATCH 07/12] little fix for granularity --- .../compact/FCCee_ECalBarrel_thetamodulemerged.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index 6cfb3e09..a704f30f 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -82,27 +82,27 @@ - + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 - - + + system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 From c765ab4a1a6d42472a340a7648d21efab5575e5e Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Wed, 12 Jul 2023 15:15:35 +0200 Subject: [PATCH 08/12] read number of modules from xml --- .../FCCee_ECalBarrel_thetamodulemerged.xml | 1 + .../src/ECalBarrelInclined_geo.cpp | 6 ++++++ .../DetSegmentation/FCCSWGridModuleThetaMerged.h | 3 +++ .../src/FCCSWGridModuleThetaMerged.cpp | 15 ++++++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index a704f30f..d4b13390 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -58,6 +58,7 @@ + - - - - - - - - + + - system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 - + - system:4,cryo:1,type:3,subtype:3,layer:8,module:11,theta:10 - - diff --git a/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h b/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h index e8f086ea..5707d2e7 100644 --- a/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h +++ b/Detector/DetSegmentation/include/DetSegmentation/GridTheta.h @@ -69,7 +69,7 @@ class GridTheta : public Segmentation { inline void setFieldNameTheta(const std::string& fieldName) { m_thetaID = fieldName; } /// calculates the Cartesian position from cylindrical coordinates (r, phi, theta) inline Vector3D positionFromRThetaPhi(double ar, double atheta, double aphi) const { - return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar * std::cos(atheta)/std::sin(atheta)); + return Vector3D(ar * std::cos(aphi), ar * std::sin(aphi), ar * std::cos(atheta)/std::sin(atheta)); } /// calculates the theta angle from Cartesian coordinates inline double thetaFromXYZ(const Vector3D& aposition) const { From c8e2c4b0a5ab16ee674bf59f422471861dbab065 Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Thu, 21 Sep 2023 17:53:11 +0200 Subject: [PATCH 11/12] add a comment to the code --- .../src/ECalBarrelInclined_geo.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Detector/DetFCChhECalInclined/src/ECalBarrelInclined_geo.cpp b/Detector/DetFCChhECalInclined/src/ECalBarrelInclined_geo.cpp index d5951922..72a7bb0c 100644 --- a/Detector/DetFCChhECalInclined/src/ECalBarrelInclined_geo.cpp +++ b/Detector/DetFCChhECalInclined/src/ECalBarrelInclined_geo.cpp @@ -186,6 +186,15 @@ static dd4hep::detail::Ref_t createECalBarrelInclined(dd4hep::Detector& aLcdd, uint numPlanes = round(M_PI / asin((passiveThickness + activeThickness + readoutThickness) / (2. * caloDim.rmin() * cos(angle)))); + // The following code checks if the xml geometry file contains a constant defining + // the number of planes in the barrel. In that case, it makes the program abort + // if the number of planes in the xml is different from the one calculated from + // the geometry. This is because the number of plane information (retrieved from the + // xml) is used in other parts of the code (the readout for the FCC-ee ECAL with + // inclined modules). In principle the code above should be refactored so that the number + // of planes is one of the inputs of the calculation and other geometrical parameters + // are adjusted accordingly. This is left for the future, and we use the workaround + // below to enforce for the time being that the number of planes is "correct" int nModules = -1; try { nModules = aLcdd.constant("ECalBarrelNumPlanes"); @@ -199,7 +208,6 @@ static dd4hep::detail::Ref_t createECalBarrelInclined(dd4hep::Detector& aLcdd, // make the code crash (incidentSvc does not work) assert(nModules == numPlanes); } - //std::cout << "Number of modules read from detector metadata and used in readout class: " << m_nModules << std::endl; double dPhi = 2. * M_PI / numPlanes; lLog << MSG::INFO << "number of passive plates = " << numPlanes << " azim. angle difference = " << dPhi << endmsg; lLog << MSG::INFO << " distance at inner radius (cm) = " << 2. * M_PI * caloDim.rmin() / numPlanes << "\n" From 9542241ac18dcf56636361318d2dae088f5e7c70 Mon Sep 17 00:00:00 2001 From: Giovanni Marchiori Date: Thu, 21 Sep 2023 23:22:10 +0200 Subject: [PATCH 12/12] add number of layers info (currently only for printout of merging config but could be used to enforce that length of vector passed via xml to configure merging per layer is correct --- .../FCCee_ECalBarrel_thetamodulemerged.xml | 1 + .../src/ECalBarrelInclined_geo.cpp | 21 +++++++++++- .../FCCSWGridModuleThetaMerged.h | 34 ++++++++++++++----- .../FCCSWGridModuleThetaMergedHandle.h | 15 ++++---- .../src/FCCSWGridModuleThetaMerged.cpp | 18 ++++++++-- 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml index e9401b96..c9a8f312 100644 --- a/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml +++ b/Detector/DetFCCeeECalInclined/compact/FCCee_ECalBarrel_thetamodulemerged.xml @@ -59,6 +59,7 @@ +