36 const std::string& name,
37 ISvcLocator* pSvcLocator)
67 ATH_MSG_FATAL(
"For adding cells relative to the hottest cell to be "
68 "symmetric in eta, the AddCells "
69 "window size needs to be odd");
71 return StatusCode::FAILURE;
89 <<
"--> Eta Window size for L0/L1/L2 cells : "
92 <<
"--> Eta Window size for L3 cells : "
97 <<
" -> Phi window is fully dynamic for L2/L3" <<
'\n'
98 <<
" -> L0/L1 cells in phi will be collected in a Window : "
102 return StatusCode::SUCCESS;
123 ATH_CHECK(newEgammaRecs.
record(std::make_unique<EgammaRecContainer>()));
125 size_t inputSize = egammaRecs->size();
126 outputClusterContainer->reserve(inputSize);
127 newEgammaRecs->reserve(inputSize);
129 std::optional<SG::WriteHandle<xAOD::CaloClusterContainer>> precorrClustersH;
133 precorrClustersH->ptr()->reserve(inputSize);
144 if (egammaRecs->empty()) {
145 return StatusCode::SUCCESS;
150 (*egammaRecs)[0]->caloCluster()->getCellLinks()->getCellContainerLink();
153 size_t numInput = egammaRecs->size();
154 std::vector<bool> isUsed(numInput,
false);
155 std::vector<bool> isUsedRevert(numInput,
false);
157 for (std::size_t i = 0; i < egammaRecs->size(); ++i) {
161 const auto* egRec = (*egammaRecs)[i];
173 isUsedRevert = isUsed;
178 std::vector<const xAOD::CaloCluster*> accumulatedClusters;
179 accumulatedClusters.push_back(clus);
183 const std::vector<std::size_t> secondaryIndices =
185 for (
const auto& secClusIndex : secondaryIndices) {
186 const auto*
const secRec = (*egammaRecs)[secClusIndex];
187 accumulatedClusters.push_back(secRec->caloCluster());
189 ATH_MSG_DEBUG(
"Total clusters " << accumulatedClusters.size());
192 std::unique_ptr<xAOD::CaloCluster> newCluster =
198 precorrClustersH ? precorrClustersH->ptr() :
nullptr);
202 outputClusterContainer->push_back(std::move(newCluster));
205 isUsed.swap(isUsedRevert);
211 *outputClusterContainer, outputClusterContainer->size() - 1, ctx);
212 std::vector<ElementLink<xAOD::CaloClusterContainer>> elClusters{
217 auto newEgRec = std::make_unique<egammaRec>(*egRec);
218 newEgRec->setCaloClusters(elClusters);
219 newEgammaRecs->push_back(std::move(newEgRec));
224 return StatusCode::SUCCESS;
234 [[maybe_unused]]
const EventContext &ctx,
237 return StatusCode::SUCCESS;
245 auto inRange = [](
float eta1,
float phi1,
246 float eta2,
float phi2,
247 float etaWindow,
float phiWindow) {
249 const float dEta = std::abs(eta1 - eta2);
252 return dEta < etaWindow && dPhi < phiWindow;
257 if (
ref->hasSampling(CaloSampling::EMB2) &&
258 ref->hasSampling(CaloSampling::EME2)) {
259 const bool inRangeBarrel =
inRange(
ref->eta(),
266 const bool inRangeEndcap =
inRange(
ref->eta(),
273 const bool inRangeBarrelL2 =
inRange(
ref->etaSample(CaloSampling::EMB2),
274 ref->phiSample(CaloSampling::EMB2),
280 const bool inRangeEndcapL2 =
inRange(
ref->etaSample(CaloSampling::EME2),
281 ref->phiSample(CaloSampling::EME2),
288 return inRangeBarrel || inRangeEndcap || inRangeBarrelL2 || inRangeEndcapL2;
308std::unique_ptr<xAOD::CaloCluster>
310 const EventContext& ctx,
311 const std::vector<const xAOD::CaloCluster*>& clusters,
317 if (clusters.empty()) {
318 ATH_MSG_ERROR(
"Missing the seed cluster! Should not happen.");
327 ATH_MSG_ERROR(
"CaloClusterStoreHelper::makeCluster failed.");
338 newCluster->setEta0(cp0.
etaB);
339 newCluster->setPhi0(cp0.
phiB);
341 newCluster->setEta0(cp0.
etaEC);
342 newCluster->setPhi0(cp0.
phiEC);
350 float eta0 = std::abs(newCluster->eta0());
359 "AddTileGap3CellsinWindow?");
387 if (newCluster->et() < 0) {
393 std::vector<ElementLink<xAOD::CaloClusterContainer>> constituentLinks;
396 cluster->getSisterClusterLink();
400 constituentLinks.push_back(sisterCluster);
408 std::vector<ElementLink<xAOD::CaloClusterContainer>>>
409 caloClusterLinks(
"constituentClusterLinks");
410 caloClusterLinks(*newCluster) = constituentLinks;
425 const double eta2 = std::abs(clus->
etaBE(2));
430 const double EMAccEnergy =
432 const double EMAccEt = EMAccEnergy / cosh(eta2);
440 const std::vector<const xAOD::CaloCluster*>& clusters,
445 const float addCellsWindowL3EtaBarrel =
447 const float addCellsWindowL3EtaEndcap =
455 for (; cell_itr != cell_end; ++cell_itr) {
471 const bool isL2Cell =
472 (CaloCell_ID::EMB2 == sampling || CaloCell_ID::EME2 == sampling);
473 const bool isL3Cell =
474 (CaloCell_ID::EMB3 == sampling || CaloCell_ID::EME3 == sampling);
476 if ((!isL2Cell) && (!isL3Cell)) {
484 bool inEtaRange =
false;
489 (std::abs(cp0.
etaB - dde->
eta_raw()) < addCellsWindowEtaBarrel)) {
493 (std::abs(cp0.
etaB - dde->
eta_raw()) < addCellsWindowL3EtaBarrel)) {
499 (std::abs(cp0.
etaEC - dde->
eta_raw()) < addCellsWindowEtaEndcap)) {
503 addCellsWindowL3EtaEndcap)) {
515 if (tofill.
size() == 0) {
516 return StatusCode::FAILURE;
531 for (; cell_itr != cell_end; ++cell_itr) {
544 const bool isL0L1Cell =
545 (CaloCell_ID::EMB1 == sampling || CaloCell_ID::EME1 == sampling ||
546 CaloCell_ID::PreSamplerB == sampling ||
547 CaloCell_ID::PreSamplerE == sampling);
552 bool inEtaRange =
false;
556 if (std::abs(cp0.
etaB - dde->
eta_raw()) < addCellsWindowEtaBarrel) {
561 if (std::abs(cp0.
etaEC - dde->
eta_raw()) < addCellsWindowEtaEndcap) {
570 bool inPhiRange =
false;
573 if (cell_phi > phiMinusB && cell_phi < phiPlusB) {
579 if (cell_phi > phiMinusEC && cell_phi < phiPlusEC) {
594 info.etamax = cp0.
etaB;
595 info.phimax = cp0.
phiB;
597 info.etamax = cp0.
etaEC;
598 info.phimax = cp0.
phiEC;
607 for (
const auto *c : info.addedCells) {
613 return StatusCode::SUCCESS;
623 constexpr double searchWindowPhi = 2 *
M_PI / 64.0 +
M_PI / 64;
624 std::vector<const CaloCell*> cells;
630 ATH_MSG_ERROR(
"No cell container in addRemainingCellsToCluster?");
631 return StatusCode::FAILURE;
636 const std::vector<CaloSampling::CaloSample> samples = {
637 CaloSampling::TileGap3
640 for (
auto samp : samples) {
643 tofill.
eta0(), tofill.
phi0(), searchWindowEta, searchWindowPhi, samp);
644 cells.insert(cells.end(), myList.
begin(), myList.
end());
647 for (
const auto* cell : cells) {
662 if (std::abs(tofill.
eta0()) > 1.56) {
666 float cellaEtaRaw = std::abs(dde->
eta_raw());
667 if (cellaEtaRaw >= minEta && cellaEtaRaw <= maxEta) {
672 return StatusCode::SUCCESS;
677 const EventContext& ctx,
686 newCluster->
setAltE(newCluster->
e());
690 if (precorrClusters) {
691 precorrClusters->
push_back(std::make_unique<xAOD::CaloCluster>());
692 *precorrClusters->
back() = *newCluster;
696 double aeta = std::abs(newCluster->
eta());
699 "SuperCluster rejected");
700 return StatusCode::FAILURE;
702 newCluster->
setRawE(newCluster->
e());
709 return StatusCode::SUCCESS;
const boost::regex ref(r_ef)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Calculate total energy, position, etc. for a given layer of a cluster.
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
list_iterator end() const
void select(double eta, double phi, double deta, double dphi)
list_iterator begin() const
Data object for each calorimeter readout cell.
unsigned index() const
Accessor for the index of the cell in the CaloCellContainer.
weight_t weight() const
Accessor for weight associated to this cell.
const CaloCellContainer * getCellContainer() const
Method to access underlying cell container.
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 StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
This class groups all DetDescr information related to a CaloCell.
IdentifierHash calo_hash() const
cell calo hash
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
float eta_raw() const
cell eta_raw
CaloCell_ID::CaloSample getSampling() const
cell sampling
float phi_raw() const
cell phi_raw
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap
This class provides the client interface for accessing the detector description information common to...
Object reference supporting deferred reading from StoreGate.
const T * back() const
Access the last element in the collection as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementLink implementation for ROOT usage.
SG::Accessor< T, ALLOC > Accessor
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Represent an egamma object for internal egamma usage during reconstruction.
float m_addCellsWindowEtaBarrel
static constexpr float s_TG3Run2E4cellEtaMax
Gaudi::Property< int > m_addCellsWindowEtaCellsEndcap
Size of windows et eta in which cells of topoclusters are edded for the endcap (units of 2nd layer ce...
egammaSuperClusterBuilderBase(const std::string &name, ISvcLocator *pSvcLocator)
Protected constructor since this class should not be instantiated by itself.
float m_searchWindowEtaEndcap
SG::WriteHandleKey< EgammaRecContainer > m_outputEgammaRecContainerKey
Key for output egammaRec container.
SG::ReadHandleKey< EgammaRecContainer > m_inputEgammaRecContainerKey
Key for input egammaRec container.
float m_addCellsWindowEtaEndcap
static constexpr float s_cellPhiSize
Gaudi::Property< int > m_extraL3EtaSizeCells
"When adding L3 cells, how much wider in eta than the L2
static constexpr float s_TG3Run3E4cellEtaMax
Gaudi::Property< float > m_EtThresholdCut
Seed selection requirements.
static constexpr float s_TG3Run2E4cellEtaMin
StatusCode fillClusterConstrained(xAOD::CaloCluster &tofill, const std::vector< const xAOD::CaloCluster * > &clusters, const CookieCutterHelpers::CentralPosition &cp0) const
Fill super cluster constraining its size in eta,phi around the overall hottest cell and the its L2 si...
static constexpr float s_TG3Run3E3cellEtaMin
virtual StatusCode redoMatching(const EventContext &ctx, SG::WriteHandle< EgammaRecContainer > &newEgammaRecs) const
Gaudi::Property< int > m_searchWindowEtaCellsBarrel
Size of topocluster search window in eta for the barrel.
bool matchesInWindow(const xAOD::CaloCluster *ref, const xAOD::CaloCluster *clus) const
Is clus in window center around ref?
std::unique_ptr< xAOD::CaloCluster > createNewCluster(const EventContext &ctx, const std::vector< const xAOD::CaloCluster * > &clusters, const DataLink< CaloCellContainer > &cellCont, const CaloDetDescrManager &mgr, xAOD::EgammaParameters::EgammaType egType, xAOD::CaloClusterContainer *precorrClusters) const
Add new supercluster ,created out of the input clusters, to the newClusters collections.
Gaudi::Property< bool > m_linkToConstituents
Decorate the supercluster with links to the component topoclusters.
static constexpr float s_ClEtaMinForTG3cell
StatusCode calibrateCluster(const EventContext &ctx, xAOD::CaloCluster *newCluster, const CaloDetDescrManager &mgr, const xAOD::EgammaParameters::EgammaType egType, xAOD::CaloClusterContainer *precorrClusters) const
function to calibrate the new clusters energy
ToolHandle< IegammaCheckEnergyDepositTool > m_egammaCheckEnergyDepositTool
Pointer to the egammaCheckEnergyDepositTool.
ToolHandle< IegammaCellRecoveryTool > m_egammaCellRecoveryTool
Pointer to the egammaCellRecoveryTool.
Gaudi::Property< bool > m_useExtendedTG3
Use extended TG3 definition (only after Run 2)
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_precorrClustersKey
Optional key for pre-correction clusters.
virtual StatusCode execute(const EventContext &ctx) const override
should be called by the derived class in the execute phase
float m_searchWindowPhiEndcap
virtual bool egammaRecPassesSelection(const egammaRec *egRec) const
StatusCode addTileGap3CellsinWindow(xAOD::CaloCluster &tofill, const CaloDetDescrManager &mgr) const
add all tile Gap 3 cells in a window.
Gaudi::Property< int > m_searchWindowPhiCellsEndcap
Size of topocluster search window in phi for the end-cap.
virtual xAOD::EgammaParameters::EgammaType getEgammaRecType(const egammaRec *egRec) const =0
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
static constexpr float s_ClEtaMaxForTG3cell
float m_searchWindowEtaBarrel
static constexpr float s_cellEtaSize
ToolHandle< IegammaSwTool > m_clusterCorrectionTool
Tool to handle cluster corrections.
float m_searchWindowPhiBarrel
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputSuperClusterCollectionName
Key for output clusters.
Gaudi::Property< int > m_extraL0L1PhiSizeCells
"When adding L0 (PS) and L1 cells, how much wider than the L2 size of the cluster is the acceptance i...
Gaudi::Property< int > m_searchWindowEtaCellsEndcap
Size of topocluster search window in eta for the end-cap.
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Handle to the MVA calibration service.
virtual std::vector< std::size_t > searchForSecondaryClusters(std::size_t egammaInd, const EgammaRecContainer *egammaRecs, std::vector< bool > &isUsed) const =0
Gaudi::Property< int > m_addCellsWindowEtaCellsBarrel
Size of windows et eta in which cells of topoclusters are added for the barrel (units of 2nd layer ce...
Gaudi::Property< int > m_searchWindowPhiCellsBarrel
Size of topocluster search window in phi for the barrel.
virtual StatusCode initialize() override
should be called by the derived class in the initialize phase
bool seedClusterSelection(const xAOD::CaloCluster *clus) const
check if we pass the basic criteria for a seed cluster
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.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
virtual double eta() const
The pseudorapidity ( ) of the particle.
void setAltEta(flt_t)
Set for signal state ALTCALIBRATED.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
virtual double e() const
The total energy of the particle.
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version)
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setAltE(flt_t)
Set Energy for signal state ALTCALIBRATED.
flt_t eta0() const
Returns raw of cluster seed.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
flt_t phi0() const
Returns raw of cluster seed.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
void fillPositionsInCalo(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
Function to decorate the calo cluster with position variables.
void refineEta1Position(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
function to refine position in eta1
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
int summaryValueInt(const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, int deflt=-999)
return the summary value for a TrackParticle or default value (-999) (to be used mostly in python whe...
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
double proxim(double b, double a)
Find the reference position (eta, phi) relative to which cells are restricted.
Find the size of the cluster in phi using L2 cells.