ATLAS Offline Software
Loading...
Searching...
No Matches
RegionSelectionSvc Class Reference

Seolect calibration region. More...

#include <RegionSelectionSvc.h>

Inheritance diagram for RegionSelectionSvc:
Collaboration diagram for RegionSelectionSvc:

Public Member Functions

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

Private Member Functions

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

Private Attributes

Gaudi::Property< std::string > m_region_string {this, "Region", ""}
 region string - job option
Gaudi::Property< bool > m_print_list_of_selected_chambers {this, "PrintList", false}
 print list of selected chambers if set to true - job option
std::unique_ptr< MuonCalib ::RegionSelectorBase > m_master_region
 master region
std::vector< MuonCalib::NtupleStationIdm_stations_in_region
 chambers/mutlilayers in calibraition region
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
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 55 of file RegionSelectionSvc.cxx.

55 {
56 std::list<std::string> dirnames;
57 return AddRegionNtuples(infile, chain, dirnames);
58}
int AddRegionNtuples(const std::string &infile, TChain *chain)
add region ntuples which are relevant for this region to TChain

◆ AddRegionNtuples() [2/2]

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

Definition at line 59 of file RegionSelectionSvc.cxx.

59 {
60 int n_trees(0);
61 if (dirnames.empty()) {
62 // open file
63 std::unique_ptr<TFile> inf{TFile::Open(infile.c_str(), "READ")};
64 TIter nextkey(inf->GetListOfKeys());
65 TKey *key;
66 // take a list here because erase does not invalidate iterators
67 while ((key = (TKey *)nextkey())) { dirnames.push_back(key->GetName()); }
68 }
69 // loop over found ntuples and selected region
70 for (std::set<MuonCalib::NtupleStationId>::const_iterator it = m_unique_chambers.begin(); it != m_unique_chambers.end(); ++it)
71 for (std::list<std::string>::iterator nt_it = dirnames.begin(); nt_it != dirnames.end(); ++nt_it) {
72 // truncate region name
73 std::string regname(it->regionId(), 0, nt_it->size());
74 if (regname == (*nt_it)) {
75 chain->AddFile(infile.c_str(), TChain::kBigNumber, ((*nt_it) + "/" + "Segments").c_str());
76 std::list<std::string>::iterator new_it = nt_it;
77 --new_it;
78 dirnames.erase(nt_it);
79 nt_it = new_it;
80 ++n_trees;
81 }
82 }
83 return n_trees;
84}
std::set< MuonCalib::NtupleStationId > m_unique_chambers
TStreamerInfo * inf
str infile
Definition run.py:13

◆ 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()

const std::string & RegionSelectionSvc::GetRegionSelection ( ) const

get region selection

Definition at line 53 of file RegionSelectionSvc.cxx.

53{ return m_region_string; }
Gaudi::Property< std::string > m_region_string
region string - job option

◆ GetStationsInRegions()

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

get stations/multilayers in region

Definition at line 54 of file RegionSelectionSvc.cxx.

54{ return m_stations_in_region; }
std::vector< MuonCalib::NtupleStationId > m_stations_in_region
chambers/mutlilayers in calibraition region

◆ initialize()

StatusCode RegionSelectionSvc::initialize ( )
overridevirtual

initialize

Definition at line 31 of file RegionSelectionSvc.cxx.

31 {
32 ATH_MSG_INFO("initialize RegionSelectionSvc");
33
34 if (!ProcessString(m_region_string)) return StatusCode::FAILURE;
35
36 // detector stre - id to fixed id ...
37 SmartIF<StoreGateSvc> detStore{service("DetectorStore")};
38 ATH_CHECK(detStore.isValid());
39 ATH_MSG_DEBUG("Retrieved DetectorStore");
40 ATH_CHECK(m_idHelperSvc.retrieve());
41 ATH_CHECK(detStore->retrieve(m_detMgr));
42 ATH_CHECK(m_idToFixedIdTool.retrieve());
43 ATH_MSG_INFO("Retrieved " << m_idToFixedIdTool);
44
47
48 return StatusCode::SUCCESS;
49}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
void print_list_of_selected_chambers() const
print a list of selected chambers - debug function
ToolHandle< MuonCalib::IIdToFixedIdTool > m_idToFixedIdTool
Gaudi::Property< bool > m_print_list_of_selected_chambers
print list of selected chambers if set to true - job option
const MuonGM::MuonDetectorManager * m_detMgr
bool ProcessString(const std::string &input)
process string
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
search for chambers and multilayers in selected region towers in selected region

