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

#include <GepCellsHandlerAlg.h>

Inheritance diagram for GepCellsHandlerAlg:
Collaboration diagram for GepCellsHandlerAlg:

Public Member Functions

 GepCellsHandlerAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &) const override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode setNumberOfEnergyBits (int value)
StatusCode setLeastSignificantBit (int value)
StatusCode setG (int value)
int getGepEnergy (float offline_et) const
std::vector< unsigned int > getNeighbours (const CaloCellContainer &allcells, const CaloCell *acell, const EventContext &) const
StatusCode removeCellsFromOverloadedFEB (std::vector< Gep::GepCaloCell > &cells) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_nEnergyBits = -1
int m_valLeastSigBit = -1
int m_valG = -1
int m_readoutRanges [5] = {-1,-1,-1,-1,-1}
int m_stepsPerRange = -1
unsigned m_maxCellsPerFEB = -1
std::map< unsigned int, Gep::GepCaloCellm_gepCellsBase = {}
Gaudi::Property< std::string > m_GepEnergyEncodingScheme
Gaudi::Property< bool > m_doGepHardwareStyleEnergyEncoding
Gaudi::Property< bool > m_doTruncationOfOverflowingFEBs
Gaudi::Property< bool > m_writeAllCells
Gaudi::Property< bool > m_cleanOutputCells
Gaudi::Property< std::string > m_LArCellMap
SG::ReadCondHandleKey< CaloNoisem_electronicNoiseKey {this, "electronicNoiseKey", "totalNoise", "SG Key of CaloNoise data object"}
 Key of the CaloNoise Conditions data object.
SG::ReadCondHandleKey< CaloNoisem_totalNoiseKey {this, "totalNoiseKey", "totalNoise", "SG Key of CaloNoise data object"}
SG::WriteHandleKey< Gep::GepCellMapm_outputGepCellsKey {this, "outputGepCellsKey", "", "Key for GepCell map"}
SG::ReadHandleKey< CaloCellContainerm_caloCellsKey {this, "caloCells", "AllCalo", "key to read in a CaloCell constainer"}
const CaloCell_IDm_CaloCell_ID {nullptr}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 22 of file GepCellsHandlerAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ GepCellsHandlerAlg()

GepCellsHandlerAlg::GepCellsHandlerAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 14 of file GepCellsHandlerAlg.cxx.

14 :
15AthReentrantAlgorithm( name, pSvcLocator ){
16 }

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode GepCellsHandlerAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 134 of file GepCellsHandlerAlg.cxx.

