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
virtual StatusCode initialize () override

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

Private Attributes

SG::ReadCondHandleKey< CaloLocalHadCoeffm_key {this, "HadDMCoeffKey", "HadDMCoeff2"}
 name of the key for DM cell weights
Gaudi::Property< int > m_recoStatus {this, "ClusterRecoStatus", CaloRecoStatus::UNKNOWNSTATUS}
 Required Reco Status for the clusters in order to be calibrated.
Gaudi::Property< int > m_weightModeDM {this, "WeightModeDM", 1}
 method of assignment of DM energy to cluster
Gaudi::Property< float > m_MinClusterEnergyToDeal {this, "MinClusterEnergyToDeal", 200.0*CLHEP::MeV}
 Minimum energy of clusters to apply correction.
Gaudi::Property< int > m_MinLookupBinNentry {this, "MinLookupBinNentry", 40}
 minimum number of events in one lookup bin to use
Gaudi::Property< float > m_MinCellEnergyToDeal {this, "MinCellEnergyToDeal", 0.0}
 minimum cell energy to deal
Gaudi::Property< float > m_MaxChangeInCellWeight {this, "MaxChangeInCellWeight", 30.0}
 maximum allowed change in cell weights
Gaudi::Property< bool > m_useHadProbability {this, "UseHadProbability", false}
 calculate DM energy using em-probability moment
Gaudi::Property< bool > m_interpolate {this, "Interpolate", false}
 interpolate correction coefficients
Gaudi::Property< bool > m_updateSamplingVars {this, "UpdateSamplingVars", false}
 update also sampling variables
Gaudi::Property< 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)
Gaudi::Property< bool > m_absOpt {this, "WeightingOfNegClusters", false}
 In Abs Option case, DM calculation has to be handled in a slightly different way.

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 42 of file CaloLCDeadMaterialTool.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 52 of file CaloLCDeadMaterialTool.h.

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

Constructor & Destructor Documentation

◆ ~CaloLCDeadMaterialTool()

CaloLCDeadMaterialTool::~CaloLCDeadMaterialTool ( )
overridevirtualdefault

Member Function Documentation

◆ initialize()

StatusCode CaloLCDeadMaterialTool::initialize ( )
overridevirtual

Definition at line 31 of file CaloLCDeadMaterialTool.cxx.

32{
33 if(m_interpolate) {
34 msg(MSG::INFO) << "Interpolation is ON, dimensions: ";
35 for(std::map<std::string, std::vector<std::string> >::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
36 msg(MSG::INFO) << " " << (*it).first << " (";
37 for(std::vector<std::string >::iterator it2 = (*it).second.begin(); it2!=(*it).second.end(); ++it2) {
38 msg() << (*it2) << " ";
39 }
40 msg() << ")";
41 }
42 msg() << endmsg;
43 for(std::map<std::string, std::vector<std::string> >::iterator it=m_interpolateDimensionNames.begin(); it!=m_interpolateDimensionNames.end(); ++it){
44 std::vector<int > *vtmp=nullptr;
45 if((*it).first == "AREA_DMFIT") {
47 }else if((*it).first == "AREA_DMLOOKUP") {
49 }else if((*it).first == "AREA_DMSMPW") {
51 }else{
52 ATH_MSG_WARNING("Unkown dead material area type '" << (*it).first << "'");
53 continue;
54 }
55 for(std::vector<std::string >::iterator it2 = (*it).second.begin(); it2!=(*it).second.end(); ++it2) {
58 vtmp->push_back(int(id));
59 }else{
60 ATH_MSG_WARNING( "Dimension '" << (*it2) << "' is invalid and will be excluded." );
61 }
62 }
63 }
64 } // m_interpolate
65
66 ATH_MSG_INFO( "Initializing " << name() );
67
68
69 ATH_CHECK(m_key.initialize());
70
71 return StatusCode::SUCCESS;
72}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
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)
SG::ReadCondHandleKey< CaloLocalHadCoeff > m_key
name of the key for DM cell weights
Gaudi::Property< bool > m_interpolate
interpolate correction coefficients
Gaudi::Property< 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...
LocalHadDimensionId
enums to identify user dimensions id number DIMC_* - classification, DIMW_*-weighting,...
MsgStream & msg
Definition testRead.cxx:32

◆ 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 472 of file CaloLCDeadMaterialTool.cxx.

