40 if (!
m_writeAllCells)
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");
47 for (
int i = 0; i < 3; ++i) {
80 std::ifstream
file(cellMapPath.c_str());
87 int online_id, offline_id, ch, con_num, fbr;
88 std::string feb, con_type;
91 std::getline(
file, feb);
96 file >> offline_id >> online_id >> feb >> ch >> con_type >> con_num >> fbr;
98 if (
file.eof())
break;
101 caloCell.
id = offline_id;
104 caloCell.
fiber = fbr;
108 m_gepCellsBase.insert(std::pair<unsigned int, Gep::GepCaloCell>(caloCell.
id, caloCell));
114 ATH_MSG_ERROR(
"Could not open file containing the cell to FEB association");
115 return StatusCode::FAILURE;
118 ATH_MSG_DEBUG(
"Loaded FEB information for " << n_cells <<
" cells");
121 return StatusCode::SUCCESS;
139 CHECK(h_caloCells.isValid());
140 const auto & cells = *h_caloCells;
142 ATH_MSG_DEBUG(
"Read in " + std::to_string(h_caloCells->size()) +
" cells");
145 if (!electronicNoiseHdl.
isValid()) {
return StatusCode::FAILURE;}
146 const CaloNoise* electronicNoiseCDO = *electronicNoiseHdl;
149 if (!totalNoiseHdl.
isValid()) {
return StatusCode::FAILURE;}
150 const CaloNoise* totalNoiseCDO = *totalNoiseHdl;
153 std::map<std::string,std::vector<Gep::GepCaloCell>> gepCellsPerFEB;
155 for(
const auto *cell: cells){
160 caloCell.
id = (cell->ID().get_identifier32()).get_compact();
162 if (base_cell_itr !=
m_gepCellsBase.end()) caloCell = base_cell_itr->second;
166 caloCell.
FEB =
"Tile";
169 float electronicNoise = electronicNoiseCDO->
getNoise(cell->ID(), cell->gain());
170 float totalNoise = totalNoiseCDO->
getNoise(cell->ID(), cell->gain());
173 if (((cell->energy() / totalNoise) < 2.0) && !
m_writeAllCells)
continue;
176 caloCell.
offline_et = cell->energy() / TMath::CosH(cell->eta());
178 caloCell.
et =
getGepEnergy(cell->energy() / TMath::CosH(cell->eta()));
179 caloCell.
e = caloCell.
et * TMath::CosH(cell->eta());
182 caloCell.
e = cell->energy();
185 caloCell.
time = cell->time();
186 caloCell.
quality = cell->quality();
191 caloCell.
sigma = cell->energy() / totalNoise;
193 caloCell.
isBad = cell->badcell();
194 caloCell.
eta = cell->eta();
195 caloCell.
phi = cell->phi();
196 caloCell.
sinTh = cell->sinTh();
197 caloCell.
cosTh = cell->cosTh();
198 caloCell.
sinPhi = cell->sinPhi();
199 caloCell.
cosPhi = cell->cosPhi();
200 caloCell.
cotTh = cell->cotTh();
201 caloCell.
x = cell->x();
202 caloCell.
y = cell->y();
203 caloCell.
z = cell->z();
205 unsigned int samplingEnum =
m_CaloCell_ID->calo_sample(cell->ID());
208 bool IsEM_Barrel=
false;
209 bool IsEM_EndCap=
false;
210 bool IsEM_BarrelPos=
false;
211 bool IsEM_BarrelNeg=
false;
215 if(
m_CaloCell_ID->pos_neg(cell->ID())>0) IsEM_BarrelPos=
true;
220 caloCell.
isEM = IsEM;
233 caloCell.
id = (cell->ID().get_identifier32()).get_compact();
236 caloCell.
layer = cell->caloDDE()->getLayer();
238 float deta = elt->
deta();
239 float dphi = elt->
dphi();
241 float etamin = caloCell.
eta - (0.5*deta);
242 float etamax = caloCell.
eta + (0.5*deta);
244 float phimin = caloCell.
phi - (0.5*dphi);
245 float phimax = caloCell.
phi + (0.5*dphi);
254 caloCell.
index = idx;
257 auto feb_itr = gepCellsPerFEB.find(caloCell.
FEB);
258 if (feb_itr != gepCellsPerFEB.end()) feb_itr->second.push_back(std::move(caloCell));
260 std::vector<Gep::GepCaloCell> cellsThisFEB;
261 cellsThisFEB.push_back(caloCell);
262 gepCellsPerFEB.insert(std::pair<std::string,std::vector<Gep::GepCaloCell>>(caloCell.
FEB,cellsThisFEB));
269 auto itr = gepCellsPerFEB.begin();
270 int nFeb2sInOverflow = 0;
271 for ( ;itr != gepCellsPerFEB.end(); ++itr) {
275 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.");
280 gepCellMap.
insert(cell.id, cell);
282 ATH_MSG_DEBUG(
"GEP is receiving a total of " << gepCellMap.
size() <<
" cells in this event");
286 ATH_CHECK( h_gepCellMap.
record( std::make_unique<Gep::GepCellMap>(gepCellMap) ) );
288 return StatusCode::SUCCESS;
299 int readoutRange = 0;
300 for (
int i = 1; i <= 3; ++i) {
319 const EventContext&)
const {
322 std::vector<IdentifierHash> cellNeighbours;
327 std::vector<unsigned int> neighbour_ids;
328 for (
unsigned int iNeighbour = 0;
329 iNeighbour < cellNeighbours.size();
341 return neighbour_ids;
348 std::map<int,Gep::GepCaloCell> orderedCells;
350 orderedCells.insert(std::pair<int,Gep::GepCaloCell>(cell.channel,cell));
354 std::map<int,Gep::GepCaloCell>::iterator cell_itr = orderedCells.begin();
355 for ( ;cell_itr != orderedCells.end(); ++cell_itr) {
356 cells.push_back(cell_itr->second);
360 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_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