ATLAS Offline Software
NtupleStationId.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 #include "GaudiKernel/MsgStream.h"
9 #include "Identifier/IdContext.h"
13 
14 namespace MuonCalib {
15 
16  bool NtupleStationId::Initialize(const std::string& station, const int& eta, const int& phi, const int& ml, const int& author) {
18  if (station == "ANY") {
19  m_station = -1;
20  } else {
21  m_station = id.stationStringToFixedStationNumber(station);
22  if (m_station < 0) return false;
23  }
24  m_eta = eta;
25  m_phi = phi;
26  m_ml = ml;
27  m_author = author;
28  m_geom_ok = false;
29  return true;
30  }
31 
32  void NtupleStationId::SetStation(const std::string& station) {
34  m_station = id.stationStringToFixedStationNumber(station);
35  }
36 
38  MuonFixedId fid;
39  MsgStream log(Athena::getMessageSvc(), "NtupleStationId");
40  if (m_station == -1 || m_phi < 0 || m_eta == -99) {
41  log << MSG::WARNING << "NtupleStationId::InitializeGeometry: Cannot initialize geometry for multi station id" << endmsg;
42  m_geom_ok = false;
43  return false;
44  }
46  m_n_ml = mdtIdHelper.numberOfMultilayers(id);
47  // loop on multilayers
48  for (int i = 0; i < m_n_ml; i++) {
49  const MuonGM::MdtReadoutElement* detEl_ml = detMgr->getMdtReadoutElement(mdtIdHelper.channelID(id, 1 + i, 1, 1));
50  m_layer_min[i] = 1;
51  if (!detEl_ml) {
52  log << MSG::WARNING << regionId() << " ml " << i << "does not exist in current geometry" << endmsg;
53  return false;
54  }
55  m_layer_max[i] = detEl_ml->getNLayers();
56  m_n_layer[i] = m_layer_max[i] - m_layer_min[i] + 1;
57  m_tube_min[i] = 1;
58  m_tube_max[i] = detEl_ml->getNtubesperlayer();
59  m_n_tubes[i] = m_tube_max[i] - m_tube_min[i] + 1;
60  }
62  IdContext idCont = mdtIdHelper.module_context();
63  mdtIdHelper.get_hash(id, hash, &idCont);
64  m_region_hash = static_cast<int>(hash);
65  m_geom_ok = true;
66  return true;
67  }
68 
69  std::string NtupleStationId::regionId() const {
71  std::ostringstream id_stream;
72  if (m_station < 0) {
73  id_stream << "ANY";
74  } else {
75  id_stream << id.stationNumberToFixedStationString(m_station);
76  }
77  id_stream << "_";
78  if (m_phi >= 0) {
79  id_stream << m_phi;
80  } else {
81  id_stream << "ANY";
82  }
83  id_stream << "_";
84  if (m_eta != -99) {
85  id_stream << m_eta;
86  } else {
87  id_stream << "ANY";
88  }
89  if (m_ml > 0) { id_stream << "_" << m_ml; }
90  return id_stream.str();
91  }
92 
94  if (m_station < 0 || m_eta == -99 || m_phi < 0) return -1;
96  id.set_mdt();
97  if (!id.setStationName(m_station)) return -1;
98  if (!id.setStationEta(m_eta)) return -1;
99  if (!id.setStationPhi(m_phi)) return -1;
100  return id.mdtChamberId().getIdInt();
101  }
102 
103 } // namespace MuonCalib
MdtReadoutElement.h
MuonGM::MdtReadoutElement::getNLayers
int getNLayers() const
Returns the number of tube layers inside the multilayer.
MuonCalib::NtupleStationId::Initialize
void Initialize(const MuonFixedId &id)
initialize function
Definition: NtupleStationId.h:69
MdtIdHelper::numberOfMultilayers
int numberOfMultilayers(const Identifier &id) const
Definition: MdtIdHelper.cxx:496
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonCalib::NtupleStationId::InitializeGeometry
bool InitializeGeometry(const MdtIdHelper &mdtIdHelper, const MuonGM::MuonDetectorManager *detMgr)
initialize geometry information
Definition: NtupleStationId.cxx:37
MuonCalib::NtupleStationId::regionId
std::string regionId() const
return the region id string
Definition: NtupleStationId.cxx:69
MuonCalib::NtupleStationId::m_layer_min
int m_layer_min[2]
Definition: NtupleStationId.h:213
MuonCalib::NtupleStationId::m_layer_max
int m_layer_max[2]
Definition: NtupleStationId.h:213
MuonCalib::NtupleStationId::FixedId
int FixedId() const
Definition: NtupleStationId.cxx:93
MuonCalib::NtupleStationId::m_n_ml
int m_n_ml
Definition: NtupleStationId.h:212
MuonCalib::NtupleStationId::m_tube_min
int m_tube_min[2]
Definition: NtupleStationId.h:214
NtupleStationId.h
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::NtupleStationId::m_author
int m_author
Definition: NtupleStationId.h:210
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:204
IdContext.h
MuonCalib::NtupleStationId::m_eta
int m_eta
Definition: NtupleStationId.h:209
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
MuonCalib::NtupleStationId::m_region_hash
int m_region_hash
geo model information
Definition: NtupleStationId.h:212
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MdtIdHelper
Definition: MdtIdHelper.h:61
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MdtIdHelper.h
MuonCalib::MuonFixedId::stationNumberToFixedStationString
static std::string stationNumberToFixedStationString(const int station)
Definition: MuonFixedId.h:747
MuonCalib::NtupleStationId::m_n_tubes
int m_n_tubes[2]
Definition: NtupleStationId.h:212
MuonCalib::NtupleStationId::m_phi
int m_phi
Definition: NtupleStationId.h:209
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
MdtIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Definition: MdtIdHelper.cxx:659
MuonCalib::MuonFixedId
Definition: MuonFixedId.h:50
MuonDetectorManager.h
MdtIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: MdtIdHelper.cxx:630
MuonCalib::NtupleStationId::m_tube_max
int m_tube_max[2]
Definition: NtupleStationId.h:214
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MuonIdHelper::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const override
Create hash id from compact id (return == 0 for OK)
Definition: MuonIdHelper.cxx:144
MuonCalib::NtupleStationId::m_geom_ok
bool m_geom_ok
Definition: NtupleStationId.h:215
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonIdHelper::module_context
IdContext module_context() const
id for module
Definition: MuonIdHelper.cxx:731
MuonCalib::NtupleStationId::m_ml
int m_ml
Definition: NtupleStationId.h:209
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
MuonCalib::NtupleStationId::m_n_layer
int m_n_layer[2]
Definition: NtupleStationId.h:212
MuonGM::MdtReadoutElement::getNtubesperlayer
int getNtubesperlayer() const
Returns the number of tubes in each tube layer.
MuonCalib::NtupleStationId::m_station
int m_station
id
Definition: NtupleStationId.h:209
MuonCalib::NtupleStationId::SetStation
void SetStation(const std::string &station)
set station, eta or phi seperately
Definition: NtupleStationId.cxx:32
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14