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

Class which contains statically allocated LArCellCollections. More...

#include <LArCellCont.h>

Inheritance diagram for LArCellCont:

Public Types

typedef LArCellCollection IDENTIFIABLE
 Identifiable definition to be compatible with LArCellIDC.

Public Member Functions

 LArCellCont ()
 Constructor.
const std::vector< LArCellCollection * >::const_iterator find (const HWIdentifier &id) const
 Finds a collection by its LArReadoutModuleID.
const std::vector< LArCellCollection * >::const_iterator find (const unsigned int &id)
 Finds a collection by its ROD ID.
HWIdentifier findsec (const unsigned int &id) const
 Each Collection contains data from 2 FEBs.
void applyBCIDCorrection (const unsigned int &rodid)
 method to apply correction based on the luminosity to the energy
virtual ~LArCellCont ()
 destructor
StatusCode initialize (const LArRoIMap &roiMap, const LArOnOffIdMapping &onOffMap, const LArMCSym &mcsym, const LArFebRodMapping &febrod, const LArBadChannelCont &badchannel, const CaloDetDescrManager &ddm)
 initialize method.
StatusCode finalize (void)
 finalize method.
void eventNumber (const unsigned int eN)
 sets Event Number
void lumiBlock_BCID (const unsigned int lumi_block, const unsigned int BCID)
 sets LumiBlock and BCID
const std::vector< uint32_t > & MissingROBs (void)
 List of Missing ROBs.
bool lumiBCIDCheck (const EventContext &context)
void updateBCID (const CaloBCIDAverage &, const LArOnOffIdMapping &)
 update BCID dependent correction table for MT case

Public Attributes

elements
 STL member.

Private Attributes

LArRodIdHash m_hash
 Hash ID Identifier mapping to collection index.
Hid2RESrcID m_conv
 Hardware to Source ID conversion.
std::vector< HWIdentifierm_second
 FEB Hardware Identifier for second FEBs in a Collection.
std::vector< unsigned int > m_eventNumber
 eventNumber of a given Collection
unsigned int m_event
 this event number
std::vector< DataVector< LArCell > * > m_vecs
 One needs to destroy the TT vectors.
const ILArBadFebMaskerm_badFebMasker = nullptr
 A tool to help mask cells.
std::vector< uint32_t > m_MissingROBs
 List of Missing ROBs to be disabled at the RS.
std::vector< std::vector< int > > m_hashSym
 hash references to BCID
std::vector< float > m_corrBCID
 corrections for a given BCID
std::map< HWIdentifier, int > m_indexset
 index table
float m_lumi_block
 current lumi_block
unsigned int m_bcid
EventIDBase::event_number_t m_bcidEvt
bool m_BCIDcache
 flag to only update cache when trying to apply corrections

Detailed Description

Class which contains statically allocated LArCellCollections.

Definition at line 41 of file LArCellCont.h.

Member Typedef Documentation

◆ IDENTIFIABLE

Identifiable definition to be compatible with LArCellIDC.

Definition at line 47 of file LArCellCont.h.

Constructor & Destructor Documentation

◆ LArCellCont()

LArCellCont::LArCellCont ( )

Constructor.

Does not do anything. Check initialize.

Definition at line 18 of file LArCellCont.cxx.

18 : m_event(0), m_lumi_block(0), m_bcid(5000), m_bcidEvt(5000), m_BCIDcache(false)
19{}
unsigned int m_bcid
bool m_BCIDcache
flag to only update cache when trying to apply corrections
float m_lumi_block
current lumi_block
EventIDBase::event_number_t m_bcidEvt
unsigned int m_event
this event number

◆ ~LArCellCont()

virtual LArCellCont::~LArCellCont ( )
inlinevirtual

destructor

Definition at line 74 of file LArCellCont.h.

74{ };

Member Function Documentation

◆ applyBCIDCorrection()

void LArCellCont::applyBCIDCorrection ( const unsigned int & rodid)

method to apply correction based on the luminosity to the energy

Definition at line 222 of file LArCellCont.cxx.

222 {
223 int idx = m_hash(rodid);
224 std::vector<LArCellCollection*>::const_iterator it = (std::vector<LArCellCollection*>::const_iterator)((*this).begin()+idx);
225 LArCellCollection* col = (*it);
226 unsigned int itsize = col->size();
227 std::vector<int>& hashTab = m_hashSym[idx];
228 for(unsigned int i=0; i< itsize; ++i){
229 float cor = m_corrBCID[ hashTab[i] ];
230 LArCell* cell = col->operator[](i);
231#ifdef TRIGLARCELLDEBUG
232 std::cout << "LArCellId= " << cell->ID() << " Ecorr= " << cor << " MeV " << std::endl;
233#endif
234 float cellenergy = cell->energy();
235 cell->setEnergyFast( cellenergy - cor );
236 }
237 return;
238}
size_type size() const noexcept
Returns the number of elements in the collection.
std::vector< std::vector< int > > m_hashSym
hash references to BCID
std::vector< float > m_corrBCID
corrections for a given BCID
LArRodIdHash m_hash
Hash ID Identifier mapping to collection index.

