BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcConverter Class Reference

#include <MdcConverter.h>

Public Member Functions

void init (const SniperJSON &config)
 
void setRunId (int runId)
 
StatusCode convert (const BufferHolder &src, MdcDigiCol *des)
 
StatusCode convert (MdcDigiCol *src, WriteRawEvent *&des)
 

Static Public Member Functions

static MdcConverterinstance (int runMode=2)
 
static void destroy ()
 

Detailed Description

Definition at line 11 of file MdcConverter.h.

Member Function Documentation

◆ convert() [1/2]

StatusCode MdcConverter::convert ( const BufferHolder & src,
MdcDigiCol * des )

Definition at line 41 of file MdcConverter.cxx.

42{
43 //int digiId = 0;
44 uint32_t TEId, REId, TEData, TEOverflow, TETorQ;
45
46 typedef pair<uint32_t, uint32_t> PairII;
47 vector<uint32_t> vHits;
48 vector<PairII> vmTDC;
49
50 uint32_t* curTag;
51 ////////////////////////////////////
52
53 uint32_t nbuf = src.nBuf();
54
55 for (uint32_t i = 0; i < nbuf; ++i)
56 {
57 uint32_t* buf = src(i);
58 uint32_t* bufend= buf + src.bufSize(i);
59 for ( ; buf < bufend; ++buf /*, ++digiId*/)
60 {
61 uint32_t digi = *buf;
62 if (((digi>>18) & 0x3FFF) == 0) {
63 //digiId--;
64 continue;
65 }
66
67 m_builder.unPack(digi, REId, TEData, TEOverflow, TETorQ);
68
69 TEId = m_builder.getTEID( REId );
70 if ( TEId == 0xFFFFFFFF ) continue;
71
72 curTag = m_mdcTag[REId];
73
74 if ( curTag[0] == 0 ) { //1st signal from detector-unit-REId
75 curTag[1] = 0x7FFFFFFF;
76 curTag[2] = 0x7FFFFFFF;
77 curTag[3] = 0;
78
79 //uint32_t oTEId = TEId;
80
81 for ( std::vector<IdFixRule>::iterator it = m_idFixRules.begin(); it != m_idFixRules.end(); ++it ) {
82 IdFixRule& rule = (*it);
83 if ( m_runId >= rule.run_from && m_runId <= rule.run_to ) {
84 if ((TEId&rule.mask) == rule.value1) {
85 TEId = (TEId&rule.reverse_mask) | rule.value2;
86 curTag[3] |= 0x10;
87 }
88 else if ((TEId&rule.mask) == rule.value2) {
89 TEId = (TEId&rule.reverse_mask) | rule.value1;
90 curTag[3] |= 0x10;
91 }
92 }
93 }
94
95 //if ( curTag[3] != 0 ) {
96 // std::cout << " From TEId 0x" << std::hex << oTEId << std::dec
97 // << " : " << MdcID::layer(Identifier(oTEId)) << " " << MdcID::wire(Identifier(oTEId))
98 // << std::endl;
99 // std::cout << " To TEId 0x" << std::hex << TEId << std::dec
100 // << " : " << MdcID::layer(Identifier(TEId)) << " " << MdcID::wire(Identifier(TEId))
101 // << std::endl;
102 //}
103
104 curTag[0] = (TEId << 2);
105
106 vHits.push_back( REId );
107 }
108
109 if ( TETorQ == 0 ) { //T
110 if ( (curTag[0]&1) == 0 ) { //1st-found-T
111 curTag[0] |= 1;
112 curTag[1] = TEData;
113 curTag[3] |= TEOverflow; //0 or 1
114 }
115 else { //multi-T
116 curTag[3] |= 0xC; //12, set the multi-T and 1st-T bits
117 if ( TEData >= curTag[1] ) {
118 if ( TEOverflow ) TEData |= (1<<31); //LastBit
119 vmTDC.push_back( make_pair(REId, TEData) );
120 }
121 else {
122 if ( curTag[3] & 1 ) curTag[1] |= (1<<31);
123 vmTDC.push_back( make_pair(REId, curTag[1]) );
124 curTag[1] = TEData;
125 curTag[3] &= (0xFFFFFFFF-1);
126 curTag[3] |= TEOverflow;
127 }
128 }
129 }
130 else { //Q
131 curTag[0] |= 2;
132 curTag[2] = TEData;
133 if ( TEOverflow ) curTag[3] |= 2;
134 }
135 }
136 }
137
138 MdcDigi* mdcDigi;
139 if ( m_runMode == 1 ) { //OnlineMode, discard the hits that only have T or Q
140 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
141 curTag = m_mdcTag[it->first];
142 if ( (curTag[0]&3) == 3 ) {
143 uint32_t data = it->second;
144 if(data>>31) continue;
145 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
146 mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
147 des->push_back(mdcDigi);
148 }
149 }
150
151 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
152 curTag = m_mdcTag[*it];
153 if ( (curTag[0]&3) == 3 ) {
154 if( ((curTag[3]&3)>0) || (((curTag[3]&12)!=12) && ((curTag[3]&12)!=0)) ) {
155 curTag[0] = 0;
156 continue;
157 }
158 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
159 mdcDigi->setOverflow(curTag[3]);
160 des->push_back(mdcDigi);
161 }
162 curTag[0] = 0;
163 }
164 }
165 else { //Not OnlineMode, keep all the hits found
166 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
167 curTag = m_mdcTag[it->first];
168 uint32_t data = it->second;
169 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
170 mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
171 des->push_back(mdcDigi);
172 }
173
174 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
175 curTag = m_mdcTag[*it];
176 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
177 mdcDigi->setOverflow(curTag[3]);
178 des->push_back(mdcDigi);
179 curTag[0] = 0;
180 }
181 }
182
183 ////////////////////////////////////
184 return StatusCode::SUCCESS;
185}
TTree * data
uint32_t nBuf() const
uint32_t bufSize(int i) const
virtual uint32_t getTEID(uint32_t reid)
Definition MdcBuilder.h:16
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
void setOverflow(const unsigned int overflow)
Definition MdcDigi.h:23

