From 8c5a4fca6eaa3339ac2ec968f1f3c40001c21076 Mon Sep 17 00:00:00 2001 From: Nikola Dikic <nikola.dikic@cern.ch> Date: Tue, 10 Mar 2020 15:39:04 +0100 Subject: [PATCH] Started ToF --- .../Run3AFPMonitoring/AFPToFAlgorithm.h | 45 ++++++++ .../python/Run3AFPExampleMonitorAlgorithm.py | 4 + .../src/AFPSiLayerAlgorithm.cxx | 5 + .../Run3AFPMonitoring/src/AFPToFAlgorithm.cxx | 105 ++++++++++++++++++ .../components/Run3AFPMonitoring_entries.cxx | 2 + 5 files changed, 161 insertions(+) create mode 100644 ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h create mode 100644 ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h new file mode 100644 index 000000000000..450e360763f3 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPToFAlgorithm.h @@ -0,0 +1,45 @@ +/* + 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: + Gaudi::Property<bool> m_doRandom {this,"RandomHist",false}; + std::vector<int> m_abGroups1; + std::vector<std::vector<int>> m_abGroups2; + std::map<std::string,int> m_cGroups1; + //std::map<std::string,std::map<std::string,std::map<std::string,int>>> m_HitmapGroups; + std::map<std::string,std::map<std::string,int>> m_HitmapGroups; + SG::ReadHandleKey<xAOD::AFPSiHitContainer> m_afpHitContainerKey; + +// m_HitmapGroups = buildToolMap<std::string,std::map<std::string,int>> +protected: + std::vector<std::string> m_pixlayers = { "P0", "P1", "P2", "P3"}; + std::vector<std::string> m_stationnames = { "farAside", "nearAside" , "nearCside" , "farCside"}; + + + + static const int s_cNearStationIndex; + static const int s_cFarStationIndex; + const std::string m_histsDirectoryName; + +}; +#endif + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py index 24bb8430d81c..39a984de7a4c 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py @@ -34,6 +34,9 @@ def Run3AFPExampleMonitoringConfig(inputFlags): from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPSiLayerAlgorithm afpSiLayerAlgorithm = helper.addAlgorithm(AFPSiLayerAlgorithm,'AFPSiLayerAlg') + from Run3AFPMonitoring.Run3AFPMonitoringConf import AFPToFAlgorithm + afpToFAlgorithm = helper.addAlgorithm(AFPToFAlgorithm,'AFPToFAlg') + # You can actually make multiple instances of the same algorithm and give # them different configuration #anotherExampleMonAlg = helper.addAlgorithm(AFPSiLayerAlgorithm,'AnotherExampleMonAlg') @@ -63,6 +66,7 @@ def Run3AFPExampleMonitoringConfig(inputFlags): # Add a generic monitoring tool (a "group" in old language). The returned # object here is the standard GenericMonitoringTool. AFPGroup = helper.addGroup( afpSiLayerAlgorithm, 'AFPSiLayerTool', 'AFP/' ) + AFPToFGroup = helper.addGroup( afpToFAlgorithm, 'AFPToFTool', 'AFP/' ) # station0_1 = helper.addGroup(afpSiLayerAlgorithm, 'AFPSiLayer','Station0/') diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx index 65c99d2cc0bd..26f0e22fc6f3 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx @@ -1,5 +1,10 @@ /* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +* +* +* AFPSiLayerAlgorithm +* +* */ #include "Run3AFPMonitoring/AFPSiLayerAlgorithm.h" diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx new file mode 100644 index 000000000000..bfb57360d3b7 --- /dev/null +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPToFAlgorithm.cxx @@ -0,0 +1,105 @@ +/* + Copyright (C) 2002-2019 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_histsDirectoryName ("AFP/") +//, m_cNearStation (s_cNearStationIndex) +//, m_cFarStation (s_cFarStationIndex) +, m_afpToFContainerKey("AFPToFContainer") + +{ + declareProperty( "AFPToFContainer", m_afpToFContainerKey ); +} + + +AFPToFAlgorithm::~AFPToFAlgorithm() {} + + +StatusCode AFPToFAlgorithm::initialize() { + using namespace Monitored; + + m_HitmapGroups = buildToolMap<std::map<std::string,int>>(m_tools,"AFPToFTool",m_stationnames,m_pixlayers); + + // std::map<std::string,std::map<std::string,int>> <std::map<std::string,int>> + // We must declare to the framework in initialize what SG objects we are going to use + SG::ReadHandleKey<xAOD::AFPToFContainer> afpToFContainerKey("AFPToFHits"); + ATH_CHECK(m_afpToFContainerKey.initialize()); + // ... + return AthMonitorAlgorithm::initialize(); +} + + +StatusCode AFPToFAlgorithm::fillHistograms( const EventContext& ctx ) const { + using namespace Monitored; + + // Declare the quantities which should be monitored + // My histograms: + // auto h_hitMultiplicity = Monitored::Scalar<int>("h_hitMultiplicity", 0); + // auto h_timeOverThreshold = Monitored::Scalar<int>("h_timeOverThreshold", 0); + // auto h_hitMap = Monitored::Scalar<int>("h_hitMap", 0); + // End + + auto lb = Monitored::Scalar<int>("lb", 0); // Nikola + auto nhits = Monitored::Scalar<int>("nhits", 1); + + lb = GetEventInfo(ctx)->lumiBlock(); // Nikola + + + SG::ReadHandle<xAOD::AFPToFContainer> afpToFContainer(m_afpToFContainerKey, ctx); + if(! afpToFContainer.isValid()) + { + ATH_MSG_ERROR("evtStore() does not contain hits collection with name " << m_afpToFContainerKey); + return StatusCode::FAILURE; + } + + /****************************************** + * + * const int xAOD::AFPStationID::farA = 0; + * const int xAOD::AFPStationID::nearA = 1; + * const int xAOD::AFPStationID::nearC = 2; + * const int xAOD::AFPStationID::farC = 3; + * + ******************************************/ + + ATH_CHECK( afpToFContainer.initialize() ); + + nhits = afpToFContainer->size(); + fill("AFPSiLayerTool", lb, nhits); + + auto pixelRowIDChip = Monitored::Scalar<int>("pixelRowIDChip", 0); // Nikola + auto pixelColIDChip = Monitored::Scalar<int>("pixelColIDChip", 0); // Nikola + auto h_hitMap = Monitored::Scalar<int>("h_hitMap", 0); // Nikola + + for(const xAOD::AFPSiHit *hitsItr: *afpToFContainer) + { + pixelRowIDChip=hitsItr->pixelRowIDChip(); + pixelColIDChip = hitsItr->pixelColIDChip(); + std::cout << "Hits iteration -> stationID = " << hitsItr->stationID() << std::endl; + std::cout << "Hits iteration -> pixelLayerID = " << hitsItr->pixelLayerID() << std::endl; + + if (hitsItr->stationID()<4 && hitsItr->stationID()>=0 && hitsItr->pixelLayerID()<4 && hitsItr->pixelLayerID()>=0) + { + std::cout << "I AM RIGHT BEFORE FILL METHOD\n" << std::endl; + fill(m_tools[m_HitmapGroups.at( m_stationnames.at(hitsItr->stationID())).at( m_pixlayers.at(hitsItr->pixelLayerID()))] , pixelRowIDChip, pixelColIDChip); + } + else + ATH_MSG_WARNING("Unrecognised station index: " << hitsItr->stationID()); + + } + + + return StatusCode::SUCCESS; +} + diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx index 3fb7d47dc5a6..ddca4d2e27ab 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/components/Run3AFPMonitoring_entries.cxx @@ -3,5 +3,7 @@ */ #include "Run3AFPMonitoring/AFPSiLayerAlgorithm.h" +#include "Run3AFPMonitoring/AFPToFAlgorithm.h" DECLARE_COMPONENT( AFPSiLayerAlgorithm ) +//DECLARE_COMPONENT( AFPToFAlgorithm ) -- GitLab