ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterCnvTool.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
6// EDM include(s):
7#include "CaloEvent/CaloCluster.h"
8#include "CaloEvent/CaloClusterContainer.h"
12
13// Local include(s):
14#include "CaloClusterCnvTool.h"
15
16
17namespace {
18
19
20typedef bool (xAOD::CaloCluster::*setterFunc) (const xAOD::CaloCluster::CaloSample,
21 const float val);
22
23
24void copyClusterVariables (const CaloCluster* aod,
27 setterFunc setter)
28{
29 std::vector<double> vals;
30 if (! aod->getVariable (varType, vals, true))
31 vals.resize (CaloSampling::Unknown, -999);
32
33 for (unsigned iSamp=0;iSamp<CaloSampling::Unknown;++iSamp) {
36 if (aod->hasSampling(sOld))
37 ((*xaod).*setter) (sNew, vals[iSamp]);
38 }
39}
40
41
42} // anonymous namespace
43
44
45namespace xAODMaker {
46
48 const std::string& name,
49 const IInterface* parent )
50 : AthAlgTool( type, name, parent ) {
51
52 // Declare the interface(s) that the tool implements:
53 declareInterface< ICaloClusterCnvTool >( this );
54 }
55
57 convert( const CaloCluster* aod,
59 CaloClusterCellLinkContainer* ccclc ) const
60 {
61
62 //
63 // Deal with the cell association:
64 //
65 if( aod->isCellLinkValid() && ccclc ) {
66
67 ATH_MSG_DEBUG( "Found cluster with valid cell link" );
68
70 CaloCluster::cell_iterator cit_e = aod->end();
71 if( cit != cit_e ) { //Protect against empty-cluster case
72
73 //Get underlying cell container
74 const CaloCellContainer* ccc = aod->getContainer( cit );
75
76 if( ccc && ( !ccc->empty() ) ) {
77
79 xaod->addCellLink( cccl );
80 for( ; cit != cit_e; ++cit ) {
81 xaod->addCell( cit.getElement().index(), cit.getParameter() );
82 }//end loop over cells of a cluster
83
84 // Move cell links to external cell-link container:
85 xaod->setLink( ccclc );
86
87 } //end cell container ptr not NULL
88 else {
89 ATH_MSG_INFO( "Got NULL ptr to CaloCellContainer" );
90 }
91
92 }//end check cluster not-empty
93 else {
94 ATH_MSG_DEBUG( "Found cluster with empty list of constituents" );
95 }
96 }//end if isCellLink valid
97 else {
98 ATH_MSG_DEBUG( "Found cluster without valid cell link" );
99 }
100
101 // Set basic quantities:
102 xaod->setSamplingPattern( aod->samplingPattern() );
103 const xAOD::CaloCluster::ClusterSize clSize =
104 static_cast< xAOD::CaloCluster::ClusterSize >( aod->getClusterSize() );
105 xaod->setClusterSize( clSize );
106 xaod->setEta0( ( double ) aod->eta0() );
107 xaod->setPhi0( ( double ) aod->phi0() );
108 xaod->setTime( aod->getTime() );
109
110 xaod->setCalE( aod->e (P4SignalState::CALIBRATED) );
113 xaod->setCalM( aod->m (P4SignalState::CALIBRATED) );
114
115 xaod->setRawE( aod->e (P4SignalState::UNCALIBRATED) );
118 xaod->setRawM( aod->m (P4SignalState::UNCALIBRATED) );
119
120 xaod->setAltE( aod->e (P4SignalState::ALTCALIBRATED) );
123 xaod->setAltM( aod->m (P4SignalState::ALTCALIBRATED) );
124
125 //
126 // Copy the energy depositions per sampling:
127 copyClusterVariables (aod, xaod,
130 copyClusterVariables (aod, xaod,
133 copyClusterVariables (aod, xaod,
136
137 //
138 // Copy bad-channel data:
139 //
141 const std::vector< CaloClusterBadChannelData >* bcvec =
142 aod->getBadChannel();
143 for( const CaloClusterBadChannelData& bcd : *bcvec ) {
144 badChanList.emplace_back( bcd.getEta(), bcd.getPhi(),
145 bcd.getLayer(), bcd.getFlag().packedData() );
146 }
147 xaod->setBadChannelList( badChanList );
148
149 //
150 // Copy the moments:
151 //
154 for( ; mom_itr != mom_end; ++mom_itr ) {
155
156 // Forcibly convert between the two types:
157 const CaloCluster::moment_type aod_type =
158 static_cast<CaloCluster::moment_type>(mom_itr.getMomentType());
159 const xAOD::CaloCluster_v1::MomentType xaod_type =
160 static_cast< xAOD::CaloCluster_v1::MomentType >( aod_type );
161
162 // Insert the moment:
163 xaod->insertMoment( xaod_type,
164 mom_itr.getMoment().getValue() );
165 ATH_MSG_VERBOSE( "Copied moment " << aod_type );
166 }
167
168 // Return gracefully:
169 return StatusCode::SUCCESS;
170 }
171
174 xAOD::CaloClusterContainer* xaod ) const {
175
178 CaloClusterCellLinkContainer* ccclc = nullptr;
179
180 for( ; it!= itE; ++it){
181 xAOD::CaloCluster* xcluster = new xAOD::CaloCluster();
182 xaod->push_back( xcluster );
183 CHECK( convert( *it, xcluster, ccclc) );
184 }
185
186 return StatusCode::SUCCESS;
187 }
188
189} // namespace xAODMaker
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Container class for CaloCell.
const double & getValue() const
returns the value of this moment
virtual object_iter end() const
end iterator for public object access
const CaloCellContainer * getContainer(const CaloCell *pCell) const
public container access: retrieve Container for given object pointer
virtual object_iter begin() const
begin iterator for public object access
virtual bool isCellLinkValid() const
moment_type getMomentType() const
Function access to moment type.
const CaloClusterMoment & getMoment() const
Function access to CaloClusterMoment.
Principal data class for CaloCell clusters.
double eta0() const
Returns raw of cluster seed.
MomentStoreIter moment_iterator
Moment iterator type for CaloCluster clients.
virtual double m() const
Retrieve mass independent of signal state.
virtual double e() const
Retrieve energy independent of signal state.
CaloCompositeCellBase< CaloClusterNavigable >::cell_iterator cell_iterator
Iterator on CaloCell s.
virtual double eta() const
Retrieve eta independent of signal state.
CaloVariableType::VariableType variable_type
Data type indicator.
double getTime() const
Access cluster time.
moment_iterator beginMoment(bool useLink=true) const
First iterator on moment store.
moment_iterator endMoment(bool useLink=true) const
Last iterator on moment store.
double getVariable(const variable_type &varType, const sampling_type &samType, bool useLink=true) const
General sampling variable access.
unsigned int samplingPattern() const
Get sampling bitmask.
const badChannelList * getBadChannel() const
unsigned int getClusterSize() const
Get cluster size.
bool hasSampling(const sampling_type &theSampling) const
Checks if certain sampling contributes to cluster.
virtual double phi() const
Retrieve phi independent of signal state.
moment_store::moment_type moment_type
Cluster moment indicator type.
double phi0() const
Returns raw of cluster seed.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
const ElementLink< CONT > & getElement() const
RPAR getParameter() const
CaloClusterCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
Regular AlgTool constructor.
virtual StatusCode convert(const CaloCluster *aod, xAOD::CaloCluster *xaod, CaloClusterCellLinkContainer *ccclc=0) const override
Function that fill an existing xAOD::CaloCluster object with info.
void setRawEta(flt_t)
Set for signal state UNCALIBRATED.
void setAltPhi(flt_t)
Set for signal state ALTCALIBRATED.
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
void setAltM(flt_t)
Set mass for singal state ALTCALIBRATED.
void addCellLink(CaloClusterCellLink *CCCL)
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
void setCalPhi(flt_t)
Set for signal state CALIBRATED.
void setRawM(flt_t)
Set mass for singal state UNCALIBRATED.
void setAltEta(flt_t)
Set for signal state ALTCALIBRATED.
void setTime(flt_t)
Set cluster time.
void insertMoment(MomentType type, double value)
void setCalEta(flt_t)
Set for signal state CALIBRATED.
void setClusterSize(const ClusterSize)
Get cluster size.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
ClusterSize
Enumeration to identify different cluster sizes.
bool setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
void setPhi0(flt_t)
Set raw of cluster seed.
void setAltE(flt_t)
Set Energy for signal state ALTCALIBRATED.
MomentType
Enums to identify different moments.
void setCalE(flt_t)
Set Energy for signal state CALIBRATED.
void setCalM(flt_t)
Set mass for singal state CALIBRATED.
bool setLink(CaloClusterCellLinkContainer *CCCL, IProxyDict *sg=nullptr)
Set up an ElementLink to a CaloClusterCellLink object.
CaloSampling::CaloSample CaloSample
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
void setBadChannelList(const CaloClusterBadChannelList &bcl)
std::vector< CaloClusterBadChannelData > CaloClusterBadChannelList
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
setBGCode setTAP setLVL2ErrorBits bool
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.