◆ eventNumber()

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

sets Event Number

Definition at line 85 of file LArCellCont.h.

85{ m_event=eN; };

◆ finalize()

StatusCode LArCellCont::finalize ( void )

finalize method.

Destroys all cells and collections.

Definition at line 183 of file LArCellCont.cxx.

183 {
184int number_of_col = m_hash.max();
185for(int i=0;i<number_of_col;i++){
186 int number_of_cell = ((*this)[i])->size();
187 for(int j=0;j<number_of_cell;j++)
188 delete ((*((*this)[i]))[j]);
189 if ((*this)[i] != NULL)
190 delete ((*this)[i]);
191} // End of for m_hash.max()
192// Destroy also the vector of vectors to TT maps.
193for(size_t i=0;i<m_vecs.size();i++){
194 delete m_vecs[i];
195}
196for(unsigned int i=0; i< m_hashSym.size(); ++i) (m_hashSym[i]).clear();
197m_hashSym.clear();
198return StatusCode::SUCCESS;
199} // end of finalize
std::vector< DataVector< LArCell > * > m_vecs
One needs to destroy the TT vectors.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ find() [1/2]

const std::vector< LArCellCollection * >::const_iterator LArCellCont::find ( const HWIdentifier & id) const

Finds a collection by its LArReadoutModuleID.

Parameters
[in]ReadOutModule ID
Returns
const_iterator to a pointer to LArCellCollection.

Definition at line 203 of file LArCellCont.cxx.

203 {
204 int idx = m_hash(m_conv.getRodIDFromROM (rodid));
205 return (std::vector<LArCellCollection*>::const_iterator)((*this).begin()+idx);
206}
Hid2RESrcID m_conv
Hardware to Source ID conversion.

◆ find() [2/2]

const std::vector< LArCellCollection * >::const_iterator LArCellCont::find ( const unsigned int & id)

Finds a collection by its ROD ID.

Parameters
[in]ReadOut ID as provided by RegionSelector.
Returns
const_iterator to a pointer to LArCellCollection.

Definition at line 210 of file LArCellCont.cxx.

210 {
211 int idx = m_hash(rodid);
212 //coverity[NEGATIVE_RETURNS]
213 if ( m_eventNumber[idx] != m_event ) { // Decoding a new event
215 return (std::vector<LArCellCollection*>::const_iterator)((*this).begin()+idx);
216 // Keep track of last decoded number
217 } else { // Event already decoded. Return Null
218 return (std::vector<LArCellCollection*>::const_iterator)((*this).end());
219 }
220}
std::vector< unsigned int > m_eventNumber
eventNumber of a given Collection

◆ findsec()

HWIdentifier LArCellCont::findsec ( const unsigned int & id) const

Each Collection contains data from 2 FEBs.

Returns
for each collection the ID of the second FEB.

Definition at line 241 of file LArCellCont.cxx.

241 {
242 int idx = m_hash(rodid);
243 //coverity[NEGATIVE_RETURNS]
244 return m_second[idx];
245}
std::vector< HWIdentifier > m_second
FEB Hardware Identifier for second FEBs in a Collection.

◆ initialize()

StatusCode LArCellCont::initialize ( const LArRoIMap & roiMap,
const LArOnOffIdMapping & onOffMap,
const LArMCSym & mcsym,
const LArFebRodMapping & febrod,
const LArBadChannelCont & badchannel,
const CaloDetDescrManager & ddm )

initialize method.

Builds all cells and collections.

Definition at line 22 of file LArCellCont.cxx.

