ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwCalibHitsCalibration Class Referenceabstract

#include <CaloSwCalibHitsCalibration.h>

Inheritance diagram for CaloSwCalibHitsCalibration:
Collaboration diagram for CaloSwCalibHitsCalibration:

Public Types

enum  {
  EMB1 = 0 , EMB2 = 1 , EME1 = 2 , EME2 = 3 ,
  COMBINED2 = 4 , CLUSTER = 5 , NREGIONS = 6
}
 Region codes for m_region below. More...
typedef ToolWithConstants base_class
 Shorthand for derived classes.
using Context
 Convenient alias for the Context type.
using Constant
 Alias for the Constant type.

Public Member Functions

virtual void makeTheCorrection (const Context &myctx, xAOD::CaloCluster *cluster, const CaloDetDescrElement *elt, float eta, float adj_eta, float phi, float adj_phi, CaloSampling::CaloSample samp) const override
 Virtual function for the correction-specific code.
 CaloClusterCorrectionCommon (const std::string &type, const std::string &name, const IInterface *parent)
 Inherit constructor.
virtual void makeCorrection (const Context &myctx, xAOD::CaloCluster *cluster) const override
 Perform the correction.
virtual void makeCorrection (const Context &myctx, xAOD::CaloCluster *) const =0
virtual void makeTheCorrection (const Context &myctx, xAOD::CaloCluster *cluster, const CaloDetDescrElement *elt, float eta, float adj_eta, float phi, float adj_phi, CaloSampling::CaloSample samp) const =0
 Virtual function for the correction-specific code.
virtual StatusCode initialize () override
 Initialize method.
virtual void setsample (xAOD::CaloCluster *cluster, CaloSampling::CaloSample sampling, float em, float etam, float phim, float emax, float etamax, float phimax, float etas, float phis) const
virtual void setenergy (xAOD::CaloCluster *cluster, float energy) const
StatusCode execute (const EventContext &ctx, xAOD::CaloCluster *cluster) const override
virtual StatusCode execute (const EventContext &ctx, xAOD::CaloClusterContainer *collection) const
 Execute on an entire collection of clusters.
Context context (const EventContext &ctx) const
 Create a Context object.
virtual void writeConstants (std::ostream &stream, const std::string &name, const EventContext &ctx) const
 Dump method (for debugging)
virtual StatusCode mergeConstants (CaloRec::ToolConstants &out, const EventContext &ctx) const override
 Merge our constants into out with the proper prefix.
virtual int toolVersion () const
 Return the version number for this tool.
virtual const std::string & toolType () const
 Return the name of the type of this tool.

Static Public Member Functions

static float energy_interpolation (float energy, const TableBuilder &builder, const CaloRec::Array< 1 > &energies, int energy_degree)
 Many of the corrections use the same method for doing the final interpolation in energy.

Public Attributes

 cls = CompFactory.CaloSwCalibHitsCalibration
list CaloSwCalibHitsCalibration_versions

Protected Attributes

SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager"}

Private Member Functions

const CaloClusterCorr::DDHelperddhelper (const CaloDetDescrManager *dd_man) const
 Retrieve the detector description helper, creating it if needed.

Private Attributes

Constant< CxxUtils::Array< 3 > > m_correction { this, "correction", "" }
Constant< CxxUtils::Array< 2 > > m_sampling_depth { this, "sampling_depth", "" }
Constant< float > m_eta_start_crack { this, "eta_start_crack", "" }
Constant< float > m_eta_end_crack { this, "eta_end_crack", "" }
Constant< float > m_etamax { this, "etamax", "" }
Constant< bool > m_use_raw_eta { this, "use_raw_eta", "" }
Constant< bool > m_fix_v6_pathologies { this, "fix_v6_pathologies", "" }
Constant< bool > m_updateSamplingEnergies { this, "update_sampling_energies", true, "" }
Constant< int > m_region { this, "region", "Calorimeter region" }
 Calibration constant: The calorimeter region for which this correction is intended.
CxxUtils::CachedUniquePtr< const CaloClusterCorr::DDHelperm_ddhelper
 Helper for detector description lookup.
SG::ReadCondHandleKey< CaloRec::ToolConstantsm_DBHandle
 Handle to a ToolConstants conditions object.
StringProperty m_prefix
 Prefix for finding our constants within the ToolConstants object.
ToolWithConstantsImpl m_impl
 Internal implementation object.
Constant< int > m_order
 Used to fix the ordering of tools when we're initializing from COOL based on a hierarchical tag.
Constant< bool > m_isdummy
 If true, then this is a dummy tool that should not be executed.

Detailed Description

Definition at line 24 of file CaloSwCalibHitsCalibration.h.

Member Typedef Documentation

◆ base_class

typedef ToolWithConstants CaloUtils::ToolWithConstants< BASE >::base_class
inherited

Shorthand for derived classes.

Definition at line 450 of file ToolWithConstants.h.

◆ Constant

using CaloUtils::ToolWithConstants< BASE >::Constant
inherited

Alias for the Constant type.

Definition at line 463 of file ToolWithConstants.h.

◆ Context

using CaloUtils::ToolWithConstants< BASE >::Context
inherited

Convenient alias for the Context type.

Definition at line 458 of file ToolWithConstants.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Region codes for m_region below.

This is used to decide how to report the position of the cluster. Note: This numbering is also used in the job options files.

Enumerator
EMB1 
EMB2 
EME1 
EME2 
COMBINED2 
CLUSTER 
NREGIONS 

Definition at line 100 of file CaloClusterCorrectionCommon.h.

