ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
RegionSelectionSvc Class Reference

#include <RegionSelectionSvc.h>

Inheritance diagram for RegionSelectionSvc:
Collaboration diagram for RegionSelectionSvc:

Public Member Functions

 RegionSelectionSvc (const std::string &name, ISvcLocator *svc_locator)
 contructor More...
 
virtual ~RegionSelectionSvc ()
 destructor More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 just some crazy atheta function More...
 
StatusCode initialize ()
 initialize More...
 
void Print (std::ostream &os) const
 debug print More...
 
bool isInRegion (const MuonCalib::MuonFixedId &id) const
 return true if id is in selected region More...
 
std::string GetRegionSelection () const
 get region selection More...
 
const std::vector< MuonCalib ::NtupleStationId > & GetStationsInRegions () const
 get stations/multilayers in region More...
 
int AddRegionNtuples (const std::string &infile, TChain *chain)
 add region ntuples which are relevant for this region to TChain More...
 
int AddRegionNtuples (const std::string &infile, TChain *chain, std::list< std::string > &dirnames)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Private Member Functions

void search_chambers_in_region ()
 
bool ProcessString (const std::string &input)
 process string More...
 
void print_list_of_selected_chambers () const
 print a list of selected chambers - debug function More...
 
void convert_to_tower (int station, int phi, int eta, std::vector< int > &tower) const
 convert station, eta, phi in tower vector More...
 

Private Attributes

Gaudi::Property< std::string > m_region_string {this, "Region", ""}
 region string - job option More...
 
Gaudi::Property< bool > m_print_list_of_selected_chambers {this, "PrintList", false}
 print list of selected chambers if set to true - job option More...
 
std::unique_ptr< MuonCalib ::RegionSelectorBase > m_master_region
 master region More...
 
std::vector< MuonCalib::NtupleStationIdm_stations_in_region
 chambers/mutlilayers in calibraition region More...
 
std::set< MuonCalib::NtupleStationIdm_unique_chambers
 
const MuonGM::MuonDetectorManagerm_detMgr {nullptr}
 
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 search for chambers and multilayers in selected region towers in selected region More...
 
ToolHandle< MuonCalib::IIdToFixedIdToolm_idToFixedIdTool {this, "IdToFixedIdTool", "MuonCalib::IdToFixedIdTool"}
 

Detailed Description

Seolect calibration region

Author
rausc.nosp@m.her@.nosp@m.cern..nosp@m.ch

Definition at line 35 of file RegionSelectionSvc.h.

Constructor & Destructor Documentation

◆ RegionSelectionSvc()

RegionSelectionSvc::RegionSelectionSvc ( const std::string &  name,
ISvcLocator *  svc_locator 
)

contructor

Definition at line 29 of file RegionSelectionSvc.cxx.

29 : AthService(name, svc_locator) {}

◆ ~RegionSelectionSvc()

RegionSelectionSvc::~RegionSelectionSvc ( )
virtualdefault

destructor

Member Function Documentation

◆ AddRegionNtuples() [1/2]

int RegionSelectionSvc::AddRegionNtuples ( const std::string &  infile,
TChain *  chain 
)

add region ntuples which are relevant for this region to TChain

Definition at line 67 of file RegionSelectionSvc.cxx.

67  {
68  std::list<std::string> dirnames;
69  return AddRegionNtuples(infile, chain, dirnames);
70 }

◆ AddRegionNtuples() [2/2]

int RegionSelectionSvc::AddRegionNtuples ( const std::string &  infile,
TChain *  chain,
std::list< std::string > &  dirnames 
)

Definition at line 71 of file RegionSelectionSvc.cxx.

