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 
12 #include <boost/scoped_ptr.hpp>
13 
14 
15 
18 }
19 
20 
21 
23 
27  ATH_MSG_INFO("Find Pi0 in context: " << (inEleRM() ? "`EleRM`" : "`Standard`") << ", with Electron cell removal Flag: " << m_removeElectronCells);
28  return StatusCode::SUCCESS;
29 }
30 
31 
32 
33 StatusCode TauPi0CreateROI::executePi0CreateROI(xAOD::TauJet& tau, CaloConstCellContainer& pi0CellContainer, boost::dynamic_bitset<>& addedCellsMap) const {
34 
35  // only run on 0-5 prong taus
36  if (!tauRecTools::doPi0andShots(tau)) {
37  return StatusCode::SUCCESS;
38  }
39 
41  if (!caloCellInHandle.isValid()) {
42  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << caloCellInHandle.key());
43  return StatusCode::FAILURE;
44  }
45 
46  const CaloCellContainer *cellContainer = caloCellInHandle.cptr();
47  std::vector<const CaloCell*> removed_cells;
50  if (!removedClustersHandle.isValid()){
51  ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << removedClustersHandle.key());
52  return StatusCode::FAILURE;
53  }
54  const xAOD::CaloClusterContainer *removed_clusters_cont = removedClustersHandle.cptr();
55 
56  for (auto cluster : *removed_clusters_cont){
57  for(auto cell_it = cluster->cell_cbegin(); cell_it != cluster->cell_cend(); cell_it++){
58  removed_cells.push_back(*cell_it);
59  }
60  }
61  }
62 
64  const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
65 
66  // get only EM cells within dR < 0.4
67  // TODO: change hardcoded 0.4 to meaningful variable
68  std::vector<CaloCell_ID::SUBCALO> emSubCaloBlocks;
69  emSubCaloBlocks.push_back(CaloCell_ID::LAREM);
70  boost::scoped_ptr<CaloCellList> cellList(new CaloCellList(caloDDMgr,cellContainer,emSubCaloBlocks));
71  // FIXME: tau p4 is corrected to point at tau vertex, but the cells are not
72  cellList->select(tau.eta(), tau.phi(), 0.4);
73 
74  for (const CaloCell* cell : *cellList) {
75  // only keep cells that are in Ecal (PS, EM1, EM2 and EM3, both barrel and endcap).
76  int sampling = cell->caloDDE()->getSampling();
77  if (sampling > 7) continue;
78  // if in EleRM, check the clusters do not include electron activities
79  if (m_removeElectronCells && inEleRM() && std::find(removed_cells.cbegin(), removed_cells.cend(), cell) != removed_cells.cend()) continue;
80  // Store cell in output container
81  const IdentifierHash cellHash = cell->caloDDE()->calo_hash();
82 
83  if (!addedCellsMap.test(cellHash)) {
84  pi0CellContainer.push_back(cell);
85  addedCellsMap.set(cellHash);
86  }
87  }
88 
89  return StatusCode::SUCCESS;
90 }
91 
92 #endif
CaloCellList
Definition: CaloCellList.h:40
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
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:70
CaloCellList.h
TauRecToolBase
The base class for all tau tools.
Definition: TauRecToolBase.h:21
TauPi0CreateROI::TauPi0CreateROI
TauPi0CreateROI(const std::string &name)
Definition: TauPi0CreateROI.cxx:16
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:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:22
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:46
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
TauPi0CreateROI::m_caloCellInputContainer
SG::ReadHandleKey< CaloCellContainer > m_caloCellInputContainer
Definition: TauPi0CreateROI.h:45