00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "CalUtil/CalFailureModeSvc.h"
00011
00012 #include "GaudiKernel/MsgStream.h"
00013 #include "GaudiKernel/SvcFactory.h"
00014 #include <algorithm>
00015
00016
00017
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
00024
00025
00026
00027
00028
00029
00030
00031
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
00055
00056
00057
00058
00059
00060
00061 StatusCode status = StatusCode::SUCCESS;
00062
00063
00064 MsgStream log( msgSvc(), name() );
00065
00066
00067 Service::initialize ();
00068
00069
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
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
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
00135
00136
00137 if (m_towerList.size() == 0) return false;
00138
00139 int tower = id.getTower();
00140
00141
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
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
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
00166
00167
00168 if (matchTower(id)) return true;
00169 if (matchTowerLayer(id)) return true;
00170
00171 return false;
00172 }