31 ATH_MSG_INFO(
"L1CaloFEXTools/gFexTower2SCellDecorator::initialize()");
52 return StatusCode::SUCCESS;
61 return StatusCode::FAILURE;
66 if(!triggerTowerContainer.
isValid()) {
67 ATH_MSG_FATAL(
"Could not retrieve collection " << triggerTowerContainer.
key() );
68 return StatusCode::FAILURE;
75 return StatusCode::FAILURE;
79 ATH_MSG_WARNING(
"Nothing to decorate here, at least one container is empty. ScellContainer.size="<<ScellContainer->size() <<
" or gTowerContainer.size=" <<
gTowerContainer->
size() <<
" or triggerTowerContainer.size=" << triggerTowerContainer->size() );
80 return StatusCode::SUCCESS;
84 std::unordered_map< uint64_t, const CaloCell*> map_ScellID2ptr;
86 for(
const CaloCell* scell : *ScellContainer){
87 const uint64_t
ID = scell->ID().get_compact();
88 map_ScellID2ptr[
ID] = scell;
92 std::unordered_map< uint32_t, const xAOD::TriggerTower*> map_TileID2ptr;
97 if(std::abs(tower->eta())>1.5 || tower->sampling()!=1)
continue;
98 map_TileID2ptr[tower->coolId()]=tower;
117 uint32_t gFexID =
gTower->gFEXtowerID();
118 uint16_t gFexEt =
gTower->towerEt();
119 uint16_t scSumEtEncoded = 0;
121 std::vector<float> scEt;
122 std::vector<float> scEta;
123 std::vector<float> scPhi;
124 std::vector<int> scID;
125 std::vector<int> scSample;
127 std::vector<int> TileEt;
128 std::vector<float> TileEta;
129 std::vector<float> TilePhi;
135 ATH_MSG_ERROR(
"ID: "<<gFexID<<
" not found on map m_map_TTower2SCells");
136 return StatusCode::FAILURE;
139 for (
auto const& SCellID : it_TTower2SCells->second ) {
142 auto it_ScellID2ptr = map_ScellID2ptr.find(SCellID);
143 if(it_ScellID2ptr == map_ScellID2ptr.end()) {
144 ATH_MSG_WARNING(
"Scell ID: 0x"<<std::hex<<(SCellID >> 32)<<std::dec<<
" not found on map map_ScellID2ptr");
146 scEt.push_back(-9999);
147 scEta.push_back(-99);
148 scPhi.push_back(-99);
150 scID.push_back( SCellID >> 32 );
151 scSample.push_back(-99);
157 const CaloCell* myCell = it_ScellID2ptr->second;
158 float et = myCell->
et();
163 int prov = (myCell)->provenance();
164 int SCprov = prov&0xFFF;
165 bool isMasked = (SCprov&0x80)==0x80;
169 scEta.push_back(myCell->
eta());
170 scPhi.push_back(myCell->
phi());
172 scID.push_back( SCellID >> 32 );
173 scSample.push_back(sample);
179 float tmpSCellEt = 0;
180 for(
const auto& tmpet : scEt){
187 gTowerSCellEt (*
gTower) = std::move(scEt);
188 gTowerSCellEta (*
gTower) = std::move(scEta);
189 gTowerSCellPhi (*
gTower) = std::move(scPhi);
190 gTowerSCellID (*
gTower) = std::move(scID);
191 gTowerSCellSample (*
gTower) = std::move(scSample);
192 gTowerEtMeV (*
gTower) = gFexEt * 200;
193 gTowerSCEtEncoded (*
gTower) = scSumEtEncoded;
202 for (
auto const& TileTowerID : it_TTower2Tile->second ) {
205 auto it_TileID2ptr = map_TileID2ptr.find(TileTowerID);
206 if(it_TileID2ptr == map_TileID2ptr.end()) {
210 TileEt.push_back(-9999);
211 TileEta.push_back(-99);
212 TilePhi.push_back(-99);
218 TileEt.push_back(tileTower->
jepET()*1000);
219 TileEta.push_back(tileTower->
eta());
221 TilePhi.push_back(
phi);
222 TileID.push_back(TileTowerID);
231 gTowerTileEt (*
gTower) = std::move(TileEt);
233 gTowerTileEta (*
gTower) = std::move(TileEta);
234 gTowerTilePhi (*
gTower) = std::move(TilePhi);
238 return StatusCode::SUCCESS;
246 std::ifstream myfile(fileName);
248 if ( !myfile.is_open() ){
250 return StatusCode::FAILURE;
254 while ( std::getline (myfile, myline) ) {
255 std::vector<uint64_t> SCellvector;
259 myline.erase(myline.begin(), std::find_if(myline.begin(), myline.end(), [](
int ch) {
260 return !std::isspace(ch);
262 if(myline[0] ==
'#')
continue;
265 std::stringstream oneSCellID(myline);
268 std::string substr =
"";
272 while(std::getline(oneSCellID, substr,
' '))
276 TTID = std::stoi(substr);
281 return StatusCode::FAILURE;
285 uint64_t scid_uint64 = std::strtoull(substr.c_str(),
nullptr, 0);
288 if(scid_uint64 == 0xffffffffffffffff)
continue;
290 SCellvector.push_back(scid_uint64);
299 return StatusCode::SUCCESS;
305 if (
ID.find(
"0x") == std::string::npos) {
306 ATH_MSG_ERROR(
"Invalid SuperCell ID " <<
ID <<
". Expecting hexadecimal number on the mapping file");
318 std::ifstream myfile(fileName);
320 if ( !myfile.is_open() ){
322 return StatusCode::FAILURE;
326 while ( std::getline (myfile, myline) ) {
328 std::vector<uint32_t> Tilevector;
331 myline.erase(myline.begin(), std::find_if(myline.begin(), myline.end(), [](
int ch) {
332 return !std::isspace(ch);
334 if(myline[0] ==
'#')
continue;
337 std::stringstream oneTileID(myline);
340 std::string substr =
"";
344 while(std::getline(oneTileID, substr,
' ')){
347 gTowerID = std::stoi(substr);
350 uint32_t tileid_uint32 = std::strtoul(substr.c_str(),
nullptr, 0);
351 Tilevector.push_back(tileid_uint32);
360 return StatusCode::SUCCESS;
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::vector< Identifier > ID
An algorithm that can be simultaneously executed in multiple threads.
Data object for each calorimeter readout cell.
virtual double phi() const override final
get phi (through CaloDetDescrElement)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
virtual double et() const override final
get et
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
static unsigned int compress(float Energy)
Compress data.
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gTileIDdecorKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gTileEtadecorKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gtowerEtMeVdecorKey
std::unordered_map< uint32_t, std::vector< uint64_t > > m_map_TTower2SCells
Gaudi::Property< std::string > m_gFEX2Scellmapping
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gSCellPhidecorKey
gFexTower2SCellDecorator(const std::string &name, ISvcLocator *svc)
SG::ReadHandleKey< CaloCellContainer > m_SCellKey
std::unordered_map< uint32_t, std::vector< uint32_t > > m_map_TTower2Tile
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gSCellEtadecorKey
Gaudi::Property< std::string > m_gFEX2Tilemapping
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gTowersReadKey
virtual StatusCode initialize() override
Function initialising the algorithm.
bool isBadSCellID(const std::string &) const
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gSCellSampledecorKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gSCellEtdecorKey
StatusCode ReadTilefromFile(const std::string &)
StatusCode ReadSCfromFile(const std::string &)
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gTilePhidecorKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gTowerEtdecorKey
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gTileEtMeVdecorKey
virtual StatusCode execute(const EventContext &) const override
Function executing the algorithm.
SG::WriteDecorHandleKey< xAOD::gFexTowerContainer > m_gSCellIDdecorKey
The gTower class is an interface object for gFEX trigger algorithms The purposes are twofold:
static std::string find_calib_file(const std::string &logical_file_name)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
Helper class for TileCal offline identifiers.
uint8_t jepET() const
get jepET from peak of lut_jep
virtual double eta() const final
The pseudorapidity ( ) of the particle.
virtual double phi() const final
The azimuthal angle ( ) of the particle.
std::string find(const std::string &s)
return a remapped string
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
gFexTower_v1 gFexTower
Define the latest version of the TriggerTower class.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Extra patterns decribing particle interation process.