100 {
101 // Barrel, sampling 1.
102 EMB1 = 0,
103
104 // Barrel, sampling 2.
105 EMB2 = 1,
106
107 // Endcap, sampling 1.
108 EME1 = 2,
109
110 // Endcap, sampling 2.
111 EME2 = 3,
112
113 // Average of barrel and endcap in sampling 2.
114 COMBINED2 = 4,
115
116 // Overall cluster position.
117 CLUSTER = 5,
118
119 // Number of different region codes.
120 NREGIONS = 6
121 };

Member Function Documentation

◆ CaloClusterCorrectionCommon()

CaloClusterCorrectionCommon::CaloClusterCorrectionCommon ( const std::string & type,
const std::string & name,
const IInterface * parent )

Inherit constructor.

Definition at line 46 of file CaloClusterCorrectionCommon.cxx.

◆ context()

Context CaloUtils::ToolWithConstants< BASE >::context ( const EventContext & ctx) const
inherited

Create a Context object.

This can then be passed to Constant::operator().

◆ ddhelper()

const CaloClusterCorr::DDHelper & CaloClusterCorrectionCommon::ddhelper ( const CaloDetDescrManager * dd_man) const
privateinherited

Retrieve the detector description helper, creating it if needed.

Definition at line 640 of file CaloClusterCorrectionCommon.cxx.

641{
642 const CaloClusterCorr::DDHelper* ddhelper = m_ddhelper.get();
643 if (!ddhelper) {
644 auto newhelper = std::make_unique<const CaloClusterCorr::DDHelper> (dd_man);
645 ddhelper = m_ddhelper.set (std::move (newhelper));
646 }
647 return *ddhelper;
648}
CxxUtils::CachedUniquePtr< const CaloClusterCorr::DDHelper > m_ddhelper
Helper for detector description lookup.
const CaloClusterCorr::DDHelper & ddhelper(const CaloDetDescrManager *dd_man) const
Retrieve the detector description helper, creating it if needed.

◆ energy_interpolation()

float CaloClusterCorrectionCommon::energy_interpolation ( float energy,
const TableBuilder & builder,
const CaloRec::Array< 1 > & energies,
int energy_degree )
staticinherited

Many of the corrections use the same method for doing the final interpolation in energy.

Perform energy interpolation.

We factor out this common code here. builder is used to construct the interpolation table; energy is the energy value for the interpolation. energies is the list of energies at which we have tabulated values, and energy_degree is the degree of the polynomial interpolation in energy.

Parameters
energyThe energy value for the interpolation.
builderHelper to construct the interpolation table.
energiesThe energy interpolation table.
energy_degreeThe polynomial interpolation degree for the energy interpolation.

Many of the corrections use the same method for doing the final interpolation in energy. We factor out this common code here.

Definition at line 575 of file CaloClusterCorrectionCommon.cxx.

581{
582 // Calculate the correction for each energy.
583 unsigned int n_energies = energies.size();
584 unsigned int shape[] = {n_energies, 2};
585 CaloRec::WritableArrayData<2> corrtab (shape);
586
587 // If we're outside the range of the table, we'll just be using the
588 // value at the end (no extrapolation). We only need to calculate
589 // that one point in that case.
590 unsigned int beg = 0;
591 unsigned int end = n_energies;
592 if (energy <= energies[0])
593 end = 1;
594 else if (energy >= energies[n_energies-1])
595 beg = n_energies-1;
596
597 // Build the table.
598 int n_good = 0;
599 for (unsigned int i=beg; i<end; i++)
600 docalc (i, builder, energies, corrtab, n_good);
601
602 // If we only evaluated one point, but it wasn't good, keep
603 // searching until we find a good one.
604 while (n_good == 0 && beg > 0) {
605 --beg;
606 docalc (beg, builder, energies, corrtab, n_good);
607 }
608 while (n_good == 0 && end < n_energies) {
609 docalc (end, builder, energies, corrtab, n_good);
610 ++end;
611 }
612
613 // Now interpolate in energy.
614 // But if we're outside of the range of the table, just use the value
615 // at the end (don't extrapolate).
616 if (n_good == 0) {
617 // No good energies --- return a null correction.
618 return 0;
619 }
620 else if (n_good == 1) {
621 // Only one good energy --- nothing to do but to use it.
622 return corrtab[0][1];
623 }
624 else if (energy <= corrtab[0][0]) {
625 // Off the low end of the table --- return the first value.
626 return corrtab[0][1];
627 }
628 else if (energy >= corrtab[n_good-1][0]) {
629 // Off the high end of the table --- return the last value.
630 return corrtab[n_good-1][1];
631 }
632
633 // Do the interpolation.
634 return interpolate (corrtab, energy, energy_degree,
635 1, CaloRec::Array<1>(), n_good);
636}
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
float interpolate(const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > &regions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.

◆ execute() [1/2]

StatusCode CaloClusterCorrection::execute ( const EventContext & ctx,
xAOD::CaloCluster * cluster ) const
overrideinherited

Definition at line 53 of file CaloClusterCorrection.cxx.

55{
56 this->makeCorrection (context(ctx), cluster);
57
58#if 0
59 ATH_MSG_DEBUG( " ...... e, et " << cluster->e() << " " << cluster->et() << endmsg);
60 ATH_MSG_DEBUG( " ...... eta, etaBE, etaSmp " << cluster->eta() << " " << cluster->etaBE(2)
61 << " " << cluster->etaSample(CaloSampling::EMB1)
62 << " " << cluster->etaSample(CaloSampling::EMB2)
63 << " " << cluster->etaSample(CaloSampling::EMB3) << endmsg);
64 ATH_MSG_DEBUG( " ...... phi, phiBE, phiSmp " << cluster->phi() << " " << cluster->phiBE(2)
65 << " " << cluster->phiSample(CaloSampling::EMB1)
66 << " " << cluster->phiSample(CaloSampling::EMB2)
67 << " " << cluster->phiSample(CaloSampling::EMB3) << endmsg);
68#endif
69
70 return StatusCode::SUCCESS;
71}
#define endmsg
#define ATH_MSG_DEBUG(x)
virtual void makeCorrection(const Context &myctx, xAOD::CaloCluster *) const =0
Context context(const EventContext &ctx) const
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.

◆ execute() [2/2]

StatusCode CaloClusterProcessor::execute ( const EventContext & ctx,
xAOD::CaloClusterContainer * collection ) const
inherited

Execute on an entire collection of clusters.

Parameters
collectionThe container of clusters.

This will iterate over all the clusters in collection and call execute on each one individually.

Parameters
collectionThe container of clusters.
ctxThe event context.

This will iterate over all the clusters in collection and call execute on each one individually.

Definition at line 65 of file CaloClusterProcessor.cxx.

47{
48 for (xAOD::CaloCluster* clu : *collection) {
49 ATH_CHECK( execute (ctx, clu) );
50 }
51 return StatusCode::SUCCESS;
52}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *cluster) const override
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ initialize()

