diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/CMakeLists.txt b/ForwardDetectors/AFP/Run3AFPMonitoring/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1d99ae5b68e4626ce900ac04543c14774f6c003d --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/CMakeLists.txt @@ -0,0 +1,62 @@ +################################################################################ +# Package: Run3AFPMonitoring +################################################################################ + +# Declare the package name: +atlas_subdir( Run3AFPMonitoring ) + + +# Declare the package's dependencies: +atlas_depends_on_subdirs( + PUBLIC + Control/AthenaBaseComps + Control/AthenaMonitoringKernel + GaudiKernel + Event/xAOD/xAODForward + xAODForward/AFPSiHit + xAODForward/AFPToFHit + LumiBlock/LumiBlockComps + LumiBlock/LumiBlockData + Trigger/TrigEvent/TrigDecisionInterface + PRIVATE + Control/AthenaMonitoring + AtlasTest/TestTools + Control/AthenaKernel + Control/CxxUtils + Control/SGMon/SGAudCore + Database/AthenaPOOL/AthenaPoolUtilities + Event/xAOD/xAODEventInfo + Event/EventInfo + Tools/LWHists + Trigger/TrigAnalysis/TrigDecisionTool + Trigger/TrigAnalysis/TrigAnalysisInterfaces + MuonSpectrometer/MuonAlignment/MuonAlignmentData +) + +# External dependencies: +find_package( ROOT COMPONENTS Core ) + +# Component(s) in the package: +atlas_add_component( Run3AFPMonitoring + Run3AFPMonitoring/*.h src/*.cxx src/components/*.cxx + INCLUDE_DIRS + ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES + ${ROOT_LIBRARIES} + AthenaBaseComps + AthenaMonitoringLib + AthenaMonitoringKernelLib + GaudiKernel + LumiBlockCompsLib + LumiBlockData + TrigDecisionToolLib + xAODForward + AthenaKernel + SGAudCore + AthenaPoolUtilities + EventInfo + LWHists +) + +atlas_install_python_modules( python/*.py ) + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPFastReco.h b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPFastReco.h new file mode 100644 index 0000000000000000000000000000000000000000..38080060f69bb2c4eb623f60ddfe2d860e9aea7d --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPFastReco.h @@ -0,0 +1,131 @@ +#ifndef AFP_MONITORING_AFPFASTRECO_H +#define AFP_MONITORING_AFPFASTRECO_H + +#include <array> +#include <list> +#include <utility> +#include <vector> + +#include "xAODForward/AFPSiHit.h" +#include "xAODForward/AFPSiHitContainer.h" + +namespace AFPMon { + + struct AFPCluster { + AFPCluster(float x_, float y_, float z_, int s, int l) + : x {x_}, y {y_}, z {z_}, station {s}, layer {l} {} + + float x; + float y; + float z; + int station; + int layer; + }; + + inline bool operator==(const AFPCluster& lhs, const AFPCluster& rhs) { + if (lhs.x != rhs.x) return false; + if (lhs.y != rhs.y) return false; + if (lhs.z != rhs.z) return false; + if (lhs.station != rhs.station) return false; + if (lhs.layer != rhs.layer) return false; + + return true; + } + + struct AFPTrack { + AFPTrack(float x_, float y_, int s, std::array<int, 4> a) + : x {x_}, y {y_}, station {s}, layerClusters {std::move(a)} {} + + float x; + float y; + int station; + std::array<int, 4> layerClusters; + }; + + class AFPFastReco { + public: + /// Constructor. Sets input hit container + AFPFastReco(const xAOD::AFPSiHitContainer* hits) : m_hitContainer {hits} {} + + /// Performs fast reconstruction of clusters and tracks + void reco(); + + /// Returns vector of clusters + std::vector<AFPCluster> clusters() const { return m_clusters; } + + /// Returns vector of tracks + std::vector<AFPTrack> tracks() const { return m_tracks; } + + private: + /// Performs fast cluster reconstruction + void recoClusters(); + + /// Performs fast track reconstruction + void recoTracks(); + + /// Returns parameters of fitted line + std::pair<double, double> linReg(std::vector<std::pair<double, double>> YX) const; + + /// Finds hits/clusters around given init element + template <class T> + std::vector<T> findAround(T init, std::list<T>& toJoin) const; + + /// Checks if given hits are neighbours + bool areNeighbours(const xAOD::AFPSiHit* lhs, const xAOD::AFPSiHit* rhs) const; + + /// Checks if given clusters are neighbours + bool areNeighbours(const AFPCluster& lhs, const AFPCluster& rhs) const; + + /// Pointer to hit container + const xAOD::AFPSiHitContainer* m_hitContainer; + + /// Vector of clusters + std::vector<AFPCluster> m_clusters; + + /// Vector of tracks + std::vector<AFPTrack> m_tracks; + + /// Number of AFP stations + static constexpr int s_afpStations = 4; + + /// Number of layers in each station + static constexpr int s_afpLayers = 4; + + /// Minimum number of clusters in track + static constexpr int s_trackSize = 3; + + /// Maximum distance between cluster + static constexpr float s_clusterDistance = 0.4; + }; + + template <class T> + std::vector<T> AFPFastReco::findAround(T init, std::list<T>& toJoin) const { + std::vector<T> element; + element.push_back(init); + + std::vector<T> newNeighbours; + do { + newNeighbours.clear(); + for (auto& b : toJoin) { + bool isNew = false; + for (auto& a : element) + if (areNeighbours(a, b)) isNew = true; + + if (isNew) { + newNeighbours.push_back(b); + element.push_back(b); + } + } + + for (auto& t : newNeighbours) + toJoin.remove(t); + + } while (newNeighbours.size() > 0); + + return element; + } + +} // namespace AFPMon + +#endif /* AFP_MONITORING_AFPFASTRECO_H */ + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..09ee501e0d403d1d5e7734c3706ff5b7c7c89277 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef AFPSILAYERALGORITHM_H +#define AFPSILAYERALGORITHM_H + +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AthenaMonitoringKernel/Monitored.h" +#include "StoreGate/ReadHandleKey.h" +#include "xAODForward/AFPSiHitContainer.h" +#include "xAODForward/AFPSiHit.h" + +#include "TRandom3.h" + +class AFPSiLayerAlgorithm : public AthMonitorAlgorithm { +public: + AFPSiLayerAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + virtual ~AFPSiLayerAlgorithm(); + virtual StatusCode initialize() override; + virtual StatusCode fillHistograms( const EventContext& ctx ) const override; + +private: + std::map<std::string,std::map<std::string,int>> m_HitmapGroups; + SG::ReadHandleKey<xAOD::AFPSiHitContainer> m_afpHitContainerKey; + +protected: + std::vector<std::string> m_pixlayers = { "P0", "P1", "P2", "P3"}; + std::vector<std::string> m_stationnames = { "farAside", "nearAside" , "nearCside" , "farCside"}; + +}; +#endif + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..a9400de437796edc77f19e5c534967d1ca487c26 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef AFPTOFALGORITHM_H +#define AFPTOFALGORITHM_H + +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AthenaMonitoringKernel/Monitored.h" +#include "StoreGate/ReadHandleKey.h" +#include "xAODForward/AFPToFHitContainer.h" +#include "xAODForward/AFPToFHit.h" + +#include "TRandom3.h" + +class AFPToFAlgorithm : public AthMonitorAlgorithm { +public: + AFPToFAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + virtual ~AFPToFAlgorithm(); + virtual StatusCode initialize() override; + virtual StatusCode fillHistograms( const EventContext& ctx ) const override; + +private: + SG::ReadHandleKey<xAOD::AFPToFHitContainer> m_afpToFHitContainerKey; + +protected: + std::vector<std::string> m_pixlayers = { "P0", "P1", "P2", "P3"}; + std::vector<std::string> m_stationnames = { "farAside", "nearAside" , "nearCside" , "farCside"}; + +}; +#endif + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py new file mode 100644 index 0000000000000000000000000000000000000000..700a7575f04a3138bd0b98e8acc6c46122954ca8 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py @@ -0,0 +1,82 @@ +# +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# + +'''@file Run3AFPExampleMonitorAlgorithm.py +@author C. D. Burton +@author P. Onyisi +@date 2018-01-11 +@brief Example python configuration for the Run III AthenaMonitoring package +''' + +def Run3AFPExampleMonitoringConfig(inputFlags): + '''Function to configures some algorithms in the monitoring system.''' + + from AthenaMonitoring import AthMonitorCfgHelper + helper = AthMonitorCfgHelper(inputFlags,'Run3AFPMonitorCfg') + + from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPSiLayerAlgorithm + afpSiLayerAlgorithm = helper.addAlgorithm(AFPSiLayerAlgorithm,'AFPSiLayerAlg') + + from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPToFAlgorithm + afpToFAlgorithm = helper.addAlgorithm(AFPToFAlgorithm,'AFPToFAlg') + + # Add a generic monitoring tool (a "group" in old language). The returned + # object here is the standard GenericMonitoringTool. + AFPSiGroup = helper.addGroup(afpSiLayerAlgorithm, 'AFPSiLayerTool', 'AFP/') + AFPToFGroup = helper.addGroup(afpToFAlgorithm, 'AFPToFTool', 'AFP/') + + AFPSiGroup.defineHistogram('lb,nSiHits', title='Luminosity Block;lb;total number of Hits', type='TProfile', path='SiT/',xbins=1000,xmin=-0.5,xmax=999.5 ) + AFPToFGroup.defineHistogram('lb,nTofHits', title='Luminosity Block;lb;total number of Hits', type='TProfile', path='ToF/',xbins=1000,xmin=-0.5,xmax=999.5) + + AFPToFGroup.defineHistogram('numberOfHit_S0', title='Number of hit per bar station 0;total number of Hits', path='ToF/',xbins=3,xmin=-0.5,xmax=2.5) + AFPToFGroup.defineHistogram('numberOfHit_S3', title='Number of hit per bar station 3;total number of Hits', path='ToF/',xbins=3,xmin=-0.5,xmax=2.5) + + + # Using a map of groups + layerList = ['P0','P1', 'P2', 'P3'] ## TODO XXX adapt to the enum/xAOD namespace names + combinedList = ['farAside', 'nearAside', 'nearCside', 'farCside'] + + array = helper.addArray([combinedList,layerList], afpSiLayerAlgorithm, 'AFPSiLayerTool', topPath = 'AFP/SiT/') + array.defineHistogram('pixelColIDChip', title='1D hitmap for {0} Layer {1}', path='PixelColIDChip', xbins=80, xmin=0.5, xmax=80.5) + array.defineHistogram('pixelRowIDChip', title='1D hitmap for {0} Layer {1}', path='PixelRowIDChip', xbins=336, xmin=0.5, xmax=336.5) + array.defineHistogram('pixelColIDChip,pixelRowIDChip', title='hitmap for {0} Layer {1}', type='TH2F', path='pixelColRow2D', xbins=80, xmin=0.5, xmax=80.5, ybins=336, ymin=0.5, ymax=336.5) + array.defineHistogram('timeOverThreshold', title='1D Time over threshold for {0} Layer {1}', path='SiTimeOverThreshold', xbins=60, xmin=0, xmax=20) + + # Finalize. The return value should be a tuple of the ComponentAccumulator + return helper.result() + + +if __name__=='__main__': + # Setup the Run III behavior + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior = 1 + + # Setup logs + from AthenaCommon.Logging import log + from AthenaCommon.Constants import INFO + log.setLevel(INFO) + + # Set the Athena configuration flags + from AthenaConfiguration.AllConfigFlags import ConfigFlags + nightly = '' + file = '/afs/cern.ch/work/k/kristin/dataAFP/data17_13TeV.00337176.physics_Main.merge.AOD.r10258_p3399_tid13243079_00/AOD.13243079._000005.pool.root.1' + + ConfigFlags.Input.Files = [nightly+file] + ConfigFlags.Input.isMC = False + ConfigFlags.Output.HISTFileName = 'AFPOutput.root' + + ConfigFlags.lock() + + # Initialize configuration object, add accumulator, merge, and run. + from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg = MainServicesSerialCfg() + cfg.merge(PoolReadCfg(ConfigFlags)) + + exampleMonitorAcc = Run3AFPExampleMonitoringConfig(ConfigFlags) + cfg.merge(exampleMonitorAcc) + + cfg.run(1000) #use cfg.run(20) to only run on first 20 events + + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx new file mode 100644 index 0000000000000000000000000000000000000000..83ba56c43358f7948e17db6ff961b39cf86df379 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPFastReco.cxx @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + * * + * * + * * AFPFastReco.cxx + * * + * * + * */ + +#include <Run3AFPMonitoring/AFPFastReco.h> + +namespace AFPMon { + + void AFPFastReco::reco() { + recoClusters(); + recoTracks(); + } + + void AFPFastReco::recoClusters() { + constexpr float dx = 0.25; // [mm] + constexpr float dy = 0.05; // [mm] + constexpr float dz = 9.00; // [mm] + constexpr float tilt = 14. / 180. * 3.14159; + + std::list toCluster(m_hitContainer->begin(), m_hitContainer->end()); + + while (toCluster.size() > 0) { + auto init = *(toCluster.begin()); + toCluster.pop_front(); + auto clusteredHits = findAround(init, toCluster); + + float sumX = 0; + float sumY = 0; + float sumCharge = 0; + for (const xAOD::AFPSiHit* h : clusteredHits) { + const float charge = h->depositedCharge(); + const float pixX = dx * h->pixelColIDChip(); + const float pixY = dy * h->pixelRowIDChip(); + sumX += charge * pixX; + sumY += charge * pixY; + sumCharge += charge; + } + + const float xPlane = sumX / sumCharge; + const float yPlane = sumY / sumCharge; + + const int stationID = init->stationID(); + const int layerID = init->pixelLayerID(); + + const float x = xPlane; + const float y = yPlane * cos(tilt); + const float z = yPlane * sin(tilt) * dz * layerID; + + m_clusters.emplace_back(x, y, z, stationID, layerID); + } + } + + void AFPFastReco::recoTracks() { + std::list toTrack(m_clusters.begin(), m_clusters.end()); + + while (toTrack.size() > 0) { + auto init = *(toTrack.begin()); + toTrack.pop_front(); + auto trackCandidate = findAround(init, toTrack); + + if (trackCandidate.size() < s_trackSize) continue; + + std::array<int, 4> clusters {}; + + std::vector<std::pair<double, double>> XZ; + std::vector<std::pair<double, double>> YZ; + + for (const auto& cluster : trackCandidate) { + clusters[cluster.layer]++; + + XZ.emplace_back(cluster.x, cluster.z); + YZ.emplace_back(cluster.y, cluster.z); + } + + const auto [x, xSlope] = linReg(XZ); + const auto [y, ySlope] = linReg(YZ); + const int station = trackCandidate[0].station; + + m_tracks.emplace_back(x, y, station, clusters); + } + } + + std::pair<double, double> AFPFastReco::linReg(std::vector<std::pair<double, double>> YX) const { + double meanx = 0; + double meany = 0; + for (const auto& yx : YX) { + meany += yx.first; + meanx += yx.second; + } + + meanx /= YX.size(); + meany /= YX.size(); + + double numerator = 0; + double denumerator = 0; + for (const auto& yx : YX) { + const double dy = yx.first - meany; + const double dx = yx.second - meanx; + numerator += dx * dy; + denumerator += dx * dx; + } + + const double slope = numerator / denumerator; + const double position = meany - slope * meanx; + + return {position, slope}; + } + + bool AFPFastReco::areNeighbours(const xAOD::AFPSiHit* lhs, const xAOD::AFPSiHit* rhs) const { + if (lhs->stationID() != rhs->stationID()) return false; + if (lhs->pixelLayerID() != rhs->pixelLayerID()) return false; + if (lhs->pixelColIDChip() != rhs->pixelColIDChip()) return false; + if (abs(lhs->pixelRowIDChip() - rhs->pixelRowIDChip()) != 1) return false; + + return true; + } + + bool AFPFastReco::areNeighbours(const AFPCluster& lhs, const AFPCluster& rhs) const { + if (lhs.station != rhs.station) return false; + + const float dx = lhs.x - rhs.x; + const float dy = lhs.y - rhs.y; + if (dx * dx + dy * dy > s_clusterDistance) return false; + + return true; + } + +} // namespace AFPMon + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9f116b2eae45c31998133542a60fa41dfaa15e87 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx @@ -0,0 +1,97 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +* +* +* AFPSiLayerAlgorithm +* +* +*/ + +#include "Run3AFPMonitoring/AFPSiLayerAlgorithm.h" +#include "StoreGate/ReadHandleKey.h" +#include "xAODForward/AFPStationID.h" + +#include <Run3AFPMonitoring/AFPFastReco.h> + + +AFPSiLayerAlgorithm::AFPSiLayerAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) +:AthMonitorAlgorithm(name,pSvcLocator) +, m_afpHitContainerKey("AFPSiHitContainer") + +{ + declareProperty( "AFPSiHitContainer", m_afpHitContainerKey ); +} + + +AFPSiLayerAlgorithm::~AFPSiLayerAlgorithm() {} + + +StatusCode AFPSiLayerAlgorithm::initialize() { + using namespace Monitored; + + m_HitmapGroups = buildToolMap<std::map<std::string,int>>(m_tools,"AFPSiLayerTool", m_stationnames, m_pixlayers); + + // We must declare to the framework in initialize what SG objects we are going to use: + SG::ReadHandleKey<xAOD::AFPSiHitContainer> afpHitContainerKey("AFPSiHits"); + ATH_CHECK(m_afpHitContainerKey.initialize()); + + return AthMonitorAlgorithm::initialize(); +} + + +StatusCode AFPSiLayerAlgorithm::fillHistograms( const EventContext& ctx ) const { + using namespace Monitored; + + // Declare the quantities which should be monitored: + auto lb = Monitored::Scalar<int>("lb", 0); + auto nSiHits = Monitored::Scalar<int>("nSiHits", 1); + auto pixelRowIDChip = Monitored::Scalar<int>("pixelRowIDChip", 0); + auto pixelColIDChip = Monitored::Scalar<int>("pixelColIDChip", 0); + auto timeOverThreshold = Monitored::Scalar<float>("timeOverThreshold", 0.0); + + lb = GetEventInfo(ctx)->lumiBlock(); + + SG::ReadHandle<xAOD::AFPSiHitContainer> afpHitContainer(m_afpHitContainerKey, ctx); + if(! afpHitContainer.isValid()) + { + ATH_MSG_ERROR("evtStore() does not contain hits collection with name " << m_afpHitContainerKey); + return StatusCode::FAILURE; + } + + ATH_CHECK( afpHitContainer.initialize() ); + + nSiHits = afpHitContainer->size(); + fill("AFPSiLayerTool", lb, nSiHits); + + for(const xAOD::AFPSiHit *hitsItr: *afpHitContainer) + { + pixelRowIDChip = hitsItr->pixelRowIDChip(); + pixelColIDChip = hitsItr->pixelColIDChip(); + timeOverThreshold = hitsItr->timeOverThreshold(); + + if (hitsItr->stationID()<4 && hitsItr->stationID()>=0 && hitsItr->pixelLayerID()<4 && hitsItr->pixelLayerID()>=0) + { + fill(m_tools[m_HitmapGroups.at(m_stationnames.at(hitsItr->stationID())).at(m_pixlayers.at(hitsItr->pixelLayerID()))], pixelRowIDChip, pixelColIDChip); + fill(m_tools[m_HitmapGroups.at(m_stationnames.at(hitsItr->stationID())).at(m_pixlayers.at(hitsItr->pixelLayerID()))], pixelRowIDChip); + fill(m_tools[m_HitmapGroups.at(m_stationnames.at(hitsItr->stationID())).at(m_pixlayers.at(hitsItr->pixelLayerID()))], pixelColIDChip); + fill(m_tools[m_HitmapGroups.at(m_stationnames.at(hitsItr->stationID())).at(m_pixlayers.at(hitsItr->pixelLayerID()))], timeOverThreshold); + + } + else ATH_MSG_WARNING("Unrecognised station index: " << hitsItr->stationID()); + } + + AFPMon::AFPFastReco fast(afpHitContainer.get()); + fast.reco(); + + for (const auto& cluster : fast.clusters()) { + ATH_MSG_INFO("c: " << cluster.x << " " << cluster.y); + } + + for (const auto& track : fast.tracks()) { + ATH_MSG_INFO("t: " << track.x << " " << track.y); + } + + return StatusCode::SUCCESS; +} + + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d156db4b300c5c3f7e6403efe9b27aa93d0c2f75 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx @@ -0,0 +1,80 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +* +* +* AFPToFAlgorithm +* +* +*/ + +#include "Run3AFPMonitoring/AFPToFAlgorithm.h" +#include "StoreGate/ReadHandleKey.h" +#include "xAODForward/AFPStationID.h" + + +AFPToFAlgorithm::AFPToFAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) +:AthMonitorAlgorithm(name,pSvcLocator) +, m_afpToFHitContainerKey("AFPToFHitContainer") + +{ + declareProperty( "AFPToFHitContainer", m_afpToFHitContainerKey ); +} + + +AFPToFAlgorithm::~AFPToFAlgorithm() {} + + +StatusCode AFPToFAlgorithm::initialize() { + using namespace Monitored; + + // We must declare to the framework in initialize what SG objects we are going to use + SG::ReadHandleKey<xAOD::AFPToFHitContainer> afpToFHitContainerKey("AFPToFHits"); + ATH_CHECK(m_afpToFHitContainerKey.initialize()); + + return AthMonitorAlgorithm::initialize(); +} + + +StatusCode AFPToFAlgorithm::fillHistograms( const EventContext& ctx ) const { + using namespace Monitored; + + // Declare the quantities which should be monitored + auto lb = Monitored::Scalar<int>("lb", 0); + auto nTofHits = Monitored::Scalar<int>("nTofHits", 1); + + lb = GetEventInfo(ctx)->lumiBlock(); + + + SG::ReadHandle<xAOD::AFPToFHitContainer> afpToFHitContainer(m_afpToFHitContainerKey, ctx); + if(! afpToFHitContainer.isValid()) + { + ATH_MSG_ERROR("evtStore() does not contain hits collection with name " << m_afpToFHitContainerKey); + return StatusCode::FAILURE; + } + + ATH_CHECK( afpToFHitContainer.initialize() ); + + nTofHits = afpToFHitContainer->size(); + fill("AFPToFTool", lb, nTofHits); + +/* TO BE researched: difference between trainID and barInTrainID + auto numberOfHit_S0 = Monitored::Scalar<int>("numberOfHit_S0", 0); + auto numberOfHit_S3 = Monitored::Scalar<int>("numberOfHit_S3", 0); + + for(const xAOD::AFPTofHit *hitsIts: *afpToFHitContainer) + { + if(hitsIts->isSideA()) + { + fill("AFPToFTool", numberOfHit_S0); + } + else if(hitsIts->isSideC()) + { + fill("AFPToFTool", numberOfHit_S3); + } + } +*/ + + + return StatusCode::SUCCESS; +} + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..87d934362be0dc4ccfa32a62594adec2b5d69554 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx @@ -0,0 +1,9 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "Run3AFPMonitoring/AFPSiLayerAlgorithm.h" +#include "Run3AFPMonitoring/AFPToFAlgorithm.h" + +DECLARE_COMPONENT( AFPSiLayerAlgorithm ) +DECLARE_COMPONENT( AFPToFAlgorithm )