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