BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
HltBuilder.cxx
Go to the documentation of this file.
1#include <iostream>
2#include <fstream>
3#include "Identifier/HltID.h"
5using namespace std;
6
8 :Builder()
9{
10 // set vector size (2^14) and initialize to -1
11 m_re2te = new uint32_t[256]; // we have 2^8 different REID
12 memset((void*)m_re2te, 0xFF, 256*sizeof(uint32_t));
13
15}
16
18{
19 delete m_re2te;
20}
21
22void HltBuilder::unPack(uint32_t reDigi, uint32_t n,
23 uint32_t &REId, uint32_t &TEData1, uint32_t &TEData2)
24{
25 if ( n == 0 ) {
26 REId = 0;
27 TEData1 = reDigi;
28 TEData2 = 0;
29 }
30 else if ( n == 1 ) {
31 REId = 1;
32 TEData1 = (reDigi&m_algMask) >> m_algIndex;
33 TEData2 = (reDigi&m_criMask) >> m_criIndex;
34 //cout<<hex<<reDigi<<"=>"<<TEData1<<","<<TEData2<<endl
35 // <<m_algMask<<" "<<m_algIndex<<" "<<m_criMask
36 // <<" "<<m_criIndex<<dec<<endl;
37 }
38 else {
39 REId = n+1;
40 TEData1 =reDigi;
41 TEData2 =0;
42 }
43
44 return;
45}
46
47StatusCode HltBuilder::pack(HltRawCol* digiCol, WriteRawEvent*& re)
48{
49 if (digiCol == 0 ) {
50 cerr << "HltBuilder::pack can't get digiCol" << endl;
51 return StatusCode::FAILURE;
52 }
53
54 uint32_t size = 0;
55 uint32_t hltdigi = 0;
56 Identifier id;
57 uint32_t event_filter[4]={0,0,0,0};
58
59 HltRawCol::const_iterator pHltDigi = digiCol->begin();
60 for ( ; pHltDigi!= digiCol->end(); pHltDigi++) {
61 id = (*pHltDigi)->identify();
62 if(HltID::is_algorithm(id)){
63 uint32_t alg= (*pHltDigi)->getIntChannel();
64 uint32_t cri=0;
65 //cout << " debug by fucd: alg=" << alg << endl;
66 pHltDigi++;
67 if(!HltID::is_criteria((*pHltDigi)->identify())) {
68 pHltDigi--;
69 }
70 else {
71 cri= (*pHltDigi)->getIntChannel();
72 }
73 hltdigi = ((alg<<m_algIndex)&m_algMask) | ((cri<<m_algIndex)&m_criMask);
74 event_filter[1] =hltdigi;
75 }
76 else if(HltID::is_criteria(id)){
77 cerr<< "HltBuilder::pack(): HLT raw data error!" << endl;
78 return StatusCode::FAILURE;
79 }
80 else{
81 hltdigi = (*pHltDigi)->getIntChannel();
82 if(HltID::is_eventtype(id)) event_filter[0]=hltdigi;
83 else if(HltID::is_version(id)) event_filter[2]=hltdigi;
84 else if(HltID::is_energy(id)) event_filter[3]=hltdigi;
85 else m_buf[size++] = hltdigi;
86 }
87 //cout << " debug by fucd: digi="<< hex << hltdigi << dec <<endl;
88 }
89
90 re->event_filter_info(&event_filter[0]);
91 append2event(re, 0x7c0000, size);
92
93 return StatusCode::SUCCESS;
94}
95
96// initialize re2te tables
97
98StatusCode HltBuilder::initialize(string& initFile)
99{
100 ifstream f;
101
102 //-----------------------------------------------------------
103 // read initFile
104 f.open( initFile.c_str());
105
106 if( f.bad() )
107 {
108 cerr << "Error: could not open file " << initFile << endl;
109 return false;
110 }
111
112 if (!Builder::find( f, "##HltRawConf", initFile)) {
113 cerr << "Error: could not find '##HltRawConf' in file " << initFile << endl;
114 return StatusCode::FAILURE;
115 }
116
117 if( !Builder::expect( f, "#Index,mask", initFile) ||
118 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||
119 !Builder::expectInt( f, "alg", initFile, m_algIndex, m_algMask) ||
120 !Builder::expectInt( f, "cri", initFile, m_criIndex, m_criMask) ||
121 !Builder::expectInt( f, "var", initFile, m_varIndex, m_varMask))
122 return false;
123 f.close();
124
125 cout<<"HltBuilder:: #Index mask"<<endl
126 <<" "<<m_idIndex<<" "<<m_idMask<<endl
127 <<" "<<m_algIndex<<" "<<m_algMask<<endl
128 <<" "<<m_criIndex<<" "<<m_criMask<<endl
129 <<" "<<m_varIndex<<" "<<m_varMask<<endl;
130
131 //-----------------------------------------------------------
132 //Build re2te table
133 for (uint32_t i = 0; i < 256; i++) {
134 m_re2te[i] = (0x50000000 | i); //m_re2te[i]=0x50000000+0x00000000+i;
135 //if(i>4) m_re2te[i]+=0x00000000;
136 m_te2reMap.insert(TE2REMAP::value_type(m_re2te[i], i)) ;
137 }
138 // return successful initialization
139 return StatusCode::SUCCESS;
140}
141
142
143uint32_t HltBuilder::getREID(uint32_t teid)
144{
145
146 TE2REMAP::iterator itr = m_te2reMap.find(teid);
147
148 uint32_t reid = 0;
149 if(itr!= m_te2reMap.end())
150 reid = (*itr).second;
151 else
152 {
153 cout<<"wrong teid in emc "<<teid<<endl;
154 exit(8);
155 }
156
157 return reid;
158
159}
160
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
const Int_t n
ObjectVector< HltRaw > HltRawCol
Definition: HltRaw.h:35
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
Definition: Builder.cxx:76
static bool find(ifstream &f, string msg, string fname)
Definition: Builder.cxx:60
static bool expect(ifstream &f, string msg, string fname)
Definition: Builder.cxx:28
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
Definition: Builder.cxx:44
void unPack(uint32_t reDigi, uint32_t n, uint32_t &REId, uint32_t &TEData1, uint32_t &TEData2)
Definition: HltBuilder.cxx:22
uint32_t getREID(uint32_t teid)
Definition: HltBuilder.cxx:143
StatusCode pack(HltRawCol *digiCol, WriteRawEvent *&re)
Definition: HltBuilder.cxx:47
StatusCode initialize(string &initFile)
Definition: HltBuilder.cxx:98
virtual ~HltBuilder()
Definition: HltBuilder.cxx:17
static bool is_version(const Identifier &id)
Definition: HltID.cxx:90
static bool is_eventtype(const Identifier &id)
Definition: HltID.cxx:72
static bool is_algorithm(const Identifier &id)
Definition: HltID.cxx:78
static bool is_criteria(const Identifier &id)
Definition: HltID.cxx:84
static bool is_energy(const Identifier &id)
Definition: HltID.cxx:96