/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
RpcGeomInfoSvc Class Reference

#include <RpcGeomInfoSvc.h>

Inheritance diagram for RpcGeomInfoSvc:
Inheritance graph
[legend]
Collaboration diagram for RpcGeomInfoSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RpcGeomInfoSvc (const std::string &name, ISvcLocator *svc)
 ~RpcGeomInfoSvc ()
virtual StatusCode initialize ()
virtual StatusCode reinitialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
IRpcGeomInfoget (std::string structure_path)
 IRpcGeomInfoSvc interface.
IRpcGeomInfoget (IDetectorElement *rpcde)
 Look up by DetectorElement.
IRpcGeomInfoget (unsigned int rpcid)
 Look up by fully qualified RPC id (see Conventions/Detectors.h)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Types

typedef std::map< unsigned int,
IRpcGeomInfo * > 
MapByInt
typedef std::map< std::string,
IRpcGeomInfo * > 
MapByString
typedef std::map
< IDetectorElement
*, IRpcGeomInfo * > 
MapByDE

Private Member Functions

IRpcGeomInfoadd (unsigned int rpcid, const std::string &path, IDetectorElement *de)
IRpcGeomInfofind (unsigned int rpcid, IDetectorElement *de)
IDetectorElement * findParent (unsigned int rpcid, IDetectorElement *currentDE)

Private Attributes

std::vector< std::string > m_StreamItems
 Property: StreamItems.
std::vector< IDetectorElement * > m_topDEs
std::string m_SiteIdUserParameter
 Property: SiteIdUserParameter.
std::string m_DetectorIdUserParameter
 Property: DetectorIdUserParameter.
std::string m_RpcIdUserParameter
 Property: RpcIdUserParameter.
MapByInt m_byId
MapByString m_byPath
MapByDE m_byDE
IDataProviderSvc * m_detSvc
IDetectorElement * m_detector

Detailed Description

Definition at line 28 of file RpcGeomInfoSvc.h.


Member Typedef Documentation

typedef std::map<unsigned int,IRpcGeomInfo*> RpcGeomInfoSvc::MapByInt [private]

Definition at line 83 of file RpcGeomInfoSvc.h.

typedef std::map<std::string,IRpcGeomInfo*> RpcGeomInfoSvc::MapByString [private]

Definition at line 85 of file RpcGeomInfoSvc.h.

typedef std::map<IDetectorElement*,IRpcGeomInfo*> RpcGeomInfoSvc::MapByDE [private]

Definition at line 87 of file RpcGeomInfoSvc.h.


Constructor & Destructor Documentation

RpcGeomInfoSvc::RpcGeomInfoSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 12 of file RpcGeomInfoSvc.cc.

    : Service(name,svc)
    , m_detSvc(0)
    , m_detector(0)
{
    declareProperty("SiteIdUserParameter",m_SiteIdUserParameter="SiteID",
                    "Name of the user parameter attached to Site detector "
                    "elements that gives the packed Site ID number.");
    declareProperty("DetectorIdUserParameter", 
                    m_DetectorIdUserParameter="DetectorID",
                    "Name of the user parameter attached to Detector "
                    "detector elements that gives the fully qualified "
                    "packed Detector ID.");
    declareProperty("RpcIdUserParameter",m_RpcIdUserParameter="RpcID",
                    "Name of the user parameter attached to RPC detector "
                    "elements that gives the fully qualified packed RPC ID");
    declareProperty("StreamItems",m_StreamItems,
                    "List of top level Detector Elements.");
}
RpcGeomInfoSvc::~RpcGeomInfoSvc ( )

Definition at line 32 of file RpcGeomInfoSvc.cc.

{
}

Member Function Documentation

StatusCode RpcGeomInfoSvc::initialize ( ) [virtual]

Definition at line 38 of file RpcGeomInfoSvc.cc.

