ATLAS Offline Software
MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "NSWGeoPlottingAlg.h"
5 
6 #include <cmath>
7 
8 #include "GaudiKernel/SystemOfUnits.h"
11 #include "StoreGate/ReadHandle.h"
12 #include "TFile.h"
13 #include "TGraph.h"
14 #include "TH1.h"
15 #include "TH2I.h"
16 
17 #include "Acts/Surfaces/Surface.hpp"
18 #include "Acts/Surfaces/SurfaceBounds.hpp"
19 
21 
22 
23 namespace MuonGMR4 {
25  ISvcLocator* pSvcLocator)
26  : AthHistogramAlgorithm(name, pSvcLocator) {}
27 
28 
31  ATH_CHECK(m_idHelperSvc.retrieve());
33  ATH_MSG_INFO("Check Acts surface "<<m_testActsSurf);
34  ATH_CHECK(initMm());
36  return StatusCode::SUCCESS;
37 }
39  const EventContext& ctx = Gaudi::Hive::currentContext();
41  ATH_CHECK(gctxHandle.isPresent());
42 
43  std::vector<const MmReadoutElement*> micromegas = m_detMgr->getAllMmReadoutElements();
44  for (const MmReadoutElement* mm : micromegas) {
45  for (int gasGap = 1; gasGap <= 4; ++ gasGap) {
46  const IdentifierHash hash = MmReadoutElement::createHash(gasGap, (mm->stationEta() > 0 ? 1 : 2) +
47  10 * mm->multilayer());
48  auto histo = m_mmActiveAreas[hash];
49  const StripDesign& design{mm->stripLayer(hash).design()};
50  const Acts::Surface& plane{mm->surface(mm->layerHash(hash))};
51  const double halfY = 2.*design.longHalfHeight();
52  const double halfX = 2.*design.halfWidth();
53  for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){
54  for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) {
55  const Amg::Vector3D locPos{x,y,0};
56  if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) {
57  continue;
58  } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) {
59  continue;
60  }
61 
62  const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos;
63  histo->Fill(globPos.x(), globPos.y());
64  }
65  }
66  }
67  }
68 
69  std::vector<const sTgcReadoutElement*> sTgcs = m_detMgr->getAllsTgcReadoutElements();
70  for (const sTgcReadoutElement* sTgc : sTgcs) {
71  for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){
72  for (int gasGap = 1; gasGap <= 4; ++ gasGap) {
73  const IdentifierHash hash = sTgcReadoutElement::createHash(gasGap, chanType, (sTgc->stationEta() > 0 ? 1 : 2) +
74  10 * sTgc->multilayer());
76 
77  const StripDesign& design{ chanType == chType::Strip? sTgc->stripDesign(hash) :
78  chanType == chType::Wire ? static_cast<const StripDesign&>(sTgc->wireDesign(hash))
79  : static_cast<const StripDesign&>(sTgc->padDesign(hash))};
80  const Acts::Surface& plane{sTgc->surface(sTgc->layerHash(hash))};
81  const double halfY = 2.*design.longHalfHeight();
82  const double halfX = 2.*design.halfWidth();
83  for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){
84  for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) {
85  const Amg::Vector3D locPos{x,y,0};
86  if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) {
87  continue;
88  } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) {
89  continue;
90  }
91 
92  const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos;
93  histo->Fill(globPos.x(), globPos.y());
94  }
95  }
96  }
97  }
98  }
99 
100 
101 
102 
103  return StatusCode::SUCCESS;
104 }
106  for (unsigned int ml =1 ; ml <= 2; ++ml) {
107  for(unsigned int active =1 ; active <= 2; ++active){
108  for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){
109  for (unsigned int gasGap =1; gasGap <= 4; ++gasGap) {
110  std::string histoName = "STGC_"+std::string(active == 1? "A" : "C") + "M" +
111  std::to_string(ml) + "G" + std::to_string(gasGap) +
112  + (chanType == chType::Strip? "S" :
113  chanType == chType::Wire ? "W" : "P");
114 
115  auto newHisto = std::make_unique<TH2I>(histoName.c_str(),
116  "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
117  -5001., 5001.);
118  m_stgcActiveAreas[sTgcReadoutElement::createHash(gasGap, chanType, active + 10 * ml)] = newHisto.get();
119  ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto)));
120  }
121  }
122  }
123  }
124  return StatusCode::SUCCESS;
125 }
127 
128  for (unsigned int ml = 1; ml <= 2; ++ml) {
129  for (unsigned int active = 1; active <= 2; ++ active) {
130  for (unsigned int gasGap = 1; gasGap <= 4; ++gasGap) {
131  std::string histoName = "MM_"+std::string(active == 1? "A" : "C") + "M" +
132  std::to_string(ml) + "G" + std::to_string(gasGap);
133  auto newHisto = std::make_unique<TH2I>(histoName.c_str(),
134  "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
135  -5001., 5001.);
136  m_mmActiveAreas[MmReadoutElement::createHash(gasGap, active + 10 * ml)] = newHisto.get();
137  ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto)));
138  }
139  }
140  }
141  return StatusCode::SUCCESS;
142 }
143 
144 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
MuonGMR4::NswGeoPlottingAlg::m_detMgr
const MuonDetectorManager * m_detMgr
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:39
MuonGMR4::MmReadoutElement
Definition: MmReadoutElement.h:19
dumpTgcDigiDeadChambers.gasGap
list gasGap
Definition: dumpTgcDigiDeadChambers.py:33
MuonGMR4::StripDesign
Definition: StripDesign.h:30
MuonGMR4::MmReadoutElement::createHash
static IdentifierHash createHash(const int gasGap, const int strip)
MuonGMR4::NswGeoPlottingAlg::initMm
StatusCode initMm()
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:126
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
sTgcIdHelper::sTgcChannelTypes
sTgcChannelTypes
Definition: sTgcIdHelper.h:190
x
#define x
MuonGMR4::NswGeoPlottingAlg::initialize
StatusCode initialize() override
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:29
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
MuonGMR4::sTgcReadoutElement::createHash
static IdentifierHash createHash(const unsigned int gasGap, const unsigned int channelType, const unsigned int channel, const unsigned int wireInGrp=0)
Create a measurement hash from the Identifier fields.
MuonGMR4
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Definition: MdtCalibInput.h:20
Trk::active
@ active
Definition: Layer.h:48
MuonGMR4::NswGeoPlottingAlg::execute
StatusCode execute() override
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:38
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
NSWGeoPlottingAlg.h
MuonGMR4::NswGeoPlottingAlg::NswGeoPlottingAlg
NswGeoPlottingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:24
MuonDetectorManager.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonGMR4::NswGeoPlottingAlg::m_mmActiveAreas
std::map< IdentifierHash, TH1 * > m_mmActiveAreas
Map showing the active areas of the NSW to show the passivation.
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:43
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
MuonGMR4::NswGeoPlottingAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:34
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonGMR4::NswGeoPlottingAlg::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:37
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AthHistogramming::hash
hash_t hash(const std::string &histName) const
Method to calculate a 32-bit hash from a string.
Definition: AthHistogramming.h:428
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGMR4::sTgcReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/sTgcReadoutElement.h:20
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
MuonGMR4::NswGeoPlottingAlg::m_stgcActiveAreas
std::map< IdentifierHash, TH1 * > m_stgcActiveAreas
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:44
y
#define y
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
MuonGMR4::NswGeoPlottingAlg::initStgc
StatusCode initStgc()
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:105
MuonGMR4::NswGeoPlottingAlg::m_testActsSurf
Gaudi::Property< bool > m_testActsSurf
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:41
MmReadoutElement.h