Commit 118cd618 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (MuonMDT_Cabling-00-04-14)

	* Tagging MuonMDT_Cabling-00-04-14.
	* AthenaBaseComps migration.

2015-03-31 Stefano Rosati <Stefano.Rosati@cern.ch>

	* tagging 00-04-13
	* adding a flag to be set to true when running on MDT calibration stream
parent 45fb74bf
################################################################################
# Package: MuonMDT_Cabling
################################################################################
# Declare the package name:
atlas_subdir( MuonMDT_Cabling )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
Control/AthenaKernel
Control/StoreGate
GaudiKernel
MuonSpectrometer/MuonIdHelpers
PRIVATE
Database/AthenaPOOL/AthenaPoolUtilities
DetectorDescription/Identifier
Event/EventInfo
Event/EventInfoMgt
MuonSpectrometer/MuonCablings/MuonCablingData
MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondInterface )
# Component(s) in the package:
atlas_add_library( MuonMDT_CablingLib
src/*.cxx
PUBLIC_HEADERS MuonMDT_Cabling
LINK_LIBRARIES AthenaBaseComps AthenaKernel GaudiKernel StoreGateLib SGtests MuonIdHelpersLib
PRIVATE_LINK_LIBRARIES AthenaPoolUtilities Identifier EventInfo MuonCablingData MuonCondInterface )
atlas_add_component( MuonMDT_Cabling
src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel MuonIdHelpersLib AthenaPoolUtilities Identifier EventInfo MuonCablingData MuonCondInterface MuonMDT_CablingLib )
# Install files from the package:
atlas_install_python_modules( python/*.py )
......@@ -15,17 +15,17 @@
*
***********************************************/
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/IChronoStatSvc.h"
#include "MuonMDT_Cabling/MuonMDT_CablingSvc.h"
#include "MuonIdHelpers/MdtIdHelper.h"
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ServiceHandle.h"
// old cabling service
//#include "MDTcabling/IMDTcablingSvc.h"
class MdtTestCabling : public Algorithm {
class MdtTestCabling : public AthAlgorithm {
public:
......@@ -38,10 +38,7 @@ class MdtTestCabling : public Algorithm {
private:
MuonMDT_CablingSvc* m_cablingSvc;
MsgStream* m_log;
// IMDTcablingSvc* m_oldCablingSvc;
ServiceHandle<MuonMDT_CablingSvc> m_cablingSvc;
const MdtIdHelper* m_mdtIdHelper;
......@@ -53,7 +50,7 @@ class MdtTestCabling : public Algorithm {
bool testMap();
// the chrono service
IChronoStatSvc* m_chronoSvc;
ServiceHandle<IChronoStatSvc> m_chronoSvc;
std::string m_chrono1;
std::string m_chrono2;
......
......@@ -23,6 +23,9 @@ class ITagInfoMgr;
class IdentifierHash;
#include <list>
#include <string>
static const InterfaceID IID_IMuonMDT_CablingSvc("MuonMDT_CablingSvc", 1, 0);
......@@ -55,6 +58,9 @@ class MuonMDT_CablingSvc : public AthService
// IOV service callback
StatusCode initMappingModel(IOVSVC_CALLBACK_ARGS_P(I,keys));
// IOV service callback
StatusCode initMappingModelNoCallback() const;
// MuonMDT_CablingMap* getCablingMap() {return m_cablingMap;}
DataHandle<MuonMDT_CablingMap> getCablingMap();
......@@ -125,6 +131,10 @@ class MuonMDT_CablingSvc : public AthService
/** flag to indicate the first access to the map (to be fixed) */
bool m_firstAccess;
// this flag is by default false, to be set to true only to read MDT calibration stream
bool m_doCalStreamInit;
/** pointer to the old cabling service: added for backwards compatibility to read
old simulated data */
// ServiceHandle<IMDTcablingSvc> m_oldCablingSvc;
......
......@@ -10,15 +10,11 @@
#include "StoreGate/DataHandle.h"
MdtTestCabling::MdtTestCabling(const std::string& name, ISvcLocator* pSvcLocator) :
Algorithm(name,pSvcLocator),
m_cablingSvc(0),
AthAlgorithm(name,pSvcLocator),
m_cablingSvc("MuonMDT_CablingSvc", name),
m_mdtIdHelper(0),
m_chronoSvc(0)
m_chronoSvc("ChronoStatSvc", name)
{
// m_log = new MsgStream(msgSvc(),name());
m_log = new MsgStream(msgSvc(),"MdtTestCabling");
}
MdtTestCabling::~MdtTestCabling() { }
......@@ -26,45 +22,13 @@ MdtTestCabling::~MdtTestCabling() { }
StatusCode MdtTestCabling::initialize()
{
// initialize the chrono service
StatusCode sc = service("ChronoStatSvc",m_chronoSvc);
if (sc != StatusCode::SUCCESS) {
*m_log << MSG::ERROR << "Could not find the ChronoSvc" << endreq;
return sc;
}
// initialize the cabling service
sc = service("MuonMDT_CablingSvc",m_cablingSvc);
if (sc != StatusCode::SUCCESS) {
*m_log << MSG::ERROR << "Could not find the MuonMDT_CablingSvc" << endreq;
return sc;
}
// bool init = initTestMap();
//if (!init) {
// *m_log << MSG::FATAL << "could not initialize the test map " << endreq;
// return StatusCode::FAILURE;
//}
ATH_CHECK( m_chronoSvc.retrieve() );
ATH_CHECK( m_cablingSvc.retrieve() );
// initialize the pointer to the MdtIdHelper
StoreGateSvc* detStore;
sc = service("DetectorStore", detStore);
if ( sc.isSuccess() ) {
*m_log << MSG::DEBUG << "Retrieved DetectorStore" << endreq;
}else{
*m_log << MSG::ERROR << "Failed to retrieve DetectorStore" << endreq;
return sc;
}
// retrieve the mdt id helper
sc = detStore->retrieve(m_mdtIdHelper, "MDTIDHELPER" );
if (!sc.isSuccess()) {
*m_log << MSG::ERROR << "Can't retrieve MdtIdHelper" << endreq;
return sc;
}
ServiceHandle<StoreGateSvc> detStore ("DetectorStore", name());
ATH_CHECK( detStore.retrieve() );
ATH_CHECK( detStore->retrieve(m_mdtIdHelper, "MDTIDHELPER" ) );
m_chrono1 = "newcab";
m_chrono2 = "oldcab";
......@@ -110,11 +74,11 @@ bool MdtTestCabling::testMap()
// loop on the hardware objects to get online identifiers
// if (m_debug) {
*m_log << MSG::DEBUG << "in testMap()" << endreq;
ATH_MSG_DEBUG( "in testMap()" );
//}
DataHandle<MuonMDT_CablingMap> cablingMap = m_cablingSvc->getCablingMap();
//if (m_debug) {
*m_log << MSG::DEBUG << "retrieved the map from the service" << endreq;
ATH_MSG_DEBUG( "retrieved the map from the service" );
//}
std::map<uint8_t, MdtSubdetectorMap*, std::less<uint8_t> >* listOfSubdet;
......@@ -132,40 +96,40 @@ bool MdtTestCabling::testMap()
listOfSubdet = cablingMap->getListOfElements();
// if (m_debug) {
*m_log << MSG::DEBUG << "Got the list of subdetectors" << endreq;
*m_log << MSG::DEBUG << "Number of subdetectors: " << listOfSubdet->size() << endreq;
ATH_MSG_DEBUG( "Got the list of subdetectors" );
ATH_MSG_DEBUG( "Number of subdetectors: " << listOfSubdet->size() );
//}
// loop on the subdetectors
for (it_sub=listOfSubdet->begin() ; it_sub !=listOfSubdet->end() ; ++it_sub) {
int subdetectorId = ((*it_sub).second)->moduleId();
*m_log << MSG::DEBUG << "Now in subdetector: 0x" << MSG::hex
<< (int) subdetectorId << MSG::dec << endreq;
ATH_MSG_DEBUG( "Now in subdetector: 0x" << MSG::hex
<< (int) subdetectorId << MSG::dec);
// loop on the RODs of this subdetector
listOfROD = ((*it_sub).second)->getListOfElements();
for (it_rod=listOfROD->begin() ; it_rod !=listOfROD->end() ; ++it_rod) {
int rodId = ((*it_rod).second)->moduleId();
*m_log << MSG::DEBUG << "Now in ROD: 0x" << MSG::hex
<< (int) rodId << MSG::dec << endreq;
ATH_MSG_DEBUG( "Now in ROD: 0x" << MSG::hex
<< (int) rodId << MSG::dec );
// loop on the CSMs of this ROD
listOfCsm = ((*it_rod).second)->getListOfElements();
for (it_csm=listOfCsm->begin() ; it_csm !=listOfCsm->end() ; ++it_csm) {
int csmId = ((*it_csm).second)->moduleId();
*m_log << MSG::DEBUG << "Now in csm: 0x" << MSG::hex
<< (int) csmId << MSG::dec << endreq;
ATH_MSG_DEBUG( "Now in csm: 0x" << MSG::hex
<< (int) csmId << MSG::dec );
listOfAmt = ((*it_csm).second)->getListOfElements();
for (it_amt=listOfAmt->begin() ; it_amt !=listOfAmt->end() ; ++it_amt) {
int amtId = ((*it_amt).second)->moduleId();
*m_log << MSG::DEBUG << "Now in amt: 0x" << MSG::hex
<< (int) amtId << MSG::dec << endreq;
ATH_MSG_DEBUG( "Now in amt: 0x" << MSG::hex
<< (int) amtId << MSG::dec );
for (int chanId = 0 ; chanId<24 ; ++chanId) {
// convert the channel
......@@ -187,14 +151,14 @@ bool MdtTestCabling::testMap()
m_chronoSvc->chronoStop(m_chrono1);
if (!cabling) {
//*m_log << MSG::ERROR << "channel not found !" << endreq;
//ATH_MSG_ERROR( "channel not found !" );
}
else {
*m_log << MSG::DEBUG << "Channel converted to: station: " << station
<< " eta: " << eta << " phi: "<< phi << " multi: " << multi
<< " layer: " << layer << " tube: " << tube << endreq;
ATH_MSG_DEBUG( "Channel converted to: station: " << station
<< " eta: " << eta << " phi: "<< phi << " multi: " << multi
<< " layer: " << layer << " tube: " << tube );
uint8_t newSubdet = 0;
uint8_t newRod = 0;
......@@ -209,38 +173,37 @@ bool MdtTestCabling::testMap()
m_chronoSvc->chronoStop(m_chrono3);
if (!cabling) {
// *m_log << MSG::WARNING << "Could not convert back offline->online" << endreq;
// ATH_MSG_WARNING( "Could not convert back offline->online" );
}
else {
if (newSubdet!=subdetectorId || newRod!=rodId || newCsm!=csmId ||
newAmt!=amtId || newChan!=chanId) {
*m_log << MSG::ERROR << "=================================" << endreq;
*m_log << MSG::ERROR << "Back conversion gives a different result !"
<< endreq;
*m_log << MSG::ERROR << "Original online: subdet 0x" << MSG::hex
<< subdetectorId << MSG::dec
<< " rodId 0x" << MSG::hex << rodId << MSG::dec
<< " csmId 0x" << MSG::hex << csmId << MSG::dec
<< " amtId 0x" << MSG::hex << amtId << MSG::dec
<< " chanId 0x" << MSG::hex << chanId << MSG:: dec << endreq;
*m_log << MSG::ERROR << "converted to station: " << station
<< " name: " << m_mdtIdHelper->stationNameString(station)
<< " eta: " << eta << " phi: " << phi << " multi: " << multi
<< " layer: " << layer << " tube: " << tube << endreq;
*m_log << MSG::ERROR << "New online: subdet 0x" << MSG::hex
<< (int) newSubdet << MSG::dec
<< " rodId 0x" << MSG::hex << (int) newRod << MSG::dec
<< " csmId 0x" << MSG::hex << (int) newCsm << MSG::dec
<< " amtId 0x" << MSG::hex << (int) newAmt << MSG::dec
<< " chanId 0x" << MSG::hex << (int) newChan << MSG:: dec << endreq;
ATH_MSG_ERROR( "=================================" );
ATH_MSG_ERROR( "Back conversion gives a different result !" );
ATH_MSG_ERROR( "Original online: subdet 0x" << MSG::hex
<< subdetectorId << MSG::dec
<< " rodId 0x" << MSG::hex << rodId << MSG::dec
<< " csmId 0x" << MSG::hex << csmId << MSG::dec
<< " amtId 0x" << MSG::hex << amtId << MSG::dec
<< " chanId 0x" << MSG::hex << chanId << MSG:: dec );
ATH_MSG_ERROR( "converted to station: " << station
<< " name: " << m_mdtIdHelper->stationNameString(station)
<< " eta: " << eta << " phi: " << phi << " multi: " << multi
<< " layer: " << layer << " tube: " << tube );
ATH_MSG_ERROR( "New online: subdet 0x" << MSG::hex
<< (int) newSubdet << MSG::dec
<< " rodId 0x" << MSG::hex << (int) newRod << MSG::dec
<< " csmId 0x" << MSG::hex << (int) newCsm << MSG::dec
<< " amtId 0x" << MSG::hex << (int) newAmt << MSG::dec
<< " chanId 0x" << MSG::hex << (int) newChan << MSG:: dec );
*m_log << MSG::ERROR << "=================================" << endreq;
ATH_MSG_ERROR( "=================================" );
}
}
......@@ -284,7 +247,7 @@ bool MdtTestCabling::testMapTiming()
stationName,stationEta,stationPhi,
multiLayer,layer,tube);
if (!found) {
*m_log<< MSG::FATAL << " coul dnot find the test channel" << endreq;
ATH_MSG_FATAL( " coul dnot find the test channel" );
return found;
}
......@@ -295,7 +258,7 @@ bool MdtTestCabling::testMapTiming()
stationName,stationEta,stationPhi,
multiLayer,layer,tube);
if (!found) {
*m_log<< MSG::FATAL << " coul dnot find the test channel" << endreq;
ATH_MSG_FATAL( " coul dnot find the test channel" );
return StatusCode::FAILURE;
}
}
......
......@@ -39,6 +39,7 @@ AthService(svcName,sl),
// declareProperty("OldCablingSvc", m_oldCablingSvc);
declareProperty("TagInfoManager", m_tagInfoMgr);
declareProperty("ForcedUse", m_forceUse);
declareProperty("doCalStreamInit",m_doCalStreamInit=false);
}
MuonMDT_CablingSvc::~MuonMDT_CablingSvc()
......@@ -150,7 +151,19 @@ StatusCode MuonMDT_CablingSvc::initialize()
<< endreq;
return sc;
}
// This is the special initialization needed to run on the calibration stream
// No use of the callback but initialize the map at service initialization
// Activated only when running on the calibration stream
if ( m_doCalStreamInit ) {
msg(MSG::INFO) << "Initializing the MDT calibration map to read the calibration stream" << endreq;
sc = initMappingModelNoCallback();
if ( sc.isFailure() ) {
msg(MSG::ERROR) << "Could not initialize the MDT cabling service for the calibration stream" << endreq;
return StatusCode::FAILURE;
}
}
return sc;
}
......@@ -429,3 +442,45 @@ StatusCode MuonMDT_CablingSvc::initMappingModel(IOVSVC_CALLBACK_ARGS_P(I,keys))
// initalize the map without using the callback
StatusCode MuonMDT_CablingSvc::initMappingModelNoCallback() const
{
msg(MSG::INFO) << "initMappingModel has been called" << endreq;
msg(MSG::INFO) << "ToolHandle in initMappingModel - <" << m_dbTool << ">" << endreq;
if(!m_useOldCabling) {
std::list<std::string> keys;
keys.push_back("/MDT/CABLING/MAP_SCHEMA");
keys.push_back("/MDT/CABLING/MEZZANINE_SCHEMA");
int I=0;
StatusCode sc = m_dbTool->loadParameters(I, keys);
if (sc.isFailure()) {
msg(MSG::ERROR)<<"Reading Cabling maps from COOL failed; try to read from file"<<endreq;
return StatusCode::FAILURE;
}
// retrieve the map from the detector store
sc = m_detStore->retrieve(m_cablingMap);
if (sc!=StatusCode::SUCCESS) {
msg(MSG::ERROR) << "Can't retrieve the cabling map from the detector store" << endreq;
return false;
}
else {
msg(MSG::DEBUG) << "Retrieved map from the detector store" << endreq;
}
}
else {
msg(MSG::INFO) << "Using the old cabling, no callback" << endreq;
}
return StatusCode::SUCCESS;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment