ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLCDeadMaterialTool Class Reference

dead material correction tool for local hadronic calibration More...

#include <CaloLCDeadMaterialTool.h>

Inheritance diagram for CaloLCDeadMaterialTool:
Collaboration diagram for CaloLCDeadMaterialTool:

Classes

struct  Area
struct  Cell

Public Types

enum  dm_area_keys {
  sDM_EMB0_EMB1 , sDM_EMB3_TILE0 , sDM_SCN , sDM_EME0_EME12 ,
  sDM_EME3_HEC0 , sDM_FCAL , sDM_LEAKAGE , sDM_UNCLASS ,
  sDM
}
 Dead Material area number. More...

Public Member Functions

virtual ~CaloLCDeadMaterialTool () override
virtual StatusCode weight (xAOD::CaloCluster *theCluster, const EventContext &ctx) const override
 method to weight the cells in a cluster
virtual StatusCode initialize () override
 CaloLCDeadMaterialTool (const std::string &type, const std::string &name, const IInterface *parent)
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode prepare_for_cluster (const xAOD::CaloCluster *theCluster, std::vector< Area > &areas, std::vector< Cell > &cells, float *smp_energy, float &cls_unweighted_energy, const CaloLocalHadCoeff *data) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadCondHandleKey< CaloLocalHadCoeffm_key
 name of the key for DM cell weights
int m_recoStatus
 Required Reco Status for the clusters in order to be calibrated.
int m_weightModeDM
 method of assignment of DM energy to cluster
float m_MinClusterEnergyToDeal
 Minimum energy of clusters to apply correction.
int m_MinLookupBinNentry
 minimum number of events in one lookup bin to use
float m_MinCellEnergyToDeal
 minimum cell energy to deal
float m_MaxChangeInCellWeight
 maximum allowed change in cell weights
bool m_useHadProbability
 calculate DM energy using em-probability moment
bool m_interpolate
 interpolate correction coefficients
bool m_updateSamplingVars
 update also sampling variables
std::map< std::string, std::vector< std::string > > m_interpolateDimensionNames
 vector of names of dimensions to interpolate (for different correction types different set of dimensions)
std::vector< int > m_interpolateDimensionsFit
 actual set of dimension id's to interpolate (in the DM areas corrected with TProfile approach)
std::vector< int > m_interpolateDimensionsLookup
 actual set of dimension id's to interpolate (in the DM areas corrected with lookup approach)
std::vector< int > m_interpolateDimensionsSampling
 actual set of dimension id's to interpolate (in the DM areas corrected with sampling weight approach)
bool m_absOpt
 In Abs Option case, DM calculation has to be handled in a slightly different way.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

dead material correction tool for local hadronic calibration

Author
Gennady Pospelov guenn.nosp@m.adi..nosp@m.pospe.nosp@m.lov@.nosp@m.cern..nosp@m.ch
Date
09-September-2009

Calculates dead material energy of given cluster. Cluster energy, lambda and eta are used to get appropriate set of DM correction coefficients for appropriate dead material area ( dead material area definition and set of correction coefficients are holded by CaloHadDMCoeff2 class). DM coefficients are applied to cluster cells sums to calculate DM energy in different calorimeter areas. Finally, calculated DM energy is added to the cluster by changing (increasing) cluster cells weights in appropriate samplings.

Definition at line 39 of file CaloLCDeadMaterialTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ dm_area_keys

Dead Material area number.

These keys are used to identify specific dead material areas in the calorimeter where procedure of DM correction will be applied

Enumerator
sDM_EMB0_EMB1 
sDM_EMB3_TILE0 
sDM_SCN 
sDM_EME0_EME12 
sDM_EME3_HEC0 
sDM_FCAL 
sDM_LEAKAGE 
sDM_UNCLASS 
sDM 

Definition at line 47 of file CaloLCDeadMaterialTool.h.

48 {
49 sDM_EMB0_EMB1, // 0 before PreSamplerB, between PreSamplerB and EMB1
50 sDM_EMB3_TILE0, // 1 between barrel and tile
51 sDM_SCN, // 2 before TileGap3 (scintillator)
52 sDM_EME0_EME12, // 3 before PreSamplerE, between PreSamplerE and EME1
53 sDM_EME3_HEC0, // 4 between EME3 and HEC0
54 sDM_FCAL, // 5 between HEC and FCAL, before FCAL
55 sDM_LEAKAGE, // 6 leakage behind calorimeter
56 sDM_UNCLASS, // 7 unclassified DM enegry
57 sDM
58 };

Constructor & Destructor Documentation

◆ ~CaloLCDeadMaterialTool()

CaloLCDeadMaterialTool::~CaloLCDeadMaterialTool ( )
overridevirtualdefault

◆ CaloLCDeadMaterialTool()

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

Definition at line 33 of file CaloLCDeadMaterialTool.cxx.

36 : AthAlgTool(type,name,parent),
37 m_key("HadDMCoeff2"),
40 m_MinClusterEnergyToDeal(200.0*MeV),
45 m_interpolate(false),
46 m_absOpt(false)
47{
48 declareInterface<IClusterCellWeightTool>(this);
49 declareProperty("HadDMCoeffKey",m_key);
50 declareProperty("ClusterRecoStatus",m_recoStatus);
51 declareProperty("WeightModeDM",m_weightModeDM) ;
52 declareProperty("MinClusterEnergyToDeal", m_MinClusterEnergyToDeal);
53 declareProperty("MinLookupBinNentry", m_MinLookupBinNentry);
54 declareProperty("MinCellEnergyToDeal", m_MinCellEnergyToDeal);
55 declareProperty("MaxChangeInCellWeight", m_MaxChangeInCellWeight);
56 declareProperty("UseHadProbability",m_useHadProbability);
57 // Use Interpolation or not
58 declareProperty("Interpolate",m_interpolate);
59 // list of dimensions to interpolate trought in 3 different type of areas
60 m_interpolateDimensionNames["AREA_DMFIT"s] = {"DIMD_ETA"s, "DIMD_ENER"s};
61 m_interpolateDimensionNames["AREA_DMLOOKUP"s] = {"DIMD_ETA"s, "DIMD_ENER"s, "DIMD_LAMBDA"s};
62 m_interpolateDimensionNames["AREA_DMSMPW"s] = {"DIMD_ETA"s, "DIMD_LAMBDA"s};
63 declareProperty("InterpolateDimensionNames", m_interpolateDimensionNames);
64 declareProperty("UpdateSamplingVars",m_updateSamplingVars=false);
65 //Use weighting of negative clusters?
66 declareProperty("WeightingOfNegClusters",m_absOpt);
67}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int m_recoStatus
Required Reco Status for the clusters in order to be calibrated.
bool m_absOpt
In Abs Option case, DM calculation has to be handled in a slightly different way.
bool m_useHadProbability
calculate DM energy using em-probability moment
bool m_updateSamplingVars
update also sampling variables
SG::ReadCondHandleKey< CaloLocalHadCoeff > m_key
name of the key for DM cell weights
float m_MaxChangeInCellWeight
maximum allowed change in cell weights
int m_MinLookupBinNentry
minimum number of events in one lookup bin to use
float m_MinClusterEnergyToDeal
Minimum energy of clusters to apply correction.
std::map< std::string, std::vector< std::string > > m_interpolateDimensionNames
vector of names of dimensions to interpolate (for different correction types different set of dimensi...
int m_weightModeDM
method of assignment of DM energy to cluster
float m_MinCellEnergyToDeal
minimum cell energy to deal
bool m_interpolate
interpolate correction coefficients

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode CaloLCDeadMaterialTool::initialize ( )
overridevirtual

Definition at line 80 of file CaloLCDeadMaterialTool.cxx.

81{
82 if(m_interpolate) {
83 msg(MSG::INFO) << "Interpolation is ON, dimensions: ";
84 for(std::map<std::string, std::vector<std::string> >::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
85 msg(MSG::INFO) << " " << (*it).first << " (";
86 for(std::vector<std::string >::iterator it2 = (*it).second.begin(); it2!=(*it).second.end(); ++it2) {
87 msg() << (*it2) << " ";
88 }
89 msg() << ")";
90 }
91 msg() << endmsg;
92 for(std::map<std::string, std::vector<std::string> >::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
93 std::vector<int > *vtmp=nullptr;
94 if((*it).first == "AREA_DMFIT") {
96 }else if((*it).first == "AREA_DMLOOKUP") {
98 }else if((*it).first == "AREA_DMSMPW") {
100 }else{
101 msg(MSG::WARNING) << "Unkown dead material area type '" << (*it).first << "'" << std::endl;
102 continue;
103 }
104 for(std::vector<std::string >::iterator it2 = (*it).second.begin(); it2!=(*it).second.end(); ++it2) {
107 vtmp->push_back(int(id));
108 }else{
109 ATH_MSG_WARNING( "Dimension '" << (*it2) << "' is invalid and will be excluded." );
110 }
111 }
112 }
113 } // m_interpolate
114
115 ATH_MSG_INFO( "Initializing " << name() );
116
117
118 ATH_CHECK(m_key.initialize());
119
120 return StatusCode::SUCCESS;
121}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
MsgStream & msg() const
static CaloLocalHadDefs::LocalHadDimensionId getDimensionId(const std::string &dimensionName)
std::vector< int > m_interpolateDimensionsFit
actual set of dimension id's to interpolate (in the DM areas corrected with TProfile approach)
std::vector< int > m_interpolateDimensionsSampling
actual set of dimension id's to interpolate (in the DM areas corrected with sampling weight approach)
std::vector< int > m_interpolateDimensionsLookup
actual set of dimension id's to interpolate (in the DM areas corrected with lookup approach)
LocalHadDimensionId
enums to identify user dimensions id number DIMC_* - classification, DIMW_*-weighting,...

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & IClusterCellWeightTool::interfaceID ( )
inlinestaticinherited

