Skip to content
Snippets Groups Projects
Commit 9bbeeba8 authored by John Derek Chapman's avatar John Derek Chapman Committed by Atlas Nightlybuild
Browse files

Merge branch 'nsw_calib' into '21.3'

Adding a new package for calibration tool, and a tool for detector studies on resolution and efficiencies

See merge request atlas/athena!26760

(cherry picked from commit 853e1d31)

1cb2c872 adding NSWCalibTools
582c46b1 updating MM tool
c01cf53f updating MM smearing tool
a7358a22  Changes to be committed:
ee41f6c2 update
dc56cbc5 Modifying tool names
parent a44b21f7
No related branches found
No related tags found
1 merge request!26806Sweeping !26760 from 21.3 to master. Adding a new package for calibration tool, and a tool for detector studies on resolution and efficiencies
Pipeline #1115903 failed
################################################################################
#Package: NSWCalibTools
################################################################################
# Declare the package name:
atlas_subdir( NSWCalibTools )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
GaudiKernel
MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData
MuonSpectrometer/MuonIdHelpers
PRIVATE
Control/AthenaBaseComps )
# External dependencies:
find_package( ROOT COMPONENTS Core Tree MathCore Hist )
# Component(s) in the package:
atlas_add_library( NSWCalibToolsLib
src/*.cxx
PUBLIC_HEADERS NSWCalibTools
PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES GaudiKernel MuonPrepRawData MuonIdHelpers
PRIVATE_LINK_LIBRARIES AthenaBaseComps )
atlas_add_component( NSWCalibTools
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel AthenaBaseComps MuonPrepRawData MuonIdHelpers NSWCalibToolsLib )
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INSWCalibSmearingTool_h
#define INSWCalibSmearingTool_h
#include "GaudiKernel/IAlgTool.h"
static const InterfaceID IID_INSWCalibSmearingTool("Muon::INSWCalibSmearingTool",1,0);
class Identifier;
namespace Muon {
class INSWCalibSmearingTool : virtual public IAlgTool {
public: // static methods
static const InterfaceID& interfaceID() {return IID_INSWCalibSmearingTool;}
public: // interface methods
virtual StatusCode smearAndSelect(Identifier id, double& time, double& charge, bool& accepted) = 0;
};
}
#endif
#include "NSWCalibSmearingTool.h"
#include "MuonIdHelpers/MuonIdHelperTool.h"
using namespace Muon;
Muon::NSWCalibSmearingTool::NSWCalibSmearingTool(const std::string& t,
const std::string& n,
const IInterface* p ) :
AthAlgTool(t,n,p),
m_idHelperTool("Muon::MuonIdHelperTool/MuonIdHelperTool")
{
declareInterface<INSWCalibSmearingTool>(this);
declareProperty("TimeSmearPattern", m_timeSmear ={0.,0.,0.,0.,0.,0.,0.,0.});
declareProperty("ChargeSmearPattern", m_chargeSmear ={0.,0.,0.,0.,0.,0.,0.,0.});
declareProperty("EfficiencyPattern", m_efficiency ={1.,1.,1.,1.,1.,1.,1.,1.});
}
Muon::NSWCalibSmearingTool::~NSWCalibSmearingTool()
{ }
StatusCode Muon::NSWCalibSmearingTool::initialize()
{
ATH_MSG_DEBUG("In initialize()");
// initialize the MuonIdHelperTool and check the configuration
ATH_CHECK(m_idHelperTool.retrieve());
if ( !(m_idHelperTool->HasMM() && m_idHelperTool->HasSTgc() ) ) {
ATH_MSG_ERROR("MuonIdHelperTool not properly configured, missing MM or STGC");
return StatusCode::FAILURE;
}
m_random = TRandom3();
return StatusCode::SUCCESS;
}
StatusCode Muon::NSWCalibSmearingTool::finalize()
{
ATH_MSG_DEBUG("In finalize()");
return StatusCode::SUCCESS;
}
StatusCode Muon::NSWCalibSmearingTool::smearAndSelect(Identifier id, double& time, double& charge, bool& accepted)
{
int gasGap = 0;
if ( m_idHelperTool->isMM(id) ) {
int multilayer = m_idHelperTool->mmIdHelper().multilayer(id);
gasGap = (multilayer-1)*4+m_idHelperTool->mmIdHelper().gasGap(id);
}
else if ( m_idHelperTool->issTgc(id) ) {
int multilayer = m_idHelperTool->stgcIdHelper().multilayer(id);
gasGap = (multilayer-1)*4+m_idHelperTool->stgcIdHelper().gasGap(id);
}
else {
ATH_MSG_ERROR("Wrong identifier: should be MM or STGC");
return StatusCode::FAILURE;
}
// smear time and charge
double timeSmear = m_timeSmear.value()[gasGap-1];
double chargeSmear = m_chargeSmear.value()[gasGap-1];
time = time+m_random.Gaus(0.0,timeSmear);
charge = charge+m_random.Gaus(0.0,chargeSmear);
// check if the RDO can be accepted
accepted = false;
if ( m_random.Rndm() <= m_efficiency.value()[gasGap-1] ) {
accepted = true;
}
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef NSWCalibSmearingTool_h
#define NSWCalibSmearingTool_h
#include "NSWCalibTools/INSWCalibSmearingTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "MuonPrepRawData/MuonCluster.h"
#include "TRandom3.h"
namespace Muon {
class MuonIdHelperTool;
class NSWCalibSmearingTool : virtual public INSWCalibSmearingTool, public AthAlgTool {
public:
NSWCalibSmearingTool(const std::string&, const std::string&, const IInterface*);
virtual ~NSWCalibSmearingTool();
virtual StatusCode initialize();
virtual StatusCode finalize();
StatusCode smearAndSelect(Identifier id, double& time, double& charge, bool& accepted);
private:
ToolHandle<MuonIdHelperTool> m_idHelperTool;
DoubleArrayProperty m_timeSmear;
DoubleArrayProperty m_chargeSmear;
DoubleArrayProperty m_efficiency;
TRandom3 m_random;
};
}
#endif
#include "../NSWCalibSmearingTool.h"
DECLARE_COMPONENT(Muon::NSWCalibSmearingTool)
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(NSWCalibTools)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment