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

This class builds the Tile cells. More...

#include <TileCellCont.h>

Inheritance diagram for TileCellCont:
Collaboration diagram for TileCellCont:

Public Types

typedef TileCellCollection IDENTIFIABLE

Public Member Functions

 TileCellCont ()
 constructor
const std::vector< TileCellCollection * >::const_iterator find (const unsigned int &id) const
 Finds a collection.
unsigned int find_rod (const unsigned int &id) const
virtual ~TileCellCont ()
 destructor
const std::vector< int > & Rw2CellMap (int section)
const TileCellCollectionMBTS_collection (void) const
TileCellCollectionMBTS_collection (void)
std::map< unsigned int, unsigned int > & MBTS_map (void)
const std::vector< unsigned int > * MBTS_RODs ()
const std::vector< unsigned int > * MBTS_IDs ()
int MBTS_channel (void)
StatusCode initialize (void)
StatusCode finalize (void)
void setHashIdToROD (const TileHid2RESrcID *p)
const TileHid2RESrcIDgetHashIdToROD () const
void eventNumber (const unsigned int eN)
unsigned int eventNumber () const
bool cached (const unsigned int &rodid)
const std::vector< int > & Rw2PmtMap (int section)

Public Attributes

elements
 STL member.

Private Attributes

TileRodIdHash m_hash
std::vector< int > m_Rw2Cell [4]
std::vector< int > m_Rw2Pmt [4]
std::vector< unsigned int > m_eventNumber
 eventNumber of a given Collection
unsigned int m_event
 this event number
std::vector< unsigned int > m_mbts_rods
std::vector< unsigned int > m_mbts_IDs
TileCellCollectionm_MBTS
std::map< unsigned int, unsigned int > m_mapMBTS
int m_MBTS_channel
const TileHid2RESrcIDm_src
 map Hash ID to ROD

Detailed Description

This class builds the Tile cells.

Author
Denis Oliveira Damazio
Alexander Solodkov

Definition at line 24 of file TileCellCont.h.

Member Typedef Documentation

◆ IDENTIFIABLE

Definition at line 29 of file TileCellCont.h.

Constructor & Destructor Documentation

◆ TileCellCont()

TileCellCont::TileCellCont ( )

constructor

Definition at line 32 of file TileCellCont.cxx.

33 : m_event(0)
34 , m_MBTS(0)
36 , m_src(0) {
37}
const TileHid2RESrcID * m_src
map Hash ID to ROD
unsigned int m_event
this event number
TileCellCollection * m_MBTS

◆ ~TileCellCont()

virtual TileCellCont::~TileCellCont ( )
inlinevirtual

destructor

Definition at line 39 of file TileCellCont.h.

39{ }

Member Function Documentation

◆ cached()

bool TileCellCont::cached ( const unsigned int & rodid)
inline

Definition at line 72 of file TileCellCont.h.

72 {
73 if ( m_eventNumber[rodid] != m_event ) { // Decoding a new event
74 // Keep track of last decoded number
75 m_eventNumber[rodid] = m_event;
76 return false;
77 } else return true;
78 }
std::vector< unsigned int > m_eventNumber
eventNumber of a given Collection

◆ eventNumber() [1/2]

unsigned int TileCellCont::eventNumber ( ) const
inline

Definition at line 71 of file TileCellCont.h.

71{ return m_event; } ;

◆ eventNumber() [2/2]

void TileCellCont::eventNumber ( const unsigned int eN)
inline

Definition at line 70 of file TileCellCont.h.

70{ m_event=eN; };

◆ finalize()

StatusCode TileCellCont::finalize ( void )

Definition at line 198 of file TileCellCont.cxx.

198 {
199
200 // Delete m_RwCells
201 for (int i = 0; i < 4; i++)
202 m_Rw2Cell[i].clear();
203 for (int i = 0; i < 4; i++)
204 m_Rw2Pmt[i].clear();
205
206 // Delete Collections and cells
207 for (unsigned int i = 0; i < this->size(); i++) {
208 // Delete collections. Own cells -> also destroyed
209 delete ((TileCellCollection*) ((*this)[i]));
210 }
211 // Destroy also MBTS collection
212 delete m_MBTS;
213 m_mapMBTS.clear();
214 m_mbts_rods.clear();
215 m_mbts_IDs.clear();
216 this->clear();
217 return StatusCode::SUCCESS;
218
219}
std::vector< unsigned int > m_mbts_IDs
std::vector< int > m_Rw2Cell[4]
std::vector< unsigned int > m_mbts_rods
std::vector< int > m_Rw2Pmt[4]
std::map< unsigned int, unsigned int > m_mapMBTS

◆ find()

