|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \file GeometryTGeo.h |
| 12 | +/// \brief Definition of the GeometryTGeo class |
| 13 | +/// \author cvetan.cheshkov@cern.ch - 15/02/2007 |
| 14 | +/// \author ruben.shahoyan@cern.ch - adapted to ITSupg 18/07/2012 |
| 15 | +/// \author rafael.pezzi@cern.ch - adapted to PostLS4EndCaps 25/06/2020 |
| 16 | + |
| 17 | +#ifndef ALICEO2_FT3_GEOMETRYTGEO_H_ |
| 18 | +#define ALICEO2_FT3_GEOMETRYTGEO_H_ |
| 19 | + |
| 20 | +#include <TGeoMatrix.h> // for TGeoHMatrix |
| 21 | +#include <TObject.h> // for TObject |
| 22 | +#include <array> |
| 23 | +#include <string> |
| 24 | +#include <vector> |
| 25 | +#include "DetectorsBase/GeometryManager.h" |
| 26 | +#include "DetectorsCommonDataFormats/DetID.h" |
| 27 | +#include "ITSMFTBase/GeometryTGeo.h" |
| 28 | +#include "MathUtils/Utils.h" |
| 29 | +#include "Rtypes.h" // for Int_t, Double_t, Bool_t, UInt_t, etc |
| 30 | + |
| 31 | +class TGeoPNEntry; |
| 32 | + |
| 33 | +namespace o2 |
| 34 | +{ |
| 35 | +namespace ft3 |
| 36 | +{ |
| 37 | +/// GeometryTGeo is a simple interface class to TGeoManager. It is used in the simulation |
| 38 | +/// in order to query the TGeo FT3 geometry. |
| 39 | +/// RS: In order to preserve the static character of the class but make it dynamically access |
| 40 | +/// geometry, we need to check in every method if the structures are initialized. To be converted |
| 41 | +/// to singleton at later stage. |
| 42 | + |
| 43 | +class GeometryTGeo : public o2::itsmft::GeometryTGeo |
| 44 | +{ |
| 45 | + public: |
| 46 | + typedef o2::math_utils::Transform3D Mat3D; |
| 47 | + using DetMatrixCache::getMatrixL2G; |
| 48 | + using DetMatrixCache::getMatrixT2GRot; |
| 49 | + using DetMatrixCache::getMatrixT2L; |
| 50 | + // this method is not advised for ITS: for barrel detectors whose tracking frame is just a rotation |
| 51 | + // it is cheaper to use T2GRot |
| 52 | + using DetMatrixCache::getMatrixT2G; |
| 53 | + |
| 54 | + static GeometryTGeo* Instance() |
| 55 | + { |
| 56 | + // get (create if needed) a unique instance of the object |
| 57 | + if (!sInstance) { |
| 58 | + sInstance = std::unique_ptr<GeometryTGeo>(new GeometryTGeo(true, 0)); |
| 59 | + } |
| 60 | + return sInstance.get(); |
| 61 | + } |
| 62 | + |
| 63 | + // adopt the unique instance from external raw pointer (to be used only to read saved instance from file) |
| 64 | + static void adopt(GeometryTGeo* raw); |
| 65 | + |
| 66 | + // constructor |
| 67 | + // ATTENTION: this class is supposed to behave as a singleton, but to make it root-persistent |
| 68 | + // we must define public default constructor. |
| 69 | + // NEVER use it, it will throw exception if the class instance was already created |
| 70 | + // Use GeometryTGeo::Instance() instead |
| 71 | + GeometryTGeo(bool build = kFALSE, int loadTrans = 0 |
| 72 | + /*o2::base::utils::bit2Mask(o2::TransformType::T2L, // default transformations to load |
| 73 | + o2::TransformType::T2G, |
| 74 | + o2::TransformType::L2G)*/ |
| 75 | + ); |
| 76 | + |
| 77 | + /// Default destructor |
| 78 | + ~GeometryTGeo() override = default; |
| 79 | + |
| 80 | + GeometryTGeo(const GeometryTGeo& src) = delete; |
| 81 | + GeometryTGeo& operator=(const GeometryTGeo& geom) = delete; |
| 82 | + |
| 83 | + // implement filling of the matrix cache |
| 84 | + using o2::itsmft::GeometryTGeo::fillMatrixCache; |
| 85 | + void fillMatrixCache(int mask) override; |
| 86 | + |
| 87 | + /// Exract FT3 parameters from TGeo |
| 88 | + void Build(int loadTrans = 0) override; |
| 89 | + |
| 90 | + void Print(Option_t* opt = "") const; |
| 91 | + static const char* getFT3VolPattern() { return sVolumeName.c_str(); } |
| 92 | + static const char* getFT3LayerPattern() { return sLayerName.c_str(); } |
| 93 | + static const char* getFT3ChipPattern() { return sChipName.c_str(); } |
| 94 | + static const char* getFT3SensorPattern() { return sSensorName.c_str(); } |
| 95 | + |
| 96 | + static const char* composeSymNameFT3(Int_t d) { return Form("%s_%d", o2::detectors::DetID(o2::detectors::DetID::FT3).getName(), d); } |
| 97 | + static const char* composeSymNameLayer(Int_t d, Int_t lr); |
| 98 | + static const char* composeSymNameChip(Int_t d, Int_t lr); |
| 99 | + static const char* composeSymNameSensor(Int_t d, Int_t lr); |
| 100 | + |
| 101 | + protected: |
| 102 | + static constexpr int MAXLAYERS = 15; ///< max number of active layers |
| 103 | + |
| 104 | + Int_t mNumberOfLayers; ///< number of layers |
| 105 | + static std::string sVolumeName; ///< Mother volume name |
| 106 | + static std::string sLayerName; ///< Layer name |
| 107 | + static std::string sChipName; ///< Chip name |
| 108 | + |
| 109 | + static std::string sSensorName; ///< Sensor name |
| 110 | + |
| 111 | + private: |
| 112 | + static std::unique_ptr<o2::ft3::GeometryTGeo> sInstance; ///< singletone instance |
| 113 | + |
| 114 | + ClassDefOverride(GeometryTGeo, 1); // FT3 geometry based on TGeo |
| 115 | +}; |
| 116 | +} // namespace ft3 |
| 117 | +} // namespace o2 |
| 118 | + |
| 119 | +#endif |
0 commit comments