Definition at line 28 of file IClusterCellWeightTool.h.

28 {
29 static const InterfaceID IID_IClusterCellWeightTool("IClusterCellWeightTool", 1 , 0);
30 return IID_IClusterCellWeightTool;
31 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepare_for_cluster()

StatusCode CaloLCDeadMaterialTool::prepare_for_cluster ( const xAOD::CaloCluster * theCluster,
std::vector< Area > & areas,
std::vector< Cell > & cells,
float * smp_energy,
float & cls_unweighted_energy,
const CaloLocalHadCoeff * data ) const
private

Definition at line 521 of file CaloLCDeadMaterialTool.cxx.

527{
528 areas.resize(data->getSizeAreaSet());
529 cells.reserve (theCluster->size());
530
531 bzero(smp_energy, CaloSampling::Unknown*sizeof(float));
532
533 // Finding of energy and noise in different "areas" of cluster. Some of these
534 // areas correspond to CaloSamplings, others are special.
535 CaloCluster::const_cell_iterator itrCell = theCluster->cell_begin();
536 CaloCluster::const_cell_iterator itrCellEnd = theCluster->cell_end();
537 cls_unweighted_energy = 0;
538 for (;itrCell!=itrCellEnd; ++itrCell) {
539 CxxUtils::prefetchNext(itrCell, itrCellEnd);
540 const CaloCell* thisCell = *itrCell;
541 //Identifier id = thisCell->ID();
542 CaloSampling::CaloSample nsmp=thisCell->caloDDE()->getSampling();
543 //CaloSampling::CaloSample nsmp = CaloSampling::CaloSample(m_calo_id->calo_sample(id));
544
545 float energy = thisCell->e();
546 float weight = itrCell.weight();
547 cls_unweighted_energy += energy;
548
549 Cell cell{};
550 cell.weight = weight;
551 cell.energy = energy;
552 cell.dm = sDM;
553
554 smp_energy[nsmp] += energy; // unweighted energy in samplings for given cluster
555
556 if(energy > m_MinCellEnergyToDeal) {
557
558 if ( nsmp == CaloSampling::PreSamplerB || nsmp == CaloSampling::EMB1) {
559 cell.dm = sDM_EMB0_EMB1;
560
561 } else if( nsmp == CaloSampling::TileGap3 ) {
562 cell.dm = sDM_SCN;
563
564 } else if ( nsmp == CaloSampling::PreSamplerE || nsmp == CaloSampling::EME1 ) {
565 cell.dm = sDM_EME0_EME12;
566
567 } else if (nsmp == CaloSampling::EME3) {
568 cell.dm = sDM_EME3_HEC0;
569
570 } else if (nsmp == CaloSampling::HEC0) {
571 cell.dm = sDM_EME3_HEC0;
572
573 } else if (nsmp == CaloSampling::EMB3) {
574 cell.dm = sDM_EMB3_TILE0;
575
576 } else if (nsmp == CaloSampling::TileBar0) {
577 cell.dm = sDM_EMB3_TILE0;
578 }
579
580 } // cell_ener > cell_min_energy
581 cells.push_back (cell);
582 } // itrCell
583
584// Realculate sampling energy as the abs value of the original cluster, if you summed up energies, fluctuations wouldn't cancel and sample energy would be huge
585 if(m_absOpt){
586
587 for(unsigned int i=0; i != CaloSampling::Unknown; ++ i) smp_energy[i] = fabs(theCluster->eSample((CaloSampling::CaloSample)i));
588
589 }
590
591
592 // calculation of 'signal' which will be used for DM energy estimation
593 float x(0), y(0);
594
595 // sDM_EMB0_EMB1: energy before EMB0 and between EMB0 and EMB1
596 x = smp_energy[CaloSampling::PreSamplerB];
597 if ( x > 0.) {
598 areas[sDM_EMB0_EMB1].eprep = x;
599 areas[sDM_EMB0_EMB1].edm_wrong = x;
600 }
601
602 // sDM_EMB3_TILE0: to correct energy between barrel and tile
603 x = smp_energy[CaloSampling::EMB3];
604 y = smp_energy[CaloSampling::TileBar0];
605 if ( x > 0. && y>0.) areas[sDM_EMB3_TILE0].eprep = sqrt(x*y);
606
607 // sDM_SCN: to correct energy before scintillator
608 x = smp_energy[CaloSampling::TileGap3];
609 if ( x > 0.) {
610 areas[sDM_SCN].eprep = x;
611 areas[sDM_SCN].edm_wrong = x;
612 }
613
614 // sDM_EME0_EME12: sum of energy before EME0 and between EME0 and EME1
615 x = smp_energy[CaloSampling::PreSamplerE];
616 if ( x > 0.) {
617 areas[sDM_EME0_EME12].eprep = x;
618 areas[sDM_EME0_EME12].edm_wrong = x;
619 }
620
621 // sDM_EME3_HEC0: to correct energy between EMEC and HEC
622 x = smp_energy[CaloSampling::EME3];
623 y = smp_energy[CaloSampling::HEC0];
624 if ( x > 0. && y>0.) areas[sDM_EME3_HEC0].eprep = sqrt(x*y);
625
626 areas[sDM_FCAL].eprep = cls_unweighted_energy;
627 areas[sDM_LEAKAGE].eprep = cls_unweighted_energy;
628 areas[sDM_UNCLASS].eprep = cls_unweighted_energy;
629
630 return StatusCode::SUCCESS;
631}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define y
#define x
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
CaloCell_ID::CaloSample getSampling() const
cell sampling
virtual StatusCode weight(xAOD::CaloCluster *theCluster, const EventContext &ctx) const override
method to weight the cells in a cluster
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version)
const_cell_iterator cell_end() const
float eSample(const CaloSample sampling) const
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version)
void prefetchNext(Iter iter, Iter endIter)
Prefetch next object in sequence.
Definition prefetch.h:130

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ weight()