StatusCode CaloClusterCorrection::initialize ( )
overridevirtualinherited

Initialize method.

Derived classes must call this.

Reimplemented from CaloUtils::ToolWithConstants< CaloClusterProcessor >.

Reimplemented in CaloClusterBadChannelList, CaloDummyCorrection, CaloFillRectangularCluster, CaloSwDeadOTX_back, CaloSwDeadOTX_ps, CaloSwGap_g3, CaloSwGap_v2, CaloSwGap_v3, CaloTopoEMGap, and CaloTopoEMlayers.

Definition at line 47 of file CaloClusterCorrection.cxx.

47 {
48 ATH_CHECK(m_caloMgrKey.initialize());
50 return StatusCode::SUCCESS;
51}
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode initialize() override
Initialize method.

◆ makeCorrection() [1/2]

virtual void CaloClusterCorrection::makeCorrection ( const Context & myctx,
xAOD::CaloCluster *  ) const
pure virtualinherited

◆ makeCorrection() [2/2]

void CaloClusterCorrectionCommon::makeCorrection ( const Context & myctx,
xAOD::CaloCluster * cluster ) const
overridevirtualinherited

Perform the correction.

Called by the tool

Parameters
myctxToolWithConstants context.
clusterThe cluster to correct. It is updated in place.

Called by the tool.

Parameters
myctxToolWithConstants context.
clusterThe cluster to correct. It is updated in place.

Does the following:

  • Checks whether the cluster is present in the given calorimeter and sampling. If not, do nothing.
  • Computes quantities to pass to makeTheCorrection.
  • Calls makeTheCorrection.

Definition at line 436 of file CaloClusterCorrectionCommon.cxx.

438{
439 int region = m_region (myctx);
440
441 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey, myctx.ctx()};
442 const CaloDetDescrManager* dd_man = *caloMgrHandle;
443
444 // This causes a lot of overhead (mostly from the MsgStream ctor).
445 // Comment out when not needed.
446 //MsgStream log( msgSvc(), name() );
447 //log << MSG::DEBUG << "Entering makeCorrection" << endmsg;
448 //log << MSG::DEBUG << "e, eta, phi, etasize, phisize" << " " << cluster->e() << " " << cluster->eta() << " " << cluster->phi()
449 // << " " << cluster->etasize(CaloSampling::EMB2) << " " << cluster->phisize(CaloSampling::EMB2) << endmsg;
450 //log << MSG::DEBUG << "B / E " << cluster->inBarrel() << " " << cluster->inEndcap() << endmsg;
451 //log << MSG::DEBUG << "region " << region << endmsg;
452
453 float eta;
454 float phi;
455 CaloSampling::CaloSample samp = CaloSampling::Unknown;
456
457 // Find the proper @f$\eta@f$ and @f$\phi@f$ measures of the cluster.
458 // Also set up the sampling code @c samp.
459 switch (region) {
460 case EMB1:
461 case EMB2:
462 case EME1:
463 case EME2:
464 // Return immediately if we can tell we're in the wrong region.
465 if (barrel_p (region)) {
466 if (!cluster->inBarrel()) return;
467 }
468 else {
469 if (!cluster->inEndcap()) return;
470 }
471
472 switch (region) {
473 case EMB1:
474 samp = CaloSampling::EMB1;
475 break;
476 case EMB2:
477 samp = CaloSampling::EMB2;
478 break;
479 case EME1:
480 samp = CaloSampling::EME1;
481 break;
482 case EME2:
483 samp = CaloSampling::EME2;
484 break;
485 }
486
487 eta = cluster->etaSample (samp);
488 phi = cluster->phiSample (samp);
489 break;
490
491 case COMBINED2:
492 eta = cluster->etaBE (2);
493 phi = cluster->phiBE (2);
494 break;
495
496 case CLUSTER:
497 eta = cluster->eta();
498 phi = cluster->phi();
499 break;
500
501 default:
502 abort();
503 }
504
505 // Give up if one of them is an error flag.
506 if (std::abs (phi) > 900 || std::abs (eta) > 900)
507 return;
508
509 // Sometimes unnormalized @f$\phi@f$ values still come through.
510 // Make sure this is in the proper range before calling the correction.
512
513 // Look up the DD element.
514 // Give up if we can't find one.
515 const CaloDetDescrElement* elt = ddhelper(dd_man).find_dd_elt (dd_man,
516 region,
517 cluster,
518 eta, phi);
519 if (!elt)
520 return;
521
522 // Compute the adjusted eta and phi --- the coordinates shifted
523 // from the actual to the nominal coordinate system.
524 float adj_eta = eta - elt->eta() + elt->eta_raw();
525 float adj_phi = CaloPhiRange::fix (phi - elt->phi() + elt->phi_raw());
526
527 // Call the actual correction.
528 makeTheCorrection (myctx, cluster, elt, eta, adj_eta, phi, adj_phi, samp);
529}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
const CaloDetDescrElement * find_dd_elt(const CaloDetDescrManager *dd_mgr, int region, const xAOD::CaloCluster *cluster, float eta, float phi) const
Find the detector descriptor element for a given position, correcting for DD edge bugs.
virtual void makeTheCorrection(const Context &myctx, xAOD::CaloCluster *cluster, const CaloDetDescrElement *elt, float eta, float adj_eta, float phi, float adj_phi, CaloSampling::CaloSample samp) const =0
Virtual function for the correction-specific code.
Constant< int > m_region
Calibration constant: The calorimeter region for which this correction is intended.
static double fix(double phi)
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.

