diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7fbb6f2c0b8c29b0fb720a49a96c14a197d65306 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.cxx @@ -0,0 +1,181 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MMPRDVariables.h" +#include "AthenaKernel/errorcheck.h" + +#include "MuonPrepRawData/MMPrepDataContainer.h" +#include "MuonPrepRawData/MMPrepData.h" + +#include "MuonReadoutGeometry/MMReadoutElement.h" +#include "MuonSimData/MuonSimDataCollection.h" + +#include "TTree.h" + + +StatusCode MMPRDVariables::fillVariables() +{ + ATH_MSG_DEBUG(" do fillNSWMMPRDVariables()"); + + CHECK( this->clearVariables() ); + + const Muon::MMPrepDataContainer *nsw_MMPrepDataContainer = nullptr; + CHECK( m_evtStore->retrieve(nsw_MMPrepDataContainer, m_ContainerName.c_str()) ); + + if(nsw_MMPrepDataContainer->size()==0) ATH_MSG_WARNING(" MM PRD Container empty "); + + for(const Muon::MMPrepDataCollection* coll : *nsw_MMPrepDataContainer) { + + for (unsigned int item=0; item<coll->size(); item++) { + const Muon::MMPrepData* prd = coll->at(item); + Identifier Id = prd->identify(); + + std::string stName = m_MmIdHelper->stationNameString(m_MmIdHelper->stationName(Id)); + int stationEta = m_MmIdHelper->stationEta(Id); + int stationPhi = m_MmIdHelper->stationPhi(Id); + int multiplet = m_MmIdHelper->multilayer(Id); + int gas_gap = m_MmIdHelper->gasGap(Id); + int channel = m_MmIdHelper->channel(Id); + + + ATH_MSG_DEBUG( "MicroMegas PRD Offline id: Station Name [" << stName << " ]" + << " Station Eta [" << stationEta << "]" + << " Station Phi [" << stationPhi << "]" + << " Multiplet [" << multiplet << "]" + << " GasGap [" << gas_gap << "]" + << " ChNr [" << channel << "]" ); + + m_NSWMM_prd_stationName->push_back(stName); + m_NSWMM_prd_stationEta->push_back(stationEta); + m_NSWMM_prd_stationPhi->push_back(stationPhi); + m_NSWMM_prd_multiplet->push_back(multiplet); + m_NSWMM_prd_gas_gap->push_back(gas_gap); + m_NSWMM_prd_channel->push_back(channel); + + const MuonGM::MMReadoutElement* det = prd->detectorElement(); + Amg::Vector3D pos = prd->globalPosition(); + const Amg::MatrixX & cov = prd->localCovariance(); + Amg::Vector2D loc_pos(0., 0.); + det->surface(Id).globalToLocal(pos, Amg::Vector3D(0., 0., 0.), loc_pos); + + ATH_MSG_DEBUG( "MicroMegas PRD local pos.: x=" << std::setw(6) << std::setprecision(2) << loc_pos[0] + << ", ex=" << std::setw(6) << std::setprecision(2) << cov(0,0) + << ", y=" << std::setw(6) << std::setprecision(2) << loc_pos[1] ); + + m_NSWMM_prd_globalPosX->push_back(pos.x()); + m_NSWMM_prd_globalPosY->push_back(pos.y()); + m_NSWMM_prd_globalPosZ->push_back(pos.z()); + + m_NSWMM_prd_localPosX->push_back(loc_pos[0]); + m_NSWMM_prd_localPosY->push_back(loc_pos[1]); + m_NSWMM_prd_covMatrix_1_1->push_back(cov(0,0)); + + m_NSWMM_nPRDs++; + } + } + + ATH_MSG_DEBUG("processed " << m_NSWMM_nPRDs << " MicroMegas PRD's"); + return StatusCode::SUCCESS; +} + +void MMPRDVariables::deleteVariables() +{ + delete m_NSWMM_prd_stationName; + delete m_NSWMM_prd_stationEta; + delete m_NSWMM_prd_stationPhi; + delete m_NSWMM_prd_multiplet; + delete m_NSWMM_prd_gas_gap; + delete m_NSWMM_prd_channel; + + delete m_NSWMM_prd_globalPosX; + delete m_NSWMM_prd_globalPosY; + delete m_NSWMM_prd_globalPosZ; + + delete m_NSWMM_prd_localPosX; + delete m_NSWMM_prd_localPosY; + delete m_NSWMM_prd_covMatrix_1_1; + + + m_NSWMM_nPRDs = 0; + m_NSWMM_prd_stationName= nullptr; + m_NSWMM_prd_stationEta = nullptr; + m_NSWMM_prd_stationPhi = nullptr; + m_NSWMM_prd_multiplet = nullptr; + m_NSWMM_prd_gas_gap = nullptr; + m_NSWMM_prd_channel = nullptr; + + m_NSWMM_prd_globalPosX = nullptr; + m_NSWMM_prd_globalPosY = nullptr; + m_NSWMM_prd_globalPosZ = nullptr; + + m_NSWMM_prd_localPosX = nullptr; + m_NSWMM_prd_localPosY = nullptr; + m_NSWMM_prd_covMatrix_1_1 = nullptr; + + return; +} + + +StatusCode MMPRDVariables::clearVariables() +{ + m_NSWMM_nPRDs = 0; + m_NSWMM_prd_stationName->clear(); + m_NSWMM_prd_stationEta->clear(); + m_NSWMM_prd_stationPhi->clear(); + m_NSWMM_prd_multiplet->clear(); + m_NSWMM_prd_gas_gap->clear(); + m_NSWMM_prd_channel->clear(); + + m_NSWMM_prd_globalPosX->clear(); + m_NSWMM_prd_globalPosY->clear(); + m_NSWMM_prd_globalPosZ->clear(); + + m_NSWMM_prd_localPosX->clear(); + m_NSWMM_prd_localPosY->clear(); + m_NSWMM_prd_covMatrix_1_1->clear(); + + return StatusCode::SUCCESS; +} + + +StatusCode MMPRDVariables::initializeVariables() +{ + m_NSWMM_nPRDs = 0; + m_NSWMM_prd_stationName = new std::vector<std::string>(); + m_NSWMM_prd_stationEta = new std::vector<int>(); + m_NSWMM_prd_stationPhi = new std::vector<int>(); + m_NSWMM_prd_multiplet = new std::vector<int>(); + m_NSWMM_prd_gas_gap = new std::vector<int>(); + m_NSWMM_prd_channel = new std::vector<int>(); + + m_NSWMM_prd_globalPosX = new std::vector<double>(); + m_NSWMM_prd_globalPosY = new std::vector<double>(); + m_NSWMM_prd_globalPosZ = new std::vector<double>(); + + m_NSWMM_prd_localPosX = new std::vector<double>(); + m_NSWMM_prd_localPosY = new std::vector<double>(); + m_NSWMM_prd_covMatrix_1_1 = new std::vector<double>(); + + if(m_tree) { + m_tree->Branch("PRD_MM", &m_NSWMM_nPRDs, "PRDs_MM_n/i"); + m_tree->Branch("PRD_MM_stationName", &m_NSWMM_prd_stationName); + m_tree->Branch("PRD_MM_stationEta", &m_NSWMM_prd_stationEta); + m_tree->Branch("PRD_MM_stationPhi", &m_NSWMM_prd_stationPhi); + m_tree->Branch("PRD_MM_multiplet", &m_NSWMM_prd_multiplet); + m_tree->Branch("PRD_MM_gas_gap", &m_NSWMM_prd_gas_gap); + m_tree->Branch("PRD_MM_channel", &m_NSWMM_prd_channel); + + m_tree->Branch("PRD_MM_globalPosX", &m_NSWMM_prd_globalPosX); + m_tree->Branch("PRD_MM_globalPosY", &m_NSWMM_prd_globalPosY); + m_tree->Branch("PRD_MM_globalPosZ", &m_NSWMM_prd_globalPosZ); + + m_tree->Branch("PRD_MM_localPosX", &m_NSWMM_prd_localPosX); + m_tree->Branch("PRD_MM_localPosY", &m_NSWMM_prd_localPosY); + m_tree->Branch("PRD_MM_covMatrix_1_1", &m_NSWMM_prd_covMatrix_1_1); + + } + + return StatusCode::SUCCESS; +} + diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.h new file mode 100644 index 0000000000000000000000000000000000000000..4c4fbdc5bbdf524a5416117821b40024f6d28de9 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMPRDVariables.h @@ -0,0 +1,81 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef MMPRDVARIABLES_H +#define MMPRDVARIABLES_H + +#include "ValAlgVariables.h" +#include "MuonIdHelpers/MmIdHelper.h" +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include <vector> + +class MMPRDVariables : public ValAlgVariables +{ + public: + MMPRDVariables(StoreGateSvc* evtStore, + const MuonGM::MuonDetectorManager* detManager, + const MuonIdHelper* idhelper, + TTree* tree, + std::string containername) : + ValAlgVariables(evtStore, detManager, tree, containername, "MMPRDVariables"), + m_MmIdHelper(0), + m_NSWMM_nPRDs(0), + m_NSWMM_prd_stationName(0), + m_NSWMM_prd_stationEta(0), + m_NSWMM_prd_stationPhi(0), + m_NSWMM_prd_multiplet(0), + m_NSWMM_prd_gas_gap(0), + m_NSWMM_prd_channel(0), + m_NSWMM_prd_globalPosX(0), + m_NSWMM_prd_globalPosY(0), + m_NSWMM_prd_globalPosZ(0), + m_NSWMM_prd_localPosX(0), + m_NSWMM_prd_localPosY(0), + m_NSWMM_prd_covMatrix_1_1(0) + { + setHelper(idhelper); + } + + ~MMPRDVariables() + { + deleteVariables(); + } + + StatusCode initializeVariables(); + StatusCode fillVariables(); + + private: + + void setHelper(const MuonIdHelper* idhelper){ + m_MmIdHelper = dynamic_cast<const MmIdHelper*>(idhelper); + if(m_MmIdHelper == 0) { + ATH_MSG_ERROR("casting IdHelper to MmIdhelper failed"); + throw; + } + } + + void deleteVariables(); + StatusCode clearVariables(); + + const MmIdHelper* m_MmIdHelper; + + int m_NSWMM_nPRDs; + std::vector<std::string> *m_NSWMM_prd_stationName; + std::vector<int> *m_NSWMM_prd_stationEta; + std::vector<int> *m_NSWMM_prd_stationPhi; + std::vector<int> *m_NSWMM_prd_multiplet; + std::vector<int> *m_NSWMM_prd_gas_gap; + std::vector<int> *m_NSWMM_prd_channel; + + std::vector<double> *m_NSWMM_prd_globalPosX; + std::vector<double> *m_NSWMM_prd_globalPosY; + std::vector<double> *m_NSWMM_prd_globalPosZ; + + std::vector<double> *m_NSWMM_prd_localPosX; + std::vector<double> *m_NSWMM_prd_localPosY; + std::vector<double> *m_NSWMM_prd_covMatrix_1_1; + +}; + +#endif // MMPRDVARIABLE_H diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMRDOVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMRDOVariables.cxx index e96053f31a507a7af5b8b591c1186a07eeca7693..2b965366b218a79f8766227f0cdadf75bb9910a7 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMRDOVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMRDOVariables.cxx @@ -68,8 +68,8 @@ StatusCode MMRDOVariables::fillVariables() m_NSWMM_rdo_charge->push_back(rdo->charge()); // get the readout element class where the RDO is recorded - int isSmall = (stName[2] == 'S'); - const MuonGM::MMReadoutElement* rdoEl = m_detManager->getMMRElement_fromIdFields(isSmall, stationEta, stationPhi, multiplet ); + // int isSmall = (stName[2] == 'S'); + // const MuonGM::MMReadoutElement* rdoEl = m_detManager->getMMRElement_fromIdFields(isSmall, stationEta, stationPhi, multiplet ); // rdo counter for the ntuple @@ -96,6 +96,8 @@ StatusCode MMRDOVariables::clearVariables() m_NSWMM_rdo_multiplet->clear(); m_NSWMM_rdo_gas_gap->clear(); m_NSWMM_rdo_channel->clear(); + m_NSWMM_rdo_time->clear(); + m_NSWMM_rdo_charge->clear(); return StatusCode::SUCCESS; } @@ -118,13 +120,15 @@ StatusCode MMRDOVariables::initializeVariables() if(m_tree) { - m_tree->Branch("nrdo_MM", &m_NSWMM_nrdo); + m_tree->Branch("RDO_MM_n", &m_NSWMM_nrdo); m_tree->Branch("RDO_MM_stationName", &m_NSWMM_rdo_stationName); m_tree->Branch("RDO_MM_stationEta", &m_NSWMM_rdo_stationEta); m_tree->Branch("RDO_MM_stationPhi", &m_NSWMM_rdo_stationPhi); m_tree->Branch("RDO_MM_multiplet", &m_NSWMM_rdo_multiplet); m_tree->Branch("RDO_MM_gas_gap", &m_NSWMM_rdo_gas_gap); m_tree->Branch("RDO_MM_channel", &m_NSWMM_rdo_channel); + m_tree->Branch("RDO_MM_time", &m_NSWMM_rdo_time); + m_tree->Branch("RDO_MM_charge", &m_NSWMM_rdo_charge); } return StatusCode::SUCCESS; @@ -141,6 +145,8 @@ void MMRDOVariables::deleteVariables() delete m_NSWMM_rdo_multiplet; delete m_NSWMM_rdo_gas_gap; delete m_NSWMM_rdo_channel; + delete m_NSWMM_rdo_time; + delete m_NSWMM_rdo_charge; m_NSWMM_nrdo = 0; @@ -150,6 +156,8 @@ void MMRDOVariables::deleteVariables() m_NSWMM_rdo_multiplet = nullptr; m_NSWMM_rdo_gas_gap = nullptr; m_NSWMM_rdo_channel = nullptr; + m_NSWMM_rdo_time = nullptr; + m_NSWMM_rdo_charge = nullptr; return; } diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx index 9d4875d339f362439e345d5a4d55f686d936fd82..d6180277b17e2fabaa3021ac202864d7fafa4fe9 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.cxx @@ -34,17 +34,10 @@ StatusCode MMSimHitVariables::fillVariables() const GenericMuonSimHit hit = it; if(hit.depositEnergy()==0.) continue; // SimHits without energy loss are not recorded. - // if( hit.kineticEnergy()<m_energyThreshold && abs(hit.particleEncoding())==11) continue ; // connect the hit with the MC truth -// int barcode = hit.particleLink().barcode(); -// m_NSWMM_trackId->push_back(barcode); -// for (unsigned int tr=0;tr<m_Truth_particleBarcode->size();tr++) { -// if (barcode==m_Truth_particleBarcode->at(tr)) { -// m_NSWMM_truthEl->push_back(tr); -// } -// } - + int barcode = hit.particleLink().barcode(); + m_NSWMM_trackId->push_back(barcode); m_NSWMM_globalTime->push_back(hit.globalTime()); @@ -145,17 +138,9 @@ StatusCode MMSimHitVariables::fillVariables() ATH_MSG_DEBUG("MicroMegas geometry, retrieving detector element for: isSmall " << isSmall << " eta " << m_MmIdHelper->stationEta(offId) << " phi " << m_MmIdHelper->stationPhi(offId) << " ml " << m_MmIdHelper->multilayer(offId) ); - int phiCor = m_MmIdHelper->stationPhi(offId); - int mlCor = m_MmIdHelper->multilayer(offId); - - const MuonGM::MMReadoutElement* detEl = m_detManager->getMMRElement_fromIdFields(isSmall, m_MmIdHelper->stationEta(offId), phiCor, mlCor ); - // const MuonGM::MMReadoutElement* detEl = m_detManager->getMMReadoutElement(offId); + const MuonGM::MMReadoutElement* detEl = m_detManager->getMMReadoutElement(offId); if( !detEl ){ - /* - ATH_MSG_WARNING("MicroMegas geometry, failed to retrieve detector element for: isSmall " << isSmall << " eta " << m_MmIdHelper->stationEta(offId) - << " phi " << m_MmIdHelper->stationPhi(offId) << " ml " << m_MmIdHelper->multiplet(offId) ); - */ ATH_MSG_WARNING("MicroMegas geometry, failed to retrieve detector element for: " << m_MmIdHelper->print_to_string(offId) ); continue; } @@ -270,7 +255,6 @@ StatusCode MMSimHitVariables::clearVariables() { m_NSWMM_nSimHits = 0; m_NSWMM_trackId->clear(); - m_NSWMM_truthEl->clear(); m_NSWMM_globalTime->clear(); m_NSWMM_hitGlobalPositionX->clear(); m_NSWMM_hitGlobalPositionY->clear(); @@ -302,13 +286,11 @@ StatusCode MMSimHitVariables::clearVariables() m_NSWMM_FastDigitRsurfacePositionX->clear(); m_NSWMM_FastDigitRsurfacePositionY->clear(); - m_NSWMM_particleEncoding->clear(); m_NSWMM_kineticEnergy->clear(); m_NSWMM_depositEnergy->clear(); m_NSWMM_StepLength->clear(); - m_NSWMM_sim_stationName->clear(); m_NSWMM_sim_stationEta->clear(); m_NSWMM_sim_stationPhi->clear(); @@ -328,6 +310,8 @@ StatusCode MMSimHitVariables::clearVariables() void MMSimHitVariables::deleteVariables() { + delete m_NSWMM_trackId; + delete m_NSWMM_globalTime; delete m_NSWMM_hitGlobalPositionX; delete m_NSWMM_hitGlobalPositionY; @@ -381,6 +365,7 @@ void MMSimHitVariables::deleteVariables() m_NSWMM_nSimHits = 0; + m_NSWMM_trackId = nullptr; m_NSWMM_globalTime = nullptr; m_NSWMM_hitGlobalPositionX = nullptr; m_NSWMM_hitGlobalPositionY = nullptr; @@ -439,7 +424,6 @@ StatusCode MMSimHitVariables::initializeVariables() { m_NSWMM_nSimHits = 0; m_NSWMM_trackId = new std::vector<int>; - m_NSWMM_truthEl = new std::vector<int>; m_NSWMM_globalTime = new std::vector<double>; m_NSWMM_hitGlobalPositionX = new std::vector<double>; m_NSWMM_hitGlobalPositionY = new std::vector<double>; @@ -495,7 +479,6 @@ StatusCode MMSimHitVariables::initializeVariables() if(m_tree) { m_tree->Branch("Hits_MM_n", &m_NSWMM_nSimHits, "Hits_MM_n/i"); m_tree->Branch("Hits_MM_trackId", &m_NSWMM_trackId); - m_tree->Branch("Hits_MM_truthEl", &m_NSWMM_truthEl); m_tree->Branch("Hits_MM_globalTime", &m_NSWMM_globalTime); m_tree->Branch("Hits_MM_hitGlobalPositionX", &m_NSWMM_hitGlobalPositionX); m_tree->Branch("Hits_MM_hitGlobalPositionY", &m_NSWMM_hitGlobalPositionY); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.h index a565efecb6344b3d046cf07aad5a89e6b5110038..9cc59c14d5685740f446ea15206f857e50c34cf2 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.h +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/MMSimHitVariables.h @@ -22,7 +22,6 @@ class MMSimHitVariables : public ValAlgVariables m_MmIdHelper(0), m_NSWMM_nSimHits(0), m_NSWMM_trackId(0), - m_NSWMM_truthEl(0), m_NSWMM_globalTime(0), m_NSWMM_hitGlobalPositionX(0), m_NSWMM_hitGlobalPositionY(0), @@ -93,7 +92,6 @@ class MMSimHitVariables : public ValAlgVariables int m_NSWMM_nSimHits; std::vector<int> *m_NSWMM_trackId; - std::vector<int> *m_NSWMM_truthEl; std::vector<double> *m_NSWMM_globalTime; std::vector<double> *m_NSWMM_hitGlobalPositionX; std::vector<double> *m_NSWMM_hitGlobalPositionY; diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx index ebbfbd38a692f2a77d9c0acb360501f98f5a5615..bf5c35797dd392fa45f404e4c956ef007fd3312b 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.cxx @@ -8,10 +8,12 @@ #include "MMSimHitVariables.h" #include "MMFastDigitVariables.h" #include "MMRDOVariables.h" +#include "MMPRDVariables.h" #include "sTGCDigitVariables.h" #include "sTGCSimHitVariables.h" #include "sTGCFastDigitVariables.h" +#include "sTGCPRDVariables.h" #include "CSCDigitVariables.h" @@ -37,10 +39,12 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) m_sTgcSimHitVar(nullptr), m_sTgcFastDigitVar(nullptr), m_sTgcDigitVar(nullptr), + m_sTgcPrdVar(nullptr), m_MmSimHitVar(nullptr), m_MmFastDigitVar(nullptr), m_MmDigitVar(nullptr), m_MmRdoVar(nullptr), + m_MmPrdVar(nullptr), m_CscDigitVar(nullptr), m_thistSvc(nullptr), m_tree(nullptr), @@ -55,11 +59,13 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) declareProperty("MuonEntryLayer_ContainerName", m_MuEntry_ContainerName="MuonEntryLayer"); declareProperty("NSWsTGC_ContainerName", m_NSWsTGC_ContainerName="sTGCSensitiveDetector"); declareProperty("NSWsTGC_FastDigitContainerName", m_NSWsTGC_FastDigitContainerName="STGC_Measurements"); - declareProperty("NSWsTGC_DigitContainerName", m_NSWsTGC_DigitContainerName=""); + declareProperty("NSWsTGC_DigitContainerName", m_NSWsTGC_DigitContainerName="sTGC_DIGITS"); + declareProperty("NSWsTGC_PRDContainerName", m_NSWsTGC_PRDContainerName="STGC_Measurements"); declareProperty("NSWMM_ContainerName", m_NSWMM_ContainerName="MicromegasSensitiveDetector"); declareProperty("NSWMM_FastDigitContainerName", m_NSWMM_FastDigitContainerName="MM_Measurements"); declareProperty("NSWMM_DigitContainerName", m_NSWMM_DigitContainerName="MM_DIGITS"); declareProperty("NSWMM_RDOContainerName", m_NSWMM_RDOContainerName="MMRDO"); + declareProperty("NSWMM_PRDContainerName", m_NSWMM_PRDContainerName="MM_Measurements"); declareProperty("CSC_DigitContainerName", m_CSC_DigitContainerName="CSC_DIGITS"); declareProperty("doTruth", m_doTruth=false); @@ -67,10 +73,12 @@ NSWPRDValAlg::NSWPRDValAlg(const std::string& name, ISvcLocator* pSvcLocator) declareProperty("doSTGCHit", m_doSTGCHit=false); declareProperty("doSTGCFastDigit", m_doSTGCFastDigit=false); declareProperty("doSTGCDigit", m_doSTGCDigit=false); + declareProperty("doSTGCPRD", m_doSTGCPRD=false); declareProperty("doMMHit", m_doMMHit=false); declareProperty("doMMFastDigit", m_doMMFastDigit=false); declareProperty("doMMDigit", m_doMMDigit=false); declareProperty("doMMRDO", m_doMMRDO=false); + declareProperty("doMMPRD", m_doMMPRD=false); declareProperty("doCSCDigit", m_doCSCDigit=false); } @@ -96,7 +104,7 @@ StatusCode NSWPRDValAlg::initialize() { if (m_doTruth){ m_TruthVar = new TruthVariables(&(*(evtStore())), m_detManager, - m_tree, m_Truth_ContainerName); + m_tree, m_Truth_ContainerName); CHECK( m_TruthVar->initializeVariables() ); } @@ -108,7 +116,7 @@ StatusCode NSWPRDValAlg::initialize() { if (m_doSTGCHit){ m_sTgcSimHitVar = new sTGCSimHitVariables(&(*(evtStore())), m_detManager, - m_sTgcIdHelper, m_tree, m_NSWsTGC_ContainerName); + m_sTgcIdHelper, m_tree, m_NSWsTGC_ContainerName); ATH_CHECK( m_sTgcSimHitVar->initializeVariables() ); } @@ -118,6 +126,12 @@ StatusCode NSWPRDValAlg::initialize() { ATH_CHECK( m_sTgcFastDigitVar->initializeVariables() ); } + if (m_doSTGCPRD){ + m_sTgcPrdVar = new sTGCPRDVariables(&(*(evtStore())), m_detManager, + m_sTgcIdHelper, m_tree, m_NSWsTGC_PRDContainerName); + ATH_CHECK( m_sTgcPrdVar->initializeVariables() ); + } + if (m_doSTGCDigit){ m_sTgcDigitVar = new sTGCDigitVariables(&(*(evtStore())), m_detManager, m_sTgcIdHelper, m_tree, m_NSWsTGC_DigitContainerName); @@ -126,32 +140,38 @@ StatusCode NSWPRDValAlg::initialize() { if (m_doMMHit) { m_MmSimHitVar = new MMSimHitVariables(&(*(evtStore())), m_detManager, - m_MmIdHelper, m_tree, m_NSWMM_ContainerName); + m_MmIdHelper, m_tree, m_NSWMM_ContainerName); ATH_CHECK( m_MmSimHitVar->initializeVariables() ); } if (m_doMMDigit) { m_MmDigitVar = new MMDigitVariables(&(*(evtStore())), m_detManager, - m_MmIdHelper, m_tree, m_NSWMM_DigitContainerName); + m_MmIdHelper, m_tree, m_NSWMM_DigitContainerName); ATH_CHECK( m_MmDigitVar->initializeVariables() ); } if (m_doMMRDO) { m_MmRdoVar = new MMRDOVariables(&(*(evtStore())), m_detManager, - m_MmIdHelper, m_tree, m_NSWMM_RDOContainerName); + m_MmIdHelper, m_tree, m_NSWMM_RDOContainerName); ATH_CHECK( m_MmRdoVar->initializeVariables() ); } if (m_doMMFastDigit){ m_MmFastDigitVar = new MMFastDigitVariables(&(*(evtStore())), m_detManager, - m_MmIdHelper, m_tree, m_NSWMM_FastDigitContainerName); + m_MmIdHelper, m_tree, m_NSWMM_FastDigitContainerName); ATH_CHECK( m_MmFastDigitVar->initializeVariables() ); } + if (m_doMMPRD){ + m_MmPrdVar = new MMPRDVariables(&(*(evtStore())), m_detManager, + m_MmIdHelper, m_tree, m_NSWMM_PRDContainerName); + ATH_CHECK( m_MmPrdVar->initializeVariables() ); + } + if (m_doCSCDigit){ m_CscDigitVar = new CSCDigitVariables(&(*(evtStore())), m_detManager, - m_CscIdHelper, m_tree, m_CSC_DigitContainerName); + m_CscIdHelper, m_tree, m_CSC_DigitContainerName); ATH_CHECK( m_CscDigitVar->initializeVariables() ); } @@ -167,10 +187,12 @@ StatusCode NSWPRDValAlg::finalize() if (m_sTgcSimHitVar) { delete m_sTgcSimHitVar; m_sTgcSimHitVar=0;} if (m_sTgcFastDigitVar) { delete m_sTgcFastDigitVar; m_sTgcFastDigitVar=0;} if (m_sTgcDigitVar) { delete m_sTgcDigitVar; m_sTgcDigitVar=0;} + if (m_sTgcPrdVar) { delete m_sTgcPrdVar; m_sTgcPrdVar=0;} if (m_MmSimHitVar) { delete m_MmSimHitVar; m_MmSimHitVar=0;} if (m_MmFastDigitVar) { delete m_MmFastDigitVar; m_MmFastDigitVar=0;} if (m_MmDigitVar) { delete m_MmDigitVar; m_MmDigitVar=0;} if (m_MmRdoVar) { delete m_MmRdoVar; m_MmRdoVar=0;} + if (m_MmPrdVar) { delete m_MmPrdVar; m_MmPrdVar=0;} if (m_CscDigitVar) { delete m_CscDigitVar; m_CscDigitVar=0;} return StatusCode::SUCCESS; @@ -202,6 +224,8 @@ StatusCode NSWPRDValAlg::execute() if (m_doSTGCDigit) ATH_CHECK( m_sTgcDigitVar->fillVariables() ); + if (m_doSTGCPRD) ATH_CHECK( m_sTgcPrdVar->fillVariables() ); + if (m_doMMHit) ATH_CHECK( m_MmSimHitVar->fillVariables() ); if (m_doMMFastDigit) ATH_CHECK( m_MmFastDigitVar->fillVariables() ); @@ -210,6 +234,8 @@ StatusCode NSWPRDValAlg::execute() if (m_doMMRDO) ATH_CHECK( m_MmRdoVar->fillVariables() ); + if (m_doMMPRD) ATH_CHECK( m_MmPrdVar->fillVariables() ); + if (m_doCSCDigit) ATH_CHECK( m_CscDigitVar->fillVariables() ); m_tree->Fill(); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h index 6fb841801dc75ff31c3f963e0bc0473796eed19e..c7ec6ad7c34f79719ebe31b410ce7d24d3cc71bd 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/NSWPRDValAlg.h @@ -13,10 +13,12 @@ class MMDigitVariables; class MMSimHitVariables; class MMFastDigitVariables; class MMRDOVariables; +class MMPRDVariables; class sTGCDigitVariables; class sTGCSimHitVariables; class sTGCFastDigitVariables; +class sTGCPRDVariables; class CSCDigitVariables; @@ -48,10 +50,12 @@ class NSWPRDValAlg:public AthAlgorithm sTGCSimHitVariables* m_sTgcSimHitVar; sTGCFastDigitVariables* m_sTgcFastDigitVar; sTGCDigitVariables* m_sTgcDigitVar; + sTGCPRDVariables* m_sTgcPrdVar; MMSimHitVariables* m_MmSimHitVar; MMFastDigitVariables* m_MmFastDigitVar; MMDigitVariables* m_MmDigitVar; MMRDOVariables* m_MmRdoVar; + MMPRDVariables* m_MmPrdVar; CSCDigitVariables* m_CscDigitVar; ITHistSvc *m_thistSvc; @@ -67,11 +71,13 @@ class NSWPRDValAlg:public AthAlgorithm BooleanProperty m_doSTGCHit; // switch on the output of the Small TGC data BooleanProperty m_doSTGCFastDigit; // switch on the output of the Small TGC fast digitization BooleanProperty m_doSTGCDigit; // swicth on the output of the Small TGC digit + BooleanProperty m_doSTGCPRD; // swicth on the output of the Small TGC prepdata BooleanProperty m_doMMHit; // switch on the output of the MicroMegas data BooleanProperty m_doMMFastDigit; // switch on the output of the MicroMegas fast digitization BooleanProperty m_doMMDigit; // switch on the output of the MicroMegas digitization - BooleanProperty m_doMMRDO; // switch on the output of the MicroMegas digitization - BooleanProperty m_doCSCDigit; // switch on the output of the MicroMegas digitization + BooleanProperty m_doMMRDO; // switch on the output of the MicroMegas digitization + BooleanProperty m_doMMPRD; // switch on the output of the MicroMegas prepdata + BooleanProperty m_doCSCDigit; // switch on the output of the MicroMegas digitization unsigned int m_runNumber; unsigned int m_eventNumber; @@ -81,11 +87,13 @@ class NSWPRDValAlg:public AthAlgorithm std::string m_NSWsTGC_ContainerName; std::string m_NSWsTGC_FastDigitContainerName; std::string m_NSWsTGC_DigitContainerName; + std::string m_NSWsTGC_PRDContainerName; std::string m_NSWMM_ContainerName; std::string m_NSWMM_FastDigitContainerName; std::string m_NSWMM_DigitContainerName; std::string m_NSWMM_RDOContainerName; + std::string m_NSWMM_PRDContainerName; std::string m_CSC_DigitContainerName; }; -#endif // NSWHITSDUMPALG_H +#endif // NSWPRDVALALG_H diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx index 5e8334364bc19a24dcf8549c15c0d102a0a1c959..e1ac5557aa5313751eb50d1b0f86f46a3e76ad8f 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCDigitVariables.cxx @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ @@ -27,160 +27,160 @@ StatusCode sTGCDigitVariables::fillVariables() m_msg.get().setLevel(msgLevel); CHECK( this->clearVariables() ); - + // get truth information container of digitization const MuonSimDataCollection* nsw_sTgcSdoContainer = nullptr; CHECK( m_evtStore->retrieve(nsw_sTgcSdoContainer, "sTGC_SDO") ); - + const sTgcDigitContainer* nsw_sTgcDigitContainer = nullptr; - CHECK( m_evtStore->retrieve(nsw_sTgcDigitContainer, "sTGC_DIGITS") ); - + CHECK( m_evtStore->retrieve(nsw_sTgcDigitContainer, m_ContainerName.c_str()) ); + sTgcDigitContainer::const_iterator it = nsw_sTgcDigitContainer->begin(); sTgcDigitContainer::const_iterator it_e = nsw_sTgcDigitContainer->end(); ATH_MSG_DEBUG("retrieved sTGC Digit Container with size "<<nsw_sTgcDigitContainer->digit_size()); if(nsw_sTgcDigitContainer->size()==0) ATH_MSG_WARNING(" sTGC Digit Continer empty "); for(; it!=it_e; ++it) { - const sTgcDigitCollection* coll = *it; - ATH_MSG_DEBUG( "processing collection with size " << coll->size() ); - for (unsigned int digitNum=0; digitNum<coll->size(); digitNum++) { - const sTgcDigit* digit = coll->at(digitNum); - Identifier Id = digit->identify(); - - std::string stName = m_sTgcIdHelper->stationNameString(m_sTgcIdHelper->stationName(Id)); - int stationEta = m_sTgcIdHelper->stationEta(Id); - int stationPhi = m_sTgcIdHelper->stationPhi(Id); - int multiplet = m_sTgcIdHelper->multilayer(Id); - int gas_gap = m_sTgcIdHelper->gasGap(Id); - int channel = m_sTgcIdHelper->channel(Id); - int stationEtaMin = m_sTgcIdHelper->stationEtaMin(Id); - int stationEtaMax = m_sTgcIdHelper->stationEtaMax(Id); - int stationPhiMin = m_sTgcIdHelper->stationPhiMin(Id); - int stationPhiMax = m_sTgcIdHelper->stationPhiMax(Id); - int gas_gapMin = m_sTgcIdHelper->gasGapMin(Id); - int gas_gapMax = m_sTgcIdHelper->gasGapMax(Id); - int padEta = m_sTgcIdHelper->padEta(Id); - int padPhi = m_sTgcIdHelper->padPhi(Id); - int NofMultilayers = m_sTgcIdHelper->numberOfMultilayers(Id); - int multilayerMin = m_sTgcIdHelper->multilayerMin(Id); - int multilayerMax = m_sTgcIdHelper->multilayerMax(Id); - int channelTypeMin = m_sTgcIdHelper->channelTypeMin(Id); - int channelTypeMax = m_sTgcIdHelper->channelTypeMax(Id); - int channelMin = m_sTgcIdHelper->channelMin(Id); - int channelMax = m_sTgcIdHelper->channelMax(Id); - int channelType = m_sTgcIdHelper->channelType(Id); - - ATH_MSG_DEBUG( "sTGC Digit Offline id: Station Name [" << stName << " ]" - << " Station Eta [" << stationEta << "]" - << " Station Phi [" << stationPhi << "]" - << " Multiplet [" << multiplet << "]" - << " GasGap [" << gas_gap << "]" - << " ChNr [" << channel << "]" - << " Station EtaMin [" << stationEtaMin << "]" - << " Station EtaMax [" << stationEtaMax << "]" - << " Station PhiMin [" << stationPhiMin << "]" - << " Station PhiMax [" << stationPhiMax << "]"); - - int isSmall = stName[2] == 'S'; - const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcRElement_fromIdFields(isSmall, stationEta, stationPhi, multiplet ); - - int channelNumber = 0; - const Identifier phiId, etaId; - Amg::Vector3D gpos(0.,0.,0.); - Amg::Vector2D lpos(0.,0.); - - rdoEl->stripPosition(Id,lpos); - rdoEl->surface(Id).localToGlobal(lpos, gpos,gpos); - - std::vector<Amg::Vector2D> local_pad_corners; - rdoEl->padCorners(Id,local_pad_corners); - std::vector<Amg::Vector3D> global_pad_corners; - - for(auto& local_corner : local_pad_corners) { - Amg::Vector3D global_corner; - rdoEl->surface(Id).localToGlobal(local_corner, global_corner, global_corner); - global_pad_corners.push_back(global_corner); - } - - - m_NSWsTGC_dig_globalPosX->push_back( gpos.x() ); - m_NSWsTGC_dig_globalPosY->push_back( gpos.y() ); - m_NSWsTGC_dig_globalPosZ->push_back( gpos.z() ); - m_NSWsTGC_dig_localPosX->push_back( lpos.x() ); - m_NSWsTGC_dig_localPosY->push_back( lpos.y() ); - for(auto corner : global_pad_corners){ - if(channelType ==0 ){ - m_NSWsTGC_dig_PadglobalCornerPosX->push_back(corner.x()); - m_NSWsTGC_dig_PadglobalCornerPosY->push_back(corner.y()); - m_NSWsTGC_dig_PadglobalCornerPosZ->push_back(corner.z()); - } - } - channelNumber = rdoEl->stripNumber(lpos,Id); - m_NSWsTGC_dig_channelPosX->push_back( lpos.x() ); - m_NSWsTGC_dig_channelPosY->push_back( lpos.y() ); - - m_NSWsTGC_dig_channel_type->push_back(channelType); - m_NSWsTGC_dig_stationName->push_back(stName); - m_NSWsTGC_dig_stationEta->push_back(stationEta); - m_NSWsTGC_dig_stationPhi->push_back(stationPhi); - m_NSWsTGC_dig_multiplet->push_back(multiplet); - m_NSWsTGC_dig_gas_gap->push_back(gas_gap); - m_NSWsTGC_dig_channel->push_back(channel); - m_NSWsTGC_dig_stationEtaMin->push_back(stationEtaMin); - m_NSWsTGC_dig_stationEtaMax->push_back(stationEtaMax); - m_NSWsTGC_dig_stationPhiMin->push_back(stationPhiMin); - m_NSWsTGC_dig_stationPhiMax->push_back(stationPhiMax); - m_NSWsTGC_dig_gas_gapMin->push_back(gas_gapMin); - m_NSWsTGC_dig_gas_gapMax->push_back(gas_gapMax); - m_NSWsTGC_dig_padEta->push_back(padEta); - m_NSWsTGC_dig_padPhi->push_back(padPhi); - m_NSWsTGC_dig_numberOfMultilayers->push_back(NofMultilayers); - m_NSWsTGC_dig_multilayerMin->push_back(multilayerMin); - m_NSWsTGC_dig_multilayerMax->push_back(multilayerMax); - m_NSWsTGC_dig_channelTypeMin->push_back(channelTypeMin); - m_NSWsTGC_dig_channelTypeMax->push_back(channelTypeMax); - m_NSWsTGC_dig_channelMin->push_back(channelMin); - m_NSWsTGC_dig_channelMax->push_back(channelMax); - m_NSWsTGC_dig_channelNumber->push_back(channelNumber); - - m_NSWsTGC_dig_bctag->push_back(digit->bcTag()); - m_NSWsTGC_dig_time->push_back(digit->time()); - m_NSWsTGC_dig_charge->push_back(digit->charge()); - m_NSWsTGC_dig_isDead->push_back(digit->isDead()); - m_NSWsTGC_dig_isPileup->push_back(digit->isPileup()); - - // retrieve the MC truth associated with the digit (means the Geant4 hit information) - if (nsw_sTgcSdoContainer) { - - const MuonSimData sTgc_sdo = (nsw_sTgcSdoContainer->find(Id))->second; - std::vector<MuonSimData::Deposit> deposits; - sTgc_sdo.deposits(deposits); - - int truth_barcode = deposits[0].first.barcode(); - double truth_localPosX = deposits[0].second.firstEntry(); - double truth_localPosY = deposits[0].second.secondEntry(); - float truth_angle = sTgc_sdo.word()/1000.; - Amg::Vector2D hit_on_surface(truth_localPosX, truth_localPosY); - Amg::Vector3D hit_gpos(0., 0., 0.); - rdoEl->surface(Id).localToGlobal(hit_on_surface, Amg::Vector3D(0., 0., 0.), hit_gpos); - ATH_MSG_DEBUG(" sTGC Digit, truth barcode=" << truth_barcode); - ATH_MSG_DEBUG(" sTGC Digit, truth localPosX=" << std::setw(9) << std::setprecision(2) << truth_localPosX - << ", truth localPosY=" << std::setw(9) << std::setprecision(2) << truth_localPosY - << ", truth XZ angle=" << std::setw(8) << std::setprecision(5) << truth_angle); - - - m_NSWsTGC_dig_truth_barcode->push_back( truth_barcode ); - m_NSWsTGC_dig_truth_localPosX->push_back( truth_localPosX ); - m_NSWsTGC_dig_truth_localPosY->push_back( truth_localPosY ); - m_NSWsTGC_dig_truth_XZ_angle->push_back( truth_angle ); - m_NSWsTGC_dig_truth_globalPosX->push_back( hit_gpos[0] ); - m_NSWsTGC_dig_truth_globalPosY->push_back( hit_gpos[1] ); - m_NSWsTGC_dig_truth_globalPosZ->push_back( hit_gpos[2] ); - } - if(channelType == 0) m_NSWsTGC_nPadDigits++; - m_NSWsTGC_nDigits++; + const sTgcDigitCollection* coll = *it; + ATH_MSG_DEBUG( "processing collection with size " << coll->size() ); + for (unsigned int digitNum=0; digitNum<coll->size(); digitNum++) { + const sTgcDigit* digit = coll->at(digitNum); + Identifier Id = digit->identify(); + + std::string stName = m_sTgcIdHelper->stationNameString(m_sTgcIdHelper->stationName(Id)); + int stationEta = m_sTgcIdHelper->stationEta(Id); + int stationPhi = m_sTgcIdHelper->stationPhi(Id); + int multiplet = m_sTgcIdHelper->multilayer(Id); + int gas_gap = m_sTgcIdHelper->gasGap(Id); + int channel = m_sTgcIdHelper->channel(Id); + int stationEtaMin = m_sTgcIdHelper->stationEtaMin(Id); + int stationEtaMax = m_sTgcIdHelper->stationEtaMax(Id); + int stationPhiMin = m_sTgcIdHelper->stationPhiMin(Id); + int stationPhiMax = m_sTgcIdHelper->stationPhiMax(Id); + int gas_gapMin = m_sTgcIdHelper->gasGapMin(Id); + int gas_gapMax = m_sTgcIdHelper->gasGapMax(Id); + int padEta = m_sTgcIdHelper->padEta(Id); + int padPhi = m_sTgcIdHelper->padPhi(Id); + int NofMultilayers = m_sTgcIdHelper->numberOfMultilayers(Id); + int multilayerMin = m_sTgcIdHelper->multilayerMin(Id); + int multilayerMax = m_sTgcIdHelper->multilayerMax(Id); + int channelTypeMin = m_sTgcIdHelper->channelTypeMin(Id); + int channelTypeMax = m_sTgcIdHelper->channelTypeMax(Id); + int channelMin = m_sTgcIdHelper->channelMin(Id); + int channelMax = m_sTgcIdHelper->channelMax(Id); + int channelType = m_sTgcIdHelper->channelType(Id); + + ATH_MSG_DEBUG( "sTGC Digit Offline id: Station Name [" << stName << " ]" + << " Station Eta [" << stationEta << "]" + << " Station Phi [" << stationPhi << "]" + << " Multiplet [" << multiplet << "]" + << " GasGap [" << gas_gap << "]" + << " ChNr [" << channel << "]" + << " Station EtaMin [" << stationEtaMin << "]" + << " Station EtaMax [" << stationEtaMax << "]" + << " Station PhiMin [" << stationPhiMin << "]" + << " Station PhiMax [" << stationPhiMax << "]"); + + int isSmall = stName[2] == 'S'; + const MuonGM::sTgcReadoutElement* rdoEl = m_detManager->getsTgcRElement_fromIdFields(isSmall, stationEta, stationPhi, multiplet ); + + int channelNumber = 0; + const Identifier phiId, etaId; + Amg::Vector3D gpos(0.,0.,0.); + Amg::Vector2D lpos(0.,0.); + + rdoEl->stripPosition(Id,lpos); + rdoEl->surface(Id).localToGlobal(lpos, gpos,gpos); + + std::vector<Amg::Vector2D> local_pad_corners; + rdoEl->padCorners(Id,local_pad_corners); + std::vector<Amg::Vector3D> global_pad_corners; + + for(auto& local_corner : local_pad_corners) { + Amg::Vector3D global_corner; + rdoEl->surface(Id).localToGlobal(local_corner, global_corner, global_corner); + global_pad_corners.push_back(global_corner); } + + + m_NSWsTGC_dig_globalPosX->push_back( gpos.x() ); + m_NSWsTGC_dig_globalPosY->push_back( gpos.y() ); + m_NSWsTGC_dig_globalPosZ->push_back( gpos.z() ); + m_NSWsTGC_dig_localPosX->push_back( lpos.x() ); + m_NSWsTGC_dig_localPosY->push_back( lpos.y() ); + for(auto corner : global_pad_corners) { + if(channelType ==0 ) { + m_NSWsTGC_dig_PadglobalCornerPosX->push_back(corner.x()); + m_NSWsTGC_dig_PadglobalCornerPosY->push_back(corner.y()); + m_NSWsTGC_dig_PadglobalCornerPosZ->push_back(corner.z()); + } + } + channelNumber = rdoEl->stripNumber(lpos,Id); + m_NSWsTGC_dig_channelPosX->push_back( lpos.x() ); + m_NSWsTGC_dig_channelPosY->push_back( lpos.y() ); + + m_NSWsTGC_dig_channel_type->push_back(channelType); + m_NSWsTGC_dig_stationName->push_back(stName); + m_NSWsTGC_dig_stationEta->push_back(stationEta); + m_NSWsTGC_dig_stationPhi->push_back(stationPhi); + m_NSWsTGC_dig_multiplet->push_back(multiplet); + m_NSWsTGC_dig_gas_gap->push_back(gas_gap); + m_NSWsTGC_dig_channel->push_back(channel); + m_NSWsTGC_dig_stationEtaMin->push_back(stationEtaMin); + m_NSWsTGC_dig_stationEtaMax->push_back(stationEtaMax); + m_NSWsTGC_dig_stationPhiMin->push_back(stationPhiMin); + m_NSWsTGC_dig_stationPhiMax->push_back(stationPhiMax); + m_NSWsTGC_dig_gas_gapMin->push_back(gas_gapMin); + m_NSWsTGC_dig_gas_gapMax->push_back(gas_gapMax); + m_NSWsTGC_dig_padEta->push_back(padEta); + m_NSWsTGC_dig_padPhi->push_back(padPhi); + m_NSWsTGC_dig_numberOfMultilayers->push_back(NofMultilayers); + m_NSWsTGC_dig_multilayerMin->push_back(multilayerMin); + m_NSWsTGC_dig_multilayerMax->push_back(multilayerMax); + m_NSWsTGC_dig_channelTypeMin->push_back(channelTypeMin); + m_NSWsTGC_dig_channelTypeMax->push_back(channelTypeMax); + m_NSWsTGC_dig_channelMin->push_back(channelMin); + m_NSWsTGC_dig_channelMax->push_back(channelMax); + m_NSWsTGC_dig_channelNumber->push_back(channelNumber); + + m_NSWsTGC_dig_bctag->push_back(digit->bcTag()); + m_NSWsTGC_dig_time->push_back(digit->time()); + m_NSWsTGC_dig_charge->push_back(digit->charge()); + m_NSWsTGC_dig_isDead->push_back(digit->isDead()); + m_NSWsTGC_dig_isPileup->push_back(digit->isPileup()); + + // retrieve the MC truth associated with the digit (means the Geant4 hit information) + if (nsw_sTgcSdoContainer) { + + const MuonSimData sTgc_sdo = (nsw_sTgcSdoContainer->find(Id))->second; + std::vector<MuonSimData::Deposit> deposits; + sTgc_sdo.deposits(deposits); + + int truth_barcode = deposits[0].first.barcode(); + double truth_localPosX = deposits[0].second.firstEntry(); + double truth_localPosY = deposits[0].second.secondEntry(); + float truth_angle = sTgc_sdo.word()/1000.; + Amg::Vector2D hit_on_surface(truth_localPosX, truth_localPosY); + Amg::Vector3D hit_gpos(0., 0., 0.); + rdoEl->surface(Id).localToGlobal(hit_on_surface, Amg::Vector3D(0., 0., 0.), hit_gpos); + ATH_MSG_DEBUG(" sTGC Digit, truth barcode=" << truth_barcode); + ATH_MSG_DEBUG(" sTGC Digit, truth localPosX=" << std::setw(9) << std::setprecision(2) << truth_localPosX + << ", truth localPosY=" << std::setw(9) << std::setprecision(2) << truth_localPosY + << ", truth XZ angle=" << std::setw(8) << std::setprecision(5) << truth_angle); + + m_NSWsTGC_dig_truth_barcode->push_back( truth_barcode ); + m_NSWsTGC_dig_truth_localPosX->push_back( truth_localPosX ); + m_NSWsTGC_dig_truth_localPosY->push_back( truth_localPosY ); + m_NSWsTGC_dig_truth_XZ_angle->push_back( truth_angle ); + m_NSWsTGC_dig_truth_globalPosX->push_back( hit_gpos[0] ); + m_NSWsTGC_dig_truth_globalPosY->push_back( hit_gpos[1] ); + m_NSWsTGC_dig_truth_globalPosZ->push_back( hit_gpos[2] ); + } + if(channelType == 0) m_NSWsTGC_nPadDigits++; + m_NSWsTGC_nDigits++; + } } + ATH_MSG_INFO(" finished fillNSWsTGCDigitVariables()"); return StatusCode::SUCCESS; } @@ -247,13 +247,14 @@ StatusCode sTGCDigitVariables::clearVariables() StatusCode sTGCDigitVariables::initializeVariables() { - m_NSWsTGC_nDigits = 0; - m_NSWsTGC_nPadDigits = 0; - m_NSWsTGC_dig_time = new std::vector<double>(); - m_NSWsTGC_dig_bctag = new std::vector<int>(); - m_NSWsTGC_dig_charge = new std::vector<double>(); - m_NSWsTGC_dig_isDead = new std::vector<bool>(); - m_NSWsTGC_dig_isPileup = new std::vector<bool>(); + m_NSWsTGC_nDigits = 0; + m_NSWsTGC_nPadDigits = 0; + m_NSWsTGC_dig_time = new std::vector<double>(); + m_NSWsTGC_dig_bctag = new std::vector<int>(); + m_NSWsTGC_dig_charge = new std::vector<double>(); + m_NSWsTGC_dig_isDead = new std::vector<bool>(); + m_NSWsTGC_dig_isPileup = new std::vector<bool>(); + m_NSWsTGC_dig_stationName = new std::vector<std::string>(); m_NSWsTGC_dig_stationEta = new std::vector<int>(); m_NSWsTGC_dig_stationPhi = new std::vector<int>(); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a1ef967b1cc26696c0e89e3f6031b656cfee4584 --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.cxx @@ -0,0 +1,193 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "sTGCPRDVariables.h" +#include "AthenaKernel/errorcheck.h" +#include "MuonSimData/MuonSimDataCollection.h" +#include "MuonPrepRawData/sTgcPrepDataContainer.h" + +#include "TTree.h" + + +StatusCode sTGCPRDVariables::fillVariables() +{ + ATH_MSG_DEBUG("do fillNSWsTGCPRDVariables()"); + CHECK( this->clearVariables() ); + + const Muon::sTgcPrepDataContainer *nsw_sTgcPrepDataContainer = nullptr; + CHECK( m_evtStore->retrieve(nsw_sTgcPrepDataContainer, m_ContainerName.c_str()) ); + + if(nsw_sTgcPrepDataContainer->size()==0) ATH_MSG_WARNING(" sTgc PRD Container empty "); + + for(const Muon::sTgcPrepDataCollection* coll : *nsw_sTgcPrepDataContainer ) { + + for (unsigned int item=0; item<coll->size(); item++) { + const Muon::sTgcPrepData* prd = coll->at(item); + Identifier Id = prd->identify(); + + std::string stName = m_sTgcIdHelper->stationNameString(m_sTgcIdHelper->stationName(Id)); + int stationEta = m_sTgcIdHelper->stationEta(Id); + int stationPhi = m_sTgcIdHelper->stationPhi(Id); + int multiplet = m_sTgcIdHelper->multilayer(Id); + int gas_gap = m_sTgcIdHelper->gasGap(Id); + int channel_type = m_sTgcIdHelper->channelType(Id); + int channel = m_sTgcIdHelper->channel(Id); + + ATH_MSG_DEBUG( "sTGC PRD Offline id: Station Name [" << stName << "]" + << " Station Eta [" << stationEta << "]" + << " Station Phi [" << stationPhi << "]" + << " Multiplet [" << multiplet << "]" + << " GasGap [" << gas_gap << "]" + << " Type [" << channel_type << "]" + << " ChNr [" << channel << "]" ); + + m_NSWsTGC_prd_stationName->push_back(stName); + m_NSWsTGC_prd_stationEta->push_back(stationEta); + m_NSWsTGC_prd_stationPhi->push_back(stationPhi); + m_NSWsTGC_prd_multiplet->push_back(multiplet); + m_NSWsTGC_prd_gas_gap->push_back(gas_gap); + m_NSWsTGC_prd_channel_type->push_back(channel_type); + m_NSWsTGC_prd_channel->push_back(channel); + + const MuonGM::sTgcReadoutElement* det = prd->detectorElement(); + Amg::Vector3D pos = prd->globalPosition(); + Amg::Vector2D loc_pos(0., 0.); + det->surface(Id).globalToLocal(pos, Amg::Vector3D(0., 0., 0.), loc_pos); + + double err_x = prd->localCovariance()(0,0); + double err_y = ( prd->localCovariance().rows()==2)? prd->localCovariance()(1,1) : 0.; + + ATH_MSG_DEBUG( "sTgc PRD local pos.: x=" << std::setw(6) << std::setprecision(2) << loc_pos[0] + << ", ex=" << std::setw(6) << std::setprecision(2) << err_x + << ", y=" << std::setw(6) << std::setprecision(2) << loc_pos[1] + << ", ey=" << std::setw(6) << std::setprecision(2) << err_y ); + + m_NSWsTGC_prd_globalPosX->push_back(pos.x()); + m_NSWsTGC_prd_globalPosY->push_back(pos.y()); + m_NSWsTGC_prd_globalPosZ->push_back(pos.z()); + + m_NSWsTGC_prd_localPosX->push_back(loc_pos[0]); + m_NSWsTGC_prd_localPosY->push_back(loc_pos[1]); + m_NSWsTGC_prd_covMatrix_1_1->push_back(err_x); + m_NSWsTGC_prd_covMatrix_2_2->push_back(err_y); + + m_NSWsTGC_nPRDs++; + } + } + + ATH_MSG_DEBUG("processed " << m_NSWsTGC_nPRDs << " sTGC PRD's"); + + return StatusCode::SUCCESS; +} + +void sTGCPRDVariables::deleteVariables() +{ + delete m_NSWsTGC_prd_stationName; + delete m_NSWsTGC_prd_stationEta; + delete m_NSWsTGC_prd_stationPhi; + delete m_NSWsTGC_prd_multiplet; + delete m_NSWsTGC_prd_gas_gap; + delete m_NSWsTGC_prd_channel_type; + delete m_NSWsTGC_prd_channel; + + delete m_NSWsTGC_prd_globalPosX; + delete m_NSWsTGC_prd_globalPosY; + delete m_NSWsTGC_prd_globalPosZ; + + delete m_NSWsTGC_prd_localPosX; + delete m_NSWsTGC_prd_localPosY; + delete m_NSWsTGC_prd_covMatrix_1_1; + delete m_NSWsTGC_prd_covMatrix_2_2; + + m_NSWsTGC_nPRDs = 0; + m_NSWsTGC_prd_stationName = nullptr; + m_NSWsTGC_prd_stationEta = nullptr; + m_NSWsTGC_prd_stationPhi = nullptr; + m_NSWsTGC_prd_multiplet = nullptr; + m_NSWsTGC_prd_gas_gap = nullptr; + m_NSWsTGC_prd_channel_type = nullptr; + m_NSWsTGC_prd_channel = nullptr; + + m_NSWsTGC_prd_globalPosX = nullptr; + m_NSWsTGC_prd_globalPosY = nullptr; + m_NSWsTGC_prd_globalPosZ = nullptr; + + m_NSWsTGC_prd_localPosX = nullptr; + m_NSWsTGC_prd_localPosY = nullptr; + m_NSWsTGC_prd_covMatrix_1_1 = nullptr; + m_NSWsTGC_prd_covMatrix_2_2 = nullptr; + + return; +} + + +StatusCode sTGCPRDVariables::clearVariables() +{ + + m_NSWsTGC_nPRDs = 0; + m_NSWsTGC_prd_stationName->clear(); + m_NSWsTGC_prd_stationEta ->clear(); + m_NSWsTGC_prd_stationPhi ->clear(); + m_NSWsTGC_prd_multiplet ->clear(); + m_NSWsTGC_prd_gas_gap ->clear(); + m_NSWsTGC_prd_channel_type->clear(); + m_NSWsTGC_prd_channel ->clear(); + + m_NSWsTGC_prd_globalPosX ->clear(); + m_NSWsTGC_prd_globalPosY ->clear(); + m_NSWsTGC_prd_globalPosZ ->clear(); + + m_NSWsTGC_prd_localPosX ->clear(); + m_NSWsTGC_prd_localPosY ->clear(); + m_NSWsTGC_prd_covMatrix_1_1 ->clear(); + m_NSWsTGC_prd_covMatrix_2_2 ->clear(); + + return StatusCode::SUCCESS; +} + + +StatusCode sTGCPRDVariables::initializeVariables() +{ + m_NSWsTGC_nPRDs = 0; + m_NSWsTGC_prd_stationName = new std::vector<std::string>; + m_NSWsTGC_prd_stationEta = new std::vector<int>; + m_NSWsTGC_prd_stationPhi = new std::vector<int>; + m_NSWsTGC_prd_multiplet = new std::vector<int>; + m_NSWsTGC_prd_gas_gap = new std::vector<int>; + m_NSWsTGC_prd_channel_type = new std::vector<int>; + m_NSWsTGC_prd_channel = new std::vector<int>; + + m_NSWsTGC_prd_globalPosX = new std::vector<double>; + m_NSWsTGC_prd_globalPosY = new std::vector<double>; + m_NSWsTGC_prd_globalPosZ = new std::vector<double>; + + m_NSWsTGC_prd_localPosX = new std::vector<double>; + m_NSWsTGC_prd_localPosY = new std::vector<double>; + m_NSWsTGC_prd_covMatrix_1_1 = new std::vector<double>; + m_NSWsTGC_prd_covMatrix_2_2 = new std::vector<double>; + + if(m_tree) { + m_tree->Branch("PRD_sTGC", &m_NSWsTGC_nPRDs, "PRDs_sTGC_n/i"); + m_tree->Branch("PRD_sTGC_stationName", &m_NSWsTGC_prd_stationName); + m_tree->Branch("PRD_sTGC_stationEta", &m_NSWsTGC_prd_stationEta); + m_tree->Branch("PRD_sTGC_stationPhi", &m_NSWsTGC_prd_stationPhi); + m_tree->Branch("PRD_sTGC_multiplet", &m_NSWsTGC_prd_multiplet); + m_tree->Branch("PRD_sTGC_gas_gap", &m_NSWsTGC_prd_gas_gap); + m_tree->Branch("PRD_sTGC_channel_type",&m_NSWsTGC_prd_channel_type); + m_tree->Branch("PRD_sTGC_channel", &m_NSWsTGC_prd_channel); + + m_tree->Branch("PRD_sTGC_globalPosX", &m_NSWsTGC_prd_globalPosX); + m_tree->Branch("PRD_sTGC_globalPosY", &m_NSWsTGC_prd_globalPosY); + m_tree->Branch("PRD_sTGC_globalPosZ", &m_NSWsTGC_prd_globalPosZ); + + m_tree->Branch("PRD_sTGC_localPosX", &m_NSWsTGC_prd_localPosX); + m_tree->Branch("PRD_sTGC_localPosY", &m_NSWsTGC_prd_localPosY); + m_tree->Branch("PRD_sTGC_covMatrix_1_1", &m_NSWsTGC_prd_covMatrix_1_1); + m_tree->Branch("PRD_sTGC_covMatrix_2_2", &m_NSWsTGC_prd_covMatrix_2_2); + + } + + return StatusCode::SUCCESS; +} + diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.h new file mode 100644 index 0000000000000000000000000000000000000000..ddda572b53ef7b336d749cc6ac8716f4367dadbc --- /dev/null +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCPRDVariables.h @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef STGCPRDVARIABLES_H +#define STGCPRDVARIABLES_H + +#include "ValAlgVariables.h" +#include "MuonIdHelpers/sTgcIdHelper.h" +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include <vector> + +class sTGCPRDVariables : public ValAlgVariables +{ + public: + sTGCPRDVariables(StoreGateSvc* evtStore, + const MuonGM::MuonDetectorManager* detManager, + const MuonIdHelper* idhelper, + TTree* tree, + std::string containername) : + ValAlgVariables(evtStore, detManager, tree, containername, "sTGCPRDVariables"), + m_sTgcIdHelper(0), + m_NSWsTGC_nPRDs(0), + m_NSWsTGC_prd_stationName(0), + m_NSWsTGC_prd_stationEta(0), + m_NSWsTGC_prd_stationPhi(0), + m_NSWsTGC_prd_multiplet(0), + m_NSWsTGC_prd_gas_gap(0), + m_NSWsTGC_prd_channel_type(0), + m_NSWsTGC_prd_channel(0), + m_NSWsTGC_prd_globalPosX(0), + m_NSWsTGC_prd_globalPosY(0), + m_NSWsTGC_prd_globalPosZ(0), + m_NSWsTGC_prd_localPosX(0), + m_NSWsTGC_prd_localPosY(0), + m_NSWsTGC_prd_covMatrix_1_1(0), + m_NSWsTGC_prd_covMatrix_2_2(0) + { + setHelper(idhelper); + } + + ~sTGCPRDVariables() + { + deleteVariables(); + } + + StatusCode initializeVariables(); + StatusCode fillVariables(); + + private: + + void setHelper(const MuonIdHelper* idhelper){ + m_sTgcIdHelper = dynamic_cast<const sTgcIdHelper*>(idhelper); + if(m_sTgcIdHelper == 0) { + ATH_MSG_ERROR("casting IdHelper to sTgcIdhelper failed"); + throw; + } + } + + void deleteVariables(); + StatusCode clearVariables(); + + const sTgcIdHelper* m_sTgcIdHelper; + + int m_NSWsTGC_nPRDs; + std::vector<std::string> *m_NSWsTGC_prd_stationName; + std::vector<int> *m_NSWsTGC_prd_stationEta; + std::vector<int> *m_NSWsTGC_prd_stationPhi; + std::vector<int> *m_NSWsTGC_prd_multiplet; + std::vector<int> *m_NSWsTGC_prd_gas_gap; + std::vector<int> *m_NSWsTGC_prd_channel_type; + std::vector<int> *m_NSWsTGC_prd_channel; + + std::vector<double> *m_NSWsTGC_prd_globalPosX; + std::vector<double> *m_NSWsTGC_prd_globalPosY; + std::vector<double> *m_NSWsTGC_prd_globalPosZ; + + std::vector<double> *m_NSWsTGC_prd_localPosX; + std::vector<double> *m_NSWsTGC_prd_localPosY; + std::vector<double> *m_NSWsTGC_prd_covMatrix_1_1; + std::vector<double> *m_NSWsTGC_prd_covMatrix_2_2; + +}; + +#endif // STGCPRDVARIABLE_H diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx index 4b24bd781c8b515028abbe1d1f89377543f8c615..7d559a82251dad0b4b07d5ea6fe9c8bf3248bb24 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.cxx @@ -32,127 +32,127 @@ StatusCode sTGCSimHitVariables::fillVariables() const GenericMuonSimHit hit = it; if(hit.depositEnergy()==0.) continue; // SimHits without energy loss are not recorded. - // connect the hit with the MC truth - int barcode = hit.particleLink().barcode(); - m_NSWsTGC_trackId->push_back(barcode); -// for (unsigned int tr=0;tr<m_Truth_particleBarcode->size();tr++) { -// if (barcode==m_Truth_particleBarcode->at(tr)) { -// m_NSWsTGC_truthEl->push_back(tr); -// } -// } - - m_NSWsTGC_globalTime->push_back(hit.globalTime()); - const Amg::Vector3D globalPosition = hit.globalPosition(); - m_NSWsTGC_hitGlobalPositionX->push_back(globalPosition.x()); - m_NSWsTGC_hitGlobalPositionY->push_back(globalPosition.y()); - m_NSWsTGC_hitGlobalPositionZ->push_back(globalPosition.z()); - m_NSWsTGC_hitGlobalPositionR->push_back(globalPosition.perp()); - m_NSWsTGC_hitGlobalPositionP->push_back(globalPosition.phi()); - const Amg::Vector3D globalDirection = hit.globalDirection(); - m_NSWsTGC_hitGlobalDirectionX->push_back(globalDirection.x()); - m_NSWsTGC_hitGlobalDirectionY->push_back(globalDirection.y()); - m_NSWsTGC_hitGlobalDirectionZ->push_back(globalDirection.z()); - - const Amg::Vector3D localPosition = hit.localPosition(); - m_NSWsTGC_hitLocalPositionX->push_back(localPosition.x()); - m_NSWsTGC_hitLocalPositionY->push_back(localPosition.y()); - m_NSWsTGC_hitLocalPositionZ->push_back(localPosition.z()); - - m_NSWsTGC_particleEncoding->push_back(hit.particleEncoding()); - m_NSWsTGC_kineticEnergy->push_back(hit.kineticEnergy()); - m_NSWsTGC_depositEnergy->push_back(hit.depositEnergy()); - m_NSWsTGC_StepLength->push_back(hit.StepLength()); - - // Read information about the sTGC hits; make sanity checks and printout - int simId = hit.GenericId(); - std::string sim_stationName = hitHelper->GetStationName(simId); - int sim_stationEta = hitHelper->GetZSector(simId); - int sim_stationPhi = hitHelper->GetPhiSector(simId); - int sim_multilayer = hitHelper->GetMultiLayer(simId); - int sim_layer = hitHelper->GetLayer(simId); - int sim_side = hitHelper->GetSide(simId); - - ATH_MSG_DEBUG( "sTGC SimHit id: Station Name [" << sim_stationName << " ]" - << " Station Eta [" << sim_stationEta << "]" - << " Station Phi [" << sim_stationPhi << "]" - << " MultiLayer [" << sim_multilayer << "]" - << " Layer [" << sim_layer << "]" - << " Side [" << sim_side << "]" ); - - if ( sim_stationPhi==0 ) { - ATH_MSG_ERROR("unexpected phi range: " << sim_stationPhi); - return StatusCode::FAILURE; - } - // Current [7/12/12] implementation of the Station Name is: T[0-3][L/S][P/C] - int detNumber = -999, wedgeId = -999, wedgeType = -999; - if(sim_stationName.length()!=4) { - ATH_MSG_WARNING("sTGC validation: station Name exceeds 4 charactes, filling dummy information for detNumber, wedgeId and wedgeType"); - } - else { - detNumber = atoi(sim_stationName.substr(1,1).c_str()); - wedgeId = (sim_stationName.substr(2,1).compare("L")) ? 0 : 1; - wedgeType = (sim_stationName.substr(3,1).compare("P")) ? 0 : 1; - } - - // Fill Ntuple with SimId data - m_NSWsTGC_sim_stationName ->push_back(sim_stationName); - m_NSWsTGC_sim_stationEta ->push_back(sim_stationEta); - m_NSWsTGC_sim_stationPhi ->push_back(sim_stationPhi); - m_NSWsTGC_wedgeId ->push_back(wedgeId); - m_NSWsTGC_wedgeType ->push_back(wedgeType); - m_NSWsTGC_detectorNumber ->push_back(detNumber); - m_NSWsTGC_sim_multilayer ->push_back(sim_multilayer); - m_NSWsTGC_sim_layer ->push_back(sim_layer); - m_NSWsTGC_sim_side ->push_back(sim_side); - - // convert simHit id to offline id; make sanity checks; retrieve the associated detector element. - Identifier offId = simToOffline.convert(hit.GenericId()); - if( !m_sTgcIdHelper->is_stgc(offId) ){ - ATH_MSG_WARNING("sTgc id is not a stgc id! " << m_sTgcIdHelper->print_to_string(offId)); - } - if( !m_sTgcIdHelper->is_muon(offId) ){ - ATH_MSG_WARNING("sTgc id is not a muon id! " << m_sTgcIdHelper->print_to_string(offId)); - } - if( m_sTgcIdHelper->is_mdt(offId)||m_sTgcIdHelper->is_rpc(offId)||m_sTgcIdHelper->is_tgc(offId)||m_sTgcIdHelper->is_csc(offId)||m_sTgcIdHelper->is_mm(offId) ){ - ATH_MSG_WARNING("sTgc id has wrong technology type! " << m_sTgcIdHelper->is_mdt(offId) << " " << m_sTgcIdHelper->is_rpc(offId) - << " " << m_sTgcIdHelper->is_tgc(offId) << " " << m_sTgcIdHelper->is_csc(offId) << " " << m_sTgcIdHelper->is_mm(offId) ); - } - if( m_sTgcIdHelper->gasGap(offId) != sim_layer ) { - ATH_MSG_WARNING("sTgc id has bad layer field! " << m_sTgcIdHelper->print_to_string(offId) ); - } - - std::string stName = m_sTgcIdHelper->stationNameString(m_sTgcIdHelper->stationName(offId)); - int off_stationEta = m_sTgcIdHelper->stationEta(offId); - int off_stationPhi = m_sTgcIdHelper->stationPhi(offId); - int off_multiplet = m_sTgcIdHelper->multilayer(offId); - int off_gas_gap = m_sTgcIdHelper->gasGap(offId); - int off_channel_type = m_sTgcIdHelper->channelType(offId); - int off_channel = m_sTgcIdHelper->channel(offId); - - ATH_MSG_DEBUG( "sTGC Offline id: Station Name [" << stName << "]" - << " Station Eta [" << off_stationEta << "]" - << " Station Phi [" << off_stationPhi << "]" - << " Multiplet [" << off_multiplet << "]" - << " GasGap [" << off_gas_gap << "]" - << " Type [" << off_channel_type << "]" - << " ChNr [" << off_channel << "]" ); - - int isSmall = stName[2] == 'S'; - - 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) ); - - 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; - } - // 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 ){ + + // Read information about the sTGC hits; make sanity checks and printout + int simId = hit.GenericId(); + std::string sim_stationName = hitHelper->GetStationName(simId); + int sim_stationEta = hitHelper->GetZSector(simId); + int sim_stationPhi = hitHelper->GetPhiSector(simId); + int sim_multilayer = hitHelper->GetMultiLayer(simId); + int sim_layer = hitHelper->GetLayer(simId); + int sim_side = hitHelper->GetSide(simId); + + ATH_MSG_DEBUG( "sTGC SimHit id: Station Name [" << sim_stationName << " ]" + << " Station Eta [" << sim_stationEta << "]" + << " Station Phi [" << sim_stationPhi << "]" + << " MultiLayer [" << sim_multilayer << "]" + << " Layer [" << sim_layer << "]" + << " Side [" << sim_side << "]" ); + + if ( sim_stationPhi==0 ) { + ATH_MSG_ERROR("unexpected phi range: " << sim_stationPhi); + return StatusCode::FAILURE; + } + // Current [7/12/12] implementation of the Station Name is: T[0-3][L/S][P/C] + int detNumber = -999, wedgeId = -999, wedgeType = -999; + if(sim_stationName.length()!=4) { + ATH_MSG_WARNING("sTGC validation: station Name exceeds 4 charactes, filling dummy information for detNumber, wedgeId and wedgeType"); + } + else { + detNumber = atoi(sim_stationName.substr(1,1).c_str()); + wedgeId = (sim_stationName.substr(2,1).compare("L")) ? 0 : 1; + wedgeType = (sim_stationName.substr(3,1).compare("P")) ? 0 : 1; + } + + + // convert simHit id to offline id; make sanity checks; retrieve the associated detector element. + Identifier offId = simToOffline.convert(hit.GenericId()); + if( type == 2 && abs(m_sTgcIdHelper->stationEta(offId)) < 3 ) continue; + + std::string stName = m_sTgcIdHelper->stationNameString(m_sTgcIdHelper->stationName(offId)); + int off_stationEta = m_sTgcIdHelper->stationEta(offId); + int off_stationPhi = m_sTgcIdHelper->stationPhi(offId); + int off_multiplet = m_sTgcIdHelper->multilayer(offId); + int off_gas_gap = m_sTgcIdHelper->gasGap(offId); + int off_channel_type = m_sTgcIdHelper->channelType(offId); + int off_channel = m_sTgcIdHelper->channel(offId); + + int isSmall = stName[2] == 'S'; + + 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; + } + + if( !m_sTgcIdHelper->is_stgc(offId) ){ + ATH_MSG_WARNING("sTgc id is not a stgc id! " << m_sTgcIdHelper->print_to_string(offId)); + } + if( !m_sTgcIdHelper->is_muon(offId) ){ + ATH_MSG_WARNING("sTgc id is not a muon id! " << m_sTgcIdHelper->print_to_string(offId)); + } + if( m_sTgcIdHelper->is_mdt(offId)||m_sTgcIdHelper->is_rpc(offId)||m_sTgcIdHelper->is_tgc(offId)||m_sTgcIdHelper->is_csc(offId)||m_sTgcIdHelper->is_mm(offId) ){ + ATH_MSG_WARNING("sTgc id has wrong technology type! " << m_sTgcIdHelper->is_mdt(offId) << " " << m_sTgcIdHelper->is_rpc(offId) + << " " << m_sTgcIdHelper->is_tgc(offId) << " " << m_sTgcIdHelper->is_csc(offId) << " " << m_sTgcIdHelper->is_mm(offId) ); + } + if( m_sTgcIdHelper->gasGap(offId) != sim_layer ) { + ATH_MSG_WARNING("sTgc id has bad layer field! " << m_sTgcIdHelper->print_to_string(offId) ); + } + // connect the hit with the MC truth + int barcode = hit.particleLink().barcode(); + m_NSWsTGC_trackId->push_back(barcode); + + m_NSWsTGC_globalTime->push_back(hit.globalTime()); + const Amg::Vector3D globalPosition = hit.globalPosition(); + m_NSWsTGC_hitGlobalPositionX->push_back(globalPosition.x()); + m_NSWsTGC_hitGlobalPositionY->push_back(globalPosition.y()); + m_NSWsTGC_hitGlobalPositionZ->push_back(globalPosition.z()); + m_NSWsTGC_hitGlobalPositionR->push_back(globalPosition.perp()); + m_NSWsTGC_hitGlobalPositionP->push_back(globalPosition.phi()); + const Amg::Vector3D globalDirection = hit.globalDirection(); + m_NSWsTGC_hitGlobalDirectionX->push_back(globalDirection.x()); + m_NSWsTGC_hitGlobalDirectionY->push_back(globalDirection.y()); + m_NSWsTGC_hitGlobalDirectionZ->push_back(globalDirection.z()); + + const Amg::Vector3D localPosition = hit.localPosition(); + m_NSWsTGC_hitLocalPositionX->push_back(localPosition.x()); + m_NSWsTGC_hitLocalPositionY->push_back(localPosition.y()); + m_NSWsTGC_hitLocalPositionZ->push_back(localPosition.z()); + + m_NSWsTGC_particleEncoding->push_back(hit.particleEncoding()); + m_NSWsTGC_kineticEnergy->push_back(hit.kineticEnergy()); + m_NSWsTGC_depositEnergy->push_back(hit.depositEnergy()); + m_NSWsTGC_StepLength->push_back(hit.StepLength()); + + + // Fill Ntuple with SimId data + m_NSWsTGC_sim_stationName ->push_back(sim_stationName); + m_NSWsTGC_sim_stationEta ->push_back(sim_stationEta); + m_NSWsTGC_sim_stationPhi ->push_back(sim_stationPhi); + m_NSWsTGC_wedgeId ->push_back(wedgeId); + m_NSWsTGC_wedgeType ->push_back(wedgeType); + m_NSWsTGC_detectorNumber ->push_back(detNumber); + m_NSWsTGC_sim_multilayer ->push_back(sim_multilayer); + m_NSWsTGC_sim_layer ->push_back(sim_layer); + m_NSWsTGC_sim_side ->push_back(sim_side); + + ATH_MSG_DEBUG( "sTGC Offline id: Station Name [" << stName << "]" + << " Station Eta [" << off_stationEta << "]" + << " Station Phi [" << off_stationPhi << "]" + << " Multiplet [" << off_multiplet << "]" + << " GasGap [" << off_gas_gap << "]" + << " Type [" << off_channel_type << "]" + << " ChNr [" << off_channel << "]" ); + + 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) ); + + 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 @@ -189,7 +189,6 @@ StatusCode sTGCSimHitVariables::fillVariables() 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(); @@ -265,7 +264,6 @@ StatusCode sTGCSimHitVariables::clearVariables() { m_NSWsTGC_nSimHits = 0; m_NSWsTGC_trackId->clear(); - m_NSWsTGC_truthEl->clear(); m_NSWsTGC_globalTime->clear(); m_NSWsTGC_hitGlobalPositionX->clear(); @@ -331,7 +329,6 @@ StatusCode sTGCSimHitVariables::clearVariables() void sTGCSimHitVariables::deleteVariables() { delete m_NSWsTGC_trackId; - delete m_NSWsTGC_truthEl; delete m_NSWsTGC_globalTime; delete m_NSWsTGC_hitGlobalPositionX; delete m_NSWsTGC_hitGlobalPositionY; @@ -363,13 +360,11 @@ void sTGCSimHitVariables::deleteVariables() delete m_NSWsTGC_FastDigitRsurfacePositionX; delete m_NSWsTGC_FastDigitRsurfacePositionY; - delete m_NSWsTGC_particleEncoding; delete m_NSWsTGC_kineticEnergy; delete m_NSWsTGC_depositEnergy; delete m_NSWsTGC_StepLength; - delete m_NSWsTGC_sim_stationName; delete m_NSWsTGC_sim_stationEta; delete m_NSWsTGC_sim_stationPhi; @@ -394,7 +389,6 @@ void sTGCSimHitVariables::deleteVariables() m_NSWsTGC_nSimHits = 0; m_NSWsTGC_trackId = nullptr; - m_NSWsTGC_truthEl = nullptr; m_NSWsTGC_globalTime = nullptr; m_NSWsTGC_hitGlobalPositionX = nullptr; @@ -459,7 +453,6 @@ StatusCode sTGCSimHitVariables::initializeVariables() { m_NSWsTGC_nSimHits = 0; m_NSWsTGC_trackId = new std::vector<int>(); - m_NSWsTGC_truthEl = new std::vector<int>(); m_NSWsTGC_globalTime = new std::vector<double>; m_NSWsTGC_hitGlobalPositionX = new std::vector<double>; @@ -521,7 +514,6 @@ StatusCode sTGCSimHitVariables::initializeVariables() if(m_tree) { m_tree->Branch("Hits_sTGC_n", &m_NSWsTGC_nSimHits, "Hits_sTGC_nSimHits/i"); m_tree->Branch("Hits_sTGC_trackId", &m_NSWsTGC_trackId); - m_tree->Branch("Hits_sTGC_truthEl", &m_NSWsTGC_truthEl); m_tree->Branch("Hits_sTGC_globalTime", &m_NSWsTGC_globalTime); m_tree->Branch("Hits_sTGC_hitGlobalPositionX", &m_NSWsTGC_hitGlobalPositionX); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.h b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.h index d5000620d340471cea3f194799d6a494ce020a23..86029f9b9af6b83c25ffda2c3cbee4c0f96ae429 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.h +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/sTGCSimHitVariables.h @@ -22,7 +22,6 @@ class sTGCSimHitVariables : public ValAlgVariables m_sTgcIdHelper(0), m_NSWsTGC_nSimHits(0), m_NSWsTGC_trackId(0), - m_NSWsTGC_truthEl(0), m_NSWsTGC_globalTime(0), m_NSWsTGC_hitGlobalPositionX(0), m_NSWsTGC_hitGlobalPositionY(0), @@ -100,7 +99,6 @@ class sTGCSimHitVariables : public ValAlgVariables int m_NSWsTGC_nSimHits; std::vector<int> *m_NSWsTGC_trackId; - std::vector<int> *m_NSWsTGC_truthEl; std::vector<double> *m_NSWsTGC_globalTime; std::vector<double> *m_NSWsTGC_hitGlobalPositionX;