{
    this->Service::initialize();

    MsgStream msg(msgSvc(),name());
    msg << MSG::DEBUG << "RpcGeomInfoSvc::initialize()" << endreq;

    StatusCode sc = service("DetectorDataSvc",m_detSvc,true);
    if (sc.isFailure()) return sc;

    msg << MSG::DEBUG << "Using IDs:"
        << " site: " << m_SiteIdUserParameter
        << " det: " << m_DetectorIdUserParameter
        << " rpc: " << m_RpcIdUserParameter
        << endreq;

    if (! m_StreamItems.size()) {
        msg << MSG::WARNING << "did not get any StreamItems, can not lookup RPCs" << endreq;
        return StatusCode::FAILURE;
    }
    for (size_t ind=0; ind<m_StreamItems.size(); ++ind) {
        string dename = m_StreamItems[ind];
        SmartDataPtr<IDetectorElement> obj(m_detSvc,dename);
        if (!obj) {
            MsgStream msg(msgSvc(),name());
            msg << MSG::WARNING << "Failed to get top Detector Element: \"" 
                << dename << "\", skipping" << endreq;
            sc = StatusCode::FAILURE;
            continue;
        }
        msg << MSG::DEBUG << "Adding top level Detector Element: \"" 
            << dename << endreq;
        m_topDEs.push_back(obj);
    }
    return sc;
}
StatusCode RpcGeomInfoSvc::reinitialize ( ) [virtual]

Definition at line 83 of file PmtGeomInfoSvc.cc.

{
    return StatusCode::SUCCESS;
}
StatusCode RpcGeomInfoSvc::finalize ( ) [virtual]

Definition at line 88 of file PmtGeomInfoSvc.cc.

{
    m_detSvc->release();

    // Delete all PmtGeomInfo's.....

    return StatusCode::SUCCESS;
}
StatusCode RpcGeomInfoSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 357 of file PmtGeomInfoSvc.cc.

{
    StatusCode sc = StatusCode::FAILURE;
    if (ppvInterface) {
        *ppvInterface = 0;
    
        if (IPmtGeomInfoSvc::interfaceID().versionMatch(riid)) {
            *ppvInterface = static_cast<IPmtGeomInfoSvc*>(this);
            sc = StatusCode::SUCCESS;
            addRef();
        }
        else sc = Service::queryInterface( riid, ppvInterface );    
    }
    return sc;
}
IRpcGeomInfo * RpcGeomInfoSvc::get ( std::string  structure_path) [virtual]

IRpcGeomInfoSvc interface.

Look up by TDS path of detector element.

Look up by TDS path of detector element

Implements IRpcGeomInfoSvc.

Definition at line 90 of file RpcGeomInfoSvc.cc.

{
    MsgStream msg(msgSvc(),name());
    msg << MSG::DEBUG << "RpcGeomInfoSvc::get(path "<<structure_path<<")" << endreq;

    IRpcGeomInfo* rpcinfo = m_byPath[structure_path];
    if (rpcinfo) return rpcinfo;

    SmartDataPtr<IDetectorElement> obj(m_detSvc,structure_path);
    if (!obj) return 0;

    unsigned int rpcid = obj->params()->param<int>(m_RpcIdUserParameter);
    if (!rpcid) return 0;
    
    return this->add(rpcid,structure_path,obj);
}
IRpcGeomInfo * RpcGeomInfoSvc::get ( IDetectorElement *  rpcde) [virtual]

Look up by DetectorElement.

Implements IRpcGeomInfoSvc.

Definition at line 108 of file RpcGeomInfoSvc.cc.

{
    MsgStream msg(msgSvc(),name());
    msg << MSG::DEBUG << "RpcGeomInfoSvc::get(IDetectorElement "<<rpcde->name()<<")" << endreq;

    IRpcGeomInfo* rpcinfo = m_byDE[rpcde];
    if (rpcinfo) return rpcinfo;

    unsigned int rpcid = rpcde->params()->param<int>(m_RpcIdUserParameter);
    if (!rpcid) return 0;

    return this->add(rpcid,"",rpcde);
}
IRpcGeomInfo * RpcGeomInfoSvc::get ( unsigned int  rpcid) [virtual]

