Skip to content
Snippets Groups Projects
Commit 904f8f7d authored by Dave Casper's avatar Dave Casper
Browse files

Use cable mapping DB for raw Tracker data

parent 4523f558
No related branches found
No related tags found
No related merge requests found
Showing
with 253 additions and 10 deletions
...@@ -21,5 +21,9 @@ ...@@ -21,5 +21,9 @@
<service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" />
</logicalservice> </logicalservice>
<logicalservice name="COOLONL_SCT">
<service name="sqlite_file:data/sqlite200/CABP200.db" accessMode="read" />
<service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/CABP200.db" accessMode="read" />
</logicalservice>
</servicelist> </servicelist>
...@@ -50,6 +50,10 @@ def FaserByteStreamCnvSvcCfg(configFlags, **kwargs): ...@@ -50,6 +50,10 @@ def FaserByteStreamCnvSvcCfg(configFlags, **kwargs):
from WaveByteStream.WaveByteStreamConfig import WaveByteStreamCfg from WaveByteStream.WaveByteStreamConfig import WaveByteStreamCfg
result.merge(WaveByteStreamCfg(configFlags)) result.merge(WaveByteStreamCfg(configFlags))
# Configure TrackerByteStream converter
from TrackerByteStream.TrackerByteStreamConfig import TrackerByteStreamCfg
result.merge(TrackerByteStreamCfg(configFlags))
# Load ByteStreamEventStorageInputSvc # Load ByteStreamEventStorageInputSvc
bsInputSvc = CompFactory.FaserByteStreamInputSvc bsInputSvc = CompFactory.FaserByteStreamInputSvc
result.addService(bsInputSvc(name = "FaserByteStreamInputSvc")) result.addService(bsInputSvc(name = "FaserByteStreamInputSvc"))
......
/*
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 ISCT_CABLE_MAPPING_TOOL
#define ISCT_CABLE_MAPPING_TOOL
//STL includes
#include <vector>
//Gaudi Includes
#include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/EventContext.h"
class ISCT_CableMappingTool: virtual public IAlgTool {
public:
//----------Public Member Functions----------//
// Structors
virtual ~ISCT_CableMappingTool() = default; //!< Destructor
/// Creates the InterfaceID and interfaceID() method
DeclareInterfaceID(ISCT_CableMappingTool, 1, 0);
// Methods to return cable-mapping data
virtual std::map<int, std::pair<int,int> > getCableMapping(const EventContext& ctx) const = 0;
virtual std::map<int, std::pair<int,int> > getCableMapping(void) const = 0;
};
//----------------------------------------------------------------------
#endif // ISCT_CABLE_MAPPING_TOOL
"""Define methods to configure FaserSCT_CableMapping
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
"""
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from AthenaConfiguration.ComponentFactory import CompFactory
from IOVDbSvc.IOVDbSvcConfig import addFolders
FaserSCT_CableMappingTool=CompFactory.FaserSCT_CableMappingTool
def FaserSCT_CableMappingToolCfg(flags, name="CableMappingTool", **kwargs):
"""Return a configured FaserSCT_CableMappingTool"""
return FaserSCT_CableMappingTool(name, **kwargs)
def FaserSCT_CableMappingCfg(flags, **kwargs):
"""Return configured ComponentAccumulator and tool for FaserSCT_CableMapping
CableMappingTool may be provided in kwargs
"""
acc = ComponentAccumulator()
# tool = kwargs.get("CableMappingTool", FaserSCT_CableMappingToolCfg(flags))
# folder arguments
dbInstance = kwargs.get("dbInstance", "SCT_ONL")
dbFolder = kwargs.get("dbFolder", "/SCT/DAQ/CableMapping")
acc.merge(addFolders(flags, dbFolder, dbInstance, className="CondAttrListCollection"))
# acc.addPublicTool(tool)
return acc
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FASER collaborations
*/
/** @file FaserSCT_CableMappingTool.cxx Implementation file for FaserSCT_CableMappingTool.
@author Dave Casper (06/01/22)
*/
#include "FaserSCT_CableMappingTool.h"
// Include Athena stuff
//----------------------------------------------------------------------
FaserSCT_CableMappingTool::FaserSCT_CableMappingTool (const std::string& type, const std::string& name, const IInterface* parent) :
base_class(type, name, parent)
{
}
//----------------------------------------------------------------------
StatusCode
FaserSCT_CableMappingTool::initialize() {
// Read Cond Handle Key
ATH_CHECK(m_readKey.initialize());
return StatusCode::SUCCESS;
} // FaserSCT_CableMappingTool::initialize()
//----------------------------------------------------------------------
StatusCode
FaserSCT_CableMappingTool::finalize() {
// Print where you are
return StatusCode::SUCCESS;
} // FaserSCT_CableMappingTool::finalize()
//----------------------------------------------------------------------
std::map<int, std::pair<int, int> >
FaserSCT_CableMappingTool::getCableMapping(const EventContext& ctx) const {
// Print where you are
ATH_MSG_DEBUG("in getCableMapping()");
std::map<int, std::pair<int, int> > 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_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
ATH_MSG_INFO("Range of input is " << rangeW);
// Read mapping info
std::string stationParam{"station"};
std::string planeParam{"plane"};
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(stationParam) and not payload[stationParam].isNull() and
payload.exists(planeParam) and not payload[planeParam].isNull())
{
int stationVal{payload[stationParam].data<int>()};
int planeVal {payload[planeParam].data<int>()};
if (stationVal < 0 || planeVal < 0) continue; // Don't include invalid entries
mappingData.emplace(std::make_pair(channelNumber, std::make_pair(stationVal, planeVal)));
} else {
ATH_MSG_WARNING(stationParam << " and/or " << planeParam << " does not exist for ChanNum " << channelNumber);
}
}
return mappingData;
} //FaserSCT_ReadCalibChipDataTool::getNPtGainData()
std::map<int, std::pair<int, int> >
FaserSCT_CableMappingTool::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 FaserSCT_CableMappingTool.h Header file for FaserSCT_CableMappingTool.
@author Dave Casper, 06/01/22
*/
// Multiple inclusion protection
#ifndef FASERSCT_CABLE_MAPPING_TOOL
#define FASERSCT_CABLE_MAPPING_TOOL
// Include interface class
#include "AthenaBaseComps/AthAlgTool.h"
#include "FaserSCT_ConditionsTools/ISCT_CableMappingTool.h"
// Include Athena stuff
#include "AthenaPoolUtilities/CondAttrListCollection.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "GaudiKernel/ICondSvc.h"
#include "Gaudi/Property.h"
// #include "FaserSCT_ConditionsData/FaserSCT_ConditionsParameters.h"
// #include "FaserSCT_ConditionsData/FaserSCT_GainCalibData.h"
// #include "FaserSCT_ConditionsData/FaserSCT_NoiseCalibData.h"
// Include Gaudi classes
#include "GaudiKernel/EventContext.h"
/** This class contains a Tool that reads SCT cable mapping data and makes it available to
other algorithms. The current implementation reads the data from a COOL database.
*/
class FaserSCT_CableMappingTool: public extends<AthAlgTool, ISCT_CableMappingTool> {
public:
//----------Public Member Functions----------//
// Structors
FaserSCT_CableMappingTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor
virtual ~FaserSCT_CableMappingTool() = default; //!< Destructor
// Standard Gaudi functions
virtual StatusCode initialize() override; //!< Gaudi initialiser
virtual StatusCode finalize() override; //!< Gaudi finaliser
// Methods to return calibration data
virtual std::map<int, std::pair<int, int> > getCableMapping(const EventContext& ctx) const override;
virtual std::map<int, std::pair<int, int> > getCableMapping(void) const override;
private:
// Read Cond Handle
SG::ReadCondHandleKey<CondAttrListCollection> m_readKey{this, "ReadKey", "/SCT/DAQ/CableMapping", "Key of input cabling folder"};
ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"};
};
//----------------------------------------------------------------------
#endif // FASERSCT_CABLE_MAPPING_TOOL
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "../FaserSCT_SiliconConditionsTool.h" #include "../FaserSCT_SiliconConditionsTool.h"
// #include "../SCT_StripVetoTool.h" // #include "../SCT_StripVetoTool.h"
// #include "../SCT_TdaqEnabledTool.h" // #include "../SCT_TdaqEnabledTool.h"
#include "../FaserSCT_CableMappingTool.h"
// DECLARE_COMPONENT( SCT_ByteStreamErrorsTool ) // DECLARE_COMPONENT( SCT_ByteStreamErrorsTool )
// DECLARE_COMPONENT( SCT_ChargeTrappingTool ) // DECLARE_COMPONENT( SCT_ChargeTrappingTool )
...@@ -41,3 +42,4 @@ DECLARE_COMPONENT( FaserSCT_ReadCalibChipDataTool ) ...@@ -41,3 +42,4 @@ DECLARE_COMPONENT( FaserSCT_ReadCalibChipDataTool )
DECLARE_COMPONENT( FaserSCT_SiliconConditionsTool ) DECLARE_COMPONENT( FaserSCT_SiliconConditionsTool )
// DECLARE_COMPONENT( SCT_StripVetoTool ) // DECLARE_COMPONENT( SCT_StripVetoTool )
// DECLARE_COMPONENT( SCT_TdaqEnabledTool ) // DECLARE_COMPONENT( SCT_TdaqEnabledTool )
DECLARE_COMPONENT( FaserSCT_CableMappingTool )
\ No newline at end of file
...@@ -8,7 +8,7 @@ atlas_subdir( TrackerByteStream ) ...@@ -8,7 +8,7 @@ atlas_subdir( TrackerByteStream )
atlas_add_component( TrackerByteStream atlas_add_component( TrackerByteStream
src/*.cxx src/*.h src/*.cxx src/*.h
src/components/*.cxx src/components/*.cxx
LINK_LIBRARIES AthenaKernel GaudiKernel StoreGateLib FaserByteStreamCnvSvcBaseLib FaserEventStorageLib TrackerRawData TrackerReadoutGeometry TrackerIdentifier EventFormats LINK_LIBRARIES AthenaKernel GaudiKernel StoreGateLib FaserByteStreamCnvSvcBaseLib FaserEventStorageLib TrackerRawData TrackerReadoutGeometry TrackerIdentifier EventFormats FaserSCT_ConditionsToolsLib
PRIVATE_LINK_LIBRARIES AthenaBaseComps ) PRIVATE_LINK_LIBRARIES AthenaBaseComps )
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
#from AthenaConfiguration.ComponentFactory import CompFactory #from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
from FaserSCT_ConditionsTools.FaserSCT_CableMappingConfig import FaserSCT_CableMappingCfg
# from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsCfg
def TrackerByteStreamCfg(configFlags, **kwargs): def TrackerByteStreamCfg(configFlags, **kwargs):
acc = ComponentAccumulator() acc = FaserSCT_CableMappingCfg(configFlags, **kwargs)
# tool = acc.popToolsAndMerge(acc)
return acc return acc
\ No newline at end of file
...@@ -26,6 +26,7 @@ TrackerByteStreamCnv::TrackerByteStreamCnv(ISvcLocator* svcloc) ...@@ -26,6 +26,7 @@ TrackerByteStreamCnv::TrackerByteStreamCnv(ISvcLocator* svcloc)
: Converter(storageType(), classID(), svcloc) : Converter(storageType(), classID(), svcloc)
, AthMessaging(svcloc != nullptr ? msgSvc() : nullptr, "TrackerByteStreamCnv") , AthMessaging(svcloc != nullptr ? msgSvc() : nullptr, "TrackerByteStreamCnv")
, m_tool("TrackerDataDecoderTool") , m_tool("TrackerDataDecoderTool")
, m_mappingTool("FaserSCT_CableMappingTool")
, m_rdpSvc("FaserROBDataProviderSvc", "TrackerByteStreamCnv") , m_rdpSvc("FaserROBDataProviderSvc", "TrackerByteStreamCnv")
, m_detStoreSvc("StoreGateSvc/DetectorStore", "TrackerByteStreamCnv") , m_detStoreSvc("StoreGateSvc/DetectorStore", "TrackerByteStreamCnv")
{ {
...@@ -46,6 +47,7 @@ StatusCode TrackerByteStreamCnv::initialize() ...@@ -46,6 +47,7 @@ StatusCode TrackerByteStreamCnv::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());
ATH_CHECK(m_detStoreSvc.retrieve()); ATH_CHECK(m_detStoreSvc.retrieve());
ATH_CHECK(m_detStoreSvc->retrieve(m_sctID, "FaserSCT_ID")); ATH_CHECK(m_detStoreSvc->retrieve(m_sctID, "FaserSCT_ID"));
...@@ -94,9 +96,12 @@ StatusCode TrackerByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& p ...@@ -94,9 +96,12 @@ StatusCode TrackerByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& p
FaserSCT_RDO_Container* cont = new FaserSCT_RDO_Container(max); FaserSCT_RDO_Container* cont = new FaserSCT_RDO_Container(max);
ATH_MSG_DEBUG("New FaserSCT_RDO_Container created of size="<<cont->size()); ATH_MSG_DEBUG("New FaserSCT_RDO_Container created of size="<<cont->size());
auto mapping = m_mappingTool->getCableMapping();
ATH_MSG_ALWAYS("Cable mapping contains " << mapping.size() << " entries");
// Convert raw data into this container // Convert raw data into this container
CHECK( m_tool->convert(re, cont, key) ); CHECK( m_tool->convert(re, cont, key, mapping) );
pObj = SG::asStorable(cont); pObj = SG::asStorable(cont);
......
...@@ -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 "FaserSCT_ConditionsTools/ISCT_CableMappingTool.h"
class TrackerDataDecoderTool; class TrackerDataDecoderTool;
class IFaserROBDataProviderSvc; class IFaserROBDataProviderSvc;
...@@ -40,6 +41,7 @@ public: ...@@ -40,6 +41,7 @@ public:
private: private:
ToolHandle<TrackerDataDecoderTool> m_tool; ToolHandle<TrackerDataDecoderTool> m_tool;
ToolHandle<ISCT_CableMappingTool> m_mappingTool;
ServiceHandle<IFaserROBDataProviderSvc> m_rdpSvc; ServiceHandle<IFaserROBDataProviderSvc> m_rdpSvc;
ServiceHandle<StoreGateSvc> m_detStoreSvc; ServiceHandle<StoreGateSvc> m_detStoreSvc;
const FaserSCT_ID* m_sctID{nullptr}; const FaserSCT_ID* m_sctID{nullptr};
......
...@@ -46,7 +46,7 @@ TrackerDataDecoderTool::initialize() ...@@ -46,7 +46,7 @@ TrackerDataDecoderTool::initialize()
ATH_CHECK(detStore()->retrieve(m_sctID, "FaserSCT_ID")); ATH_CHECK(detStore()->retrieve(m_sctID, "FaserSCT_ID"));
auto first_wafer = m_sctID->wafer_begin(); auto first_wafer = m_sctID->wafer_begin();
m_trb0Station = m_sctID->station(*first_wafer); // m_trb0Station = m_sctID->station(*first_wafer);
m_sctContext = m_sctID->wafer_context(); m_sctContext = m_sctID->wafer_context();
m_phiReversed.resize(m_sctID->wafer_hash_max(), false); m_phiReversed.resize(m_sctID->wafer_hash_max(), false);
...@@ -80,7 +80,8 @@ TrackerDataDecoderTool::finalize() ...@@ -80,7 +80,8 @@ TrackerDataDecoderTool::finalize()
StatusCode StatusCode
TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re,
FaserSCT_RDO_Container* container, FaserSCT_RDO_Container* container,
std::string key) std::string key,
const std::map<int, std::pair<int, int> >& cableMapping)
{ {
ATH_MSG_DEBUG("TrackerDataDecoderTool::convert()"); ATH_MSG_DEBUG("TrackerDataDecoderTool::convert()");
...@@ -116,10 +117,17 @@ TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, ...@@ -116,10 +117,17 @@ TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re,
if ((frag->source_id()&0xFFFF0000) != DAQFormats::SourceIDs::TrackerSourceID) continue; if ((frag->source_id()&0xFFFF0000) != DAQFormats::SourceIDs::TrackerSourceID) continue;
ATH_MSG_DEBUG("Fragment:\n" << *frag); ATH_MSG_DEBUG("Fragment:\n" << *frag);
uint32_t trb = frag->source_id() & 0x0000FFFF; uint32_t trb = frag->source_id() & 0x0000FFFF;
if (cableMapping.count(trb) == 0)
{
ATH_MSG_ERROR("Invalid trb number " << trb << " not in mapping DB");
return StatusCode::FAILURE;
}
// FIXME: 1 by default; needs to be 0 for IFT // FIXME: 1 by default; needs to be 0 for IFT
int station = m_trb0Station + trb / TrackerDataFragment::PLANES_PER_STATION; // int station = m_trb0Station + trb / TrackerDataFragment::PLANES_PER_STATION;
int plane = trb % TrackerDataFragment::PLANES_PER_STATION; // int plane = trb % TrackerDataFragment::PLANES_PER_STATION;
int station = cableMapping.at(trb).first;
int plane = cableMapping.at(trb).second;
// Exceptions are a no-no in Athena/Calypso, so catch any thrown by faser-common // Exceptions are a no-no in Athena/Calypso, so catch any thrown by faser-common
try try
{ {
......
...@@ -31,7 +31,7 @@ class TrackerDataDecoderTool : public AthAlgTool { ...@@ -31,7 +31,7 @@ class TrackerDataDecoderTool : public AthAlgTool {
virtual StatusCode initialize(); virtual StatusCode initialize();
virtual StatusCode finalize(); virtual StatusCode finalize();
StatusCode convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* cont, std::string key); StatusCode convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* cont, std::string key, const std::map<int, std::pair<int, int> >& cableMapping);
private: private:
const FaserSCT_ID* m_sctID{nullptr}; const FaserSCT_ID* m_sctID{nullptr};
...@@ -42,7 +42,7 @@ private: ...@@ -42,7 +42,7 @@ private:
{7, 2, 5, 0, 3, 6, 1, 4}, {7, 2, 5, 0, 3, 6, 1, 4},
"Mapping from online to offline module numbers" }; "Mapping from online to offline module numbers" };
Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" }; // Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" };
}; };
#endif /* TRACKERBYTESTREAM_TRACKERDATADECODERTOOL_H */ #endif /* TRACKERBYTESTREAM_TRACKERDATADECODERTOOL_H */
......
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