27 {
28
29#ifdef TRIGLARCELLDEBUG
30std::cout << "LArCellCont \t\t DEBUG \t in initialize" << std::endl;
31#endif
32
33 ServiceHandle<IToolSvc> toolSvc("ToolSvc", "LArCellCont");
34 CHECK_WITH_CONTEXT( toolSvc.retrieve(), "LArCellCont");
35
36 ServiceHandle<StoreGateSvc> detStore("DetectorStore", "LArCellCont");
37 CHECK_WITH_CONTEXT( detStore.retrieve(), "LArCellCont");
38
39 const LArOnlineID* onlineId = nullptr;
40 CHECK_WITH_CONTEXT( detStore->retrieve(onlineId,"LArOnlineID"), "LArCellCont" );
41
42 CHECK_WITH_CONTEXT( m_conv.initialize(febrod), "LArCellCont" );
43 m_hash.initialize(0, febrod.getLArRoModIDvec() );
44
45 HWIdentifier larrodid(0);
46 for(int i=0;i<m_hash.max();i++){
47#ifdef TRIGLARCELLDEBUG
48 std::cout << "LArCellCont\t\t DEBUG \t"
49 << i << " " << std::hex << m_hash.identifier(i) << std::dec
50 << std::endl;
51#endif
52 // A collection per ROD/ROB/HashId
53 LArCellCollection* mycoll = new LArCellCollection(larrodid);
54 mycoll->reserve(256);
55 this->push_back(mycoll);
56 m_second.push_back(HWIdentifier(0));
57 m_eventNumber.push_back(0xFFFFFFFF);
58 } // end of for id
59 // Not anymore necessary
60 //delete larrodid;
61
62std::vector<const CaloCellCorrection*> LArCellCorrTools;
63
64MakeLArCellFromRaw makeCell;
65makeCell.setThreshold(-100);
66makeCell.initialize( roiMap, onOffMap, man, &LArCellCorrTools, 0 );
67
68StatusCode sc = toolSvc->retrieveTool("LArBadFebMasker", m_badFebMasker);
69bool toolAvailable = sc.isSuccess();
70
71if(!toolAvailable) //not a critical error. LArCellCont can proceed as usual, without masking.
72 REPORT_MESSAGE_WITH_CONTEXT(MSG::INFO, "LArCellCont") <<
73 "Failed to retrieve LArBadFebMasker - no masking will be done." << endmsg;
74
75std::vector<uint32_t> RobsFromMissingFeb;
76
77int count = 0;
78std::vector<HWIdentifier>::const_iterator beg = onlineId->channel_begin();
79std::vector<HWIdentifier>::const_iterator end = onlineId->channel_end ();
80for( ; beg != end; ++beg ){
81 HWIdentifier hwid = mcsym.ZPhiSymOnl(*beg);
82 if ( m_indexset.try_emplace (hwid, count).second ) {
83 ++count;
84 }
85} // end of loop over online IDs
86int indexsetmax = m_indexset.size();
87// the extra indexsetmax is used for invalid cells
88m_corrBCID.resize(indexsetmax+1,0.0);
89
90for(unsigned int i=0; i< m_hashSym.size(); ++i) (m_hashSym[i]).clear();
91m_hashSym.clear();
92m_hashSym.resize(onlineId->febHashMax());
93 for (unsigned iFeb=0;iFeb<onlineId->febHashMax();++iFeb) {
94 const HWIdentifier& febid=onlineId->feb_Id(IdentifierHash(iFeb));
95 if( (toolAvailable && (m_badFebMasker->febMissing(febid)) ) || !toolAvailable ){
96 RobsFromMissingFeb.push_back( m_conv.getRobID( m_conv.getRodID( febrod, febid ) ) );
97 }
98 if( (toolAvailable && !(m_badFebMasker->febMissing(febid)) ) || !toolAvailable ){
99 // get RodID associated with the collection
100 const HWIdentifier& rodId = febrod.getReadoutModuleID(febid);
101 unsigned int rodId32 = m_conv.getRodIDFromROM(rodId);
102 // index in the collection vector
103 int idx = m_hash(rodId32);
104
105#ifdef TRIGLARCELLDEBUG
106 std::cout << "LArCellCont\t\t DEBUG \t"
107 << idx << " " << std::hex << m_hash.identifier(idx) << std::dec
108 << std::endl;
109#endif
110 // get all channels for a FEB
111 std::map<LArRoIMap::TT_ID,std::vector<LArCell* > > collMap;
112 //coverity[NEGATIVE_RETURNS]
113 if ( (*this)[idx]->size() != 0 ) { // This is the second FEB
114 m_second[idx] = febid;
115 }
116 std::vector<int>& hashTab = m_hashSym[idx];
117 hashTab.reserve(256);
118 unsigned int febidcomp = febid.get_identifier32().get_compact();
119 for(int ch=0;ch<128;ch++){
120 LArRoIMap::TT_ID ttId;
121 LArCell* larcell = makeCell.getLArCell(febidcomp,ch,0,0,0,ttId);
122 if ( larcell ) { // if it is a good cell
123 // Fixes default value
125 (*this)[idx]->push_back(larcell);
126 LArBadChannel bc = badchannel.offlineStatus(larcell->ID());
127 bool good(true);
128 if (! bc.good() ){
129 // cell has some specific problems
130 if ( bc.unstable() ) good=false;
131 if ( bc.highNoiseHG() ) good=false;
132 if ( bc.highNoiseMG() ) good=false;
133 if ( bc.highNoiseLG() ) good=false;
134 if ( bc.problematicForUnknownReason() ) good=false;
135 }
136 if ( good ) collMap[ttId].push_back(larcell); // cell masked if not know to be good
137 HWIdentifier hwsym = mcsym.ZPhiSymOnl(onlineId->channel_Id(febid,ch));
138 if ( m_indexset.find( hwsym ) != m_indexset.end() ){
139 int index = (m_indexset.find( hwsym ))->second;
140 hashTab.push_back( index );
141 } else hashTab.push_back(indexsetmax);
142#ifdef TRIGLARCELLDEBUG
143 std::cout << "Cell registered at Collection "
144 << std::hex << febid.get_identifier32().get_compact() << std::dec <<
145 " Channel " << ch << " TTId " << (unsigned int)ttId
146 << std::endl;
147#endif
148 }
149 else {// add a dummy cell
150#ifdef TRIGLARCELLDEBUG
151 std::cout << "Cell not existing" << std::endl;
152#endif
153 LArCell* larcell = new LArCell();
154 (*this)[idx]->push_back(larcell);
155 hashTab.push_back( indexsetmax);
156 } // end of if bad cell
157 } // end of for ch loop
158 for (const auto& [ttid, cells] : collMap) {
159 // Ones needs to dump the mapped vector to an allocated vector
160 DataVector<LArCell> *vec = new DataVector<LArCell>(SG::VIEW_ELEMENTS);
161 vec->reserve(cells.size());
162 for(LArCell* c : cells)
163 {
164 // if(doCellMasking && m_masker->cellShouldBeMasked(c->ID()) )
165 vec->push_back(c);
166 }
167 (*this)[idx]->setTT(ttid,vec->begin(),vec->end());
168 m_vecs.push_back(vec);
169 }//End of loop over the map
170 } // End of check for missing FEB
171} // end of FEB for
172
173m_MissingROBs.clear();
174for(size_t i = 0 ; i < RobsFromMissingFeb.size() ; i++)
175for(size_t j = i+1 ; j < RobsFromMissingFeb.size() ; j++)
176if ( RobsFromMissingFeb[i] == RobsFromMissingFeb[j] )
177m_MissingROBs.push_back(RobsFromMissingFeb[i]);
178RobsFromMissingFeb.clear();
179
180return StatusCode::SUCCESS;
181}
#define endmsg
std::vector< size_t > vec
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
static Double_t sc
void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN)
set gain
Definition CaloCell.h:497
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
bool highNoiseHG() const
bool problematicForUnknownReason() const
bool unstable() const
bool highNoiseMG() const
bool highNoiseLG() const
bool good() const
Returns true if no problems at all (all bits at zero)
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
std::vector< uint32_t > m_MissingROBs
List of Missing ROBs to be disabled at the RS.
const ILArBadFebMasker * m_badFebMasker
A tool to help mask cells.
std::map< HWIdentifier, int > m_indexset
index table
const std::vector< HWIdentifier > & getLArRoModIDvec() const
"iterator" on LArReadoutModuleIDs
HWIdentifier getReadoutModuleID(const HWIdentifier &id) const
HWIdentifier ZPhiSymOnl(const HWIdentifier notSymOnlId) const
Find the symmetric HWID for an online channel identifier.
Definition LArMCSym.h:91
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
id_iterator channel_end() const
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
size_type febHashMax() const
define feb hash tables max size
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
unsigned int TT_ID
Definition LArRoIMap.h:34
void initialize(const LArRoIMap &roiMap, const LArOnOffIdMapping &onOffMap, const CaloDetDescrManager &man, const std::vector< const CaloCellCorrection * > *pCorr, unsigned int poolMaxSize=190000)
initialize the internal map
LArCell * getLArCell(unsigned int feb, unsigned int chan, int e, int t, int q, CaloGain::CaloGain caloGain, unsigned int &ttId) const
access by Identifier
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
@ LARHIGHGAIN
Definition CaloGain.h:18
str index
Definition DeMoScan.py:362
::StatusCode StatusCode
StatusCode definition for legacy code.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ lumiBCIDCheck()