Look up by fully qualified RPC id (see Conventions/Detectors.h)

Implements IRpcGeomInfoSvc.

Definition at line 123 of file RpcGeomInfoSvc.cc.

{
    MsgStream msg(msgSvc(),name());
    msg << MSG::DEBUG << "RpcGeomInfoSvc::get(int "<<(void*)rpcid<<")" << endreq;
    

    /*
      algorithm: 

      * add site/detector values into high level detector elements in
      XML.

      * add isCompatible() method to Detectors.h, Returns true if bits
      * match, but not including fully zero'd bytes.

      * Search down /dd/Structure, check each DetectorElement for a
      * RpcID user parameter.  Failing that look for a DetectorID
      * parameter and if found check if value isCompatible() and
      * abandon branch if it isn't. Quit if DetectorElements are
      * exhausted or if one is found that matches the RPCID.

     */

    // Have we seen you before?
    IRpcGeomInfo* rpcinfo = m_byId[rpcid];
    if (rpcinfo) {
        msg << MSG::DEBUG << "Found "<< (void*)rpcid << ", seen before"<<endreq;
        return rpcinfo;
    }

    // Let's first do a quick check in the last detector we saw
    if (m_detector) {
        msg << MSG::DEBUG << "Looking for "<< (void*)rpcid 
            << " in "<< m_detector->name() << endreq;
        rpcinfo = this->find(rpcid,m_detector);
        if (rpcinfo) {
            msg << MSG::DEBUG << "Found "<< (void*)rpcid
                << " after quick check"<<endreq;
            return rpcinfo;
        }
        m_detector = 0;
    }

    // No luck, do a full search starting from top level DEs
    for (size_t ind=0; ind<m_topDEs.size(); ++ind) {
        msg << MSG::DEBUG << "Looking for "<< (void*)rpcid 
            << " in "<< m_topDEs[ind]->name() << endreq;
        rpcinfo = this->find(rpcid,m_topDEs[ind]);
        if (rpcinfo) {
            msg << MSG::DEBUG << "Found "<< (void*)rpcid
                << " after full search"<<endreq;
            return rpcinfo;
        }
    }
    msg << MSG::DEBUG << "Failed to find RPC ID "<< (void*)rpcid << endreq;
    return 0;
}
IRpcGeomInfo * RpcGeomInfoSvc::add ( unsigned int  rpcid,
const std::string &  path,
IDetectorElement *  de 
) [private]

Definition at line 325 of file PmtGeomInfoSvc.cc.

{
    MsgStream msg(msgSvc(), name());

    if (!de) {
        msg << MSG::ERROR 
            << "Given NULL DetectorElement (pmtid=" 
            << (void*)pmtid << endreq;
        return 0;
    }
    IDetectorElement* parent = findParent(pmtid,0);
    if (!parent) {
        msg << MSG::ERROR 
            << "No parent detector, cannot add DetectorElement with pmtid=" 
            << (void*)pmtid << endreq;
        return 0;
    }

    msg << MSG::DEBUG
        << "Adding pmtid " << (void*)pmtid << " at \"" << path <<"\""
        << endreq;

    PmtGeomInfo* gpi = new PmtGeomInfo(pmtid,de,parent);

    if (path == "") m_byPath[de->name()] = gpi;
    else m_byPath[path] = gpi;
    m_byDE[de] = gpi;
    m_byId[pmtid] = gpi;

    return gpi;
}
IRpcGeomInfo * RpcGeomInfoSvc::find ( unsigned int  rpcid,
IDetectorElement *  de 
) [private]

Definition at line 201 of file PmtGeomInfoSvc.cc.