◆ makeTheCorrection() [1/2]

virtual void CaloClusterCorrectionCommon::makeTheCorrection ( const Context & myctx,
xAOD::CaloCluster * cluster,
const CaloDetDescrElement * elt,
float eta,
float adj_eta,
float phi,
float adj_phi,
CaloSampling::CaloSample samp ) const
pure virtualinherited

Virtual function for the correction-specific code.

Parameters
myctxToolWithConstants context.
clusterThe cluster to correct. It is updated in place.
eltThe detector description element corresponding to the cluster location.
etaThe \(\eta\) coordinate of the cluster.
adj_etaThe \(\eta\) adjusted for any shift between the actual and nominal coordinates. (This is shifted back to the nominal coordinate system.)
phiThe \(\phi\) coordinate of the cluster.
adj_phiThe \(\phi\) adjusted for any shift between the actual and nominal coordinates. (This is shifted back to the nominal coordinate system.)
sampIf we're looking at a particular sampling, this is the calorimeter sampling we're examining. It is a sampling code as defined by CaloSampling::CaloSample; i.e., it has both the calorimeter region and sampling encoded. Otherwise, this is Unknown.

Implemented in CaloLongWeights_v2.

◆ makeTheCorrection() [2/2]

void CaloSwCalibHitsCalibration::makeTheCorrection ( const Context & myctx,
xAOD::CaloCluster * cluster,
const CaloDetDescrElement * elt,
float eta,
float adj_eta,
float phi,
float adj_phi,
CaloSampling::CaloSample samp ) const
overridevirtual

Virtual function for the correction-specific code.

Parameters
myctxToolWithConstants context.
clusterThe cluster to correct. It is updated in place.
eltThe detector description element corresponding to the cluster location.
etaThe \(\eta\) coordinate of the cluster, in this sampling.
adj_etaThe \(\eta\) adjusted for any shift between the actual and nominal coordinates. (This is shifted back to the nominal coordinate system.)
phiThe \(\phi\) coordinate of the cluster, in this sampling.
adj_phiThe \(\phi\) adjusted for any shift between the actual and nominal coordinates. (This is shifted back to the nominal coordinate system.)
sampThe calorimeter sampling we're examining. This is a sampling code as defined by CaloSampling::CaloSample; i.e., it has both the calorimeter region and sampling encoded.

Definition at line 56 of file CaloSwCalibHitsCalibration.cxx.