bool LArCellCont::lumiBCIDCheck ( const EventContext & context)

Definition at line 274 of file LArCellCont.cxx.

274 {
275 uint32_t bcid = context.eventID().bunch_crossing_id();
276 if ( bcid == m_bcid ) return false;
277 EventIDBase::event_number_t evN = context.eventID().event_number();
278 if ( evN == m_bcidEvt ) return false;
279 m_bcid = bcid;
280 m_bcidEvt = evN;
281 return true;
282}
setEventNumber setTimeStamp bcid
setEventNumber uint32_t

◆ lumiBlock_BCID()

void LArCellCont::lumiBlock_BCID ( const unsigned int lumi_block,
const unsigned int BCID )

sets LumiBlock and BCID

Definition at line 247 of file LArCellCont.cxx.

247 {
248 if ( m_bcid != BCID ) {
249#ifdef TRIGLARCELLDEBUG
250 std::cout << "Update : CURRENT lumi_block, BCID = " << lumi_block << ", " << BCID << " <--> PREVIOUS lumi_block = " << m_lumi_block << ", " << m_bcid << std::endl;
251#endif
252 m_lumi_block = lumi_block; m_bcid = BCID;
253 m_BCIDcache=false;
254 }
255}

◆ MissingROBs()

const std::vector< uint32_t > & LArCellCont::MissingROBs ( void )
inline