◆ isInRegion()

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

return true if id is in selected region

Definition at line 51 of file RegionSelectionSvc.cxx.

51{ return m_master_region->Result(id); }
std::unique_ptr< MuonCalib ::RegionSelectorBase > m_master_region
master region

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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 86 of file RegionSelectionSvc.cxx.

86 {
87 if (!m_master_region) {
88 os << "ERROR";
89 return;
90 }
91 m_master_region->Print(os);
92}

◆ 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 137 of file RegionSelectionSvc.cxx.

137 {
138 ATH_MSG_INFO("Selected regions: " << m_stations_in_region.size());
139 msg(MSG::INFO) << "Selected regions: ";
140 for (std::vector<MuonCalib::NtupleStationId>::const_iterator it = m_stations_in_region.begin(); it != m_stations_in_region.end();
141 ++it) {
142 msg(MSG::INFO) << " " << it->regionId();
143 }
144 msg(MSG::INFO) << endmsg;
145}
#define endmsg
MsgStream & msg() const

◆ ProcessString()

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

process string

Definition at line 132 of file RegionSelectionSvc.cxx.

132 {
134 return (m_master_region != nullptr);
135}
static std::unique_ptr< RegionSelectorBase > GetRegion(const std::string &input)
create a region from a string

◆ search_chambers_in_region()

void RegionSelectionSvc::search_chambers_in_region ( )
private

Definition at line 94 of file RegionSelectionSvc.cxx.

94 {
95 MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin();
96 MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end();
97 for (; it != it_end; ++it) {
98 const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it, 1, 1, 1));
99 if (!detEl) continue;
100 // get number of mls;
101 int n_mls = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it);
102 // fixed id
103 MuonCalib::MuonFixedId fixed_id(m_idToFixedIdTool->idToFixedId(*it));
104 std::vector<MuonCalib::NtupleStationId> the_ids;
105 for (int i = 1; i <= n_mls; i++) {
106 fixed_id.setMdtMultilayer(i);
107 if (isInRegion(fixed_id)) {
108 NtupleStationId the_id(fixed_id);
109 the_ids.push_back(the_id);
110 }
111 }
112 // all multilayers are in the region - inser the whole station
113 if (static_cast<int>(the_ids.size()) == n_mls) {
114 NtupleStationId full_station(fixed_id);
115 full_station.SetMultilayer(0);
116 m_stations_in_region.push_back(full_station);
117 } else {
118 for (std::vector<MuonCalib::NtupleStationId>::iterator it2 = the_ids.begin(); it2 != the_ids.end(); ++it2) {
119 m_stations_in_region.push_back(*it2);
120 }
121 }
122 }
123 // create a set of chambers (not multilayers)
124 std::vector<int> tower(3);
125 for (std::vector<MuonCalib::NtupleStationId>::iterator it2 = m_stations_in_region.begin(); it2 != m_stations_in_region.end(); ++it2) {
126 MuonCalib::NtupleStationId station(*it2);
127 station.SetMultilayer(0);
128 m_unique_chambers.insert(station);
129 }
130}
std::vector< Identifier >::const_iterator const_id_iterator
bool isInRegion(const MuonCalib::MuonFixedId &id) const
return true if id is in selected region

Member Data Documentation

◆ m_detMgr

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

Definition at line 65 of file RegionSelectionSvc.h.

65{nullptr};

◆ 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 67 of file RegionSelectionSvc.h.

67{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_idToFixedIdTool

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

Definition at line 68 of file RegionSelectionSvc.h.

68{this, "IdToFixedIdTool", "MuonCalib::IdToFixedIdTool"};

◆ m_master_region

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

master region

Definition at line 61 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 59 of file RegionSelectionSvc.h.

59{this, "PrintList", false};

◆ m_region_string

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

region string - job option

Definition at line 57 of file RegionSelectionSvc.h.

57{this, "Region", ""};

◆ m_stations_in_region

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

chambers/mutlilayers in calibraition region

Definition at line 63 of file RegionSelectionSvc.h.

◆ m_unique_chambers

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

Definition at line 64 of file RegionSelectionSvc.h.


The documentation for this class was generated from the following files: