Skip to content
Snippets Groups Projects
Commit 5fb20c64 authored by Eric Torrence's avatar Eric Torrence
Browse files

Merge branch 'waveform-cablemap' into 'master'

Add cable mapping DB for waveform digitizer

See merge request faser/calypso!205
parents 203c3851 dc111c6f
Branches
No related tags found
No related merge requests found
Pipeline #3562310 passed
Showing
with 353 additions and 219 deletions
...@@ -30,7 +30,6 @@ RawWaveformAccess::initialize() ...@@ -30,7 +30,6 @@ RawWaveformAccess::initialize()
ATH_CHECK( m_VetoWaveformContainer.initialize() ); ATH_CHECK( m_VetoWaveformContainer.initialize() );
ATH_CHECK( m_TriggerWaveformContainer.initialize() ); ATH_CHECK( m_TriggerWaveformContainer.initialize() );
ATH_CHECK( m_PreshowerWaveformContainer.initialize() ); ATH_CHECK( m_PreshowerWaveformContainer.initialize() );
ATH_CHECK( m_TestWaveformContainer.initialize() );
ATH_CHECK( m_ClockWaveformContainer.initialize() ); ATH_CHECK( m_ClockWaveformContainer.initialize() );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
...@@ -66,10 +65,6 @@ RawWaveformAccess::execute(const EventContext& ctx) const ...@@ -66,10 +65,6 @@ RawWaveformAccess::execute(const EventContext& ctx) const
ATH_MSG_INFO("Found ReadHandle for PreshowerWaveforms"); ATH_MSG_INFO("Found ReadHandle for PreshowerWaveforms");
ATH_MSG_INFO(*preshowerHandle); ATH_MSG_INFO(*preshowerHandle);
SG::ReadHandle<RawWaveformContainer> testHandle(m_TestWaveformContainer, ctx);
ATH_MSG_INFO("Found ReadHandle for TestWaveforms");
ATH_MSG_INFO(*testHandle);
SG::ReadHandle<RawWaveformContainer> clockHandle(m_ClockWaveformContainer, ctx); SG::ReadHandle<RawWaveformContainer> clockHandle(m_ClockWaveformContainer, ctx);
ATH_MSG_INFO("Found ReadHandle for ClockWaveforms"); ATH_MSG_INFO("Found ReadHandle for ClockWaveforms");
ATH_MSG_INFO(*clockHandle); ATH_MSG_INFO(*clockHandle);
......
...@@ -38,8 +38,6 @@ class RawWaveformAccess: public AthReentrantAlgorithm ...@@ -38,8 +38,6 @@ class RawWaveformAccess: public AthReentrantAlgorithm
{ this, "TriggerWaveformContainerKey", "TriggerWaveforms", "ReadHandleKey for TriggerWaveforms Container"}; { this, "TriggerWaveformContainerKey", "TriggerWaveforms", "ReadHandleKey for TriggerWaveforms Container"};
SG::ReadHandleKey<RawWaveformContainer> m_PreshowerWaveformContainer SG::ReadHandleKey<RawWaveformContainer> m_PreshowerWaveformContainer
{ this, "PreshowerWaveformContainerKey", "PreshowerWaveforms", "ReadHandleKey for PreshowerWaveforms Container"}; { this, "PreshowerWaveformContainerKey", "PreshowerWaveforms", "ReadHandleKey for PreshowerWaveforms Container"};
SG::ReadHandleKey<RawWaveformContainer> m_TestWaveformContainer
{ this, "TestWaveformContainerKey", "TestWaveforms", "ReadHandleKey for TestWaveforms Container"};
SG::ReadHandleKey<RawWaveformContainer> m_ClockWaveformContainer SG::ReadHandleKey<RawWaveformContainer> m_ClockWaveformContainer
{ this, "ClockWaveformContainerKey", "ClockWaveforms", "ReadHandleKey for ClockWaveforms Container"}; { this, "ClockWaveformContainerKey", "ClockWaveforms", "ReadHandleKey for ClockWaveforms Container"};
}; };
......
...@@ -4,16 +4,10 @@ ...@@ -4,16 +4,10 @@
atlas_subdir( WaveByteStream ) atlas_subdir( WaveByteStream )
# Component(s) in the package: # Component(s) in the package:
#atlas_add_library( WaveByteStreamLib
# WaveByteStream/*.h
# PUBLIC_HEADERS WaveByteStream
# LINK_LIBRARIES StoreGateLib
# )
atlas_add_component( WaveByteStream atlas_add_component( WaveByteStream
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
LINK_LIBRARIES Identifier ScintIdentifier FaserCaloIdentifier AthenaKernel GaudiKernel FaserByteStreamCnvSvcBaseLib FaserEventStorageLib WaveRawEvent LINK_LIBRARIES AthenaKernel GaudiKernel FaserByteStreamCnvSvcBaseLib FaserEventStorageLib WaveRawEvent WaveformConditionsToolsLib
PRIVATE_LINK_LIBRARIES AthenaBaseComps ) PRIVATE_LINK_LIBRARIES AthenaBaseComps )
atlas_install_python_modules( python/*.py ) atlas_install_python_modules( python/*.py )
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from WaveformConditionsTools.WaveformCableMappingConfig import WaveformCableMappingCfg
def WaveByteStreamCfg(configFlags, **kwargs): def WaveByteStreamCfg(configFlags, **kwargs):
acc = WaveformCableMappingCfg(configFlags, **kwargs)
acc = ComponentAccumulator()
# Decide which waveform mapping to instantiate from Geo tag
if configFlags.Input.isMC:
# Nothing to do for MC
print("WaveByteStreamConfig.WaveByteStreamCfg - Called for isMC True, nothing to do...")
return acc
print("WaveByteStreamConfig.WaveByteStreamCfg - Found FaserVersion: ", configFlags.GeoModel.FaserVersion,)
# Channels are ordered front->back, bottom->top, right->left
if configFlags.GeoModel.FaserVersion == "FASER-TB00":
print(" - setting up testbeam detector")
waveform_tool = CompFactory.RawWaveformDecoderTool("RawWaveformDecoderTool")
waveform_tool.CaloChannels = [5, 3, 1, 4, 2, 0]
waveform_tool.VetoChannels = []
waveform_tool.TriggerChannels = [8, 9]
waveform_tool.PreshowerChannels = [6, 7]
acc.addPublicTool(waveform_tool)
elif configFlags.GeoModel.FaserVersion == "FASER-01":
print(" - setting up TI12 detector")
waveform_tool = CompFactory.RawWaveformDecoderTool("RawWaveformDecoderTool")
waveform_tool.CaloChannels = [1, 0, 3, 2]
waveform_tool.VetoChannels = [4, 5, 6, 7]
waveform_tool.TriggerChannels = [9, 8, 11, 10]
waveform_tool.PreshowerChannels = [12, 13]
acc.addPublicTool(waveform_tool)
elif configFlags.GeoModel.FaserVersion == "FASER-02":
print(" - setting up TI12 with IFT detector")
# Need to fix this!
waveform_tool = CompFactory.RawWaveformDecoderTool("RawWaveformDecoderTool")
waveform_tool.CaloChannels = [1, 0, 3, 2]
waveform_tool.VetoChannels = [4, 5, 6, 7]
waveform_tool.TriggerChannels = [9, 8, 11, 10]
waveform_tool.PreshowerChannels = [12, 13]
acc.addPublicTool(waveform_tool)
else:
print(" - unknown version: user must set up Waveform channel mapping by hand!")
return acc return acc
...@@ -19,20 +19,6 @@ RawWaveformDecoderTool::RawWaveformDecoderTool(const std::string& type, ...@@ -19,20 +19,6 @@ RawWaveformDecoderTool::RawWaveformDecoderTool(const std::string& type,
: AthAlgTool(type, name, parent) : AthAlgTool(type, name, parent)
{ {
declareInterface<RawWaveformDecoderTool>(this); declareInterface<RawWaveformDecoderTool>(this);
// These must be configured by job options
declareProperty("CaloChannels", m_caloChannels);
declareProperty("VetoChannels", m_vetoChannels);
declareProperty("TriggerChannels", m_triggerChannels);
declareProperty("PreshowerChannels", m_preshowerChannels);
// Test channels is provided for conveniene, not normally used
declareProperty("TestChannels", m_testChannels);
// Clock should always be in channel 15
declareProperty("ClockChannels", m_clockChannels);
m_clockChannels.push_back(15);
} }
RawWaveformDecoderTool::~RawWaveformDecoderTool() RawWaveformDecoderTool::~RawWaveformDecoderTool()
...@@ -43,82 +29,6 @@ StatusCode ...@@ -43,82 +29,6 @@ StatusCode
RawWaveformDecoderTool::initialize() RawWaveformDecoderTool::initialize()
{ {
ATH_MSG_DEBUG("RawWaveformDecoderTool::initialize()"); ATH_MSG_DEBUG("RawWaveformDecoderTool::initialize()");
// Set up helpers
ATH_CHECK(detStore()->retrieve(m_ecalID, "EcalID"));
ATH_CHECK(detStore()->retrieve(m_vetoID, "VetoID"));
ATH_CHECK(detStore()->retrieve(m_triggerID, "TriggerID"));
ATH_CHECK(detStore()->retrieve(m_preshowerID, "PreshowerID"));
// Take each channel list and create identifiers
// Loop through digitizer channel lists creating Identifiers
m_identifierMap.clear();
// First, calorimeter. Can either be 4 or 6 channels
// Bottom row first from left to right, then top row
int index=0;
int module=0;
int row=0;
int pmt=0;
int max_modules = m_caloChannels.size() / 2;
for (auto const& chan : m_caloChannels) {
row = index / max_modules;
module = index % max_modules;
index++;
// Only store in map if digitizer channel is valid
if (chan < 0) continue;
m_identifierMap[chan] = m_ecalID->pmt_id(row, module, pmt);
ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to calo ID: " << m_identifierMap[chan]);
}
// Next, veto detector. Have station and plate here.
int station=0;
int plate=0;
pmt=0;
index=0;
int max_stations=m_vetoChannels.size() / 2;
for (auto const& chan : m_vetoChannels) {
station = index / max_stations;
plate = index % max_stations;
index++;
// Only store in map if digitizer channel is valid
if (chan < 0) continue;
m_identifierMap[chan] = m_vetoID->pmt_id(station, plate, pmt);
ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to veto ID: " << m_identifierMap[chan]);
}
// Next, trigger detector. Have pmt and plate.
pmt=0;
station=0;
index=0;
int max_plates=m_triggerChannels.size() / 2;
for (auto const& chan : m_triggerChannels) {
plate = index / max_plates;
pmt = index % max_plates;
index++;
// Only store in map if digitizer channel is valid
if (chan < 0) continue;
m_identifierMap[chan] = m_triggerID->pmt_id(station, plate, pmt);
ATH_MSG_DEBUG("Mapped dititizer channel " << chan << " to trigger ID: " << m_identifierMap[chan]);
}
// Finally, preshower detector.
pmt=0;
station=0;
plate=0;
index=0;
for (auto const& chan : m_preshowerChannels) {
plate = index;
index++;
// Only store in map if digitizer channel is valid
if (chan < 0) continue;
m_identifierMap[chan] = m_preshowerID->pmt_id(station, plate, pmt);
ATH_MSG_DEBUG("Mapped digitizer channel " << chan << " to preshower ID: " << m_identifierMap[chan]);
}
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -131,8 +41,10 @@ RawWaveformDecoderTool::finalize() ...@@ -131,8 +41,10 @@ RawWaveformDecoderTool::finalize()
StatusCode StatusCode
RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re,
RawWaveformContainer* container, RawWaveformContainer* container,
const std::string key) const std::string key,
WaveformCableMap cable_map
)
{ {
ATH_MSG_DEBUG("RawWaveformDecoderTool::convert("+key+")"); ATH_MSG_DEBUG("RawWaveformDecoderTool::convert("+key+")");
...@@ -172,26 +84,32 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, ...@@ -172,26 +84,32 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re,
ATH_MSG_DEBUG("Found valid digitizer fragment"); ATH_MSG_DEBUG("Found valid digitizer fragment");
} }
std::vector<int>* channelList; // Detector type to match in first element of cable map
std::string det_type;
if (key == std::string("CaloWaveforms")) { if (key == std::string("CaloWaveforms")) {
channelList = &m_caloChannels; det_type = std::string("calo");
} else if (key == std::string("VetoWaveforms")) { } else if (key == std::string("VetoWaveforms")) {
channelList = &m_vetoChannels; det_type = std::string("veto");
} else if (key == std::string("TriggerWaveforms")) { } else if (key == std::string("TriggerWaveforms")) {
channelList = &m_triggerChannels; det_type = std::string("trigger");
} else if (key == std::string("PreshowerWaveforms")) { } else if (key == std::string("PreshowerWaveforms")) {
channelList = &m_preshowerChannels; det_type = std::string("preshower");
} else if (key == std::string("TestWaveforms")) {
channelList = &m_testChannels;
} else if (key == std::string("ClockWaveforms")) { } else if (key == std::string("ClockWaveforms")) {
channelList = &m_clockChannels; det_type = std::string("clock");
} else { } else {
ATH_MSG_ERROR("Unknown key " << key); ATH_MSG_ERROR("Unknown key " << key);
return StatusCode::FAILURE; return StatusCode::FAILURE;
} }
for (int channel: *channelList) { // Loop over 16 digitizer channels
std::vector<int> channelList(16);
std::iota (std::begin(channelList), std::end(channelList), 0);
for (int channel: channelList) {
// Only look at channels we care about
if (det_type != cable_map[channel].first) continue;
ATH_MSG_DEBUG("Converting channel "+std::to_string(channel)+" for "+key); ATH_MSG_DEBUG("Converting channel "+std::to_string(channel)+" for "+key);
// Check if this has data // Check if this has data
...@@ -223,8 +141,8 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re, ...@@ -223,8 +141,8 @@ RawWaveformDecoderTool::convert(const DAQFormats::EventFull* re,
} }
// Set ID if one exists (clock, for instance, doesn't have an identifier) // Set ID if one exists (clock, for instance, doesn't have an identifier)
if (m_identifierMap.count(channel) == 1) { if (cable_map[channel].second != -1) { // Identifier doesn't have operator>=
wfm->setIdentifier(m_identifierMap[channel]); wfm->setIdentifier(cable_map[channel].second);
} }
container->push_back(wfm); container->push_back(wfm);
......
...@@ -13,11 +13,7 @@ ...@@ -13,11 +13,7 @@
#include "EventFormats/DAQFormats.hpp" #include "EventFormats/DAQFormats.hpp"
#include "WaveRawEvent/RawWaveformContainer.h" #include "WaveRawEvent/RawWaveformContainer.h"
#include "Identifier/Identifier.h" #include "WaveformConditionsTools/IWaveformCableMappingTool.h"
#include "FaserCaloIdentifier/EcalID.h"
#include "ScintIdentifier/VetoID.h"
#include "ScintIdentifier/TriggerID.h"
#include "ScintIdentifier/PreshowerID.h"
// This class provides conversion between bytestream and Waveform objects // This class provides conversion between bytestream and Waveform objects
...@@ -34,53 +30,9 @@ class RawWaveformDecoderTool : public AthAlgTool { ...@@ -34,53 +30,9 @@ class RawWaveformDecoderTool : public AthAlgTool {
virtual StatusCode initialize(); virtual StatusCode initialize();
virtual StatusCode finalize(); virtual StatusCode finalize();
StatusCode convert(const DAQFormats::EventFull* re, RawWaveformContainer* wfm, std::string key); StatusCode convert(const DAQFormats::EventFull* re, RawWaveformContainer* wfm, std::string key, WaveformCableMap cable_map);
private: private:
// List of channels to include in each container
// List order must correspond to offline channel order
// All L/R designations refer to looking at the detector from
// the beam direction.
//
// In general, the ordering is layer (longitudinal), row (vertical), module (horizontal)
// Layers increase with longitudianl position downstream
// Rows increase from bottom to top
// Modules increase from right to left
//
// For all lists, use invalid channel (-1) to indicate detectors
// missing in sequence (i.e. 3 of 4 veto counters)
//
// TI12 detector:
// Calorimeter order:
// bottom right, bottom left, top right, top left
// Veto
// front to back.
// Trigger
// bottom right PMT, bottom left PMT, top right PMT, top left PMT
// Preshower
// front to back
//
// 2021 Testbeam detector:
// Calo order:
// bottom right, bottom center, bottom left, top R, top C, top L
// All others are just in order front to back
std::vector<int> m_caloChannels;
std::vector<int> m_vetoChannels;
std::vector<int> m_triggerChannels;
std::vector<int> m_preshowerChannels;
std::vector<int> m_testChannels;
std::vector<int> m_clockChannels;
// Identifiers keyed by digitizer channel
std::map<unsigned int, Identifier> m_identifierMap;
// ID helpers
const EcalID* m_ecalID{nullptr};
const VetoID* m_vetoID{nullptr};
const TriggerID* m_triggerID{nullptr};
const PreshowerID* m_preshowerID{nullptr};
}; };
#endif /* WAVEBYTESTREAM_FASERTRIGGERDECODERTOOL_H */ #endif /* WAVEBYTESTREAM_FASERTRIGGERDECODERTOOL_H */
......
...@@ -26,6 +26,7 @@ WaveByteStreamCnv::WaveByteStreamCnv(ISvcLocator* svcloc) ...@@ -26,6 +26,7 @@ WaveByteStreamCnv::WaveByteStreamCnv(ISvcLocator* svcloc)
, AthMessaging(svcloc != nullptr ? msgSvc() : nullptr, "WaveByteStreamCnv") , AthMessaging(svcloc != nullptr ? msgSvc() : nullptr, "WaveByteStreamCnv")
, m_name("WaveByteStreamCnv") , m_name("WaveByteStreamCnv")
, m_tool("RawWaveformDecoderTool") , m_tool("RawWaveformDecoderTool")
, m_mappingTool("WaveformCableMappingTool")
, m_rdpSvc("FaserROBDataProviderSvc", m_name) , m_rdpSvc("FaserROBDataProviderSvc", m_name)
{ {
ATH_MSG_DEBUG(m_name+"::initialize() called"); ATH_MSG_DEBUG(m_name+"::initialize() called");
...@@ -47,6 +48,7 @@ StatusCode WaveByteStreamCnv::initialize() ...@@ -47,6 +48,7 @@ StatusCode WaveByteStreamCnv::initialize()
CHECK(Converter::initialize()); CHECK(Converter::initialize());
CHECK(m_rdpSvc.retrieve()); CHECK(m_rdpSvc.retrieve());
CHECK(m_tool.retrieve()); CHECK(m_tool.retrieve());
CHECK(m_mappingTool.retrieve());
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -90,9 +92,12 @@ StatusCode WaveByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj ...@@ -90,9 +92,12 @@ StatusCode WaveByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj
RawWaveformContainer* wfmCont = new RawWaveformContainer; RawWaveformContainer* wfmCont = new RawWaveformContainer;
// Convert selected channels // Get mapping tool
auto mapping = m_mappingTool->getCableMapping();
ATH_MSG_DEBUG("Cable mapping contains " << mapping.size() << " entries");
CHECK( m_tool->convert(re, wfmCont, key) ); // Convert selected channels
CHECK( m_tool->convert(re, wfmCont, key, mapping) );
pObj = SG::asStorable(wfmCont); pObj = SG::asStorable(wfmCont);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "AthenaBaseComps/AthMessaging.h" #include "AthenaBaseComps/AthMessaging.h"
#include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" #include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h"
#include "WaveformConditionsTools/IWaveformCableMappingTool.h"
class RawWaveformDecoderTool; class RawWaveformDecoderTool;
class IFaserROBDataProviderSvc; class IFaserROBDataProviderSvc;
...@@ -39,8 +40,8 @@ public: ...@@ -39,8 +40,8 @@ public:
private: private:
std::string m_name; std::string m_name;
ToolHandle<RawWaveformDecoderTool> m_tool; ToolHandle<RawWaveformDecoderTool> m_tool;
ToolHandle<IWaveformCableMappingTool> m_mappingTool;
ServiceHandle<IFaserROBDataProviderSvc> m_rdpSvc; ServiceHandle<IFaserROBDataProviderSvc> m_rdpSvc;
}; };
#endif /* WAVEBYTESTREAM_WAVEBYTESTREAMCNV_H */ #endif /* WAVEBYTESTREAM_WAVEBYTESTREAMCNV_H */
......
###############################################################################
# Package: WaveformConditionsTools
################################################################################
# Declare the package name:
atlas_subdir( WaveformConditionsTools )
# External dependencies:
find_package( CLHEP )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
# Component(s) in the package:
atlas_add_component ( WaveformConditionsTools
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel WaveformConditionsToolsLib Identifier ScintIdentifier FaserCaloIdentifier GaudiKernel AthenaBaseComps AthenaPoolUtilities StoreGateLib xAODEventInfo )
atlas_add_library( WaveformConditionsToolsLib
src/*.cxx
PUBLIC_HEADERS WaveformConditionsTools
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel Identifier ScintIdentifier FaserCaloIdentifier GaudiKernel AthenaBaseComps AthenaPoolUtilities StoreGateLib xAODEventInfo )
# Install files from the package:
atlas_install_python_modules( python/*.py )
Waveform/WaveformConditions/WaveformConditionsTools
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FAsER collaborations
*/
/** @file ISCT_CableMappingTool.h Interface file for SCT_CableMappingTool.
*/
// Multiple inclusion protection
#ifndef IWAVEFORMCABLEMAPPINGTOOL
#define IWAVEFORMCABLEMAPPINGTOOL
//STL includes
#include <map>
//Gaudi Includes
#include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/EventContext.h"
#include "Identifier/Identifier.h"
// Cable map indexed by digitizer channel number
// Contains detector type "calo", "trigger", "veto", "preshower" and identifier
typedef std::map<int, std::pair<std::string, Identifier> > WaveformCableMap;
class IWaveformCableMappingTool: virtual public IAlgTool {
public:
//----------Public Member Functions----------//
// Structors
virtual ~IWaveformCableMappingTool() = default; //!< Destructor
/// Creates the InterfaceID and interfaceID() method
DeclareInterfaceID(IWaveformCableMappingTool, 1, 0);
// Methods to return cable-mapping data
// Key is digitizer channel, pair is <type, identifier>
virtual WaveformCableMap getCableMapping(const EventContext& ctx) const = 0;
virtual WaveformCableMap getCableMapping(void) const = 0;
};
//----------------------------------------------------------------------
#endif // WAVEFORMCABLEMAPPINGTOOL
""" Define methods to configure WaveformCableMapping
Copyright (C) 2022 CERN for the benefit of the FASER collaboration
"""
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
from IOVDbSvc.IOVDbSvcConfig import addFolders
WaveformCableMappingTool=CompFactory.WaveformCableMappingTool
def WaveformCableMappingToolCfg(flags, name="WaveformCableMappingTool", **kwargs):
""" Return a configured WaveformCableMappingTool"""
return WaveformCableMappingTool(name, **kwargs)
def WaveformCableMappingCfg(flags, **kwargs):
""" Return configured ComponentAccumulator and tool for Waveform CableMapping
WaveformCableMappingTool may be provided in kwargs
"""
acc = ComponentAccumulator()
# tool = kwargs.get("WaveformCableMappingTool", WaveformCableMappingTool(flags))
# Probably need to figure this out!
dbInstance = kwargs.get("dbInstance", "TDAQ_OFL")
dbFolder = kwargs.get("dbFolder", "/WAVE/DAQ/CableMapping")
acc.merge(addFolders(flags, dbFolder, dbInstance, className="CondAttrListCollection"))
return acc
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FASER collaborations
*/
/** @file WaveformCableMappingTool.cxx Implementation file for WaveformCableMappingTool.
@author Eric Torrence (05/02/22)
Based on FaserSCT_CableMappingTool
*/
#include "WaveformCableMappingTool.h"
//----------------------------------------------------------------------
WaveformCableMappingTool::WaveformCableMappingTool (const std::string& type, const std::string& name, const IInterface* parent) :
base_class(type, name, parent)
{
}
//----------------------------------------------------------------------
StatusCode
WaveformCableMappingTool::initialize() {
// Read Cond Handle Key
ATH_MSG_DEBUG("WaveformCableMappingTool::initialize()");
ATH_CHECK(m_readKey.initialize());
// Set up helpers
ATH_CHECK(detStore()->retrieve(m_ecalID, "EcalID"));
ATH_CHECK(detStore()->retrieve(m_vetoID, "VetoID"));
ATH_CHECK(detStore()->retrieve(m_triggerID, "TriggerID"));
ATH_CHECK(detStore()->retrieve(m_preshowerID, "PreshowerID"));
return StatusCode::SUCCESS;
}
//----------------------------------------------------------------------
StatusCode
WaveformCableMappingTool::finalize() {
// Print where you are
return StatusCode::SUCCESS;
}
//----------------------------------------------------------------------
WaveformCableMap
WaveformCableMappingTool::getCableMapping(const EventContext& ctx) const {
// Print where you are
ATH_MSG_DEBUG("in getCableMapping()");
WaveformCableMap mappingData;
// Read Cond Handle
SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey, ctx};
const CondAttrListCollection* readCdo{*readHandle};
if (readCdo==nullptr) {
ATH_MSG_FATAL("Null pointer to the read conditions object");
return mappingData;
}
// Get the validitiy range
EventIDRange rangeW;
if (not readHandle.range(rangeW)) {
ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
return mappingData;
}
ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
ATH_MSG_DEBUG("Range of input is " << rangeW);
// Read mapping info
/*
std::string typeParam{"type"};
std::string stationParam{"station"};
std::string plateParam{"plate"};
std::string rowParam{"row"};
std::string moduleParam{"module"};
std::string pmtParam{"pmt"};
*/
CondAttrListCollection::const_iterator attrList{readCdo->begin()};
CondAttrListCollection::const_iterator end{readCdo->end()};
// CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
for (; attrList!=end; ++attrList) {
// A CondAttrListCollection is a map of ChanNum and AttributeList
CondAttrListCollection::ChanNum channelNumber{attrList->first};
const CondAttrListCollection::AttributeList &payload{attrList->second};
if (payload.exists("type") and not payload["type"].isNull()) {
std::string det_type{payload["type"].data<std::string>()};
int stationVal{payload["station"].data<int>()};
int plateVal {payload["plate"].data<int>()};
int rowVal {payload["row"].data<int>()};
int moduleVal {payload["module"].data<int>()};
int pmtVal {payload["pmt"].data<int>()};
Identifier identifier;
// Ugh, cant use switch statement with strings
// Must do this using an if ladder
if (det_type == "calo") {
identifier = m_ecalID->pmt_id(rowVal, moduleVal, pmtVal);
}
else if (det_type == "veto") {
identifier = m_vetoID->pmt_id(stationVal, plateVal, pmtVal);
}
else if (det_type == "trigger") {
identifier = m_triggerID->pmt_id(stationVal, plateVal, pmtVal);
}
else if (det_type == "preshower") {
identifier = m_preshowerID->pmt_id(stationVal, plateVal, pmtVal);
}
else if (det_type == "clock") {
// No valid identifiers for these
identifier = -1;
}
else if (det_type == "none") {
identifier = -1;
}
else {
ATH_MSG_WARNING("Detector type " << det_type << " not known for channel " << channelNumber << "!");
det_type = std::string("none");
identifier = -1;
}
ATH_MSG_DEBUG("Mapped digitizer channel " << channelNumber << " to " << det_type<< " ID: " << identifier);
mappingData.emplace(std::make_pair(channelNumber, std::make_pair(det_type, identifier)));
}
} // End of loop over attributes
return mappingData;
}
WaveformCableMap
WaveformCableMappingTool::getCableMapping(void) const {
const EventContext& ctx{Gaudi::Hive::currentContext()};
return getCableMapping(ctx);
}
// -*- C++ -*-
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and CERN collaborations
*/
/** @file WaveformCableMappingTool.h Header file for WaveformCableMappingTool.
@author Eric Torrence, 05/02/22
Based on FaserSCT_CableMappingTool
*/
// Multiple inclusion protection
#ifndef WAVEFORM_CABLE_MAPPING_TOOL
#define WAVEFORM_CABLE_MAPPING_TOOL
// Include interface class
#include "AthenaBaseComps/AthAlgTool.h"
#include "WaveformConditionsTools/IWaveformCableMappingTool.h"
// Identifiers
#include "Identifier/Identifier.h"
#include "FaserCaloIdentifier/EcalID.h"
#include "ScintIdentifier/VetoID.h"
#include "ScintIdentifier/TriggerID.h"
#include "ScintIdentifier/PreshowerID.h"
// Include Athena stuff
#include "AthenaPoolUtilities/CondAttrListCollection.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "GaudiKernel/ICondSvc.h"
#include "Gaudi/Property.h"
// Include Gaudi classes
#include "GaudiKernel/EventContext.h"
/** This class contains a Tool that reads Waveform cable mapping data and makes it available to
other algorithms. The current implementation reads the data from a COOL database.
*/
class WaveformCableMappingTool: public extends<AthAlgTool, IWaveformCableMappingTool> {
public:
//----------Public Member Functions----------//
// Structors
WaveformCableMappingTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor
virtual ~WaveformCableMappingTool() = default; //!< Destructor
// Standard Gaudi functions
virtual StatusCode initialize() override; //!< Gaudi initialiser
virtual StatusCode finalize() override; //!< Gaudi finaliser
// Methods to return calibration data
// Map indexed by digitizer channel number
// Returns detector type "calo", "trigger", "veto", "preshower" and identifier
virtual WaveformCableMap getCableMapping(const EventContext& ctx) const override;
virtual WaveformCableMap getCableMapping(void) const override;
private:
// Read Cond Handle
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey{this, "ReadKey", "/WAVE/DAQ/CableMapping", "Key of input cabling folder"};
ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"};
// ID helpers
const EcalID* m_ecalID{nullptr};
const VetoID* m_vetoID{nullptr};
const TriggerID* m_triggerID{nullptr};
const PreshowerID* m_preshowerID{nullptr};
};
//----------------------------------------------------------------------
#endif // WAVEFORM_CABLE_MAPPING_TOOL
#include "../WaveformCableMappingTool.h"
DECLARE_COMPONENT( WaveformCableMappingTool )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment