From c08d9a03a7598741b5acb583ee014208436ed049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20K=C3=B6hler?= <nicolas.koehler@cern.ch> Date: Fri, 31 Jan 2020 16:05:01 +0100 Subject: [PATCH 1/2] move from MuonIdHelperTool to MuonIdHelperSvc --- .../MuonCalibAlgs/MuonCalibAlg.h | 3 +- .../MuonCalibDbOperations/CoolInserter.h | 10 +- .../src/CoolInserter.cxx | 83 ++++----- .../SegmentOnTrackSelector.h | 6 +- .../src/SegmentOnTrackSelector.cxx | 31 +--- .../MuonSegmentToCalibSegment.h | 13 +- .../src/MuonSegmentToCalibSegment.cxx | 166 +++++------------- .../MuonCalibGeometryDumper.h | 23 +-- .../SegmentRawdataSelector.h | 17 +- .../CalibNtupleAnalysisAlg/WriteMdtGeometry.h | 18 +- .../src/MuonCalibGeometryDumper.cxx | 50 +++--- .../src/SegmentRawdataSelector.cxx | 29 +-- .../src/WriteMdtGeometry.cxx | 55 ++---- 13 files changed, 156 insertions(+), 348 deletions(-) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h index 2e2e6b0d3cd4..ad21ab69631f 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibAlgs/MuonCalibAlgs/MuonCalibAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONCALIB_MUONCALIBALG_H @@ -12,7 +12,6 @@ #include "MuonCalibEventBase/MuonCalibEvent.h" #include "MuonPrdSelector/MuonIdCutTool.h" #include "MuonIdHelpers/IMuonIdHelperSvc.h" -/* #include "StoreGate/ReadCondHandleKey.h" */ #include "MuonReadoutGeometry/MuonDetectorManager.h" class ICscStripFitter; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/MuonCalibDbOperations/CoolInserter.h b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/MuonCalibDbOperations/CoolInserter.h index e9d9e905e2e5..d094588a02ac 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/MuonCalibDbOperations/CoolInserter.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/MuonCalibDbOperations/CoolInserter.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MuonCalib_CoolInserter_h @@ -11,7 +11,7 @@ //athena #include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" // COOL API: database service bootstrap #include "CoolApplication/Application.h" @@ -28,11 +28,10 @@ #include "CoolKernel/types.h" #include "CoolKernel/Record.h" - //MuonCalibStandAloneBase #include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class RegionSelectionSvc; @@ -93,8 +92,7 @@ class CoolInserter : public AthAlgorithm { bool m_cool_connect, m_t0_created, m_rt_created; //already filled chambers - do not double fill std::set<NtupleStationId> m_t0_filled, m_rt_filled; - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/src/CoolInserter.cxx b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/src/CoolInserter.cxx index 986bc8e2097f..c3e267ca36a5 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/src/CoolInserter.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/src/CoolInserter.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //this @@ -24,12 +24,8 @@ //MuonCalibStandAloneBase #include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/IMessageSvc.h" -#include "StoreGate/StoreGateSvc.h" - #include "MuonReadoutGeometry/MdtReadoutElement.h" + //c - c++ #include "iostream" #include "sstream" @@ -61,65 +57,50 @@ CoolInserter::CoolInserter(const std::string& name, ISvcLocator* pSvcLocator) : } StatusCode CoolInserter::initialize() { - MsgStream log(msgSvc(), name()); //check jo if(m_tagt0.size() != m_t0_folder.size() || m_tagrt.size() != m_rt_folder.size()) { - log << MSG::FATAL << "Configuration error: Number of folders and tags do not match!"<< endmsg; + ATH_MSG_FATAL("Configuration error: Number of folders and tags do not match!"); return StatusCode::FAILURE; } - StoreGateSvc * detStore; - StatusCode sc=service("DetectorStore", detStore); - if(!sc.isSuccess()) { - log << MSG::FATAL << "Cannot retrieve Store Gate!" << endmsg; - return sc; - } - - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + + ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_DetectorManagerKey.initialize()); -//get region selection service - sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve RegionSelectionSvc!" <<endmsg; - return sc; - } -//connect to cool database + //get region selection service + ATH_CHECK(service("RegionSelectionSvc", p_reg_sel_svc)); + + //connect to cool database try { m_db = m_app.databaseService().openDatabase(m_cool_connection_string ,false ); } catch ( cool::DatabaseDoesNotExist & e ) { - log<<MSG::INFO<<"Creating new database."<<endmsg; + ATH_MSG_INFO("Creating new database."); try { m_db = m_app.databaseService().createDatabase(m_cool_connection_string); } catch(cool::Exception & e) { - log << MSG::FATAL << "Cannot create database and datbasae does not exist!" << endmsg; + ATH_MSG_FATAL("Cannot create database and datbasae does not exist!"); return StatusCode::FAILURE; } } m_cool_connect=true; if(m_t0_folder.size()) { - log << MSG::INFO <<"Replication into t0 folders: "; + ATH_MSG_INFO("Replication into t0 folders: "); for(unsigned int i=0; i<m_t0_folder.size(); i++) { - log<<m_t0_folder[i] << "(" << m_tagt0[i] << ") "; + ATH_MSG_INFO(m_t0_folder[i] << "(" << m_tagt0[i] << ") "); } - log<<endmsg; } if(m_rt_folder.size()) { - log << MSG::INFO <<"Replication into rt folders: "; + ATH_MSG_INFO("Replication into rt folders: "); for(unsigned int i=0; i<m_rt_folder.size(); i++) { - log<<m_rt_folder[i] << "(" << m_tagrt[i] << ") "; + ATH_MSG_INFO(m_rt_folder[i] << "(" << m_tagrt[i] << ") "); } - log<<endmsg; } -//retrieve calibration sources - sc=m_calibration_sources.retrieve(); - if(!sc.isSuccess()) { - log << MSG::FATAL <<"Cannot retrieve calibration sources!"<<endmsg; - return sc; - } -//get iov + //retrieve calibration sources + ATH_CHECK(m_calibration_sources.retrieve()); + + //get iov for(unsigned int i=0; i<m_calibration_sources.size(); i++) { int iov_start(-1), iov_end(-1); m_calibration_sources[i]->SetIOV(iov_start, iov_end); @@ -129,7 +110,7 @@ StatusCode CoolInserter::initialize() { m_iov_end = iov_end; } if(m_iov_start<0 || m_iov_end==-1) { - log << MSG::FATAL << "IOV has to be set, if no calibration source provides it!"<<endmsg; + ATH_MSG_FATAL("IOV has to be set, if no calibration source provides it!"); return StatusCode::FAILURE; } IOVTime start(m_iov_start, 0); @@ -141,8 +122,8 @@ StatusCode CoolInserter::initialize() { IOVTime end(m_iov_end, 0); m_iovt_end = end.re_time(); } - log << MSG::INFO << "IOV is "<<m_iov_start<<" to "<<m_iov_end<<endmsg; -//fill compressed flags + ATH_MSG_INFO("IOV is "<<m_iov_start<<" to "<<m_iov_end); + //fill compressed flags if(m_compressed_t0.size() < m_t0_folder.size()) for(unsigned int i=m_compressed_t0.size(); i<m_t0_folder.size(); i++) m_compressed_t0.push_back(false); @@ -153,8 +134,7 @@ StatusCode CoolInserter::initialize() { } StatusCode CoolInserter::finalize() { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "finalizing "<<endmsg; + ATH_MSG_INFO("finalizing "); try { for(unsigned int i=0; i<m_mdtt0_fld.size(); i++) m_mdtt0_fld[i]->flushStorageBuffer(); @@ -162,18 +142,17 @@ StatusCode CoolInserter::finalize() { m_mdtrt_fld[i]->flushStorageBuffer(); } catch(std::exception & e) { - log << MSG::FATAL << "Exception in finalize: " << e.what() <<endmsg; + ATH_MSG_FATAL("Exception in finalize: " << e.what()); return StatusCode::FAILURE; } return StatusCode::SUCCESS; } StatusCode CoolInserter::execute() { - MsgStream log(msgSvc(), name()); for(unsigned int i=0; i<m_calibration_sources.size(); i++) { - log << MSG::INFO << "Now running " <<m_calibration_sources[i] <<endmsg; + ATH_MSG_INFO("Now running " <<m_calibration_sources[i]); if (!m_calibration_sources[i]->InstertCalibration(this, static_cast<bool>(m_t0_folder.size()), static_cast<bool>(m_rt_folder.size()))) { - log << MSG::FATAL << "Calibration Source " << m_calibration_sources[i].name() << " failed!" << endmsg; + ATH_MSG_FATAL("Calibration Source " << m_calibration_sources[i].name() << " failed!"); return StatusCode::FAILURE; } } @@ -192,7 +171,7 @@ bool CoolInserter::StartT0Chamber(const NtupleStationId & sid) { return false; } - if (!m_sid.InitializeGeometry(m_muonIdHelperTool->mdtIdHelper(), MuonDetMgr)) + if (!m_sid.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) return false; //get number of tubes int max_nly(-1); @@ -224,7 +203,6 @@ bool CoolInserter::AppendT0(float t0, int validflag, float adc0) { } bool CoolInserter::StoreT0Chamber(const NtupleStationId & id, const std::string & file, unsigned int creation_flags) { - MsgStream log(msgSvc(), name()); MuonFixedId fid(id.FixedId()); //generate fixed if for chamber if(!p_reg_sel_svc->isInRegion(fid)) { @@ -237,7 +215,7 @@ bool CoolInserter::StoreT0Chamber(const NtupleStationId & id, const std::string m_t0_filled.insert(id); //check number of added tubes if (m_n_tubes_added < m_n_tubes_chamber) { - log << MSG::WARNING << "Filling missing tubes with average for chamber" << m_sid.regionId()<<endmsg; + ATH_MSG_WARNING("Filling missing tubes with average for chamber" << m_sid.regionId()); m_aver_t0/=m_n_tubes_added; m_aver_adc/=m_n_tubes_added; for(int i=m_n_tubes_added; i<m_n_tubes_chamber; i++) { @@ -249,7 +227,7 @@ bool CoolInserter::StoreT0Chamber(const NtupleStationId & id, const std::string for(unsigned int i=0; i<m_t0_folder.size(); i++) { if(!m_db->existsFolder(m_t0_folder[i])) { if(!create_folder(i, false)) { - log << MSG::FATAL << "Cannot create folder '" << m_t0_folder[i] <<"'!"<<endmsg; + ATH_MSG_FATAL("Cannot create folder '" << m_t0_folder[i] <<"'!"); return false; } } @@ -296,7 +274,6 @@ bool CoolInserter::StoreT0Chamber(const NtupleStationId & id, const std::string } bool CoolInserter::StoreRtChamber(const NtupleStationId & id, const std::map<int, SamplePoint> & points, const std::string & file, unsigned int creation_flags) { - MsgStream log(msgSvc(), name()); //generate fixed if for chamber MuonFixedId fid(id.FixedId()); if(!p_reg_sel_svc->isInRegion(fid)) { @@ -332,7 +309,7 @@ bool CoolInserter::StoreRtChamber(const NtupleStationId & id, const std::map<int if(!m_db->existsFolder(m_rt_folder[i])) { if(!create_folder(i, true)) { - log << MSG::FATAL << "Cannot create folder '" << m_rt_folder[i] <<"'!"<<endmsg; + ATH_MSG_FATAL("Cannot create folder '" << m_rt_folder[i] <<"'!"); return false; } } diff --git a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/MuonCalibExtraTreeAlg/SegmentOnTrackSelector.h b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/MuonCalibExtraTreeAlg/SegmentOnTrackSelector.h index 505a2d0d4550..b5a6065d8324 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/MuonCalibExtraTreeAlg/SegmentOnTrackSelector.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/MuonCalibExtraTreeAlg/SegmentOnTrackSelector.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MuonCalib_SegmentOnTrackSelector_h @@ -15,7 +15,7 @@ #include "GaudiKernel/ServiceHandle.h" #include "MuonCalibExtraTreeAlg/ISegmentOnTrackSelector.h" #include "MuonRecHelperTools/IMuonEDMHelperSvc.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" namespace Trk { class Track; @@ -49,7 +49,7 @@ class SegmentOnTrackSelector: public AthAlgTool, virtual public ISegmentOnTrackS "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc", "Handle to the service providing the IMuonEDMHelperSvc interface" }; ToolHandle<IIdToFixedIdTool> m_idToFixedIdTool; - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; //internal data structures std::vector<std::set<MuonFixedId> > m_segment_hits; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/SegmentOnTrackSelector.cxx b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/SegmentOnTrackSelector.cxx index f4b1dce445ab..ec7dc17094bc 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/SegmentOnTrackSelector.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/SegmentOnTrackSelector.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "MuonCalibExtraTreeAlg/SegmentOnTrackSelector.h" @@ -7,11 +7,8 @@ #include "MuonCalibEvent/MuonCalibPatternCollection.h" #include "MuonCalibEventBase/MuonCalibPattern.h" #include "MuonCalibEventBase/MuonCalibSegment.h" -//MuonCalibITools #include "MuonCalibITools/IIdToFixedIdTool.h" -//MuonRecHelperTools #include "MuonRecHelperTools/IMuonEDMHelperSvc.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" #include "MuonCalibIdentifier/MuonFixedId.h" namespace MuonCalib { @@ -21,15 +18,13 @@ SegmentOnTrackSelector::SegmentOnTrackSelector(const std::string &type,const std m_pattern_location(""), m_min_hits_on_track(3), m_max_hits_not_on_track(1), - m_idToFixedIdTool("MuonCalib::IdToFixedIdTool"), - m_muonIdHelperTool("Muon::MuonIdHelperTool") + m_idToFixedIdTool("MuonCalib::IdToFixedIdTool") { declareInterface<ISegmentOnTrackSelector>(this); declareProperty("PattternLocation", m_pattern_location); declareProperty("MinHitsOnTrack", m_min_hits_on_track); declareProperty("MaxHitsNotOnTrack", m_max_hits_not_on_track); declareProperty("IdToFixedIdTool", m_idToFixedIdTool); - declareProperty("MuonIdHelperTool", m_muonIdHelperTool); } StatusCode SegmentOnTrackSelector::initialize() { @@ -37,20 +32,12 @@ StatusCode SegmentOnTrackSelector::initialize() { ATH_MSG_FATAL("Cannot run without patterns!"); return StatusCode::FAILURE; } - if(!m_edmHelperSvc.retrieve().isSuccess()) { - ATH_MSG_FATAL("Cannot retrieve muon EDM helper!"); - return StatusCode::FAILURE; - } - if(!m_idToFixedIdTool.retrieve().isSuccess()) { - ATH_MSG_FATAL("Cannot retrieve idToFixedId tool"); - return StatusCode::FAILURE; - } - if(!m_muonIdHelperTool.retrieve().isSuccess()) { - ATH_MSG_FATAL("Cannot retrieve id helper tool tool"); - return StatusCode::FAILURE; - } + ATH_CHECK(m_edmHelperSvc.retrieve()); + ATH_CHECK(m_idToFixedIdTool.retrieve()); + ATH_CHECK(m_idHelperSvc.retrieve()); + return StatusCode::SUCCESS; -} //end SegmentOnTrackSelector::initialize +} StatusCode SegmentOnTrackSelector::finalize() { return StatusCode::SUCCESS; @@ -128,8 +115,8 @@ inline void SegmentOnTrackSelector::getIdentifiers(const Trk::Track &tk, std::se continue; const Trk::MeasurementBase* measurement = (*tsit)->measurementOnTrack(); Identifier id = m_edmHelperSvc->getIdentifier(*measurement); - if(!m_muonIdHelperTool->isMuon(id)) continue; - if(!m_muonIdHelperTool->isMdt(id) && !m_muonIdHelperTool->isCsc(id)) continue; + if(!m_idHelperSvc->isMuon(id)) continue; + if(!m_idHelperSvc->isMdt(id) && !m_idHelperSvc->isCsc(id)) continue; ids.insert(m_idToFixedIdTool->idToFixedId(id)); } } //end SegmentOnTrackSelector::getIdentifiers diff --git a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/MuonCalibPatRec/MuonSegmentToCalibSegment.h b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/MuonCalibPatRec/MuonSegmentToCalibSegment.h index 968df06d6303..15a94796e2e5 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/MuonCalibPatRec/MuonSegmentToCalibSegment.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/MuonCalibPatRec/MuonSegmentToCalibSegment.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONCALIB_MUONSEGMENTTOCALIBSEGMENT_H #define MUONCALIB_MUONSEGMENTTOCALIBSEGMENT_H #include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +18,7 @@ #include "MuonCalibITools/IIdToFixedIdTool.h" #include "MuonRecToolInterfaces/IMuonPatternSegmentAssociationTool.h" #include "MdtCalibSvc/MdtCalibrationTool.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" namespace Muon{ @@ -36,6 +37,7 @@ output the muon calibration input. public: /** Algorithm constructor */ MuonSegmentToCalibSegment(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~MuonSegmentToCalibSegment()=default; /** Algorithm initialize */ StatusCode initialize(); @@ -43,9 +45,6 @@ output the muon calibration input. /** Algorithm execute, called once per event */ StatusCode execute(); - /** Algorithm finalize */ - StatusCode finalize(); - private: /** retrieve patterns and segments from storegate */ // const Muon::MuonSegmentCollection* retrieveSegments(); @@ -93,9 +92,7 @@ output the muon calibration input. "MuonDetectorManager", "Key of input MuonDetectorManager condition data"}; - /** Tool for the Identifier Helpers */ - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; /** pointer to MdtCalibSvc */ ToolHandle<MdtCalibrationTool> m_calibrationTool; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx index b94769feef5d..914aad132c4b 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibPatRec/src/MuonSegmentToCalibSegment.cxx @@ -1,20 +1,9 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "MuonCalibPatRec/MuonSegmentToCalibSegment.h" -// gaudi -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/ISvcLocator.h" - -// idhelpers -#include "Identifier/Identifier.h" -#include "MuonIdHelpers/MdtIdHelper.h" -#include "MuonIdHelpers/CscIdHelper.h" -#include "MuonIdHelpers/RpcIdHelper.h" -#include "MuonIdHelpers/TgcIdHelper.h" - // muon geomodel #include "MuonRecToolInterfaces/IMuonPatternSegmentAssociationTool.h" @@ -91,35 +80,16 @@ namespace MuonCalib { } // Initialize - StatusCode MuonSegmentToCalibSegment::initialize(){ - // - if(m_segmentLocationVector.value().size() < m_segment_authors.size()) - { - m_segment_authors.resize(m_segmentLocationVector.value().size(), -1); - } -/* m_log << MSG::INFO << "Initialisation started " << endmsg; - // - // - m_log << MSG::INFO << "================================" << endmsg; - m_log << MSG::INFO << "= Proprieties are " << endmsg; - std::vector<std::string>::const_iterator segLocit = m_segmentLocationVector.value().begin(); - std::vector<std::string>::const_iterator segLocit_end = m_segmentLocationVector.value().end(); - for ( ; segLocit != segLocit_end ; ++segLocit) { - m_log << MSG::INFO << "= SegmentLocation " << *segLocit << endmsg; + StatusCode MuonSegmentToCalibSegment::initialize() { + if(m_segmentLocationVector.value().size() < m_segment_authors.size()) { + m_segment_authors.resize(m_segmentLocationVector.value().size(), -1); } - m_log << MSG::INFO << "= SegmentCscLocation " << m_segmentCscLocation << endmsg; - m_log << MSG::INFO << "= SegmentCombiLocation " << m_segmentCombiLocation << endmsg; - - m_log << MSG::INFO << "= PatternLocation " << m_patternLocation << endmsg; - m_log << MSG::INFO << "================================" << endmsg;*/ std::string managerName="Muon"; ATH_CHECK(m_DetectorManagerKey.initialize()); - ATH_CHECK( m_idToFixedIdTool.retrieve() ); - ATH_CHECK( m_assocTool.retrieve() ); - - // initialize MuonIdHelperTool - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK(m_idToFixedIdTool.retrieve() ); + ATH_CHECK(m_assocTool.retrieve()); + ATH_CHECK(m_idHelperSvc.retrieve()); // Get the maximum number of segments each algorithm can // store in the ntuple @@ -141,11 +111,6 @@ namespace MuonCalib { return StatusCode::SUCCESS; } - StatusCode MuonSegmentToCalibSegment::finalize(){ - ATH_MSG_DEBUG( "Finalisation started " ); - return StatusCode::SUCCESS; - } - StatusCode MuonSegmentToCalibSegment::savePatterns( const MuonCalibPatternCollection* newPatterns) const { ATH_CHECK( evtStore()->record(newPatterns, m_patternLocation) ); @@ -205,12 +170,7 @@ namespace MuonCalib { Muon::MuonSegmentCombination::SegmentVec* stationSegs = (*sit)->stationSegments( i ) ; ATH_MSG_VERBOSE( "New station with " << stationSegs->size() << " segments " ); - - // if( stationSegs->size() != 1 ) { - // m_log << MSG::DEBUG << " -> skipping station, to many segments " << endmsg; - // continue; - // } - + Muon::MuonSegmentCombination::SegmentVec::iterator segit = stationSegs->begin(); Muon::MuonSegmentCombination::SegmentVec::iterator segit_end = stationSegs->end(); @@ -305,8 +265,6 @@ namespace MuonCalib { ATH_CHECK( savePatterns(patterns) ); return StatusCode::SUCCESS; } - - // m_segmentAuthor = segmentAuthor(m_segmentCscLocation); MuonSegmentCombinationCollection::const_iterator sit = segCombis->begin(); MuonSegmentCombinationCollection::const_iterator sit_end = segCombis->end(); @@ -341,11 +299,6 @@ namespace MuonCalib { ATH_MSG_VERBOSE( "New Csc station with " << stationSegs->size() << " segments " ); - // if( stationSegs->size() != 1 ) { - // m_log << MSG::DEBUG << " -> skipping station, too many segments " << endmsg; - // continue; - // } - Muon::MuonSegmentCombination::SegmentVec::iterator segit = stationSegs->begin(); Muon::MuonSegmentCombination::SegmentVec::iterator segit_end = stationSegs->end(); @@ -368,7 +321,7 @@ namespace MuonCalib { } - }//if(m_useCscSegments) + } // store patterns in storegate ATH_CHECK( savePatterns(patterns) ); return StatusCode::SUCCESS; @@ -391,9 +344,9 @@ namespace MuonCalib { // use pointer to rot const Trk::RIO_OnTrack* rot = *rit; - if( m_muonIdHelperTool->mdtIdHelper().is_mdt( rot->identify() ) ){ + if( m_idHelperSvc->mdtIdHelper().is_mdt( rot->identify() ) ){ return rot->identify(); - }else if( m_muonIdHelperTool->cscIdHelper().is_csc( rot->identify() ) ){ + }else if( m_idHelperSvc->cscIdHelper().is_csc( rot->identify() ) ){ return rot->identify(); } } @@ -405,28 +358,28 @@ namespace MuonCalib { Amg::Transform3D MuonSegmentToCalibSegment::getGlobalToStation( const Identifier& id, const MuonGM::MuonDetectorManager* MuonDetMgr ) const { - if( m_muonIdHelperTool->mdtIdHelper().is_mdt( id ) ){ + if( m_idHelperSvc->mdtIdHelper().is_mdt( id ) ){ const MuonGM::MdtReadoutElement* detEl = MuonDetMgr->getMdtReadoutElement(id); if( !detEl ) { ATH_MSG_WARNING( "getGlobalToStation failed to retrieve detEL byebye" ); }else{ return detEl->GlobalToAmdbLRSTransform(); } - }else if( m_muonIdHelperTool->cscIdHelper().is_csc( id ) ){ + }else if( m_idHelperSvc->cscIdHelper().is_csc( id ) ){ const MuonGM::CscReadoutElement* detEl = MuonDetMgr->getCscReadoutElement(id); if( !detEl ) { ATH_MSG_WARNING( "getGlobalToStation failed to retrieve detEL byebye" ); }else{ return detEl->transform().inverse(); } - }else if( m_muonIdHelperTool->tgcIdHelper().is_tgc( id ) ){ + }else if( m_idHelperSvc->tgcIdHelper().is_tgc( id ) ){ const MuonGM::TgcReadoutElement* detEl = MuonDetMgr->getTgcReadoutElement(id); if( !detEl ) { ATH_MSG_WARNING( "getGlobalToStation failed to retrieve detEL byebye" ); }else{ return detEl->transform().inverse(); } - }else if( m_muonIdHelperTool->rpcIdHelper().is_rpc( id ) ){ + }else if( m_idHelperSvc->rpcIdHelper().is_rpc( id ) ){ const MuonGM::RpcReadoutElement* detEl = MuonDetMgr->getRpcReadoutElement(id); if( !detEl ) { ATH_MSG_WARNING( "getGlobalToStation failed to retrieve detEL byebye" ); @@ -517,9 +470,6 @@ namespace MuonCalib { Amg::Vector3D segPosL = gToStation*segPosG; Amg::Vector3D segDirL = gToStation.linear()*segDirG; Amg::Vector3D segDirLCheck = gToStationCheck.linear()*segDirG; - // std::cout << " local segment " << segPosL << " dir " << segDirL.unit() << std::endl; - // std::cout << " global segment " << segPosG << " dir " << segDirG.unit() << std::endl; -// bool mdtSegment = false; double qualityFactor(1e9); if( seg.fitQuality() ){ @@ -575,7 +525,7 @@ namespace MuonCalib { } else { continue;} } - if( m_muonIdHelperTool->mdtIdHelper().is_mdt(id)) { + if( m_idHelperSvc->mdtIdHelper().is_mdt(id)) { if (competingRio) { ATH_MSG_WARNING( " MDT hit is competing Rio !!! " ); continue; @@ -606,7 +556,6 @@ namespace MuonCalib { ATH_MSG_WARNING( "This has no StraightLineSurface !!! " ); continue; } -// mdtSegment = true; // Prd has no second coordinate Amg::Vector3D tubePosLoc = gToStation*prd->globalPosition(); @@ -636,7 +585,6 @@ namespace MuonCalib { Amg::Vector3D tubePosLocAtDCA = tubePosLoc + ScaleOnTube * tubeDirLoc ; Amg::Vector3D segPosLocAtDCA = segPosLoc + ScaleOnSeg * segDirLoc ; -// Amg::Vector3D tubePosAtDCA = gToStation.inverse()*tubePosLocAtDCA; Amg::Vector3D segPosAtDCA = gToStation.inverse()*segPosLocAtDCA ; @@ -676,7 +624,6 @@ namespace MuonCalib { tubePosLoc = tubePosLocAtDCA ; } -// const Trk::LocalPosition* lpos = prd->detectorElement()->surface(id).globalToLocal(mrot->globalPosition(), 5000 ); double xLocTwin(-99999999.); @@ -684,9 +631,9 @@ namespace MuonCalib { if( prd->localPosition()[Trk::locY] ){ Identifier test_prd_Id = prd->detectorElement()->identify(); ATH_MSG_DEBUG( " Twin Position : prd->localPosition()[Trk::locY] = " << prd->localPosition()[Trk::locY] - << " in station " << m_muonIdHelperTool->mdtIdHelper().stationNameString(m_muonIdHelperTool->mdtIdHelper().stationName(test_prd_Id)) - << " multilayer = " << m_muonIdHelperTool->mdtIdHelper().multilayer(test_prd_Id) << " layer = " << m_muonIdHelperTool->mdtIdHelper().tubeLayer(test_prd_Id) - << " tube = " << m_muonIdHelperTool->mdtIdHelper().tube(test_prd_Id) << " modulo4 = " << (m_muonIdHelperTool->mdtIdHelper().tube(test_prd_Id)%4) ); + << " in station " << m_idHelperSvc->mdtIdHelper().stationNameString(m_idHelperSvc->mdtIdHelper().stationName(test_prd_Id)) + << " multilayer = " << m_idHelperSvc->mdtIdHelper().multilayer(test_prd_Id) << " layer = " << m_idHelperSvc->mdtIdHelper().tubeLayer(test_prd_Id) + << " tube = " << m_idHelperSvc->mdtIdHelper().tube(test_prd_Id) << " modulo4 = " << (m_idHelperSvc->mdtIdHelper().tube(test_prd_Id)%4) ); Amg::Vector3D lposTrking(0.,0., prd->localPosition()[Trk::locY]); @@ -699,10 +646,6 @@ namespace MuonCalib { Amg::Vector3D tubePos = gToStation.inverse()*tubePosLoc; // If the wire is rotated wrt segmentsurface we need this transform -// Amg::Vector3D tubePos = detEl->surface(id).transform()*tubePosLoc; - - // std::cout << " loc pos " << tubePosLoc << " gpos " << tubePos << std::endl; - // get distance to readoud from detector manager double distRo_det = detEl->distanceFromRO(mrot->globalPosition(), id); @@ -732,14 +675,13 @@ namespace MuonCalib { t0Shift=seg.time(); } MdtCalibrationSvcInput input; - // if( m_doTof ) input.tof = tubePos.mag()/299.792458; if( m_doTof ) input.tof = calibHit.globalPointOfClosestApproach().mag()*(1./299.792458); input.trackDirection = &seg.globalDirection(); input.pointOfClosestApproach = &calibHit.globalPointOfClosestApproach(); bool sameChamber = false; if (cachedId.is_valid()) { - sameChamber = (m_muonIdHelperTool->mdtIdHelper().stationName(id) == m_muonIdHelperTool->mdtIdHelper().stationName(cachedId)) && (m_muonIdHelperTool->mdtIdHelper().stationEta(id) == m_muonIdHelperTool->mdtIdHelper().stationEta(cachedId)) && (m_muonIdHelperTool->mdtIdHelper().stationPhi(id) == m_muonIdHelperTool->mdtIdHelper().stationPhi(cachedId)); + sameChamber = (m_idHelperSvc->mdtIdHelper().stationName(id) == m_idHelperSvc->mdtIdHelper().stationName(cachedId)) && (m_idHelperSvc->mdtIdHelper().stationEta(id) == m_idHelperSvc->mdtIdHelper().stationEta(cachedId)) && (m_idHelperSvc->mdtIdHelper().stationPhi(id) == m_idHelperSvc->mdtIdHelper().stationPhi(cachedId)); } if (!sameChamber) ATH_MSG_DEBUG( "Moving to a new chamber! " << cachedId << " to " << id ); // We're done with the cached Id for now, so immediately reassign it @@ -791,7 +733,6 @@ namespace MuonCalib { } ATH_MSG_DEBUG( "B-field correction: " << calibHit.lorentzTime() ); - // std::cout << " Drift radius ROT " << rot->localParameters()[Trk::driftRadius] << " Calibsvc " << driftR <<std::endl; // fill distance to track calibHit.setDistanceToTrack( rtrk, 0. ); @@ -820,10 +761,7 @@ namespace MuonCalib { basehit->setSegmentT0Applied(apply_t0); mdtSeg->addHitOnTrack(basehit); - // std::cout << " MDT hit " << calibHit << std::endl; - // std::cout << " base hit " << *basehit << std::endl; - - }else if( m_muonIdHelperTool->rpcIdHelper().is_rpc( id ) ){ + }else if( m_idHelperSvc->rpcIdHelper().is_rpc( id ) ){ // rpc ROT ++nr; @@ -847,27 +785,23 @@ namespace MuonCalib { const Muon::RpcPrepData* rprd = rrot->prepRawData(); id = rprd->identify(); - // m_muonIdHelperTool->rpcIdHelper().print(id); int nStrips = rprd->rdoList().size(); // get detector element const MuonGM::RpcReadoutElement* detEl = rprd->detectorElement(); - double stripWidth = detEl->StripWidth( m_muonIdHelperTool->rpcIdHelper().measuresPhi(id )); + double stripWidth = detEl->StripWidth( m_idHelperSvc->rpcIdHelper().measuresPhi(id )); double time = rprd->time(); double error = sqrt( rrot->localCovariance()(0,0) ); Amg::Vector3D rgp = rrot->globalPosition(); -// if (competingRio) { -// error = sqrt( rotc->localCovariance()(0,0) ); -// rgp = rotc->globalPosition(); -// } + Amg::Vector3D rlp = gToStation*rgp; // get strip lengths - double stripLen = detEl->StripLength(m_muonIdHelperTool->rpcIdHelper().measuresPhi(id)); + double stripLen = detEl->StripLength(m_idHelperSvc->rpcIdHelper().measuresPhi(id)); double distRO; - if( m_muonIdHelperTool->rpcIdHelper().measuresPhi(id) ){ + if( m_idHelperSvc->rpcIdHelper().measuresPhi(id) ){ distRO = detEl->distanceToPhiReadout( rgp, id ); }else{ distRO = detEl->distanceToEtaReadout( rgp, id ); @@ -882,7 +816,7 @@ namespace MuonCalib { mdtSeg->addHitOnTrack( rpcCH ); } - }else if( m_muonIdHelperTool->tgcIdHelper().is_tgc( id ) ){ + }else if( m_idHelperSvc->tgcIdHelper().is_tgc( id ) ){ ++nt; int nRios = 1; @@ -906,17 +840,13 @@ namespace MuonCalib { const Muon::TgcPrepData* tprd = trot->prepRawData(); id = tprd->identify(); ATH_MSG_DEBUG( "TGC RIO " ); - // m_muonIdHelperTool->tgcIdHelper().print(id); int nStrips = tprd->rdoList().size(); -// if (competingRio) { -// nStrips = rotc->numberOfContainedROTs(); -// } double stripWidth; - bool measuresPhi = (bool) m_muonIdHelperTool->tgcIdHelper().isStrip(tprd->identify()); - int gasGap = m_muonIdHelperTool->tgcIdHelper().gasGap(tprd->identify()); - int channel = m_muonIdHelperTool->tgcIdHelper().channel(tprd->identify()); + bool measuresPhi = (bool) m_idHelperSvc->tgcIdHelper().isStrip(tprd->identify()); + int gasGap = m_idHelperSvc->tgcIdHelper().gasGap(tprd->identify()); + int channel = m_idHelperSvc->tgcIdHelper().channel(tprd->identify()); const MuonGM::TgcReadoutElement* detEl = tprd->detectorElement(); if (!measuresPhi){ stripWidth = detEl->gangMaxZ(gasGap,channel)-detEl->gangMinZ(gasGap,channel); @@ -927,10 +857,6 @@ namespace MuonCalib { double error = sqrt( trot->localCovariance()(0,0) ); Amg::Vector3D tgp = trot->globalPosition(); -// if (competingRio) { -// error = sqrt( rotc->localCovariance()(0,0) ); -// tgp = rotc->globalPosition(); -// } Amg::Vector3D tlp = gToStation*tgp; TgcCalibHitBase* tgcCH = new TgcCalibHitBase( nStrips, stripWidth, error, tgp, tlp ); @@ -941,7 +867,7 @@ namespace MuonCalib { mdtSeg->addHitOnTrack( tgcCH ); } - }else if( m_muonIdHelperTool->cscIdHelper().is_csc( id ) ){ + }else if( m_idHelperSvc->cscIdHelper().is_csc( id ) ){ ++nc; int nRios = 1; @@ -961,24 +887,16 @@ namespace MuonCalib { const Muon::CscPrepData* cprd = crot->prepRawData(); Identifier id = cprd->identify(); - // m_muonIdHelperTool->cscIdHelper().print(id); int nStrips = cprd->rdoList().size(); -// if (competingRio) { -// nStrips = rotc->numberOfContainedROTs(); -// } - int measuresPhi = m_muonIdHelperTool->cscIdHelper().measuresPhi(id); - int chamberLayer = m_muonIdHelperTool->cscIdHelper().chamberLayer(id); + int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(id); + int chamberLayer = m_idHelperSvc->cscIdHelper().chamberLayer(id); double stripWidth = cprd->detectorElement()->cathodeReadoutPitch( chamberLayer, measuresPhi ); int charge = cprd->charge(); double error = sqrt( crot->localCovariance()(0,0) ); Amg::Vector3D cgp = crot->globalPosition(); -// if (competingRio) { -// error = sqrt( rotc->localCovariance()(0,0) ); -// cgp = rotc->globalPosition(); -// } Amg::Vector3D clp = gToStation *cgp; CscCalibHitBase* cscCH = new CscCalibHitBase( nStrips, stripWidth, charge, error, cgp, clp ); @@ -991,10 +909,6 @@ namespace MuonCalib { ATH_MSG_DEBUG( "mdtSeg->cscHitsOnTrack()=" << mdtSeg->cscHitsOnTrack() ); ATH_MSG_DEBUG( "mdtSeg->hitsOnTrack()=" << mdtSeg->hitsOnTrack() ); // set the global to amdb transform in case of first hit - //if( rit == rots.begin() ) { - // global to AMDB transform - // gToStation = prd->detectorElement()->GlobalToAmdbLRSTransform(); - //} } }else{ @@ -1062,16 +976,16 @@ namespace MuonCalib { std::vector< const Trk::PrepRawData* >::const_iterator prd_it = prdvec.begin(); for( ; prd_it!= prdvec.end() ;++prd_it ) { Identifier id = (*prd_it)->identify(); - if( m_muonIdHelperTool->mdtIdHelper().is_mdt(id) ) { + if( m_idHelperSvc->mdtIdHelper().is_mdt(id) ) { nmdt += 1000; //a mdt is always an eta-hit. - } else if ( m_muonIdHelperTool->rpcIdHelper().is_rpc(id) ) { - if ( m_muonIdHelperTool->rpcIdHelper().measuresPhi(id) ) nrpc += 1; + } else if ( m_idHelperSvc->isRpc(id) ) { + if ( m_idHelperSvc->rpcIdHelper().measuresPhi(id) ) nrpc += 1; else nrpc += 1000 ; - } else if ( m_muonIdHelperTool->tgcIdHelper().is_tgc(id) ) { - if ( m_muonIdHelperTool->tgcIdHelper().isStrip(id) ) ntgc += 1 ; + } else if ( m_idHelperSvc->isTgc(id) ) { + if ( m_idHelperSvc->tgcIdHelper().isStrip(id) ) ntgc += 1 ; else ntgc += 1000 ; - } else if ( m_muonIdHelperTool->cscIdHelper().is_csc(id) ) { - if ( m_muonIdHelperTool->cscIdHelper().measuresPhi(id) ) ncsc += 1 ; + } else if ( m_idHelperSvc->isCsc(id) ) { + if ( m_idHelperSvc->cscIdHelper().measuresPhi(id) ) ncsc += 1 ; else ncsc += 1000 ; } else ATH_MSG_INFO( "PrepRawData on pat is not a muon-technom_logy" ); } @@ -1092,7 +1006,7 @@ namespace MuonCalib { const Muon::MuonSegmentQuality* q = dynamic_cast<const Muon::MuonSegmentQuality*>(seg.fitQuality()); if( !q ) { -// NO quality available for CSC std::cout << "dynamic_cast MdtSegmentQuality failed" << std::endl; +// NO quality available for CSC return 0; } ATH_MSG_DEBUG( "Got MuonSegmentQuality " diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h index 1d7e738542b1..6f45e6933f84 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/MuonCalibGeometryDumper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MuonCalibGeometryDumper_h @@ -7,7 +7,8 @@ //athena #include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" + namespace coral { class IRelationalDomain; @@ -18,7 +19,7 @@ namespace coral { class ITableDataEditor; } -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" namespace MuonGM { class MuonDetectorManager; class MdtReadoutElement; @@ -28,9 +29,9 @@ class TFile; class TTree; #include "CLHEP/Geometry/Transform3D.h" namespace ROOT { -namespace Math{ -class Transform3D; -} + namespace Math{ + class Transform3D; + } } namespace MuonCalib { @@ -45,7 +46,7 @@ class MuonCalibGeometryDumper : public AthAlgorithm { /** Algorithm Constructor */ MuonCalibGeometryDumper(const std::string& name, ISvcLocator *pSvcLocator); /** Algorithm destrucrtor*/ - ~MuonCalibGeometryDumper(); + ~MuonCalibGeometryDumper()=default; //=============================public members=================================== /** Is called at the beginning of the analysis */ StatusCode initialize(); @@ -53,19 +54,13 @@ class MuonCalibGeometryDumper : public AthAlgorithm { inline StatusCode execute() { return StatusCode::SUCCESS; } - /** finalize functions */ - inline StatusCode finalize() { - return StatusCode::SUCCESS; - } //============================private members=================================== private: void loadServices(); std::string m_rootFile; - std::string m_MDT_ID_helper; // name of the MDT ID helper std::string m_idToFixedIdToolType; // type of the muon fixed id tool std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; const MuonGM::MuonDetectorManager *m_detMgr; // pointer to the muon detector manager const IIdToFixedIdTool *m_id_tool; // identifier converter inline bool dump_mdt_geometry(); diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h index 3a698f14d2ff..30341e6c35fa 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/SegmentRawdataSelector.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef MuonCalib_SegmentRawdataSelector_h @@ -12,12 +12,11 @@ //MuonCalibStandAloneBase #include "MuonCalibStandAloneBase/CalibSegmentPreparationTool.h" -//c - c++ #include "set" #include "GeoPrimitives/GeoPrimitives.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class RegionSelectionSvc; @@ -31,13 +30,11 @@ class SegmentRawdataSelector : public AthAlgTool, virtual public CalibSegmentPre public: //=========================constructor========================================== SegmentRawdataSelector(const std::string &t, const std::string &n, const IInterface *p); - inline ~SegmentRawdataSelector() {} + inline ~SegmentRawdataSelector()=default; //=========================public member functions============================== //initialize and finalize - StatusCode initialize(void); - inline StatusCode finalize(void) { - return StatusCode :: SUCCESS; - } + StatusCode initialize(); + //load event void prepareSegments(const MuonCalibEvent *&event, std::map<NtupleStationId, MuonCalibSegment *> &segments); private: @@ -49,11 +46,9 @@ class SegmentRawdataSelector : public AthAlgTool, virtual public CalibSegmentPre //! pointer to region selection service ServiceHandle<RegionSelectionSvc> m_reg_sel_svc; // helpers // - std::string m_MDT_ID_helper; // name of the MDT ID helper std::string m_idToFixedIdToolType; // type of the muon fixed id tool std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h index e73ab7ada8d7..82ee8cc66452 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/CalibNtupleAnalysisAlg/WriteMdtGeometry.h @@ -7,8 +7,8 @@ //athena #include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" namespace coral { class IRelationalDomain; @@ -33,7 +33,7 @@ class WriteMdtGeometry : public AthAlgorithm { /** Algorithm Constructor */ WriteMdtGeometry(const std::string &name, ISvcLocator *pSvcLocator); /** Algorithm destrucrtor*/ - ~WriteMdtGeometry(); + ~WriteMdtGeometry()=default; //=============================public members=================================== /** Is called at the beginning of the analysis */ StatusCode initialize(); @@ -41,26 +41,20 @@ class WriteMdtGeometry : public AthAlgorithm { inline StatusCode execute() { return StatusCode::SUCCESS; } - /** finalize functions */ - inline StatusCode finalize() { - return StatusCode::SUCCESS; - } //============================private members=================================== private: coral::Context *m_context; coral::IRelationalDomain& domain( const std::string &connectionString ); void loadServices(); - coral::ISessionProxy *m_session; + std::string m_connectionString; std::string m_WorkingSchema; std::string m_username, m_password; - std::string m_MDT_ID_helper; // name of the MDT ID helper std::string m_idToFixedIdToolType; // type of the muon fixed id tool std::string m_idToFixedIdToolName; // name of the muon fixed id tool - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; + coral::ISessionProxy *m_session; const MuonGM::MuonDetectorManager *m_detMgr; // pointer to the muon - // detector manager const IIdToFixedIdTool *m_id_tool; // identifier converter inline bool fill_db(coral::ITableDataEditor& editor); diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx index bed94cf23dfd..185919a2438a 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/MuonCalibGeometryDumper.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //this @@ -28,10 +28,10 @@ namespace MuonCalib { -MuonCalibGeometryDumper::MuonCalibGeometryDumper(const std::string &name, ISvcLocator *pSvcLocator) : AthAlgorithm(name, pSvcLocator){ - - m_MDT_ID_helper = std::string("MDTIDHELPER"); - declareProperty("MDTIdHelper", m_MDT_ID_helper); +MuonCalibGeometryDumper::MuonCalibGeometryDumper(const std::string &name, ISvcLocator *pSvcLocator) : + AthAlgorithm(name, pSvcLocator), + m_detMgr(nullptr), + m_id_tool(nullptr) { m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); @@ -41,29 +41,24 @@ MuonCalibGeometryDumper::MuonCalibGeometryDumper(const std::string &name, ISvcLo m_rootFile = "geom.root"; declareProperty("RootFile", m_rootFile); - - //for the sake of coverity - m_detMgr =NULL; - m_id_tool=NULL; -} //end MuonCalibGeometryDumper::MuonCalibGeometryDumper -MuonCalibGeometryDumper::~MuonCalibGeometryDumper() { -} +} //end MuonCalibGeometryDumper::MuonCalibGeometryDumper StatusCode MuonCalibGeometryDumper::initialize() { -// MDT ID helper // - ATH_CHECK( m_muonIdHelperTool.retrieve() ); - + ATH_CHECK(m_idHelperSvc.retrieve()); // muon detector manager // - ATH_CHECK( detStore()->retrieve(m_detMgr) ); + ATH_CHECK(detStore()->retrieve(m_detMgr)); // muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, - m_idToFixedIdToolName, m_id_tool) ); + ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); - const IGeoModelSvc *geoModel; + const IGeoModelSvc *geoModel=nullptr; ATH_CHECK( service ("GeoModelSvc", geoModel) ); + if (!geoModel) { + ATH_MSG_FATAL("Could not retrieve GeoModelSvc"); + return StatusCode::FAILURE; + } TFile *output_file = new TFile(m_rootFile.c_str(), "RECREATE"); TNamed geometry_version("ATLASVersion", geoModel->atlasVersion().c_str()); @@ -86,25 +81,21 @@ inline bool MuonCalibGeometryDumper::dump_mdt_geometry() { mdt_station->Branch("id", &station_id, "id/i"); station_row.CreateBranches(mdt_station); //loop on chambers - MdtIdHelper::const_id_iterator it = m_muonIdHelperTool->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_muonIdHelperTool->mdtIdHelper().module_end(); + MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); + MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); for( ; it!=it_end;++it ) { - std::cout<<"."<<std::flush; - const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(*it,1,1,1)); + const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(*it,1,1,1)); if(!detEl) continue; station_row.ReadHepTransform(detEl->AmdbLRSToGlobalTransform()); MuonFixedId fixed_id(m_id_tool->idToFixedId(*it)); station_id=fixed_id.mdtChamberId().getIdInt(); mdt_station->Fill(); //get number of mls; - int n_mls=m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(*it); + int n_mls=m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it); //loop on multilayers for(int ml=1; ml<=n_mls; ml++) { - const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_muonIdHelperTool->mdtIdHelper().channelID(*it,ml ,1,1)); + const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it,ml ,1,1)); int n_layers=detEl_ml->getNLayers(); -// if(detEl_ml==NULL) { -// std::cerr<<"detEl_ml==NULL"<<std::endl; -// } for(int ly=1; ly<=n_layers; ly++) { fillLayer(*it, detEl_ml, row, mdt_tubes, ml, ly); } @@ -115,10 +106,9 @@ inline bool MuonCalibGeometryDumper::dump_mdt_geometry() { inline void MuonCalibGeometryDumper::fillLayer(const Identifier &ch_id, const MuonGM::MdtReadoutElement *detEl, MdtTubeGeomertyRow &row, TTree *tree, const int &ml, const int &ly) { -// std::cout<<"fillTubePos for "<<ml<<", "<<ly<<", "<<tb<<std::endl; int n_tubes=detEl->getNtubesperlayer(); for(int tb=1; tb<=n_tubes; tb++) { - Identifier tid(m_muonIdHelperTool->mdtIdHelper().channelID(ch_id ,ml ,ly, tb)); + Identifier tid(m_idHelperSvc->mdtIdHelper().channelID(ch_id ,ml ,ly, tb)); MuonFixedId fixed_id(m_id_tool->idToFixedId(tid)); row.tube_id=fixed_id.getIdInt(); Amg::Vector3D tube_pos_g=detEl->tubePos(ml, ly, tb); diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx index 4a1a00307496..c4babaddd65b 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/SegmentRawdataSelector.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //this @@ -20,19 +20,15 @@ // MuonReadoutGeometry // #include "MuonReadoutGeometry/MdtReadoutElement.h" -// AtlasConditions // -#include "MuonIdHelpers/MdtIdHelper.h" - // MuonCalib // #include "MuonCalibITools/IIdToFixedIdTool.h" namespace MuonCalib { - /////////////////////////// // SegmentRawdataSelector // /////////////////////////// SegmentRawdataSelector::SegmentRawdataSelector(const std::string &t, const std::string &n, const IInterface *p): - AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n) { + AthAlgTool(t, n, p), m_reg_sel_svc("RegionSelectionSvc", n), m_id_tool(nullptr) { m_min_hits = 1; declareProperty("MinHits", m_min_hits); m_max_hits = -1; @@ -40,9 +36,6 @@ SegmentRawdataSelector::SegmentRawdataSelector(const std::string &t, const std:: m_adc_cut = 0; declareProperty("AdcCut", m_adc_cut); declareInterface< CalibSegmentPreparationTool >(this); - - m_MDT_ID_helper = std::string("MDTIDHELPER"); - declareProperty("MDTIdHelper", m_MDT_ID_helper); m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); @@ -57,16 +50,10 @@ SegmentRawdataSelector::SegmentRawdataSelector(const std::string &t, const std:: //////////////// StatusCode SegmentRawdataSelector::initialize(void) { - ATH_CHECK( m_reg_sel_svc.retrieve() ); - -// MDT ID helper // - ATH_CHECK( m_muonIdHelperTool.retrieve() ); - -//retrieve detector manager from the conditions store + ATH_CHECK(m_reg_sel_svc.retrieve()); + ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_DetectorManagerKey.initialize()); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool) ); + ATH_CHECK(toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); return StatusCode::SUCCESS; } //end SegmentRawdataSelector::initialize @@ -101,7 +88,7 @@ void SegmentRawdataSelector::prepareSegments(const MuonCalibEvent *&event, std:: station_identifier.SetMultilayer(0); Identifier station_id = m_id_tool->fixedIdToId(hit->identify()); const MuonGM::MdtReadoutElement *MdtRoEl = - MuonDetMgr->getMdtReadoutElement(m_muonIdHelperTool->mdtIdHelper().channelID(station_id, + MuonDetMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(station_id, hit->identify().mdtMultilayer(),hit->identify().mdtTubeLayer(),hit->identify().mdtTube())); if (MdtRoEl==0) { @@ -147,7 +134,6 @@ void SegmentRawdataSelector::prepareSegments(const MuonCalibEvent *&event, std:: inline const Amg::Vector3D SegmentRawdataSelector::get_raw_position(const MuonCalibRawMdtHit *hit, const MuonCalibRawHitCollection *coll, const Amg::Transform3D &global_to_local) const { -// std::cout<<"event"<<std::endl; double x_pos=0.0; int n_rpc_hits=0; int mdt_station=hit->identify().stationName(); @@ -155,8 +141,6 @@ const MuonCalibRawHitCollection *coll, const Amg::Transform3D &global_to_local) int mdt_phi=hit->identify().phi(); for(MuonCalibRawHitCollection::MuonCalibRawRpcHitVecCit it = coll->rawRpcHitCollectionBegin(); it != coll->rawRpcHitCollectionEnd(); it++) { MuonCalibRawRpcHit *rpc_hit(*it); -// const MuonFixedId & id(rpc_hit->identify()); -// std::cout<<id.stationNameString()<<" "<<id.phi()<<" "<<id.eta()<<std::endl; //check that rpc and mdt hit are in the same chamber if(mdt_station != rpc_hit->identify().stationName() || mdt_eta != rpc_hit->identify().eta() || mdt_phi != rpc_hit->identify().phi()) { continue; @@ -165,7 +149,6 @@ const MuonCalibRawHitCollection *coll, const Amg::Transform3D &global_to_local) if(rpc_hit->identify().rpcMeasuresPhi() == 0) continue; Amg::Vector3D local_strip_pos = global_to_local*rpc_hit->globalPosition(); x_pos += local_strip_pos.x(); -// std::cout<< local_strip_pos << std::endl; n_rpc_hits++; } if(n_rpc_hits>0) { diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx index 0e534898d01e..06d5d17a3353 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/CalibNtupleAnalysisAlg/src/WriteMdtGeometry.cxx @@ -7,10 +7,8 @@ //coral #include "RelationalAccess/IRelationalService.h" -//#include "RelationalAccess/IConnection.h" #include "RelationalAccess/IConnectionService.h" #include "RelationalAccess/ConnectionService.h" -//#include "RelationalAccess/ISession.h" #include "RelationalAccess/ISessionProxy.h" #include "RelationalAccess/IRelationalDomain.h" #include "RelationalAccess/ITransaction.h" @@ -30,7 +28,6 @@ #include <stdexcept> -// MuonReadoutGeometry // #include "MuonReadoutGeometry/MdtReadoutElement.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" @@ -39,38 +36,26 @@ namespace MuonCalib { -WriteMdtGeometry::WriteMdtGeometry(const std::string &name, ISvcLocator *pSvcLocator) : AthAlgorithm(name, pSvcLocator), m_context( &coral::Context::instance() ) { - m_MDT_ID_helper = std::string("MDTIDHELPER"); - declareProperty("MDTIdHelper", m_MDT_ID_helper); +WriteMdtGeometry::WriteMdtGeometry(const std::string &name, ISvcLocator *pSvcLocator) : + AthAlgorithm(name, pSvcLocator), + m_context( &coral::Context::instance() ), + m_idToFixedIdToolType("MuonCalib::IdToFixedIdTool"), + m_idToFixedIdToolName("MuonCalib_IdToFixedIdTool"), + m_session(nullptr), + m_detMgr(nullptr), + m_id_tool(nullptr) { - m_idToFixedIdToolType = std::string("MuonCalib::IdToFixedIdTool"); declareProperty("idToFixedIdToolType", m_idToFixedIdToolType); - - m_idToFixedIdToolName = std::string("MuonCalib_IdToFixedIdTool"); declareProperty("idToFixedIdToolName", m_idToFixedIdToolName); - declareProperty("ConnectionString", m_connectionString); declareProperty("WorkingSchema", m_WorkingSchema); - - //for the sake of coverity - m_session=NULL; - m_detMgr =NULL; - m_id_tool=NULL; -} //end WriteMdtGeometry::WriteMdtGeometry -WriteMdtGeometry::~WriteMdtGeometry() { -} +} //end WriteMdtGeometry::WriteMdtGeometry StatusCode WriteMdtGeometry::initialize() { -// MDT ID helper // - ATH_CHECK( m_muonIdHelperTool.retrieve() ); - -// muon detector manager // - ATH_CHECK( detStore()->retrieve(m_detMgr) ); - -// muon fixed id tool // - ATH_CHECK( toolSvc()->retrieveTool(m_idToFixedIdToolType, - m_idToFixedIdToolName, m_id_tool) ); + ATH_CHECK(m_idHelperSvc.retrieve()); + ATH_CHECK(detStore()->retrieve(m_detMgr)); + ATH_CHECK(toolSvc()->retrieveTool(m_idToFixedIdToolType, m_idToFixedIdToolName, m_id_tool)); loadServices(); @@ -88,12 +73,6 @@ StatusCode WriteMdtGeometry::initialize() { CloseConnection(false); return StatusCode::FAILURE; } -// catch (std::exception &e ) -// { -// std::cerr << "std::exception : " << e.what() << std::endl; -// CloseConnection(false); -// return StatusCode::FAILURE; -// } ATH_MSG_INFO( "Initialisation done!" ); return StatusCode::SUCCESS; } //end WriteMdtGeometry::initialize @@ -122,21 +101,21 @@ inline bool WriteMdtGeometry::fill_db(coral::ITableDataEditor &editor) { rowBuffer.extend<float>("LOC_Z"); rowBuffer.extend<float>("Y_SPACING"); //loop on chambers - MdtIdHelper::const_id_iterator it = m_muonIdHelperTool->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_muonIdHelperTool->mdtIdHelper().module_end(); + MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); + MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); for( ; it!=it_end;++it ) { std::cout<<"."<<std::flush; - const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(*it,1,1,1)); + const MuonGM::MdtReadoutElement *detEl = m_detMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(*it,1,1,1)); if(!detEl) continue; //get number of mls; - int n_mls=m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(*it); + int n_mls=m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it); //fixed id MuonFixedId fixed_id(m_id_tool->idToFixedId(*it)); rowBuffer["CHAMBER"].data<int>() = fixed_id.mdtChamberId().getIdInt(); //loop on multilayers for(int ml=1; ml<=n_mls; ml++) { rowBuffer["ML"].data<int>()=ml; - const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_muonIdHelperTool->mdtIdHelper().channelID(*it,ml ,1,1)); + const MuonGM::MdtReadoutElement *detEl_ml = m_detMgr->getMdtReadoutElement(m_idHelperSvc->mdtIdHelper().channelID(*it,ml ,1,1)); int n_layers=detEl_ml->getNLayers(); int n_tubes=detEl_ml->getNtubesperlayer(); // if(detEl_ml==NULL) { -- GitLab From 13742d816594efc337d60df98efd04d27ad6567d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20K=C3=B6hler?= <nicolas.koehler@cern.ch> Date: Fri, 31 Jan 2020 18:30:32 +0100 Subject: [PATCH 2/2] move MuonIdHelperTool to MuonIdHelperSvc --- .../MdtCalibIOSvc/MdtCalibOutputDbSvc.h | 9 +- .../MdtCalibIOSvc/src/MdtCalibOutputDbSvc.cxx | 26 +- .../RegionSelectionSvc.h | 18 +- .../src/RegionSelectionSvc.cxx | 74 +-- .../HistogramManager.h | 71 +-- .../MdtDqaGlobalTimeFit.h | 59 +- .../MdtDqaTubeEfficiency.h | 45 +- .../NtupleMdtDqaTool.h | 22 +- .../src/HistogramManager.cxx | 549 ++++-------------- .../src/MdtDqaGlobalTimeFit.cxx | 407 +------------ .../src/MdtDqaTubeEfficiency.cxx | 99 ++-- .../src/NtupleMdtDqaTool.cxx | 95 +-- .../NtupleDisplayTool.h | 20 +- .../NtupleRunScanTool.h | 16 +- .../NtupleTubeEfficiencyTool.h | 12 +- .../src/NtupleDisplayTool.cxx | 90 +-- .../src/NtupleRunScanTool.cxx | 11 +- .../src/NtupleTubeEfficiencyTool.cxx | 144 +---- 18 files changed, 315 insertions(+), 1452 deletions(-) diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/MdtCalibIOSvc/MdtCalibOutputDbSvc.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/MdtCalibIOSvc/MdtCalibOutputDbSvc.h index 00f7c1eda9fb..80ef4fcf0dfd 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/MdtCalibIOSvc/MdtCalibOutputDbSvc.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/MdtCalibIOSvc/MdtCalibOutputDbSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -47,7 +47,7 @@ #include "MuonCalibStandAloneBase/NtupleStationId.h" #include "MuonCalibStandAloneBase/CalibrationIOTool.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class RegionSelectionSvc; @@ -132,9 +132,8 @@ private: ToolHandle<MuonCalib::CalibrationIOTool> m_calib_output_tool; // iov range in run numbers// int m_iov_start, m_iov_end; -//access to geomodel - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/src/MdtCalibOutputDbSvc.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/src/MdtCalibOutputDbSvc.cxx index ae8d0c2ee20f..a3bca1d43ee0 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/src/MdtCalibOutputDbSvc.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MdtCalibIOSvc/src/MdtCalibOutputDbSvc.cxx @@ -1,15 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 07.10.2006, AUTHOR: OLIVER KORTNER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - // standard C++ // #include <iostream> #include <fstream> @@ -17,12 +9,8 @@ #include "cmath" // Gaudi // -#include "Identifier/Identifier.h" #include "StoreGate/StoreGateSvc.h" -//geo model -#include "MuonIdHelpers/MdtIdHelper.h" - // MuonCalib // #include "MdtCalibIOSvc/MdtCalibOutputDbSvc.h" #include "MdtCalibIOSvc/MdtCalibInputSvc.h" @@ -30,13 +18,9 @@ #include "MdtCalibData/MdtTubeFitContainer.h" #include "MdtCalibRt/RtCalibrationOutput.h" #include "MdtCalibData/IRtRelation.h" -//#include "MdtCalibData/RtChebyshev.h" -//#include "MdtCalibData/RtRelationLookUp.h" #include "MdtCalibData/RtResolutionLookUp.h" -//#include "MuonCalibIdentifier/MuonFixedId.h" #include "MdtCalibInterfaces/IMdtCalibrationOutput.h" -//#include "MuonCalibDbOperations/CalibDBCoral.h" #include "MdtCalibData/IRtResolution.h" #include "MdtCalibData/RtResolutionFromPoints.h" @@ -45,8 +29,6 @@ //:::::::::::::::::::::::: //:: NAMESPACE SETTINGS :: //:::::::::::::::::::::::: - -using namespace std; using namespace MuonCalib; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -124,7 +106,7 @@ StatusCode MdtCalibOutputDbSvc::initialize(void) { StoreGateSvc *detStore; ATH_CHECK( serviceLocator()->service("DetectorStore", detStore) ); //retrieve mdt id helper - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK( m_idHelperSvc.retrieve() ); //retrieve detector manager from the conditions store ATH_CHECK(m_DetectorManagerKey.initialize()); } @@ -220,7 +202,7 @@ StatusCode MdtCalibOutputDbSvc::saveCalibrationResults(void) { MuonCalib::NtupleStationId the_id(*it); // get region geometry if required if (m_postprocess_calibration) { - if(!the_id.InitializeGeometry(m_muonIdHelperTool->mdtIdHelper(), MuonDetMgr)) { + if(!the_id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) { ATH_MSG_ERROR( "Faild to get geometry for " << the_id.regionId() ); } } @@ -383,7 +365,7 @@ inline void MdtCalibOutputDbSvc::create_default_resolution(const MuonCalib::IRtR double r=rt->radius(t); double resol(0.0); for (int l=0; l<9; l++) { - resol = resol+alpha[l]*pow(r, l); + resol = resol+alpha[l]*std::pow(r, l); } par_vec[i+2]=resol; } diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/MuonCalibStandAloneBase/RegionSelectionSvc.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/MuonCalibStandAloneBase/RegionSelectionSvc.h index 750e03a9ee54..15c565adfece 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/MuonCalibStandAloneBase/RegionSelectionSvc.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/MuonCalibStandAloneBase/RegionSelectionSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef RegionSelectionSvc_H @@ -15,6 +15,7 @@ //gaudi #include "AthenaBaseComps/AthService.h" #include "GaudiKernel/IInterface.h" +#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" //MuonCalibITools @@ -22,7 +23,7 @@ #include "MuonCalibStandAloneBase/NtupleStationId.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" namespace MuonCalib { @@ -57,16 +58,13 @@ class RegionSelectionSvc : public AthService /**contructor */ RegionSelectionSvc(const std::string & name, ISvcLocator *svc_locator); /**destructor */ - virtual ~RegionSelectionSvc(); + virtual ~RegionSelectionSvc()=default; static const InterfaceID& interfaceID() { return IID_IRegionSelectionSvc; } /** just some crazy atheta function */ virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown); /**initialize */ StatusCode initialize(); - /**finalize function */ - inline StatusCode finalize() { - return StatusCode::SUCCESS;} /** debug print */ void Print(std::ostream &os) const; /** return true if id is in selected region */ @@ -98,12 +96,12 @@ class RegionSelectionSvc : public AthService //! chambers/mutlilayers in calibraition region std::vector<MuonCalib::NtupleStationId> m_stations_in_region; std::set<MuonCalib::NtupleStationId> m_unique_chambers; - ToolHandle<MuonCalib::IIdToFixedIdTool> m_idToFixedIdTool; StoreGateSvc* m_detStore; + const MuonGM::MuonDetectorManager* m_detMgr;//! search for chambers and multilayers in selected region //!towers in selected region - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; - const MuonGM::MuonDetectorManager* m_detMgr; //! search for chambers and multilayers in selected region + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; + ToolHandle<MuonCalib::IIdToFixedIdTool> m_idToFixedIdTool; + inline void search_chambers_in_region(); /** process string */ inline bool ProcessString(const std::string & input); diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/src/RegionSelectionSvc.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/src/RegionSelectionSvc.cxx index 4fca5598c344..18a102e5a658 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/src/RegionSelectionSvc.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneBase/src/RegionSelectionSvc.cxx @@ -1,12 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -// Gaudi // -#include "GaudiKernel/MsgStream.h" -#include "StoreGate/StoreGateSvc.h" - - //MuonGeoModel #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" @@ -23,11 +18,6 @@ #include "MuonCalibStandAloneBase/RegionLogicalOperation.h" #include "MuonCalibStandAloneBase/RegionElement.h" -//MuonCalibIdentifier -#include "MuonCalibIdentifier/MuonFixedId.h" - - - //root #include "TChain.h" #include "TTree.h" @@ -39,23 +29,19 @@ using namespace MuonCalib; -RegionSelectionSvc :: RegionSelectionSvc(const std::string & name, ISvcLocator *svc_locator) : AthService(name, svc_locator), m_region_string(), m_print_list_of_selected_chambers(false), m_idToFixedIdTool("MuonCalib::IdToFixedIdTool") +RegionSelectionSvc :: RegionSelectionSvc(const std::string & name, ISvcLocator *svc_locator) : + AthService(name, svc_locator), + m_region_string(), + m_print_list_of_selected_chambers(false), + m_master_region(nullptr), + m_detStore(nullptr), + m_detMgr(nullptr), + m_idToFixedIdTool("MuonCalib::IdToFixedIdTool") { declareProperty("Region", m_region_string); declareProperty("PrintList", m_print_list_of_selected_chambers); - - //for the sake of coverity - m_detMgr=NULL; - m_detStore=NULL; - m_master_region=NULL; } - -RegionSelectionSvc :: ~RegionSelectionSvc() - { - } - - StatusCode RegionSelectionSvc::queryInterface(const InterfaceID& riid, void** ppvUnknown) { ATH_MSG_VERBOSE("StatusCode RegionSelectionSvc::queryInterface"); @@ -80,34 +66,12 @@ StatusCode RegionSelectionSvc :: initialize() //detector stre - id to fixed id ... - StatusCode sc = serviceLocator()->service("DetectorStore", m_detStore); - if ( sc.isSuccess() ) { - ATH_MSG_DEBUG("Retrieved DetectorStore"); - }else{ - ATH_MSG_ERROR("Failed to retrieve DetectorStore"); - return sc; - } - - sc = m_muonIdHelperTool.retrieve(); - if (!sc.isSuccess()) { - ATH_MSG_ERROR("Can't retrieve MdtIdHelper"); - return sc; - } - - sc = m_detStore->retrieve( m_detMgr ); - if (!sc.isSuccess()) { - ATH_MSG_ERROR("Can't retrieve MuonDetectorManager"); - return sc; - } - - sc = m_idToFixedIdTool.retrieve(); - if (sc.isFailure()) { - ATH_MSG_FATAL("Could not find " << m_idToFixedIdTool ); - return sc; - }else{ - ATH_MSG_INFO("Retrieved " << m_idToFixedIdTool ); - } - + ATH_CHECK(serviceLocator()->service("DetectorStore", m_detStore)); + ATH_MSG_DEBUG("Retrieved DetectorStore"); + ATH_CHECK(m_idHelperSvc.retrieve()); + ATH_CHECK(m_detStore->retrieve( m_detMgr )); + ATH_CHECK(m_idToFixedIdTool.retrieve()); + ATH_MSG_INFO("Retrieved " << m_idToFixedIdTool); search_chambers_in_region(); if(m_print_list_of_selected_chambers) @@ -171,14 +135,14 @@ void RegionSelectionSvc :: Print(std::ostream &os) const inline void RegionSelectionSvc :: search_chambers_in_region() { - MdtIdHelper::const_id_iterator it = m_muonIdHelperTool->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_muonIdHelperTool->mdtIdHelper().module_end(); + MdtIdHelper::const_id_iterator it = m_idHelperSvc->mdtIdHelper().module_begin(); + MdtIdHelper::const_id_iterator it_end = m_idHelperSvc->mdtIdHelper().module_end(); for( ; it!=it_end;++it ) { - const MuonGM::MdtReadoutElement* detEl = m_detMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(*it,1,1,1)); + const MuonGM::MdtReadoutElement* detEl = m_detMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(*it,1,1,1)); if(!detEl) continue; //get number of mls; - int n_mls=m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(*it); + int n_mls=m_idHelperSvc->mdtIdHelper().numberOfMultilayers(*it); //fixed id MuonCalib::MuonFixedId fixed_id(m_idToFixedIdTool->idToFixedId(*it)); std::vector<MuonCalib::NtupleStationId> the_ids; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h index d0f8c42ee5ed..095038180024 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/HistogramManager.h @@ -1,11 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 13.08.2008, AUTHOR: MAURO IODICE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// #ifndef SRC_HISTOGRAMMANAGER_H #define SRC_HISTOGRAMMANAGER_H @@ -30,11 +26,8 @@ #define UPDATETIME 2000 -//using namespace std; -//using namespace MuonCalib; - namespace Muon { - class MuonIdHelperTool; + class IMuonIdHelperSvc; } class MdtChamber { @@ -82,8 +75,8 @@ struct sortMdtChambersByName { class HistogramManager { public: HistogramManager(); - HistogramManager(const Muon::MuonIdHelperTool *muonIdHelperTool); - ~HistogramManager(); + HistogramManager(const Muon::IMuonIdHelperSvc *idHelper); + ~HistogramManager()=default; void buildGlobalHistos(); void buildTrackHistos(); void buildDebugHistos(); @@ -133,72 +126,18 @@ public: int GetChamberNumOfMezzPerML (std::string chamberName); int GetChamberTubesPerMezz (std::string chamberName); - // std::vector<std::string> GetChamberTypeList(std::string region, std::string side, int sector); int GetEtaMax(std::string region, std::string side, int sector, std::string chamberType); - - // void buildAll(int sectorMin, int sectorMax); - // void test(); TFile* rootFile(){return m_rootfile;}; TFile *m_rootfile; private: TObjArray m_hList; - const Muon::MuonIdHelperTool * m_muonIdHelperTool; + const Muon::IMuonIdHelperSvc* m_idHelper; bool m_doTracks; - - // ToString ts; - // ToChar _tc; }; -//////////////////////////////////////////////////////////////////// -// -// UTILITIES of General usage -// - -/********************* -// -class ToString{ - public: - template< class T > - std::string operator()( const T& i ) - { - std::ostringstream os; - os << i; - return os.str(); - } -}; -*********************************/ - - -/********************************* -class ToChar { - public: - char* operator()( const std::string i ) - { - return i.c_str(); - } - char* operator()( const int i ) - { - ToString ts; - return ts(i).c_str(); - } - char* operator()( const float i ) - { - ToString ts; - return ts(i).c_str(); - } - char* operator()( const char * i ) - { - return i; - } - -}; - - -*********************************/ - #endif //SRC_HISTOMANAGER_H diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h index c6ca0debed54..7c87f18f208b 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h @@ -1,11 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 05.09.2008, AUTHOR: MAURO IODICE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - #ifndef MuonCalib_MdtDqaGlobalTimeFitH #define MuonCalib_MdtDqaGlobalTimeFitH @@ -25,9 +21,6 @@ //:: HEADER FILES :: //:::::::::::::::::: -// this -// #include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" - #include "MdtCalibData/IRtRelation.h" #include "MdtCalibData/RtRelationLookUp.h" #include "MdtCalibData/MdtCalibrationFactory.h" @@ -43,15 +36,10 @@ class TNtuple; class TH1F; class TH1I; - namespace MuonGM{ class MuonDetectorManager; } -namespace Muon { - class MuonIdHelperTool; -} - namespace MuonCalib { class QuasianalyticLineReconstruction; @@ -68,18 +56,12 @@ class MdtDqaGlobalTimeFit { public: // Constructors // MdtDqaGlobalTimeFit(int nbHitsMin, int nbHitsMax, float chi2cut, int BfieldON, bool debug); - ///< Default constructor. - - inline ~MdtDqaGlobalTimeFit(){} - ///< Destructor + ~MdtDqaGlobalTimeFit()=default; // Methods // /** tool initialize */ - StatusCode initialize(const Muon::MuonIdHelperTool*, const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *,RegionSelectionSvc *, HistogramManager *); - - /** tool finalize */ - StatusCode finalize(); + StatusCode initialize(const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *,RegionSelectionSvc *, HistogramManager *); StatusCode handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); ///< analysis of the given segment of @@ -95,7 +77,6 @@ class MdtDqaGlobalTimeFit { IRtRelation *getDefaultRtRelation(int BfieldON); private: - const Muon::MuonIdHelperTool *m_muonIdHelperTool; const MuonGM::MuonDetectorManager *m_detMgr; const MuonCalib::IIdToFixedIdTool *m_id_tool; // pointer to region selection service @@ -104,54 +85,20 @@ class MdtDqaGlobalTimeFit { HistogramManager *m_histoManager; std::string m_chamberAthenaName; std::string m_chamberHardwareName; - - // ROOT file and analysis ntuples/trees // - //TFile *m_tfile; // ROOT file - //TFile *m_tfile_debug; // ROOT file for debug purposes - //TNtuple *m_hit_ntuple; // hit ntuple std::string m_file_name; //root file name - //float m_nb_hits; //minimum number of hits in segment int m_minNumHits; //minimum number of hits in segment int m_maxNumHits; //maximum number of hits in segment float m_chi2_cut; //track chi2 cut; int m_BfieldON; // BField was ON (1) or OFF (0) used for rtDefault choice; bool m_debug; //write debugging rootfile - // calibration region// - //const NtupleStationId *m_cal_region; - // line reconstruction // IRtRelation *m_rtRel; //QuasianalyticLineReconstruction *m_qfitter; // NOT MAINTAINED ANYMORE MuCCaFitter * m_muFitter; DCSLFitter *m_muFitter; GlobalTimeFitter *m_GTFitter; - - // counter/numbers // - //int m_nb_trigger; - // int m_nb_multilayers; - // int m_nb_layers; - // int m_nb_tubes; - //int m_nb_stations; - //int m_nb_layers_tubes[1500][4]; - - // histograms // - //TH1F *m_htoffset; - - // TH1F *h_distance; - //TH1I *h_nb_hit_tubes; - - /* - std::vector< std::vector< std::vector<TH1F*> > > h_efficiency; - std::vector< std::vector< std::vector<TH1F*> > > h_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_efficiency; - std::vector< std::vector<TH1F*> > h_tube_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_entries_efficiency; - std::vector< std::vector<TH1F*> > h_tube_entries_fakerate; - */ }; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h index 8bd8c6dc3cd5..11c6108c3db9 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/MdtDqaTubeEfficiency.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -36,7 +36,6 @@ //:::::::::::::::::: // this -// #include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" #include "MdtCalibIOSvc/MdtCalibInputSvc.h" class RegionSelectionSvc; class HistogramManager; @@ -48,7 +47,7 @@ class TH1F; class TH1I; namespace Muon { - class MuonIdHelperTool; + class IMuonIdHelperSvc; } namespace MuonGM{ @@ -78,11 +77,8 @@ class MdtDqaTubeEfficiency { // Methods // /** tool initialize */ - StatusCode initialize(const Muon::MuonIdHelperTool*, const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *, + StatusCode initialize(const Muon::IMuonIdHelperSvc*, const MuonGM::MuonDetectorManager*, const MuonCalib::IIdToFixedIdTool *, RegionSelectionSvc *, MdtCalibInputSvc *, HistogramManager *); - - /** tool finalize */ - StatusCode finalize(); StatusCode handleEvent(const MuonCalibEvent &event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); ///< analysis of the given segment of @@ -107,7 +103,7 @@ class MdtDqaTubeEfficiency { } ; private: - const Muon::MuonIdHelperTool* m_muonIdHelperTool; + const Muon::IMuonIdHelperSvc* m_idHelper; const MuonGM::MuonDetectorManager *m_detMgr; const MuonCalib::IIdToFixedIdTool *m_id_tool; // pointer to region selection service @@ -117,11 +113,6 @@ class MdtDqaTubeEfficiency { HistogramManager *m_histoManager ; std::string m_chamberAthenaName; std::string m_chamberHardwareName; - - // ROOT file and analysis ntuples/trees // - //TFile *m_tfile; // ROOT file - //TFile *m_tfile_debug; // ROOT file for debug purposes - //TNtuple *m_hit_ntuple; // hit ntuple std::string m_file_name; // root file name float m_nsigma; // efficiency at nsigma*resol(r) @@ -131,41 +122,13 @@ class MdtDqaTubeEfficiency { bool m_GTFitON; // refit with GlobalTimeFitter the initial segment bool m_useNewCalibConstants; bool m_useTimeCorrections; - - // calibration region// - //const NtupleStationId *m_cal_region; // line reconstruction // QuasianalyticLineReconstruction *m_qfitter; // counter/numbers // - //int m_nb_trigger; - // int m_nb_multilayers; - // int m_nb_layers; - // int m_nb_tubes; int m_nb_stations ; int m_nb_layers_tubes[1500][4] ; - - // histograms // - //TH1F *m_h_distance; - //TH1I *m_h_nb_hit_tubes; - /* - std::vector< std::vector< std::vector<TH1F*> > > h_efficiency; - std::vector< std::vector< std::vector<TH1F*> > > h_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_efficiency; - std::vector< std::vector<TH1F*> > h_tube_fakerate; - - std::vector< std::vector<TH1F*> > h_tube_entries_efficiency; - std::vector< std::vector<TH1F*> > h_tube_entries_fakerate; - */ - //TH1F *m_h_layer_efficiency; - //TH1F *m_h_layer_fakerate; - - //TH1F *m_h_chamber_efficiency; - //TH1F *m_h_chamber_fakerate; - - //TH1F *m_h_chi2; }; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h index 2ae7314f34e7..01b3e795f0ed 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -38,8 +38,8 @@ #include "MuonCalibStandAloneExtraTools/SegmentAnalysis.h" #include "AthenaBaseComps/AthAlgTool.h" - -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" class RegionSelectionSvc; class MdtCalibInputSvc; @@ -52,8 +52,6 @@ class TNtuple; class TH1F; class TH1I; -class MdtIdHelper; - namespace MuonGM{ class MuonDetectorManager; } @@ -66,16 +64,13 @@ class MuonCalibSegment; class NtupleStationId; class MuonCalibEvent; - class NtupleMdtDqaTool : public AthAlgTool, virtual public NtupleCalibrationTool { public: // Constructors // NtupleMdtDqaTool(const std::string& t, const std::string& n, const IInterface* p); - ///< Default constructor. - inline ~NtupleMdtDqaTool(){} - ///< Destructor + ~NtupleMdtDqaTool()=default; // Methods // @@ -100,18 +95,17 @@ class NtupleMdtDqaTool : public AthAlgTool, virtual public NtupleCalibrationTool } private: - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; const MuonGM::MuonDetectorManager *m_detMgr; const MuonCalib::IIdToFixedIdTool *m_id_tool; // pointer to region selection service - RegionSelectionSvc *p_reg_sel_svc; + RegionSelectionSvc* p_reg_sel_svc; // pointer to the calibration service - MdtCalibInputSvc *p_calib_input_svc; + MdtCalibInputSvc* p_calib_input_svc; // Manager tools // - HistogramManager * m_histoManager; + HistogramManager* m_histoManager; // Analysis tools and variables : // // diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx index 30b01bab3d46..57b869d003a8 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/HistogramManager.cxx @@ -1,23 +1,11 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 13.08.2008, AUTHOR: MAURO IODICE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// -// -// .L HistogramManager.C -// HistogramManager * builder = new HistogramManager(); -// builder->METODO1(); -// builder->METODO2(); - #include "MuonCalibStandAloneExtraTools/HistogramManager.h" #include "MuonCalibStandAloneExtraTools/MDTName.h" -//------------------------- -#include "MuonIdHelpers/MuonIdHelperTool.h" -#include "Identifier/IdentifierHash.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" #include <array> @@ -268,24 +256,20 @@ namespace { } -using namespace std; using namespace MuonCalib; HistogramManager::HistogramManager() { - // m_rootfile = new TFile(); - m_rootfile = NULL; + m_idHelper = nullptr; + m_rootfile = nullptr; m_hList(0); m_doTracks = false; } -HistogramManager::HistogramManager(const Muon::MuonIdHelperTool* muonIdHelperTool) { - // m_rootfile = new TFile(); - m_muonIdHelperTool = muonIdHelperTool; - m_rootfile = NULL; +HistogramManager::HistogramManager(const Muon::IMuonIdHelperSvc* idHelper) { + m_idHelper = idHelper; + m_rootfile = nullptr; m_hList(0); m_doTracks = false; } -HistogramManager::~HistogramManager() { -} void HistogramManager::SetDoTracks(bool the_tracks) { m_doTracks=the_tracks; @@ -293,17 +277,14 @@ void HistogramManager::SetDoTracks(bool the_tracks) { void HistogramManager::buildGlobalHistos() { - //cout<<"Building Global Histos " <<endl; - if (!m_rootfile->IsOpen()){ - //cout << "opening output file with default name"<< endl; - string defaultOutputFile="outDQA.root"; + std::string defaultOutputFile="outDQA.root"; openOutputFile(defaultOutputFile); } m_rootfile->cd(); - string dir_name; + std::string dir_name; // Building Base directory : // /GLOBAL/ dir_name="/GLOBAL"; @@ -339,23 +320,17 @@ void HistogramManager::buildGlobalHistos() { phiVseta->GetYaxis()->SetTitle("Segment_phi (deg)"); phiVseta->GetXaxis()->SetTitle("Segment_eta"); -// TH1F * segments; -// segments = new TH1F("seg","Segments per Event",40,0.,39.); -// segments->GetXaxis()->SetTitle("numSegments_per_event"); } // TRACK Histograms .... void HistogramManager::buildTrackHistos() { - //cout<<"Building Track Histos " <<endl; - if (!m_rootfile->IsOpen()){ - //cout << "opening output file with default name"<< endl; - string defaultOutputFile="outDQA.root"; + std::string defaultOutputFile="outDQA.root"; openOutputFile(defaultOutputFile); } m_rootfile->cd(); - string dir_name; + std::string dir_name; dir_name="TRACKS"; if (!m_rootfile->GetDirectory(dir_name.c_str())) { // A new TDirectoryFile gets owned by the current directory (side effect). @@ -364,10 +339,6 @@ void HistogramManager::buildTrackHistos() { m_rootfile->cd("/TRACKS"); - // TH1F * nmbts; - // nmbts=new TH1F("mbts_nb","number of mbts",12,-1.5,10.5); - // nmbts->GetXaxis()->SetTitle("number of mbts"); - TH1F * tmbts1; tmbts1=new TH1F("mbts1_time","Time mbts 1 (plus)",200,-100.,100.); tmbts1->GetXaxis()->SetTitle("time (ns)"); @@ -537,22 +508,16 @@ void HistogramManager::buildTrackHistos() { } - // DEBUG AND SPECIFIC-ANALYSIS Histograms .... - // buildDebugHistos(); - - void HistogramManager::buildDebugHistos() { - //cout<<"Building DEBUG Histos " <<endl; if (!m_rootfile->IsOpen()){ - //cout << "opening output file with default name"<< endl; - string defaultOutputFile="outDQA.root"; + std::string defaultOutputFile="outDQA.root"; openOutputFile(defaultOutputFile); } m_rootfile->cd(); - string dir_name; + std::string dir_name; // Building Base directory : // /DEBUG/ dir_name=GetMdtDirectoryName(); @@ -561,10 +526,6 @@ void HistogramManager::buildDebugHistos() { new TDirectoryFile("DEBUG","DEBUG"); } m_rootfile->cd("/DEBUG"); - - // new TH2F("t0FitVst0RPC","; t0RPC (ns); t0Refit (ns)",200,-50.,50.,200,-50.,50.); - // new TH2F("At0FitVsAt0RPC","; slope t0RPC; slope t0Refit (ns)",200,-50.,50.,200,-50.,50.); - // new TH2F("Bt0FitVsBt0RPC","; Intercept t0RPC; Intercept t0Refit",200,-50.,50.,200,-50.,50.); TH1F * h1 = new TH1F("nSegPerTrack","n Segments",21,-0.5,20.5); h1->GetXaxis()->SetTitle("nSegments"); @@ -591,17 +552,13 @@ void HistogramManager::buildDebugHistos() { } -void HistogramManager::buildTopLevel(string region, string side,int sectorMin, int sectorMax) { - - //ToString _ts; - string regionSide = region+"_"+side; - string dir_name="none"; +void HistogramManager::buildTopLevel(std::string region, std::string side,int sectorMin, int sectorMax) { - //cout<<"Building top level histograms for region : " << regionSide <<endl; + std::string regionSide = region+"_"+side; + std::string dir_name="none"; if (!m_rootfile->IsOpen()){ - //cout << "opening output file with default name"<< endl; - string defaultOutputFile="outDQA.root"; + std::string defaultOutputFile="outDQA.root"; openOutputFile(defaultOutputFile); } @@ -676,7 +633,7 @@ void HistogramManager::buildTopLevel(string region, string side,int sectorMin, i // Building Base directory : // /MDTvsRPC/ (for Barrel) - /MDTvsTGC/ (for Endcap) dir_name = GetTDaqDirectoryName(region); - string MDTvsTriggerChambers="Undefined"; + std::string MDTvsTriggerChambers="Undefined"; if (region == "Barrel") MDTvsTriggerChambers="MDTvsRPC"; if (region == "Endcap") MDTvsTriggerChambers="MDTvsTGC"; if (!m_rootfile->GetDirectory(dir_name.c_str())) { @@ -686,7 +643,7 @@ void HistogramManager::buildTopLevel(string region, string side,int sectorMin, i // Building <region-side> (ex. Barrel_A) directories : // motherdir = /MDT/; - string motherdir; + std::string motherdir; motherdir = GetMdtDirectoryName(); m_rootfile->cd(motherdir.c_str()); dir_name=GetMdtDirectoryName(region,side); @@ -702,8 +659,8 @@ void HistogramManager::buildTopLevel(string region, string side,int sectorMin, i float tdriftMax=800.; int tdriftNbins = 100; - string histoType; - string histoTitle; + std::string histoType; + std::string histoTitle; // histoType="t0PerSector_Inner"; histoTitle = histoType; @@ -759,86 +716,6 @@ void HistogramManager::buildTopLevel(string region, string side,int sectorMin, i h2->GetYaxis()->SetTitle("tdrift per ML (ns)"); } - /* - histoType="t0PerSector_Inner"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(400.,800.,"Y"); - // - histoType="t0PerSector_Middle"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(400.,800.,"Y"); - // - histoType="t0PerSector_Outer"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(400.,800.,"Y"); - // - if(region=="Endcap") - { - histoType="t0PerSector_extra"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("t0 (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(400.,800.,"Y"); - } - // - histoType="tdriftPerSector_Inner"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(600.,800.,"Y"); - // - histoType="tdriftPerSector_Middle"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(600.,800.,"Y"); - // - histoType="tdriftPerSector_Outer"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(600.,800.,"Y"); - // - if(region=="Endcap") - { - histoType="tdriftPerSector_extra"; - histoTitle = histoType; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),16,0.5,16.5); - h->GetXaxis()->SetTitle("Sector nr."); - h->GetYaxis()->SetTitle("tdrift (ns)"); - h->SetMarkerStyle(20); - h->SetMarkerSize(1.0); - h->SetAxisRange(600.,800.,"Y"); - } - */ - histoType="time_Fit_t0"; histoTitle = histoType; h = new TH1F(histoType.c_str(),histoTitle.c_str(),t0Nbins,t0Min,t0Max); @@ -992,15 +869,10 @@ void HistogramManager::buildTopLevel(string region, string side,int sectorMin, i } -void HistogramManager::buildSector(string region, string side, int sector) { - - // cout << " HistogramManager::buildSector - building sector: "<<sector - // << " side "<<side<<" in the "<<region << endl; +void HistogramManager::buildSector(std::string region, std::string side, int sector) { - string sectordir=GetMdtDirectoryName(region, side, sector); + std::string sectordir=GetMdtDirectoryName(region, side, sector); if (m_rootfile->GetDirectory(sectordir.c_str())) { - // cout << " Sector Histograms already built for : Region "<<region - // <<" side "<<side<<" Sector "<<sector<<endl; return; } @@ -1010,7 +882,7 @@ void HistogramManager::buildSector(string region, string side, int sector) { std::stable_sort(chamberList.begin(), chamberList.end(), sortMdtChambersByName() ) ; int numTotChambers=chamberList.size(); - string previousChamberType = "XXX"; + std::string previousChamberType = "XXX"; std::vector<MDTName> chamberListPerType[7]; int totChamberTypes = 0; for (int ichamber = 0; ichamber<numTotChambers; ichamber++ ) { @@ -1023,14 +895,12 @@ void HistogramManager::buildSector(string region, string side, int sector) { ToString ts; - //bool smallSector = (sector/2)*2==sector; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string sector_name="Sector"+sectorString; - string sector_title="Sector "+sectorString; + std::string sector_name="Sector"+sectorString; + std::string sector_title="Sector "+sectorString; - // string motherdir="/MDT/Barrel_"+side; - string motherdir= GetMdtDirectoryName(region,side); + std::string motherdir= GetMdtDirectoryName(region,side); m_rootfile->cd(motherdir.c_str()); TH1F * h; TH1F * h1; @@ -1040,29 +910,15 @@ void HistogramManager::buildSector(string region, string side, int sector) { TDirectoryFile * overview = new TDirectoryFile("OVERVIEW","OVERVIEW","",sector_dir); overview->cd(); - string histoTitPart2 = region+"_"+side+" Sector "+sectorString; - string histoType; - string histoTitle; + std::string histoTitPart2 = region+"_"+side+" Sector "+sectorString; + std::string histoType; + std::string histoTitle; int nbinMultipl=50; float xminMultipl=0.5; float xmaxMultipl=50.5; /////////////////////////////////////////////////////////////////////// // DEFINITION OF HISTOGRAMS in directory /MDT/<region>_{A,C}/SectorXX/OVERVIEW : - // -// histoType="HitMultiplicity"; -// histoTitle = histoType+histoTitPart2; -// TH1F * HitMultiplicity = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); -// HitMultiplicity->GetXaxis()->SetTitle("Tot nr. hits"); - // - // histoType="HitMultiplicityAdcCut"; - // histoTitle = histoType+histoTitPart2; - // TH1F * HitMultiplicityAdcCut = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); - // - // histoType="HitMultiplicityVsEvent"; - // histoTitle = histoType+histoTitPart2; - // TH2F * HitMultiplicityVsEvent = new TH2F(histoType.c_str(),histoTitle.c_str(),200,0.,2000000.,nbinMultipl, xminMultipl, xmaxMultipl); - // // - Occupancies // histoType="z_HitsVsMezzanine"; @@ -1071,9 +927,9 @@ void HistogramManager::buildSector(string region, string side, int sector) { numTotChambers,0.,(float)numTotChambers,20,-0.5,19.5); HitsVsMezzanine->GetYaxis()->SetTitle("Mezzanine nr."); - string chamberType; + std::string chamberType; for (int ichamber = 0; ichamber<numTotChambers; ichamber++ ) { - string chamberName = chamberList[ichamber].getOnlineName(); + std::string chamberName = chamberList[ichamber].getOnlineName(); HitsVsMezzanine->GetXaxis()->SetBinLabel(ichamber+1,chamberName.c_str()); } @@ -1117,22 +973,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { h->GetXaxis()->SetTitle("Distance MDT segment to TGC hit (mm)"); } - // - /* - histoType="TDC_AllChambers_Inner_AdcCut"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - // - histoType="TDC_AllChambers_Middle_AdcCut"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - // - histoType="TDC_AllChambers_Outer_AdcCut"; - histoTitle = histoType+" "+histoTitPart2; - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinTDC,TDCmin,TDCmax); - // - */ - int etaMinI = 99; // Inner chambers int etaMaxI = -99; int etaMinM = 99; // Middle @@ -1159,7 +999,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { // check if it is a reasonable name ! // if ( !(chamberType.substr(0,1)=="B" || chamberType.substr(0,1)=="E") ) { - // cout << "HistogramManager::buildSector WARNING : unknown chamberType " << chamberType<<endl; continue; } // @@ -1259,7 +1098,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { fetaMaxX = (float)etaMaxI+0.5; histoType="HitsPerML_Inner"; histoTitle = histoType+" "+histoTitPart2; - //h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBins,fetaMin,fetaMax); h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); h->GetXaxis()->SetTitle("eta_id"); // @@ -1268,7 +1106,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { fetaMaxX = (float)etaMaxM+0.5; histoType="HitsPerML_Middle"; histoTitle = histoType+" "+histoTitPart2; - //h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBins,fetaMin,fetaMax); h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); h->GetXaxis()->SetTitle("eta_id"); // @@ -1277,7 +1114,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { fetaMaxX = (float)etaMaxO+0.5; histoType="HitsPerML_Outer"; histoTitle = histoType+" "+histoTitPart2; - //h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBins,fetaMin,fetaMax); h = new TH1F(histoType.c_str(),histoTitle.c_str(),etaBinsX,fetaMinX,fetaMaxX); h->GetXaxis()->SetTitle("eta_id"); @@ -1306,11 +1142,7 @@ void HistogramManager::buildSector(string region, string side, int sector) { histoTitle = "Distance Segment to RPC "+histoTitPart2; h = new TH1F(histoType.c_str(),histoTitle.c_str(),100,-50.,50.); h->GetXaxis()->SetTitle("Distance MDT segment to RPC hit (mm)"); - // - // histoType="MDT_RPC_Vs_Event"; - // histoTitle = "Distance Segment to RPC Vs Event "+histoTitPart2; - // h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,0.,2000000.,100,-50.,50.); - // + // GLOBAL TIME FIT HISTOGRAMS : // @@ -1337,12 +1169,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { h2->GetXaxis()->SetTitle("Residuals (mm)"); h2->GetYaxis()->SetTitle("BM chamber eta_id"); - // histoType="Hit_Residuals"; - // histoTitle = "eta_id Vs Hit Residuals "+histoTitPart2; - // h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,-5.,5.,6,0.5,6.5); - // h2->GetXaxis()->SetTitle("Hit Residuals (mm)"); - // h2->GetYaxis()->SetTitle("BM chamber eta_id"); - histoType="HitsOnSegment"; histoTitle = "eta_id Vs HitsOnSegment "+histoTitPart2; h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),10,0.5,10.5,6,0.5,6.5); @@ -1438,12 +1264,6 @@ void HistogramManager::buildSector(string region, string side, int sector) { h2->GetXaxis()->SetTitle("Residuals (mm)"); h2->GetYaxis()->SetTitle("EM chamber eta_id"); - // histoType="Hit_Residuals"; - // histoTitle = "eta_id Vs Hit Residuals "+histoTitPart2; - // h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),200,-5.,5.,6,0.5,6.5); - // h2->GetXaxis()->SetTitle("Hit Residuals (mm)"); - // h2->GetYaxis()->SetTitle("EM chamber eta_id"); - histoType="Hit_Res_Chi2DoF"; histoTitle = "eta_id Vs Hit Residuals Chi2/DoF"+histoTitPart2; h2 = new TH2F(histoType.c_str(),histoTitle.c_str(),100,0.,50.,6,0.5,6.5); @@ -1493,19 +1313,18 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string sector_name="Sector"+sectorString; - string sector_title="Sector "+sectorString; + std::string sector_name="Sector"+sectorString; + std::string sector_title="Sector "+sectorString; - string region=chamb.getRegion(); - string side=chamb.getSide(); + std::string region=chamb.getRegion(); + std::string side=chamb.getSide(); - string chamberName=chamb.getOnlineName(); - string chamberType=chamb.getName(); + std::string chamberName=chamb.getOnlineName(); + std::string chamberType=chamb.getName(); - // string motherdir="/MDT/Barrel_"+side+"/"+sector_name; - string motherdir=GetMdtDirectoryName(region, side, sector); + std::string motherdir=GetMdtDirectoryName(region, side, sector); m_rootfile->cd(motherdir.c_str()); TDirectoryFile * chamber_dir = new TDirectoryFile(chamberName.c_str(),chamberName.c_str()); @@ -1518,11 +1337,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { // // The following values should be read in from a Chamber Layout File - // - // int numML = 2; - // int numLayersPerML = 4; - // int numTubesPerLayer = 36; - // int numMezzanines = 10; int numTubesPerLayer[2], numOfMezzPerML[2]; numTubesPerLayer[0] = 0; @@ -1530,7 +1344,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { numOfMezzPerML[0] = 0; numOfMezzPerML[1] = 0; int numLayersPerML, numML, numTubesPerMezz, numMezzanines, numMaxTubesPerLayer; - // int nTubes, numLayers; int numTotTubesML[2]; int tubeNumberOffsetML[2]; // @@ -1540,22 +1353,20 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { tubeNumberOffsetML[0] = GetTubeOffsetML1(chamberName); tubeNumberOffsetML[1] = 0; - if ( m_muonIdHelperTool ) { - Identifier station_id = m_muonIdHelperTool->mdtIdHelper().elementID(chamberType, eta_id, phi_id); - numML = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(station_id); - Identifier MdtML1_id = m_muonIdHelperTool->mdtIdHelper().multilayerID(station_id,1); + if ( m_idHelper ) { + Identifier station_id = m_idHelper->mdtIdHelper().elementID(chamberType, eta_id, phi_id); + numML = m_idHelper->mdtIdHelper().numberOfMultilayers(station_id); + Identifier MdtML1_id = m_idHelper->mdtIdHelper().multilayerID(station_id,1); Identifier MdtML2_id; - if ( numML>1) MdtML2_id = m_muonIdHelperTool->mdtIdHelper().multilayerID(station_id,2); - numLayersPerML = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(MdtML1_id) - m_muonIdHelperTool->mdtIdHelper().tubeLayerMin(MdtML1_id) + 1; + if ( numML>1) MdtML2_id = m_idHelper->mdtIdHelper().multilayerID(station_id,2); + numLayersPerML = m_idHelper->mdtIdHelper().tubeLayerMax(MdtML1_id) - m_idHelper->mdtIdHelper().tubeLayerMin(MdtML1_id) + 1; if (chamberName.substr(0,4)=="BIS8") numLayersPerML=3; // PATCH TO MdtIdHelper BUG (should be fixed in next release) - numTubesPerLayer[0] = m_muonIdHelperTool->mdtIdHelper().tubeMax(MdtML1_id) - m_muonIdHelperTool->mdtIdHelper().tubeMin(MdtML1_id) + 1; + numTubesPerLayer[0] = m_idHelper->mdtIdHelper().tubeMax(MdtML1_id) - m_idHelper->mdtIdHelper().tubeMin(MdtML1_id) + 1; - if ( numML>1 ) numTubesPerLayer[1] = m_muonIdHelperTool->mdtIdHelper().tubeMax(MdtML2_id) - m_muonIdHelperTool->mdtIdHelper().tubeMin(MdtML2_id) + 1; + if ( numML>1 ) numTubesPerLayer[1] = m_idHelper->mdtIdHelper().tubeMax(MdtML2_id) - m_idHelper->mdtIdHelper().tubeMin(MdtML2_id) + 1; numMaxTubesPerLayer = numTubesPerLayer[0]; if (numTubesPerLayer[1]>numTubesPerLayer[0]) numMaxTubesPerLayer = numTubesPerLayer[1]; - // nTubes = numLayersPerML*(numTubesPerLayer[0]+numTubesPerLayer[1]); - // numLayers = numML*numLayersPerML; numTubesPerMezz = 8; if (numLayersPerML==4) numTubesPerMezz = 6; numOfMezzPerML[0] = numTubesPerLayer[0]/numTubesPerMezz; @@ -1573,15 +1384,10 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { numMaxTubesPerLayer = numTubesPerLayer[0]; if (numTubesPerLayer[1]>numTubesPerLayer[0]) numMaxTubesPerLayer = numTubesPerLayer[1]; numMezzanines = numOfMezzPerML[0]+numOfMezzPerML[1]; - // nTubes = numLayersPerML*(numTubesPerLayer[0]+numTubesPerLayer[1]); - // numLayers = numML*numLayersPerML; } numTotTubesML[0]=numLayersPerML*numTubesPerLayer[0]; numTotTubesML[1]=numLayersPerML*numTubesPerLayer[1]; - //float tubeMin= 0.5; - //float tubeMax= (float)nTubes + 0.5; - float allTubesMin = 0.5; float allTubesMax = (float) numTotTubesML[0]; if (numTotTubesML[0]<numTotTubesML[1]) allTubesMax = (float) numTotTubesML[1]; @@ -1589,10 +1395,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { allTubesMax = allTubesMax + 0.5; int nbinAllTubes = (int) (allTubesMax-allTubesMin); - // //cout << "numML ,numLayersPerML, numTotTubesML[0] , numTotTubesML[1] , allTubesMin , allTubesMax" - // << numML <<" "<<numLayersPerML<<" " << numTotTubesML[0] <<" "<< numTotTubesML[1] <<" "<< allTubesMin - // <<" "<< allTubesMax << endl; - int nbinMultipl=50; float xminMultipl=0.; float xmaxMultipl=50.; @@ -1611,9 +1413,9 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { TH1F * h1; TH2F * h2; - string histoTitPart2=chamberName; - string histoType; - string histoTitle; + std::string histoTitPart2=chamberName; + std::string histoType; + std::string histoTitle; /////////////////////////////////////////////////////////////////////////////// // // DEFINITION OF HISTOGRAMS in directory /MDT/Barrel_{A,C}/SectorXX/<chamber> : @@ -1624,21 +1426,13 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { histoTitle = "ChamberHitMultiplicity "+histoTitPart2; TH1F * HitMult = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); HitMult->GetXaxis()->SetTitle("Chamber tot nr. hits"); - // - // histoType="ChamberHitMultiplicityAdcCut"; - // histoTitle = histoType+" "+histoTitPart2; - // TH1F * HitMultAdcCut = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); - // + histoType="D_ChamberHitsOnSegment"; histoTitle = "ChamberHitsOnSegment "+histoTitPart2; TH1F * HitsOnSeg = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinMultipl, xminMultipl, xmaxMultipl); HitsOnSeg->GetXaxis()->SetTitle("nr. hits on segment"); HitsOnSeg->SetAxisRange(xminMultipl,20.5); - // - // histoType="ChamberHitMultiplicityVsEvent"; - // histoTitle = histoType+" "+histoTitPart2; - // TH2F * HitMultVsEv = new TH2F(histoType.c_str(),histoTitle.c_str(),200,0.,2000000, nbinMultipl, xminMultipl, xmaxMultipl); - // + // - occupancies // @@ -1666,16 +1460,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { HitsPerTubeAdcCut->GetXaxis()->SetTitle("Tube_id"); // // - efficiencies - // - /* - histoType="EfficiencyPerLayer"; - histoTitle = histoType+histoTitPart2; - TH1F * EfficiencyPerLayer = new TH1F(histoType.c_str(),histoTitle.c_str(),numLayers,0.5,numLayers+0.5); - EfficiencyPerLayer->SetMarkerStyle(20); - EfficiencyPerLayer->SetMarkerSize(1.0); - EfficiencyPerLayer->Sumw2(); - */ - //efficiency_dir->cd(); histoType="b_EfficiencyPerTube"; histoTitle = "EfficiencyPerTube "+histoTitPart2; @@ -1769,9 +1553,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { int tubesLayerExtended = tubesMLextended/numLayersPerML; for (int ibin=1;ibin<=nbinAllTubes;ibin++) { - // cout << " ibin, nbinAllTubes, numTotTubesML[0], numTubesPerLayer[1] " - // << ibin<<" "<< nbinAllTubes<<" "<< numTotTubesML[0]<<" "<< numTubesPerLayer[1]<<endl; - int binSign, layercode; if (ibin<=tubesMLextended) { binSign = -1; @@ -1783,13 +1564,10 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { layercode = layercode*10*binSign; } - // cout << " layercode "<< layercode << endl; - href->SetBinContent(ibin,layercode); } setChamberCutOut(chamberName, href ); - //setChamberDisconnectedTubes(chamberName, href ); histoType="DeadTubeMap"; histoTitle = histoType+" "+histoTitPart2; @@ -1797,27 +1575,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { h = (TH1F*) href->Clone(histoType.c_str()); h->SetTitle(histoTitle.c_str()); - /* - h = new TH1F(histoType.c_str(),histoTitle.c_str(),nbinAllTubes,allTubesMin,allTubesMax); - h->GetXaxis()->SetTitle("Tube_id"); - - for (int ibin=1;ibin<=nbinAllTubes;ibin++) { - int binSign, layercode; - if (ibin<=numTotTubesML[0]) { - binSign = -1; - layercode = (ibin/(numTubesPerLayer[0]+1)) + 1; - layercode = layercode*10*binSign; - } else { - binSign = 1; - layercode = ((ibin-numTotTubesML[0])/(numTubesPerLayer[1])+1) +1; - layercode = layercode*10*binSign; - } - h->SetBinContent(ibin,layercode); - } - */ - - - histoType="ChamberDeadChannels"; histoTitle = histoType+" "+histoTitPart2; h2 = new TH2F(histoType.c_str(),histoTitle.c_str(), @@ -1828,8 +1585,6 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { histoType="EffiResidVsRadius"; histoTitle = histoType+" "+histoTitPart2; - // h2 = new TH2F(histoType.c_str(),histoTitle.c_str(), - // 30,0.,15.,128,-16.,16.); h2 = new TH2F(histoType.c_str(),histoTitle.c_str(), 30,0.,15.,640,-16.,16.); h2->GetXaxis()->SetTitle("Segment distance from wire (mm)"); @@ -1895,7 +1650,7 @@ void HistogramManager::buildChamberHistos(MDTName chamb) { } -void HistogramManager::setChamberCutOut(string chamber, TH1F * href ) { +void HistogramManager::setChamberCutOut(std::string chamber, TH1F * href ) { //find the 'setBinContent' vector corresponding to the chamber name auto pvecPair = string2Vec.find(chamber); if (pvecPair != string2Vec.end()){ @@ -1904,7 +1659,7 @@ void HistogramManager::setChamberCutOut(string chamber, TH1F * href ) { } //if not found, do nothing. } -void HistogramManager::setChamberDisconnectedTubes(string chamber, TH1F * href ) { +void HistogramManager::setChamberDisconnectedTubes(std::string chamber, TH1F * href ) { auto pdisconnectedVectorOfPairs = disconnected.find(chamber); if (pdisconnectedVectorOfPairs != disconnected.end()){ for(const auto & thisPair:pdisconnectedVectorOfPairs->second){ @@ -1915,7 +1670,7 @@ void HistogramManager::setChamberDisconnectedTubes(string chamber, TH1F * href ) } -int HistogramManager::GetTubeOffsetML1(string chamber){ +int HistogramManager::GetTubeOffsetML1(std::string chamber){ int tubeOffset=0; if (chamber=="BIR1A11" ) tubeOffset=6; if (chamber=="BIR1A15" ) tubeOffset=6; @@ -1928,7 +1683,7 @@ int HistogramManager::GetTubeOffsetML1(string chamber){ return tubeOffset; } -int HistogramManager::GetTubeOffsetAtEndML1(string chamber){ +int HistogramManager::GetTubeOffsetAtEndML1(std::string chamber){ int tubeOffset=0; if (chamber.substr(0,4)=="BMS4") tubeOffset=8; if (chamber.substr(0,4)=="BMS6") tubeOffset=8; @@ -1946,35 +1701,35 @@ int HistogramManager::GetTubeOffsetAtEndML1(string chamber){ ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -TObject * HistogramManager::GetMdtHisto(string histo_name) { +TObject * HistogramManager::GetMdtHisto(std::string histo_name) { TObject * h = NULL; - string dir_name=GetMdtDirectoryName(); + std::string dir_name=GetMdtDirectoryName(); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if(dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetMdtHisto(string histo_name, string region, string side) { +TObject * HistogramManager::GetMdtHisto(std::string histo_name, std::string region, std::string side) { TObject * h = NULL; - string dir_name=GetMdtDirectoryName(region, side); + std::string dir_name=GetMdtDirectoryName(region, side); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if(dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetMdtHisto(string histo_name,string region, string side, int sector) { +TObject * HistogramManager::GetMdtHisto(std::string histo_name,std::string region, std::string side, int sector) { TObject * h = NULL; - string dir_name=GetMdtDirectoryName(region,side,sector); + std::string dir_name=GetMdtDirectoryName(region,side,sector); dir_name+="/OVERVIEW"; TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if(dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetMdtHisto(string histo_name, MDTName chamb) { +TObject * HistogramManager::GetMdtHisto(std::string histo_name, MDTName chamb) { TObject * h = NULL; - string dir_name=GetMdtDirectoryName(chamb); + std::string dir_name=GetMdtDirectoryName(chamb); if(histo_name.substr(0,14)=="HitsPerTube_ML"){ dir_name += "/Occupancy"; @@ -1990,117 +1745,115 @@ TObject * HistogramManager::GetMdtHisto(string histo_name, MDTName chamb) { } if(histo_name=="EffiResidVsRadius"){ dir_name=dir_name+"/Expert"; - //dir_name=dir_name; } TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if(dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -string HistogramManager::GetMdtDirectoryName() { - string Mdt_dirName="/MDT"; +std::string HistogramManager::GetMdtDirectoryName() { + std::string Mdt_dirName="/MDT"; return Mdt_dirName; } -string HistogramManager::GetMdtDirectoryName(string region, string side) { - string Mdt_dirName="/MDT/"+region+"_"+side; +std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side) { + std::string Mdt_dirName="/MDT/"+region+"_"+side; return Mdt_dirName; } -string HistogramManager::GetMdtDirectoryName(string region, string side, int sector) { +std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side, int sector) { ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString; + std::string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString; return Mdt_dirName; } -string HistogramManager::GetMdtDirectoryName(string region, string side, int sector, string chamberType, int eta) { +std::string HistogramManager::GetMdtDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta) { ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string chamberName = chamberType+ts(eta)+side+sectorString; - string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; + std::string chamberName = chamberType+ts(eta)+side+sectorString; + std::string Mdt_dirName="/MDT/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; return Mdt_dirName; } -string HistogramManager::GetMdtDirectoryName(MDTName chamb) { +std::string HistogramManager::GetMdtDirectoryName(MDTName chamb) { int sector=chamb.getOnlineSector(); ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string Mdt_dirName="/MDT/"+chamb.getRegion()+"_"+chamb.getSide()+"/Sector"+sectorString+"/"+chamb.getOnlineName(); - //std::cout<<Mdt_dirName<<endl; + std::string Mdt_dirName="/MDT/"+chamb.getRegion()+"_"+chamb.getSide()+"/Sector"+sectorString+"/"+chamb.getOnlineName(); return Mdt_dirName; } -TObject * HistogramManager::GetTDaqHisto(string histo_name, string region) { +TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region) { TObject * h = NULL; - string dir_name=GetTDaqDirectoryName(region); + std::string dir_name=GetTDaqDirectoryName(region); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if (dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetTDaqHisto(string histo_name, string region, string side) { +TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side) { TObject * h = NULL; - string dir_name=GetTDaqDirectoryName(region, side); + std::string dir_name=GetTDaqDirectoryName(region, side); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if (dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetTDaqHisto(string histo_name, string region, string side, int sector) { +TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector) { TObject * h = NULL; - string dir_name=GetTDaqDirectoryName(region, side,sector); + std::string dir_name=GetTDaqDirectoryName(region, side,sector); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if (dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -TObject * HistogramManager::GetTDaqHisto(string histo_name, string region, string side, int sector, string chamberType, int eta) { +TObject * HistogramManager::GetTDaqHisto(std::string histo_name, std::string region, std::string side, int sector, std::string chamberType, int eta) { TObject * h = NULL; - string dir_name=GetTDaqDirectoryName(region,side,sector,chamberType,eta); + std::string dir_name=GetTDaqDirectoryName(region,side,sector,chamberType,eta); TDirectory* dir = m_rootfile->GetDirectory(dir_name.c_str()); if (dir) h = dir->FindObjectAny(histo_name.c_str()); return h; } -string HistogramManager::GetTDaqDirectoryName(string region) { - string TDaq_dirName="Undefined"; +std::string HistogramManager::GetTDaqDirectoryName(std::string region) { + std::string TDaq_dirName="Undefined"; if (region=="Barrel") TDaq_dirName="/MDTvsRPC"; if (region=="Endcap") TDaq_dirName="/MDTvsTGC"; return TDaq_dirName; } -string HistogramManager::GetTDaqDirectoryName(string region, string side) { - string TDaq_dirName="undefined"; +std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side) { + std::string TDaq_dirName="undefined"; if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side; if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side; return TDaq_dirName; } -string HistogramManager::GetTDaqDirectoryName(string region, string side, int sector) { +std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side, int sector) { ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string TDaq_dirName="undefined"; + std::string TDaq_dirName="undefined"; if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side+"/Sector"+sectorString; if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side+"/Sector"+sectorString; return TDaq_dirName; } -string HistogramManager::GetTDaqDirectoryName(string region, string side, int sector, string chamberType, int eta) { +std::string HistogramManager::GetTDaqDirectoryName(std::string region, std::string side, int sector, std::string chamberType, int eta) { ToString ts; - string sectorString=ts(sector); + std::string sectorString=ts(sector); if(sector<10) sectorString="0"+sectorString; - string chamberName = chamberType+ts(eta)+side+sectorString; - string TDaq_dirName="undefined"; + std::string chamberName = chamberType+ts(eta)+side+sectorString; + std::string TDaq_dirName="undefined"; if (region=="Barrel") TDaq_dirName="/MDTvsRPC/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; if (region=="Endcap") TDaq_dirName="/MDTvsTGC/"+region+"_"+side+"/Sector"+sectorString+"/"+chamberName; return TDaq_dirName; } -TObject * HistogramManager::GetHisto(string main_dir, string histo_name) { +TObject * HistogramManager::GetHisto(std::string main_dir, std::string histo_name) { TObject * h = NULL; TDirectory* dir = m_rootfile->GetDirectory(main_dir.c_str()); if(dir) h = dir->FindObjectAny(histo_name.c_str()); @@ -2108,33 +1861,27 @@ TObject * HistogramManager::GetHisto(string main_dir, string histo_name) { } //////////////////////////////////////////////////////////////////////////////// -bool HistogramManager::openOutputFile(string outFileName) { - //cout<<"Opening Output File: "<< outFileName << endl; +bool HistogramManager::openOutputFile(std::string outFileName) { m_rootfile = new TFile(outFileName.c_str(),"recreate"); if (!m_rootfile) { - //cout<<"HistogramManager::openOutputFile : FAILING OPENING NEW FILE "<< outFileName << endl; return false; } else { return true; } } -bool HistogramManager::openReadOnlyFile(string outFileName) { - //cout<<"Opening Output File: "<< outFileName << endl; +bool HistogramManager::openReadOnlyFile(std::string outFileName) { m_rootfile = new TFile(outFileName.c_str(),"readonly"); if (!m_rootfile) { - //cout<<"HistogramManager::openReadOnlyFile : FAILING OPENING FILE "<< outFileName << endl; return false; } else { return true; } } -bool HistogramManager::openUpdateFile(string outFileName) { - //cout<<"Opening Output File: "<< outFileName << endl; +bool HistogramManager::openUpdateFile(std::string outFileName) { m_rootfile = new TFile(outFileName.c_str(),"update"); if (!m_rootfile) { - //cout<<"HistogramManager::openUpdateFile : FAILING OPENING FILE "<< outFileName << endl; return false; } else { return true; @@ -2151,27 +1898,27 @@ void HistogramManager::WriteAndCloseFile() { //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -int HistogramManager::GetEtaMax(string /* region*/, string /*side*/, int /*sector*/, string /*chamberType*/) { +int HistogramManager::GetEtaMax(std::string /* region*/, std::string /*side*/, int /*sector*/, std::string /*chamberType*/) { int etaMax = 6; return etaMax; } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -std::vector<MDTName> HistogramManager::GetChamberList(string region, string side, int sector) { +std::vector<MDTName> HistogramManager::GetChamberList(std::string region, std::string side, int sector) { //ToString ts; std::vector<MDTName> chamberList; - if ( m_muonIdHelperTool ) { - MdtIdHelper::const_id_iterator it = m_muonIdHelperTool->mdtIdHelper().module_begin(); - MdtIdHelper::const_id_iterator it_end = m_muonIdHelperTool->mdtIdHelper().module_end(); + if ( m_idHelper ) { + MdtIdHelper::const_id_iterator it = m_idHelper->mdtIdHelper().module_begin(); + MdtIdHelper::const_id_iterator it_end = m_idHelper->mdtIdHelper().module_end(); for(; it!=it_end;++it ) { - if ( !m_muonIdHelperTool->mdtIdHelper().is_mdt(*it) ) continue; - int station_index = m_muonIdHelperTool->mdtIdHelper().stationName(*it); - string stationName = m_muonIdHelperTool->mdtIdHelper().stationNameString(station_index); - int phi_id = m_muonIdHelperTool->mdtIdHelper().stationPhi(*it); - int eta_id = m_muonIdHelperTool->mdtIdHelper().stationEta(*it); + if ( !m_idHelper->mdtIdHelper().is_mdt(*it) ) continue; + int station_index = m_idHelper->mdtIdHelper().stationName(*it); + std::string stationName = m_idHelper->mdtIdHelper().stationNameString(station_index); + int phi_id = m_idHelper->mdtIdHelper().stationPhi(*it); + int eta_id = m_idHelper->mdtIdHelper().stationEta(*it); MDTName chamber(stationName,phi_id,eta_id); @@ -2195,7 +1942,7 @@ std::vector<MDTName> HistogramManager::GetChamberList(string region, string side //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -int HistogramManager::GetChamberNumOfML (string chamberName){ +int HistogramManager::GetChamberNumOfML (std::string chamberName){ int numOfML=0; const int numParams=10; int chamberGeo[numParams]; @@ -2204,7 +1951,7 @@ int HistogramManager::GetChamberNumOfML (string chamberName){ numOfML=chamberGeo[0]; return numOfML; } -int HistogramManager::GetChamberNumOfMezzPerML (string chamberName){ +int HistogramManager::GetChamberNumOfMezzPerML (std::string chamberName){ int numOfMezzPerML=0; const int numParams=10; int chamberGeo[numParams]; @@ -2213,7 +1960,7 @@ int HistogramManager::GetChamberNumOfMezzPerML (string chamberName){ numOfMezzPerML=chamberGeo[1]; return numOfMezzPerML; } -int HistogramManager::GetChamberTubesPerMezz (string chamberName){ +int HistogramManager::GetChamberTubesPerMezz (std::string chamberName){ int numOfTubesPerMezz=0; const int numParams=10; int chamberGeo[numParams]; @@ -2223,14 +1970,13 @@ int HistogramManager::GetChamberTubesPerMezz (string chamberName){ return numOfTubesPerMezz; } -void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoParams, int numParams) { +void HistogramManager::ReadChamberMapFile(std::string chamberName, int * chamberGeoParams, int numParams) { for (int i=0; i<numParams; i++) chamberGeoParams[i]=0; - string s; - ifstream inf("ChambersLayout.txt"); + std::string s; + std::ifstream inf("ChambersLayout.txt"); if(!inf.good()){ - //cout << "Text mapfile ChambersLayout.txt is missing! Check configuration."<<endl; return; } @@ -2238,14 +1984,13 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa while(getline(inf,s)){ // bool test=false; - string name, tag; - istringstream is(s); + std::string name, tag; + std::istringstream is(s); is>>tag; if(tag=="name"){ //scan chamber block if(!(is>>name).good()){//1. take the name - //cout<< " chamber name missing on mapfile "<<s.c_str() <<endl; break; } @@ -2258,7 +2003,6 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa //if what I find in file is NOT a chamber to be tested continue; } else { //3. read full information - // test=true; unsigned int ReadInfo=0; for(int i=0;i<20;i++){ @@ -2274,24 +2018,20 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa break; //out of "for" over 20 lines } - istringstream is(s); + std::istringstream is(s); is>>tag; if (tag=="MLayers"){ if (!(is>>chamberGeoParams[0]).good()) { - //cout << "WRONG MAP FILE FORMAT "<<endl; break; } - // cout << " Number of Multilayers = " << chamberGeoParams[0] << endl; ReadInfo++; } if(tag=="MezzPerML"){ if (!(is>>chamberGeoParams[1]).good()) { - //std::cout << "WRONG MAP FILE FORMAT "<<std::endl; break; } - // cout << " Mezzanines Per ML = " << chamberGeoParams[1] << endl; ReadInfo++; } @@ -2300,13 +2040,11 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa int tubesPerMezz=0; is>>mezzType; if (mezzType<1 || mezzType>4) { - //cout << "WRONG MAP FILE FORMAT "<<endl; break; } if (mezzType==1 || mezzType==2) tubesPerMezz=8; if (mezzType==3 || mezzType==4) tubesPerMezz=6; chamberGeoParams[2]=tubesPerMezz; - // cout << " Tubes Per Layer Per Mezzanine = " << chamberGeoParams[2] << endl; ReadInfo++; } @@ -2325,11 +2063,6 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa }// end for over 20 lines - if(ReadInfo!=6) { - // ERS_WARNING ("Incomplete map for "<<ChambList->at(it).name); - // ChambList->erase(ChambList->begin()+it); - // it--; - } break; //out of "for" loop on ChambList }// else if(name...) @@ -2339,39 +2072,3 @@ void HistogramManager::ReadChamberMapFile(string chamberName, int * chamberGeoPa return; } - - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -// -// TEST METHODS : -// -/* - void HistogramManager::test() { - cout << " You are in the test method. Opening output file with default name"<< endl; - string defaultOutputFile="outDQA.root"; - openOutputFile(defaultOutputFile); - - cout << " Now building All histograms buildAll()" <<endl; - buildAll(3,5); - - TH1F * h; - cout << " Now trying to retrieve histogram HitsPerTube from BML1A03 : " <<endl; - h = (TH1F*) GetMdtHisto("HitsPerTube","A",3,"BML",1); - cout << " Filling it with 1 entry " << endl; - h->Fill(14.); - cout <<" Check number of Entries :" << h->GetEntries() << endl; - - cout << " Now trying to retrieve histogram MDT_RPC for Sector 1 side C in MDTvsRPC directory : " <<endl; - h = (TH1F*) GetTDaqHisto("MDT_RPC","C",2); - cout << " Filling it with 1 entry " << endl; - h->Fill(3.5); - cout <<" Check number of Entries :" << h->GetEntries() << endl; - - cout <<" Writing and Closing File"<< endl; - m_rootfile->Write(); - m_rootfile->Close(); - } -*/ diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx index 3f33c921a44b..96bb2cacff61 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaGlobalTimeFit.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -22,15 +22,10 @@ #include <vector> #include <cstdlib> -// Athena // -// #include "GaudiKernel/MsgStream.h" - // MuonReadoutGeometry // #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "Identifier/IdentifierHash.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" #include "MuonCalibITools/IIdToFixedIdTool.h" #include "MdtCalibInterfaces/IMdtSegmentFitter.h" @@ -49,22 +44,15 @@ #include "MdtCalibData/IRtRelation.h" #include "MdtCalibUtils/GlobalTimeFitter.h" -// #include "MdtCalibInterfaces/IMdtSegmentFitter.h" #include "MdtCalibData/RtRelationLookUp.h" #include "MdtCalibData/RtFullInfo.h" #include "MdtCalibData/MdtCalibrationFactory.h" -// #include "MuonCalibStl/ToString.h" #include "MdtCalibFitters/LocalSegmentResolver.h" //MdtCalibFitters -// #include "MdtCalibFitters/MuCCaFitter.h" // OBSOLETE #include "MdtCalibFitters/DCSLFitter.h" - -// ------- - - // MdtDqaGlobalTimeFit // #include "MuonCalibStandAloneExtraTools/MdtDqaGlobalTimeFit.h" @@ -83,22 +71,18 @@ //:: NAMESPACE SETTINGS :: //:::::::::::::::::::::::: -using namespace std; namespace MuonCalib { //***************************************************************************** -// constructor - MdtDqaGlobalTimeFit::MdtDqaGlobalTimeFit(int nbHitsMin, int nbHitsMax, float chi2cut, int BfieldON, bool debug) : - m_muonIdHelperTool(NULL), m_detMgr(NULL), m_id_tool(NULL), p_reg_sel_svc(NULL), m_histoManager(NULL), - //m_tfile(NULL), - //m_tfile_debug(NULL), m_hit_ntuple(NULL), m_nb_hits(-1.), m_cal_region(NULL), - m_rtRel(NULL), - //m_qfitter(NULL), - m_muFitter(NULL), m_GTFitter(NULL) - //m_nb_trigger(-1), m_nb_stations(-1), - //m_htoffset(NULL) + m_detMgr(nullptr), + m_id_tool(nullptr), + p_reg_sel_svc(nullptr), + m_histoManager(nullptr), + m_rtRel(nullptr), + m_muFitter(nullptr), + m_GTFitter(nullptr) { m_minNumHits = nbHitsMin; m_maxNumHits = nbHitsMax; @@ -111,101 +95,23 @@ MdtDqaGlobalTimeFit::MdtDqaGlobalTimeFit(int nbHitsMin, int nbHitsMax, float chi //:: METHOD init :: //::::::::::::::::: -StatusCode MdtDqaGlobalTimeFit::initialize(const Muon::MuonIdHelperTool* muonIdHelperTool, const MuonGM::MuonDetectorManager *detMgr, +StatusCode MdtDqaGlobalTimeFit::initialize(const MuonGM::MuonDetectorManager *detMgr, const MuonCalib::IIdToFixedIdTool *id_tool, RegionSelectionSvc *reg_sel_svc, HistogramManager *histoManager) { - - // m_BfieldON = 0; // THIS PARAMETER MUST BE SET VIA jobOptions - // cout << " MdtDqaGlobalTimeFit::initialize ... " <<endl; - m_muonIdHelperTool = muonIdHelperTool; m_detMgr = detMgr; m_id_tool = id_tool; p_reg_sel_svc = reg_sel_svc; m_histoManager = histoManager; - // m_muFitter = new MuCCaFitter(); // OBSOLETE m_muFitter = new DCSLFitter(); m_rtRel = getDefaultRtRelation(m_BfieldON); m_GTFitter = new GlobalTimeFitter(m_muFitter, m_rtRel); - /* - ToString ts; - - string RegionName = p_reg_sel_svc->GetRegionSelection(); - cout << " MdtDqaGlobalTimeFit::initialize - RegionName: "<<RegionName<< endl; - - const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); - - //----------------------------------// - //-- Create Root Files and Histos --// - //----------------------------------// - - m_qfitter = NULL; - - m_nb_trigger = 0; - - // loop over stations in region - m_nb_stations = stationsInRegion.size(); - for (int istation=0;istation<m_nb_stations;istation++) { - for (int k=0;k<4;k++) m_nb_layers_tubes[istation][k] = -1; - } - cout << " end of first for loop " << endl; - - // - std::vector<MuonCalib::NtupleStationId>::const_iterator itstation; - for (itstation = stationsInRegion.begin(); - itstation!=stationsInRegion.end(); itstation++) { - cout << "in the loop. itest = "<<itest++ << endl; - string stationNameString = (itstation)->regionId(); - cout << " stationName : "<< stationNameString << endl; - } - - - for (int istation=0;istation<m_nb_stations;istation++) { - string stationNameString = stationsInRegion.at(istation).regionId(); - // cout << " initializing vector m_nb_layers_tubes. istation : "<< istation - // << " stationName: "<< stationNameString << endl; - string chamberType = stationNameString.substr(0,3); - int phi_id = stationsInRegion.at(istation).GetPhi(); - int eta_id = stationsInRegion.at(istation).GetEta(); - - // string fullStationName = chamberType+"_"+ts(phi_id)+"_"+ts(eta_id); - Identifier station_id = m_muonIdHelperTool->mdtIdHelper().elementID(chamberType, eta_id, phi_id); - int stationIntId = (int) station_id; - int numberOfML = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(station_id); - - for (int multilayer=1;multilayer<=numberOfML; multilayer++) { - Identifier MdtML = m_muonIdHelperTool->mdtIdHelper().multilayerID(station_id, multilayer); - int layerMin = m_muonIdHelperTool->mdtIdHelper().tubeLayerMin(MdtML); - int layerMax = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(MdtML); - int tubeMin = m_muonIdHelperTool->mdtIdHelper().tubeMin(MdtML); - int tubeMax = m_muonIdHelperTool->mdtIdHelper().tubeMax(MdtML); - m_nb_layers_tubes[istation][0] = stationIntId; - m_nb_layers_tubes[istation][1] = layerMax-layerMin+1; - m_nb_layers_tubes[istation][1+multilayer] = tubeMax-tubeMin+1; - } - } //end loop on stations - */ return StatusCode::SUCCESS; } //end MdtDqaGlobalTimeFit::initialize -//***************************************************************************** - - //::::::::::::::::::::: - //:: METHOD finalize :: - //::::::::::::::::::::: -StatusCode MdtDqaGlobalTimeFit::finalize() { - - /**** - Here I have removed everything : - I don't know why the m_mdtIdHelper here gets corrupted!!! - ****/ - - return StatusCode::SUCCESS; -} - //***************************************************************************** //:::::::::::::::::::::::: @@ -217,11 +123,7 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position) { - // if ( m_debug ) cout << " MdtDqaGlobalTimeFit::handleEvent ... " <<endl; - // if ( m_debug ) cout << " MdtDqaGlobalTimeFit:: segments.size() and position: "<<segments.size()<<" "<<position <<endl; - if (segments.size()<=position) return StatusCode::SUCCESS; - // MuonCalibSegment segment(*segments[position]); for (unsigned int k=position; k<segments.size(); k++) { // LOOP OVER SEGMENTS MuonCalibSegment segment(*segments[k]); @@ -229,9 +131,7 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, //---------------// //-- Variables --// //---------------// - - // int segAuthor = segment.author(); - // cout << "DEBUG DEBUG - segment.author() = " <<segAuthor; + int nhits = (int) segment.mdtHitsOnTrack(); bool REFIT_GTFIT = true; // THIS SHOULD BE PASSED VIA JOBOPTIONS !!!!!!!!!!!!! // station identifiers // @@ -246,7 +146,6 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, //-- Hits --// //----------// - // if ( m_debug ) cout << " MdtDqaGlobalTimeFit:: segments num of hits: "<<nhits <<endl; if(nhits<m_minNumHits || nhits>m_maxNumHits) continue; // @@ -261,85 +160,28 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, int eta = Mid.eta(); int absEta = eta; if (eta<0) absEta=-eta; - string stationNameStr = Mid.stationNameString(); + std::string stationNameStr = Mid.stationNameString(); // // HERE WE LIMIT THE ANALYSIS TO BM(L,S) and EM(L,S) CHAMBERS : // if ( !(stationNameStr.substr(0,2)=="BM" || stationNameStr.substr(0,2)=="EM") ) continue; - // if ( m_debug ) cout << " MdtDqaGlobalTimeFit:: stationNameStr: "<<stationNameStr <<endl; - - //int stationIntId = (int) m_muonIdHelperTool->mdtIdHelper().elementID(stationNameStr,eta,phi); - - string region = "Barrel"; + std::string region = "Barrel"; if ( stationNameStr.substr(0,1) == "E" ) region = "Endcap"; - string side = "A"; + std::string side = "A"; if (eta<0) side = "C"; PhiEtaNameConverter phiEtaConverter; - string chamberType = stationNameStr; + std::string chamberType = stationNameStr; - string fullStationName = chamberType+"_"+ts(phi)+"_"+ts(eta); - // if (m_debug) cout << " MdtDqaGlobalTimeFit on " << fullStationName << endl; + std::string fullStationName = chamberType+"_"+ts(phi)+"_"+ts(eta); int sector = phiEtaConverter.phi_8to16(stationNameId,phi); - // DEBUG DEBUG DEBUG - // DEBUG DEBUG DEBUG - // DEBUG DEBUG DEBUG - // double r; - // double dr; - // double t; - - /* MARCH 27, 2009 I comment this ! M.I. - for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); - it!=segment.mdtHOTEnd();++it) { - - t=(*it)->driftTime(); - r = (*it)->driftRadius(); // THIS IS A PATCH !!! ONE HAS TO PUT THE rt !!!! - //float rTEST = m_rtRel->radius(t); - dr=(*it)->sigmaDriftRadius(); - (*it)->setDriftRadius(r,dr); - // std::cout << "DEBUGDEBUG HIT RawTDC "<< (*it)->tdcCount() - // <<" RawTime "<<(*it)->tdcCount()*(25./32.) - // <<" Time "<<t<<" Radius "<<r<< "resol " - // <<dr <<" rTEST = "<< rTEST << std::endl; - } - */ // Commented March 27, 2009 - - //----------------------// - //-- GLOBAL TIME FIT --// - //----------------------// - // What does actually the resolver do ? - // from Dan Levin email of March 20, 2009 we can probably remove it! - // - /* MARCH 27, 2009 I comment this ! M.I. - LocalSegmentResolver resolver; - resolver.resolve(&segment); - */ // Commented March 27, 2009 - TH1F *h1; TH2F *h2; - // DEBUG DIFFERENCES BETWEEN OLD AND NEW SEGMENTS : - // - /* - double chi2_old = segment.chi2(); - double dirY_old = segment.direction().y(); - double dirZ_old = segment.direction().z(); - double posY_old = segment.position().y(); - double posZ_old = segment.position().z(); - double aseg_old = -999.; - double bseg_old = -999.; - if(dirZ_old !=0. ) { - aseg_old = dirY_old/dirZ_old; - bseg_old = posY_old - aseg_old*posZ_old; - } - */ - // - // DEBUG DIFFERENCES BETWEEN OLD AND NEW SEGMENTS : - float toffset(999.); if ( REFIT_GTFIT ) toffset =m_GTFitter->GTFit(&segment); @@ -348,79 +190,20 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, if ( REFIT_GTFIT ) DoF = DoF-1; float SegChi2 = SegChi2DoF*((float)DoF); - // DEBUG DIFFERENCES BETWEEN OLD AND NEW SEGMENTS : - // - /* - if ( REFIT_GTFIT ) { - double chi2_new = segment.chi2(); - double dirY_new = segment.direction().y(); - double dirZ_new = segment.direction().z(); - double posY_new = segment.position().y(); - double posZ_new = segment.position().z(); - double aseg_new = -999.; - double bseg_new = -999.; - if(dirZ_new !=0. ) { - aseg_new = dirY_new/dirZ_new; - bseg_new = posY_new - aseg_new*posZ_new; - } - - float abs_a_old = aseg_old; - if (aseg_old<0) abs_a_old = -aseg_old; - float abs_a_new = aseg_new; - if (aseg_new<0) abs_a_new = -aseg_new; - if ( abs_a_old<0.05 && abs_a_new>0.3 ) { - std::cout << " Event with 0 slope: " <<event.eventInfo().eventNumber()<<std::endl; - std::cout << " slope_old , slope_new : " << aseg_old << " "<< aseg_new <<std::endl; - } - - string debugHisto; - debugHisto = "a_old_Vs_a_new"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(debugHisto,region,side,sector); - if (h2) h2->Fill(aseg_new,aseg_old); - - debugHisto = "b_old_Vs_b_new"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(debugHisto,region,side,sector); - if (h2) h2->Fill(bseg_new,bseg_old); - - debugHisto = "a_diff"; - h1 = (TH1F*) m_histoManager->GetTDaqHisto(debugHisto,region,side,sector); - if (h1) h1->Fill(aseg_new-aseg_old); - - debugHisto = "b_diff"; - h1 = (TH1F*) m_histoManager->GetTDaqHisto(debugHisto,region,side,sector); - if (h1) h1->Fill(bseg_new-bseg_old); - } - */ - // - // DEBUG DIFFERENCES BETWEEN OLD AND NEW SEGMENTS : - - // if ( m_debug ) cout << " MdtDqaGlobalTimeFit:: segmentChi2perDoF: "<<SegChi2DoF <<endl; if (SegChi2DoF<=m_chi2_cut){ // chi2DoF cut - // if (m_debug) cout << "MdtDqaGlobalTimeFit handling segment with chi2, DoF and chi2/Dof : " - // << SegChi2 <<" "<< DoF <<" "<< SegChi2DoF << endl; // get MDT coordinates from first hit // (this can be changed in future by averaging over the hit for example) - - // std::vector<MdtCalibHitBase*>::iterator firstHit = segment.mdtHOTBegin(); // TRY THE FOLLOWING float distRO = (segment.mdtHOT()[0])->distanceToReadout(); // along the tube float tube = (float) ((segment.mdtHOT()[0])->identify()).mdtTube(); - //const HepGeom::Vector3D<double>& localPosHit=(segment.mdtHOT()[0])->localPosition(); - //float localX = localPosHit.x(); // along the tube - //float localZ = localPosHit.z(); // follows tube numbering - - // DEBUG DEBUG : - // std::cout << " DEBUGDEBUG firstHit coordinates : distRO "<<distRO - // << " tube "<<tube<<" localX "<<localX<<" localZ "<<localZ<<std::endl; - // // FILLING Histograms // - string histoType; + std::string histoType; - string station = "undefined"; + std::string station = "undefined"; if ( region == "Barrel" )station = "BM"; if ( region == "Endcap" )station = "EM"; @@ -429,11 +212,6 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, if (h1) { h1->Fill(toffset); } - // else { - // cout << "DEBUGDEBUG histo not found in dir " - // <<m_histoManager->GetTDaqDirectoryName(region, side,sector) <<endl;} - - // cout << " TEST TEST HISTTITLE = " << histoType << endl; histoType="TrigTimeVsROdistance_"+station+"_eta_"+ts(absEta); @@ -461,14 +239,7 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); it!=segment.mdtHOTEnd();++it) { - // const HepGeom::Point3D<double>& localClosestApproach = (*it)->localPointOfClosestApproach(); - // float localCloApZ = localClosestApproach.z(); // follows tube numbering - // const HepGeom::Point3D<double>& localTubeWirePosition = (*it)->localPosition(); - // float localTubeWirePositionZ = localTubeWirePosition.z(); // follows tube numbering float radius=(*it)->driftRadius(); - //cout << " DEBUG closestApproach " <<localCloApZ<<" tubePosition "<<localTubeWirePositionZ<<endl; - //cout << " DEBUG signedDistanceToTrack "<<(*it)->signedDistanceToTrack() - // << " radius "<<radius<<endl; if ((*it)->signedDistanceToTrack()<0.) radius=-radius; if (h1) h1->Fill(radius); @@ -491,48 +262,6 @@ StatusCode MdtDqaGlobalTimeFit::handleEvent( const MuonCalibEvent & /*event*/, if ((*it)->signedDistanceToTrack()<0.) radius=-radius; if (h2) h2->Fill(radius,resid); } -/* IMPLEMENTED BY NIR but REMOVED by himself afterward AT the moment we leave it commented - // Do the hit residuals calculation: - histoType="Hit_Residuals"; - h2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - histoType="Hit_Res_Chi2DoF"; - TH2F* h2_2 = (TH2F*) m_histoManager->GetTDaqHisto(histoType,region,side,sector); - - IMdtSegmentFitter::HitSelection ref_hitsel(segment.mdtHitsOnTrack(), 0); // Reference hit selection, containing 0 for all hits in segment - for (std::vector<MdtCalibHitBase*>::iterator it =segment.mdtHOTBegin(); - it!=segment.mdtHOTEnd();++it) { // Loop on all hits on tracks - unsigned int iHit = it-segment.mdtHOTBegin(); - IMdtSegmentFitter::HitSelection hitsel = ref_hitsel; - // Ignore hit iHit; - hitsel[iHit] = 1; - // Clone segment: - MuonCalibSegment segmentClone(segment); - // Printing hitSelections: - // cout<<"Fitting segment with hitSelection: [ "; - // for (IMdtSegmentFitter::HitSelection::const_iterator selIt = hitsel.begin(); - // selIt != hitsel.end(); selIt++) { // printing the hit selection - // cout << *selIt << " "; - // } - // cout<<"]\n"; - // Setment fit: - m_GTFitter->fit(segmentClone, hitsel); - - //Get the residual of the ignored hit: - float orig_resid = segment.mdtHOT()[iHit]->radialResidual(); // unsigned residual - float resid = segmentClone.mdtHOT()[iHit]->radialResidual(); // unsigned residual - float orig_dToTrack = segment.mdtHOT()[iHit]->signedDistanceToTrack(); // distance to track - float dToTrack = segmentClone.mdtHOT()[iHit]->signedDistanceToTrack(); // distance to track - float orig_driftR = segment.mdtHOT()[iHit]->driftRadius(); // drift Radius - float driftR = segmentClone.mdtHOT()[iHit]->driftRadius(); // drift Radius - float chi2DoF = segmentClone.chi2(); // segment chi2/dof - - // printf("orig_dToTrack = %6.2f dToTrack = %6.2f orig_driftR = %6.2f driftR = %6.2f orig_resid = %6.2f resid = %6.2f orig_chi2 = %6.2f new_chi2 = %6.2f n = %d\n", - // orig_dToTrack, dToTrack, orig_driftR, driftR, orig_resid, resid, segment.chi2(), segmentClone.chi2(), (int) segment.mdtHitsOnTrack()); - - if (h2) h2->Fill(resid,absEta); - if (h2_2) h2_2->Fill(chi2DoF, absEta); - } // End loop over hits -*/ } // End if over chi2DoF } // end LOOP OVER SEGMENTS @@ -556,108 +285,6 @@ IRtRelation *MdtDqaGlobalTimeFit::getDefaultRtRelation(int BfieldON ) { // B field is OFF : if ( BfieldON == 0) { - /* - rtPars.push_back(0.2 ); // r(-50) - rtPars.push_back(0.2 ); // r(-50 + 8) - rtPars.push_back(0.2 ); // .... - rtPars.push_back(0.2 ); - rtPars.push_back(0.22); - rtPars.push_back(0.25); - rtPars.push_back(0.3 ); - rtPars.push_back(0.4 ); - rtPars.push_back(0.7 ); - rtPars.push_back(1.106 ); - rtPars.push_back(1.506 ); - rtPars.push_back(1.898 ); - rtPars.push_back(2.283 ); - rtPars.push_back(2.658 ); - rtPars.push_back(3.024 ); - rtPars.push_back(3.38 ); - rtPars.push_back(3.725 ); - rtPars.push_back(4.058 ); - rtPars.push_back(4.381 ); - rtPars.push_back(4.693 ); - rtPars.push_back(4.993 ); - rtPars.push_back(5.281 ); - rtPars.push_back(5.559 ); - rtPars.push_back(5.826 ); - rtPars.push_back(6.082 ); - rtPars.push_back(6.327 ); - rtPars.push_back(6.563 ); - rtPars.push_back(6.788 ); - rtPars.push_back(7.005 ); - rtPars.push_back(7.213 ); - rtPars.push_back(7.412 ); - rtPars.push_back(7.603 ); - rtPars.push_back(7.787 ); - rtPars.push_back(7.964 ); - rtPars.push_back(8.135 ); - rtPars.push_back(8.299 ); - rtPars.push_back(8.458 ); - rtPars.push_back(8.613 ); - rtPars.push_back(8.762 ); - rtPars.push_back(8.908 ); - rtPars.push_back(9.05 ); - rtPars.push_back(9.189 ); - rtPars.push_back(9.325 ); - rtPars.push_back(9.458 ); - rtPars.push_back(9.59 ); - rtPars.push_back(9.719 ); - rtPars.push_back(9.847 ); - rtPars.push_back(9.974 ); - rtPars.push_back(10.099 ); - rtPars.push_back(10.224 ); - rtPars.push_back(10.348 ); - rtPars.push_back(10.471 ); - rtPars.push_back(10.593 ); - rtPars.push_back(10.715 ); - rtPars.push_back(10.837 ); - rtPars.push_back(10.958 ); - rtPars.push_back(11.078 ); - rtPars.push_back(11.198 ); - rtPars.push_back(11.317 ); - rtPars.push_back(11.435 ); - rtPars.push_back(11.552 ); - rtPars.push_back(11.668 ); - rtPars.push_back(11.783 ); - rtPars.push_back(11.896 ); - rtPars.push_back(12.008 ); - rtPars.push_back(12.118 ); - rtPars.push_back(12.226 ); - rtPars.push_back(12.332 ); - rtPars.push_back(12.435 ); - rtPars.push_back(12.536 ); - rtPars.push_back(12.635 ); - rtPars.push_back(12.731 ); - rtPars.push_back(12.824 ); - rtPars.push_back(12.915 ); - rtPars.push_back(13.003 ); - rtPars.push_back(13.088 ); - rtPars.push_back(13.17 ); - rtPars.push_back(13.251 ); - rtPars.push_back(13.329 ); - rtPars.push_back(13.406 ); - rtPars.push_back(13.481 ); - rtPars.push_back(13.556 ); - rtPars.push_back(13.64 ); - rtPars.push_back(13.74 ); - rtPars.push_back(13.83 ); - rtPars.push_back(13.9 ); - rtPars.push_back(14.0 ); - rtPars.push_back(14.08 ); - rtPars.push_back(14.18 ); - rtPars.push_back(14.27 ); - rtPars.push_back(14.37 ); - rtPars.push_back(14.45 ); - rtPars.push_back(14.55 ); - rtPars.push_back(14.62 ); - rtPars.push_back(14.7 ); - rtPars.push_back(14.75 ); - rtPars.push_back(14.8 ); - rtPars.push_back(14.82 ); - rtPars.push_back(14.84 ); - rtPars.push_back(14.86 ); - */ rtPars.push_back(0.2); // r(-50) rtPars.push_back(0.2); // r(-50+8) rtPars.push_back(0.2); // ... diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx index 85d5a38f19cd..3c0b2c4c2042 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/MdtDqaTubeEfficiency.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -22,9 +22,7 @@ #include <cstdlib> // Athena // - -#include "Identifier/IdentifierHash.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" // MuonReadoutGeometry // #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" @@ -64,19 +62,20 @@ //:: NAMESPACE SETTINGS :: //:::::::::::::::::::::::: -using namespace std; namespace MuonCalib { //***************************************************************************** - // constructor - MdtDqaTubeEfficiency::MdtDqaTubeEfficiency(float nsigma, float chi2Cut, bool defaultResol, float adcCut, bool GTFitON, bool useNewCalibConstants, bool useTimeCorrections) : - m_muonIdHelperTool(NULL), m_detMgr(NULL), m_id_tool(NULL), p_reg_sel_svc(NULL), p_calib_input_svc(NULL), - m_histoManager(NULL), - m_qfitter(NULL), + m_idHelper(nullptr), + m_detMgr(nullptr), + m_id_tool(nullptr), + p_reg_sel_svc(nullptr), + p_calib_input_svc(nullptr), + m_histoManager(nullptr), + m_qfitter(nullptr), m_nb_stations(-1) { m_nsigma = nsigma; @@ -91,19 +90,17 @@ MdtDqaTubeEfficiency::MdtDqaTubeEfficiency(float nsigma, float chi2Cut, //::::::::::::::::: //:: METHOD init :: //::::::::::::::::: -StatusCode MdtDqaTubeEfficiency::initialize(const Muon::MuonIdHelperTool *muonIdHelperTool, const MuonGM::MuonDetectorManager *detMgr, +StatusCode MdtDqaTubeEfficiency::initialize(const Muon::IMuonIdHelperSvc *idHelper, const MuonGM::MuonDetectorManager *detMgr, const MuonCalib::IIdToFixedIdTool *id_tool, RegionSelectionSvc *reg_sel_svc, MdtCalibInputSvc *calib_input_svc, HistogramManager *histoManager) { - m_muonIdHelperTool = muonIdHelperTool; + m_idHelper = idHelper; m_detMgr = detMgr; m_id_tool = id_tool; p_reg_sel_svc = reg_sel_svc; p_calib_input_svc = calib_input_svc; m_histoManager = histoManager; - - //ToString ts; - string RegionName = p_reg_sel_svc->GetRegionSelection(); + std::string RegionName = p_reg_sel_svc->GetRegionSelection(); const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); @@ -120,21 +117,21 @@ StatusCode MdtDqaTubeEfficiency::initialize(const Muon::MuonIdHelperTool *muonId } for (int istation=0;istation<m_nb_stations;istation++) { - string stationNameString = stationsInRegion.at(istation).regionId(); - string chamberType = stationNameString.substr(0,3); + std::string stationNameString = stationsInRegion.at(istation).regionId(); + std::string chamberType = stationNameString.substr(0,3); int phi_id = stationsInRegion.at(istation).GetPhi(); int eta_id = stationsInRegion.at(istation).GetEta(); - Identifier station_id = m_muonIdHelperTool->mdtIdHelper().elementID(chamberType, eta_id, phi_id); + Identifier station_id = m_idHelper->mdtIdHelper().elementID(chamberType, eta_id, phi_id); int stationIntId = static_cast<int>(station_id.get_identifier32().get_compact()); - int numberOfML = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(station_id); + int numberOfML = m_idHelper->mdtIdHelper().numberOfMultilayers(station_id); for (int multilayer=1;multilayer<=numberOfML; multilayer++) { - Identifier MdtML = m_muonIdHelperTool->mdtIdHelper().multilayerID(station_id, multilayer); - int layerMin = m_muonIdHelperTool->mdtIdHelper().tubeLayerMin(MdtML); - int layerMax = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(MdtML); - int tubeMin = m_muonIdHelperTool->mdtIdHelper().tubeMin(MdtML); - int tubeMax = m_muonIdHelperTool->mdtIdHelper().tubeMax(MdtML); + Identifier MdtML = m_idHelper->mdtIdHelper().multilayerID(station_id, multilayer); + int layerMin = m_idHelper->mdtIdHelper().tubeLayerMin(MdtML); + int layerMax = m_idHelper->mdtIdHelper().tubeLayerMax(MdtML); + int tubeMin = m_idHelper->mdtIdHelper().tubeMin(MdtML); + int tubeMax = m_idHelper->mdtIdHelper().tubeMax(MdtML); m_nb_layers_tubes[istation][0] = stationIntId; m_nb_layers_tubes[istation][1] = layerMax-layerMin+1; m_nb_layers_tubes[istation][1+multilayer] = tubeMax-tubeMin+1; @@ -146,20 +143,6 @@ StatusCode MdtDqaTubeEfficiency::initialize(const Muon::MuonIdHelperTool *muonId //***************************************************************************** -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: -StatusCode MdtDqaTubeEfficiency::finalize() { - /**** - Here I have removed everything : - I don't know why the m_mdtIdHelper here gets corrupted!!! - ****/ - - return StatusCode::SUCCESS; -} - -//***************************************************************************** - //:::::::::::::::::::::::: //:: METHOD handleEvent :: //:::::::::::::::::::::::: @@ -211,7 +194,7 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, // int phi = Mid.phi(); int eta = Mid.eta(); - string stationNameStr = Mid.stationNameString(); + std::string stationNameStr = Mid.stationNameString(); // // Check that all the hits in the segment belongs to the same chamber : @@ -236,7 +219,7 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, // // Get numberOfMultiLayers, numberOfLayers, numberOfTubes : // - int stationIntId = static_cast<int>(m_muonIdHelperTool->mdtIdHelper(). elementID(stationNameStr,eta,phi).get_compact()); + int stationIntId = static_cast<int>(m_idHelper->mdtIdHelper(). elementID(stationNameStr,eta,phi).get_compact()); Identifier station_id = m_id_tool->fixedIdToId(Mid); int numberOfML, numberOfLayers, numberOfTubes[2]; @@ -264,15 +247,15 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, // Get Histograms TFile *mdtDqaRoot = m_histoManager->rootFile(); - string region = chamb.getRegion(); - string side = chamb.getSide(); + std::string region = chamb.getRegion(); + std::string side = chamb.getSide(); PhiEtaNameConverter phiEtaConverter; - string chamberType = chamb.getName(); + std::string chamberType = chamb.getName(); - string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); - string effiDirName = chamberDirName+"/Efficiency"; - string expertDirName = chamberDirName+"/Expert"; + std::string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); + std::string effiDirName = chamberDirName+"/Efficiency"; + std::string expertDirName = chamberDirName+"/Expert"; TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str()); TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str()); @@ -283,7 +266,7 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, return StatusCode::FAILURE; } - string histoName; + std::string histoName; TH1F* heffiEntries; TH1F* heffiCounts; TH2F* heffiVsRadius; @@ -320,7 +303,6 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, GTFitter->setRtRelation(GTFitRt); // here a method on GTFitter should be implemented to setResolution ! // something like - // GlobalTimeFitter::setResolution( IRtResolution * GTFitResol) } toffset = GTFitter->GTFit(&segment); @@ -428,7 +410,7 @@ StatusCode MdtDqaTubeEfficiency::handleEvent( const MuonCalibEvent &event, for (int multilayer=1; multilayer<=numberOfML; multilayer++) { // LOOP OVER MULTILAYERS const MuonGM::MdtReadoutElement *MdtRoEl = - m_detMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(station_id,multilayer,1,1) ); + m_detMgr->getMdtReadoutElement( m_idHelper->mdtIdHelper().channelID(station_id,multilayer,1,1) ); //loop over layers for (int layer=1; layer<=numberOfLayers; layer++) { // LOOP OVER LAYERS @@ -619,8 +601,8 @@ StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegm for ( int istation=0; istation<m_nb_stations; istation++ ) { int phi = stationsInRegion.at(istation).GetPhi(); int eta = stationsInRegion.at(istation).GetEta(); - string stationNameString = stationsInRegion.at(istation).regionId(); - string chamberType = stationNameString.substr(0,3); + std::string stationNameString = stationsInRegion.at(istation).regionId(); + std::string chamberType = stationNameString.substr(0,3); MDTName chamb(chamberType,phi,eta); @@ -629,7 +611,6 @@ StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegm // with istation following the same order of stationsInRegion.at(istation) // ...if this is not the case, then the service m_mdtIdHelper should be used // matching the stationIntId : - // int stationIntId = (int) m_muonIdHelperTool->mdtIdHelper().elementID(chamberType, eta, phi); int numberOfML = 0; int numberOfTubes[2]; int numberOfLayers = m_nb_layers_tubes[istation][1]; @@ -638,14 +619,14 @@ StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegm if (numberOfTubes[0]>0 || numberOfTubes[1]>0 ) numberOfML = 1; if (numberOfTubes[0]>0 && numberOfTubes[1]>0 ) numberOfML = 2; - string region= chamb.getRegion(); - string side=chamb.getSide(); + std::string region= chamb.getRegion(); + std::string side=chamb.getSide(); PhiEtaNameConverter phiEtaConverter; - string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); + std::string chamberDirName = m_histoManager->GetMdtDirectoryName(chamb); - string effiDirName = chamberDirName+"/Efficiency"; - string expertDirName = chamberDirName+"/Expert"; + std::string effiDirName = chamberDirName+"/Efficiency"; + std::string expertDirName = chamberDirName+"/Expert"; TDirectory *chamberRootDir = mdtDqaRoot->GetDirectory(chamberDirName.c_str()); TDirectory *effiRootDir = mdtDqaRoot->GetDirectory(effiDirName.c_str()); TDirectory *expertRootDir = mdtDqaRoot->GetDirectory(expertDirName.c_str()); @@ -654,7 +635,7 @@ StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegm return StatusCode::FAILURE; } - string histoName; + std::string histoName; TH1F *heffiEntries; TH1F *heffiCounts; @@ -702,7 +683,7 @@ StatusCode MdtDqaTubeEfficiency::analyseSegments(const std::vector<MuonCalibSegm // Fill MdtDqa Histos // - string histoName; + std::string histoName; TH1F *heffi; chamberRootDir->cd(); histoName = "b_EfficiencyPerTube"; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx index 0cdaeeec6dd0..93c00b1246a3 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneExtraTools/src/NtupleMdtDqaTool.cxx @@ -1,11 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 13.08.2008, AUTHOR: MAURO IODICE -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS NtupleMdtDqaTool :: //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -21,11 +17,6 @@ #include <vector> #include <cstdlib> -// Athena // -#include "GaudiKernel/MsgStream.h" -#include "MuonIdHelpers/MdtIdHelper.h" -#include "Identifier/IdentifierHash.h" -#include "MuonIdHelpers/MdtIdHelper.h" // MuonReadoutGeometry // #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" @@ -39,13 +30,11 @@ #include "MdtCalibFitters/QuasianalyticLineReconstruction.h" #include "MuonCalibEventBase/MuonCalibEvent.h" - // NtupleMdtDqaTool // #include "MuonCalibStandAloneExtraTools/NtupleMdtDqaTool.h" #include "MuonCalibStandAloneExtraTools/PhiEtaUtils.h" #include "MuonCalibStandAloneExtraTools/MDTName.h" - //this #include "MuonCalibStandAloneBase/NtupleStationId.h" #include "MuonCalibStandAloneBase/RegionSelectionSvc.h" @@ -59,11 +48,6 @@ #include "TString.h" #include "TDirectory.h" -//:::::::::::::::::::::::: -//:: NAMESPACE SETTINGS :: -//:::::::::::::::::::::::: - -using namespace std; namespace MuonCalib { //***************************************************************************** @@ -79,7 +63,7 @@ NtupleMdtDqaTool::NtupleMdtDqaTool( const std::string &t, const std::string &n, declareInterface< NtupleCalibrationTool >(this); - m_MdtDqa_file_name = string("MdtDqa"); + m_MdtDqa_file_name = std::string("MdtDqa"); declareProperty("MdtDqaFileName", m_MdtDqa_file_name); m_verbose = false; @@ -158,40 +142,23 @@ NtupleMdtDqaTool::NtupleMdtDqaTool( const std::string &t, const std::string &n, //::::::::::::::::: StatusCode NtupleMdtDqaTool::initialize() { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "Initializing NtupleMdtDqaTool" << endmsg; + ATH_MSG_INFO("Initializing NtupleMdtDqaTool"); - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK(m_idHelperSvc.retrieve()); - StatusCode sc = detStore()->retrieve( m_detMgr ); - if (!sc.isSuccess()) { - log << MSG::FATAL << "Can't retrieve MuonDetectorManager" << endmsg; - return sc; - } + ATH_CHECK(detStore()->retrieve(m_detMgr)); //retrieve fixed id tool std::string idToFixedIdToolType("MuonCalib::IdToFixedIdTool"); std::string idToFixedIdToolName("MuonCalib_IdToFixedIdTool"); - sc = toolSvc()->retrieveTool(idToFixedIdToolType, idToFixedIdToolName, m_id_tool); - if(!sc.isSuccess()) { - log << MSG::FATAL << "Can't retrieve IdToFixedIdTool" << endmsg; - return sc; - } + ATH_CHECK(toolSvc()->retrieveTool(idToFixedIdToolType, idToFixedIdToolName, m_id_tool)); //get region selection service - sc=service("RegionSelectionSvc", p_reg_sel_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve RegionSelectionSvc!" <<endmsg; - return sc; - } + ATH_CHECK(service("RegionSelectionSvc", p_reg_sel_svc)); //get pointer to Calibration input service - sc=service("MdtCalibInputSvc", p_calib_input_svc); - if(!sc.isSuccess()) { - log << MSG::ERROR <<"Cannot retrieve MdtCalibInputSvc!" <<endmsg; - return sc; - } + ATH_CHECK(service("MdtCalibInputSvc", p_calib_input_svc)); //------------------------------------------------------// //-- Check Region and book histograms --// @@ -208,8 +175,8 @@ StatusCode NtupleMdtDqaTool::initialize() { int SectorMin[2][2] ; int SectorMax[2][2] ; int SectorMinMax[2][2][2]; - string spectrometerRegion[2]; - string spectrometerSide[2]; + std::string spectrometerRegion[2]; + std::string spectrometerSide[2]; spectrometerRegion[0] = "Barrel"; spectrometerRegion[1] = "Endcap"; spectrometerSide[0] = "A"; @@ -226,9 +193,8 @@ StatusCode NtupleMdtDqaTool::initialize() { const std::vector<MuonCalib::NtupleStationId> stationsInRegion = p_reg_sel_svc->GetStationsInRegions(); std::vector<MuonCalib::NtupleStationId>::const_iterator itstation; for (itstation = stationsInRegion.begin(); itstation!=stationsInRegion.end(); itstation++) { -// int stationNameId = itstation->GetStation(); - string stationName = itstation->regionId(); - string chamberType = stationName.substr(0,3); + std::string stationName = itstation->regionId(); + std::string chamberType = stationName.substr(0,3); int phi = itstation->GetPhi(); int eta = itstation->GetEta(); @@ -262,10 +228,10 @@ StatusCode NtupleMdtDqaTool::initialize() { // m_histoManager = new HistogramManager(); // use HistogramManager constructor with MdtIdHelper to retrieve the chamber geometry - m_histoManager = new HistogramManager(m_muonIdHelperTool.get()); + m_histoManager = new HistogramManager(m_idHelperSvc.get()); m_histoManager->SetDoTracks(m_doTracks); - string mdtDqaRootFileName = m_MdtDqa_file_name+".root"; + std::string mdtDqaRootFileName = m_MdtDqa_file_name+".root"; if (m_fillHistos || m_doTracks) { if(!m_histoManager->openOutputFile(mdtDqaRootFileName)) return StatusCode::FAILURE; } @@ -285,9 +251,6 @@ StatusCode NtupleMdtDqaTool::initialize() { int secMax = SectorMax[i][j]; if (secMin>0&&secMin<=16 && secMax>0&&secMax<=16 && secMin<=secMax ) { m_histoManager->buildTopLevel(spectrometerRegion[i],spectrometerSide[j], secMin, secMax); - // std::cout<<" Top Level Histograms histogram built for region :" - // <<spectrometerRegion[i] <<" Side : " << spectrometerSide[j] - // <<"Sector min : "<< secMin<< "Sector max : "<< secMax<< std::endl; } } } @@ -296,17 +259,14 @@ StatusCode NtupleMdtDqaTool::initialize() { // for (itstation = stationsInRegion.begin(); itstation!=stationsInRegion.end(); itstation++) { // int stationNameId = itstation->GetStation(); - string stationName = itstation->regionId(); - string chamberType = stationName.substr(0,3); + std::string stationName = itstation->regionId(); + std::string chamberType = stationName.substr(0,3); int phi = itstation->GetPhi(); int eta = itstation->GetEta(); MDTName chamb(chamberType,phi,eta); - string region = chamb.getRegion(); - string side = chamb.getSide(); - // int sector = chamb.getOnlineSector(); - - // std::cout<<" Chamber Histograms building : "<<chamb.getOnlineName()<<std::endl; + std::string region = chamb.getRegion(); + std::string side = chamb.getSide(); m_histoManager->buildChamberHistos(chamb); } } @@ -331,14 +291,13 @@ StatusCode NtupleMdtDqaTool::initialize() { m_tubeEffi = new MdtDqaTubeEfficiency(m_EffiNSigma, m_EffiChi2Cut, m_EffiUseDefaultResolution, m_EffiHitADCCut, m_EffiGTFitON, m_EffiUseNewCalibConstants, m_EffiUseTimeCorrections); - if(!m_tubeEffi->initialize(m_muonIdHelperTool.get(), m_detMgr, m_id_tool, p_reg_sel_svc, p_calib_input_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; + if(!m_tubeEffi->initialize(m_idHelperSvc.get(), m_detMgr, m_id_tool, p_reg_sel_svc, p_calib_input_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; } if (m_doGlobalTimeFit) { - // m_globalTimeFit = new MdtDqaGlobalTimeFit(4,10,50.,false); m_globalTimeFit = new MdtDqaGlobalTimeFit(m_GTFitSeg_minNumHits,m_GTFitSeg_maxNumHits,m_GTFitSeg_chi2Cut, m_rtDefaultBfieldON, m_GTFitDebug); - if(!m_globalTimeFit->initialize(m_muonIdHelperTool.get(), m_detMgr, m_id_tool, p_reg_sel_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; + if(!m_globalTimeFit->initialize(m_detMgr, m_id_tool, p_reg_sel_svc, m_histoManager).isSuccess()) return StatusCode::FAILURE; } //FOR THE TRACK ANALYSIS if (m_doTracks) { @@ -355,11 +314,10 @@ StatusCode NtupleMdtDqaTool::initialize() { StatusCode NtupleMdtDqaTool::finalize(void) { - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "Finalizing NtupleMdtDqaTool" << endmsg; + ATH_MSG_INFO("Finalizing NtupleMdtDqaTool"); if (m_doFinalize) { - log << MSG::INFO << "Executing MdtDqaNtupleAnalysis::histogramAnalysis " << endmsg; + ATH_MSG_INFO("Executing MdtDqaNtupleAnalysis::histogramAnalysis "); m_ntupleAna->histogramAnalysis(m_histoManager->rootFile()); } @@ -395,14 +353,7 @@ StatusCode NtupleMdtDqaTool::handleEvent( const MuonCalibEvent &event, //:: METHOD analyseSegments :: //:::::::::::::::::::::::::::: StatusCode NtupleMdtDqaTool::analyseSegments(const std::vector<MuonCalibSegment *> &/*segments*/) { - - MsgStream log(msgSvc(), name()); - log << MSG::INFO << "NtupleMdtDqaTool::analyseSegments ...it does nothing analysis moved elsewhere" - << endmsg; - // if (m_doFinalize && m_doEfficiency ) { - // log << MSG::INFO << "Executing MdtDqaTubeEfficiency::analyseSegments" << endmsg; - // m_tubeEffi->analyseSegments(segments); - // } + ATH_MSG_INFO("NtupleMdtDqaTool::analyseSegments ...it does nothing analysis moved elsewhere"); return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h index 64ee9f291668..8f1fd8eb8e0d 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleDisplayTool.h @@ -1,11 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 19.10.2007, AUTHOR: STEFFEN KAISER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - #ifndef MuonCalib_NtupleDisplayToolH #define MuonCalib_NtupleDisplayToolH @@ -42,7 +38,7 @@ class TApplication; // MuonCalib #include "MdtCalibInterfaces/IMdtPatRecFitter.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class RegionSelectionSvc; @@ -62,19 +58,13 @@ class NtupleDisplayTool : public AthAlgTool, virtual public NtupleCalibrationToo public: // Constructors // NtupleDisplayTool(const std::string& t, const std::string& n, const IInterface* p); - ///< Default constructor. - inline ~NtupleDisplayTool(){} + ~NtupleDisplayTool()=default; ///< Destructor - - // Methods // /** tool initialize */ StatusCode initialize(); - /** tool finalize */ - StatusCode finalize(); - StatusCode handleEvent(const MuonCalibEvent & event, int evnt_nr, const std::vector<MuonCalibSegment *> &segments, unsigned int position); ///< analysis of the given segment of ///< event eventnumber, event contains @@ -88,9 +78,7 @@ class NtupleDisplayTool : public AthAlgTool, virtual public NtupleCalibrationToo } private: - //for retrieving the chamber geometry - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h index 5bed7e13dff1..1a60f0e423da 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleRunScanTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef _NtupleRunScanTool_H @@ -12,9 +12,10 @@ #include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" #include "MuonCalibStandAloneBase/NtupleStationId.h" #include "MuonCalibStandAloneTools/HitCounter.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "AthenaBaseComps/AthAlgTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class TFile; @@ -33,13 +34,9 @@ class NtupleRunScanTool: public AthAlgTool, virtual public NtupleCalibrationToo //============================================================================== /** Tool Constructor*/ NtupleRunScanTool(const std::string& t, const std::string& n, const IInterface* p); + ~NtupleRunScanTool()=default; /** tool initialization */ StatusCode initialize(); - /** tool finalization */ - inline StatusCode finalize() - { - return StatusCode::SUCCESS; - } /**analyse event - fill hits into specra*/ StatusCode handleEvent(const MuonCalibEvent &event, int /*evnt_nr*/, const std::vector<MuonCalibSegment *> &segments, unsigned int position); /** end of events analysis - segemnts are not used here*/ @@ -62,8 +59,7 @@ class NtupleRunScanTool: public AthAlgTool, virtual public NtupleCalibrationToo //! hit counter classes - sortet by station std::map<NtupleStationId, HitCounter> m_hit_counters; //!access to geomodel - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h index fd7ecc1fecd6..f930c92a109e 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -38,7 +38,7 @@ #include "MuonCalibStandAloneBase/NtupleCalibrationTool.h" #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ServiceHandle.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" class RegionSelectionSvc; @@ -64,13 +64,10 @@ class NtupleTubeEfficiencyTool : public AthAlgTool, virtual public NtupleCalibra public: // Constructors // NtupleTubeEfficiencyTool(const std::string& t, const std::string& n, const IInterface* p); - ///< Default constructor. - inline ~NtupleTubeEfficiencyTool(){} + ~NtupleTubeEfficiencyTool()=default; ///< Destructor - // Methods // - /** tool initialize */ StatusCode initialize(); @@ -90,8 +87,7 @@ class NtupleTubeEfficiencyTool : public AthAlgTool, virtual public NtupleCalibra } private: - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; // MuonDetectorManager from the conditions store SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey {this, "DetectorManagerKey", diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx index 1c6358bc9032..31ad0519a4b7 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleDisplayTool.cxx @@ -1,19 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 19.10.2007, AUTHOR: STEFFEN KAISER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS NtupleDisplay :: -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -//:::::::::::::::::: -//:: HEADER FILES :: -//:::::::::::::::::: - // standard C++ // #include <iostream> #include <fstream> @@ -22,13 +10,9 @@ #include <cstdlib> #include <sstream> -// Athena // -#include "MuonIdHelpers/MdtIdHelper.h" - // MuonReadoutGeometry // #include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "Identifier/IdentifierHash.h" #include "MuonCalibITools/IIdToFixedIdTool.h" #include "MdtCalibInterfaces/IMdtSegmentFitter.h" @@ -43,12 +27,10 @@ // NtupleDisplayTool // #include "MuonCalibStandAloneTools/NtupleDisplayTool.h" - //this #include "MuonCalibStandAloneBase/NtupleStationId.h" #include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - //root #include "TCanvas.h" #include "TControlBar.h" @@ -62,17 +44,11 @@ // STL // #include <string> -//:::::::::::::::::::::::: -//:: NAMESPACE SETTINGS :: -//:::::::::::::::::::::::: - -using namespace std; namespace MuonCalib { //***************************************************************************** // constructor - NtupleDisplayTool::NtupleDisplayTool( const std::string& t, const std::string& n, const IInterface* p) : @@ -86,7 +62,7 @@ NtupleDisplayTool::NtupleDisplayTool( const std::string& t, //-- Job Options --// //-----------------// - m_fitter_name = string("QuasianalyticLineReconstruction"); + m_fitter_name = std::string("QuasianalyticLineReconstruction"); declareProperty("fitterName", m_fitter_name); m_nb_hits = 5; @@ -132,7 +108,7 @@ StatusCode NtupleDisplayTool::initialize() { //-- Get the StoreGate Stuff --// //-----------------------------// - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK(m_idHelperSvc.retrieve()); //retrieve detector manager from the conditions store ATH_CHECK(m_DetectorManagerKey.initialize()); @@ -154,7 +130,7 @@ StatusCode NtupleDisplayTool::initialize() { m_nb_tubes = -1; //vector of colors to be used - m_colors = vector<int>(5); + m_colors = std::vector<int>(5); m_colors[0] = 3; //segment hit m_colors[1] = 14; //raw hit m_colors[2] = 1; //drift radius>14.6 @@ -162,14 +138,14 @@ StatusCode NtupleDisplayTool::initialize() { m_colors[4] = 0; //drift time<0 // tube circles - m_tube_circle = vector< vector< vector<TubeCircle*> > >(2); //up to two multilayers + m_tube_circle = std::vector< std::vector< std::vector<TubeCircle*> > >(2); //up to two multilayers for (unsigned int k=0; k<m_tube_circle.size(); k++) { - m_tube_circle[k] = vector< vector<TubeCircle*> >(4); // up to four layers per multilayer + m_tube_circle[k] = std::vector< std::vector<TubeCircle*> >(4); // up to four layers per multilayer for (unsigned int l=0; l<m_tube_circle[k].size(); l++) { - m_tube_circle[k][l] = vector<TubeCircle*>(72); // up to 72 tubes per layer + m_tube_circle[k][l] = std::vector<TubeCircle*>(72); // up to 72 tubes per layer for (unsigned int m=0; m<m_tube_circle[k][l].size(); m++) { m_tube_circle[k][l][m] = new TubeCircle(m_colors,m_adc_cut); @@ -187,20 +163,6 @@ StatusCode NtupleDisplayTool::initialize() { //***************************************************************************** -//::::::::::::::::::::: -//:: METHOD finalize :: -//::::::::::::::::::::: - -StatusCode NtupleDisplayTool::finalize(void) { - - ATH_MSG_INFO( "Finalizing NtupleDisplayTool" ); - - return StatusCode::SUCCESS; - -} - -//***************************************************************************** - //:::::::::::::::::::::::: //:: METHOD handleEvent :: //:::::::::::::::::::::::: @@ -228,14 +190,14 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, //---------------// if(m_qfitter==NULL){ - if (m_fitter_name==string("QuasianalyticLineReconstruction")) { + if (m_fitter_name==std::string("QuasianalyticLineReconstruction")) { m_qfitter = new QuasianalyticLineReconstruction(); } - if (m_fitter_name==string("StraightPatRec")) { + if (m_fitter_name==std::string("StraightPatRec")) { m_qfitter = new StraightPatRec(); } - if (m_fitter_name!=string("QuasianalyticLineReconstruction") && - m_fitter_name!=string("StraightPatRec")) { + if (m_fitter_name!=std::string("QuasianalyticLineReconstruction") && + m_fitter_name!=std::string("StraightPatRec")) { ATH_MSG_FATAL( "Unknown track fitter!" ); return StatusCode::FAILURE; } @@ -260,11 +222,11 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, Identifier station_id = m_id_tool->fixedIdToId(Mid); NtupleStationId st_id((segment.mdtHOT()[0])->identify()); st_id.SetMultilayer(0); - if (!st_id.InitializeGeometry(m_muonIdHelperTool->mdtIdHelper(), MuonDetMgr)) + if (!st_id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) return StatusCode::SUCCESS; if(m_nb_multilayers<0){ - m_nb_multilayers = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(station_id); + m_nb_multilayers = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(station_id); } @@ -283,7 +245,7 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, for (int multilayer=1; multilayer<m_nb_multilayers+1; multilayer++) { const MuonGM::MdtReadoutElement* MdtRoEl = - MuonDetMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(station_id,multilayer,1,1) ); + MuonDetMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(station_id,multilayer,1,1) ); //loop over layers for (int layer=st_id.LayerMin(multilayer-1); layer<=st_id.LayerMax(multilayer-1); layer++) { @@ -293,10 +255,7 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, Amg::Vector3D TubePos = MdtRoEl->GlobalToAmdbLRSCoords(MdtRoEl->tubePos(multilayer,layer,k)); - //ATH_MSG_INFO( "ml: " << multilayer << ", " << TubePos ); - //set the tube position -// ATH_MSG_INFO( multilayer <<" "<< layer<<" "<<k ); m_tube_circle[multilayer-1][layer-1][k-1] ->setPosition(TubePos); m_tube_circle[multilayer-1][layer-1][k-1]->multilayer= multilayer; m_tube_circle[multilayer-1][layer-1][k-1]->layer= layer; @@ -595,7 +554,6 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, std::ostringstream ostr; ostr << m_tube_circle_lin[k]->multilayer << "/" << m_tube_circle_lin[k]->layer << "/" <<m_tube_circle_lin[k]->tube; TLatex *txt=new TLatex( m_tube_circle_lin[k]->GetX1() - 2* m_tube_circle_lin[k]->GetR1(), m_tube_circle_lin[k]->GetY1(), ostr.str().c_str()); -// txt->SetTextSize(1); txt->Draw(); ATH_MSG_INFO( ostr.str() ); } @@ -604,7 +562,6 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, line->Draw(); if(fit_success){ - //if(fit_success && m_qfitter->numberOfTrackHits()>=m_nb_hits){ line_refit->Draw(); } else{ @@ -614,19 +571,6 @@ NtupleDisplayTool::handleEvent( const MuonCalibEvent & event, m_canvas->Update(); m_root->Run(true); //run the TApplication - //old control mechanism - //if(m_chosen_event!=-1){ - //return StatusCode::SUCCESS; - //} - - // ATH_MSG_INFO( "Event: " << eventnumber << " -> Press Return to continue to the next event! (q for exit)" ); - //char c = getchar(); - - //if(c==char('q')){ - // exit(0); - //} - - //------------------// //-- Reset Canvas --// //------------------// @@ -667,13 +611,13 @@ TubeCircle::TubeCircle(void) : TEllipse(){ layer=0; multilayer=0; tube=0; this->reset(); - this->setColors(vector<int>(5,1)); + this->setColors(std::vector<int>(5,1)); this->setAdcCut(50.); } -TubeCircle::TubeCircle(vector<int> colors, double adc_cut) : TEllipse(){ +TubeCircle::TubeCircle(std::vector<int> colors, double adc_cut) : TEllipse(){ layer=0; multilayer=0; tube=0; this->reset(); @@ -682,7 +626,7 @@ TubeCircle::TubeCircle(vector<int> colors, double adc_cut) : TEllipse(){ } -TubeCircle::TubeCircle(Amg::Vector3D TubePos, vector<int> colors, double adc_cut) : TEllipse(){ +TubeCircle::TubeCircle(Amg::Vector3D TubePos, std::vector<int> colors, double adc_cut) : TEllipse(){ layer=0; multilayer=0; tube=0; this->reset(); diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx index 4f862ddf8719..25c40b1dbc1c 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleRunScanTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //c - c++ @@ -22,15 +22,12 @@ // MuonReadoutGeometry // #include "MuonReadoutGeometry/MdtReadoutElement.h" - //MuonCalibIdentifier #include "MuonCalibIdentifier/MuonFixedId.h" - //this #include "MuonCalibStandAloneTools/NtupleRunScanTool.h" - namespace MuonCalib{ NtupleRunScanTool::NtupleRunScanTool(const std::string& t, const std::string& n, const IInterface* p): AthAlgTool(t, n, p), m_min_hits(2000), m_max_bad_fits(0.1), m_suppress_nofit(false), m_noisy_tube_factor(1), m_time_min(std::numeric_limits<unsigned int>::max()), m_time_max(0), m_run_min(std::numeric_limits<unsigned int>::max()), m_run_max(0) @@ -50,9 +47,7 @@ StatusCode NtupleRunScanTool::initialize() ATH_MSG_FATAL( "MaxBadFits must be between 0 and 1!" ); return StatusCode::FAILURE; } -//get geometry - //retrieve mdt id helper - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK(m_idHelperSvc.retrieve()); //retrieve detector manager from the conditions store ATH_CHECK(m_DetectorManagerKey.initialize()); @@ -101,7 +96,7 @@ StatusCode NtupleRunScanTool::handleEvent(const MuonCalibEvent &event, int /*evn HitCounter &counter(m_hit_counters[id]); if(!counter.IsInitialized()) { - if(!id.InitializeGeometry(m_muonIdHelperTool->mdtIdHelper(), MuonDetMgr)) + if(!id.InitializeGeometry(m_idHelperSvc->mdtIdHelper(), MuonDetMgr)) { ATH_MSG_FATAL( "Cannot initialize Geometry!" ); return StatusCode::FAILURE; diff --git a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx index db4389305357..2e360bf58e5b 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibStandAlone/MuonCalibStandAloneTools/src/NtupleTubeEfficiencyTool.cxx @@ -1,15 +1,7 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// 10.04.2007, AUTHOR: STEFFEN KAISER -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS NtupleTubeEfficiencyTool :: -//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - //:::::::::::::::::: //:: HEADER FILES :: //:::::::::::::::::: @@ -25,8 +17,6 @@ #include "MuonReadoutGeometry/RpcReadoutElement.h" #include "MuonReadoutGeometry/MdtReadoutElement.h" -#include "Identifier/IdentifierHash.h" -#include "MuonIdHelpers/MdtIdHelper.h" #include "MuonCalibITools/IIdToFixedIdTool.h" #include "MdtCalibInterfaces/IMdtSegmentFitter.h" @@ -40,12 +30,10 @@ // NtupleTubeEfficiencyTool // #include "MuonCalibStandAloneTools/NtupleTubeEfficiencyTool.h" - //this #include "MuonCalibStandAloneBase/NtupleStationId.h" #include "MuonCalibStandAloneBase/RegionSelectionSvc.h" - //root #include "TFile.h" #include "TH1.h" @@ -53,11 +41,6 @@ #include "TString.h" #include "TDirectory.h" -//:::::::::::::::::::::::: -//:: NAMESPACE SETTINGS :: -//:::::::::::::::::::::::: - -using namespace std; namespace MuonCalib { //***************************************************************************** @@ -81,7 +64,7 @@ NtupleTubeEfficiencyTool::NtupleTubeEfficiencyTool( const std::string& t, m_debug = false; declareProperty("Debug", m_debug); - m_file_name = string("TubeEfficiencies"); + m_file_name = std::string("TubeEfficiencies"); declareProperty("fileName", m_file_name); m_chi2_cut = 10.0; @@ -104,7 +87,7 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { //-- Get the StoreGate Stuff --// //-----------------------------// - ATH_CHECK( m_muonIdHelperTool.retrieve() ); + ATH_CHECK( m_idHelperSvc.retrieve() ); //retrieve detector manager from the conditions store ATH_CHECK(m_DetectorManagerKey.initialize()); @@ -127,7 +110,6 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { if(m_debug){ - //m_tfile_debug = new TFile(TString(m_file_name).ReplaceAll(".root","_debug.root"), "RECREATE"); m_tfile_debug = new TFile(TString(m_file_name)+"_debug.root", "RECREATE"); ATH_MSG_INFO( "NtupleTubeEfficiencyTool: Debug mode is switched on" ); @@ -166,14 +148,14 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { //efficiency and fakerate histos (per tube) - m_h_efficiency = vector< vector< vector<TH1F*> > >(2); //up to two multilayers + m_h_efficiency = std::vector< std::vector< std::vector<TH1F*> > >(2); //up to two multilayers for (unsigned int k=0; k<m_h_efficiency.size(); k++) { - m_h_efficiency[k] = vector< vector<TH1F*> >(4); // up to four layers per multilayer + m_h_efficiency[k] = std::vector< std::vector<TH1F*> >(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_efficiency[k].size(); l++) { - m_h_efficiency[k][l] = vector<TH1F*>(72); // up to 72 tubes per layer + m_h_efficiency[k][l] = std::vector<TH1F*>(72); // up to 72 tubes per layer for (unsigned int m=0; m<m_h_efficiency[k][l].size(); m++) { m_h_efficiency[k][l][m] @@ -184,14 +166,14 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { } - m_h_fakerate = vector< vector< vector<TH1F*> > >(2); //up to two multilayers + m_h_fakerate = std::vector< std::vector< std::vector<TH1F*> > >(2); //up to two multilayers for (unsigned int k=0; k<m_h_fakerate.size(); k++) { - m_h_fakerate[k] = vector< vector<TH1F*> >(4); // up to four layers per multilayer + m_h_fakerate[k] = std::vector< std::vector<TH1F*> >(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_fakerate[k].size(); l++) { - m_h_fakerate[k][l] = vector<TH1F*>(72); // up to 72 tubes per layer + m_h_fakerate[k][l] = std::vector<TH1F*>(72); // up to 72 tubes per layer for (unsigned int m=0; m<m_h_fakerate[k][l].size(); m++) { m_h_fakerate[k][l][m] @@ -206,10 +188,10 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { m_tfile->cd(); - m_h_tube_efficiency = vector< vector<TH1F*> >(2); //up to two multilayers + m_h_tube_efficiency = std::vector< std::vector<TH1F*> >(2); //up to two multilayers for (unsigned int k=0; k<m_h_tube_efficiency.size(); k++) { - m_h_tube_efficiency[k] = vector<TH1F*>(4); // up to four layers per multilayer + m_h_tube_efficiency[k] = std::vector<TH1F*>(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_tube_efficiency[k].size(); l++) { m_h_tube_efficiency[k][l] @@ -222,10 +204,10 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { } } - m_h_tube_fakerate = vector< vector<TH1F*> >(2); //up to two multilayers + m_h_tube_fakerate = std::vector< std::vector<TH1F*> >(2); //up to two multilayers for (unsigned int k=0; k<m_h_tube_fakerate.size(); k++) { - m_h_tube_fakerate[k] = vector<TH1F*>(4); // up to four layers per multilayer + m_h_tube_fakerate[k] = std::vector<TH1F*>(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_tube_fakerate[k].size(); l++) { m_h_tube_fakerate[k][l] @@ -242,10 +224,10 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { //entry histos (per layer) - m_h_tube_entries_efficiency = vector< vector<TH1F*> >(2); //up to two multilayers + m_h_tube_entries_efficiency = std::vector< std::vector<TH1F*> >(2); //up to two multilayers for (unsigned int k=0; k<m_h_tube_entries_efficiency.size(); k++) { - m_h_tube_entries_efficiency[k] = vector<TH1F*>(4); // up to four layers per multilayer + m_h_tube_entries_efficiency[k] = std::vector<TH1F*>(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_tube_entries_efficiency[k].size(); l++) { m_h_tube_entries_efficiency[k][l] @@ -257,10 +239,10 @@ StatusCode NtupleTubeEfficiencyTool::initialize() { } } - m_h_tube_entries_fakerate = vector< vector<TH1F*> >(2); //up to two multilayers + m_h_tube_entries_fakerate = std::vector< std::vector<TH1F*> >(2); //up to two multilayers for (unsigned int k=0; k<m_h_tube_entries_fakerate.size(); k++) { - m_h_tube_entries_fakerate[k] = vector<TH1F*>(4); // up to four layers per multilayer + m_h_tube_entries_fakerate[k] = std::vector<TH1F*>(4); // up to four layers per multilayer for (unsigned int l=0; l<m_h_tube_entries_fakerate[k].size(); l++) { m_h_tube_entries_fakerate[k][l] @@ -349,7 +331,7 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, if(m_nb_multilayers<0){ - m_nb_multilayers = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(station_id); + m_nb_multilayers = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(station_id); } @@ -389,7 +371,6 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, m_qfitter->setRoadWidth(m_road_width); //0.65 m_qfitter->switchOnRefit(); - //m_qfitter->fit(segment); SG::ReadCondHandle<MuonGM::MuonDetectorManager> DetectorManagerHandle{m_DetectorManagerKey}; const MuonGM::MuonDetectorManager* MuonDetMgr = DetectorManagerHandle.cptr(); @@ -402,7 +383,7 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, for (int multilayer=1; multilayer<m_nb_multilayers+1; multilayer++) { const MuonGM::MdtReadoutElement* MdtRoEl = - MuonDetMgr->getMdtReadoutElement( m_muonIdHelperTool->mdtIdHelper().channelID(station_id,multilayer,1,1) ); + MuonDetMgr->getMdtReadoutElement( m_idHelperSvc->mdtIdHelper().channelID(station_id,multilayer,1,1) ); if(m_nb_layers<0) m_nb_layers = MdtRoEl->getNLayers(); if(m_nb_tubes<0) m_nb_tubes = MdtRoEl->getNtubesperlayer(); @@ -435,15 +416,6 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, } } - //cout << "event: " << eventnumber << ", hits: " << nb_hits << ", segment: " << segment.mdtHitsOnTrack() << endl; - - //perform the track fit // - //if (nb_hits<m_nb_hits) { - // continue; - //} - - - if(m_exclude_layer){ m_h_chi2->Fill(m_qfitter->chi2PerDegreesOfFreedom()); @@ -454,9 +426,6 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, if (m_qfitter->numberOfTrackHits()<3) { continue; } - //if (m_qfitter->numberOfTrackHits()<(m_nb_hits-1) { - // continue; - //} if(m_qfitter->chi2PerDegreesOfFreedom()>m_chi2_cut){ continue; } @@ -496,11 +465,7 @@ NtupleTubeEfficiencyTool::handleEvent( const MuonCalibEvent & event, MTStraightLine tube = MTStraightLine( tube_position, tube_direction, Amg::Vector3D(0,0,0), Amg::Vector3D(0,0,0) ); - - //debug: check geometry - //cout << "AMDpos: " << tube_position - // << ", mypos: " << wire_position[multilayer-1][layer-1][k] << endl; - + double distance = TMath::Abs(track.signDistFrom(tube)); if ( distance < (MdtRoEl->innerTubeRadius()) ){ @@ -592,8 +557,8 @@ NtupleTubeEfficiencyTool::analyseSegments(const std::vector<MuonCalibSegment *> std::string outfilename = m_file_name + ".txt"; - ofstream outfile(outfilename.c_str()); - outfile << "ml \t ly \t tube \t efficiency \t error \t fakerate \t ferror" << endl; + std::ofstream outfile(outfilename.c_str()); + outfile << "ml \t ly \t tube \t efficiency \t error \t fakerate \t ferror" << std::endl; //initialize summary variables @@ -687,7 +652,7 @@ NtupleTubeEfficiencyTool::analyseSegments(const std::vector<MuonCalibSegment *> << Form("%1.3f",efficiency) << "\t" << Form("%1.3f",error) << "\t" << Form("%1.8f",fakerate) << "\t" - << Form("%1.3f",ferror) << endl; + << Form("%1.3f",ferror) << std::endl; //entry histos @@ -816,66 +781,3 @@ NtupleTubeEfficiencyTool::analyseSegments(const std::vector<MuonCalibSegment *> } } - - -//HepGeom::Point3D<double> tubePos = ml2->tubePos(1,2,1); -//HepGeom::Point3D<double> tubePos = ml2->localTubePos(2,1,1); -//cout << "tubePos: " << tubePos.y() << endl; - -//HepGeom::Point3D<double> tubePosLoc = ml2->GlobalToAmdbLRSCoords(tubePos); -//HepGeom::Point3D<double> tubePosLoc = ml2->AmdbLRSToGlobalCoords(tubePos); -//HepGeom::Point3D<double> tubePosLoc = ml2->tubeFrame_localROPos(2,1,1); - -// cout << "k \t wirepos(x) \t wirepos(y) \t wirepos(z) \t tubepos(x) \t tubepos(y) \t tubepos(z)" << endl; -// for (int k=0; k<n_tubesly; k++) { - -// //HepGeom::Point3D<double> LTubePos = ml2->localTubePos(2,1,k+1); -// HepGeom::Point3D<double> LTubePos = ml2->GlobalToAmdbLRSCoords(ml2->tubePos(1,2,k+1)); - -// cout << k << "\t" -// << wire[k].positionVector().x() << "\t" -// << wire[k].positionVector().y() << "\t" -// << wire[k].positionVector().z() << "\t || \t" -// << LTubePos.x() << "\t" -// << LTubePos.y() << "\t" -// << LTubePos.z() << endl; -// } - - - //hardcoded wire positions for BML_3_1 - // Amg::Vector3D wire_position[2][3][72]; - // for (int k=0; k<72; k++) { - // wire_position[0][0][k] = Amg::Vector3D(0, 30.035*(k+1)-15.018, 169.516998); - // wire_position[0][1][k] = Amg::Vector3D(0, 30.035*(k+1)+0.0000023, 195.528992); - // wire_position[0][2][k] = Amg::Vector3D(0, 30.035*(k+1)-15.018001, 221.540009); - // wire_position[1][0][k] = Amg::Vector3D(0, 30.035*(k+1)-15.018000, 568.576965); - // wire_position[1][1][k] = Amg::Vector3D(0, 30.035*(k+1)+0.000004, 594.588989); - // wire_position[1][2][k] = Amg::Vector3D(0, 30.035*(k+1)-15.018000, 620.599976); - // } - - //reset histo names - - // if( !(TString(m_h_tube_efficiency[0][0]->GetName())) -// .Contains(TString(m_cal_region->regionId()))){ - -// for (unsigned int k=0; k<m_h_tube_efficiency.size(); k++) { - -// for (unsigned int l=0; l<m_h_tube_efficiency[k].size(); l++) { - -// m_h_tube_efficiency[k][l]->SetName( TString(m_cal_region->regionId()) + "_" + -// TString(m_h_tube_efficiency[k][l]->GetName()) ); - - -// } -// } - -// for (unsigned int k=0; k<m_h_tube_fakerate.size(); k++) { - -// for (unsigned int l=0; l<m_h_tube_fakerate[k].size(); l++) { - -// m_h_tube_fakerate[k][l]->SetName( TString(m_cal_region->regionId()) + "_" + -// TString(m_h_tube_fakerate[k][l]->GetName()) ); - -// } -// } -// } -- GitLab