478{
479 areas.resize(data->getSizeAreaSet());
480 cells.reserve (theCluster->size());
481
482 bzero(smp_energy, CaloSampling::Unknown*sizeof(float));
483
484 // Finding of energy and noise in different "areas" of cluster. Some of these
485 // areas correspond to CaloSamplings, others are special.
486 CaloCluster::const_cell_iterator itrCell = theCluster->cell_begin();
487 CaloCluster::const_cell_iterator itrCellEnd = theCluster->cell_end();
488 cls_unweighted_energy = 0;
489 for (;itrCell!=itrCellEnd; ++itrCell) {
490 CxxUtils::prefetchNext(itrCell, itrCellEnd);
491 const CaloCell* thisCell = *itrCell;
492 //Identifier id = thisCell->ID();
493 CaloSampling::CaloSample nsmp=thisCell->caloDDE()->getSampling();
494 //CaloSampling::CaloSample nsmp = CaloSampling::CaloSample(m_calo_id->calo_sample(id));
495
496 float energy = thisCell->e();
497 float weight = itrCell.weight();
498 cls_unweighted_energy += energy;
499
500 Cell cell{};
501 cell.weight = weight;
502 cell.energy = energy;
503 cell.dm = sDM;
504
505 smp_energy[nsmp] += energy; // unweighted energy in samplings for given cluster
506
507 if(energy > m_MinCellEnergyToDeal) {
508
509 if ( nsmp == CaloSampling::PreSamplerB || nsmp == CaloSampling::EMB1) {
510 cell.dm = sDM_EMB0_EMB1;
511
512 } else if( nsmp == CaloSampling::TileGap3 ) {
513 cell.dm = sDM_SCN;
514
515 } else if ( nsmp == CaloSampling::PreSamplerE || nsmp == CaloSampling::EME1 ) {
516 cell.dm = sDM_EME0_EME12;
517
518 } else if (nsmp == CaloSampling::EME3) {
519 cell.dm = sDM_EME3_HEC0;
520
521 } else if (nsmp == CaloSampling::HEC0) {
522 cell.dm = sDM_EME3_HEC0;
523
524 } else if (nsmp == CaloSampling::EMB3) {
525 cell.dm = sDM_EMB3_TILE0;
526
527 } else if (nsmp == CaloSampling::TileBar0) {
528 cell.dm = sDM_EMB3_TILE0;
529 }
530
531 } // cell_ener > cell_min_energy
532 cells.push_back (cell);
533 } // itrCell
534
535// 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
536 if(m_absOpt){
537
538 for(unsigned int i=0; i != CaloSampling::Unknown; ++ i) smp_energy[i] = fabs(theCluster->eSample((CaloSampling::CaloSample)i));
539
540 }
541
542
543 // calculation of 'signal' which will be used for DM energy estimation
544 float x(0), y(0);
545
546 // sDM_EMB0_EMB1: energy before EMB0 and between EMB0 and EMB1
547 x = smp_energy[CaloSampling::PreSamplerB];
548 if ( x > 0.) {
549 areas[sDM_EMB0_EMB1].eprep = x;
550 areas[sDM_EMB0_EMB1].edm_wrong = x;
551 }
552
553 // sDM_EMB3_TILE0: to correct energy between barrel and tile
554 x = smp_energy[CaloSampling::EMB3];
555 y = smp_energy[CaloSampling::TileBar0];
556 if ( x > 0. && y>0.) areas[sDM_EMB3_TILE0].eprep = sqrt(x*y);
557
558 // sDM_SCN: to correct energy before scintillator
559 x = smp_energy[CaloSampling::TileGap3];
560 if ( x > 0.) {
561 areas[sDM_SCN].eprep = x;
562 areas[sDM_SCN].edm_wrong = x;
563 }
564
565 // sDM_EME0_EME12: sum of energy before EME0 and between EME0 and EME1
566 x = smp_energy[CaloSampling::PreSamplerE];
567 if ( x > 0.) {
568 areas[sDM_EME0_EME12].eprep = x;
569 areas[sDM_EME0_EME12].edm_wrong = x;
570 }
571
572 // sDM_EME3_HEC0: to correct energy between EMEC and HEC
573 x = smp_energy[CaloSampling::EME3];
574 y = smp_energy[CaloSampling::HEC0];
575 if ( x > 0. && y>0.) areas[sDM_EME3_HEC0].eprep = sqrt(x*y);
576
577 areas[sDM_FCAL].eprep = cls_unweighted_energy;
578 areas[sDM_LEAKAGE].eprep = cls_unweighted_energy;
579 areas[sDM_UNCLASS].eprep = cls_unweighted_energy;
580
581 return StatusCode::SUCCESS;
582}
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
Gaudi::Property< bool > m_absOpt
In Abs Option case, DM calculation has to be handled in a slightly different way.
Gaudi::Property< float > m_MinCellEnergyToDeal
minimum cell energy to deal
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

◆ weight()

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

Definition at line 79 of file CaloLCDeadMaterialTool.cxx.

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

Member Data Documentation

◆ m_absOpt

Gaudi::Property<bool> CaloLCDeadMaterialTool::m_absOpt {this, "WeightingOfNegClusters", false}
private

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