65{
66 // ??? In principle, we should use adj_eta for the interpolation
67 // and range checks. However, the v2 corrections were derived
68 // using regular eta instead.
69 float the_aeta;
70 if (m_use_raw_eta (myctx))
71 the_aeta = std::abs (adj_eta);
72 else
73 the_aeta = std::abs (eta);
74
75 const float etamax = m_etamax (myctx);
76 if (the_aeta >= etamax) return;
77
78 const float eta_start_crack = m_eta_start_crack (myctx);
79 const float eta_end_crack = m_eta_end_crack (myctx);
80 int si;
81 if (the_aeta < eta_start_crack)
82 si = 0;
83 else if (the_aeta > eta_end_crack)
84 si = 1;
85 else {
86 // No corrections are applied for the crack region.
87 return;
88 }
89
90 const CxxUtils::Array<3> correction = m_correction (myctx);
91
92// the_aeta = std::abs (cluster->eta() );
93
94
95 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
96 ATH_MSG_DEBUG( " USING CALIBHITS CALIBRATION " << endmsg);
97 ATH_MSG_DEBUG( " Tool Name " << name() << endmsg);
98 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
99
100 unsigned int shape[] = {2};
101 CaloRec::WritableArrayData<1> interp_barriers (shape);
102 interp_barriers[0] = eta_start_crack;
103 interp_barriers[1] = eta_end_crack;
104
105 int ibin = (static_cast<int> (the_aeta / etamax * 100)) ;
106
107 int ibin_frontCorr = ibin;
108 if (m_fix_v6_pathologies (myctx)) {
109 if (the_aeta>2.35) ibin_frontCorr = (static_cast<int> (2.35 / etamax * 100)) ;
110 }
111
112// -------------------------------------------------------------
113// Load calibration coefficients
114// -------------------------------------------------------------
115
116 CaloRec::Array<1> acc = correction[0][ibin];
117 CaloRec::Array<1> ooc = correction[1][ibin];
118 CaloRec::Array<1> lleak = correction[2][ibin];
119 CaloRec::Array<1> froffset = correction[3][ibin_frontCorr];
120 CaloRec::Array<1> frslope = correction[4][ibin_frontCorr];
121 CaloRec::Array<1> sec = correction[5][ibin_frontCorr];
122
123 ATH_MSG_DEBUG( "Check etas -------------------------------------------------------------------"<< endmsg);
124 ATH_MSG_DEBUG( "Eta --> " << the_aeta << " Bin --> " << ibin <<" Cluster eta = " << cluster->eta() << endmsg);
125 ATH_MSG_DEBUG( "ETA = " << std::abs (adj_eta) << " ADJ_ETA = " << std::abs (eta)<< endmsg);
126
127 ATH_MSG_DEBUG( "Check calibration coefficients -----------------------------------------------"<< endmsg);
128 ATH_MSG_DEBUG( "Accordion : " << acc[0] <<" " << acc[1]
129 << " " << acc[2] << " " << acc[3] << endmsg);
130 ATH_MSG_DEBUG( "OutOfCOne : " << ooc[0] <<" " << ooc[1]
131 << " " << ooc[2] << " " << ooc[3] << endmsg);
132 ATH_MSG_DEBUG( "Leakage : " << lleak[0] <<" " << lleak[1]
133 << " " << lleak[2] << " " << lleak[3] << endmsg);
134 ATH_MSG_DEBUG( "Front offset: " << froffset[0] <<" "
135 <<froffset[1] << " " << froffset[2] << " " << froffset[3] <<endmsg);
136 ATH_MSG_DEBUG( "Front Slope : " << frslope[0] <<" " << frslope[1]
137 << " " << frslope[2] << " " << frslope[3] << endmsg);
138 ATH_MSG_DEBUG( "Second order: " << sec[0] << " " << sec[1]
139 << " " << sec[2] << " " << sec[3] << endmsg);
140
141 static const CaloSampling::CaloSample samps[2][4] = {
142 { CaloSampling::PreSamplerB,
143 CaloSampling::EMB1,
144 CaloSampling::EMB2,
145 CaloSampling::EMB3 },
146 { CaloSampling::PreSamplerE,
147 CaloSampling::EME1,
148 CaloSampling::EME2,
149 CaloSampling::EME3 }
150 };
151
152 // Compute longitudinal barycenter: this is a very old and approximate
153 // parametrization that needs to be updated.
154 double shower_lbary = CaloClusterCorr::CaloSwCalibHitsShowerDepth::depth (the_aeta,
155 eta_start_crack,
156 eta_end_crack,
157 m_sampling_depth(myctx),
158 etamax,
159 cluster, msg() );
160 if (shower_lbary == 0) return;
161
162 if (shower_lbary < 5. || shower_lbary > 25.) {
163 shower_lbary =15.;
164 ATH_MSG_DEBUG( " replace pathological depth by 15 X0" << endmsg);
165 }
166
167 // Compute total energy in the accordion (eacc_base) and
168 // presampler (eps_base)
169
170 double eacc_base = 0;
171 for (int sampling=1; sampling<4; sampling++) {
172 eacc_base += cluster->eSample(samps[si][sampling]);
173 ATH_MSG_DEBUG( "Barrel/endcap = " << si << " Sampling = " << sampling << " Energy -->> " << cluster->eSample(samps[si][sampling]) << endmsg);
174 }
175 double eps_base = cluster->eSample (samps[si][0]);
176
177 ATH_MSG_DEBUG( "E accordion base --->>>> " << eacc_base << " Eps base " << eps_base << endmsg);
178
179 // Add a protection against large longitudinal barycenter for clusters from
180 // hadrons which may cause over-calibration. A energy dependent upper limit
181 // on the long bary is introduced (from 20 at 0 to 23 at 1 TeV)
182
183 double depth_max = 20. + (eacc_base+eps_base)*(3./TeV) ;
184 ATH_MSG_DEBUG( "Raw energy ---->> " << (eacc_base+eps_base) << endmsg) ;
185 ATH_MSG_DEBUG( "Bary max for this event ---->> " << depth_max
186 << endmsg) ;
187
188 if ( shower_lbary > depth_max ) {
189 shower_lbary = 15.;
190 //shower_lbary = depth_max;
191 ATH_MSG_DEBUG( " replace pathological depth by 15 X0 "
192 << endmsg);
193 }
194
195
196
197// -------------------------------------------------------------
198// Now calibrate the accordion
199// -------------------------------------------------------------
200
201 double acc_corr =
202 acc[1] + acc[2] * shower_lbary + acc[3] * shower_lbary * shower_lbary ;
203
204 double e_out_perc = 0;
205 if (the_aeta < eta_start_crack) {
206 e_out_perc = ooc[1] + ooc[2] * shower_lbary + ooc[3] * shower_lbary * shower_lbary ;
207 }
208 else if (the_aeta > eta_end_crack) {
209 e_out_perc = ooc[1] + ooc[2] * shower_lbary + ooc[3] / shower_lbary ;
210 }
211
212 double e_acc_reco=acc_corr*(eacc_base )*(1+(e_out_perc)*0.01);
213
214// -------------------------------------------------------------
215// Now estimate the longitudinal leakage
216// -------------------------------------------------------------
217
218 double e_leak_perc = 0;
219/*
220 if (the_aeta < eta_start_crack) {
221 e_leak_perc = lleak[1] + lleak[2] * shower_lbary + lleak[3] * exp(shower_lbary);
222 } else if (the_aeta > eta_end_crack) {
223 e_leak_perc = lleak[1] * shower_lbary + lleak[2] * exp(shower_lbary);
224 }
225*/
226 e_leak_perc = lleak[3] + lleak[1] * shower_lbary + lleak[2] * exp(shower_lbary);
227
228 if (e_leak_perc < 0 ) e_leak_perc = 0.;
229 if (e_leak_perc > 100.) e_leak_perc = 100.;
230 double e_leak_reco = e_leak_perc * (e_acc_reco)*0.01;
231
232// -------------------------------------------------------------
233// Now estimate the energy lost in front of the calorimeter
234// -------------------------------------------------------------
235
236 // raw_energy = e_acc_reco ;
237
238 double raw_energy=e_acc_reco*1e-3;
239 double e_front_reco = eps_base;
240
241 if (raw_energy <= 1) {
242 // Protect against log() going negative in pow();
243 // also protect against sqrt() of a negative number and div-by-zero.
244 }
245 else if (the_aeta < 1.8) {
246
247 if (the_aeta < eta_start_crack) {
248 double WpsOff = froffset[1] + froffset[2] * raw_energy +
249 froffset[3] * raw_energy * raw_energy;
250 double WpsSlo = frslope[1] * pow(log(raw_energy),
251 static_cast<double>(frslope[2])) +
252 frslope[3] *sqrt( raw_energy );
253 e_front_reco=WpsOff + WpsSlo*(eps_base );
254
255 ATH_MSG_DEBUG( " raw event " << raw_energy << endmsg);
256 ATH_MSG_DEBUG( " froffset coeff " << froffset[1] << " " << froffset[2] << " " << froffset[3] << endmsg);
257 ATH_MSG_DEBUG( " frslope coeff " << frslope[1] << " " << frslope[2] << " " << frslope[3] << endmsg);
258 ATH_MSG_DEBUG( " WpsOff,WpsSlo " << WpsOff << " " << WpsSlo << endmsg);
259 ATH_MSG_DEBUG( " eps_base, efront_reco " << eps_base << " " << e_front_reco << endmsg);
260 }
261 else{
262
263 if (raw_energy<20.) raw_energy=20.;
264
265 double WpsOff = froffset[1] + froffset[2] * raw_energy +
266 froffset[3] * sqrt(raw_energy);
267 double WpsSlo = frslope[1] + frslope[2] * log(raw_energy) +
268 frslope[3] * sqrt(raw_energy);
269 double WpsSlo2 = sec[1] + sec[2] * raw_energy -
270 sec[3] / (raw_energy * raw_energy) ;
271 e_front_reco=WpsOff + WpsSlo*(eps_base) + WpsSlo2*(eps_base)*(eps_base);
272 if (e_front_reco<0.) e_front_reco= eps_base;
273
274 ATH_MSG_DEBUG( " raw energy " << raw_energy << endmsg);
275 ATH_MSG_DEBUG( "p1 " << froffset[1] << " "
276 << froffset[2] << " " << froffset[3] << " " << WpsOff << endmsg);
277 ATH_MSG_DEBUG( "p2 " << frslope[1] << " "
278 << frslope[2] << " " << frslope[3] << " " << WpsSlo << endmsg);
279 ATH_MSG_DEBUG( "p3 " << sec[1] << " "
280 << sec[2] << " " << sec[3] << " " << WpsSlo2 << endmsg);
281 ATH_MSG_DEBUG( " WpsOff, WpsSlo, WpsSlo2 " << WpsOff << " " << WpsSlo << " " << WpsSlo2 << endmsg);
282 ATH_MSG_DEBUG( " eps_base, efront_reco " << eps_base << " " << e_front_reco << endmsg);
283
284 }
285
286 }
287 else {
288
289 double p1 = froffset[1] + froffset[2] * raw_energy +
290 froffset[3]* raw_energy * raw_energy ;
291 double p2 = frslope[1] + frslope[2] * raw_energy +
292 frslope[3] * raw_energy * raw_energy ;
293 double p3 = sec[1] + sec[2] * raw_energy +
294 sec[3] * raw_energy * raw_energy ;
295
296 ATH_MSG_DEBUG( "p1 " << froffset[1] << " "
297 << froffset[2] << " " << froffset[3] << endmsg);
298 ATH_MSG_DEBUG( "p2 " << frslope[1] << " "
299 << frslope[2] << " " << frslope[3] << endmsg);
300 ATH_MSG_DEBUG( "p3 " << sec[1] << " "
301 << sec[2] << " " << sec[3] << endmsg);
302
303 e_front_reco= (p1 + p2 * shower_lbary + p3 * shower_lbary * shower_lbary);
304 if (e_front_reco<0.) e_front_reco=eps_base;
305 }
306
307// -------------------------------------------------------------
308// Now compute the total energy and finally update the cluster energies
309// -------------------------------------------------------------
310
311 double e_calo_reco =e_front_reco + e_leak_reco + e_acc_reco;
312
313 ATH_MSG_DEBUG( "CaloSwCalibrationHits::Final reco energy ---------------------- " << e_calo_reco << endmsg);
314 ATH_MSG_DEBUG( "CaloSwCalibrationHits::Front ---------------------- " << e_front_reco << endmsg);
315 ATH_MSG_DEBUG( "CaloSwCalibrationHits::Accordion ------------------ " << e_acc_reco << endmsg);
316 ATH_MSG_DEBUG( "CaloSwCalibrationHits::out of cone ---------------- " << acc_corr*(eacc_base )*(e_out_perc)*0.01 << endmsg);
317 ATH_MSG_DEBUG( "CaloSwCalibrationHits::Leakage -------------------- " << e_leak_reco << endmsg);
318
319
320
321/*
322 -------------------------------------------------------------
323 Conventions discussed in Dec 2007 larg week to fill energies in the samplings:
324 E = total energy including all corrections
325 E0 = total energy in front of the accordion :
326 presampler energy + energy lost in front + energy lost between PS and strips
327 E1 = energy in the strips with no out of cone corrections
328 E2 = energy in the middle with no out of cone corrections
329 E3 = energy in the back with no out of cone correction + longitudinal leakage
330
331 Please note that E != E0+E1+E2+E3
332 -------------------------------------------------------------
333*/
334 if (m_updateSamplingEnergies (myctx))
335 {
336 // presampler
337
338 cluster->setEnergy (samps[si][0], e_front_reco );
339
340 // strips and middle
341
342 for (int sampling=1; sampling<=2; sampling++){
343 cluster->setEnergy (samps[si][sampling], cluster->eSample(samps[si][sampling]) * acc_corr );
344 }
345
346 // back
347
348 cluster->setEnergy (samps[si][3], cluster->eSample (samps[si][3]) * acc_corr + e_leak_reco);
349 }
350// total energy
351
352 double e_temp = 0;
353 for (int nl = 0 ; nl< 4 ; nl++) e_temp += cluster->eSample (samps [si][nl]);
354
355 ATH_MSG_DEBUG( "---------- Sum of the sampling energy --- >> " << e_temp << " EcaloReco = " << e_calo_reco << endmsg);
356
357 cluster->setE (e_calo_reco);
358
359 ATH_MSG_DEBUG( "CaloSwCalibHitsCalibration::Energy after correction --> " << cluster->e() << endmsg);
360
361}
constexpr int pow(int base, int exp) noexcept
static double depth(const float aeta, const float start_crack, const float end_crack, const CaloRec::Array< 2 > &sampling_depth, const float etamax, const xAOD::CaloCluster *cluster, MsgStream &log)
Calculate the depth of the cluster.
Constant< CxxUtils::Array< 2 > > m_sampling_depth
Read-only multidimensional array.
float eSample(const CaloSample sampling) const
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.
correction(mu, runmode, campaign, run=None)
Definition zlumi_mc_cf.py:4
MsgStream & msg
Definition testRead.cxx:32

