 |
ATLAS Offline Software
|
Go to the documentation of this file.
62 return StatusCode::FAILURE;
65 ATH_MSG_INFO(
"Loading cell map associating LAr cells to FEB2s");
70 std::ifstream
file(cellMapPath.c_str());
75 std::map<std::string,Feb2MuxInfo> feb2MuxAssoc;
80 int online_id, offline_id,
channel, con_num, fbr;
81 std::string assocFEB2, con_type, muxname, muxrack, cnnctr, laspname, lasprack;
84 std::getline(
file, assocFEB2);
89 file >> offline_id >> online_id >> assocFEB2 >>
channel >> con_type >> con_num >> fbr >> muxname >> muxrack >> cnnctr >> laspname >> lasprack;
91 if (
file.eof())
break;
95 gblLArCell.
setMUX(muxname);
98 m_gblLArCellMap.insert(std::pair<int, GlobalSim::GlobalLArCell>(offline_id, gblLArCell));
100 int indexOnMux = fbr;
101 if (cnnctr ==
"B") indexOnMux += 24;
102 if (cnnctr ==
"C") indexOnMux += 32;
105 auto itr = feb2MuxAssoc.find(assocFEB2);
106 if (itr == feb2MuxAssoc.end()) {
107 feb2MuxAssoc.insert(std::pair<std::string,Feb2MuxInfo>(assocFEB2, {muxname, indexOnMux}));
114 ATH_MSG_ERROR(
"Could not open file containing the cell to FEB2 association");
115 return StatusCode::FAILURE;
118 ATH_MSG_DEBUG(
"Loaded FEB2 information for " << n_cells <<
" LAr cells");
124 return StatusCode::SUCCESS;
139 CHECK(h_caloCells.isValid());
140 const auto &
cells = *h_caloCells;
145 if (!totalNoiseHdl.isValid()) {
return StatusCode::FAILURE;}
146 const CaloNoise* totalNoiseCDO = *totalNoiseHdl;
148 std::map<std::string,std::vector<GlobalSim::GlobalLArCell>> gblLArCellsPerFEB2;
152 int cell_id = (
cell->ID().get_identifier32()).get_compact();
160 float sigma =
cell->energy() / totalNoise;
163 if (
sigma < 2.0)
continue;
165 if (
cell->badcell())
continue;
167 std::pair<float, boost::dynamic_bitset<>> gep_energy =
encodeEnergy(
cell->energy() / TMath::CosH(
cell->eta()));
169 gblLArCell.
setEnergy(gep_energy.first, std::move(gep_energy.second));
174 auto feb2_itr = gblLArCellsPerFEB2.find(gblLArCell.
getFEB2());
175 if (feb2_itr != gblLArCellsPerFEB2.end()) feb2_itr->second.push_back(gblLArCell);
177 std::vector<GlobalSim::GlobalLArCell> cellsThisFEB;
178 cellsThisFEB.push_back(gblLArCell);
179 gblLArCellsPerFEB2.insert(std::pair<std::string,std::vector<GlobalSim::GlobalLArCell>>(gblLArCell.
getFEB2(),cellsThisFEB));
185 auto gblLArCellContainer = std::make_unique<GlobalSim::GlobalLArCellContainer>(templateRef);
188 for (
auto& [feb2Name,
cells] : gblLArCellsPerFEB2) {
191 bool inOverflow =
false;
192 bool inError =
false;
196 ATH_MSG_INFO(
"FEB " << feb2Name <<
" is sending " <<
cells.size() <<
" cells, which is more cells than GEP can receive. Removing all but the possible " <<
m_maxCellsPerFEB <<
" cells.");
201 for (
auto& gblLArCell :
cells)
202 gblLArCellContainer->push_back(std::move(gblLArCell));
204 gblLArCellContainer->setFeb2Flags(feb2Name, inOverflow, inError);
206 ATH_MSG_DEBUG(
"Global is receiving a total of " << gblLArCellContainer->size() <<
" LAr cells in this event");
209 ATH_CHECK( h_gblLArCellContainer.
record( std::move(gblLArCellContainer) ) );
211 return StatusCode::SUCCESS;
231 for (
int i = 1;
i <= 3; ++
i) {
237 float encoded_energy = -1;
249 return std::pair<float,boost::dynamic_bitset<>>(encoded_energy,energy_bits);
258 std::sort(
cells.begin(),
cells.end(), [](
const auto&
a,
const auto&
b) {
259 return a.getChannel() < b.getChannel(); });
265 return StatusCode::SUCCESS;
std::unique_ptr< GlobalSim::GlobalLArCellContainer > m_gblLArCellContainerTemplate
GlobalLArCellContainer template which is constructed in initialize and used in execute.
Gaudi::Property< int > m_valueGainFactor
std::map< int, GlobalSim::GlobalLArCell > m_gblLArCellMap
LAr cell map where the key is the offline cell ID.
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Key to the total noise used for each CaloCell.
int m_readoutRanges[5]
array holding the energy edges of the multilinear encoding
Gaudi::Property< int > m_valueLSB
void setEnergy(float energy)
set transverse energy in MeV
void setSigma(float sigma)
set significancy of energy deposit
void setBoardConnector(std::string connector, std::string type, int number, int fiber)
set properties of associated board connector
virtual StatusCode initialize() override
initialize function running before first event
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
int m_stepsPerRange
number of discrete values per multilinear energy encoding range
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & getFEB2() const
get the name of the FEB2 this cell is associated with
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Gaudi::Property< int > m_numberOfEnergyBits
Parameters defining the multilinear energy encoding scheme.
std::pair< float, boost::dynamic_bitset<> > encodeEnergy(float energy) const
Function to simulate the cell energy as seen by Global.
SG::ReadHandleKey< CaloCellContainer > m_caloCellsKey
Key to the CaloCell container.
::StatusCode StatusCode
StatusCode definition for legacy code.
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual StatusCode execute(const EventContext &) const override
execute function running for every event
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Gaudi::Property< std::string > m_LArCellMap
Path to the LAr cell map in the CVMFS GroupData space.
std::string to_string(const DetectorType &type)
StatusCode initialize(bool used=true)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
unsigned m_maxCellsPerFEB
maximum number of cells that can be send to Global for each FEB2
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
StatusCode removeCellsFromOverloadedFEB(std::vector< GlobalSim::GlobalLArCell > &cells) const
Function to simulate the truncation of overflowing FEB2s.
void setLASP(std::string laspname)
set name of associated LASP
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Key for the EventInfo object.
void setMUX(std::string muxname)
set name of associated MUX
void setPosition(float eta, float phi)
set position of cell in eta-phi space
constexpr int pow(int base, int exp) noexcept
SG::WriteHandleKey< GlobalSim::GlobalLArCellContainer > m_LArCellContainerKey
Key to writing the GlobalLArCellContainer to StoreGate.