StatusCode CaloLCDeadMaterialTool::weight ( xAOD::CaloCluster * thisCluster,
const EventContext & ctx ) const
overridevirtual

method to weight the cells in a cluster

Parameters
theClusterthe pointer to the CaloCluster to be weighted

this method is purely virtual because every derived class needs to implement it.

Implements IClusterCellWeightTool.

Definition at line 128 of file CaloLCDeadMaterialTool.cxx.

129{
130 CaloLCCoeffHelper hp;
132
133 float wrong_dm_energy = 0.0;
134 float dm_total = 0.0;
135
136
137 double weightMom (1);
138 if (!theCluster->retrieveMoment(CaloCluster::DM_WEIGHT,weightMom)) {
139 ATH_MSG_WARNING ("Cannot find cluster moment DM_WEIGHT");
140 }
141 /* WTF?? re-setting the same moment??
142 theCluster->insertMoment(CaloClusterMoment::DM_WEIGHT,CaloClusterMoment(new_weight),true);
143 */
144
145 double eWeighted = theCluster->e();
146
147// // check desired reco status
148// float cls_em_fraction = 0.0;
149// if ( theCluster->checkRecoStatus(CaloRecoStatus::TAGGEDHAD)) {
150// cls_em_fraction = 0.25;
151// } else if( theCluster->checkRecoStatus(CaloRecoStatus::TAGGEDEM)) {
152// cls_em_fraction = 0.99;
153// }else {
154// log << MSG::DEBUG<<"Cluster was not selected for local DM calibration. Cluster reco status differs from TAGGEDHAD or TAGGEDEM."
155// << " Cluster energy " << theCluster->e() << " remains the same." << endmsg;
156// #ifdef MAKE_MOMENTS
157// set_zero_moments(theCluster);
158// #endif
159// return StatusCode::SUCCESS;
160// }
161
162 if ( theCluster->e() <= m_MinClusterEnergyToDeal) {
163 ATH_MSG_DEBUG("Cluster was not selected for local DM calibration, ecls < m_MinClusterEnergyToDeal (=" <<m_MinClusterEnergyToDeal << ").");
164#ifdef MAKE_MOMENTS
165 set_zero_moments(theCluster);
166#endif
167 return StatusCode::SUCCESS;
168 }
169
170 double pi0Prob = 0;
171 if ( m_useHadProbability) {
172 if (!theCluster->retrieveMoment(CaloCluster::EM_PROBABILITY,pi0Prob)) {
173 ATH_MSG_ERROR("Cannot retrieve EM_PROBABILITY cluster moment, "
174 << " cluster energy " << theCluster->e() << " remains the same." );
175 return StatusCode::FAILURE;
176 }
177 if ( pi0Prob < 0 ) {
178 pi0Prob = 0;
179 } else if ( pi0Prob > 1 ) {
180 pi0Prob = 1;
181 }
182 } else if (theCluster->recoStatus().checkStatus(CaloRecoStatus::TAGGEDEM)) {
183 pi0Prob = 1;
184 }
185
186 double center_lambda = 0;
187 if ( !theCluster->retrieveMoment(CaloCluster::CENTER_LAMBDA, center_lambda) ){
188 ATH_MSG_ERROR("Cannot retrieve CENTER_LAMBDA cluster moment, "
189 << " cluster energy " << theCluster->e() << " remains the same." );
190 return StatusCode::FAILURE;
191 }
192
193 const CaloLocalHadCoeff* data(nullptr);
194 SG::ReadCondHandle<CaloLocalHadCoeff> rch(m_key,ctx);
195 data = *rch;
196 if(data==nullptr) {
197 ATH_MSG_ERROR("Unable to access conditions object");
198 return StatusCode::FAILURE;
199 }
200
201 ATH_MSG_DEBUG("Cluster is selected for local DM calibration."
202 << " Old cluster energy:" << theCluster->e()
203 << " m_weightModeDM:" << m_weightModeDM);
204
205 // calculation of specific cluster quantities for DM correction (i.e. core of procedure)
206 std::vector<Area> areas;
207 std::vector<Cell> cells;
208 float smp_energy[CaloSampling::Unknown];
209 float cls_unweighted_energy = 0;
210 StatusCode sc = prepare_for_cluster(theCluster, areas, cells,
211 smp_energy, cls_unweighted_energy, data);
212 if ( !sc.isSuccess() ) {
213#ifdef MAKE_MOMENTS
214 set_zero_moments(theCluster);
215#endif
216 ATH_MSG_ERROR( "prepare for cluster failed!" );
217 return sc;
218 }
219
220 float cls_initial_energy = theCluster->e();
221 float cls_side = (theCluster->eta()<0?-1.0:1.0);
222 float cls_eta = fabs(theCluster->eta());
223 float cls_phi = theCluster->phi();
224 float log10ener = 0.0;
225 if(cls_unweighted_energy > 0.0) {
226 log10ener = log10(cls_unweighted_energy);
227 }
228 float log10lambda;
229 if(center_lambda > 0.0) {
230 log10lambda = log10(center_lambda);
231 if(log10lambda >=4.0) log10lambda = 3.9999;
232 }else{
233 log10lambda = 0.0;
234 }
235#ifdef DEBUG_DMTHINGS
236 std::cout << " cls_initial_energy: " << cls_initial_energy << " cls_eta: " << cls_eta << std::endl;
237 std::cout << " log10ener: " << log10ener << " log10lambda: " << log10lambda << std::endl;
238 for(int i_smp=0; i_smp<CaloSampling::Unknown; i_smp++){
239 std::cout << " i_smp: " << i_smp << " smp_energy: " << smp_energy[i_smp] << std::endl;
240 }
241#endif
242
243 std::vector<float > vars;
244 vars.resize(6, 0.0);
245 vars[CaloLocalHadDefs::DIMD_EMFRAC] = pi0Prob;
246 vars[CaloLocalHadDefs::DIMD_SIDE] = cls_side;
247 vars[CaloLocalHadDefs::DIMD_ETA] = cls_eta;
248 vars[CaloLocalHadDefs::DIMD_PHI] = cls_phi;
249 vars[CaloLocalHadDefs::DIMD_ENER] = log10ener;
250 vars[CaloLocalHadDefs::DIMD_LAMBDA] = log10lambda;
251
252 size_t n_dm = data->getSizeAreaSet();
253
254 // loop over HAD/EM possibilities for mixing different correction types
255 for(int i_mix=0; i_mix<2; i_mix++){ // 0 - pure HAD case, 1-pure EM case
256 float mixWeight = (i_mix==0?(1-pi0Prob):pi0Prob);
257 if(mixWeight == 0) continue;
258
260
261 // loop over DM areas defined and calculation of cluster DM energy deposited in these areas
262 for(size_t i_dm=0; i_dm < n_dm; i_dm++){
263 if(areas[i_dm].eprep <= 0.0) continue; // no appropriate signal to reconstruct dm energy in this area
264
265 const CaloLocalHadCoeff::LocalHadArea *area = data->getArea(i_dm);
266 float emax = area->getDimension(CaloLocalHadDefs::DIMD_ENER)->getXmax();
267 if(log10ener > emax) log10ener = emax - 0.0001;
268 vars[CaloLocalHadDefs::DIMD_ENER] = log10ener;
269
270 const CaloLocalHadCoeff::LocalHadCoeff *pars = data->getCoeff(i_dm, vars);
271 if( !pars ) continue;
272
273 float edm = 0.0;
274 // if dm area is reconstructed using polynom fit approach
275 if(area->getType() == CaloLocalHadDefs::AREA_DMFIT) {
276 edm = (*pars)[CaloLocalHadDefs::BIN_P0] + (*pars)[CaloLocalHadDefs::BIN_P1]*areas[i_dm].eprep;
277 if(m_interpolate) {
278 bool isa = CaloLCCoeffHelper::Interpolate(data, i_dm, vars, parint, m_interpolateDimensionsFit, areas[i_dm].eprep);
279 // calculation of fitted values is done already in the interpolator
280 if(isa) edm = parint[CaloLocalHadDefs::BIN_P0];
281 }
282
283 // if dm area is reconstructed using lookup table approach
284 }else if(area->getType() == CaloLocalHadDefs::AREA_DMLOOKUP){
285 if( (*pars)[CaloLocalHadDefs::BIN_ENTRIES] > m_MinLookupBinNentry) edm = cls_unweighted_energy*((*pars)[CaloLocalHadDefs::BIN_WEIGHT] - 1.0 );
286 if(m_interpolate) {
288 if(isa && parint[CaloLocalHadDefs::BIN_ENTRIES] > m_MinLookupBinNentry) edm = cls_unweighted_energy*(parint[CaloLocalHadDefs::BIN_WEIGHT] - 1.0 );
289 }
290
291 // if dm area is reconstructed using new sampling weights
292 }else if(area->getType() == CaloLocalHadDefs::AREA_DMSMPW){
293 const int nSmp=pars->size()-1;
294 //std::cout << "size=" << nSmp << ", unkown value=" << CaloSampling::Unknown << ", minifcal=" << CaloSampling::MINIFCAL0 << std::endl;
295 double ecalonew = 0.0;
296 double ecaloold = 0.0;
297 for(int i_smp=0; i_smp<nSmp; i_smp++){
298 ecaloold += smp_energy[i_smp];
299 ecalonew += smp_energy[i_smp] * (*pars)[i_smp];
300 }
301 ecalonew += (*pars)[nSmp]; // const Used to be CaloSampling::Unknown but the value of this enum has changed to include the miniFCAL.
302 edm = ecalonew - ecaloold;
303
304// if(m_interpolate) {
305// bool isa = hp.Interpolate(data, i_dm, vars, parint, m_interpolateDimensionsSampling);
306// if(isa) {
307// ecalonew = 0.0;
308// ecaloold = 0.0;
309// for(int i_smp=0; i_smp<CaloSampling::Unknown; i_smp++){
310// ecaloold += smp_energy[i_smp];
311// ecalonew += smp_energy[i_smp] * parint[i_smp];
312// }
313// ecalonew += parint[CaloSampling::Unknown]; // const
314// edm = ecalonew - ecaloold;
315// }
316// }
317
318 } else{
319 std::cout << "CaloLCDeadMaterialTool -> Error! Unknown correction type " << area->getType()
320 << " with number of parameters " << area->getNpars() << std::endl;
321 }
322 wrong_dm_energy += areas[i_dm].edm_wrong;
323
324#ifdef DEBUG_DMTHINGS
325 std::cout << " result> edm: " << edm << " edm_wrong:" << edm_wrong << std::endl;
326#endif
327 edm -= areas[i_dm].edm_wrong;
328 if(edm > 0.0) {
329 areas[i_dm].erec = areas[i_dm].erec + edm*mixWeight;
330 dm_total += edm;
331 }
332 } // i_dm
333 } // i_mix
334
335 // giving of calculated DM energy to cluster by one of 3 methods
336 // m_weightModeDM=0 - simple setting of cluster energy to new value
337 // m_weightModeDM=1 - changing (increasing) of weights of cluster cells
338 // m_weightModeDM=2 - changing (increasing) of weights of cluster cells (which were invloved into DM calculation)
339
340#ifdef DEBUG_DMTHINGS
341 std::cout << "wc> calculation of weights" << std::endl;
342#endif
343
344 if(dm_total > 0.0) {
345 if (m_weightModeDM == 0) {
346 // method 0: setting cluster energy to new value without changing of cells weights
347 theCluster->setE(cls_initial_energy + dm_total - wrong_dm_energy);
348
349 } else if (m_weightModeDM == 1) {
350 // method1: calculation of weights of all cluster cells to treat DM energy.
351 // Weights of all cluster cells will be changed proportionally
352 float sub_ener_old = 0.0;
353 for(size_t i_c = 0; i_c < cells.size(); i_c++)
354 {
355 const Cell& cell = cells[i_c];
356 if (cell.energy <= m_MinCellEnergyToDeal) continue;
357 sub_ener_old += cell.weight*cell.energy;
358 }
359 if(sub_ener_old > 0.0) {
360 float corr = (sub_ener_old + dm_total)/sub_ener_old;
361 for(size_t i_c = 0; i_c < cells.size(); i_c++)
362 {
363 if(cells[i_c].energy <= m_MinCellEnergyToDeal) continue;
364 cells[i_c].weight *= corr;
365 }
366 }
367
368 } else if (m_weightModeDM == 2) {
369 // method2: calculation of weights of all cluster cells to treat DM energy.
370 // only weights for cells involved into DM calculation will be changed
371
372 for (size_t cell_index = 0; cell_index < cells.size(); ++cell_index)
373 {
374 const Cell& cell = cells[cell_index];
375 if (cell.energy <= m_MinCellEnergyToDeal) continue;
376 float we = cell.weight * cell.energy;
377 if (cell.dm != sDM)
378 areas[cell.dm].sub_ener_old += we;
379 areas[sDM_FCAL].sub_ener_old += we;
380 areas[sDM_LEAKAGE].sub_ener_old += we;
381 areas[sDM_UNCLASS].sub_ener_old += we;
382 }
383
384 for(size_t i_dm=0; i_dm < areas.size(); i_dm++) {
385 Area& dma = areas[i_dm];
386 float corrfac = 1;
387 if (i_dm >= n_dm || dma.eprep <= 0)
388 corrfac = 1;
389 else if (dma.sub_ener_old > 0)
390 corrfac = (dma.sub_ener_old + dma.erec) / dma.sub_ener_old;
391
392 if (i_dm < sDM_FCAL)
393 areas[sDM_FCAL].sub_ener_old += (corrfac-1)*dma.sub_ener_old;
394 if (i_dm < sDM_LEAKAGE)
395 areas[sDM_LEAKAGE].sub_ener_old += (corrfac-1)*dma.sub_ener_old;
396 if (i_dm < sDM_UNCLASS)
397 areas[sDM_UNCLASS].sub_ener_old += (corrfac-1)*dma.sub_ener_old;
398
399 dma.corr = corrfac;
400 }
401
402 float gblfac = areas[sDM_FCAL].corr * areas[sDM_LEAKAGE].corr * areas[sDM_UNCLASS].corr;
403 for (size_t cell_index = 0; cell_index < cells.size(); ++cell_index)
404 {
405 Cell& cell = cells[cell_index];
406 if (cell.energy <= m_MinCellEnergyToDeal) continue;
407 if (cell.dm != sDM)
408 cell.weight *= areas[cell.dm].corr;
409 cell.weight *= gblfac;
410 }
411 } else {
412 ATH_MSG_ERROR( "Unknown m_weightModeDM " << m_weightModeDM );
413 }
414
415 // setting of calculated weights to the cluster cells
416 if (m_weightModeDM == 1 || m_weightModeDM == 2){
417 int cell_index = 0;
418 CaloCluster::cell_iterator itrCell = theCluster->cell_begin();
419 CaloCluster::cell_iterator itrCellEnd = theCluster->cell_end();
420 for (;itrCell!=itrCellEnd; ++itrCell) {
421 //CaloPrefetch::nextDDE(itrCell, itrCellEnd); no DDE info needed
422 const float old_weight = itrCell.weight();
423 float new_weight = cells[cell_index].weight;
424 if( new_weight < m_MaxChangeInCellWeight*old_weight ){
425 theCluster->reweightCell(itrCell, new_weight);
426 }else{
427 new_weight = old_weight; //Why that? Just for the printout below?
428 }
429#ifdef DEBUG_DMTHINGS
430 std::cout << " cells> " << cell_index << " ener: " << cells[cell_index].energy << " old_w: " << old_weight << " new_w:" << new_weight << std::endl;
431 if( new_weight > 100) std::cout << "DeadMaterialCorrectionTool2 -> Panic! Too large weight" << std::endl;
432#endif
433 cell_index++;
434 }//end loop over cells
436 }//end if method 1 or 2
437
438 } // dm_total > 0.0
439
440 ATH_MSG_DEBUG("cls_initial_energy: " << cls_initial_energy
441 << " (contains wrongly estimated DM energy: " << wrong_dm_energy << ")"
442 << " calculated DM energy (to be added):" << dm_total
443 << " new cluster energy:" << theCluster->e());
444
445#ifdef MAKE_MOMENTS
446 // to save reconstructed energy in different DM areas as cluster moments
448 double xmom;
449 bool result = theCluster->retrieveMoment(xtype, xmom, false);
450
451 if(result) {
452 double x;
453 bool useLink = true;
454
455 x = (double)smp_energy[CaloSampling::PreSamplerB];
456 theCluster->insertMoment(CaloCluster::ENG_RECO_EMB0, x);
457
458 x = (double)smp_energy[CaloSampling::PreSamplerE];
459 theCluster->insertMoment(CaloCluster::ENG_RECO_EME0, x);
460
461 x = (double)smp_energy[CaloSampling::TileGap3];
462 theCluster->insertMoment(CaloCluster::ENG_RECO_TILEG3, x);
463
464 x = (double)(dm_total+wrong_dm_energy);
465 theCluster->insertMoment(CaloCluster::ENG_RECO_DEAD_TOT, x);
466
467 for(size_t i_dm=0; i_dm < areas.size(); i_dm++) {
468 Area& dma = areas[i_dm];
469 CaloCluster::MomentType m_type = (CaloCluster::MomentType) (int(CaloCluster::ENG_RECO_DEAD_EMB0)+i_dm);
470 x = (double)dma.erec;
471 if(i_dm == sDM_EMB0_EMB1 && smp_energy[CaloSampling::PreSamplerB]>0.0) x+= smp_energy[CaloSampling::PreSamplerB];
472 if(i_dm == sDM_EME0_EME12 && smp_energy[CaloSampling::PreSamplerE] > 0.0) x+= smp_energy[CaloSampling::PreSamplerE];
473 if(i_dm == sDM_SCN && smp_energy[CaloSampling::TileGap3] > 0.0) x+= smp_energy[CaloSampling::TileGap3];
474 theCluster->insertMoment(m_type, CaloClusterMoment(x));
475 }
476 }
477
478#endif
479
480 // assume that the weighting could be called more than once. In that
481 // case eWeighted is the result of the previous step and the current
482 // e/eWeighted ratio should be multiplied with the existing
483 // DM_WEIGHT moment
484
485 if ( eWeighted > 0 || eWeighted < 0 ) {
486 weightMom *= theCluster->e()/eWeighted;
487 }
488 theCluster->insertMoment(CaloCluster::DM_WEIGHT,weightMom);
489
490 return StatusCode::SUCCESS;
491}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double area(double R)
static Double_t sc
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 bool Interpolate(const CaloLocalHadCoeff *m_data, const unsigned int n_area, std::vector< float > &x, CaloLocalHadCoeff::LocalHadCoeff &pars, const std::vector< int > &dim, double xfit=0.)
StatusCode prepare_for_cluster(const xAOD::CaloCluster *theCluster, std::vector< Area > &areas, std::vector< Cell > &cells, float *smp_energy, float &cls_unweighted_energy, const CaloLocalHadCoeff *data) const
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version)
MomentType
Enums to identify different moments.
@ EM_PROBABILITY
Classification probability to be em-like.
@ DM_WEIGHT
Dead-material weight (E_dm/E_ooc)
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ ENG_CALIB_DEAD_TOT
Attached Calibration Hit energy in dead material.
::StatusCode StatusCode
StatusCode definition for legacy code.