◆ mergeConstants()

virtual StatusCode CaloUtils::ToolWithConstants< BASE >::mergeConstants ( CaloRec::ToolConstants & out,
const EventContext & ctx ) const
overridevirtualinherited

Merge our constants into out with the proper prefix.

Parameters
[out]outObject to receive our constants.
ctxEvent context.

◆ setenergy()

void CaloClusterCorrection::setenergy ( xAOD::CaloCluster * cluster,
float energy ) const
virtualinherited

Definition at line 94 of file CaloClusterCorrection.cxx.

95{
96 if (cluster->e() == 0) {
97 if (energy != 0)
98 REPORT_MESSAGE (MSG::WARNING)
99 << "Attempt to rescale zero-energy cluster to energy " << energy
100 << " ignored.";
101 return;
102 }
103
104 float correction = energy/cluster->e();
105 cluster->setE(energy);
106
107 // also correct individual sampling energies:
108
109 for (int iSample=CaloSampling::PreSamplerB;
110 iSample < CaloSampling::Unknown;
111 ++iSample)
112 {
113 CaloSampling::CaloSample sampling=static_cast<CaloSampling::CaloSample>(iSample);
114 if (cluster->hasSampling (sampling)) {
115 double e = cluster->eSample(sampling);
116 cluster->setEnergy(sampling,e*correction) ;
117 }
118 }
119}
#define REPORT_MESSAGE(LVL)
Report a message.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.

