 |
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));
176 auto feb2_itr = gblLArCellsPerFEB2.find(gblLArCell.
getFEB2());
177 if (feb2_itr != gblLArCellsPerFEB2.end()) feb2_itr->second.push_back(gblLArCell);
179 std::vector<GlobalSim::GlobalLArCell> cellsThisFEB;
180 cellsThisFEB.push_back(gblLArCell);
181 gblLArCellsPerFEB2.insert(std::pair<std::string,std::vector<GlobalSim::GlobalLArCell>>(gblLArCell.
getFEB2(),cellsThisFEB));
187 auto gblLArCellContainer = std::make_unique<GlobalSim::GlobalLArCellContainer>(templateRef);
190 for (
auto& [feb2Name,
cells] : gblLArCellsPerFEB2) {
193 bool inOverflow =
false;
194 bool inError =
false;
198 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.");
203 for (
auto& gblLArCell :
cells)
204 gblLArCellContainer->push_back(std::move(gblLArCell));
206 gblLArCellContainer->setFeb2Flags(feb2Name, inOverflow, inError);
208 ATH_MSG_DEBUG(
"Global is receiving a total of " << gblLArCellContainer->size() <<
" LAr cells in this event");
211 ATH_CHECK( h_gblLArCellContainer.
record( std::move(gblLArCellContainer) ) );
213 return StatusCode::SUCCESS;
234 for (
int i = 1;
i <= 3; ++
i) {
240 float encoded_energy = -1;
252 return std::pair<float,boost::dynamic_bitset<>>(encoded_energy,energy_bits);
261 std::sort(
cells.begin(),
cells.end(), [](
const auto&
a,
const auto&
b) {
262 return a.getChannel() < b.getChannel(); });
268 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
void setSampling(int sampling)
set sampling of cell
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
std::string to_string(const SectorProjector proj)
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 that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
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.
void setLayer(int layer)
set layer of cell
::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.
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.