ATLAS Offline Software
MissingCellListTool.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // MissingCellListTool.cxx
8 // Implementation file for class MissingCellListTool
9 // Author: S.Binet<binet@cern.ch>
11 
12 // JetMomentTools includes
14 // FrameWork includes
16 // StoreGate
18 #include "StoreGate/WriteHandle.h"
19 
20 //
23 
24 
25 
26 // ///////////////////////////////////////////////////////////////////
27 // // Public methods:
28 // ///////////////////////////////////////////////////////////////////
29 
30 // Constructors
33  asg::AsgTool ( name ),
34  m_tileCabling("TileCablingSvc",name),
35  m_tileTool("TileBadChanTool",this)
36 {
37 
38  //declareInterface<IMissingCellListTool>( this );
39 
40  declareProperty("AddCellList", m_userAddedCells);
41  declareProperty("RemoveCellList", m_userRemovedCells );
42  declareProperty("AddBadCells", m_addBadCells=true );
43  declareProperty("DeltaRmax", m_rmax=1.0);
44  // ported from JetBadChanCorrTool
45  declareProperty("AddCellFromTool", m_addCellFromTool = false);
46  //608517, deadReadout | deadPhys | missingFEB | highNoiseHG | highNoiseMG | highNoiseLG | spor adicBurstNoise
47  declareProperty("LArMaskBit", m_larMaskBit = ( 1<< 0 | 1<< 2 | 1<<16 | 1<<8 | 1<<11 | 1<<14 | 1<<19 ));
48  declareProperty("TileMaskBit", m_tileMaskBit = ( 1<< 0 )); //1, dead
49 }
50 
51 // Destructor
54 = default;
55 
56 // Athena algtool's Hooks
59 {
60  ATH_MSG_INFO ("Initializing " << name() << "...");
61  CHECK( m_tileCabling.retrieve() );
62  //
66  ATH_CHECK(m_BCKey.initialize(m_addCellFromTool));
67  if (m_addCellFromTool) {
68  ATH_CHECK( m_tileTool.retrieve() );
69  } else {
70  m_tileTool.disable();
71  }
72  return StatusCode::SUCCESS;
73 }
74 
76 {
77  ATH_MSG_INFO ("Finalizing " << name() << "...");
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 
84 
85  //cellset_t missingCells;
86  auto badandmissingCellsGeomMap = std::make_unique<jet::CaloCellFastMap>();
87  jet::cellset_t & badandmissingCells = badandmissingCellsGeomMap->cells();
88  badandmissingCellsGeomMap->init(m_rmax);
89 
90  // get permanently missing cells.
91  const std::vector<Identifier> & tiledisconnected = m_tileCabling->disconnectedCells();
92  badandmissingCells.insert(tiledisconnected.begin(), tiledisconnected.end());
93 
94  // from user given cells
95  for(cellidvec_t::const_iterator it=m_userAddedCells.begin(); it != m_userAddedCells.end(); ++it){
96  badandmissingCells.insert( Identifier(*it) ) ;
97  }
98  // remove user give cells.
99  for(cellidvec_t::const_iterator it=m_userRemovedCells.begin(); it != m_userRemovedCells.end(); ++it){
100  badandmissingCells.erase( Identifier(*it) );
101  }
102  // ---------------------------
103 
105  const CaloDetDescrManager* caloDDM = *caloDetDescrMgrHandle;
106 
107  if(m_addBadCells) {
108  // (In run1 this part possibly added several times the same cell in the geometric map)
110  if ( !cc.isValid() ) {
111  ATH_MSG_ERROR("Unable to retrieve CaloCellContainer AllCalo from event store.");
112  return 1;
113  }
114  const CaloCellContainer * cells = cc.ptr();
117  for(; it!=itE; ++it){
118  if( (*it)->badcell() ) {
119  const CaloCell * c= *it;
120  badandmissingCells.insert( c->ID() );
121  }
122  }
123  }
124 
125 
126  if(m_addCellFromTool){
127  const CaloCell_ID* calo_id = caloDDM->getCaloCell_ID();
128  const TileBadChanTool* tileTool = dynamic_cast<const TileBadChanTool*>(m_tileTool.operator->());
130  const LArBadChannelCont *bcCont {*readHandle};
131  if(!bcCont) {
132  ATH_MSG_ERROR( "Do not have Bad chan container !!!" );
133  return 1;
134  }
135  std::vector<Identifier>::const_iterator idItr = calo_id->cell_begin();
136  std::vector<Identifier>::const_iterator idItrE = calo_id->cell_end();
137  for(; idItr!=idItrE; ++idItr){
138 
139  // check if needs insertion.
140  bool insert = false;
141  if(calo_id->is_tile(*idItr)){
142  CaloBadChannel bc = tileTool->caloStatus(*idItr);
143  insert = (bc.packedData() & m_tileMaskBit) != 0 ;
144  } else {
145  LArBadChannel bc = bcCont->offlineStatus(*idItr);
146  insert = (bc.packedData() & m_larMaskBit) != 0 ;
147  }
148 
149  if(insert) {
150  badandmissingCells.insert( *idItr );
151  }
152  }
153  }
154 
155  // fill the geometric map : ------------------
156  jet::cellset_t::iterator lit = badandmissingCells.begin();
157  jet::cellset_t::iterator litE = badandmissingCells.end();
158  for( ; lit != litE; ++lit){
159  const CaloDetDescrElement * dde = caloDDM->get_element(*lit);
160  jet::CellPosition p(dde->eta(), dde->phi(), *lit, dde->getSampling());
161  badandmissingCellsGeomMap->insert( p );
162  }
163  // ---------------------------
164 
165 
166  ATH_MSG( DEBUG ) << " total bad and missing "<< badandmissingCells.size() << " "<< badandmissingCellsGeomMap->size() << endmsg;
167 
169  StatusCode sc = badCellMap.record(std::move(badandmissingCellsGeomMap));
170  if (sc.isFailure()) {
171  ATH_MSG_ERROR("Unable to record badandmissingCellsGeomMap in event store: "
172  << m_badCellMap_key);
173  return 1;
174  }
175 
176  return 0;
177 }
178 
MissingCellListTool::m_rmax
double m_rmax
Definition: MissingCellListTool.h:166
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TileBadChanTool::caloStatus
virtual CaloBadChannel caloStatus(const EventContext &ctx, Identifier cell_id) const override
Definition: TileBadChanTool.cxx:85
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG
#define ATH_MSG(lvl)
Definition: AthMsgStreamMacros.h:38
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
MissingCellListTool::MissingCellListTool
MissingCellListTool(const std::string &name)
Default constructor:
Definition: MissingCellListTool.cxx:32
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MissingCellListTool.h
MissingCellListTool::m_cells_name
SG::ReadHandleKey< CaloCellContainer > m_cells_name
Definition: MissingCellListTool.h:186
MissingCellListTool::m_tileCabling
ServiceHandle< TileCablingSvc > m_tileCabling
Definition: MissingCellListTool.h:173
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MissingCellListTool::m_tileMaskBit
unsigned int m_tileMaskBit
Definition: MissingCellListTool.h:171
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
MissingCellListTool::~MissingCellListTool
virtual ~MissingCellListTool()
Destructor:
skel.it
it
Definition: skel.GENtoEVGEN.py:423
asg
Definition: DataHandleTestTool.h:28
MissingCellListTool::m_userAddedCells
cellidvec_t m_userAddedCells
Definition: MissingCellListTool.h:163
CaloCell_Base_ID::cell_end
id_iterator cell_end(void) const
end iterator over full set of Identifiers (LAr + Tiles)
MissingCellListTool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: MissingCellListTool.cxx:58
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
TileBadChanTool.h
ReadCondHandle.h
TruthTest.itE
itE
Definition: TruthTest.py:25
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
MissingCellListTool::m_caloDetDescrMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Definition: MissingCellListTool.h:179
WriteHandle.h
Handle class for recording to StoreGate.
jet::CellPosition
Definition: MissingCellListTool.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MissingCellListTool::m_larMaskBit
unsigned int m_larMaskBit
Definition: MissingCellListTool.h:170
LArBadChannel
Definition: LArBadChannel.h:10
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloCell_Base_ID::cell_begin
id_iterator cell_begin(void) const
begin iterator over full set of Identifiers (LAr + Tiles)
MissingCellListTool::execute
virtual int execute() const
Method to be called for each event.
Definition: MissingCellListTool.cxx:83
MissingCellListTool::m_badCellMap_key
SG::WriteHandleKey< jet::CaloCellFastMap > m_badCellMap_key
Definition: MissingCellListTool.h:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MissingCellListTool::m_tileTool
ToolHandle< ITileBadChanTool > m_tileTool
Definition: MissingCellListTool.h:174
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LArBadChannel::packedData
BitWord packedData() const
Definition: LArBadChannel.h:143
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloBadChannel::packedData
BitWord packedData() const
Definition: CaloBadChannel.h:32
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
MissingCellListTool::m_userRemovedCells
cellidvec_t m_userRemovedCells
Definition: MissingCellListTool.h:162
MissingCellListTool::m_BCKey
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
Definition: MissingCellListTool.h:175
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
MissingCellListTool::m_addBadCells
bool m_addBadCells
Definition: MissingCellListTool.h:168
TileBadChanTool
The tool to get Tile channel and ADC status.
Definition: TileBadChanTool.h:36
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloBadChannel
Definition: CaloBadChannel.h:8
CaloDetDescrManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
Definition: CaloDetDescrManager.cxx:1590
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
ITileBadChanTool.h
MissingCellListTool::m_addCellFromTool
bool m_addCellFromTool
Definition: MissingCellListTool.h:169
python.compressB64.c
def c
Definition: compressB64.py:93
jet::cellset_t
std::unordered_set< Identifier > cellset_t
Definition: MissingCellListTool.h:86
MissingCellListTool::finalize
virtual StatusCode finalize()
Definition: MissingCellListTool.cxx:75
python.handimod.cc
int cc
Definition: handimod.py:523