134 {
135
136 // PS this function creates and stores a map which has Gep::GepCaloCells as its values
137 // The cells are made up of data which is invariant for all events, and dynamic
138 // data which varies with event.
139 // The invariant data should be setup in initialize(), and the dynamic
140 // data should be updated here in a way which is compatible with the const-ness of this
141 // function.
142 // This will be attended to in the future.
143
144 ATH_MSG_DEBUG ("Executing " << name() << "...");
145
146 // Read in a container containing (all) CaloCells
147 auto h_caloCells = SG::makeHandle(m_caloCellsKey, ctx);
148 CHECK(h_caloCells.isValid());
149 const auto & cells = *h_caloCells;
150
151 ATH_MSG_DEBUG("Read in " + std::to_string(h_caloCells->size()) + " cells");
152
153 SG::ReadCondHandle<CaloNoise> electronicNoiseHdl{m_electronicNoiseKey, ctx};
154 if (!electronicNoiseHdl.isValid()) {return StatusCode::FAILURE;}
155 const CaloNoise* electronicNoiseCDO = *electronicNoiseHdl;
156
157 SG::ReadCondHandle<CaloNoise> totalNoiseHdl{m_totalNoiseKey, ctx};
158 if (!totalNoiseHdl.isValid()) {return StatusCode::FAILURE;}
159 const CaloNoise* totalNoiseCDO = *totalNoiseHdl;
160
161 int idx = -1;
162 std::map<std::string,std::vector<Gep::GepCaloCell>> gepCellsPerFEB;
163
164 for(const auto *cell: cells){
165
166 Gep::GepCaloCell caloCell;
167 ++idx;
168
169 caloCell.id = (cell->ID().get_identifier32()).get_compact();
170 auto base_cell_itr = m_gepCellsBase.find(caloCell.id);
171 if (base_cell_itr != m_gepCellsBase.end()) caloCell = base_cell_itr->second;
172 else {
173 // Tile cells are not included in the cell base map
174 // In the future this might change, for now just setting FEB value to a dummy
175 caloCell.FEB = "Tile";
176 }
177
178 float electronicNoise = electronicNoiseCDO->getNoise(cell->ID(), cell->gain());
179 float totalNoise = totalNoiseCDO->getNoise(cell->ID(), cell->gain());
180
181 // Only send positive-energy 2sigma cells to the GEP
182 const bool pass_2sigma = cell->energy() / totalNoise >= 2.0;
183 if (!pass_2sigma && !m_writeAllCells) continue;
184
185 const double energy = m_cleanOutputCells && !pass_2sigma ? 0 : cell->energy();
186
187 // GEP will only have ET available for LAr cells, so convert to energy from ET
188 caloCell.offline_et = energy / TMath::CosH(cell->eta());
189 if (m_doGepHardwareStyleEnergyEncoding && !m_CaloCell_ID->is_tile(cell->ID())) {
190 caloCell.et = getGepEnergy(energy / TMath::CosH(cell->eta()));
191 caloCell.e = caloCell.et * TMath::CosH(cell->eta());
192 }
193 else {
194 caloCell.e = energy;
195 caloCell.et = caloCell.offline_et;
196 }
197 caloCell.time = cell->time();
198 caloCell.quality = cell->quality();
199 caloCell.provenance = cell->provenance();
200
201 caloCell.totalNoise = totalNoise;
202 caloCell.electronicNoise = electronicNoise;
203 caloCell.sigma = cell->energy() / totalNoise;
204
205 caloCell.isBad = cell->badcell();
206 caloCell.eta = cell->eta();
207 caloCell.phi = cell->phi();
208 caloCell.sinTh = cell->sinTh();
209 caloCell.cosTh = cell->cosTh();
210 caloCell.sinPhi = cell->sinPhi();
211 caloCell.cosPhi = cell->cosPhi();
212 caloCell.cotTh = cell->cotTh();
213 caloCell.x = cell->x();
214 caloCell.y = cell->y();
215 caloCell.z = cell->z();
216
217 unsigned int samplingEnum = m_CaloCell_ID->calo_sample(cell->ID());
218
219 bool IsEM = m_CaloCell_ID->is_em(cell->ID());
220 bool IsEM_Barrel=false;
221 bool IsEM_EndCap=false;
222 bool IsEM_BarrelPos=false;
223 bool IsEM_BarrelNeg=false;
224 if(IsEM){
225 IsEM_Barrel=m_CaloCell_ID->is_em_barrel(cell->ID());
226 if(IsEM_Barrel){
227 if(m_CaloCell_ID->pos_neg(cell->ID())>0) IsEM_BarrelPos=true;
228 }
229 IsEM_EndCap=m_CaloCell_ID->is_em_endcap(cell->ID());
230 }
231
232 caloCell.isEM = IsEM;
233 caloCell.isEM_barrel = IsEM_Barrel;
234 caloCell.isEM_endCap = IsEM_EndCap;
235 caloCell.isEM_barrelPos = IsEM_BarrelPos;
236 caloCell.isEM_barrelNeg = IsEM_BarrelNeg; //always false?
237 caloCell.isFCAL = m_CaloCell_ID->is_fcal(cell->ID());
238 caloCell.isHEC = m_CaloCell_ID->is_hec(cell->ID());
239 caloCell.isTile = m_CaloCell_ID->is_tile(cell->ID());
240
241 caloCell.sampling = samplingEnum;
242 caloCell.detName = CaloSampling::getSamplingName(samplingEnum);
243
244 caloCell.neighbours = getNeighbours(cells, cell, ctx);
245 caloCell.id = (cell->ID().get_identifier32()).get_compact();
246
247 const CaloDetDescriptor *elt = cell->caloDDE()->descriptor();
248 caloCell.layer = cell->caloDDE()->getLayer();
249
250 float deta = elt->deta();
251 float dphi = elt->dphi();
252
253 float etamin = caloCell.eta - (0.5*deta);
254 float etamax = caloCell.eta + (0.5*deta);
255
256 float phimin = caloCell.phi - (0.5*dphi);
257 float phimax = caloCell.phi + (0.5*dphi);
258
259 caloCell.etaMin = etamin;
260 caloCell.etaMax = etamax;
261 caloCell.phiMin = phimin;
262 caloCell.phiMax = phimax;
263 caloCell.etaGranularity = deta;
264 caloCell.phiGranularity = dphi;
265
266 caloCell.index = idx;
267
268 // Fill cells into map according to FEB
269 auto feb_itr = gepCellsPerFEB.find(caloCell.FEB);
270 if (feb_itr != gepCellsPerFEB.end()) feb_itr->second.push_back(std::move(caloCell));
271 else {
272 std::vector<Gep::GepCaloCell> cellsThisFEB;
273 cellsThisFEB.push_back(caloCell);
274 gepCellsPerFEB.insert(std::pair<std::string,std::vector<Gep::GepCaloCell>>(caloCell.FEB,cellsThisFEB));
275 }
276 }
277
278 Gep::GepCellMap gepCellMap;
279
280 // do truncation
281 auto itr = gepCellsPerFEB.begin();
282 int nFeb2sInOverflow = 0;
283 for ( ;itr != gepCellsPerFEB.end(); ++itr) {
284
285 // LAr FEBs might overflow, so they will get truncated
286 if (m_doTruncationOfOverflowingFEBs && itr->second.size() > m_maxCellsPerFEB && itr->first != "Tile" && (!m_writeAllCells || m_cleanOutputCells)) {
287 ATH_MSG_DEBUG("FEB " << itr->first << " is sending " << itr->second.size() << " cells, which is more cells than GEP can receive. Removing all but the possible " << m_maxCellsPerFEB << " cells.");
289 ++nFeb2sInOverflow;
290 }
291 for (const Gep::GepCaloCell& cell : itr->second)
292 gepCellMap.insert(cell.id, cell);
293 }
294 ATH_MSG_DEBUG("GEP is receiving a total of " << gepCellMap.size() << " cells in this event");
295 gepCellMap.setNumberOfOverflowingFEB2s(nFeb2sInOverflow);
296
297 SG::WriteHandle<Gep::GepCellMap> h_gepCellMap = SG::makeHandle(m_outputGepCellsKey, ctx);
298 ATH_CHECK( h_gepCellMap.record( std::make_unique<Gep::GepCellMap>(gepCellMap) ) );
299
300 return StatusCode::SUCCESS;
301}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
double deta() const
delta eta
double dphi() const
delta phi
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:35
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
std::map< unsigned int, Gep::GepCaloCell > m_gepCellsBase
Gaudi::Property< bool > m_cleanOutputCells
Gaudi::Property< bool > m_doTruncationOfOverflowingFEBs
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Gaudi::Property< bool > m_writeAllCells
SG::WriteHandleKey< Gep::GepCellMap > m_outputGepCellsKey
StatusCode removeCellsFromOverloadedFEB(std::vector< Gep::GepCaloCell > &cells) const
SG::ReadCondHandleKey< CaloNoise > m_electronicNoiseKey
Key of the CaloNoise Conditions data object.
int getGepEnergy(float offline_et) const
Gaudi::Property< bool > m_doGepHardwareStyleEnergyEncoding
SG::ReadHandleKey< CaloCellContainer > m_caloCellsKey
std::vector< unsigned int > getNeighbours(const CaloCellContainer &allcells, const CaloCell *acell, const EventContext &) const
const CaloCell_ID * m_CaloCell_ID
void setNumberOfOverflowingFEB2s(int n)
Definition GepCellMap.h:37
unsigned int size()
Definition GepCellMap.h:25
void insert(unsigned int id, const Gep::GepCaloCell &cell)
Definition GepCellMap.h:21
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ IsEM
cut-based identification for egamma objects (cluster and track-based)
unsigned int sampling
Definition GepCaloCell.h:49
unsigned int provenance
Definition GepCaloCell.h:19
unsigned int quality
Definition GepCaloCell.h:18
unsigned int id
Definition GepCaloCell.h:50
std::vector< unsigned int > neighbours
Definition GepCaloCell.h:57
std::string detName
Definition GepCaloCell.h:51
std::string FEB
Definition GepCaloCell.h:52

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ getGepEnergy()

