diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/share/NSWPRDValAlg.digi.py b/MuonSpectrometer/MuonValidation/MuonPRDTest/share/NSWPRDValAlg.digi.py index d6a9696bf6835b1efc74cd04ff5ea12d2ea8b837..d9a225b90343c5549056e169aa45624ea30f7b52 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/share/NSWPRDValAlg.digi.py +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/share/NSWPRDValAlg.digi.py @@ -29,6 +29,9 @@ NSWPRDValAlg.doSTGCRDO = MuonGeometryFlags.hasSTGC() NSWPRDValAlg.doSTGCPRD = False NSWPRDValAlg.doSTGCFastDigit = False +NSWPRDValAlg.doRPCHit = True +NSWPRDValAlg.doRPCDigit = True + #----------------------------------------------------------------------------- # save ROOT histograms and Tuple #----------------------------------------------------------------------------- diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx index 110ad08d67e033b595eb000e7ee8da8b0ad84c21..81eaf69394610f9afec632dc078d3ad20ccdfdbf 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <fstream> @@ -10,6 +10,7 @@ #include "MMDigitVariables.h" #include "MMSimHitVariables.h" #include "MDTSimHitVariables.h" +#include "RPCDigitVariables.h" #include "RPCSimHitVariables.h" #include "CSCSimHitVariables.h" #include "TGCSimHitVariables.h" @@ -61,6 +62,7 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) m_CscDigitVar(nullptr), m_MDTSimHitVar(nullptr), m_RPCSimHitVar(nullptr), + m_RPCDigitVar(nullptr), m_CSCSimHitVar(nullptr), m_TGCSimHitVar(nullptr), m_thistSvc(nullptr), @@ -84,6 +86,7 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) declareProperty("CSC_DigitContainerName", m_CSC_DigitContainerName="CSC_DIGITS"); declareProperty("MDT_SimContainerName", m_MDT_SimContainerName="MDT_Hits"); declareProperty("RPC_SimContainerName", m_RPC_SimContainerName="RPC_Hits"); + declareProperty("RPC_DigitContainerName", m_RPC_DigitContainerName="RPC_DIGITS"); declareProperty("CSC_SimContainerName", m_CSC_SimContainerName="CSC_Hits"); declareProperty("TGC_SimContainerName", m_TGC_SimContainerName="TGC_Hits"); @@ -104,6 +107,7 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) declareProperty("doCSCDigit", m_doCSCDigit=false); declareProperty("doMDTHit", m_doMDTHit=false); declareProperty("doRPCHit", m_doRPCHit=false); + declareProperty("doRPCDigit", m_doRPCDigit=false); declareProperty("doCSCHit", m_doCSCHit=false); declareProperty("doTGCHit", m_doTGCHit=false); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h index 196a2abf9db8d12a028e749fe5398247184fd4c2..d551f31ec0365863b84ac2e890fb32abaeace51b 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef NSWPRDVALALG_H @@ -15,6 +15,7 @@ class MDTSimHitVariables; class RPCSimHitVariables; +class RPCDigitVariables; class CSCSimHitVariables; class TGCSimHitVariables; class MMDigitVariables; @@ -69,6 +70,7 @@ class NSWPRDValAlg:public AthAlgorithm CSCDigitVariables* m_CscDigitVar; MDTSimHitVariables* m_MDTSimHitVar; RPCSimHitVariables* m_RPCSimHitVar; + RPCDigitVariables* m_RPCDigitVar; CSCSimHitVariables* m_CSCSimHitVar; TGCSimHitVariables* m_TGCSimHitVar; @@ -100,7 +102,8 @@ class NSWPRDValAlg:public AthAlgorithm BooleanProperty m_doMMPRD; // switch on the output of the MicroMegas prepdata BooleanProperty m_doCSCDigit; // switch on the output of the MicroMegas digitization BooleanProperty m_doMDTHit; - BooleanProperty m_doRPCHit; + BooleanProperty m_doRPCHit; // switch on the output of the RPC data + BooleanProperty m_doRPCDigit; // switch on the output of the RPC digitization BooleanProperty m_doCSCHit; BooleanProperty m_doTGCHit; @@ -121,6 +124,7 @@ class NSWPRDValAlg:public AthAlgorithm std::string m_NSWMM_PRDContainerName; std::string m_CSC_DigitContainerName; std::string m_MDT_SimContainerName; + std::string m_RPC_DigitContainerName; std::string m_RPC_SimContainerName; std::string m_CSC_SimContainerName; std::string m_TGC_SimContainerName; diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f3653745c5a572b56637a4d6f6b3fd746998ba59 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.cxx @@ -0,0 +1,175 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#include "RPCDigitVariables.h" +#include "AthenaKernel/errorcheck.h" + +#include "MuonDigitContainer/RpcDigitContainer.h" +#include "MuonDigitContainer/RpcDigit.h" + +#include "MuonReadoutGeometry/RpcReadoutElement.h" + +#include "MuonDigitContainer/RpcDigitCollection.h" + +#include "TTree.h" +#include <TString.h> // for Form +/** ---------- filling of variables */ +/** ---------- to be called on each evt i.e. execute level of main alg */ +StatusCode RpcDigitVariables::fillVariables(const MuonGM::MuonDetectorManager* MuonDetMgr) +{ + ATH_MSG_DEBUG(" do fillRpcDigitVariables()"); + CHECK( this->clearVariables() ); + + const RpcDigitContainer* RpcDigitContainer = nullptr; + CHECK( m_evtStore->retrieve(RpcDigitContainer, m_ContainerName.c_str()) ); + + ATH_MSG_DEBUG("retrieved RPC Digit Container with size "<<RpcDigitContainer->digit_size()); + + if(RpcDigitContainer->size()==0) ATH_MSG_DEBUG(" RPC Digit Continer empty "); + for(const RpcDigitCollection* coll : *RpcDigitContainer) { + ATH_MSG_DEBUG( "processing collection with size " << coll->size() ); + for (unsigned int digitNum=0; digitNum<coll->size(); digitNum++) { + const RpcDigit* digit = coll->at(digitNum); + Identifier Id = digit->identify(); + + std::string stName = m_RpcIdHelper->stationNameString(m_RpcIdHelper->stationName(Id)); + int stationEta = m_RpcIdHelper->stationEta(Id); + int stationPhi = m_RpcIdHelper->stationPhi(Id); + int doubletR = m_RpcIdHelper->doubletR(Id); + int doubletZ = m_RpcIdHelper->doubletZ(Id); + int doubletPhi = m_RpcIdHelper->doubletPhi(Id); + int gas_gap = m_RpcIdHelper->gasGap(Id); + + int stationEtaMin = m_RpcIdHelper->stationEtaMin(Id); + int stationEtaMax = m_RpcIdHelper->stationEtaMax(Id); + int stationPhiMin = m_RpcIdHelper->stationPhiMin(Id); + int stationPhiMax = m_RpcIdHelper->stationPhiMax(Id); + int doubletRMin = m_RpcIdHelper->doubletRMin(Id); + int doubletRMax = m_RpcIdHelper->doubletRMax(Id); + int doubletZMin = m_RpcIdHelper->doubletZMin(Id); + int doubletZMax = m_RpcIdHelper->doubletZMax(Id); + int doubletPhiMin = m_RpcIdHelper->doubletPhiMin(Id); + int doubletPhiMax = m_RpcIdHelper->doubletPhiMax(Id); + int gas_gapMin = m_RpcIdHelper->gasGapMin(Id); + int gas_gapMax = m_RpcIdHelper->gasGapMax(Id); + + ATH_MSG_DEBUG( "RPC Digit Offline id: Station Name [" << stName << " ]" + << " Station Eta [" << stationEta << "]" + << " Station Phi [" << stationPhi << "]" + << " GasGap [" << gas_gap << "]" + << " Station EtaMin [" << stationEtaMin << "]" + << " Station EtaMax [" << stationEtaMax << "]" + << " Station PhiMin [" << stationPhiMin << "]" + << " Station PhiMax [" << stationPhiMax << "]"); + + const MuonGM::RpcReadoutElement* rdoEl = MuonDetMgr->getRpcReadoutElement(Id); + if (!rdoEl) return StatusCode::FAILURE; + + Amg::Vector3D gpos(0.,0.,0.); + Amg::Vector2D lpos(0.,0.); + + rdoEl->stripPosition(Id,lpos); + rdoEl->surface(Id).localToGlobal(lpos, gpos,gpos); + + m_RPC_dig_localPosX.push_back( lpos.x() ); + m_RPC_dig_localPosY.push_back( lpos.y() ); + m_RPC_dig_globalPosX.push_back( gpos.x() ); + m_RPC_dig_globalPosY.push_back( gpos.y() ); + m_RPC_dig_globalPosZ.push_back( gpos.z() ); + + m_RPC_dig_stationName.push_back(stName); + m_RPC_dig_stationEta.push_back(stationEta); + m_RPC_dig_stationPhi.push_back(stationPhi); + m_RPC_dig_gas_gap.push_back(gas_gap); + m_RPC_dig_stationEtaMin.push_back(stationEtaMin); + m_RPC_dig_stationEtaMax.push_back(stationEtaMax); + m_RPC_dig_stationPhiMin.push_back(stationPhiMin); + m_RPC_dig_stationPhiMax.push_back(stationPhiMax); + m_RPC_dig_doubletR.push_back(doubletR); + m_RPC_dig_doubletZ.push_back(doubletZ); + m_RPC_dig_doubletPhiMax.push_back(doubletPhi); + m_RPC_dig_doubletRMin.push_back(doubletRMin); + m_RPC_dig_doubletRMax.push_back(doubletRMax); + m_RPC_dig_doubletZMin.push_back(doubletZMin); + m_RPC_dig_doubletZMax.push_back(doubletZMax); + m_RPC_dig_doubletPhiMin.push_back(doubletPhiMin); + m_RPC_dig_doubletPhiMax.push_back(doubletPhiMax); + m_RPC_dig_gas_gapMin.push_back(gas_gapMin); + m_RPC_dig_gas_gapMax.push_back(gas_gapMax); + + m_RPC_nDigits++; + } + } + ATH_MSG_DEBUG(" finished fillRpcDigitVariables()"); + return StatusCode::SUCCESS; +} + +/** ---------- clearing of variables */ +/** ---------- to be called inside filling method before filling starts */ +StatusCode RpcDigitVariables::clearVariables() +{ + m_RPC_nDigits = 0; + m_RPC_dig_stationName.clear(); + m_RPC_dig_stationEta.clear(); + m_RPC_dig_stationPhi.clear(); + m_RPC_dig_gas_gap.clear(); + + m_RPC_dig_stationEtaMin.clear(); + m_RPC_dig_stationEtaMax.clear(); + m_RPC_dig_stationPhiMin.clear(); + m_RPC_dig_stationPhiMax.clear(); + m_RPC_dig_doubletRMin.clear(); + m_RPC_dig_doubletRMax.clear(); + m_RPC_dig_doubletZMin.clear(); + m_RPC_dig_doubletZMax.clear(); + m_RPC_dig_doubletPhiMin.clear(); + m_RPC_dig_doubletPhiMax.clear(); + m_RPC_dig_gas_gapMin.clear(); + m_RPC_dig_gas_gapMax.clear(); + + m_RPC_dig_localPosX.clear(); + m_RPC_dig_localPosY.clear(); + m_RPC_dig_globalPosX.clear(); + m_RPC_dig_globalPosY.clear(); + m_RPC_dig_globalPosZ.clear(); + + return StatusCode::SUCCESS; +} + + +/** ---------- creating variables and associate them to branches */ +/** ---------- to be called on initialization level of main alg */ +StatusCode RpcDigitVariables::initializeVariables() +{ + + if(m_tree) { + ATH_MSG_DEBUG("RPC digit: init m_tree "); + m_tree->Branch("Digits_RPC", &m_RPC_nDigits, "Digits_RPC_n/i"); + m_tree->Branch("Digits_RPC_stationName", &m_RPC_dig_stationName); + m_tree->Branch("Digits_RPC_stationEta", &m_RPC_dig_stationEta); + m_tree->Branch("Digits_RPC_stationPhi", &m_RPC_dig_stationPhi); + m_tree->Branch("Digits_RPC_gas_gap", &m_RPC_dig_gas_gap); + m_tree->Branch("Digits_RPC_stationEtaMin", &m_RPC_dig_stationEtaMin); + m_tree->Branch("Digits_RPC_stationEtaMax", &m_RPC_dig_stationEtaMax); + m_tree->Branch("Digits_RPC_stationPhiMin", &m_RPC_dig_stationPhiMin); + m_tree->Branch("Digits_RPC_stationPhiMax", &m_RPC_dig_stationPhiMax); + m_tree->Branch("Digits_RPC_doubletRmin", &m_RPC_dig_doubletRMin); + m_tree->Branch("Digits_RPC_doubletRMax", &m_RPC_dig_doubletRMax); + m_tree->Branch("Digits_RPC_doubletZmin", &m_RPC_dig_doubletZMin); + m_tree->Branch("Digits_RPC_doubletZMax", &m_RPC_dig_doubletZMax); + m_tree->Branch("Digits_RPC_doubletPhiMin", &m_RPC_dig_doubletPhiMin); + m_tree->Branch("Digits_RPC_doubletPhiMax", &m_RPC_dig_doubletPhiMax); + m_tree->Branch("Digits_RPC_gas_gapMin", &m_RPC_dig_gas_gapMin); + m_tree->Branch("Digits_RPC_gas_gapMax", &m_RPC_dig_gas_gapMax); + + m_tree->Branch("Digits_RPC_localPosX", &m_RPC_dig_localPosX); + m_tree->Branch("Digits_RPC_localPosY", &m_RPC_dig_localPosY); + m_tree->Branch("Digits_RPC_globalPosX", &m_RPC_dig_globalPosX); + m_tree->Branch("Digits_RPC_globalPosY", &m_RPC_dig_globalPosY); + m_tree->Branch("Digits_RPC_globalPosZ", &m_RPC_dig_globalPosZ); + } + + return StatusCode::SUCCESS; +} + diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.h new file mode 100644 index 0000000000000000000000000000000000000000..cc2ca5b0bfad3190367a4b2fa2b5593731a58559 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/RPCDigitVariables.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MuonPRDTEST_RPCDigitVARIABLES_H +#define MuonPRDTEST_RPCDigitVARIABLES_H + +#include "ValAlgVariables.h" +#include "MuonIdHelpers/RpcIdHelper.h" +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include <vector> + +class RpcDigitVariables : public ValAlgVariables +{ + public: + RpcDigitVariables(StoreGateSvc* evtStore, + const MuonGM::MuonDetectorManager* detManager, + const MuonIdHelper* idhelper, + TTree* tree, + std::string containername, + MSG::Level msglvl) : + ValAlgVariables(evtStore, detManager, tree, containername, msglvl) + { + setHelper(idhelper); + } + + ~RpcDigitVariables() = default; + + StatusCode initializeVariables(); + StatusCode fillVariables(const MuonGM::MuonDetectorManager* MuonDetMgr); + + private: + + void setHelper(const MuonIdHelper* idhelper){ + m_RpcIdHelper = dynamic_cast<const RpcIdHelper*>(idhelper); + if (!m_RpcIdHelper){ + throw std::runtime_error("Could not cast the RPCIdHelper"); + } + } + + StatusCode clearVariables(); + + const RpcIdHelper* m_RpcIdHelper; + + int m_RPC_nDigits; + std::vector<std::string> m_RPC_dig_stationName; + std::vector<int> m_RPC_dig_stationEta; + std::vector<int> m_RPC_dig_stationPhi; + std::vector<int> m_RPC_dig_gas_gap; + std::vector<int> m_RPC_dig_stationEtaMin; + std::vector<int> m_RPC_dig_stationEtaMax; + std::vector<int> m_RPC_dig_stationPhiMin; + std::vector<int> m_RPC_dig_stationPhiMax; + std::vector<int> m_RPC_dig_doubletR; + std::vector<int> m_RPC_dig_doubletZ; + std::vector<int> m_RPC_dig_doubletPhi; + std::vector<int> m_RPC_dig_doubletRMin; + std::vector<int> m_RPC_dig_doubletRMax; + std::vector<int> m_RPC_dig_doubletZMin; + std::vector<int> m_RPC_dig_doubletZMax; + std::vector<int> m_RPC_dig_doubletPhiMin; + std::vector<int> m_RPC_dig_doubletPhiMax; + std::vector<int> m_RPC_dig_gas_gapMin; + std::vector<int> m_RPC_dig_gas_gapMax; + + std::vector< double > m_RPC_dig_localPosX; + std::vector< double > m_RPC_dig_localPosY; + std::vector< double > m_RPC_dig_globalPosX; + std::vector< double > m_RPC_dig_globalPosY; + std::vector< double > m_RPC_dig_globalPosZ; +}; + +#endif // MuonPRDTEST_RPCDigitVARIABLES_H