13#ifndef XAOD_STANDALONE
45 JetTileCorrectionTool :: JetTileCorrectionTool(
const std::string&
name )
55 JetTileCorrectionTool :: ~JetTileCorrectionTool()
63 StatusCode JetTileCorrectionTool :: initialize() {
76 std::string projectName =
"";
78 if ( projectName ==
"IS_SIMULATION" )
m_isMC =
true;
79 else if (projectName.compare(0, 4,
"data") == 0 )
m_isMC =
false;
95 m_rootFile = TFile::Open( fname.c_str(),
"READ" );
99 return StatusCode::FAILURE;
109 for(
unsigned int ieta=0; ieta <
Pix_eta ; ieta++){
110 for(
unsigned int iphi=0; iphi <
Pix_phi ; iphi++){
111 sub = Form(
"_%d_%d",ieta,iphi);
132 ATH_MSG_ERROR(
"Loading the central value systematic set failed.");
133 return StatusCode::FAILURE;
139 return StatusCode::FAILURE;
145 return StatusCode::SUCCESS;
175 float newPt =
jet.pt();
176 float newM =
jet.m();
178 for(
auto cf : cfactors){
186 newp4.SetCoordinates(newPt,
jet.eta(),
jet.phi(), newM);
188 jet.setJetP4( newp4 );
201 "There's a possible memory leak!" );
207 std::unique_ptr< xAOD::Jet > newobj(
new xAOD::Jet( input ) );
214 output = newobj.release();
224 return sys.find (systematic) != sys.end ();
244 StatusCode JetTileCorrectionTool :: applySystematicVariation (
const SystematicSet& systConfig ) {
256 ATH_MSG_ERROR(
"Unsupported combination of systematics passed to the tool!");
257 return StatusCode::FAILURE;
261 itr =
m_systFilter.insert(std::make_pair(systConfig, filteredSys)).first;
266 return StatusCode::SUCCESS;
272 double phisize = region.
phi2-region.
phi1;
273 double phicenter = (region.
phi1+region.
phi2)/2.;
280 if( std::abs(TVector2::Phi_mpi_pi(jet_phi-phicenter)) >
m_RJET+phisize/2.)
return TS::GOOD;
289 void JetTileCorrectionTool :: loadDeadUser(){
297 std::stringstream
ss(
r);
300 std::vector<std::string> tokens;
301 while (getline(
ss, s,
' ')) {
305 if(tokens.size() < 2){
306 ATH_MSG_ERROR(
"Part-Module pair " <<
r <<
" not known! Please use \"PART MOD\" format ");
311 int i_mod = std::atoi((tokens.at(1)).c_str());
312 if (tokens.at(0).find(
'B') != std::string::npos)
315 if(tokens.at(0)==
"LBA" || tokens.at(0)==
"0"){
317 }
else if (tokens.at(0)==
"LBC" || tokens.at(0)==
"1"){
319 }
else if (tokens.at(0)==
"EBA" || tokens.at(0)==
"2"){
321 }
else if (tokens.at(0)==
"EBC" || tokens.at(0)==
"3"){
324 ATH_MSG_ERROR(
"Part-Module pair " <<
r <<
" not known! Please use \"PART MOD\" format ");
340 void JetTileCorrectionTool :: loadDeadDB(){
345 std::vector<Hole> dbholes={};
376 std::ifstream mapFile;
377 mapFile.open(mapFilename);
380 while (std::getline(mapFile, line)){
382 if(line[0]==
'#')
continue;
384 std::istringstream iss(line);
385 int part,mod, irun, erun;
388 if (!(iss >> part >> mod >> irun >> erun >> modname)) {
break; }
391 rdead.
iov = std::make_pair(irun,erun);
392 dbholes.push_back( rdead );
398 for(
const auto&
h : dbholes){
399 if(std::abs(
h.eta1)>1 || std::abs(
h.eta2)>1){
409 ATH_MSG_DEBUG(
"Adding DB dead module at (eta1,phi1)=(" <<
h.eta1 <<
"," <<
h.phi1 <<
")");
416 float eta = (mod.eta1+mod.eta2)/2.;
417 float phi = (mod.phi1+mod.phi2)/2.;
422 float eta_dist = jet_eta-
eta;
423 float phi_dist = TVector2::Phi_mpi_pi((
double)jet_phi - (
double)
phi);
427 if(std::abs(phi_dist)<0.05){ inphi=0; }
428 else if(std::abs(phi_dist)<0.1){ inphi=1; }
429 else if(std::abs(phi_dist)<0.2){ inphi=2; }
430 else if(std::abs(phi_dist)<0.3){ inphi=3; }
431 else if(std::abs(phi_dist)<0.4){ inphi=4; }
435 int ineta = (
int)ieta;
439 if(mod.eta1 < -0.1) ineta = -ineta;
441 return std::make_pair(ineta+8, inphi);
450 for (
const auto& mod : hmap){
468 if(cstatus > status) status = cstatus;
482 ATH_MSG_ERROR(
"Something went wrong while loading/checking the modules!");
489 StatusCode JetTileCorrectionTool :: addTileStatus(
const xAOD::Jet&
jet){
492 return StatusCode::SUCCESS;
495 void JetTileCorrectionTool :: setRJET(
float r){
508 if(
evtStore()->retrieve( ei,
"EventInfo" ).isFailure() ) {
514 return StatusCode::FAILURE;
534 return StatusCode::SUCCESS;
537 std::vector<float> JetTileCorrectionTool :: getCorrections(
const xAOD::Jet&
jet){
539 float ptlast =
jet.pt();
546 std::vector<float> corrections = {};
548 if (ptbin < 0)
return corrections;
551 if (ptlast < 40000)
return corrections;
570 else clast =
m_pars_LB[region.ep.first +
Pix_eta * region.ep.second]->GetBinContent(ptbin) + sigma *
m_pars_LB[region.ep.first +
Pix_eta * region.ep.second]->GetBinError(ptbin);
577 else clast =
m_pars_EB[region.ep.first +
Pix_eta * region.ep.second]->GetBinContent(ptbin) + sigma *
m_pars_EB[region.ep.first +
Pix_eta * region.ep.second]->GetBinError(ptbin);
582 corrections.push_back(clast);
589 int JetTileCorrectionTool :: getPtBin(
float pt){
591 if(
pt < 20000.)
return -1;
596 if (ptbin < 1) ptbin = 1;
602 bool JetTileCorrectionTool :: inIOV(
const Hole& region,
int run){
603 if( region.
iov.first>=0 && (
run < region.
iov.first) )
return false;
604 if( region.
iov.second>=0 && (
run > region.
iov.second) )
return false;
613 bool JetTileCorrectionTool :: inHole(
float eta,
float phi,
const Hole& rdead){
624 region.
iov = std::make_pair(0,1000000);
644 std::cout<<
"Bad partition value passed!\n";
660 std::cout<<
"Bad module value passed!\n";
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide type-safe access to aux data.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static std::string retrieveMetadata(const std::string &folder, const std::string &key, const ServiceHandle< StoreGateSvc > &inputMetaStore)
method that always returns as a string you can use from, e.g, pyROOT with evt = ROOT....
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
Header file for AthHistogramAlgorithm.
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Helper class to provide type-safe access to aux data.
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
uint32_t runNumber() const
The current event's run number.
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Select isolated Photons, Electrons and Muons.
static const SG::Decorator< float > dec_ptraw("Ptraw")
static const SG::Decorator< unsigned int > dec_status("TileStatus")
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Jet_v1 Jet
Definition of the current "jet version".
setRcore setEtHad setFside pt
EventInfo_v1 EventInfo
Definition of the latest event info version.
@ JetConstitScaleMomentum
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
double getCorrections(TH2F *corrections, double eta, double phi, double Et, double charge)
std::pair< int, int > iov