int GepCellsHandlerAlg::getGepEnergy ( float offline_et) const
private

Definition at line 305 of file GepCellsHandlerAlg.cxx.

305 {
306
307 // If cell saturates readout range, largest possible value is send
308 if (offline_et > m_readoutRanges[4])
310
311 int readoutRange = 0;
312 for (int i = 1; i <= 3; ++i) {
313 if (offline_et > m_readoutRanges[i]) readoutRange = i;
314 }
315
316 float step = (static_cast<float>(m_readoutRanges[readoutRange+1]) - static_cast<float>(m_readoutRanges[readoutRange])) / m_stepsPerRange;
317 int gep_energy = -1;
318 for (int i = 0; i < m_stepsPerRange; ++i) {
319 gep_energy = m_readoutRanges[readoutRange]+(step*i);
320 if (offline_et < (m_readoutRanges[readoutRange]+(step*(i+1)))) break;
321 }
322
323 return gep_energy;
324}

◆ getNeighbours()

std::vector< unsigned int > GepCellsHandlerAlg::getNeighbours ( const CaloCellContainer & allcells,
const CaloCell * acell,
const EventContext &  ) const
private

Definition at line 329 of file GepCellsHandlerAlg.cxx.

331 {
332
333 // get all neighboring cells
334 std::vector<IdentifierHash> cellNeighbours;
335
336 IdentifierHash cellHashID = m_CaloCell_ID->calo_cell_hash(acell->ID());
337 m_CaloCell_ID->get_neighbours(cellHashID,LArNeighbours::super3D,cellNeighbours);
338
339 std::vector<unsigned int> neighbour_ids;
340 for (unsigned int iNeighbour = 0;
341 iNeighbour < cellNeighbours.size();
342 ++iNeighbour) {
343
344 const CaloCell* neighbour = allcells.findCell(cellNeighbours[iNeighbour]);
345 if (neighbour) {
346 neighbour_ids.push_back((neighbour->ID().get_identifier32()).get_compact());
347 } else {
348 ATH_MSG_ERROR("Couldn't access neighbour #" << iNeighbour
349 << " for cell ID "
350 << (acell->ID().get_identifier32()).get_compact());
351 }
352 }
353 return neighbour_ids;
354}
#define ATH_MSG_ERROR(x)
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.