{
    //nomsg MsgStream msg(msgSvc(),name());
    //nomsg msg << MSG::DEBUG << "PmtGeomInfoSvc::find(int "<<(void*)pmtid        <<","<<de->name()<<")" << endreq;

    const ParamValidDataObject* params = de->params();
    // Check if DE is a PMT.  If current DE has a PmtID we are done
    // for good or bad.
    if (de->params()->exists(m_PmtIdUserParameter)) {
        unsigned int this_pmtid = (unsigned int)(params->param<int>(m_PmtIdUserParameter));
        if (pmtid == this_pmtid) {
            //nomsg msg << MSG::DEBUG << "found PMT ID " << (void*)pmtid << endreq;
            return this->add(pmtid,"",de);
        }
        //nomsg msg << MSG::DEBUG << "got PMT ID but wrong one "            << (void*)this_pmtid << " != " << (void*)pmtid << endreq;
        return 0;
    }

    // Check if DE is a Detector.  If current DE has a DetectorID we
    // check for compatibility and cache or bail out.
    if (de->params()->exists(m_DetectorIdUserParameter)) {
        unsigned int detid = 
            (unsigned int)(params->param<int>(m_DetectorIdUserParameter));
        //nomsg msg << MSG::DEBUG << "checking Detector ID "            << (void*)detid << " =?= " << (void*)(pmtid) << endreq;

        if ( (pmtid&0xffff0000) == detid) { 
            //nomsg msg << MSG::DEBUG << "found Detector ID "                << (void*)detid << " for " << (void*)(pmtid) << endreq;
            m_detector = de;    // We have a winner!
        }
        else {                  // We have a detector, but the wrong one
            //nomsg msg << MSG::DEBUG << "got Detector ID but wrong one "                << (void*)detid << " != " << (void*)(pmtid&0xffff0000) << endreq;
        }
    }

    // Check if DE is a Site.  If current DE has a SiteID we bail out
    // if it isn't compatible.
    if (params->exists(m_SiteIdUserParameter)) {
        unsigned int siteid = 
            (unsigned int)(params->param<int>(m_SiteIdUserParameter));
        if ( (pmtid&0xff000000) != siteid) {
            //nomsg msg << MSG::DEBUG << "got Site ID but wrong one "                << (void*)siteid << " != " << (void*)(pmtid&0xff000000) << endreq;
            return 0;
        }
    }

    // We get here we know we are still on the right track
    IDetectorElement::IDEContainer& child = de->childIDetectorElements();
    for (size_t ind=0; ind < child.size(); ++ind) {
        IPmtGeomInfo *pgi = this->find(pmtid,child[ind]);
        if (pgi) return pgi;
    }
    //nomsg msg << MSG::DEBUG << "failed to find pmtid " << (void*)pmtid << endreq;
    return 0;
}
IDetectorElement * RpcGeomInfoSvc::findParent ( unsigned int  rpcid,
IDetectorElement *  currentDE 
) [private]

Definition at line 257 of file PmtGeomInfoSvc.cc.

