BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
ana_raw.cxx
Go to the documentation of this file.
4#include <iostream>
5#include <iomanip>
6#include <unistd.h>
7#include <stdlib.h>
8
9unsigned long calEts(const uint32_t* dptr)
10{
11 unsigned int tmp = dptr[0] & 0xffffff;
12 unsigned long val = (tmp >> 16 ) * 61 * 61;
13 val += ((tmp >> 8) & 0xff) * 61;
14 val += tmp & 0xff;
15 val *= 2000000; // s -> 500ns
16 val += (dptr[1] & 0x3fffff);
17
18 return val;
19}
20
21void dump( const uint32_t* data, uint32_t n )
22{
23 std::cout << std::hex;
24 for ( uint32_t i = 0; i < n; ++i ) {
25 if ( i%8 != 0 ) {
26 std::cout << " ";
27 }
28 else {
29 if ( i != 0 )
30 std::cout << std::endl;
31 }
32 std::cout << "0x" << std::setw(8) << std::setfill('0') << data[i];
33 }
34 std::cout << std::dec << std::endl;
35}
36
37void processETS(const uint32_t* dataPtr, uint32_t dataLen)
38{
39 unsigned long t1 = 0, t2 = 0;
40
41 if ( dataLen > 11 && dataPtr[1] == 0xffffffff ) {
42 uint32_t start = 10;
43 if ( (dataPtr[start] >> 24) == 0xcf ) {
44 t1 = calEts( dataPtr + start );
45
46 static unsigned long _t2 = 0;
47 if ( (start+3) < dataLen && (dataPtr[start+2]>>24) == 0xd1 ) {
48 _t2 = calEts( dataPtr + start + 2 );
49 }
50 t2 = _t2;
51 }
52 }
53
54 std::cout << "t1 " << t1 << " t2 " << t2 << std::endl;
55
56 dump(dataPtr, dataLen);
57}
58
59int main(int argc, char* argv[])
60{
61 if (argc != 3) {
62 std::cout << "Usage: " << argv[0] << " file.data nevts" << std::endl;
63 exit(1);
64 }
65
66 const uint32_t** m_sds = new const uint32_t*[64];
67 const uint32_t** m_robs = new const uint32_t*[256];
68
69 int nevts = atoi( argv[2] );
70
71 RawFileReader freader(argv[1]);
72
73 for ( int i = 0; i < nevts; ++i ) {
74 try {
75 uint32_t* dataptr = NULL;
76
77 RawEvent f;
78 f.assign( freader.nextEvent() );
79
80 //if ( i < 43649 ) continue;
81 //if ( i > 43809 ) break;
82 std::cout << i << " >> run: " << f.run_no() << " event: " << f.global_id() << std::endl;
83
84 int nrobs = 0;
85 int nsds = f.children(m_sds, 64);
86 for ( int sdi = 0; sdi < nsds; ++sdi ) {
88 nrobs += eformat::get_robs(m_sds[sdi], m_robs+nrobs, 256-nrobs);
89 }
90 for (int robi = 0; robi < nrobs; robi++) {
91 eformat::ROBFragment<uint32_t*> rob((uint32_t*)m_robs[robi]);
92 uint32_t source_id_number = rob.rod_source_id();
93 source_id_number <<= 8;
94 source_id_number >>= 24;
95
96 /// >>>>>>>>>>>>>>>>>>>
97 if ((rob.rod_detev_type() & 0x2) != 0) {
98 if ( source_id_number == 165 ) {
99 rob.rod_data(dataptr);
100 processETS(dataptr, rob.rod_ndata());
101 break;
102 }
103 }
104 }
105
106 if ( ! dataptr ) {
107 std::cout << "no ETS data found" << std::endl;
108 break;
109 }
110 }
111 catch ( RawFileException& e ) {
112 e.print();
113 break;
114 }
115 catch (std::exception& ex) {
116 std::cerr << std::endl << "Uncaught std exception: " << ex.what() << std::endl;
117 break;
118 }
119 catch (...) {
120 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
121 break;
122 }
123 }
124
125 delete [] m_sds;
126 delete [] m_robs;
127
128 return 0;
129}
unsigned long calEts(const uint32_t *dptr)
Definition: ana_raw.cxx:9
void processETS(const uint32_t *dataPtr, uint32_t dataLen)
Definition: ana_raw.cxx:37
void dump(const uint32_t *data, uint32_t n)
Definition: ana_raw.cxx:21
virtual void print() const
const uint32_t * nextEvent()
void rod_data(TPointer &it) const
Definition: ROBFragment.h:257
uint32_t rod_source_id() const
Definition: ROBFragment.h:115
uint32_t rod_ndata() const
Definition: ROBFragment.h:159
uint32_t rod_detev_type() const
Definition: ROBFragment.h:140
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105
int main()
Definition: test_IFile.cxx:11