const std::vector< TileCellCollection * >::const_iterator TileCellCont::find ( const unsigned int & id) const

Finds a collection.

Definition at line 194 of file TileCellCont.cxx.

194 {
195 return this->begin() + rodid;
196}

◆ find_rod()

unsigned int TileCellCont::find_rod ( const unsigned int & id) const

Definition at line 221 of file TileCellCont.cxx.

221 {
222 unsigned int rodidx = m_hash.identifier(rodid);
223 return rodidx;
224}
TileRodIdHash m_hash

◆ getHashIdToROD()

const TileHid2RESrcID * TileCellCont::getHashIdToROD ( ) const
inline

Definition at line 67 of file TileCellCont.h.

68 { return m_src; }

◆ initialize()

StatusCode TileCellCont::initialize ( void )

Definition at line 39 of file TileCellCont.cxx.

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 // Get the TileID helper from the detector store
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 // Get the TileHWID helper from the detector store
60 const TileHWID* tileHWID = nullptr;
61 if (detStore->retrieve(tileHWID, "TileHWID").isFailure()) {
62 std::cout << "Could not get TileHWID helper !" << std::endl;
63 return StatusCode::FAILURE;
64 }
65
66 // Get pointer to TileDetDescrManager
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 // Get pointer to MbtsDetDescrManager
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
80 if ( !m_src ){ // if nothing set, use 2017
81 std::cout << "TileCellCont::initialize ERROR : TileHid2RESrc has to be initialized before this" << std::endl;
82 return StatusCode::FAILURE;
83 }
84
85 // Get pointer to TileCablingService
86 const TileCablingService* cabling = TileCablingService::getInstance();
87 int maxChannels = cabling->getMaxChannels();
88
89 //m_hash.initialize(0);
90 m_mbts_rods.clear();
91 m_mbts_IDs.clear();
92 int mbts_count = 0;
93 int ID_of_Col = 0;
94 std::vector<int> rodids;
95 m_MBTS = new TileCellCollection(ID_of_Col, SG::OWN_ELEMENTS);
96 for (unsigned int ros = 1; ros < TileCalibUtils::MAX_ROS; ++ros) {
97 for (unsigned int drawer = 0; drawer < TileCalibUtils::MAX_DRAWER; ++drawer) {
98 int frag = tileHWID->frag(ros, drawer);
99 int rodid = m_src->getRodID(frag);
100 rodids.push_back(rodid);
101 m_mapMBTS[frag] = 0xFFFF;
102 // One event number per collection
103 m_eventNumber.push_back(0xFFFFFFFF);
104
105 // Tries to find the TileRawChannel -> TileCell correpondence
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;
112
113 for (int channel = 0; channel < maxChannels; ++channel) {
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) { // MBTS cell, only one per drawer
117 m_mbts_rods.push_back(m_src->getRodID(frag));
118 m_mbts_IDs.push_back(((ros - 1) * TileCalibUtils::MAX_DRAWER + drawer));
119 CaloDetDescrElement * caloDDE = (mbtsMgr) ? mbtsMgr->get_element(cell_id) : NULL;
120 TileCell* myMBTSCell = new TileCell(caloDDE, cell_id, 0.0, 0.0, 0, 0, CaloGain::TILEONELOW);
121 m_MBTS->push_back(myMBTSCell);
122 m_mapMBTS[frag] = mbts_count;
123 mbts_count++;
125 } else if (index >= 0) { // normal cell
126 Rw2Pmt[channel] = pmt;
127 if (channel > 0 || ros != 2) { // ignoring D0 (first channel) in negative barrel
128 cell_hash = tileID->cell_hash(cell_id);
129 tmp.push_back(int_pair(channel, cell_hash));
130 }
131 }
132 } // End of for over TileRawChannel
133
134
135 // create new cell collection which will own all elements
136 TileCellCollection* newColl = new TileCellCollection(frag, SG::OWN_ELEMENTS);
137 this->push_back(newColl);
138
139 // sort index according to cell hash and put it in Rw2Cell vector
140 // create TileCells in appropriate order and put them in newColl
141 if (tmp.size() > 0) {
142 std::sort(tmp.begin(), tmp.end(), sort_pred); // sort according to cell hash index
143 index = -1;
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;
148 ++index;
149 CaloDetDescrElement * caloDDE = tileMgr->get_cell_element((IdentifierHash) cell_hash);
150 TileCell * pCell = new TileCell(caloDDE, 0.0, 0.0, 0, 0, CaloGain::TILELOWLOW);
151 newColl->push_back(pCell);
152 }
153 Rw2Cell[tmp[i].first] = index;
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 // One needs to keep track of Rw2Cell
165 for (std::vector<int>::iterator i = Rw2Cell.begin(); i != Rw2Cell.end(); ++i)
166 m_Rw2Cell[ros - 1].push_back(*i);
167 for (std::vector<int>::iterator i = Rw2Pmt.begin(); i != Rw2Pmt.end(); ++i)
168 m_Rw2Pmt[ros - 1].push_back(*i);
169 } // End of if first drawer of Barrel or Ext
170
171 } // end of drawer for
172 } // end of ros for
173#ifndef NDEBUG
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;
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 // A collection per ROD/ROB/HashId
186 } // end of for id
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)
Definition CaloCell.h:375
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
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
Definition TileHWID.h:181
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Definition TileHWID.cxx:199
IdentifierHash cell_hash(const Identifier &cell_id) const
fast conversion from ID to hash for cells
@ TILELOWLOW
Definition CaloGain.h:12
@ TILEONELOW
Definition CaloGain.h:16
str index
Definition DeMoScan.py:362
@ 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.