{
    // Find the parent detector element for this PMT, starting the
    // search at the current detector element.  If currentDE==0, then
    // the entire geometry will be searched.

    //nomsg MsgStream msg(msgSvc(),name());
    //nomsg msg << MSG::DEBUG << "PmtGeomInfoSvc::find(int "<<(void*)pmtid;
    //nomsg if (currentDE) msg <<","<<currentDE->name();
    //nomsg msg << ")"<< endreq;

    if (!currentDE) {
      // If current detector element is undefined, check the usual suspects
      // First, check the cached detector
      if (m_detector) {
        IDetectorElement* parent = findParent(pmtid, m_detector);
        if(parent) return parent;
        m_detector = 0; // Unset incorrect cached detector
      }
      // Next, check the top-level detector elements
      for (size_t ind=0; ind<m_topDEs.size(); ++ind) {
        if (m_topDEs[ind]){
          IDetectorElement* parent = findParent(pmtid, m_topDEs[ind]);
          if(parent) return parent;
        }
      }
      // Failed to find parent detector
      //nomsg msg << MSG::DEBUG << "failed to find parent detector for pmtid "  << (void*)pmtid << endreq;
      return 0;
    }

    //nomsg msg << MSG::DEBUG << "Looking for "<< (void*)pmtid  << " in "<< currentDE->name() << endreq;
    const ParamValidDataObject* params = currentDE->params();

    // Check if current detector element is the pmt parent detector
    if (params->exists(m_DetectorIdUserParameter)) {
      unsigned int detid = 
        (unsigned int)(params->param<int>(m_DetectorIdUserParameter));
      //nomsg msg << MSG::DEBUG << "checking Detector ID "        << (void*)detid << " =?= " << (void*)(pmtid) << endreq;
      if ( (pmtid&0xffff0000) == detid) { 
        //nomsg msg << MSG::DEBUG << "found Detector ID "           << (void*)detid << " for " << (void*)(pmtid) << endreq;
        return currentDE;    // We have a winner!
      }
    }

    // Check if current detector element is the correct site
    if (params->exists(m_SiteIdUserParameter)) {
      unsigned int siteid = 
        (unsigned int)(params->param<int>(m_SiteIdUserParameter));
      if ( (pmtid&0xff000000) != siteid) {
        //nomsg msg << MSG::DEBUG << "got Site ID but wrong one "           << (void*)siteid << " != " << (void*)(pmtid&0xff000000) << endreq;
        return 0;
      }
    }
    
    // Check detector element children
    // We get here we know we are still on the right track
    IDetectorElement::IDEContainer& child = currentDE->childIDetectorElements();
    for (size_t ind=0; ind < child.size(); ++ind) {
        IDetectorElement* parent = this->findParent(pmtid,child[ind]);
        if (parent) return parent;
    }
    //nomsg msg << MSG::DEBUG   << "failed to find parent detector for pmtid "  << (void*)pmtid << " in current branch" << endreq;
    return 0;    
}
const InterfaceID & IRpcGeomInfoSvc::interfaceID ( ) [static, inherited]

Definition at line 3 of file IRpcGeomInfoSvc.cc.

                                                {

  static const InterfaceID m_IID("IRpcGeomInfoSvc", 1, 0);

  return m_IID;
}

Member Data Documentation

std::vector<std::string> RpcGeomInfoSvc::m_StreamItems [private]

Property: StreamItems.

List of top level Detector Elements. For simulation this should likely match GiGa's property of the same name.

Definition at line 57 of file RpcGeomInfoSvc.h.

std::vector<IDetectorElement*> RpcGeomInfoSvc::m_topDEs [private]

Definition at line 58 of file RpcGeomInfoSvc.h.

Property: SiteIdUserParameter.

Name of the user parameter attached to Site detector elements that gives the packed Site ID number. Default is "SiteID"

Definition at line 63 of file RpcGeomInfoSvc.h.

Property: DetectorIdUserParameter.

Name of the user parameter attached to Detector detector elements that gives the fully qualified packed Detector ID. Default is "DetectorID"

Definition at line 67 of file RpcGeomInfoSvc.h.

std::string RpcGeomInfoSvc::m_RpcIdUserParameter [private]

Property: RpcIdUserParameter.

Name of the user parameter attached to RPC detector elements that gives the fully qualified packed RPC ID. Default is "RpcID"

Definition at line 71 of file RpcGeomInfoSvc.h.

Definition at line 84 of file RpcGeomInfoSvc.h.

Definition at line 86 of file RpcGeomInfoSvc.h.

Definition at line 88 of file RpcGeomInfoSvc.h.

IDataProviderSvc* RpcGeomInfoSvc::m_detSvc [private]

Definition at line 90 of file RpcGeomInfoSvc.h.

IDetectorElement* RpcGeomInfoSvc::m_detector [private]

Definition at line 93 of file RpcGeomInfoSvc.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:56:27 for DetHelpers by doxygen 1.7.4