Member Data Documentation

◆ m_absOpt

bool CaloLCDeadMaterialTool::m_absOpt
private

In Abs Option case, DM calculation has to be handled in a slightly different way.

Definition at line 160 of file CaloLCDeadMaterialTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_interpolate

bool CaloLCDeadMaterialTool::m_interpolate
private

interpolate correction coefficients

Definition at line 138 of file CaloLCDeadMaterialTool.h.

◆ m_interpolateDimensionNames

std::map<std::string, std::vector<std::string > > CaloLCDeadMaterialTool::m_interpolateDimensionNames
private

vector of names of dimensions to interpolate (for different correction types different set of dimensions)

Definition at line 146 of file CaloLCDeadMaterialTool.h.

◆ m_interpolateDimensionsFit

std::vector<int > CaloLCDeadMaterialTool::m_interpolateDimensionsFit
private

actual set of dimension id's to interpolate (in the DM areas corrected with TProfile approach)

Definition at line 150 of file CaloLCDeadMaterialTool.h.

◆ m_interpolateDimensionsLookup

std::vector<int > CaloLCDeadMaterialTool::m_interpolateDimensionsLookup
private

actual set of dimension id's to interpolate (in the DM areas corrected with lookup approach)

Definition at line 153 of file CaloLCDeadMaterialTool.h.