◆ setsample()

void CaloClusterCorrection::setsample ( xAOD::CaloCluster * cluster,
CaloSampling::CaloSample sampling,
float em,
float etam,
float phim,
float emax,
float etamax,
float phimax,
float etas,
float phis ) const
virtualinherited

Definition at line 74 of file CaloClusterCorrection.cxx.

79{
80 cluster->setEnergy(sampling, em);
81 cluster->setEta(sampling, etam);
82 cluster->setPhi(sampling, phim);
83
84 cluster->setEmax(sampling,emax);
85 cluster->setEtamax(sampling,etamax);
86 cluster->setPhimax(sampling,phimax);
87
88 cluster->setEtasize(sampling, etas);
89 cluster->setPhisize(sampling, phis);
90}
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEtasize(const CaloSample sampling, const float etaSize)
Set the cluster size in for a given sampling.
bool setPhisize(const CaloSample sampling, const float phiSize)
Set the cluster size in for a given sampling.
bool setPhimax(const CaloSample sampling, const float phiMax)
Set the phi of the cell with the highest energy in a particular sampling.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEmax(const CaloSample sampling, const float eMax)
Set the Energy of the cell with the highest energy in a particular sampling.
bool setEtamax(const CaloSample sampling, const float etaMax)
Set the eta of the cell with the highest energy in a particular sampling.

◆ toolType()

virtual const std::string & CaloUtils::ToolWithConstants< BASE >::toolType ( ) const
virtualinherited

Return the name of the type of this tool.

A saved set of constants includes both the C++ class name and a version number. Normally, the class name is taken from the Gaudi type() method, but that may be changed by overriding this method. This can be used, for example, when there are tools with distinct C++ classes but which are yet similar enough to combine together.

Reimplemented in CaloSwEta1b_g3, CaloSwEta1e_g3, CaloSwEta2b_g3, and CaloSwEta2e_g3.

◆ toolVersion()

virtual int CaloUtils::ToolWithConstants< BASE >::toolVersion ( ) const
virtualinherited

Return the version number for this tool.

A saved set of constants includes both the C++ class name and a version number. The idea is that the version number can be bumped whenever there's a backwards-incompatible change; this gives some protection against trying to use an old version of a tool with an incompatible newer set of constants.

