diff --git a/Calorimeter/CaloClusterCorrection/python/StandardCellWeightCalib.py b/Calorimeter/CaloClusterCorrection/python/StandardCellWeightCalib.py index fd9e2cbdd2d4cb0f760454495f3ecc5856889a4f..1c372020eb3f82ec032f5a5279e7e11ba9e05859 100644 --- a/Calorimeter/CaloClusterCorrection/python/StandardCellWeightCalib.py +++ b/Calorimeter/CaloClusterCorrection/python/StandardCellWeightCalib.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #-- #-- Configures standard cell weight calibration tools (extracted from JetGetter) @@ -187,9 +187,12 @@ class H1Calibration(object): dbString="CALO" if (folder,tag) not in H1Calibration.loaded_folder: if H1Calibration.overrideFolder(): - conddb.addFolder(dbString,folder+'<tag>'+tag+'</tag>') + conddb.addFolder(dbString,folder+'<tag>'+tag+'</tag>', + className = 'CaloRec::ToolConstants') else: - conddb.addFolder(dbString,folder) + conddb.addFolder(dbString,folder, + className = 'CaloRec::ToolConstants') + H1Calibration.loaded_folder.append( (folder,tag) ) def getCellWeightTool(finder="Cone",mainparam=0.4,input="Topo", onlyCellWeight=False): @@ -212,6 +215,6 @@ def getCellWeightTool(finder="Cone",mainparam=0.4,input="Topo", onlyCellWeight=F #-- configure tool toolName = finder + editParm(mainparam) + input cellcalibtool = H1WeightToolCSC12Generic("H1Weight"+toolName) - cellcalibtool.detStoreKey = key + cellcalibtool.DBHandleKey = key # -- return cellcalibtool diff --git a/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.cxx b/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.cxx index b700e84b03d5059f33228245cbcc6b728cd3225e..f39e4fff481dcfa83d331b3419d7f8e932352de4 100755 --- a/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.cxx +++ b/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /*********************************************************************** @@ -23,75 +23,12 @@ Created : Feb 2007 using CLHEP::millimeter; using CLHEP::GeV; -////////////////////////////////////////////////////////////////////// -// Constructor/destructor -////////////////////////////////////////////////////////////////////// - -H1WeightToolCSC12Generic::H1WeightToolCSC12Generic(const std::string& name, - const std::string& type, - const IInterface* parent) - : AthAlgTool(name,type,parent) -{ - declareInterface<IHadronicCalibrationTool>(this); - declareInterface<ICellWeightTool>(this); - declareConstant("wtEMB0", m_wtEMB0); - declareConstant("wtEME0", m_wtEME0); - declareConstant("wtEMB1", m_wtEMB1); - declareConstant("wtEMB2", m_wtEMB2); - declareConstant("wtEME1", m_wtEME1); - declareConstant("wtEME2", m_wtEME2); - declareConstant("wtTile1", m_wtTile1); - declareConstant("wtTile2", m_wtTile2); - declareConstant("wtHec1", m_wtHec1); - declareConstant("wtHec2", m_wtHec2); - declareConstant("wtFCal1", m_wtFCal1); - declareConstant("wtFCal2", m_wtFCal2); - declareConstant("wtGap", m_wtGap); - declareConstant("wtScint", m_wtScint); - declareConstant("wtCryo",m_wtCryo);//l1.21519; - declareConstant("etaFit",m_etaFit); - - finish_ctor(); //From ToolWithConstantsMixin -} - -H1WeightToolCSC12Generic::~H1WeightToolCSC12Generic() -{ } - StatusCode H1WeightToolCSC12Generic::initialize() { - return CaloRec::ToolWithConstantsMixin::initialize(); -} - - -StatusCode H1WeightToolCSC12Generic::setProperty (const std::string& propname, - const std::string& value) -{ - StatusCode sc; - sc=AlgTool::setProperty (propname, value); - if (sc.isFailure()) - return sc; - - sc=CaloRec::ToolWithConstantsMixin::setProperty (propname, value); - if (sc.isFailure()) - return sc; - - return StatusCode::SUCCESS; -} -StatusCode H1WeightToolCSC12Generic::setProperty (const Property& p) -{ - StatusCode sc; - sc=AlgTool::setProperty (p); - if (sc.isFailure()) - return sc; - - sc=CaloRec::ToolWithConstantsMixin::setProperty (p); - if (sc.isFailure()) - return sc; - + ATH_CHECK( base_class::initialize() ); return StatusCode::SUCCESS; } - double H1WeightToolCSC12Generic::etCell(const CaloCell* thisCell, double weight) { @@ -103,15 +40,13 @@ double H1WeightToolCSC12Generic::etCell(const CaloCell* thisCell, double weight) double H1WeightToolCSC12Generic::wtCell(const CaloCell* thisCell) const { - - - + Context myctx = context (Gaudi::Hive::currentContext()); const double mm3 = millimeter*millimeter*millimeter; const double log2 = 0.69314718056; const double inv_log2 = 1. / log2; - int dim=m_wtEMB1.size(); //FIXME: Assume same size for all m_wtXXXXX + int dim=m_wtEMB1(myctx).size(); //FIXME: Assume same size for all m_wtXXXXX // Process cell @@ -135,49 +70,49 @@ double H1WeightToolCSC12Generic::wtCell(const CaloCell* thisCell) const // Presampler case CaloSampling::PreSamplerB: - wt = m_wtEMB0[0]; + wt = m_wtEMB0(myctx)[0]; break; case CaloSampling::PreSamplerE: - wt = m_wtEME0[0]; + wt = m_wtEME0(myctx)[0]; break; // First EM layer case CaloSampling::EMB1: - wt = m_wtEMB0[1]; + wt = m_wtEMB0(myctx)[1]; break; case CaloSampling::EME1: - wt = m_wtEME0[1]; + wt = m_wtEME0(myctx)[1]; break; // EM Barrel case CaloSampling::EMB2: case CaloSampling::EMB3: - if(iET >= 0 && etaa < 0.8) wt = m_wtEMB1[iET]; - if(iET >= 0 && etaa >= 0.8) wt = m_wtEMB2[iET]; + if(iET >= 0 && etaa < 0.8) wt = m_wtEMB1(myctx)[iET]; + if(iET >= 0 && etaa >= 0.8) wt = m_wtEMB2(myctx)[iET]; break; // EM Endcap case CaloSampling::EME2: case CaloSampling::EME3: - if(iET >= 0 && etaa < 2.5) wt = m_wtEME1[iET]; - if(iET >= 0 && etaa >= 2.5) wt = m_wtEME2[iET]; + if(iET >= 0 && etaa < 2.5) wt = m_wtEME1(myctx)[iET]; + if(iET >= 0 && etaa >= 2.5) wt = m_wtEME2(myctx)[iET]; break; // Tile case CaloSampling::TileBar0: case CaloSampling::TileBar1: case CaloSampling::TileBar2: - if(iET >= 0) wt = m_wtTile1[iET]; + if(iET >= 0) wt = m_wtTile1(myctx)[iET]; break; case CaloSampling::TileExt0: case CaloSampling::TileExt1: case CaloSampling::TileExt2: - if(iET >= 0) wt = m_wtTile2[iET]; + if(iET >= 0) wt = m_wtTile2(myctx)[iET]; break; // Had endcap @@ -185,29 +120,29 @@ double H1WeightToolCSC12Generic::wtCell(const CaloCell* thisCell) const case CaloSampling::HEC1: case CaloSampling::HEC2: case CaloSampling::HEC3: - if(iET>=0 && etaa<2.5) wt = m_wtHec1[iET]; - if(iET>=0 && etaa>=2.5) wt = m_wtHec2[iET]; + if(iET>=0 && etaa<2.5) wt = m_wtHec1(myctx)[iET]; + if(iET>=0 && etaa>=2.5) wt = m_wtHec2(myctx)[iET]; break; // FCal case CaloSampling::FCAL0: - if(iET >= 0) wt = m_wtFCal1[iET]; + if(iET >= 0) wt = m_wtFCal1(myctx)[iET]; break; case CaloSampling::FCAL1: case CaloSampling::FCAL2: - if(iET >= 0) wt = m_wtFCal2[iET]; + if(iET >= 0) wt = m_wtFCal2(myctx)[iET]; break; // Gap calorimeter case CaloSampling::TileGap3: - wt = m_wtGap; + wt = m_wtGap(myctx); break; // Gap scintillators case CaloSampling::TileGap1: case CaloSampling::TileGap2: - wt = m_wtScint; + wt = m_wtScint(myctx); break; case CaloSampling::MINIFCAL0: @@ -237,15 +172,18 @@ double H1WeightToolCSC12Generic::etCryo(double etAccb3, double etTile1) double H1WeightToolCSC12Generic::wtCryo() { - return m_wtCryo; + Context myctx = context (Gaudi::Hive::currentContext()); + return m_wtCryo(myctx); } // Jet Energy scale double H1WeightToolCSC12Generic::jetScale(double e, double eta) { + Context myctx = context (Gaudi::Hive::currentContext()); + const CxxUtils::Array<2> etaFit = m_etaFit(myctx); - int nEtaBins=m_etaFit.size(); + int nEtaBins=etaFit.size(); if (nEtaBins==0) return 1.0; @@ -254,10 +192,10 @@ double H1WeightToolCSC12Generic::jetScale(double e, double eta) //if(ieta > 49) ieta = 49; double ptlog = log(fabs(e)/(cosh(eta)*GeV)); if(ptlog < 2.3) ptlog = 2.3; - if(ptlog > m_etaFit[ieta][4]) ptlog = m_etaFit[ieta][4]; - double func = m_etaFit[ieta][0] + m_etaFit[ieta][1]/ptlog - + m_etaFit[ieta][2]/(ptlog*ptlog) - + m_etaFit[ieta][3]/(ptlog*ptlog*ptlog); + if(ptlog > etaFit[ieta][4]) ptlog = etaFit[ieta][4]; + double func = etaFit[ieta][0] + etaFit[ieta][1]/ptlog + + etaFit[ieta][2]/(ptlog*ptlog) + + etaFit[ieta][3]/(ptlog*ptlog*ptlog); return 1./func; diff --git a/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.h b/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.h index 0a944a0a9370d845ea86940b1962a85b49bd7b5c..628848d757b5532cb7434b6e4cf8580a75b568ac 100755 --- a/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.h +++ b/Calorimeter/CaloClusterCorrection/src/H1WeightToolCSC12Generic.h @@ -1,7 +1,7 @@ //Dear emacs, this is -*- C++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -16,22 +16,20 @@ Created : Feb 2007 #include "GaudiKernel/AlgTool.h" #include "CaloInterface/IHadronicCalibrationTool.h" -#include "CaloRec/ToolWithConstantsMixin.h" +#include "CaloUtils/ToolWithConstants.h" //#include "GaudiKernel/AlgTool.h" #include "AthenaBaseComps/AthAlgTool.h" #include <string> class CaloCell; -class H1WeightToolCSC12Generic : public AthAlgTool, virtual public IHadronicCalibrationTool, - public CaloRec::ToolWithConstantsMixin +class H1WeightToolCSC12Generic : + public extends<CaloUtils::ToolWithConstants<AthAlgTool>, + IHadronicCalibrationTool> { public: - - // Algtool constructor - H1WeightToolCSC12Generic(const std::string& name, const std::string& type, - const IInterface* parent); - virtual ~H1WeightToolCSC12Generic(); + /// Inherit constructor. + using base_class::base_class; virtual StatusCode initialize() override; @@ -41,43 +39,24 @@ class H1WeightToolCSC12Generic : public AthAlgTool, virtual public IHadronicCali virtual double wtCell(const CaloCell* thisCell) const override; virtual double wtCryo() override; - using AlgTool::setProperty; - // using IHadronicCalibrationTool::setProperty; - /** - * @brief Method to set a property value. - * @param propname The name of the property to set. - * @param value The value to which to set it. - * - * Defined here as required by @c ToolWithConstantsMixin. - */ - virtual StatusCode setProperty (const std::string& propname, - const std::string& value) override; - - /** - * @brief Method to set a property value. - * @param p The property name/value to set. - * - * Defined here as required by @c ToolWithConstantsMixin. - */ - virtual StatusCode setProperty (const Property& p) override; - private: - CaloRec::Array<1> m_wtEMB0; - CaloRec::Array<1> m_wtEME0; - CaloRec::Array<1> m_wtEMB1; - CaloRec::Array<1> m_wtEMB2; - CaloRec::Array<1> m_wtEME1; - CaloRec::Array<1> m_wtEME2; - CaloRec::Array<1> m_wtTile1; - CaloRec::Array<1> m_wtTile2; - CaloRec::Array<1> m_wtHec1; - CaloRec::Array<1> m_wtHec2; - CaloRec::Array<1> m_wtFCal1; - CaloRec::Array<1> m_wtFCal2; - float m_wtGap; - float m_wtScint; - float m_wtCryo; - CaloRec::Array<2> m_etaFit; +private: + Constant<CxxUtils::Array<1> > m_wtEMB0 { this, "wtEMB0" }; + Constant<CxxUtils::Array<1> > m_wtEME0 { this, "wtEME0" }; + Constant<CxxUtils::Array<1> > m_wtEMB1 { this, "wtEMB1" }; + Constant<CxxUtils::Array<1> > m_wtEMB2 { this, "wtEMB2" }; + Constant<CxxUtils::Array<1> > m_wtEME1 { this, "wtEME1" }; + Constant<CxxUtils::Array<1> > m_wtEME2 { this, "wtEME2" }; + Constant<CxxUtils::Array<1> > m_wtTile1 { this, "wtTile1" }; + Constant<CxxUtils::Array<1> > m_wtTile2 { this, "wtTile2" }; + Constant<CxxUtils::Array<1> > m_wtHec1 { this, "wtHec1" }; + Constant<CxxUtils::Array<1> > m_wtHec2 { this, "wtHec2" }; + Constant<CxxUtils::Array<1> > m_wtFCal1 { this, "wrFCal1" }; + Constant<CxxUtils::Array<1> > m_wtFCal2 { this, "wrFCal2" }; + Constant<float> m_wtGap { this, "wtGap" }; + Constant<float> m_wtScint { this, "wtScint" }; + Constant<float> m_wtCryo { this, "wtCyo" }; + Constant<CxxUtils::Array<2> > m_etaFit { this, "etaFit" }; }; #endif