71  {
72  int n_trees(0);
73  if (dirnames.empty()) {
74  // open file
75  std::unique_ptr<TFile> inf{TFile::Open(infile.c_str(), "READ")};
76  TIter nextkey(inf->GetListOfKeys());
77  TKey *key;
78  // take a list here because erase does not invalidate iterators
79  while ((key = (TKey *)nextkey())) { dirnames.push_back(key->GetName()); }
80  }
81  // loop over found ntuples and selected region
82  for (std::set<MuonCalib::NtupleStationId>::const_iterator it = m_unique_chambers.begin(); it != m_unique_chambers.end(); ++it)
83  for (std::list<std::string>::iterator nt_it = dirnames.begin(); nt_it != dirnames.end(); ++nt_it) {
84  // truncate region name
85  std::string regname(it->regionId(), 0, nt_it->size());
86  if (regname == (*nt_it)) {
87  chain->AddFile(infile.c_str(), TChain::kBigNumber, ((*nt_it) + "/" + "Segments").c_str());
88  std::list<std::string>::iterator new_it = nt_it;
89  --new_it;
90  dirnames.erase(nt_it);
91  nt_it = new_it;
92  ++n_trees;
93  }
94  }
95  return n_trees;
96 }

◆ convert_to_tower()

void RegionSelectionSvc::convert_to_tower ( int  station,
int  phi,
int  eta,
std::vector< int > &  tower 
) const
private

convert station, eta, phi in tower vector

◆ GetRegionSelection()

std::string RegionSelectionSvc::GetRegionSelection ( ) const

get region selection

Definition at line 65 of file RegionSelectionSvc.cxx.

65 { return m_region_string; }

◆ GetStationsInRegions()

const std::vector< MuonCalib::NtupleStationId > & RegionSelectionSvc::GetStationsInRegions ( ) const

get stations/multilayers in region

Definition at line 66 of file RegionSelectionSvc.cxx.

66 { return m_stations_in_region; }

◆ initialize()

StatusCode RegionSelectionSvc::initialize ( )

initialize

Definition at line 43 of file RegionSelectionSvc.cxx.

43  {
44  ATH_MSG_INFO("initialize RegionSelectionSvc");
45 
46  if (!ProcessString(m_region_string)) return StatusCode::FAILURE;
47 
48  // detector stre - id to fixed id ...
49  StoreGateSvc *detStore{nullptr};
50  ATH_CHECK(serviceLocator()->service("DetectorStore", detStore));
51  ATH_MSG_DEBUG("Retrieved DetectorStore");
52  ATH_CHECK(m_idHelperSvc.retrieve());
53  ATH_CHECK(detStore->retrieve(m_detMgr));
54  ATH_CHECK(m_idToFixedIdTool.retrieve());
55  ATH_MSG_INFO("Retrieved " << m_idToFixedIdTool);
56 
59 
60  return StatusCode::SUCCESS;
61 }

◆ interfaceID()

static const InterfaceID& RegionSelectionSvc::interfaceID ( )
inlinestatic

Definition at line 41 of file RegionSelectionSvc.h.

41  {
42  static const InterfaceID IID_IRegionSelectionSvc("RegionSelectionSvc", 1, 0);
43  return IID_IRegionSelectionSvc;
44  }

◆ isInRegion()

bool RegionSelectionSvc::isInRegion ( const MuonCalib::MuonFixedId id) const

return true if id is in selected region

Definition at line 63 of file RegionSelectionSvc.cxx.

63 { return m_master_region->Result(id); }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ Print()

void RegionSelectionSvc::Print ( std::ostream &  os) const

debug print

Definition at line 98 of file RegionSelectionSvc.cxx.

98  {
99  if (!m_master_region) {
100  os << "ERROR";
101  return;
102  }
103  m_master_region->Print(os);
104 }

◆ print_list_of_selected_chambers()

void RegionSelectionSvc::print_list_of_selected_chambers ( ) const
private

print a list of selected chambers - debug function

Definition at line 149 of file RegionSelectionSvc.cxx.

