From c2024d88a5fdd23eb6d75b4d8a51d66ffc829554 Mon Sep 17 00:00:00 2001 From: kristin <kristin.lohwasser@cern.ch> Date: Mon, 9 Mar 2020 11:19:52 +0100 Subject: [PATCH] added loop over layers and statiosn --- .../Run3AFPMonitoring/AFPSiLayerAlgorithm.h | 8 ++- .../python/Run3AFPExampleMonitorAlgorithm.py | 25 ++++---- .../src/AFPSiLayerAlgorithm.cxx | 61 ++++++------------- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h index a880b0a101e7..b245a2f57dd3 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/Run3AFPMonitoring/AFPSiLayerAlgorithm.h @@ -25,10 +25,16 @@ private: 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; + 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; diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py index c22c115fb6c3..50218c937f04 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/python/Run3AFPExampleMonitorAlgorithm.py @@ -80,16 +80,17 @@ def Run3AFPExampleMonitoringConfig(inputFlags): # one might have an array of TH1's such as quantity[etaIndex][phiIndex][layerIndex]. for alg in [afpSiLayerAlgorithm]: - # Using a map of groups - layerList = ['P0','P1', 'P2', 'P3'] ## TODO XXX adapt to the enum/xAOD namespace names - #stationList = ['FarStation','NearStation'] # TODO XXX - #sideList = ['Aside' , 'Cside' ] - combinedList = [ 0, 1, 2, 3 ] - #array = helper.addArray([sideList,stationList,layerList],alg,'AFPSiLayerTool') - array = helper.addArray([combinedList,layerList],alg,'AFPSiLayerTool') - array.defineHistogram( 'h_hitMap', title='Map of hits', type='TH2F', path='AFPSiLayer', xbins=80,xmin=0.5,xmax=80.5, ybins=336,ymin=0.5,ymax=336.5) - #array.defineHistogram('h_hitMap', title='hitmap for {0} {1} Layer {2}', path='Keys/{0}', xmax=3. ) - array.defineHistogram('h_hitMap', title='hitmap for {0} Layer {1}', path='Keys/{0}', xmax=3. ) + # Using a map of groups + layerList = ['P0','P1', 'P2', 'P3'] ## TODO XXX adapt to the enum/xAOD namespace names + #stationList = ['FarStation','NearStation'] # TODO XXX + #sideList = ['Aside' , 'Cside' ] + combinedList = [ "farAside", "nearAside" , "nearCside" , "farCside" ] + + #array = helper.addArray([sideList,stationList,layerList],alg,'AFPSiLayerTool') + array = helper.addArray([combinedList,layerList],alg,'AFPSiLayerTool') + array.defineHistogram( 'h_hitMap', title='Map of hits', type='TH2F', path='AFPSiLayer', xbins=80,xmin=0.5,xmax=80.5, ybins=336,ymin=0.5,ymax=336.5) + #array.defineHistogram('h_hitMap', title='hitmap for {0} {1} Layer {2}', path='Keys/{0}', xmax=3. ) + array.defineHistogram('h_hitMap', title='hitmap for {0} Layer {1}', path='Keys/{0}', xmax=3. ) ### STEP 6 ### # Finalize. The return value should be a tuple of the ComponentAccumulator @@ -143,6 +144,6 @@ if __name__=='__main__': # If you want to turn on more detailed messages ... # exampleMonitorAcc.getEventAlgo('ExampleMonAlg').OutputLevel = 2 # DEBUG - cfg.printConfig(withDetails=False) # set True for exhaustive info + # cfg.printConfig(withDetails=False) # set True for exhaustive info - cfg.run(1000) #use cfg.run(20) to only run on first 20 events + cfg.run(10) #use cfg.run(20) to only run on first 20 events diff --git a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx index 79fc33eeb389..c68ae9dc1aab 100644 --- a/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx +++ b/ForwardDetectors/AFP/Run3AFPMonitoring/src/AFPSiLayerAlgorithm.cxx @@ -6,16 +6,7 @@ //#include <xAODForward/AFPSiHit.h> //#include <xAODForward/AFPSiHitContainer.h> #include "StoreGate/ReadHandleKey.h" - -/* Old constructor: -AFPHitsMonitorAlgorithm::AFPHitsMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) -:AthMonitorAlgorithm(name,pSvcLocator) -,m_doRandom(true) -{} -*/ - -const int s_cNearStationIndex = 2; -const int s_cFarStationIndex = 3; +#include "xAODForward/AFPStationID.h" AFPSiLayerAlgorithm::AFPSiLayerAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) @@ -36,14 +27,7 @@ AFPSiLayerAlgorithm::~AFPSiLayerAlgorithm() {} StatusCode AFPSiLayerAlgorithm::initialize() { using namespace Monitored; - std::vector<std::string> layers = { "P0", "P1", "P2", "P3"}; - std::vector<int> combined = { 0, 1, 2, 3}; - //std::vector<std::string> stations = { "FarStation" , "NearStation" }; - //std::vector<std::string> sides = { "Aside" , "Cside" }; - - - //m_HitmapGroups = buildToolMap<std::map<std::string,std::map<std::string,int>>>(m_tools,"AFPSiLayerTool",sides,stations,layers); - m_HitmapGroups = buildToolMap<std::map<int,int>>(m_tools,"AFPSiLayerTool",combined,layers); + m_HitmapGroups = buildToolMap<std::map<std::string,int>>(m_tools,"AFPSiLayerTool",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 @@ -163,36 +147,25 @@ StatusCode AFPSiLayerAlgorithm::fillHistograms( const EventContext& ctx ) const nhits = afpHitContainer->size(); fill("AFPSiLayerTool", lb, nhits); + auto pixelRowIDChip = Monitored::Scalar<int>("pixelRowIDChip", 0); // Nikola + auto pixelColIDChip = Monitored::Scalar<int>("pixelColIDChip", 0); // Nikola + for(const xAOD::AFPSiHit *hitsItr: *afpHitContainer) { - //std::cout << hitsItr->stationID() << std::endl; - - for ( auto& layer : std::vector<std::string>({"P0","P1", "P2", "P3"}) ) - { - switch(hitsItr->stationID()) - { - case 0: - std::cout << "Case 0; Test" << std::endl; - fill(m_tools[m_HitmapGroups.at(layer).at(hitsItr)]); - break; - case 1: - std::cout << "Case 1; Test" << std::endl; - fill(m_tools[m_HitmapGroups.at(layer).at(hitsItr)]); - break; - case 2: - std::cout << "Case 2; Test" << std::endl; - fill(m_tools[m_HitmapGroups.at(layer).at(hitsItr)]); - break; - case 3: - std::cout << "Case 3; Test" << std::endl; - fill(m_tools[m_HitmapGroups.at(layer).at(hitsItr)]); - //m_cFarStation.fillHistograms(*hitsItr); - break; - default: - ATH_MSG_WARNING("Unrecognised station index: " << hitsItr->stationID()); + pixelRowIDChip=hitsItr->pixelRowIDChip(); + pixelColIDChip = hitsItr->pixelColIDChip(); + std::cout << hitsItr->stationID() << std::endl; + std::cout << hitsItr->pixelLayerID() << std::endl; + + 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); } +else ATH_MSG_WARNING("Unrecognised station index: " << hitsItr->stationID()); + } - } + /* // Filling using a pre-defined map of groups. for ( auto& layer : std::vector<std::string>({"layer1","layer2"}) ) { -- GitLab