20using namespace std::string_literals;
34 msg(MSG::INFO) <<
"Interpolation is ON, dimensions: ";
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) <<
" ";
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") {
52 ATH_MSG_WARNING(
"Unkown dead material area type '" << (*it).first <<
"'");
55 for(std::vector<std::string >::iterator it2 = (*it).second.begin(); it2!=(*it).second.end(); ++it2) {
58 vtmp->push_back(
int(
id));
60 ATH_MSG_WARNING(
"Dimension '" << (*it2) <<
"' is invalid and will be excluded." );
71 return StatusCode::SUCCESS;
84 float wrong_dm_energy = 0.0;
96 double eWeighted = theCluster->
e();
116 set_zero_moments(theCluster);
118 return StatusCode::SUCCESS;
124 ATH_MSG_ERROR(
"Cannot retrieve EM_PROBABILITY cluster moment, "
125 <<
" cluster energy " << theCluster->
e() <<
" remains the same." );
126 return StatusCode::FAILURE;
130 }
else if ( pi0Prob > 1 ) {
137 double center_lambda = 0;
139 ATH_MSG_ERROR(
"Cannot retrieve CENTER_LAMBDA cluster moment, "
140 <<
" cluster energy " << theCluster->
e() <<
" remains the same." );
141 return StatusCode::FAILURE;
149 return StatusCode::FAILURE;
152 ATH_MSG_DEBUG(
"Cluster is selected for local DM calibration."
153 <<
" Old cluster energy:" << theCluster->
e()
157 std::vector<Area> areas;
158 std::vector<Cell> cells;
159 float smp_energy[CaloSampling::Unknown];
160 float cls_unweighted_energy = 0;
162 smp_energy, cls_unweighted_energy,
data);
163 if ( !
sc.isSuccess() ) {
165 set_zero_moments(theCluster);
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);
180 if(center_lambda > 0.0) {
181 log10lambda = log10(center_lambda);
182 if(log10lambda >=4.0) log10lambda = 3.9999;
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;
194 std::vector<float > vars;
203 size_t n_dm =
data->getSizeAreaSet();
206 for(
int i_mix=0; i_mix<2; i_mix++){
207 float mixWeight = (i_mix==0?(1-pi0Prob):pi0Prob);
208 if(mixWeight == 0)
continue;
213 for(
size_t i_dm=0; i_dm < n_dm; i_dm++){
214 if(areas[i_dm].eprep <= 0.0)
continue;
218 if(log10ener > emax) log10ener = emax - 0.0001;
222 if( !pars )
continue;
244 const int nSmp=pars->size()-1;
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];
252 ecalonew += (*pars)[nSmp];
253 edm = ecalonew - ecaloold;
270 std::cout <<
"CaloLCDeadMaterialTool -> Error! Unknown correction type " <<
area->getType()
271 <<
" with number of parameters " <<
area->getNpars() << std::endl;
273 wrong_dm_energy += areas[i_dm].edm_wrong;
276 std::cout <<
" result> edm: " << edm <<
" edm_wrong:" << edm_wrong << std::endl;
278 edm -= areas[i_dm].edm_wrong;
280 areas[i_dm].erec = areas[i_dm].erec + edm*mixWeight;
292 std::cout <<
"wc> calculation of weights" << std::endl;
298 theCluster->
setE(cls_initial_energy + dm_total - wrong_dm_energy);
303 float sub_ener_old = 0.0;
304 for(
size_t i_c = 0; i_c < cells.size(); i_c++)
306 const Cell& cell = cells[i_c];
308 sub_ener_old += cell.weight*cell.energy;
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++)
315 cells[i_c].weight *= corr;
323 for (
size_t cell_index = 0; cell_index < cells.size(); ++cell_index)
325 const Cell& cell = cells[cell_index];
327 float we = cell.weight * cell.energy;
329 areas[cell.dm].sub_ener_old += we;
335 for(
size_t i_dm=0; i_dm < areas.size(); i_dm++) {
336 Area& dma = areas[i_dm];
338 if (i_dm >= n_dm || dma.
eprep <= 0)
354 for (
size_t cell_index = 0; cell_index < cells.size(); ++cell_index)
356 Cell& cell = cells[cell_index];
359 cell.weight *= areas[cell.dm].corr;
360 cell.weight *= gblfac;
371 for (;itrCell!=itrCellEnd; ++itrCell) {
373 const float old_weight = itrCell.
weight();
374 float new_weight = cells[cell_index].weight;
378 new_weight = old_weight;
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;
392 <<
" (contains wrongly estimated DM energy: " << wrong_dm_energy <<
")"
393 <<
" calculated DM energy (to be added):" << dm_total
394 <<
" new cluster energy:" << theCluster->
e());
406 x = (double)smp_energy[CaloSampling::PreSamplerB];
409 x = (double)smp_energy[CaloSampling::PreSamplerE];
412 x = (double)smp_energy[CaloSampling::TileGap3];
415 x = (double)(dm_total+wrong_dm_energy);
418 for(
size_t i_dm=0; i_dm < areas.size(); i_dm++) {
419 Area& dma = areas[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];
436 if ( eWeighted > 0 || eWeighted < 0 ) {
437 weightMom *= theCluster->
e()/eWeighted;
441 return StatusCode::SUCCESS;
451 theCluster->
insertMoment(CaloCluster::ENG_RECO_EMB0, 0.0);
452 theCluster->
insertMoment(CaloCluster::ENG_RECO_EME0, 0.0);
453 theCluster->
insertMoment(CaloCluster::ENG_RECO_TILEG3, 0.0);
454 theCluster->
insertMoment(CaloCluster::ENG_RECO_DEAD_TOT, 0.0);
455 for(
size_t i_dm=0; i_dm < DeadMaterialCorrectionTool2::sDM; i_dm++) {
474 std::vector<Area>& areas,
475 std::vector<Cell>& cells,
479 areas.resize(
data->getSizeAreaSet());
480 cells.reserve (theCluster->size());
482 bzero(smp_energy, CaloSampling::Unknown*
sizeof(
float));
488 cls_unweighted_energy = 0;
489 for (;itrCell!=itrCellEnd; ++itrCell) {
491 const CaloCell* thisCell = *itrCell;
496 float energy = thisCell->
e();
498 cls_unweighted_energy += energy;
502 cell.energy = energy;
505 smp_energy[nsmp] += energy;
509 if ( nsmp == CaloSampling::PreSamplerB || nsmp == CaloSampling::EMB1) {
512 }
else if( nsmp == CaloSampling::TileGap3 ) {
515 }
else if ( nsmp == CaloSampling::PreSamplerE || nsmp == CaloSampling::EME1 ) {
518 }
else if (nsmp == CaloSampling::EME3) {
521 }
else if (nsmp == CaloSampling::HEC0) {
524 }
else if (nsmp == CaloSampling::EMB3) {
527 }
else if (nsmp == CaloSampling::TileBar0) {
532 cells.push_back (cell);
547 x = smp_energy[CaloSampling::PreSamplerB];
554 x = smp_energy[CaloSampling::EMB3];
555 y = smp_energy[CaloSampling::TileBar0];
559 x = smp_energy[CaloSampling::TileGap3];
566 x = smp_energy[CaloSampling::PreSamplerE];
573 x = smp_energy[CaloSampling::EME3];
574 y = smp_energy[CaloSampling::HEC0];
577 areas[
sDM_FCAL].eprep = cls_unweighted_energy;
581 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
Data object for each calorimeter readout cell.
virtual double e() const override final
get energy (data member) (synonym to method energy()
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
weight_t weight() const
Accessor for weight associated to this cell.
weight_t weight() const
Accessor for weight associated to this cell.
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
defines enums and data types for different moments of CaloCluster
Principal data class for CaloCell clusters.
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
bool retrieveMoment(const moment_type &momType, moment_value &momValue, bool useLink=true) const
Retrieve individual moment.
virtual double e() const
Retrieve energy independent of signal state.
void insertMoment(const moment_type &momType, const moment_value &momValue, bool useLink=true)
Set individual moment.
virtual double eta() const
Retrieve eta independent of signal state.
virtual double phi() const
Retrieve phi independent of signal state.
virtual void setE(double e)
Set energy.
cell_iterator cell_end() const
Retrieve a STL-type end() iterator for the cell store.
void reweightCell(const CaloCell *pCell, double weight)
Reweight a cell with kinematic update.
cell_iterator cell_begin() const
Retrieve a STL-type begin() iterator for the cell store.
CaloCell_ID::CaloSample getSampling() const
cell sampling
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.)
static CaloLocalHadDefs::LocalHadDimensionId getDimensionId(const std::string &dimensionName)
Definition of correction area.
Hold binned correction data for local hadronic calibration procedure.
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version).
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly 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.
void prefetchNext(Iter iter, Iter endIter)
Prefetch next object in sequence.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Functions to prefetch blocks of memory.
LocalHadDimensionId
enums to identify user dimensions id number DIMC_* - classification, DIMW_*-weighting,...