◆ initialize()

StatusCode GepCellsHandlerAlg::initialize ( )
overridevirtual

Definition at line 19 of file GepCellsHandlerAlg.cxx.

19 {
20 ATH_MSG_INFO ("Initializing " << name() << "...");
21 ATH_MSG_INFO ("Target GepCell container name " << m_outputGepCellsKey);
22
23 // Retrieve AlgTools
24 ATH_CHECK(m_electronicNoiseKey.initialize());
25 ATH_CHECK(m_totalNoiseKey.initialize());
26
27 CHECK(m_caloCellsKey.initialize());
28 CHECK(m_outputGepCellsKey.initialize());
29
30 // CaloIndentifier
31 CHECK( detStore()->retrieve (m_CaloCell_ID, "CaloCell_ID") );
32
33 ATH_MSG_INFO("Hardware-style energy encoding for GEP cells has been set to " << m_doGepHardwareStyleEnergyEncoding.value());
34 if (!m_doGepHardwareStyleEnergyEncoding) ATH_MSG_WARNING("Hardware-style energy encoding for GEP cells has been disabled. Cell energies will have larger precision than realistically possible");
35
36 ATH_MSG_INFO("Truncation of Gep cells from FEBs which are overflowing has been set to " << m_doTruncationOfOverflowingFEBs.value());
37 if (!m_doTruncationOfOverflowingFEBs) ATH_MSG_WARNING("Truncation of GEP cells from overflowing FEBs has been disabled. More GEP cells will be send to algorithms than realistically possible");
38
39 ATH_MSG_INFO("Flag to enabling the writting of all cells has been set to " << m_writeAllCells.value());
40 if (m_writeAllCells) {
41 ATH_MSG_WARNING("Will write all cells even if they would get truncated for GEP and/or are below the 2sigma threshold. This might lead to large output Ntuples and is not a realistic representation of GEP cells");
43 ATH_MSG_INFO("Setting energies of the truncated and noisy cells to 0");
44 }
45 } else if (m_cleanOutputCells) {
46 ATH_MSG_ERROR("Cannot use CleanOutputCells without WriteAllCells");
47 return StatusCode::FAILURE;
48 }
49
50
51 // Setting up GEP energy encoding scheme
53
54 // Read values of Gep readout scheme from argument
55 int GepScheme[3];
56 for (int i = 0; i < 3; ++i) {
57 GepScheme[i] = std::stoi(m_GepEnergyEncodingScheme.value().substr(0,m_GepEnergyEncodingScheme.value().find("-")));
58 m_GepEnergyEncodingScheme.value().erase(0, m_GepEnergyEncodingScheme.value().find("-")+1);
59 }
60
61 CHECK(setNumberOfEnergyBits(GepScheme[0]));
62 CHECK(setLeastSignificantBit(GepScheme[1]));
63 CHECK(setG(GepScheme[2]));
64
65 m_stepsPerRange = std::pow(2,m_nEnergyBits-2);
66
67 m_readoutRanges[0] = 0;
72
73 ATH_MSG_DEBUG("Readout scheme with " << m_nEnergyBits << "-bits provides the following four energy thresholds (with " << m_stepsPerRange << " discrete steps on each threshold)");
74 ATH_MSG_DEBUG("GEP cell energy range 0: min = " << m_readoutRanges[0] << " MeV -> max = " << m_readoutRanges[1] << " MeV");
75 ATH_MSG_DEBUG("GEP cell energy range 1: min = " << m_readoutRanges[1] + m_valLeastSigBit << " MeV -> max = " << m_readoutRanges[2] << " MeV");
76 ATH_MSG_DEBUG("GEP cell energy range 2: min = " << m_readoutRanges[2]+(m_valG*m_valLeastSigBit) << " MeV -> max = " << m_readoutRanges[3] << " MeV");
77 ATH_MSG_DEBUG("GEP cell energy range 3: min = " << m_readoutRanges[3]+(m_valG*m_valG*m_valLeastSigBit) << " MeV -> max = " << m_readoutRanges[4] << " MeV");
78 }
79
81 // Loading the invariant cell data and storing in m_gepCellsBase for later use on event-by-event basis
82 m_gepCellsBase.clear();
83
84 ATH_MSG_DEBUG("Loading cell map associating cells to FEBs");
85
86 std::string cellMapPath = PathResolverFindCalibFile(m_LArCellMap);
87 if(cellMapPath.empty()) ATH_MSG_ERROR("Could not find file with cell map data: " << m_LArCellMap.value());
88
89 std::ifstream file(cellMapPath.c_str());
90
91 unsigned n_cells = 0;
92
93 // Read input file
94 if (file.is_open()) {
95
96 int online_id, offline_id, ch, con_num, fbr;
97 std::string feb, con_type;
98
99 // Skipping header of file
100 std::getline(file, feb);
101
102 // start reading data
103 while (true) {
104
105 file >> offline_id >> online_id >> feb >> ch >> con_type >> con_num >> fbr;
106
107 if (file.eof()) break;
108
109 Gep::GepCaloCell caloCell;
110 caloCell.id = offline_id;
111 caloCell.FEB = feb;
112 caloCell.channel = ch;
113 caloCell.fiber = fbr;
114 caloCell.connection_type = con_type;
115 caloCell.connection_number = con_num;
116
117 m_gepCellsBase.insert(std::pair<unsigned int, Gep::GepCaloCell>(caloCell.id, caloCell));
118
119 ++n_cells;
120 }
121 }
122 else {
123 ATH_MSG_ERROR("Could not open file containing the cell to FEB association");
124 return StatusCode::FAILURE;
125 }
126
127 ATH_MSG_DEBUG("Loaded FEB information for " << n_cells << " cells");
128 }
129
130 return StatusCode::SUCCESS;
131}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
const ServiceHandle< StoreGateSvc > & detStore() const
Gaudi::Property< std::string > m_GepEnergyEncodingScheme
Gaudi::Property< std::string > m_LArCellMap
StatusCode setG(int value)
StatusCode setNumberOfEnergyBits(int value)
StatusCode setLeastSignificantBit(int value)
std::string connection_type
Definition GepCaloCell.h:55
TFile * file

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ removeCellsFromOverloadedFEB()