List of Missing ROBs.

Definition at line 90 of file LArCellCont.h.

90 {
91 return m_MissingROBs;
92 }

◆ updateBCID()

void LArCellCont::updateBCID ( const CaloBCIDAverage & avg,
const LArOnOffIdMapping & onoff )

update BCID dependent correction table for MT case

Definition at line 257 of file LArCellCont.cxx.

257 {
258
259 std::map<HWIdentifier,int>::const_iterator end = m_indexset.end ();
260
261 std::map<HWIdentifier,int>::const_iterator beg = m_indexset.begin();
262 for( ; beg != end ; ++beg ) {
263 HWIdentifier hwid = (*beg).first;
264 int idx = (*beg).second;
265 if ( idx < (int)m_corrBCID.size() ){
266 Identifier id = onoff.cnvToIdentifier(hwid);
267 float corr = avg.average(id);
268 m_corrBCID[idx] = corr;
269 }
270 } // end of HWID
271 return;
272}
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
avg(a, b)
Definition Recovery.py:79

Member Data Documentation

◆ elements

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

STL member.

◆ m_badFebMasker

const ILArBadFebMasker* LArCellCont::m_badFebMasker = nullptr
private

A tool to help mask cells.

A tool to help mask febs

Definition at line 117 of file LArCellCont.h.

◆ m_bcid

unsigned int LArCellCont::m_bcid
private

Definition at line 128 of file LArCellCont.h.

◆ m_BCIDcache

bool LArCellCont::m_BCIDcache
private

flag to only update cache when trying to apply corrections

Definition at line 132 of file LArCellCont.h.

◆ m_bcidEvt

EventIDBase::event_number_t LArCellCont::m_bcidEvt
private

Definition at line 129 of file LArCellCont.h.

◆ m_conv

Hid2RESrcID LArCellCont::m_conv
private

Hardware to Source ID conversion.

Definition at line 103 of file LArCellCont.h.

◆ m_corrBCID

std::vector<float> LArCellCont::m_corrBCID
private

corrections for a given BCID

Definition at line 123 of file LArCellCont.h.

◆ m_event

unsigned int LArCellCont::m_event
private

this event number

Definition at line 110 of file LArCellCont.h.

◆ m_eventNumber

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

eventNumber of a given Collection

Definition at line 108 of file LArCellCont.h.

◆ m_hash

LArRodIdHash LArCellCont::m_hash
private

Hash ID Identifier mapping to collection index.

Definition at line 101 of file LArCellCont.h.

◆ m_hashSym

std::vector< std::vector<int> > LArCellCont::m_hashSym
private

hash references to BCID

Definition at line 121 of file LArCellCont.h.

◆ m_indexset

std::map<HWIdentifier,int> LArCellCont::m_indexset
private

index table

Definition at line 125 of file LArCellCont.h.

◆ m_lumi_block

float LArCellCont::m_lumi_block
private

current lumi_block

Definition at line 127 of file LArCellCont.h.

◆ m_MissingROBs

std::vector<uint32_t> LArCellCont::m_MissingROBs
private

List of Missing ROBs to be disabled at the RS.

Definition at line 119 of file LArCellCont.h.

◆ m_second

std::vector<HWIdentifier> LArCellCont::m_second
private

FEB Hardware Identifier for second FEBs in a Collection.

Definition at line 106 of file LArCellCont.h.

◆ m_vecs

std::vector<DataVector<LArCell>*> LArCellCont::m_vecs
private

One needs to destroy the TT vectors.

Definition at line 112 of file LArCellCont.h.


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