7#include "CLHEP/Units/SystemOfUnits.h"
21 const std::string& name,
22 const IInterface* parent)
62 MsgStream log(msgSvc(), name());
63 log << MSG::INFO <<
"in initialize()" <<
endmsg;
72 <<
"problems performing setup of module and sampling lookup tables"
74 return StatusCode::FAILURE;
79 log << MSG::FATAL <<
"List of samplings is not supplied" <<
endmsg;
80 return StatusCode::FAILURE;
83 log << MSG::FATAL <<
"Number of cone cuts = " <<
m_coneCuts.size() <<
84 " does not correspond to the number of samplings = " <<
86 return StatusCode::FAILURE;
89 log << MSG::INFO <<
"Included calorimeter samplings(coneCuts): ";
90 std::vector<std::string>::const_iterator sampling =
m_samplingNames.begin();
91 std::vector<float>::const_iterator cut =
m_coneCuts.begin();
95 if (idSamp == CaloSampling::Unknown) {
96 log << MSG::FATAL <<
" Unknown sampling: \042" << *sampling <<
"\042 "
98 return StatusCode::FAILURE;
100 log << MSG::INFO <<
"\042" << *sampling <<
"\042"
101 <<
"(" << *cut <<
") ";
105 std::vector<CaloCell_ID::SUBCALO>::iterator it=
m_calos.begin();
106 for (;it!=
m_calos.end();++it)
if (*it == idCalo)
break;
109 log << MSG::INFO <<
endmsg;
110 log << MSG::INFO <<
"Included calorimeters: " <<
m_calos <<
endmsg;
112 log << MSG::FATAL <<
" Cluster position is fixed but (eta, phi) are not "
113 <<
"supplied in the JO file" <<
endmsg;
114 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
128 MsgStream log(msgSvc(), name());
129 log << MSG::DEBUG <<
"in execute()" <<
endmsg;
141 if (
sc.isFailure()) {
143 <<
"cannot allocate CaloCellContainer with key <"
147 log << MSG::DEBUG <<
"CaloCellContainer container size = " <<
150 std::unique_ptr<xAOD::CaloCluster> Cluster;
151 double cluEta=0,cluPhi=0,cluNorm = 0;
152 double cluEta0=0,cluPhi0=0,cluNorm0 = 0;
153 bool clusterPositionFound =
false;
155 clusterPositionFound =
true;
167 for (; itc!=cellContainer->
endConstCalo(calo); ++itc,++cindex) {
169 double e = cell->energy();
170 double noiseRMS = elecNoise->getNoise(cell->ID(), cell->gain());
171 if(noiseRMS <= 0.) noiseRMS = 0.0001;
172 double eSigma = e/noiseRMS;
175 if (!clusterPositionFound) {
179 log << MSG::DEBUG <<
"smp,eta,phi,e,eSigma= "
180 <<idSample<<
" "<<cell->eta()<<
" "<<cell->phi()<<
" "<<
181 e<<
" "<<eSigma<<
" "<<
endmsg;
184 cluPhi0 = e*cell->phi();
187 else cluPhi0 += e*
proxim(cell->phi(),phiRef);
188 cluEta0 += e*cell->eta();
192 double dist = sqrt(
pow(cluPhi0-
proxim(cell->phi(),cluPhi0),2)
193 +
pow(cluEta0-cell->eta(),2));
198 cluPhi += e*
proxim(cell->phi(),cluPhi0);
199 cluEta += e*cell->eta();
206 double dist = sqrt(
pow(cluPhi0-
proxim(cell->phi(),cluPhi0),2)
207 +
pow(cluEta0-cell->eta(),2));
214 Cluster->addCell(cindex,1.);
215 log << MSG::DEBUG <<
"smp,e,eSigma= "
216 <<idSample<<
" "<<e<<
" "<<eSigma<<
" "<<
endmsg;
220 if (clusterPositionFound)
break;
222 if (cluNorm0 == 0.) {
224 log << MSG::INFO <<
"No seed cell found" <<
endmsg;
225 return StatusCode::SUCCESS;
229 log << MSG::DEBUG <<
"nIter=0: cluEta0,cluPhi0,cluNorm0= " << cluEta0
230 <<
" " << cluPhi0 <<
" " << cluNorm0 <<
endmsg;
234 log << MSG::ERROR <<
"cluNorm = 0.: should never be" <<
endmsg;
235 return StatusCode::SUCCESS;
239 double dist = sqrt(
pow(cluPhi0-
proxim(cluPhi,cluPhi0),2)
240 +
pow(cluEta0-cluEta,2));
242 clusterPositionFound =
true;
246 clusterPositionFound =
true;
248 log << MSG::DEBUG <<
"Maximal number of iterations reached" <<
endmsg;
249 log << MSG::DEBUG <<
"cluEta0,cluPhi0,cluNorm0= " << cluEta0 <<
" " <<
250 cluPhi0 <<
" " << cluNorm0 <<
endmsg;
251 log << MSG::DEBUG <<
"cluEta,cluPhi,cluNorm= " << cluEta <<
" " <<
252 cluPhi <<
" " << cluNorm <<
endmsg;
257 cluEta=0.; cluPhi=0.; cluNorm = 0.;
263 log<<MSG::DEBUG<<
"Cluster eta0, phi0= "<<Cluster->eta0()<<
" "<<
265 log<<MSG::DEBUG<<
" Cluster #cells, E, eta, phi= "<<
266 Cluster->clusterSize()<<
" "<<Cluster->e()<<
" "<<
267 Cluster->eta()<<
" "<<Cluster->phi()<<
endmsg;
268 log<<MSG::DEBUG<<
"In samplings: #samp E eta(etasize) phi(phisize):"
283 return StatusCode::SUCCESS;
285 log << MSG::ERROR <<
"Cluster not found: should never be here!" <<
endmsg;
286 return StatusCode::SUCCESS;
293 MsgStream log(msgSvc(), name());
294 log << MSG::DEBUG <<
"in finalize()" <<
endmsg;
304 return StatusCode::SUCCESS;
372 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
CaloPhiRange class declaration.
constexpr int pow(int base, int exp) noexcept
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
Container class for CaloCell.
CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const iterators on cell of just one calo
CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
int indexFirstCellCalo(const CaloCell_ID::SUBCALO caloNum) const
index of first cell of given calorimeter (-1 if none).
CaloCell_Base_ID::SUBCALO SUBCALO
Data object for each calorimeter readout cell.
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
static constexpr unsigned int getNumberOfSamplings()
Get number of available samplings.
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
float m_cellCut
Threshold cut on cell energy in sigma noise units.
virtual StatusCode initialize() override
StatusCode setupLookupTables()
Setup lookup tables.
std::vector< std::string > m_samplingNames
std::vector< float > m_samplingConeCuts
Map of cone cuts for calorimeter samplings.
bool m_fixClusterPosition
Flag to fix cluster position ( ) from JO file.
const CaloCell_ID * m_calo_id
Services.
bool m_CellEnergyInADC
True if cell enrgy is in ADC counts, default = FALSE.
float m_eta0
Cluster ) set in JO file.
std::vector< CaloSampling::CaloSample > m_samplings
Vectors containing the list of used samplings and corresponding cone cuts; list of used calorimeters.
std::map< CaloSampling::CaloSample, CaloCell_ID::SUBCALO > m_caloLookup
std::vector< float > m_coneCuts
std::vector< CaloCell_ID::SUBCALO > m_calos
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *theClusters) const override
Execute on an entire collection of clusters.
float m_seedCut
Threshold cut on seed cell energy in sigma noise units to find the 1st approximation of cluster .
std::map< std::string, CaloSampling::CaloSample > m_samplingFromNameLookup
TBClusterMaker(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< CaloNoise > m_elecNoiseKey
int m_maxIter
Maximal number of iterations to find cluster position.
float m_deltaR
Maximal claster position shift at the current step to stop iterations.
std::string m_caloCellContainerName
Names.
virtual StatusCode finalize() override
std::vector< float > m_adcToMeV
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
double proxim(double b, double a)