StatusCode GepCellsHandlerAlg::removeCellsFromOverloadedFEB ( std::vector< Gep::GepCaloCell > & cells) const
private

Definition at line 358 of file GepCellsHandlerAlg.cxx.

358 {
359
360 std::map<int,Gep::GepCaloCell> orderedCells;
361 for (const Gep::GepCaloCell& cell : cells)
362 orderedCells.insert(std::pair<int,Gep::GepCaloCell>(cell.channel,cell));
363
364 cells.clear();
365
366 std::map<int,Gep::GepCaloCell>::iterator cell_itr = orderedCells.begin();
367 for ( ;cell_itr != orderedCells.end(); ++cell_itr) {
368 cells.push_back(cell_itr->second);
369 if (!m_cleanOutputCells && cells.size() == m_maxCellsPerFEB) break;
370 else if (m_cleanOutputCells && cells.size() > m_maxCellsPerFEB) {
371 cells.back().offline_et = 0;
372 cells.back().e = 0;
373 cells.back().et = 0;
374 }
375 }
376
377 return StatusCode::SUCCESS;
378}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ setG()

StatusCode GepCellsHandlerAlg::setG ( int value)
inlineprivate

Definition at line 63 of file GepCellsHandlerAlg.h.

63 {
64 if (value < 1) {
65 ATH_MSG_FATAL("The value of G in the GEP energy encoding cannot be set to " << value);
66 return StatusCode::FAILURE;
67 }
68 ATH_MSG_INFO("Setting the value for G in the GEP energy encoding to " << value);
69 m_valG = value;
70
71 return StatusCode::SUCCESS;
72 }
#define ATH_MSG_FATAL(x)

