9#include "CaloDetDescr/CaloDetDescrElement.h"
19#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/ToolHandle.h"
29 return left.second < right.second;
42 std::cout <<
"TileCellCont\t\t DEBUG \t constructor" << std::endl;
45 ISvcLocator* svcLoc = Gaudi::svcLocator();
47 SmartIF<StoreGateSvc> detStore{svcLoc->service(
"DetectorStore")};
49 std::cout <<
"Could not locate DetectorStore" << std::endl;
50 return StatusCode::FAILURE;
54 const TileID* tileID =
nullptr;
55 if (detStore->retrieve(tileID,
"TileID").isFailure()) {
56 std::cout <<
"Could not get TileID helper !" << std::endl;
57 return StatusCode::FAILURE;
61 if (detStore->retrieve(tileHWID,
"TileHWID").isFailure()) {
62 std::cout <<
"Could not get TileHWID helper !" << std::endl;
63 return StatusCode::FAILURE;
68 if (detStore->retrieve(tileMgr).isFailure()) {
69 std::cout <<
"Unable to retrieve TileDetDescrManager from DetectorStore" << std::endl;
70 return StatusCode::FAILURE;
75 if (detStore->retrieve(mbtsMgr).isFailure()) {
76 std::cout <<
"Warning: unable to retrieve MbtsDetDescrManager from DetectorStore" << std::endl;
81 std::cout <<
"TileCellCont::initialize ERROR : TileHid2RESrc has to be initialized before this" << std::endl;
82 return StatusCode::FAILURE;
87 int maxChannels = cabling->getMaxChannels();
94 std::vector<int> rodids;
98 int frag = tileHWID->
frag(ros, drawer);
99 int rodid =
m_src->getRodID(frag);
100 rodids.push_back(rodid);
106 int index, pmt, cell_hash;
107 std::vector<int> Rw2Pmt;
108 Rw2Pmt.resize(maxChannels, -1);
109 std::vector<int> Rw2Cell;
110 Rw2Cell.resize(maxChannels, -1);
111 std::vector<int_pair> tmp;
113 for (
int channel = 0; channel < maxChannels; ++channel) {
115 Identifier cell_id = cabling->h2s_cell_id_index(channelID,
index, pmt);
121 m_MBTS->push_back(myMBTSCell);
125 }
else if (
index >= 0) {
126 Rw2Pmt[channel] = pmt;
127 if (channel > 0 || ros != 2) {
129 tmp.push_back(
int_pair(channel, cell_hash));
137 this->push_back(newColl);
141 if (tmp.size() > 0) {
145 for (
unsigned int i = 0; i < tmp.size(); ++i) {
146 if (cell_hash != tmp[i].second) {
147 cell_hash = tmp[i].second;
153 Rw2Cell[tmp[i].first] =
index;
157 if (drawer == 0 || ros == 3 || ros == 4) {
160 for (std::vector<int>::iterator i = Rw2Cell.begin(); i != Rw2Cell.end(); ++i) {
161 if ((*i) != -1) std::cout <<
"Channel : " << idxraw++ <<
" connected to cell " << (*i) << std::endl;
165 for (std::vector<int>::iterator i = Rw2Cell.begin(); i != Rw2Cell.end(); ++i)
167 for (std::vector<int>::iterator i = Rw2Pmt.begin(); i != Rw2Pmt.end(); ++i)
174 std::cout <<
"Number of RODs is : " <<
m_mbts_rods.size() << std::endl;
175 for (
unsigned int k = 0; k <
m_mbts_rods.size(); k++)
176 std::cout <<
" MBTS RODs : " <<
m_mbts_rods[k] << std::endl;
178 m_hash.initialize(0,rodids);
181 for (
int i = 0; i <
m_hash.max(); ++i) {
184 std::cout <<
"TileCellCont\t\t DEBUG \t" << i <<
" " << std::hex <<
m_hash.identifier(i) << std::dec <<
" " << aa->identify() <<
" " << bb->
eta() <<
" " << bb->
phi() << std::endl;
189 return StatusCode::SUCCESS;
193const std::vector<TileCellCollection*>::const_iterator
195 return this->begin() + rodid;
201 for (
int i = 0; i < 4; i++)
203 for (
int i = 0; i < 4; i++)
207 for (
unsigned int i = 0; i < this->size(); i++) {
217 return StatusCode::SUCCESS;
222 unsigned int rodidx =
m_hash.identifier(rodid);
bool sort_pred(const int_pair &left, const int_pair &right)
std::pair< int, int > int_pair
virtual double phi() const override final
get phi (through CaloDetDescrElement)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
This class groups all DetDescr information related to a CaloCell.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
This is a "hash" representation of an Identifier.
CaloDetDescrElement * get_element(const Identifier &elementId) const
static const TileCablingService * getInstance()
get pointer to service instance
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
StatusCode initialize(void)
std::vector< unsigned int > m_mbts_IDs
const TileHid2RESrcID * m_src
map Hash ID to ROD
std::vector< int > m_Rw2Cell[4]
unsigned int find_rod(const unsigned int &id) const
unsigned int m_event
this event number
std::vector< unsigned int > m_mbts_rods
const std::vector< TileCellCollection * >::const_iterator find(const unsigned int &id) const
Finds a collection.
TileCellCollection * m_MBTS
std::vector< int > m_Rw2Pmt[4]
StatusCode finalize(void)
TileCellCont()
constructor
std::vector< unsigned int > m_eventNumber
eventNumber of a given Collection
std::map< unsigned int, unsigned int > m_mapMBTS
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
Helper class for TileCal online (hardware) identifiers.
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Helper class for TileCal offline identifiers.
IdentifierHash cell_hash(const Identifier &cell_id) const
fast conversion from ID to hash for cells
@ OWN_ELEMENTS
this data object owns its elements
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.