BOSS 7.1.1
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, <[email protected]> |
5// [Date ]: Mar 28, 2006 |
6// [Log ]: See ChangLog |
7//------------------------------------------------------------------------------|
8
9#include "GaudiKernel/MsgStream.h"
10
12DECLARE_COMPONENT(MucMappingAlg)
13// -----------------------------------Declaration----------------------------------------
14MucMappingAlg::MucMappingAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 Algorithm(name, pSvcLocator), m_fFecOrder(1)
16{
17 // Declear the properties
18 declareProperty("FecOrder", m_fFecOrder);
19 declareProperty("ChainMap", m_sFileName[0]);
20 declareProperty("FecMap", m_sFileName[1]);
21 declareProperty("OutputOption", m_sOutputOption);
22}
23
24// ----------------------------------Initialize-----------------------------------------
26{
27 MsgStream log(msgSvc(), name());
28 log << MSG::INFO << endreq << "In initialize()" << endreq;
29 log << MSG::INFO << "Fec order:\t\t" << m_fFecOrder << endreq;
30 log << MSG::INFO << "Chain map:\t" << m_sFileName[0] << endreq;
31 log << MSG::INFO << "Output map:\t\t" << m_sFileName[1] << endreq;
32 log << MSG::INFO << "Output option:\t\t" << m_sOutputOption << endreq;
33
34 ifstream fin(m_sFileName[0].c_str(), ios::in);
35
36 log << MSG::INFO << "-------Chain map--------" << endreq;
37 if( m_sFileName[0].size() == 0 || fin.bad() )
38 {
39 log << MSG::INFO << endreq << "Load default map!" << endreq;
40
41 for(int i=0; i<MODULE_MAX; i++)
42 {
43 for(int j=0; j<SOCKET_MAX; j++) {
44 m_sChainMap[i][j] = DEFAULT_MAP[i][j];
45 // strcpy( m_ChainMap[i][j], DEFAULT_MAP[i][j] );
46 log << MSG::INFO << m_sChainMap[i][j] << "\t";
47 }
48
49 log << MSG::INFO << endreq;
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 << endreq
63 << "Mark:\t" << "Module\t" << i << "Socket\t" << j << "\t"
64 << tempMark << "\terror!"<< endreq;
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 << endreq;
73 }
74
75 fin.close();
76 }
77 log << MSG::INFO << "------------------------" << endreq;
78
79 return StatusCode::SUCCESS;
80}
81
82// ----------------------------------Execute--------------------------------------------
84{
85 MsgStream log(msgSvc(), name());
86 log << MSG::INFO << endreq << "In execute()" << endreq;
87
88 return StatusCode::SUCCESS;
89}
90
91
92// ----------------------------------Finalize------------------------------------------
94{
95 MsgStream log(msgSvc(), name());
96 log << MSG::INFO << endreq << "In finalize()" << endreq << endreq;
97
98 ofstream fout(m_sFileName[1].c_str(), ios::out);
99 if( fout.bad() ) {
100 log << MSG::INFO << "Output file created error!" << endreq;
101 exit(-1);
102 }
103
104 for(int i=0; i<DATA_NUM; i++) {
105 if( m_sOutputOption[i] == '1' )
106 fout << DATA_NAME[i] << "\t";
107 }
108 fout << endl;
109
110 for(int i=0; i<MODULE_MAX; i++)
111 {
112 log << MSG::INFO << "----------------------Module [ " << i << " ]----------------------" << endreq;
113 for(int j=0; j<SOCKET_MAX; j++)
114 {
115 int id = i * SOCKET_MAX + j;
116 m_mucChain[id] = new MucChain( id, m_sChainMap[i][j], i, j, m_fFecOrder );
117
118 for( int k=0; k<m_mucChain[id]->GetFecTotal(); k++ )
119 {
120 MucFec* aFec = m_mucChain[id]->GetFec( k );
121 if( m_sOutputOption[0] == '1' )
122 fout << aFec->GetChainName() << "\t";
123 if( m_sOutputOption[1] == '1' )
124 fout << aFec->DecodeModule() << "\t";
125 if( m_sOutputOption[2] == '1' )
126 fout << aFec->DecodeSocket() << "\t";
127 if( m_sOutputOption[3] == '1' )
128 fout << aFec->DecodeFecID() << "\t";
129 if( m_sOutputOption[4] == '1' )
130 fout << aFec->GetVmeAddress() << "\t";
131 if( m_sOutputOption[5] == '1' )
132 fout << aFec->GetVmeBin() << "\t";
133 if( m_sOutputOption[6] == '1' )
134 fout << aFec->GetPart() << "\t";
135 if( m_sOutputOption[7] == '1' )
136 fout << aFec->GetSegment() << "\t";
137 if( m_sOutputOption[8] == '1' )
138 fout << aFec->GetLayer() << "\t";
139 if( m_sOutputOption[9] == '1' )
140 fout << aFec->GetFirstStripID() << "\t";
141 if( m_sOutputOption[10] == '1' )
142 fout << aFec->GetStripOrder() << "\t";
143 if( m_sOutputOption[11] == '1' )
144 fout << aFec->GetGeoAddress() << "\t";
145 if( m_sOutputOption[12] == '1' )
146 fout << aFec->GetGeoBin() << "\t";
147 if( m_sOutputOption[13] == '1' )
148 fout << aFec->GetDataBin() << "\t";
149 fout << endl;
150 }
151
152 log << MSG::INFO << "Chain ID: " << id << "\tName: " << m_sChainMap[i][j];
153 log << MSG::INFO << "\tSocket: " << j << "\tFecTotal: " << m_mucChain[id]->GetFecTotal()
154 << "\tFecOrder: " << m_fFecOrder << "\tdone!" << endreq;
155 } // end socket
156 } // end module
157
158 fout.close();
159
160 return StatusCode::SUCCESS;
161}
162
163
164
165
166
167
168
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()
int GetFecTotal()
Definition MucChain.h:53
MucFec * GetFec(int fecId)
Definition MucChain.h:58
string GetGeoBin()
Definition MucFec.cxx:215
string GetChainName()
Definition MucFec.h:64
int GetFirstStripID()
Definition MucFec.h:56
int DecodeModule()
Definition MucFec.h:58
int GetSegment()
Definition MucFec.h:54
int GetPart()
Definition MucFec.h:53
string GetDataBin()
Definition MucFec.cxx:220
int DecodeSocket()
Definition MucFec.h:59
int DecodeFecID()
Definition MucFec.h:60
int GetLayer()
Definition MucFec.h:55
string GetVmeBin()
Definition MucFec.cxx:210
unsigned short GetGeoAddress()
Definition MucFec.h:62
int GetStripOrder()
Definition MucFec.h:48
unsigned short GetVmeAddress()
Definition MucFec.h:50
StatusCode execute()
StatusCode finalize()
StatusCode initialize()