BOSS 7.0.6
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
12
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
40 log << MSG::INFO << endreq << "Load default map!" << endreq;
41
42 for(int i=0; i<MODULE_MAX; i++)
43 {
44 for(int j=0; j<SOCKET_MAX; j++)
45 {
46 m_sChainMap[i][j] = DEFAULT_MAP[i][j];
47 // strcpy( m_ChainMap[i][j], DEFAULT_MAP[i][j] );
48 log << MSG::INFO << m_sChainMap[i][j] << "\t";
49 }
50
51 log << MSG::INFO << endreq;
52 }
53 }
54 else
55 {
56 string tempMark;
57 for(int i=0; i<MODULE_MAX; i++)
58 {
59 for(int j=0; j<SOCKET_MAX; j++)
60 {
61 fin >> tempMark;
62 // if( strlen( tempMark ) > MARK_NUM )
63 if( tempMark.size() > MARK_NUM )
64 {
65 log << MSG::INFO << endreq
66 << "Mark:\t" << "Module\t" << i << "Socket\t" << j << "\t"
67 << tempMark << "\terror!"<< endreq;
68 continue;
69 }
70
71 m_sChainMap[i][j] = tempMark;
72 // strcpy( m_sChainMap[i][j], tempMark );
73 log << MSG::INFO << m_sChainMap[i][j] << "\t";
74 }
75 log << MSG::INFO << endreq;
76 }
77
78 fin.close();
79 }
80 log << MSG::INFO << "------------------------" << endreq;
81 return StatusCode::SUCCESS;
82}
83
84// ----------------------------------Execute--------------------------------------------
86{
87 MsgStream log(msgSvc(), name());
88 log << MSG::INFO << endreq << "In execute()" << endreq;
89
90
91 return StatusCode::SUCCESS;
92}
93
94
95// ----------------------------------Finalize------------------------------------------
97{
98 MsgStream log(msgSvc(), name());
99 log << MSG::INFO << endreq << "In finalize()" << endreq << endreq;
100
101 ofstream fout(m_sFileName[1].c_str(), ios::out);
102 if( fout.bad() )
103 {
104 log << MSG::INFO << "Output file created error!" << endreq;
105 exit(-1);
106 }
107
108 for(int i=0; i<DATA_NUM; i++)
109 {
110 if( m_sOutputOption[i] == '1' )
111 fout << DATA_NAME[i] << "\t";
112 }
113 fout << endl;
114
115 for(int i=0; i<MODULE_MAX; i++)
116 {
117 log << MSG::INFO << "----------------------Module [ " << i << " ]----------------------" << endreq;
118 for(int j=0; j<SOCKET_MAX; j++)
119 {
120 int id = i * SOCKET_MAX + j;
121 m_mucChain[id] = new MucChain( id, m_sChainMap[i][j], i, j, m_fFecOrder );
122
123 for( int k=0; k<m_mucChain[id]->GetFecTotal(); k++ )
124 {
125 MucFec* aFec = m_mucChain[id]->GetFec( k );
126 if( m_sOutputOption[0] == '1' )
127 fout << aFec->GetChainName() << "\t";
128 if( m_sOutputOption[1] == '1' )
129 fout << aFec->DecodeModule() << "\t";
130 if( m_sOutputOption[2] == '1' )
131 fout << aFec->DecodeSocket() << "\t";
132 if( m_sOutputOption[3] == '1' )
133 fout << aFec->DecodeFecID() << "\t";
134 if( m_sOutputOption[4] == '1' )
135 fout << aFec->GetVmeAddress() << "\t";
136 if( m_sOutputOption[5] == '1' )
137 fout << aFec->GetVmeBin() << "\t";
138 if( m_sOutputOption[6] == '1' )
139 fout << aFec->GetPart() << "\t";
140 if( m_sOutputOption[7] == '1' )
141 fout << aFec->GetSegment() << "\t";
142 if( m_sOutputOption[8] == '1' )
143 fout << aFec->GetLayer() << "\t";
144 if( m_sOutputOption[9] == '1' )
145 fout << aFec->GetFirstStripID() << "\t";
146 if( m_sOutputOption[10] == '1' )
147 fout << aFec->GetStripOrder() << "\t";
148 if( m_sOutputOption[11] == '1' )
149 fout << aFec->GetGeoAddress() << "\t";
150 if( m_sOutputOption[12] == '1' )
151 fout << aFec->GetGeoBin() << "\t";
152 if( m_sOutputOption[13] == '1' )
153 fout << aFec->GetDataBin() << "\t";
154 fout << endl;
155 }
156
157 log << MSG::INFO << "Chain ID: " << id << "\tName: " << m_sChainMap[i][j];
158 log << MSG::INFO << "\tSocket: " << j << "\tFecTotal: " << m_mucChain[id]->GetFecTotal()
159 << "\tFecOrder: " << m_fFecOrder << "\tdone!" << endreq;
160 } // end socket
161 } // end module
162
163 fout.close();
164
165 return StatusCode::SUCCESS;
166}
167
168
169
170
171
172
173
const int SOCKET_MAX
Definition: MucMappingAlg.h:21
const std::string DEFAULT_MAP[MODULE_MAX][SOCKET_MAX]
Definition: MucMappingAlg.h:29
const std::string DATA_NAME[DATA_NUM]
Definition: MucMappingAlg.h:41
const int MODULE_MAX
Definition: MucMappingAlg.h:20
const int DATA_NUM
Definition: MucMappingAlg.h:27
const unsigned int MARK_NUM
Definition: MucMappingAlg.h:26
IMessageSvc * msgSvc()
int GetFecTotal()
Definition: MucChain.h:54
MucFec * GetFec(int fecId)
Definition: MucChain.h:59
Definition: MucFec.h:40
string GetGeoBin()
Definition: MucFec.cxx:232
string GetChainName()
Definition: MucFec.h:59
int GetFirstStripID()
Definition: MucFec.h:58
int DecodeModule()
Definition: MucFec.h:63
int GetSegment()
Definition: MucFec.h:55
int GetPart()
Definition: MucFec.h:54
string GetDataBin()
Definition: MucFec.cxx:237
int DecodeSocket()
Definition: MucFec.h:64
int DecodeFecID()
Definition: MucFec.h:65
int GetLayer()
Definition: MucFec.h:56
string GetVmeBin()
Definition: MucFec.cxx:227
unsigned short GetGeoAddress()
Definition: MucFec.h:57
int GetStripOrder()
Definition: MucFec.h:49
unsigned short GetVmeAddress()
Definition: MucFec.h:51
StatusCode execute()
MucMappingAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize()
StatusCode initialize()