◆ m_interpolateDimensionsSampling

std::vector<int > CaloLCDeadMaterialTool::m_interpolateDimensionsSampling
private

actual set of dimension id's to interpolate (in the DM areas corrected with sampling weight approach)

Definition at line 156 of file CaloLCDeadMaterialTool.h.

◆ m_key

SG::ReadCondHandleKey<CaloLocalHadCoeff> CaloLCDeadMaterialTool::m_key
private

name of the key for DM cell weights

Definition at line 97 of file CaloLCDeadMaterialTool.h.

◆ m_MaxChangeInCellWeight

float CaloLCDeadMaterialTool::m_MaxChangeInCellWeight
private

maximum allowed change in cell weights

Definition at line 125 of file CaloLCDeadMaterialTool.h.

◆ m_MinCellEnergyToDeal

float CaloLCDeadMaterialTool::m_MinCellEnergyToDeal
private

minimum cell energy to deal

Definition at line 121 of file CaloLCDeadMaterialTool.h.

◆ m_MinClusterEnergyToDeal

float CaloLCDeadMaterialTool::m_MinClusterEnergyToDeal
private

Minimum energy of clusters to apply correction.

Definition at line 113 of file CaloLCDeadMaterialTool.h.

◆ m_MinLookupBinNentry

int CaloLCDeadMaterialTool::m_MinLookupBinNentry
private

