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 
19 
20 
21 namespace MuonGMR4 {
23  ISvcLocator* pSvcLocator)
24  : AthHistogramAlgorithm(name, pSvcLocator) {}
25 
26 
29  ATH_CHECK(m_idHelperSvc.retrieve());
31  ATH_MSG_INFO("Check Acts surface "<<m_testActsSurf);
32  ATH_CHECK(initMm());
34  return StatusCode::SUCCESS;
35 }
37  const EventContext& ctx = Gaudi::Hive::currentContext();
39  ATH_CHECK(gctxHandle.isPresent());
40 
41  std::vector<const MmReadoutElement*> micromegas = m_detMgr->getAllMmReadoutElements();
42  for (const MmReadoutElement* mm : micromegas) {
43  for (int gasGap = 1; gasGap <= 4; ++ gasGap) {
44  const IdentifierHash hash = MmReadoutElement::createHash(gasGap, (mm->stationEta() > 0 ? 1 : 2) +
45  10 * mm->multilayer());
46  auto histo = m_mmActiveAreas[hash];
47  const StripDesign& design{mm->stripLayer(hash).design()};
48  const Acts::Surface& plane{mm->surface(mm->layerHash(hash))};
49  const double halfY = 2.*design.longHalfHeight();
50  const double halfX = 2.*design.halfWidth();
51  for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){
52  for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) {
53  const Amg::Vector3D locPos{x,y,0};
54  if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) {
55  continue;
56  } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) {
57  continue;
58  }
59 
60  const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos;
61  histo->Fill(globPos.x(), globPos.y());
62  }
63  }
64  }
65  }
66 
67  std::vector<const sTgcReadoutElement*> sTgcs = m_detMgr->getAllsTgcReadoutElements();
68  for (const sTgcReadoutElement* sTgc : sTgcs) {
69  for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){
70  for (int gasGap = 1; gasGap <= 4; ++ gasGap) {
71  const IdentifierHash hash = sTgcReadoutElement::createHash(gasGap, chanType, (sTgc->stationEta() > 0 ? 1 : 2) +
72  10 * sTgc->multilayer());
74 
75  const StripDesign& design{ chanType == chType::Strip? sTgc->stripDesign(hash) :
76  chanType == chType::Wire ? static_cast<const StripDesign&>(sTgc->wireDesign(hash))
77  : static_cast<const StripDesign&>(sTgc->padDesign(hash))};
78  const Acts::Surface& plane{sTgc->surface(sTgc->layerHash(hash))};
79  const double halfY = 2.*design.longHalfHeight();
80  const double halfX = 2.*design.halfWidth();
81  for (double x = -halfX; x <= halfX; x+= 1.*Gaudi::Units::mm){
82  for (double y = -halfY; y<= halfY; y+=1.*Gaudi::Units::mm) {
83  const Amg::Vector3D locPos{x,y,0};
84  if (!m_testActsSurf && !design.insideTrapezoid(locPos.block<2,1>(0,0))) {
85  continue;
86  } else if (m_testActsSurf && !plane.insideBounds(locPos.block<2,1>(0,0))) {
87  continue;
88  }
89 
90  const Amg::Vector3D globPos = plane.transform(gctxHandle->context()) * locPos;
91  histo->Fill(globPos.x(), globPos.y());
92  }
93  }
94  }
95  }
96  }
97 
98 
99 
100 
101  return StatusCode::SUCCESS;
102 }
104  for (unsigned int ml =1 ; ml <= 2; ++ml) {
105  for(unsigned int active =1 ; active <= 2; ++active){
106  for (int chanType : {chType::Strip, chType::Pad, chType::Wire}){
107  for (unsigned int gasGap =1; gasGap <= 4; ++gasGap) {
108  std::string histoName = "STGC_"+std::string(active == 1? "A" : "C") + "M" +
109  std::to_string(ml) + "G" + std::to_string(gasGap) +
110  + (chanType == chType::Strip? "S" :
111  chanType == chType::Wire ? "W" : "P");
112 
113  auto newHisto = std::make_unique<TH2I>(histoName.c_str(),
114  "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
115  -5001., 5001.);
116  m_stgcActiveAreas[sTgcReadoutElement::createHash(gasGap, chanType, active + 10 * ml)] = newHisto.get();
117  ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto)));
118  }
119  }
120  }
121  }
122  return StatusCode::SUCCESS;
123 }
125 
126  for (unsigned int ml = 1; ml <= 2; ++ml) {
127  for (unsigned int active = 1; active <= 2; ++ active) {
128  for (unsigned int gasGap = 1; gasGap <= 4; ++gasGap) {
129  std::string histoName = "MM_"+std::string(active == 1? "A" : "C") + "M" +
130  std::to_string(ml) + "G" + std::to_string(gasGap);
131  auto newHisto = std::make_unique<TH2I>(histoName.c_str(),
132  "ActiveNSW;x [mm]; y [mm]", 1000, -5001, 5001., 1000,
133  -5001., 5001.);
134  m_mmActiveAreas[MmReadoutElement::createHash(gasGap, active + 10 * ml)] = newHisto.get();
135  ATH_CHECK(histSvc()->regHist("/GEOMODELTESTER/ActiveSurfaces/"+ histoName,std::move(newHisto)));
136  }
137  }
138  }
139  return StatusCode::SUCCESS;
140 }
141 
142 }
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:18
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:124
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:27
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
A muon chamber is a collection of readout elements belonging to the same station.
Definition: ChamberAssembleTool.h:16
Trk::active
@ active
Definition: Layer.h:48
MuonGMR4::NswGeoPlottingAlg::execute
StatusCode execute() override
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:36
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:22
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:192
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:19
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
Definition: IdentifierHash.h:38
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
MuonGMR4::NswGeoPlottingAlg::initStgc
StatusCode initStgc()
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.cxx:103
MuonGMR4::NswGeoPlottingAlg::m_testActsSurf
Gaudi::Property< bool > m_testActsSurf
Definition: MuonPhaseII/MuonDetDescr/MuonGeoModelTestR4/src/NSWGeoPlottingAlg.h:41
MmReadoutElement.h