◆ MBTS_channel()

int TileCellCont::MBTS_channel ( void )
inline

Definition at line 60 of file TileCellCont.h.

60{ return m_MBTS_channel; }

◆ MBTS_collection() [1/2]

TileCellCollection * TileCellCont::MBTS_collection ( void )
inline

Definition at line 52 of file TileCellCont.h.

53 { return m_MBTS; }

◆ MBTS_collection() [2/2]

const TileCellCollection * TileCellCont::MBTS_collection ( void ) const
inline

Definition at line 50 of file TileCellCont.h.

51 { return m_MBTS; }

◆ MBTS_IDs()

const std::vector< unsigned int > * TileCellCont::MBTS_IDs ( )
inline

Definition at line 58 of file TileCellCont.h.

59 { return &m_mbts_IDs; }

◆ MBTS_map()

std::map< unsigned int, unsigned int > & TileCellCont::MBTS_map ( void )
inline

Definition at line 54 of file TileCellCont.h.

55 { return m_mapMBTS; }

◆ MBTS_RODs()

const std::vector< unsigned int > * TileCellCont::MBTS_RODs ( )
inline

Definition at line 56 of file TileCellCont.h.

57 { return &m_mbts_rods; }

◆ Rw2CellMap()

const std::vector< int > & TileCellCont::Rw2CellMap ( int section)
inline
  • section = 0 for barrel positive
  • section = 1 for barrel negative
  • section = 2 for extended barrel positive
  • section = 3 for extended barrel negative

Definition at line 47 of file TileCellCont.h.

47 {
48 return m_Rw2Cell[section];
49 }
void section(const std::string &sec)

◆ Rw2PmtMap()

const std::vector< int > & TileCellCont::Rw2PmtMap ( int section)
inline

Definition at line 79 of file TileCellCont.h.

79 {
80 return m_Rw2Pmt[section];
81 }

◆ setHashIdToROD()

void TileCellCont::setHashIdToROD ( const TileHid2RESrcID * p)
inline

Definition at line 64 of file TileCellCont.h.

Member Data Documentation

◆ elements

T std::vector< T >::elements
inherited

STL member.

◆ m_event

unsigned int TileCellCont::m_event
private

this event number

Definition at line 93 of file TileCellCont.h.

◆ m_eventNumber

std::vector<unsigned int> TileCellCont::m_eventNumber
private

eventNumber of a given Collection

Definition at line 91 of file TileCellCont.h.

◆ m_hash

TileRodIdHash TileCellCont::m_hash
private

Definition at line 85 of file TileCellCont.h.

◆ m_mapMBTS

std::map<unsigned int, unsigned int> TileCellCont::m_mapMBTS
private

Definition at line 98 of file TileCellCont.h.

◆ m_MBTS

TileCellCollection* TileCellCont::m_MBTS
private

Definition at line 97 of file TileCellCont.h.

◆ m_MBTS_channel

int TileCellCont::m_MBTS_channel
private

Definition at line 99 of file TileCellCont.h.

◆ m_mbts_IDs

std::vector<unsigned int> TileCellCont::m_mbts_IDs
private

Definition at line 96 of file TileCellCont.h.

◆ m_mbts_rods

std::vector<unsigned int> TileCellCont::m_mbts_rods
private

Definition at line 95 of file TileCellCont.h.

◆ m_Rw2Cell

std::vector<int> TileCellCont::m_Rw2Cell[4]
private

Definition at line 87 of file TileCellCont.h.

◆ m_Rw2Pmt

std::vector<int> TileCellCont::m_Rw2Pmt[4]
private

Definition at line 89 of file TileCellCont.h.

◆ m_src

const TileHid2RESrcID* TileCellCont::m_src
private

map Hash ID to ROD

Definition at line 101 of file TileCellCont.h.


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