From 04e4ce3c40c17e46c13f4f2a847ca85dd14c783c Mon Sep 17 00:00:00 2001 From: Stefano Rosati <stefano.rosati@cern.ch> Date: Wed, 7 Mar 2018 19:36:03 +0100 Subject: [PATCH] Adding modifications by Michiel Veen to the algs in MuonPRDTest modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/MDTPRDValAlg.h modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMFastDigitVariables.cxx modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCFastDigitVariables.cxx modified: MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx Former-commit-id: e4d9bf129bf52d7df05fb7c4077de8b8ce0bdb5e --- .../MuonPRDTest/src/MDTPRDValAlg.h | 4 +- .../MuonPRDTest/src/MMFastDigitVariables.cxx | 4 +- .../MuonPRDTest/src/MMSimHitVariables.cxx | 14 +- .../MuonPRDTest/src/NSWPRDValAlg.cxx | 20 +- .../MuonPRDTest/src/sTGCDigitVariables.cxx | 65 +++--- .../src/sTGCFastDigitVariables.cxx | 4 +- .../MuonPRDTest/src/sTGCSimHitVariables.cxx | 212 +++++++++--------- 7 files changed, 164 insertions(+), 159 deletions(-) diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MDTPRDValAlg.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MDTPRDValAlg.h index 432ad8b93430..1bf76beebcc8 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MDTPRDValAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MDTPRDValAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef MDTPRDValAlg_H @@ -145,7 +145,7 @@ class MDTPRDValAlg: public AthAlgorithm { bool m_debug; bool m_verbose; StoreGateSvc* m_sgSvc; - bool isVerbose() {return (outputLevel() <= MSG::VERBOSE);} + bool isVerbose() {return (msgLevel() <= MSG::VERBOSE);} void addMcEventCollection( TruthMap& truthMap ) const; void addMuonRecord( TruthMap& truthMap, bool exit ) const; // add MuonEntry or MuonExit Record/Layer diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMFastDigitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMFastDigitVariables.cxx index f0e753d35621..9392f84be582 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMFastDigitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMFastDigitVariables.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MMFastDigitVariables.h" @@ -21,7 +21,7 @@ StatusCode MMFastDigitVariables::fillVariables() CHECK( this->clearVariables() ); const MuonSimDataCollection* nsw_MmSdoContainer = nullptr; - CHECK( m_evtStore->retrieve(nsw_MmSdoContainer, "MM_SDO") ); + CHECK( m_evtStore->retrieve(nsw_MmSdoContainer, "MMfast_SDO") ); const Muon::MMPrepDataContainer *nsw_MMPrepDataContainer = nullptr; CHECK( m_evtStore->retrieve(nsw_MMPrepDataContainer, m_ContainerName.c_str()) ); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx index c59603017248..9d4875d339f3 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "MMSimHitVariables.h" @@ -171,14 +171,11 @@ StatusCode MMSimHitVariables::fillVariables() Amg::Vector3D rSurface_pos = surf.transform().inverse()*hpos; Amg::Vector2D posOnSurfUnProjected(rSurface_pos.x(),rSurface_pos.y()); -// double gasGapThickness = detEl->getDesign(offId)->gasGapThickness(); + // double gasGapThickness = detEl->getDesign(offId)->gasGapThickness(); // check where the readout plane is located and compute the local direction accordingly Amg::Vector3D ldir(0., 0., 0.); - if ((roParam.stereoAngel).at(m_MmIdHelper->gasGap(offId)-1)==1) - ldir = surf.transform().inverse().linear()*Amg::Vector3D(hit.globalDirection().x(), hit.globalDirection().y(), hit.globalDirection().z()); - else - ldir = surf.transform().inverse().linear()*Amg::Vector3D(hit.globalDirection().x(), hit.globalDirection().y(), -hit.globalDirection().z()); + ldir = surf.transform().inverse().linear()*Amg::Vector3D(hit.globalDirection().x(), hit.globalDirection().y(), hit.globalDirection().z()); double scale, scaletop; double gasgap = 5.; @@ -194,7 +191,7 @@ StatusCode MMSimHitVariables::fillVariables() int stripNumber = detEl->stripNumber(posOnSurf,offId); -// int LastStripNumber = detEl->stripNumber(posOnTopSurf, offId); + // int LastStripNumber = detEl->stripNumber(posOnTopSurf, offId); // perform bound check if( !surf.insideBounds(posOnSurf) ) continue; @@ -235,6 +232,9 @@ StatusCode MMSimHitVariables::fillVariables() m_NSWMM_off_stationPhi ->push_back(off_stationPhi); m_NSWMM_off_multiplet ->push_back(off_multiplet); m_NSWMM_off_gas_gap ->push_back(off_gas_gap); + // The offline IdHelper class will be updated to assign wiregroup ID to SimHit. + // As a temporary solution stripnumber is used directly (also in sTGC) + off_channel = stripNumber; m_NSWMM_off_channel ->push_back(off_channel); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx index dfc437719da2..ebbfbd38a692 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx @@ -27,7 +27,8 @@ #include "MuonIdHelpers/sTgcIdHelper.h" #include "MuonIdHelpers/CscIdHelper.h" -#include "xAODEventInfo/EventInfo.h" +#include "EventInfo/EventInfo.h" +#include "EventInfo/EventID.h" NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator), @@ -180,14 +181,15 @@ StatusCode NSWPRDValAlg::execute() ATH_MSG_INFO("execute()"); // Event information - const xAOD::EventInfo *pevt = nullptr; - if( ! ( evtStore()->retrieve(pevt).isSuccess() ) ) { - ATH_MSG_WARNING("Could not retrieve event info!"); - m_runNumber = -999999; - m_eventNumber = -999999; + const EventInfo* pevt(0); + if( evtStore()->retrieve(pevt).isSuccess() ) { + m_runNumber = pevt->event_ID()->run_number(); + m_eventNumber = pevt->event_ID()->event_number(); + ATH_MSG_DEBUG("Now processing event number:" << m_eventNumber << ", run number:" << m_runNumber); } else { - m_runNumber = pevt->runNumber(); - m_eventNumber = pevt->eventNumber(); + ATH_MSG_WARNING("Could not retrieve event info!"); + m_runNumber = -1; + m_eventNumber = -1; } if (m_doTruth) ATH_CHECK( m_TruthVar->fillVariables() ); @@ -196,7 +198,7 @@ StatusCode NSWPRDValAlg::execute() if (m_doSTGCHit) ATH_CHECK( m_sTgcSimHitVar->fillVariables() ); - if (m_doSTGCFastDigit) ATH_CHECK( m_sTgcDigitVar->fillVariables() ); + if (m_doSTGCFastDigit) ATH_CHECK( m_sTgcFastDigitVar->fillVariables() ); if (m_doSTGCDigit) ATH_CHECK( m_sTgcDigitVar->fillVariables() ); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx index e9c951173728..5e8334364bc1 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "sTGCDigitVariables.h" @@ -30,7 +30,7 @@ StatusCode sTGCDigitVariables::fillVariables() // get truth information container of digitization const MuonSimDataCollection* nsw_sTgcSdoContainer = nullptr; - // CHECK( m_evtStore->retrieve(nsw_sTgcSdoContainer, "sTGC_SDO") ); + CHECK( m_evtStore->retrieve(nsw_sTgcSdoContainer, "sTGC_SDO") ); const sTgcDigitContainer* nsw_sTgcDigitContainer = nullptr; CHECK( m_evtStore->retrieve(nsw_sTgcDigitContainer, "sTGC_DIGITS") ); @@ -300,36 +300,37 @@ StatusCode sTGCDigitVariables::initializeVariables() m_NSWsTGC_dig_truth_XZ_angle = new std::vector<float>(); if(m_tree) { - m_tree->Branch("Digit_sTGC", &m_NSWsTGC_nDigits, "Digits_sTGC_n/i"); - m_tree->Branch("Digit_sTGC_Pad_Digits", &m_NSWsTGC_nPadDigits, "Digit_sTGC_Pad_Digits_n/i"); - m_tree->Branch("Digit_sTGC_time", "std::vector< double >", &m_NSWsTGC_dig_time); - m_tree->Branch("Digit_sTGC_bctag", "std::vector< int >", &m_NSWsTGC_dig_bctag); - m_tree->Branch("Digit_sTGC_charge", "std::vector< double >", &m_NSWsTGC_dig_charge); - m_tree->Branch("Digit_sTGC_isDead", "std::vector< bool >", &m_NSWsTGC_dig_isDead); - m_tree->Branch("Digit_sTGC_isPileup", "std::vector< bool >", &m_NSWsTGC_dig_isPileup); - m_tree->Branch("Digit_sTGC_stationName", &m_NSWsTGC_dig_stationName); - m_tree->Branch("Digit_sTGC_stationEta", &m_NSWsTGC_dig_stationEta); - m_tree->Branch("Digit_sTGC_stationPhi", &m_NSWsTGC_dig_stationPhi); - m_tree->Branch("Digit_sTGC_multiplet", &m_NSWsTGC_dig_multiplet); - m_tree->Branch("Digit_sTGC_gas_gap", &m_NSWsTGC_dig_gas_gap); - m_tree->Branch("Digit_sTGC_channel_type",&m_NSWsTGC_dig_channel_type); - m_tree->Branch("Digit_sTGC_channel", &m_NSWsTGC_dig_channel); - m_tree->Branch("Digit_sTGC_stationEtaMin", &m_NSWsTGC_dig_stationEtaMin); - m_tree->Branch("Digit_sTGC_stationEtaMax", &m_NSWsTGC_dig_stationEtaMax); - m_tree->Branch("Digit_sTGC_stationPhiMin", &m_NSWsTGC_dig_stationPhiMin); - m_tree->Branch("Digit_sTGC_stationPhiMax", &m_NSWsTGC_dig_stationPhiMax); - m_tree->Branch("Digit_sTGC_gas_gapMin", &m_NSWsTGC_dig_gas_gapMin); - m_tree->Branch("Digit_sTGC_gas_gapMax", &m_NSWsTGC_dig_gas_gapMax); - m_tree->Branch("Digit_sTGC_padEta", &m_NSWsTGC_dig_padEta); - m_tree->Branch("Digit_sTGC_padPhi", &m_NSWsTGC_dig_padPhi); - m_tree->Branch("Digit_sTGC_numberOfMultilayers", &m_NSWsTGC_dig_numberOfMultilayers); - m_tree->Branch("Digit_sTGC_multilayerMin", &m_NSWsTGC_dig_multilayerMin); - m_tree->Branch("Digit_sTGC_multilayerMax", &m_NSWsTGC_dig_multilayerMax); - m_tree->Branch("Digit_sTGC_channelTypeMin", &m_NSWsTGC_dig_channelTypeMin); - m_tree->Branch("Digit_sTGC_channelTypeMax", &m_NSWsTGC_dig_channelTypeMax); - m_tree->Branch("Digit_sTGC_channelMin", &m_NSWsTGC_dig_channelMin); - m_tree->Branch("Digit_sTGC_channelMax", &m_NSWsTGC_dig_channelMax); - m_tree->Branch("Digit_sTGC_channelNumber", &m_NSWsTGC_dig_channelNumber); + ATH_MSG_DEBUG("sTGC digit: init m_tree "); + m_tree->Branch("Digits_sTGC", &m_NSWsTGC_nDigits, "Digits_sTGC_n/i"); + m_tree->Branch("Digits_sTGC_Pad_Digits", &m_NSWsTGC_nPadDigits, "Digits_sTGC_Pad_Digits_n/i"); + m_tree->Branch("Digits_sTGC_time", "std::vector< double >", &m_NSWsTGC_dig_time); + m_tree->Branch("Digits_sTGC_bctag", "std::vector< int >", &m_NSWsTGC_dig_bctag); + m_tree->Branch("Digits_sTGC_charge", "std::vector< double >", &m_NSWsTGC_dig_charge); + m_tree->Branch("Digits_sTGC_isDead", "std::vector< bool >", &m_NSWsTGC_dig_isDead); + m_tree->Branch("Digits_sTGC_isPileup", "std::vector< bool >", &m_NSWsTGC_dig_isPileup); + m_tree->Branch("Digits_sTGC_stationName", &m_NSWsTGC_dig_stationName); + m_tree->Branch("Digits_sTGC_stationEta", &m_NSWsTGC_dig_stationEta); + m_tree->Branch("Digits_sTGC_stationPhi", &m_NSWsTGC_dig_stationPhi); + m_tree->Branch("Digits_sTGC_multiplet", &m_NSWsTGC_dig_multiplet); + m_tree->Branch("Digits_sTGC_gas_gap", &m_NSWsTGC_dig_gas_gap); + m_tree->Branch("Digits_sTGC_channel_type",&m_NSWsTGC_dig_channel_type); + m_tree->Branch("Digits_sTGC_channel", &m_NSWsTGC_dig_channel); + m_tree->Branch("Digits_sTGC_stationEtaMin", &m_NSWsTGC_dig_stationEtaMin); + m_tree->Branch("Digits_sTGC_stationEtaMax", &m_NSWsTGC_dig_stationEtaMax); + m_tree->Branch("Digits_sTGC_stationPhiMin", &m_NSWsTGC_dig_stationPhiMin); + m_tree->Branch("Digits_sTGC_stationPhiMax", &m_NSWsTGC_dig_stationPhiMax); + m_tree->Branch("Digits_sTGC_gas_gapMin", &m_NSWsTGC_dig_gas_gapMin); + m_tree->Branch("Digits_sTGC_gas_gapMax", &m_NSWsTGC_dig_gas_gapMax); + m_tree->Branch("Digits_sTGC_padEta", &m_NSWsTGC_dig_padEta); + m_tree->Branch("Digits_sTGC_padPhi", &m_NSWsTGC_dig_padPhi); + m_tree->Branch("Digits_sTGC_numberOfMultilayers", &m_NSWsTGC_dig_numberOfMultilayers); + m_tree->Branch("Digits_sTGC_multilayerMin", &m_NSWsTGC_dig_multilayerMin); + m_tree->Branch("Digits_sTGC_multilayerMax", &m_NSWsTGC_dig_multilayerMax); + m_tree->Branch("Digits_sTGC_channelTypeMin", &m_NSWsTGC_dig_channelTypeMin); + m_tree->Branch("Digits_sTGC_channelTypeMax", &m_NSWsTGC_dig_channelTypeMax); + m_tree->Branch("Digits_sTGC_channelMin", &m_NSWsTGC_dig_channelMin); + m_tree->Branch("Digits_sTGC_channelMax", &m_NSWsTGC_dig_channelMax); + m_tree->Branch("Digits_sTGC_channelNumber", &m_NSWsTGC_dig_channelNumber); m_tree->Branch("Digits_sTGC_channelPosX", "std::vector< double >", &m_NSWsTGC_dig_channelPosX); m_tree->Branch("Digits_sTGC_channelPosY", "std::vector< double >", &m_NSWsTGC_dig_channelPosY); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCFastDigitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCFastDigitVariables.cxx index f06d872f53ac..cb7cc4e6ac70 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCFastDigitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCFastDigitVariables.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "sTGCFastDigitVariables.h" @@ -16,7 +16,7 @@ StatusCode sTGCFastDigitVariables::fillVariables() CHECK( this->clearVariables() ); const MuonSimDataCollection* nsw_sTgcSdoContainer = nullptr; - CHECK( m_evtStore->retrieve(nsw_sTgcSdoContainer, "STGC_SDO") ); + CHECK( m_evtStore->retrieve(nsw_sTgcSdoContainer, "sTGCfast_SDO") ); const Muon::sTgcPrepDataContainer *nsw_sTgcPrepDataContainer = nullptr; CHECK( m_evtStore->retrieve(nsw_sTgcPrepDataContainer, m_ContainerName.c_str()) ); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx index d70687821ef5..4b24bd781c8b 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "sTGCSimHitVariables.h" @@ -142,117 +142,119 @@ StatusCode sTGCSimHitVariables::fillVariables() ATH_MSG_DEBUG("sTGC geometry, retrieving detector element for: isSmall " << isSmall << " eta " << m_sTgcIdHelper->stationEta(offId) << " phi " << m_sTgcIdHelper->stationPhi(offId) << " ml " << m_sTgcIdHelper->multilayer(offId) ); - int phiCor = m_sTgcIdHelper->stationPhi(offId); - - if( sim_stationPhi == 15 && hit.globalPosition().phi() > -0.4 ) phiCor = 1; - - int mlCor = m_sTgcIdHelper->multilayer(offId); - - if( !isSmall ){ - if( mlCor == 1 ) mlCor = 2; - else mlCor = 1; - } - - const MuonGM::sTgcReadoutElement* detEl = m_detManager->getsTgcRElement_fromIdFields(isSmall,m_sTgcIdHelper->stationEta(offId),phiCor,mlCor ); + const MuonGM::sTgcReadoutElement* detEl = m_detManager->getsTgcReadoutElement(offId); if( !detEl ){ ATH_MSG_WARNING("sTGC geometry, failed to retrieve detector element for: isSmall " << isSmall << " eta " << m_sTgcIdHelper->stationEta(offId) << " phi " << m_sTgcIdHelper->stationPhi(offId) << " ml " << m_sTgcIdHelper->multilayer(offId) ); continue; } - // compute hit position within the detector element/surfaces - const Trk::PlaneSurface& surf = detEl->surface(offId); - Amg::Transform3D gToL = detEl->absTransform().inverse(); - Amg::Vector3D hpos(hit.globalPosition().x(),hit.globalPosition().y(),hit.globalPosition().z()); - Amg::Vector3D dSurface_pos = gToL*hpos; - - // compute the hit position on the readout plane (same as in MuonFastDigitization) - Amg::Vector3D rSurface_pos = surf.transform().inverse()*hpos; - Amg::Vector3D ldir = surf.transform().inverse().linear()*Amg::Vector3D(hit.globalDirection().x(),hit.globalDirection().y(),hit.globalDirection().z()); - - double scale = -rSurface_pos.z()/ldir.z(); - Amg::Vector3D hitOnSurface = rSurface_pos + scale*ldir; - - // hitOnSurface.x() will be susequent smeared to simulate the detector resolution, here we do not apply any smearing - Amg::Vector2D posOnSurf(hitOnSurface.x(), rSurface_pos.y()); - - int stripNumber = detEl->stripNumber(posOnSurf,offId); - if( stripNumber == -1 ){ - ATH_MSG_WARNING("sTGC validation: failed to obtain strip number " << m_sTgcIdHelper->print_to_string(offId) ); - ATH_MSG_WARNING(" pos " << posOnSurf << " z " << rSurface_pos.z() ); - stripNumber = 1; - } - Identifier oldId = offId; - offId = m_sTgcIdHelper->channelID(offId, m_sTgcIdHelper->multilayer(offId), m_sTgcIdHelper->gasGap(offId),1,stripNumber); - if( m_sTgcIdHelper->gasGap(offId) != sim_layer ) { - ATH_MSG_WARNING("sTGC validation: sTgc id has bad layer field(2)! " << std::endl << " " << m_sTgcIdHelper->print_to_string(offId) << std::endl - << " " << m_sTgcIdHelper->print_to_string(oldId) << " stripN " << stripNumber ); + // SimHits do not have channel type (1 is assigned as dummy value). + // Compute channel type in Val Alg to be able to validate + for( int type=0;type<=2;++type ){ + if( type == 2 && abs(m_sTgcIdHelper->stationEta(offId)) < 3 ) continue; + Identifier newId = m_sTgcIdHelper->channelID(m_sTgcIdHelper->parentID(offId), m_sTgcIdHelper->multilayer(offId), m_sTgcIdHelper->gasGap(offId),type,1,0); + + // compute hit position within the detector element/surfaces + const Trk::PlaneSurface& surf = detEl->surface(newId); + Amg::Transform3D gToL = detEl->absTransform().inverse(); + Amg::Vector3D hpos(hit.globalPosition().x(),hit.globalPosition().y(),hit.globalPosition().z()); + Amg::Vector3D dSurface_pos = gToL*hpos; + + // compute the hit position on the readout plane (same as in MuonFastDigitization) + Amg::Vector3D rSurface_pos = surf.transform().inverse()*hpos; + Amg::Vector3D ldir = surf.transform().inverse().linear()*Amg::Vector3D(hit.globalDirection().x(),hit.globalDirection().y(),hit.globalDirection().z()); + + ATH_MSG_DEBUG("sTGC channel type:" << type); + + double scale = -rSurface_pos.z()/ldir.z(); + Amg::Vector3D hitOnSurface = rSurface_pos + scale*ldir; + + // hitOnSurface.x() will be susequent smeared to simulate the detector resolution, here we do not apply any smearing + Amg::Vector2D posOnSurf(hitOnSurface.x(), rSurface_pos.y()); + + int stripNumber = detEl->stripNumber(posOnSurf,newId); + if( stripNumber == -1 ){ + ATH_MSG_WARNING("sTGC validation: failed to obtain strip number " << m_sTgcIdHelper->print_to_string(offId) ); + ATH_MSG_WARNING(" pos " << posOnSurf << " z " << rSurface_pos.z() ); + //stripNumber = 1; + } + Identifier oldId = offId; + offId = m_sTgcIdHelper->channelID(offId, m_sTgcIdHelper->multilayer(offId), m_sTgcIdHelper->gasGap(offId),1,stripNumber); + if( m_sTgcIdHelper->gasGap(offId) != sim_layer ) { + ATH_MSG_WARNING("sTGC validation: sTgc id has bad layer field(2)! " << std::endl << " " << m_sTgcIdHelper->print_to_string(offId) << std::endl + << " " << m_sTgcIdHelper->print_to_string(oldId) << " stripN " << stripNumber ); + } + + Amg::Vector2D fastDigitPos(0,0); + if( !detEl->stripPosition(offId,fastDigitPos) ){ + ATH_MSG_WARNING("sTGC validation: failed to obtain local position for identifier " << m_sTgcIdHelper->print_to_string(offId) ); + continue; + } + + Amg::Vector3D detpos = detEl->globalPosition(); + ATH_MSG_DEBUG("sTGC Global hit: r " << hit.globalPosition().perp() << ", phi " << hit.globalPosition().phi() << ", z " << hit.globalPosition().z() + << "; detEl: r " << detpos.perp() << ", phi " << detpos.phi() << ", z " << detpos.z() + << "; surf z " << surf.center().z() << ", ml " << sim_multilayer << ", l " << sim_layer ); + + ATH_MSG_DEBUG("sTGC Local hit : x " << hit.localPosition().x() << " y " << hit.localPosition().y() << " z " << hit.localPosition().z() + << " detEl: x " << dSurface_pos.x() << " y " << dSurface_pos.y() << " z " << dSurface_pos.z()); + ATH_MSG_DEBUG("sTGC Fast digit: x " << fastDigitPos.x() << " y " << fastDigitPos.y() + << ", gToL: x " << rSurface_pos.x() << " y " << rSurface_pos.y() << " z " << rSurface_pos.z() ); + + + + // Fill Ntuple with offline ID data + m_NSWsTGC_off_stationName ->push_back(stName); + m_NSWsTGC_off_stationEta ->push_back(off_stationEta); + m_NSWsTGC_off_stationPhi ->push_back(off_stationPhi); + m_NSWsTGC_off_multiplet ->push_back(off_multiplet); + m_NSWsTGC_off_gas_gap ->push_back(off_gas_gap); + m_NSWsTGC_off_channel_type ->push_back(type); + // The offline IdHelper class will be updated to assign wiregroup ID to SimHit. + // As a temporary solution stripnumber is used directly (also in MM) + off_channel = stripNumber; + m_NSWsTGC_off_channel ->push_back(off_channel); + + + // Fill ntuple with the hit/surface/digit positions + m_NSWsTGC_detector_globalPositionX->push_back( detpos.x() ); + m_NSWsTGC_detector_globalPositionY->push_back( detpos.y() ); + m_NSWsTGC_detector_globalPositionZ->push_back( detpos.z() ); + m_NSWsTGC_detector_globalPositionR->push_back( detpos.perp() ); + m_NSWsTGC_detector_globalPositionP->push_back( detpos.phi() ); + + m_NSWsTGC_hitToDsurfacePositionX->push_back( dSurface_pos.x() ); + m_NSWsTGC_hitToDsurfacePositionY->push_back( dSurface_pos.y() ); + m_NSWsTGC_hitToDsurfacePositionZ->push_back( dSurface_pos.z() ); + + m_NSWsTGC_hitToRsurfacePositionX->push_back( rSurface_pos.x() ); + m_NSWsTGC_hitToRsurfacePositionY->push_back( rSurface_pos.y() ); + m_NSWsTGC_hitToRsurfacePositionZ->push_back( rSurface_pos.z() ); + + m_NSWsTGC_FastDigitRsurfacePositionX->push_back( posOnSurf.x() ); + m_NSWsTGC_FastDigitRsurfacePositionY->push_back( posOnSurf.y() ); + + + + m_NSWsTGC_stripNumber->push_back(stripNumber); + m_NSWsTGC_wireNumber->push_back(-999); + + ATH_MSG_DEBUG("---------- Hit processing ends!"); + /* + ATH_MSG_DEBUG( " NSW Hits E = " << hit.depositEnergy() + << ", Global X sTGC = " << globalPosition.x() + << ", Global Y sTGC = " << globalPosition.y() + << ", Global Z sTGC = " << globalPosition.z() + << ", Local X sTGC = " << localPosition.x() + << ", Local Y sTGC = " << localPosition.y() + << ", Local Z sTGC = " << localPosition.z() + << ", time = " << hit.globalTime() + << ", step length = " << hit.StepLength() ); + */ + m_NSWsTGC_nSimHits++; } - - Amg::Vector2D fastDigitPos(0,0); - if( !detEl->stripPosition(offId,fastDigitPos) ){ - ATH_MSG_WARNING("sTGC validation: failed to obtain local position for identifier " << m_sTgcIdHelper->print_to_string(offId) ); - continue; - } - - Amg::Vector3D detpos = detEl->globalPosition(); - ATH_MSG_DEBUG("sTGC Global hit: r " << hit.globalPosition().perp() << ", phi " << hit.globalPosition().phi() << ", z " << hit.globalPosition().z() - << "; detEl: r " << detpos.perp() << ", phi " << detpos.phi() << ", z " << detpos.z() - << "; surf z " << surf.center().z() << ", ml " << sim_multilayer << ", l " << sim_layer ); - - ATH_MSG_DEBUG("sTGC Local hit : x " << hit.localPosition().x() << " y " << hit.localPosition().y() << " z " << hit.localPosition().z() - << " detEl: x " << dSurface_pos.x() << " y " << dSurface_pos.y() << " z " << dSurface_pos.z()); - ATH_MSG_DEBUG("sTGC Fast digit: x " << fastDigitPos.x() << " y " << fastDigitPos.y() - << ", gToL: x " << rSurface_pos.x() << " y " << rSurface_pos.y() << " z " << rSurface_pos.z() ); - - - - // Fill Ntuple with offline ID data - m_NSWsTGC_off_stationName ->push_back(stName); - m_NSWsTGC_off_stationEta ->push_back(off_stationEta); - m_NSWsTGC_off_stationPhi ->push_back(off_stationPhi); - m_NSWsTGC_off_multiplet ->push_back(off_multiplet); - m_NSWsTGC_off_gas_gap ->push_back(off_gas_gap); - m_NSWsTGC_off_channel_type ->push_back(off_channel_type); - m_NSWsTGC_off_channel ->push_back(off_channel); - - // Fill ntuple with the hit/surface/digit positions - m_NSWsTGC_detector_globalPositionX->push_back( detpos.x() ); - m_NSWsTGC_detector_globalPositionY->push_back( detpos.y() ); - m_NSWsTGC_detector_globalPositionZ->push_back( detpos.z() ); - m_NSWsTGC_detector_globalPositionR->push_back( detpos.perp() ); - m_NSWsTGC_detector_globalPositionP->push_back( detpos.phi() ); - - m_NSWsTGC_hitToDsurfacePositionX->push_back( dSurface_pos.x() ); - m_NSWsTGC_hitToDsurfacePositionY->push_back( dSurface_pos.y() ); - m_NSWsTGC_hitToDsurfacePositionZ->push_back( dSurface_pos.z() ); - - m_NSWsTGC_hitToRsurfacePositionX->push_back( rSurface_pos.x() ); - m_NSWsTGC_hitToRsurfacePositionY->push_back( rSurface_pos.y() ); - m_NSWsTGC_hitToRsurfacePositionZ->push_back( rSurface_pos.z() ); - - m_NSWsTGC_FastDigitRsurfacePositionX->push_back( posOnSurf.x() ); - m_NSWsTGC_FastDigitRsurfacePositionY->push_back( posOnSurf.y() ); - - - - m_NSWsTGC_stripNumber->push_back(stripNumber); - m_NSWsTGC_wireNumber->push_back(-999); - - ATH_MSG_DEBUG("---------- Hit processing ends!"); -/* - ATH_MSG_DEBUG( " NSW Hits E = " << hit.depositEnergy() - << ", Global X sTGC = " << globalPosition.x() - << ", Global Y sTGC = " << globalPosition.y() - << ", Global Z sTGC = " << globalPosition.z() - << ", Local X sTGC = " << localPosition.x() - << ", Local Y sTGC = " << localPosition.y() - << ", Local Z sTGC = " << localPosition.z() - << ", time = " << hit.globalTime() - << ", step length = " << hit.StepLength() ); -*/ - m_NSWsTGC_nSimHits++; - } + } ATH_MSG_INFO("processed " << m_NSWsTGC_nSimHits << " sTGC sim hits"); return StatusCode::SUCCESS; -- GitLab