00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "GaudiKernel/MsgStream.h"
00010
00011 #include "MucMappingAlg/MucMappingAlg.h"
00012
00013
00014 MucMappingAlg::MucMappingAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00015 Algorithm(name, pSvcLocator), m_fFecOrder(1)
00016 {
00017
00018 declareProperty("FecOrder", m_fFecOrder);
00019 declareProperty("ChainMap", m_sFileName[0]);
00020 declareProperty("FecMap", m_sFileName[1]);
00021 declareProperty("OutputOption", m_sOutputOption);
00022 }
00023
00024
00025 StatusCode MucMappingAlg::initialize()
00026 {
00027 MsgStream log(msgSvc(), name());
00028 log << MSG::INFO << endreq << "In initialize()" << endreq;
00029 log << MSG::INFO << "Fec order:\t\t" << m_fFecOrder << endreq;
00030 log << MSG::INFO << "Chain map:\t" << m_sFileName[0] << endreq;
00031 log << MSG::INFO << "Output map:\t\t" << m_sFileName[1] << endreq;
00032 log << MSG::INFO << "Output option:\t\t" << m_sOutputOption << endreq;
00033
00034 ifstream fin(m_sFileName[0].c_str(), ios::in);
00035
00036 log << MSG::INFO << "-------Chain map--------" << endreq;
00037 if( m_sFileName[0].size() == 0 || fin.bad() )
00038 {
00039
00040 log << MSG::INFO << endreq << "Load default map!" << endreq;
00041
00042 for(int i=0; i<MODULE_MAX; i++)
00043 {
00044 for(int j=0; j<SOCKET_MAX; j++)
00045 {
00046 m_sChainMap[i][j] = DEFAULT_MAP[i][j];
00047
00048 log << MSG::INFO << m_sChainMap[i][j] << "\t";
00049 }
00050
00051 log << MSG::INFO << endreq;
00052 }
00053 }
00054 else
00055 {
00056 string tempMark;
00057 for(int i=0; i<MODULE_MAX; i++)
00058 {
00059 for(int j=0; j<SOCKET_MAX; j++)
00060 {
00061 fin >> tempMark;
00062
00063 if( tempMark.size() > MARK_NUM )
00064 {
00065 log << MSG::INFO << endreq
00066 << "Mark:\t" << "Module\t" << i << "Socket\t" << j << "\t"
00067 << tempMark << "\terror!"<< endreq;
00068 continue;
00069 }
00070
00071 m_sChainMap[i][j] = tempMark;
00072
00073 log << MSG::INFO << m_sChainMap[i][j] << "\t";
00074 }
00075 log << MSG::INFO << endreq;
00076 }
00077
00078 fin.close();
00079 }
00080 log << MSG::INFO << "------------------------" << endreq;
00081 return StatusCode::SUCCESS;
00082 }
00083
00084
00085 StatusCode MucMappingAlg::execute()
00086 {
00087 MsgStream log(msgSvc(), name());
00088 log << MSG::INFO << endreq << "In execute()" << endreq;
00089
00090
00091 return StatusCode::SUCCESS;
00092 }
00093
00094
00095
00096 StatusCode MucMappingAlg::finalize()
00097 {
00098 MsgStream log(msgSvc(), name());
00099 log << MSG::INFO << endreq << "In finalize()" << endreq << endreq;
00100
00101 ofstream fout(m_sFileName[1].c_str(), ios::out);
00102 if( fout.bad() )
00103 {
00104 log << MSG::INFO << "Output file created error!" << endreq;
00105 exit(-1);
00106 }
00107
00108 for(int i=0; i<DATA_NUM; i++)
00109 {
00110 if( m_sOutputOption[i] == '1' )
00111 fout << DATA_NAME[i] << "\t";
00112 }
00113 fout << endl;
00114
00115 for(int i=0; i<MODULE_MAX; i++)
00116 {
00117 log << MSG::INFO << "----------------------Module [ " << i << " ]----------------------" << endreq;
00118 for(int j=0; j<SOCKET_MAX; j++)
00119 {
00120 int id = i * SOCKET_MAX + j;
00121 m_mucChain[id] = new MucChain( id, m_sChainMap[i][j], i, j, m_fFecOrder );
00122
00123 for( int k=0; k<m_mucChain[id]->GetFecTotal(); k++ )
00124 {
00125 MucFec* aFec = m_mucChain[id]->GetFec( k );
00126 if( m_sOutputOption[0] == '1' )
00127 fout << aFec->GetChainName() << "\t";
00128 if( m_sOutputOption[1] == '1' )
00129 fout << aFec->DecodeModule() << "\t";
00130 if( m_sOutputOption[2] == '1' )
00131 fout << aFec->DecodeSocket() << "\t";
00132 if( m_sOutputOption[3] == '1' )
00133 fout << aFec->DecodeFecID() << "\t";
00134 if( m_sOutputOption[4] == '1' )
00135 fout << aFec->GetVmeAddress() << "\t";
00136 if( m_sOutputOption[5] == '1' )
00137 fout << aFec->GetVmeBin() << "\t";
00138 if( m_sOutputOption[6] == '1' )
00139 fout << aFec->GetPart() << "\t";
00140 if( m_sOutputOption[7] == '1' )
00141 fout << aFec->GetSegment() << "\t";
00142 if( m_sOutputOption[8] == '1' )
00143 fout << aFec->GetLayer() << "\t";
00144 if( m_sOutputOption[9] == '1' )
00145 fout << aFec->GetFirstStripID() << "\t";
00146 if( m_sOutputOption[10] == '1' )
00147 fout << aFec->GetStripOrder() << "\t";
00148 if( m_sOutputOption[11] == '1' )
00149 fout << aFec->GetGeoAddress() << "\t";
00150 if( m_sOutputOption[12] == '1' )
00151 fout << aFec->GetGeoBin() << "\t";
00152 if( m_sOutputOption[13] == '1' )
00153 fout << aFec->GetDataBin() << "\t";
00154 fout << endl;
00155 }
00156
00157 log << MSG::INFO << "Chain ID: " << id << "\tName: " << m_sChainMap[i][j];
00158 log << MSG::INFO << "\tSocket: " << j << "\tFecTotal: " << m_mucChain[id]->GetFecTotal()
00159 << "\tFecOrder: " << m_fFecOrder << "\tdone!" << endreq;
00160 }
00161 }
00162
00163 fout.close();
00164
00165 return StatusCode::SUCCESS;
00166 }
00167
00168
00169
00170
00171
00172
00173