ATLAS Offline Software
xAODCaloClusterRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CaloGeoHelpers/CaloSampling.h"
7 #include "AthenaKernel/Units.h"
8 
10 
11 namespace JiveXML {
12 
19  xAODCaloClusterRetriever::xAODCaloClusterRetriever(const std::string& type,const std::string& name,const IInterface* parent):
21  {}
22 
23 
25  ATH_CHECK(m_keys.initialize());
26  return StatusCode::SUCCESS;
27  }
28 
29 
35  StatusCode xAODCaloClusterRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
36 
37  ATH_MSG_DEBUG("In retrieve()");
38 
39  // Loop through the keys and retrieve the corresponding data
40  for (const auto& key : m_keys) {
42  if (cont.isValid()) {
43  DataMap data = getData(&(*cont));
44  if (FormatTool->AddToEvent(dataTypeName(), key.key() + "_xAOD", &data).isFailure()) {
45  ATH_MSG_WARNING("Failed to add collection " << key.key());
46  } else {
47  ATH_MSG_DEBUG(" (" << key.key() << ") retrieved");
48  }
49  } else {
50  ATH_MSG_WARNING("Collection " << key.key() << " not found in SG");
51  }
52  }
53 
54  return StatusCode::SUCCESS;
55  }
56 
57 
65 
66  ATH_MSG_DEBUG("in getData()");
67 
69 
70  DataVect phi; phi.reserve(ccc->size());
71  DataVect eta; eta.reserve(ccc->size());
72  DataVect et; et.reserve(ccc->size());
73  DataVect cells; cells.reserve(ccc->size());
74  DataVect numCells; numCells.reserve(ccc->size());
75  DataVect idVec; idVec.reserve(ccc->size());
76  DataVect emfracVec; emfracVec.reserve(ccc->size());
77  DataVect labelVec; labelVec.reserve(ccc->size());
78 
79  std::string label="";
80  int id = 0;
81  int s = 0;
82  float eInSample = 0.;
83  float eInSampleFull = 0.;
84  float emfrac = 0.;
85  float rawemfrac = 0.;
86 
87  // cells n/a in AOD, but keep this for compatibility
88  // with 'full' clusters in AtlantisJava
89  std::string tagCells;
90  tagCells = "cells multiple=\"1.0\"";
91 
93  for (; itr != ccc->end(); ++itr) {
94 
95  // sum over samplings to get EMfraction:
97  // full sum:
98  for (s=0;s<CaloSampling::Unknown; s++){
99  eInSampleFull += (*itr)->eSample(CaloSampling::CaloSample(s));
100  }
101  // Now only EMB1-3, EME1-3 and FCAL1:
102  eInSample += (*itr)->eSample(CaloSampling::EMB1);
103  eInSample += (*itr)->eSample(CaloSampling::EMB2);
104  eInSample += (*itr)->eSample(CaloSampling::EMB3);
105  eInSample += (*itr)->eSample(CaloSampling::EME1);
106  eInSample += (*itr)->eSample(CaloSampling::EME2);
107  eInSample += (*itr)->eSample(CaloSampling::EME3);
108  eInSample += (*itr)->eSample(CaloSampling::FCAL1);
109 
110  emfrac = eInSample/eInSampleFull;
111  rawemfrac = emfrac;
112  // sanity cut: emfrac should be within [0,1]
113  if ( emfrac > 1.0 ) emfrac = 1.;
114  if ( emfrac < 0.0 ) emfrac = 0.;
115  emfracVec.emplace_back( DataType(emfrac).toString() );
116 
117  if ( DataType( eInSample ).toString() != "0." ){
118  label = "AllMeV_SumEMSampl=" + DataType( eInSample ).toString() +
119  "_SumAllSampl=" + DataType( eInSampleFull ).toString() +
120  "_calcEMFrac=" + DataType( rawemfrac ).toString()+
121  "_outEMFrac=" + DataType( emfrac ).toString();
122  }else{ label = "n_a"; }
123  eInSample = 0.;
124  eInSampleFull = 0.;
125 
126  labelVec.emplace_back( label );
127  ATH_MSG_VERBOSE("label is " << label);
128 
129  // now the standard variables
130  // getBasicEnergy n/a in xAOD !
131 
132  phi.emplace_back(DataType((*itr)->phi()));
133  eta.emplace_back(DataType((*itr)->eta()));
134  et.emplace_back(DataType((*itr)->et()/GeV));
135  numCells.emplace_back(DataType( "0" ));
136  cells.emplace_back(DataType( "0" ));
137  idVec.emplace_back(DataType( ++id ));
138 
139  ATH_MSG_VERBOSE( dataTypeName() << " cluster #" << id
140  << " ,e=" << (*itr)->e()/GeV << ", et="
141  << (*itr)->et()/GeV << ", eta=" << (*itr)->eta()
142  << ", phi=" << (*itr)->phi());
143  }
144  // Start with mandatory entries
145  DataMap["phi"] = phi;
146  DataMap["eta"] = eta;
147  DataMap["et"] = et;
148  DataMap[tagCells] = cells;
149  DataMap["numCells"] = numCells;
150  DataMap["id"] = idVec;
151  DataMap["emfrac"] = emfracVec; // not in Atlantis yet ! Could be used in legoplot
152  DataMap["label"] = labelVec; // not in Atlantis yet !
153 
154  ATH_MSG_DEBUG(dataTypeName() << " (AOD, no cells), collection: " << dataTypeName()
155  << " retrieved with " << phi.size() << " entries");
156  return DataMap;
157  }
158 
159 
160 } // JiveXML namespace
xAODCaloClusterRetriever.h
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
JiveXML::xAODCaloClusterRetriever::xAODCaloClusterRetriever
xAODCaloClusterRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: xAODCaloClusterRetriever.cxx:19
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
JiveXML::xAODCaloClusterRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each cluster collection retrieve basic parameters.
Definition: xAODCaloClusterRetriever.cxx:35
et
Extra patterns decribing particle interation process.
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:18
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
JiveXML::xAODCaloClusterRetriever::m_keys
SG::ReadHandleKeyArray< xAOD::CaloClusterContainer > m_keys
Definition: xAODCaloClusterRetriever.h:52
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
JiveXML::xAODCaloClusterRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
Definition: xAODCaloClusterRetriever.h:45
JiveXML::xAODCaloClusterRetriever::getData
const DataMap getData(const xAOD::CaloClusterContainer *)
Puts the variables into a DataMap.
Definition: xAODCaloClusterRetriever.cxx:64
JiveXML::xAODCaloClusterRetriever::initialize
virtual StatusCode initialize()
Definition: xAODCaloClusterRetriever.cxx:24
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
test_pyathena.parent
parent
Definition: test_pyathena.py:15
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
Units.h
Wrapper to avoid constant divisions when using units.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::TauJetParameters::numCells
@ numCells
Definition: TauDefs.h:171
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
AthAlgTool
Definition: AthAlgTool.h:26
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37