◆ setLeastSignificantBit()

StatusCode GepCellsHandlerAlg::setLeastSignificantBit ( int value)
inlineprivate

Definition at line 52 of file GepCellsHandlerAlg.h.

52 {
53 if (value < 1) {
54 ATH_MSG_FATAL("The value of the least significant bit in the GEP energy encoding cannot be set to " << value);
55 return StatusCode::FAILURE;
56 }
57 ATH_MSG_INFO("Setting the value for the least significant bit in the GEP energy encoding to " << value << " MeV");
59
60 return StatusCode::SUCCESS;
61 }

◆ setNumberOfEnergyBits()

StatusCode GepCellsHandlerAlg::setNumberOfEnergyBits ( int value)
inlineprivate

Definition at line 33 of file GepCellsHandlerAlg.h.

33 {
34
35 // At the moment only have a detailed scheme for 6-10 bit readouts, thus rejecting any other value
36 switch(value) {
37 case 6: m_maxCellsPerFEB = 62; break;
38 case 7: m_maxCellsPerFEB = 54; break;
39 case 8: m_maxCellsPerFEB = 48; break;
40 case 9: m_maxCellsPerFEB = 43; break;
41 case 10: m_maxCellsPerFEB = 39; break;
42 default: ATH_MSG_FATAL("A GEP energy encoding scheme with " << value << " energy bits is currently not defined");
43 return StatusCode::FAILURE;
44 }
45
46 ATH_MSG_INFO("Setting GEP energy encoding to a " << value << "-bit scheme which allows for the sending of " << m_maxCellsPerFEB << " cells to GEP per FEB");
48
49 return StatusCode::SUCCESS;
50 }

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_CaloCell_ID

