ATLAS Offline Software
TauPi0CreateROI.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS
6 
7 #include "TauPi0CreateROI.h"
9 
10 #include "CaloUtils/CaloCellList.h"
11 #include <memory>
12 
15 }
16 
17 
18 
20 
24  ATH_MSG_INFO("Find Pi0 in context: " << (inEleRM() ? "`EleRM`" : "`Standard`") << ", with Electron cell removal Flag: " << m_removeElectronCells);
25  return StatusCode::SUCCESS;
26 }
27 
28 
29 
30 StatusCode TauPi0CreateROI::executePi0CreateROI(xAOD::TauJet& tau, CaloConstCellContainer& pi0CellContainer, boost::dynamic_bitset<>& addedCellsMap) const {
31 
32  // only run on 0-5 prong taus
33  if (!tauRecTools::doPi0andShots(tau)) {
34  return StatusCode::SUCCESS;
35  }
36 
38  if (!caloCellInHandle.isValid()) {
39  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << caloCellInHandle.key());
40  return StatusCode::FAILURE;
41  }
42 
43  const CaloCellContainer *cellContainer = caloCellInHandle.cptr();
44  std::vector<const CaloCell*> removed_cells;
47  if (!removedClustersHandle.isValid()){
48  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << removedClustersHandle.key());
49  return StatusCode::FAILURE;
50  }
51  const xAOD::CaloClusterContainer *removed_clusters_cont = removedClustersHandle.cptr();
52 
53  for (auto cluster : *removed_clusters_cont){
54  for(auto cell_it = cluster->cell_cbegin(); cell_it != cluster->cell_cend(); cell_it++){
55  removed_cells.push_back(*cell_it);
56  }
57  }
58  }
59 
61  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
62 
63  // get only EM cells within dR < 0.4
64  // TODO: change hardcoded 0.4 to meaningful variable
65  std::vector<CaloCell_ID::SUBCALO> emSubCaloBlocks;
66  emSubCaloBlocks.push_back(CaloCell_ID::LAREM);
67  std::unique_ptr<CaloCellList> cellList = std::make_unique<CaloCellList>(caloDDMgr, cellContainer, emSubCaloBlocks);
68  // FIXME: tau p4 is corrected to point at tau vertex, but the cells are not
69  cellList->select(tau.eta(), tau.phi(), 0.4);
70 
71  for (const CaloCell* cell : *cellList) {
72  // only keep cells that are in Ecal (PS, EM1, EM2 and EM3, both barrel and endcap).
73  int sampling = cell->caloDDE()->getSampling();
74  if (sampling > 7) continue;
75  // if in EleRM, check the clusters do not include electron activities
76  if (m_removeElectronCells && inEleRM() && std::find(removed_cells.cbegin(), removed_cells.cend(), cell) != removed_cells.cend()) continue;
77  // Store cell in output container
78  const IdentifierHash cellHash = cell->caloDDE()->calo_hash();
79 
80  if (!addedCellsMap.test(cellHash)) {
81  pi0CellContainer.push_back(cell);
82  addedCellsMap.set(cellHash);
83  }
84  }
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 #endif
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellList::select
void select(double eta, double phi, double deta, double dphi)
Definition: CaloCellList.cxx:78
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
xAOD::TauJet_v3::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
CaloCellList.h
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
TauPi0CreateROI::TauPi0CreateROI
TauPi0CreateROI(const std::string &name)
Definition: TauPi0CreateROI.cxx:13
TauPi0CreateROI.h
TauRecToolBase::inEleRM
bool inEleRM() const
Definition: TauRecToolBase.h:89
xAOD::TauJet_v3::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
tauRecTools::doPi0andShots
bool doPi0andShots(const xAOD::TauJet &tau)
Determines whether pi0s and shots should be built for a tau candidate.
Definition: Reconstruction/tauRecTools/Root/HelperFunctions.cxx:93
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
TauPi0CreateROI::m_removeElectronCells
Gaudi::Property< bool > m_removeElectronCells
Definition: TauPi0CreateROI.h:43
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TauPi0CreateROI::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: TauPi0CreateROI.h:46
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
WriteCellNoiseToCool.cellHash
cellHash
Definition: WriteCellNoiseToCool.py:433
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TauPi0CreateROI::m_removedClusterInputContainer
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_removedClusterInputContainer
Definition: TauPi0CreateROI.h:47
TauPi0CreateROI::executePi0CreateROI
virtual StatusCode executePi0CreateROI(xAOD::TauJet &pTau, CaloConstCellContainer &Pi0CellContainer, boost::dynamic_bitset<> &map) const override
Definition: TauPi0CreateROI.cxx:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
HelperFunctions.h
TauPi0CreateROI::initialize
virtual StatusCode initialize() override
Tool initializer.
Definition: TauPi0CreateROI.cxx:19
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:43
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
TauPi0CreateROI::m_caloCellInputContainer
SG::ReadHandleKey< CaloCellContainer > m_caloCellInputContainer
Definition: TauPi0CreateROI.h:45