minimum number of events in one lookup bin to use

Definition at line 117 of file CaloLCDeadMaterialTool.h.

◆ m_recoStatus

int CaloLCDeadMaterialTool::m_recoStatus
private

Required Reco Status for the clusters in order to be calibrated.

Definition at line 101 of file CaloLCDeadMaterialTool.h.

◆ m_updateSamplingVars

bool CaloLCDeadMaterialTool::m_updateSamplingVars
private

update also sampling variables

Definition at line 142 of file CaloLCDeadMaterialTool.h.

◆ m_useHadProbability

bool CaloLCDeadMaterialTool::m_useHadProbability
private

calculate DM energy using em-probability moment

The classification provides the probability p for the current cluster to be em-like. Dead material enegry of cluster is calculated as a mixture of DM energies for pure EM and pure HAD clusters using p as engDM = p *engDM_EM+(1-p)*endDM_HAD

Definition at line 134 of file CaloLCDeadMaterialTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_weightModeDM

int CaloLCDeadMaterialTool::m_weightModeDM
private

method of assignment of DM energy to cluster

if 0: setting cluster energy to the new value without changing of cells weights if 1: weights of all cells in the cluster with energy > m_MinCellEnergyToDeal will be changed if 2: changing only weights of cells which have been involved into DM calculation

Definition at line 109 of file CaloLCDeadMaterialTool.h.


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