39 {
40
41#ifndef NDEBUG
42 std::cout << "TileCellCont\t\t DEBUG \t constructor" << std::endl;
43#endif
44
45 ISvcLocator* svcLoc = Gaudi::svcLocator();
46
47 SmartIF<StoreGateSvc>
detStore{svcLoc->service(
"DetectorStore")};
48 if (!detStore) {
49 std::cout << "Could not locate DetectorStore" << std::endl;
50 return StatusCode::FAILURE;
51 }
52
53
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;
58 }
59
61 if (
detStore->retrieve(tileHWID,
"TileHWID").isFailure()) {
62 std::cout << "Could not get TileHWID helper !" << std::endl;
63 return StatusCode::FAILURE;
64 }
65
66
67 const TileDetDescrManager* tileMgr = nullptr;
68 if (
detStore->retrieve(tileMgr).isFailure()) {
69 std::cout << "Unable to retrieve TileDetDescrManager from DetectorStore" << std::endl;
70 return StatusCode::FAILURE;
71 }
72
73
74 const MbtsDetDescrManager* mbtsMgr = nullptr;
75 if (
detStore->retrieve(mbtsMgr).isFailure()) {
76 std::cout << "Warning: unable to retrieve MbtsDetDescrManager from DetectorStore" << std::endl;
77 mbtsMgr = 0;
78 }
79
81 std::cout << "TileCellCont::initialize ERROR : TileHid2RESrc has to be initialized before this" << std::endl;
82 return StatusCode::FAILURE;
83 }
84
85
87 int maxChannels =
cabling->getMaxChannels();
88
89
92 int mbts_count = 0;
93 int ID_of_Col = 0;
94 std::vector<int> rodids;
98 int frag = tileHWID->
frag(ros, drawer);
99 int rodid =
m_src->getRodID(frag);
100 rodids.push_back(rodid);
102
104
105
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;
112
114 HWIdentifier channelID = tileHWID->
channel_id(ros, drawer, channel);
115 Identifier cell_id =
cabling->h2s_cell_id_index(channelID, index, pmt);
116 if (index == -2) {
119 CaloDetDescrElement * caloDDE = (mbtsMgr) ? mbtsMgr->
get_element(cell_id) : NULL;
121 m_MBTS->push_back(myMBTSCell);
123 mbts_count++;
125 } else if (index >= 0) {
127 if (channel > 0 || ros != 2) {
130 }
131 }
132 }
133
134
135
136 TileCellCollection* newColl =
new TileCellCollection(frag,
SG::OWN_ELEMENTS);
137 this->push_back(newColl);
138
139
140
141 if (
tmp.size() > 0) {
144 cell_hash = -1;
145 for (
unsigned int i = 0;
i <
tmp.size(); ++
i) {
146 if (cell_hash != tmp[i].second) {
147 cell_hash =
tmp[
i].second;
149 CaloDetDescrElement * caloDDE = tileMgr->
get_cell_element((IdentifierHash) cell_hash);
152 }
154 }
155 }
156
157 if (drawer == 0 || ros == 3 || ros == 4) {
158#ifndef NDEBUG
159 int idxraw = 0;
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;
162 }
163#endif
164
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)
169 }
170
171 }
172 }
173#ifndef NDEBUG
174 std::cout <<
"Number of RODs is : " <<
m_mbts_rods.size() << std::endl;
176 std::cout <<
" MBTS RODs : " <<
m_mbts_rods[k] << std::endl;
177#endif
178 m_hash.initialize(0,rodids);
179
180#ifndef NDEBUG
181 for (
int i = 0;
i <
m_hash.max(); ++
i) {
182 TileCellCollection *
aa = this->at(i);
183 TileCell* bb =
aa->at(0);
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;
185
186 }
187#endif
188
189 return StatusCode::SUCCESS;
190}
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)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
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.
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
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.