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");
46 ATH_MSG_ERROR(
"Cannot use CleanOutputCells without WriteAllCells");
47 return StatusCode::FAILURE;
56 for (
int i = 0; i < 3; ++i) {
89 std::ifstream
file(cellMapPath.c_str());
96 int online_id, offline_id, ch, con_num, fbr;
97 std::string feb, con_type;
100 std::getline(
file, feb);
105 file >> offline_id >> online_id >> feb >> ch >> con_type >> con_num >> fbr;
107 if (
file.eof())
break;
110 caloCell.
id = offline_id;
113 caloCell.
fiber = fbr;
117 m_gepCellsBase.insert(std::pair<unsigned int, Gep::GepCaloCell>(caloCell.
id, caloCell));
123 ATH_MSG_ERROR(
"Could not open file containing the cell to FEB association");
124 return StatusCode::FAILURE;
127 ATH_MSG_DEBUG(
"Loaded FEB information for " << n_cells <<
" cells");
130 return StatusCode::SUCCESS;
148 CHECK(h_caloCells.isValid());
149 const auto & cells = *h_caloCells;
151 ATH_MSG_DEBUG(
"Read in " + std::to_string(h_caloCells->size()) +
" cells");
154 if (!electronicNoiseHdl.
isValid()) {
return StatusCode::FAILURE;}
155 const CaloNoise* electronicNoiseCDO = *electronicNoiseHdl;
158 if (!totalNoiseHdl.
isValid()) {
return StatusCode::FAILURE;}
159 const CaloNoise* totalNoiseCDO = *totalNoiseHdl;
162 std::map<std::string,std::vector<Gep::GepCaloCell>> gepCellsPerFEB;
164 for(
const auto *cell: cells){
169 caloCell.
id = (cell->ID().get_identifier32()).get_compact();
171 if (base_cell_itr !=
m_gepCellsBase.end()) caloCell = base_cell_itr->second;
175 caloCell.
FEB =
"Tile";
178 float electronicNoise = electronicNoiseCDO->
getNoise(cell->ID(), cell->gain());
179 float totalNoise = totalNoiseCDO->
getNoise(cell->ID(), cell->gain());
182 const bool pass_2sigma = cell->energy() / totalNoise >= 2.0;
188 caloCell.
offline_et = energy / TMath::CosH(cell->eta());
191 caloCell.
e = caloCell.
et * TMath::CosH(cell->eta());
197 caloCell.
time = cell->time();
198 caloCell.
quality = cell->quality();
203 caloCell.
sigma = cell->energy() / totalNoise;
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();
217 unsigned int samplingEnum =
m_CaloCell_ID->calo_sample(cell->ID());
220 bool IsEM_Barrel=
false;
221 bool IsEM_EndCap=
false;
222 bool IsEM_BarrelPos=
false;
223 bool IsEM_BarrelNeg=
false;
227 if(
m_CaloCell_ID->pos_neg(cell->ID())>0) IsEM_BarrelPos=
true;
232 caloCell.
isEM = IsEM;
245 caloCell.
id = (cell->ID().get_identifier32()).get_compact();
248 caloCell.
layer = cell->caloDDE()->getLayer();
250 float deta = elt->
deta();
251 float dphi = elt->
dphi();
253 float etamin = caloCell.
eta - (0.5*deta);
254 float etamax = caloCell.
eta + (0.5*deta);
256 float phimin = caloCell.
phi - (0.5*dphi);
257 float phimax = caloCell.
phi + (0.5*dphi);
266 caloCell.
index = idx;
269 auto feb_itr = gepCellsPerFEB.find(caloCell.
FEB);
270 if (feb_itr != gepCellsPerFEB.end()) feb_itr->second.push_back(std::move(caloCell));
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));
281 auto itr = gepCellsPerFEB.begin();
282 int nFeb2sInOverflow = 0;
283 for ( ;itr != gepCellsPerFEB.end(); ++itr) {
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.");
292 gepCellMap.
insert(cell.id, cell);
294 ATH_MSG_DEBUG(
"GEP is receiving a total of " << gepCellMap.
size() <<
" cells in this event");
298 ATH_CHECK( h_gepCellMap.
record( std::make_unique<Gep::GepCellMap>(gepCellMap) ) );
300 return StatusCode::SUCCESS;
311 int readoutRange = 0;
312 for (
int i = 1; i <= 3; ++i) {
331 const EventContext&)
const {
334 std::vector<IdentifierHash> cellNeighbours;
339 std::vector<unsigned int> neighbour_ids;
340 for (
unsigned int iNeighbour = 0;
341 iNeighbour < cellNeighbours.size();
353 return neighbour_ids;
360 std::map<int,Gep::GepCaloCell> orderedCells;
362 orderedCells.insert(std::pair<int,Gep::GepCaloCell>(cell.channel,cell));
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);
371 cells.back().offline_et = 0;
377 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Data object for each calorimeter readout cell.
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
double deta() const
delta eta
double dphi() const
delta phi
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
std::map< unsigned int, Gep::GepCaloCell > m_gepCellsBase
Gaudi::Property< std::string > m_GepEnergyEncodingScheme
Gaudi::Property< bool > m_cleanOutputCells
Gaudi::Property< bool > m_doTruncationOfOverflowingFEBs
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_LArCellMap
GepCellsHandlerAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Gaudi::Property< bool > m_writeAllCells
StatusCode setG(int value)
StatusCode setNumberOfEnergyBits(int value)
unsigned m_maxCellsPerFEB
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
StatusCode setLeastSignificantBit(int value)
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)
void insert(unsigned int id, const Gep::GepCaloCell &cell)
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
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())
std::string connection_type
std::vector< unsigned int > neighbours