If you want a tool to have a version number, override this method. Otherwise, it will default to a version number of 0.

◆ writeConstants()

virtual void CaloUtils::ToolWithConstants< BASE >::writeConstants ( std::ostream & stream,
const std::string & name,
const EventContext & ctx ) const
virtualinherited

Dump method (for debugging)

Parameters
streamOstream to which to write.
nameName to go in output
ctxEvent context.

Member Data Documentation

◆ CaloSwCalibHitsCalibration_versions

list CaloSwCalibHitsCalibration.CaloSwCalibHitsCalibration_versions

Definition at line 28 of file CaloSwCalibHitsCalibration.py.

◆ cls

CaloSwCalibHitsCalibration.cls = CompFactory.CaloSwCalibHitsCalibration

Definition at line 27 of file CaloSwCalibHitsCalibration.py.

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> CaloClusterCorrection::m_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager"}
protectedinherited

Definition at line 83 of file CaloClusterCorrection.h.

83{this,"CaloDetDescrManager", "CaloDetDescrManager"};

◆ m_correction

Constant<CxxUtils::Array<3> > CaloSwCalibHitsCalibration::m_correction { this, "correction", "" }
private

Definition at line 62 of file CaloSwCalibHitsCalibration.h.

62{ this, "correction", "" };

◆ m_DBHandle

Handle to a ToolConstants conditions object.

Definition at line 534 of file ToolWithConstants.h.

535{ this, "DBHandleKey", "", "" };

◆ m_ddhelper

CxxUtils::CachedUniquePtr<const CaloClusterCorr::DDHelper> CaloClusterCorrectionCommon::m_ddhelper
privateinherited

Helper for detector description lookup.

Definition at line 165 of file CaloClusterCorrectionCommon.h.

◆ m_eta_end_crack

Constant<float> CaloSwCalibHitsCalibration::m_eta_end_crack { this, "eta_end_crack", "" }
private

Definition at line 65 of file CaloSwCalibHitsCalibration.h.

65{ this, "eta_end_crack", "" };

◆ m_eta_start_crack

Constant<float> CaloSwCalibHitsCalibration::m_eta_start_crack { this, "eta_start_crack", "" }
private

Definition at line 64 of file CaloSwCalibHitsCalibration.h.

64{ this, "eta_start_crack", "" };

◆ m_etamax

Constant<float> CaloSwCalibHitsCalibration::m_etamax { this, "etamax", "" }
private

Definition at line 66 of file CaloSwCalibHitsCalibration.h.

66{ this, "etamax", "" };

◆ m_fix_v6_pathologies

Constant<bool> CaloSwCalibHitsCalibration::m_fix_v6_pathologies { this, "fix_v6_pathologies", "" }
private

Definition at line 68 of file CaloSwCalibHitsCalibration.h.

68{ this, "fix_v6_pathologies", "" };

◆ m_impl

ToolWithConstantsImpl CaloUtils::ToolWithConstants< BASE >::m_impl
privateinherited

Internal implementation object.

Definition at line 542 of file ToolWithConstants.h.

542{ this->name(), m_prefix, m_DBHandle };
Hold constants for a tool.

◆ m_isdummy

Constant<bool> CaloUtils::ToolWithConstants< BASE >::m_isdummy
privateinherited

If true, then this is a dummy tool that should not be executed.

This is used for the case of reading from COOL using hierarchical tags: we need to have such tags associated with some object in each folder, regardless of whether or not the correction from that folder is actually used. [Every folder that IOVDbSvc knows about at configuration time needs to have a valid object for the configured tag, else IOVDbSvc will raise a fatal error. But we don't know at configuration time which folders we're actually going to need, so we gotta configure all of them.]

Definition at line 560 of file ToolWithConstants.h.

561{this, "isDummy", false };

◆ m_order

Constant<int> CaloUtils::ToolWithConstants< BASE >::m_order
privateinherited

Used to fix the ordering of tools when we're initializing from COOL based on a hierarchical tag.

Tools should be executed in order of increasing m_order.

Definition at line 547 of file ToolWithConstants.h.

548{ this, "order", 0 };

◆ m_prefix

StringProperty CaloUtils::ToolWithConstants< BASE >::m_prefix
privateinherited

Prefix for finding our constants within the ToolConstants object.

Definition at line 538 of file ToolWithConstants.h.

539{ this, "prefix", "", "" };

◆ m_region

Constant<int> CaloClusterCorrectionCommon::m_region { this, "region", "Calorimeter region" }
privateinherited

Calibration constant: The calorimeter region for which this correction is intended.

This should be one of the constants above. This affects the meaning of the eta and phi arguments passed to makeTheCorrection, as well as the samp argument.

Definition at line 161 of file CaloClusterCorrectionCommon.h.

162{ this, "region", "Calorimeter region" };

◆ m_sampling_depth

Constant<CxxUtils::Array<2> > CaloSwCalibHitsCalibration::m_sampling_depth { this, "sampling_depth", "" }
private

Definition at line 63 of file CaloSwCalibHitsCalibration.h.

63{ this, "sampling_depth", "" };

◆ m_updateSamplingEnergies

Constant<bool> CaloSwCalibHitsCalibration::m_updateSamplingEnergies { this, "update_sampling_energies", true, "" }
private

Definition at line 69 of file CaloSwCalibHitsCalibration.h.

69{ this, "update_sampling_energies", true, "" };

◆ m_use_raw_eta

Constant<bool> CaloSwCalibHitsCalibration::m_use_raw_eta { this, "use_raw_eta", "" }
private

Definition at line 67 of file CaloSwCalibHitsCalibration.h.

67{ this, "use_raw_eta", "" };

The documentation for this class was generated from the following files: