BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucMappingAlg.cxx
Go to the documentation of this file.
1//------------------------------------------------------------------------------|
2// [File ]: MucMappingAlg.cxx |
3// [Brief ]: Muon detector electronics mapping algrithom for BESIII |
4// [Author]: Xie Yuguang, <ygxie@mail.ihep.ac.cn> |
5// [Date ]: Mar 28, 2006 |
6// [Log ]: See ChangLog |
7//------------------------------------------------------------------------------|
8
9#include "GaudiKernel/MsgStream.h"
10
13// -----------------------------------Declaration----------------------------------------
14MucMappingAlg::MucMappingAlg( const std::string& name, ISvcLocator* pSvcLocator )
15 : Algorithm( name, pSvcLocator ), m_fFecOrder( 1 ) {
16 // Declear the properties
17 declareProperty( "FecOrder", m_fFecOrder );
18 declareProperty( "ChainMap", m_sFileName[0] );
19 declareProperty( "FecMap", m_sFileName[1] );
20 declareProperty( "OutputOption", m_sOutputOption );
21}
22
23// ----------------------------------Initialize-----------------------------------------
25 MsgStream log( msgSvc(), name() );
26 log << MSG::INFO << endmsg << "In initialize()" << endmsg;
27 log << MSG::INFO << "Fec order:\t\t" << m_fFecOrder << endmsg;
28 log << MSG::INFO << "Chain map:\t" << m_sFileName[0] << endmsg;
29 log << MSG::INFO << "Output map:\t\t" << m_sFileName[1] << endmsg;
30 log << MSG::INFO << "Output option:\t\t" << m_sOutputOption << endmsg;
31
32 ifstream fin( m_sFileName[0].c_str(), ios::in );
33
34 log << MSG::INFO << "-------Chain map--------" << endmsg;
35 if ( m_sFileName[0].size() == 0 || fin.bad() )
36 {
37 log << MSG::INFO << endmsg << "Load default map!" << endmsg;
38
39 for ( int i = 0; i < MODULE_MAX; i++ )
40 {
41 for ( int j = 0; j < SOCKET_MAX; j++ )
42 {
43 m_sChainMap[i][j] = DEFAULT_MAP[i][j];
44 // strcpy( m_ChainMap[i][j], DEFAULT_MAP[i][j] );
45 log << MSG::INFO << m_sChainMap[i][j] << "\t";
46 }
47
48 log << MSG::INFO << endmsg;
49 }
50 }
51 else
52 {
53 string tempMark;
54 for ( int i = 0; i < MODULE_MAX; i++ )
55 {
56 for ( int j = 0; j < SOCKET_MAX; j++ )
57 {
58 fin >> tempMark;
59 // if( strlen( tempMark ) > MARK_NUM )
60 if ( tempMark.size() > MARK_NUM )
61 {
62 log << MSG::INFO << endmsg << "Mark:\t"
63 << "Module\t" << i << "Socket\t" << j << "\t" << tempMark << "\terror!"
64 << endmsg;
65 continue;
66 }
67
68 m_sChainMap[i][j] = tempMark;
69 // strcpy( m_sChainMap[i][j], tempMark );
70 log << MSG::INFO << m_sChainMap[i][j] << "\t";
71 }
72 log << MSG::INFO << endmsg;
73 }
74
75 fin.close();
76 }
77 log << MSG::INFO << "------------------------" << endmsg;
78
79 return StatusCode::SUCCESS;
80}
81
82// ----------------------------------Execute--------------------------------------------
84 MsgStream log( msgSvc(), name() );
85 log << MSG::INFO << endmsg << "In execute()" << endmsg;
86
87 return StatusCode::SUCCESS;
88}
89
90// ----------------------------------Finalize------------------------------------------
92 MsgStream log( msgSvc(), name() );
93 log << MSG::INFO << endmsg << "In finalize()" << endmsg << endmsg;
94
95 ofstream fout( m_sFileName[1].c_str(), ios::out );
96 if ( fout.bad() )
97 {
98 log << MSG::INFO << "Output file created error!" << endmsg;
99 exit( -1 );
100 }
101
102 for ( int i = 0; i < DATA_NUM; i++ )
103 {
104 if ( m_sOutputOption[i] == '1' ) fout << DATA_NAME[i] << "\t";
105 }
106 fout << endl;
107
108 for ( int i = 0; i < MODULE_MAX; i++ )
109 {
110 log << MSG::INFO << "----------------------Module [ " << i << " ]----------------------"
111 << endmsg;
112 for ( int j = 0; j < SOCKET_MAX; j++ )
113 {
114 int id = i * SOCKET_MAX + j;
115 m_mucChain[id] = new MucChain( id, m_sChainMap[i][j], i, j, m_fFecOrder );
116
117 for ( int k = 0; k < m_mucChain[id]->GetFecTotal(); k++ )
118 {
119 MucFec* aFec = m_mucChain[id]->GetFec( k );
120 if ( m_sOutputOption[0] == '1' ) fout << aFec->GetChainName() << "\t";
121 if ( m_sOutputOption[1] == '1' ) fout << aFec->DecodeModule() << "\t";
122 if ( m_sOutputOption[2] == '1' ) fout << aFec->DecodeSocket() << "\t";
123 if ( m_sOutputOption[3] == '1' ) fout << aFec->DecodeFecID() << "\t";
124 if ( m_sOutputOption[4] == '1' ) fout << aFec->GetVmeAddress() << "\t";
125 if ( m_sOutputOption[5] == '1' ) fout << aFec->GetVmeBin() << "\t";
126 if ( m_sOutputOption[6] == '1' ) fout << aFec->GetPart() << "\t";
127 if ( m_sOutputOption[7] == '1' ) fout << aFec->GetSegment() << "\t";
128 if ( m_sOutputOption[8] == '1' ) fout << aFec->GetLayer() << "\t";
129 if ( m_sOutputOption[9] == '1' ) fout << aFec->GetFirstStripID() << "\t";
130 if ( m_sOutputOption[10] == '1' ) fout << aFec->GetStripOrder() << "\t";
131 if ( m_sOutputOption[11] == '1' ) fout << aFec->GetGeoAddress() << "\t";
132 if ( m_sOutputOption[12] == '1' ) fout << aFec->GetGeoBin() << "\t";
133 if ( m_sOutputOption[13] == '1' ) fout << aFec->GetDataBin() << "\t";
134 fout << endl;
135 }
136
137 log << MSG::INFO << "Chain ID: " << id << "\tName: " << m_sChainMap[i][j];
138 log << MSG::INFO << "\tSocket: " << j << "\tFecTotal: " << m_mucChain[id]->GetFecTotal()
139 << "\tFecOrder: " << m_fFecOrder << "\tdone!" << endmsg;
140 } // end socket
141 } // end module
142
143 fout.close();
144
145 return StatusCode::SUCCESS;
146}
DECLARE_COMPONENT(BesBdkRc)
const int SOCKET_MAX
const std::string DEFAULT_MAP[MODULE_MAX][SOCKET_MAX]
const std::string DATA_NAME[DATA_NUM]
const int MODULE_MAX
const int DATA_NUM
const unsigned int MARK_NUM
IMessageSvc * msgSvc()
string GetGeoBin()
Definition MucFec.cxx:212
string GetChainName()
Definition MucFec.h:66
int GetFirstStripID()
Definition MucFec.h:58
int DecodeModule()
Definition MucFec.h:60
int GetSegment()
Definition MucFec.h:56
int GetPart()
Definition MucFec.h:55
string GetDataBin()
Definition MucFec.cxx:214
int DecodeSocket()
Definition MucFec.h:61
int DecodeFecID()
Definition MucFec.h:62
int GetLayer()
Definition MucFec.h:57
string GetVmeBin()
Definition MucFec.cxx:210
unsigned short GetGeoAddress()
Definition MucFec.h:64
int GetStripOrder()
Definition MucFec.h:50
unsigned short GetVmeAddress()
Definition MucFec.h:52
StatusCode execute()
MucMappingAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize()
StatusCode initialize()