149  {
150  ATH_MSG_INFO("Selected regions: " << m_stations_in_region.size());
151  msg(MSG::INFO) << "Selected regions: ";
152  for (std::vector<MuonCalib::NtupleStationId>::const_iterator it = m_stations_in_region.begin(); it != m_stations_in_region.end();
153  ++it) {
154  msg(MSG::INFO) << " " << it->regionId();
155  }
156  msg(MSG::INFO) << endmsg;
157 }

◆ ProcessString()

bool RegionSelectionSvc::ProcessString ( const std::string &  input)
private

process string

Definition at line 144 of file RegionSelectionSvc.cxx.

144  {
145  m_master_region = RegionSelectorBase::GetRegion(input);
146  return (m_master_region != nullptr);
147 }

◆ queryInterface()

StatusCode RegionSelectionSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
)
virtual

just some crazy atheta function

Definition at line 31 of file RegionSelectionSvc.cxx.

31  {
32  ATH_MSG_VERBOSE("StatusCode RegionSelectionSvc::queryInterface");
33 
34  if (interfaceID().versionMatch(riid)) {
35  *ppvUnknown = (RegionSelectionSvc *)this;
36  } else {
37  return AthService::queryInterface(riid, ppvUnknown);
38  }
39 
40  return StatusCode::SUCCESS;
41 }

◆ search_chambers_in_region()

void RegionSelectionSvc::search_chambers_in_region ( )
private

Definition at line 106 of file RegionSelectionSvc.cxx.

106  {
107  MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin();
108  MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end();
109  for (; it != it_end; ++it) {
110  const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it, 1, 1, 1));
111  if (!detEl) continue;
112  // get number of mls;
113  int n_mls = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it);
114  // fixed id
115  MuonCalib::MuonFixedId fixed_id(m_idToFixedIdTool->idToFixedId(*it));
116  std::vector<MuonCalib::NtupleStationId> the_ids;
117  for (int i = 1; i <= n_mls; i++) {
118  fixed_id.setMdtMultilayer(i);
119  if (isInRegion(fixed_id)) {
120  NtupleStationId the_id(fixed_id);
121  the_ids.push_back(the_id);
122  }
123  }
124  // all multilayers are in the region - inser the whole station
125  if (static_cast<int>(the_ids.size()) == n_mls) {
126  NtupleStationId full_station(fixed_id);
127  full_station.SetMultilayer(0);
128  m_stations_in_region.push_back(full_station);
129  } else {
130  for (std::vector<MuonCalib::NtupleStationId>::iterator it2 = the_ids.begin(); it2 != the_ids.end(); ++it2) {
131  m_stations_in_region.push_back(*it2);
132  }
133  }
134  }
135  // create a set of chambers (not multilayers)
136  std::vector<int> tower(3);
138  MuonCalib::NtupleStationId station(*it2);
139  station.SetMultilayer(0);
140  m_unique_chambers.insert(station);
141  }
142 }

Member Data Documentation

◆ m_detMgr

const MuonGM::MuonDetectorManager* RegionSelectionSvc::m_detMgr {nullptr}
private

Definition at line 71 of file RegionSelectionSvc.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> RegionSelectionSvc::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

search for chambers and multilayers in selected region towers in selected region

Definition at line 73 of file RegionSelectionSvc.h.

◆ m_idToFixedIdTool

ToolHandle<MuonCalib::IIdToFixedIdTool> RegionSelectionSvc::m_idToFixedIdTool {this, "IdToFixedIdTool", "MuonCalib::IdToFixedIdTool"}
private

Definition at line 74 of file RegionSelectionSvc.h.

◆ m_master_region

std::unique_ptr<MuonCalib ::RegionSelectorBase> RegionSelectionSvc::m_master_region
private

master region

Definition at line 67 of file RegionSelectionSvc.h.

◆ m_print_list_of_selected_chambers

Gaudi::Property<bool> RegionSelectionSvc::m_print_list_of_selected_chambers {this, "PrintList", false}
private