Definition at line 168 of file CaloLCDeadMaterialTool.h.

168{this, "WeightingOfNegClusters", false};

◆ m_interpolate

Gaudi::Property<bool> CaloLCDeadMaterialTool::m_interpolate {this, "Interpolate", false}
private

interpolate correction coefficients

Definition at line 139 of file CaloLCDeadMaterialTool.h.

139{this, "Interpolate", false};

◆ m_interpolateDimensionNames

Gaudi::Property<std::map<std::string, std::vector<std::string> > > CaloLCDeadMaterialTool::m_interpolateDimensionNames
private
Initial value:
{this
, "InterpolateDimensionNames"
, {
{"AREA_DMFIT" , {"DIMD_ETA", "DIMD_ENER"}}
, {"AREA_DMLOOKUP" , {"DIMD_ETA", "DIMD_ENER", "DIMD_LAMBDA"}}
, {"AREA_DMSMPW" , {"DIMD_ETA", "DIMD_LAMBDA"}}
}
}

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

Definition at line 147 of file CaloLCDeadMaterialTool.h.

147 {this
148 , "InterpolateDimensionNames"
149 , {
150 {"AREA_DMFIT" , {"DIMD_ETA", "DIMD_ENER"}}
151 , {"AREA_DMLOOKUP" , {"DIMD_ETA", "DIMD_ENER", "DIMD_LAMBDA"}}
152 , {"AREA_DMSMPW" , {"DIMD_ETA", "DIMD_LAMBDA"}}
153 }
154 };

◆ 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 158 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 161 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 164 of file CaloLCDeadMaterialTool.h.

◆ m_key

SG::ReadCondHandleKey<CaloLocalHadCoeff> CaloLCDeadMaterialTool::m_key {this, "HadDMCoeffKey", "HadDMCoeff2"}
private

name of the key for DM cell weights

Definition at line 98 of file CaloLCDeadMaterialTool.h.

98{this, "HadDMCoeffKey", "HadDMCoeff2"};

◆ m_MaxChangeInCellWeight

Gaudi::Property<float> CaloLCDeadMaterialTool::m_MaxChangeInCellWeight {this, "MaxChangeInCellWeight", 30.0}
private

maximum allowed change in cell weights

Definition at line 126 of file CaloLCDeadMaterialTool.h.

126{this, "MaxChangeInCellWeight", 30.0};

◆ m_MinCellEnergyToDeal

Gaudi::Property<float> CaloLCDeadMaterialTool::m_MinCellEnergyToDeal {this, "MinCellEnergyToDeal", 0.0}
private

minimum cell energy to deal

Definition at line 122 of file CaloLCDeadMaterialTool.h.

122{this, "MinCellEnergyToDeal", 0.0};

◆ m_MinClusterEnergyToDeal

Gaudi::Property<float> CaloLCDeadMaterialTool::m_MinClusterEnergyToDeal {this, "MinClusterEnergyToDeal", 200.0*CLHEP::MeV}
private

Minimum energy of clusters to apply correction.

Definition at line 114 of file CaloLCDeadMaterialTool.h.

114{this, "MinClusterEnergyToDeal", 200.0*CLHEP::MeV};

◆ m_MinLookupBinNentry

Gaudi::Property<int> CaloLCDeadMaterialTool::m_MinLookupBinNentry {this, "MinLookupBinNentry", 40}
private

minimum number of events in one lookup bin to use

Definition at line 118 of file CaloLCDeadMaterialTool.h.

118{this, "MinLookupBinNentry", 40};

◆ m_recoStatus

Gaudi::Property<int> CaloLCDeadMaterialTool::m_recoStatus {this, "ClusterRecoStatus", CaloRecoStatus::UNKNOWNSTATUS}
private

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

Definition at line 102 of file CaloLCDeadMaterialTool.h.

102{this, "ClusterRecoStatus", CaloRecoStatus::UNKNOWNSTATUS};

◆ m_updateSamplingVars

Gaudi::Property<bool> CaloLCDeadMaterialTool::m_updateSamplingVars {this, "UpdateSamplingVars", false}
private

update also sampling variables

Definition at line 143 of file CaloLCDeadMaterialTool.h.

143{this, "UpdateSamplingVars", false};

◆ m_useHadProbability

Gaudi::Property<bool> CaloLCDeadMaterialTool::m_useHadProbability {this, "UseHadProbability", false}
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 135 of file CaloLCDeadMaterialTool.h.

135{this, "UseHadProbability", false};

◆ m_weightModeDM

Gaudi::Property<int> CaloLCDeadMaterialTool::m_weightModeDM {this, "WeightModeDM", 1}
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 110 of file CaloLCDeadMaterialTool.h.

110{this, "WeightModeDM", 1};

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