Referenced by RawDataMdcDigiCnv::createObj(), RawDataMdcDigiCnv::createRep(), MixerAlg::decodeMdc(), and RawEventReader::execute().

◆ convert() [2/2]

StatusCode MdcConverter::convert ( MdcDigiCol * src,
WriteRawEvent *& des )

Definition at line 187 of file MdcConverter.cxx.

188{
189 return m_builder.pack(src, des);
190}
virtual StatusCode pack(MdcDigiCol *digiCol, WriteRawEvent *&re)

◆ destroy()

void MdcConverter::destroy ( )
static

Definition at line 16 of file MdcConverter.cxx.

17{
18 if ( s_instance != 0 ) {
19 delete s_instance;
20 s_instance = 0;
21 }
22}

Referenced by RawDataMdcDigiCnv::~RawDataMdcDigiCnv(), and RawEventReader::~RawEventReader().

◆ init()

void MdcConverter::init ( const SniperJSON & config)

Definition at line 24 of file MdcConverter.cxx.

25{
26 for ( SniperJSON::vec_iterator it = config.vec_begin(); it != config.vec_end(); ++it )
27 {
28 IdFixRule rule;
29 rule.run_from = (*it)["RunFrom"].get<int>();
30 rule.run_to = (*it)["RunTo"].get<int>();
31 rule.mask = (*it)["Mask"].get<uint32_t>();
32 rule.reverse_mask = ~rule.mask;
33 rule.value1 = (*it)["Value1"].get<uint32_t>();
34 rule.value2 = (*it)["Value2"].get<uint32_t>();
35 m_idFixRules.push_back(rule);
36 }
37
38 memset((void*)m_mdcTag, 0, 16384*4*4);
39}
std::vector< SniperJSON >::const_iterator vec_iterator
Definition SniperJSON.h:11
vec_iterator vec_end() const
Definition SniperJSON.h:52
vec_iterator vec_begin() const
Definition SniperJSON.h:50

Referenced by MixerAlg::initialize(), RawDataMdcDigiCnv::initialize(), and RawEventReader::initialize().

◆ instance()

MdcConverter * MdcConverter::instance ( int runMode = 2)
static

Definition at line 7 of file MdcConverter.cxx.

8{
9 if ( s_instance == 0 ) {
10 s_instance = new MdcConverter(runMode);
11 }
12
13 return s_instance;
14}

Referenced by RawDataMdcDigiCnv::initialize(), MixerAlg::MixerAlg(), and RawEventReader::RawEventReader().

◆ setRunId()

void MdcConverter::setRunId ( int runId)
inline

Definition at line 21 of file MdcConverter.h.

21{ m_runId = runId; }

Referenced by RawDataMdcDigiCnv::createObj(), and MixerAlg::execute().


The documentation for this class was generated from the following files: