CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
TofConverter.cxx
Go to the documentation of this file.
1#include "RawDataCnv/Util/TofConverter.h"
2
3TofConverter* TofConverter::s_instance = 0;
4
6{
7 if ( s_instance == 0 ) {
8 s_instance = new TofConverter();
9 }
10
11 return s_instance;
12}
13
15{
16 if ( s_instance != 0 ) {
17 delete s_instance;
18 s_instance = 0;
19 }
20}
21
22StatusCode TofConverter::convert(const BufferHolder& src, TofDigiCol* des, LumiDigiCol* des2)
23{
24 uint32_t REId, TEId, TEData, TEOverflow, TETorQ;
25 uint32_t nbuf = src.nBuf();
26
27 TofDigi* tofDigi;
28 typedef std::multimap<uint32_t, TofDigi*>::iterator my_iter;
29 std::multimap<uint32_t, TofDigi*> mapIdData;
30 my_iter it;
31
32 for (uint32_t i = 0; i < nbuf; ++i) {
33 uint32_t* buf = src(i);
34 uint32_t bufSize = src.bufSize(i);
35 for (uint32_t j = 0; j < bufSize; ++j) {
36 m_builder.unPack(buf[j], REId, TEData, TEOverflow, TETorQ);
37 TEId = m_builder.getTEID( REId);
38 if ( TEId == 0xFFFFFFFF ) {
39 uint32_t data_unit = buf[j];
40 if ( (data_unit >> 25) == 0x7F ) {
41 tofDigi = new TofDigi(Identifier(0xFFFFFFFF), 0x7FFFFFFF, 0x7FFFFFFF);
42 tofDigi->setOverflow(data_unit);
43 des->push_back(tofDigi);
44 }
45 continue;
46 }
47
48 uint32_t count = mapIdData.count(TEId);
49
50 if (count == 0) {
51 if (TETorQ) { //Q
52 tofDigi = new TofDigi(Identifier(TEId), 0x7FFFFFFF, TEData);
53 tofDigi->setOverflow(0x10 | (TEOverflow<<1));
54 }
55 else { //T
56 tofDigi = new TofDigi(Identifier(TEId), TEData, 0x7FFFFFFF);
57 tofDigi->setOverflow(0x20 | TEOverflow);
58 }
59 mapIdData.insert(make_pair(TEId, tofDigi));
60 }
61 else {
62 pair<my_iter, my_iter> range = mapIdData.equal_range(TEId);
63 it = range.first;
64 tofDigi = it->second;
65 if (TETorQ) { //Q
66 if (tofDigi->getChargeChannel() == 0x7FFFFFFF) { //matched Q and T, first Q
67 tofDigi->setChargeChannel(TEData);
68 tofDigi->setOverflow((tofDigi->getOverflow() | (TEOverflow<<1)) & 0xF);
69 while ((++it) != range.second) { //multiT
70 tofDigi = it->second;
71 tofDigi->setOverflow(tofDigi->getOverflow() & 0xF);
72 }
73 }
74 else { //multiQ
75 uint32_t flag = (tofDigi->getOverflow() & 0x3C) | 8;
76 while (it != range.second) {
77 tofDigi = (it++)->second;
78 tofDigi->setOverflow((tofDigi->getOverflow()&0x3) | flag);
79 }
80 tofDigi = new TofDigi(Identifier(TEId), 0x7FFFFFFF, TEData);
81 tofDigi->setOverflow(flag | (TEOverflow<<1));
82 mapIdData.insert(make_pair(TEId, tofDigi));
83 }
84 }
85 else { //T
86 if (tofDigi->getTimeChannel() == 0x7FFFFFFF) { //matched T and Q, firstT
87 tofDigi->setTimeChannel(TEData);
88 tofDigi->setOverflow((tofDigi->getOverflow() | TEOverflow) & 0xF);
89 while ((++it) != range.second) { //multiQ
90 tofDigi = it->second;
91 tofDigi->setOverflow(tofDigi->getOverflow() & 0xF);
92 }
93 }
94 else { //multiT
95 uint32_t flag = (tofDigi->getOverflow() & 0x3C) | 4;
96 while (it != range.second) {
97 tofDigi = (it++)->second;
98 tofDigi->setOverflow((tofDigi->getOverflow()&0x3) | flag);
99 }
100 tofDigi = new TofDigi(Identifier(TEId), TEData, 0x7FFFFFFF);
101 tofDigi->setOverflow(flag | TEOverflow);
102 mapIdData.insert(make_pair(TEId, tofDigi));
103 }
104 }
105 }
106 }
107 }
108
109 my_iter end = mapIdData.end();
110 for (it = mapIdData.begin(); it != end; ++it) {
111 TEId = it->first;
112 tofDigi = it->second;
113 if ( (TEId&0xFFFF7FFF) != 0x20000060 ) {
114 des->push_back(tofDigi);
115 }
116 //zoujh: for luminosity
117 else {
118 if (des2 != 0) {
119 des2->push_back(new LumiDigi(tofDigi));
120 }
121 delete tofDigi;
122 }
123 }
124
125 return StatusCode::SUCCESS;
126}
127
129{
130 return m_builder.pack(src, des);
131}
132
133TofConverter::TofConverter()
134{
135}
136
137TofConverter::~TofConverter()
138{
139}
ObjectVector< LumiDigi > LumiDigiCol
ObjectVector< TofDigi > TofDigiCol
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
unsigned int getChargeChannel() const
Definition: RawData.cxx:45
void setTimeChannel(const unsigned int timeChannel)
Definition: RawData.cxx:25
unsigned int getTimeChannel() const
Definition: RawData.cxx:40
virtual StatusCode pack(TofDigiCol *digiCol, WriteRawEvent *&re)
Definition: TofBuilder.cxx:38
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
Definition: TofBuilder.cxx:22
static void destroy()
StatusCode convert(const BufferHolder &src, TofDigiCol *des, LumiDigiCol *des2=0)
static TofConverter * instance()
Definition: TofConverter.cxx:5
void setOverflow(const unsigned int overflow)