print list of selected chambers if set to true - job option

Definition at line 65 of file RegionSelectionSvc.h.

◆ m_region_string

Gaudi::Property<std::string> RegionSelectionSvc::m_region_string {this, "Region", ""}
private

region string - job option

Definition at line 63 of file RegionSelectionSvc.h.

◆ m_stations_in_region

std::vector<MuonCalib::NtupleStationId> RegionSelectionSvc::m_stations_in_region
private

chambers/mutlilayers in calibraition region

Definition at line 69 of file RegionSelectionSvc.h.

◆ m_unique_chambers

std::set<MuonCalib::NtupleStationId> RegionSelectionSvc::m_unique_chambers
private

Definition at line 70 of file RegionSelectionSvc.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthService::AthService
AthService()
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
run.infile
string infile
Definition: run.py:13
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RegionSelectionSvc::m_region_string
Gaudi::Property< std::string > m_region_string
region string - job option
Definition: RegionSelectionSvc.h:63
MuonCalib::NtupleStationId
Definition: NtupleStationId.h:36
RegionSelectionSvc::m_idToFixedIdTool
ToolHandle< MuonCalib::IIdToFixedIdTool > m_idToFixedIdTool
Definition: RegionSelectionSvc.h:74
skel.it
it
Definition: skel.GENtoEVGEN.py:423
RegionSelectionSvc
Definition: RegionSelectionSvc.h:35
RegionSelectionSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: RegionSelectionSvc.h:41
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RegionSelectionSvc::m_detMgr
const MuonGM::MuonDetectorManager * m_detMgr
Definition: RegionSelectionSvc.h:71
RegionSelectionSvc::ProcessString
bool ProcessString(const std::string &input)
process string
Definition: RegionSelectionSvc.cxx:144
inf
TStreamerInfo * inf
Definition: liststreamerinfos.cxx:12
RegionSelectionSvc::m_stations_in_region
std::vector< MuonCalib::NtupleStationId > m_stations_in_region
chambers/mutlilayers in calibraition region
Definition: RegionSelectionSvc.h:69
RegionSelectionSvc::isInRegion
bool isInRegion(const MuonCalib::MuonFixedId &id) const
return true if id is in selected region
Definition: RegionSelectionSvc.cxx:63
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:204
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:50
lumiFormat.i
int i
Definition: lumiFormat.py:92
Atlas.StoreGateSvc
StoreGateSvc
Definition: Atlas.UnixStandardJob.py:25
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
RegionSelectionSvc::search_chambers_in_region
void search_chambers_in_region()
Definition: RegionSelectionSvc.cxx:106
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
RegionSelectionSvc::print_list_of_selected_chambers
void print_list_of_selected_chambers() const
print a list of selected chambers - debug function
Definition: RegionSelectionSvc.cxx:149
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MuonCalib::MuonFixedId
Definition: MuonFixedId.h:50
RegionSelectionSvc::m_print_list_of_selected_chambers
Gaudi::Property< bool > m_print_list_of_selected_chambers
print list of selected chambers if set to true - job option
Definition: RegionSelectionSvc.h:65
RegionSelectionSvc::m_unique_chambers
std::set< MuonCalib::NtupleStationId > m_unique_chambers
Definition: RegionSelectionSvc.h:70
RegionSelectionSvc::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
search for chambers and multilayers in selected region towers in selected region
Definition: RegionSelectionSvc.h:73
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
MuonIdHelper::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition: MuonIdHelper.h:143
RegionSelectionSvc::m_master_region
std::unique_ptr< MuonCalib ::RegionSelectorBase > m_master_region
master region
Definition: RegionSelectionSvc.h:67
RegionSelectionSvc::AddRegionNtuples
int AddRegionNtuples(const std::string &infile, TChain *chain)
add region ntuples which are relevant for this region to TChain
Definition: RegionSelectionSvc.cxx:67
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37