Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

CalFailureModeSvc.cxx

Go to the documentation of this file.
00001 // Implementation file for CalFailureModeSvc which handles the failure mode testing
00002 // for the CAL.
00003 // 
00004 //
00005 // $Header: /nfs/slac/g/glast/ground/cvs/CalUtil/doc/doxy-html/_cal_failure_mode_svc_8cxx-source.html,v 1.1.1.1 2002/10/30 18:13:50 richard Exp $
00006 //
00007 // Author: Richard Dubois
00008 
00009 
00010 #include "CalUtil/CalFailureModeSvc.h"
00011 
00012 #include "GaudiKernel/MsgStream.h"
00013 #include "GaudiKernel/SvcFactory.h"
00014 #include <algorithm>
00015 
00016 
00017 // declare the service factories for the CalFailureModeSvc
00018 static SvcFactory<CalFailureModeSvc> a_factory;
00019 const ISvcFactory& CalFailureModeSvcFactory = a_factory; 
00020 
00021 CalFailureModeSvc::CalFailureModeSvc(const std::string& name,ISvcLocator* svc) : Service(name,svc)
00022 {
00023     // Purpose and Method: Constructor - Declares and sets default properties
00024     //                     
00025     // Inputs: service name and locator 
00026     //         
00027     // Outputs: None
00028     // Dependencies: None
00029     // Restrictions and Caveats:  None
00030     
00031     // declare the properties
00032 
00033     declareProperty("towerList", m_towerListProperty);
00034     declareProperty("towerLayerList", m_towerLayerListProperty);
00035 }
00036 
00037 StatusCode  CalFailureModeSvc::queryInterface (const IID& riid, void **ppvIF)
00038 {
00039     if (IID_ICalFailureModeSvc == riid) {
00040         *ppvIF = dynamic_cast<ICalFailureModeSvc*> (this);
00041         return StatusCode::SUCCESS;
00042     }
00043     else {
00044         return Service::queryInterface (riid, ppvIF);
00045     }
00046 }
00047 
00048 const IID&  CalFailureModeSvc::type () const {
00049     return IID_ICalFailureModeSvc;
00050 }
00051 
00052 StatusCode CalFailureModeSvc::initialize () 
00053 {
00054     // Purpose and Method: Initialize the lists of dead units
00055     //                     
00056     // Inputs: None        
00057     // Outputs: None
00058     // Dependencies: None
00059     // Restrictions and Caveats:  None
00060     
00061     StatusCode  status = StatusCode::SUCCESS;
00062     
00063     // Open the message log
00064     MsgStream log( msgSvc(), name() );
00065     
00066     // Call super-class
00067     Service::initialize ();
00068     
00069     // Bind all of the properties for this service
00070     if ( (status = setProperties()).isFailure() ) {
00071         log << MSG::ERROR << "Failed to set properties" << endreq;
00072     }
00073     
00074     
00075     m_failureModes = 0;
00076     processTowerList();
00077     processTowerLayerList();
00078     
00079     return StatusCode::SUCCESS;
00080 }
00081 
00082 StatusCode CalFailureModeSvc::finalize () {return StatusCode::SUCCESS;}
00083 
00084 void CalFailureModeSvc::processTowerLayerList() {
00085     // Purpose and Method: process the jobOptions input lists of (tower,layer) pairs
00086     //                     
00087     
00088     MsgStream log(msgSvc(), name());
00089     
00090     const std::vector<std::string>& theTowers = m_towerLayerListProperty.value( );
00091     if (theTowers.size() == 0) return;
00092 
00093     m_failureModes = m_failureModes || 1 << TOWER;
00094 
00095     log << MSG::DEBUG << "Towers and Layers to kill " << endreq;
00096 
00097     std::vector<std::string>::const_iterator it;
00098     std::vector<std::string>::const_iterator itend = theTowers.end( );
00099     for (it = theTowers.begin(); it != itend; it++) {
00100         int len = (*it).size();
00101         int delimPos = (*it).find_first_of('_');
00102         int tower = atoi((*it).substr(0, delimPos).c_str());
00103         int layer = atoi((*it).substr(delimPos+1, len-delimPos-1).c_str());
00104         log << MSG::DEBUG << "Tower " << tower << " Layer " << layer << endreq;
00105         std::vector<int>& curList = m_towerLayerList[tower];
00106         curList.push_back(layer);                
00107     }
00108 }
00109 
00110 void CalFailureModeSvc::processTowerList() {
00111      // Purpose and Method: process the jobOptions input lists of towers
00112     //                     
00113    
00114     MsgStream log(msgSvc(), name());
00115     
00116     const std::vector<std::string>& theTowers = m_towerListProperty.value( );
00117 
00118     if (theTowers.size() == 0) return;
00119 
00120     log << MSG::DEBUG << "Towers to kill " << endreq;
00121 
00122     m_failureModes = m_failureModes || 1 << TOWERLAYER;
00123 
00124     std::vector<std::string>::const_iterator it;
00125     std::vector<std::string>::const_iterator itend = theTowers.end( );
00126     for (it = theTowers.begin(); it != itend; it++) {
00127         int tower = atoi((*it).c_str());
00128         log << MSG::DEBUG << "Tower " << tower << endreq;
00129         m_towerList.push_back(tower);
00130     }
00131 }
00132 
00133 bool CalFailureModeSvc::matchTower(idents::CalXtalId id) {
00134     // Purpose and Method: check whether given id is in any of the identified lists
00135     //                     
00136     
00137     if (m_towerList.size() == 0) return false;
00138 
00139     int tower = id.getTower();
00140     
00141     // Search to see if this event id is among the list of ids we want to pause on
00142     int *loc = std::find(m_towerList.begin(), m_towerList.end(), tower);                
00143 
00144     return (loc != m_towerList.end());
00145 }
00146 
00147 bool CalFailureModeSvc::matchTowerLayer(idents::CalXtalId id) {
00148     // Purpose and Method: look for the given id in the tower list
00149     //                     
00150     
00151     if (m_towerLayerList.size() == 0) return false;
00152 
00153     int tower = id.getTower();
00154     int layer = id.getLayer();
00155     
00156     std::vector<int> &layerList = m_towerLayerList[tower];
00157     
00158     // Search to see if this (tower,layer) is among the list
00159     int *loc = std::find(layerList.begin(), layerList.end(), layer);                
00160     
00161     return (loc != layerList.end());
00162 }
00163 
00164 bool CalFailureModeSvc::matchChannel(idents::CalXtalId id) {
00165     // Purpose and Method: look for the given id in the (tower,layer) list
00166     //                     
00167      
00168     if (matchTower(id)) return true;
00169     if (matchTowerLayer(id)) return true;
00170     
00171     return false;
00172 }

Generated on Tue Oct 29 08:24:27 2002 for CalUtil by doxygen1.2.16