const CaloCell_ID* GepCellsHandlerAlg::m_CaloCell_ID {nullptr}
private

Definition at line 113 of file GepCellsHandlerAlg.h.

113{nullptr};

◆ m_caloCellsKey

SG::ReadHandleKey<CaloCellContainer> GepCellsHandlerAlg::m_caloCellsKey {this, "caloCells", "AllCalo", "key to read in a CaloCell constainer"}
private

Definition at line 111 of file GepCellsHandlerAlg.h.

111{this, "caloCells", "AllCalo", "key to read in a CaloCell constainer"};

◆ m_cleanOutputCells

Gaudi::Property<bool> GepCellsHandlerAlg::m_cleanOutputCells
private
Initial value:
{this, "CleanOutputCells", false,
"If true, all output cells are included in the output, but those truncated or below 2sigma will have their energies set to 0; to be used only with WriteAllCells"}

Definition at line 96 of file GepCellsHandlerAlg.h.

96 {this, "CleanOutputCells", false,
97 "If true, all output cells are included in the output, but those truncated or below 2sigma will have their energies set to 0; to be used only with WriteAllCells"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doGepHardwareStyleEnergyEncoding

Gaudi::Property<bool> GepCellsHandlerAlg::m_doGepHardwareStyleEnergyEncoding
private
Initial value:
{this, "HardwareStyleEnergyEncoding", false,
"Enabling or disabling the hardware-style energy encoding for the GEP"}

Definition at line 87 of file GepCellsHandlerAlg.h.

87 {this, "HardwareStyleEnergyEncoding", false,
88 "Enabling or disabling the hardware-style energy encoding for the GEP"};

◆ m_doTruncationOfOverflowingFEBs

Gaudi::Property<bool> GepCellsHandlerAlg::m_doTruncationOfOverflowingFEBs
private
Initial value:
{this, "TruncationOfOverflowingFEBs", false,
"Enabling or disabling the truncation of cells from FEBs with more than the maximum number of cells which can be send"}

Definition at line 90 of file GepCellsHandlerAlg.h.

90 {this, "TruncationOfOverflowingFEBs", false,
91 "Enabling or disabling the truncation of cells from FEBs with more than the maximum number of cells which can be send"};

◆ m_electronicNoiseKey

SG::ReadCondHandleKey<CaloNoise> GepCellsHandlerAlg::m_electronicNoiseKey {this, "electronicNoiseKey", "totalNoise", "SG Key of CaloNoise data object"}
private

Key of the CaloNoise Conditions data object.

Typical values are '"electronicNoise', 'pileupNoise', or '"totalNoise' (default)

Definition at line 105 of file GepCellsHandlerAlg.h.

105{this, "electronicNoiseKey", "totalNoise", "SG Key of CaloNoise data object"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_gepCellsBase

std::map<unsigned int,Gep::GepCaloCell> GepCellsHandlerAlg::m_gepCellsBase = {}
private

Definition at line 82 of file GepCellsHandlerAlg.h.

82{};

◆ m_GepEnergyEncodingScheme

Gaudi::Property<std::string> GepCellsHandlerAlg::m_GepEnergyEncodingScheme
private
Initial value:
{this, "GEPEnergyEncodingScheme", "",
"String defining the GEP readout scheme according to number of readout bits + '-' + value of LSB in MeV + '-' + gain value"}

Definition at line 84 of file GepCellsHandlerAlg.h.

84 {this, "GEPEnergyEncodingScheme", "",
85 "String defining the GEP readout scheme according to number of readout bits + '-' + value of LSB in MeV + '-' + gain value"};

◆ m_LArCellMap

Gaudi::Property<std::string> GepCellsHandlerAlg::m_LArCellMap
private
Initial value:
{this, "LArCellMapFile", "UpgradePerformanceFunctions/LAr_Cell_Map_offlineID_0.csv",
"File associating LAr cells with readout FEBs and connection technology"}

Definition at line 99 of file GepCellsHandlerAlg.h.

99 {this, "LArCellMapFile", "UpgradePerformanceFunctions/LAr_Cell_Map_offlineID_0.csv",
100 "File associating LAr cells with readout FEBs and connection technology"};

◆ m_maxCellsPerFEB

unsigned GepCellsHandlerAlg::m_maxCellsPerFEB = -1
private

Definition at line 80 of file GepCellsHandlerAlg.h.

◆ m_nEnergyBits

int GepCellsHandlerAlg::m_nEnergyBits = -1
private

Definition at line 75 of file GepCellsHandlerAlg.h.

◆ m_outputGepCellsKey

SG::WriteHandleKey<Gep::GepCellMap> GepCellsHandlerAlg::m_outputGepCellsKey {this, "outputGepCellsKey", "", "Key for GepCell map"}
private

Definition at line 109 of file GepCellsHandlerAlg.h.

109{this, "outputGepCellsKey", "", "Key for GepCell map"};

◆ m_readoutRanges

int GepCellsHandlerAlg::m_readoutRanges[5] = {-1,-1,-1,-1,-1}
private

Definition at line 78 of file GepCellsHandlerAlg.h.

78{-1,-1,-1,-1,-1};

◆ m_stepsPerRange

int GepCellsHandlerAlg::m_stepsPerRange = -1
private

Definition at line 79 of file GepCellsHandlerAlg.h.

◆ m_totalNoiseKey

SG::ReadCondHandleKey<CaloNoise> GepCellsHandlerAlg::m_totalNoiseKey {this, "totalNoiseKey", "totalNoise", "SG Key of CaloNoise data object"}
private

Definition at line 107 of file GepCellsHandlerAlg.h.

107{this, "totalNoiseKey", "totalNoise", "SG Key of CaloNoise data object"};

◆ m_valG

int GepCellsHandlerAlg::m_valG = -1
private

Definition at line 77 of file GepCellsHandlerAlg.h.

◆ m_valLeastSigBit

int GepCellsHandlerAlg::m_valLeastSigBit = -1
private

Definition at line 76 of file GepCellsHandlerAlg.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_writeAllCells

Gaudi::Property<bool> GepCellsHandlerAlg::m_writeAllCells
private
Initial value:
{this, "WriteAllCells", false,
"If true, all cells are considered regardless whether they are truncated or below the 2sigma threshold"}

Definition at line 93 of file GepCellsHandlerAlg.h.

93 {this, "WriteAllCells", false,
94 "If true, all cells are considered regardless whether they are truncated or below the 2sigma threshold"};

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