7#include "GaudiKernel/ITHistSvc.h"
26using Athena::Units::GeV;
33 declareInterface<IJetDecorator>(
this);
48 return StatusCode::FAILURE;
50 TFile tf(fname.c_str());
52 ATH_MSG( ERROR ) <<
"Could not open file " << fname <<
endmsg;
53 return StatusCode::FAILURE;
56 std::vector<std::string> histsInSvc =
m_thistSvc->getHists();
58 TListIter next(tf.GetListOfKeys());
60 while((obj = next())) {
61 std::string hname=obj->GetName();
62 if(hname.find(
'_')==std::string::npos)
continue;
63 std::string tag = hname.substr(0,hname.find(
'_'));
64 std::string para = hname.substr(hname.find(
'_')+1);
69 if(
find(histsInSvc.begin(),histsInSvc.end(),location)==histsInSvc.end()){
72 ATH_MSG( ERROR ) <<
"failed to read histo " << location <<
endmsg;
73 return StatusCode::FAILURE;
83 int ret = sscanf(para.c_str(),
"sample%d_pt%lf_%lf_eta%lf_%lf_phi%lf_%lf",
84 &sample,&ptMin,&ptMax,&etaMin,&etaMax,&phiMin,&phiMax);
86 if(ret<1 || sample<0 || sample>=CaloCell_ID::Unknown) {
87 ATH_MSG(
DEBUG ) <<
"Could not understand the name of hist " << obj->GetName() <<
endmsg;
94 ATH_MSG( ERROR ) <<
"failed to get histo " << location <<
endmsg;
95 return StatusCode::FAILURE;
97 m_profileDatas[sample].emplace_back(th,sample,ptMin,ptMax,etaMin,etaMax,phiMin,phiMax);
99 <<
" tag=" << tag <<
" sample=" << sample
100 <<
" ptMin=" << ptMin <<
" ptMax=" << ptMax
101 <<
" etaMin=" << etaMin <<
" etaMax=" << etaMax
102 <<
" phiMin=" << phiMin <<
" phiMax=" << phiMax <<
endmsg;
108 ATH_MSG_ERROR(
"JetBadChanCorrTool needs to have its input jet container name configured!");
109 return StatusCode::FAILURE;
125 return StatusCode::SUCCESS;
130 return StatusCode::SUCCESS;
140 if (!handle.isValid()){
142 return StatusCode::FAILURE;
145 const auto *badCellMap = handle.cptr();
154 corrCellHandle(*
jet) = -1.;
155 corrDotxHandle(*
jet) = -1.;
156 corrJetHandle(*
jet) = -1.;
157 corrJetForCellHandle(*
jet) = -1.;
159 return StatusCode::SUCCESS;
175 double rawPt = p4.Pt();
176 double rawE = p4.E();
179 double corr_jet_associate=0;
180 double corr_jet_forcell=0;
187 for( ;cellIt!=cellItE; ++cellIt) {
191 double cellWeight = cellIt.
weight();
193 double cell_energy = cell->e() * cellWeight;
197 bool considerBad = cell->badcell();
204 if(cell->provenance() & 0x0200)
210 double frac = frac_cell * cellWeight;
212 corr_jet_associate += frac;
218 corr_dotx += cell_energy;
220 corr_cell += cell_energy;
222 corr_jet_forcell += frac;
227 const double inv_rawE = 1. / rawE;
228 corr_cell *= inv_rawE;
229 corr_dotx *= inv_rawE;
231 <<
" BCH_CORR_CELL=" << corr_cell
232 <<
" BCH_CORR_DOTX=" << corr_dotx
233 <<
" BCH_CORR_JET=" << corr_jet_associate
234 <<
" BCH_CORR_JET_FORCELL=" << corr_jet_forcell <<
endmsg;
236 corrCellHandle(*
jet) = corr_cell;
237 corrDotxHandle(*
jet) = corr_dotx;
238 corrJetForCellHandle(*
jet) = corr_jet_forcell;
242 corrJetHandle(*
jet) = corr_jet_associate;
244 return StatusCode::SUCCESS;
249 ATH_MSG_DEBUG(
" Missing cells for cone search "<< badCellMap->
size() <<
" jet="<<
jet->index() <<
" R="
250 <<
jet->getSizeParameter() <<
" input="<<
jet->getInputType() <<
" jet_eta="<<
jet->eta() ) ;
252 double corr_jet_cone=0;
256 double jeteta =
jet->eta();
257 double jetphi =
jet->phi();
258 std::vector<jet::CellPosition> closeCells = badCellMap->
cellsInDeltaR(jeteta,jetphi,
jet->getSizeParameter() );
259 std::vector<jet::CellPosition>::iterator itr = closeCells.begin();
260 std::vector<jet::CellPosition>::iterator itrE = closeCells.end();
262 for(; itr!=itrE; ++itr){
264 double cell_eta = itr->x();
265 double cell_phi = itr->phi();
270 double frac_cell =
getProfile(rawPt, dr, sampling, cell_eta, cell_phi);
272 corr_jet_cone += frac_cell;
275 return corr_jet_cone;
286 size_t nconstit=
jet->numConstituents();
287 for(
size_t i=0; i<nconstit; i++) {
293 if(v) corrCell += badE;
297 if(rawE==0) corrCellHandle(*
jet) = 0;
298 else corrCellHandle(*
jet) = corrCell / rawE;
300 return StatusCode::SUCCESS;
304 std::vector<ProfileData>::const_iterator itr =
m_profileDatas[sample].begin();
305 std::vector<ProfileData>::const_iterator itrE =
m_profileDatas[sample].end();
306 for(; itr!=itrE; ++itr){
308 return (*itr).frac(dr);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
Helpers for checking error return status codes and reporting errors.
Handle class for adding a decoration to an object.
Wrapper to avoid constant divisions when using units.
CaloSampling::CaloSample CaloSample
Data object for each calorimeter readout cell.
This class groups all DetDescr information related to a CaloCell.
bool is_tile() const
cell belongs to Tile
CaloCell_ID::CaloSample getSampling() const
cell sampling
float eta() const
cell eta
float phi() const
cell phi
unsigned int size() const
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Handle class for adding a decoration to an object.
std::vector< CellPosition > cellsInDeltaR(double eta, double phi, double r) const
weight_t weight() const
Accessor for weight associated to this cell.
static const_iterator begin(const xAOD::Jet *jet)
static const_iterator end(const xAOD::Jet *jet)
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
Class providing the definition of the 4-vector interface.
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
std::string find(const std::string &s)
return a remapped string
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ CaloCluster
The object is a calorimeter cluster.
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.