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

#include <MdcConverter.h>

Public Member Functions

void init (int runFrom, int runTo)
 
void setRunId (int runId)
 
StatusCode convert (const BufferHolder &src, MdcDigiCol *des)
 
StatusCode convert (MdcDigiCol *src, WriteRawEvent *&des)
 
void init (int runFrom, int runTo)
 
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 ()
 
static MdcConverterinstance (int runMode=2)
 
static void destroy ()
 

Detailed Description

Member Function Documentation

◆ convert() [1/4]

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

Definition at line 31 of file MdcConverter.cxx.

32{
33 //int digiId = 0;
34 uint32_t TEId, REId, TEData, TEOverflow, TETorQ;
35
36 typedef pair<uint32_t, uint32_t> PairII;
37 vector<uint32_t> vHits;
38 vector<PairII> vmTDC;
39
40 uint32_t* curTag;
41 ////////////////////////////////////
42
43 uint32_t nbuf = src.nBuf();
44
45 for (uint32_t i = 0; i < nbuf; ++i)
46 {
47 uint32_t* buf = src(i);
48 uint32_t* bufend= buf + src.bufSize(i);
49 for ( ; buf < bufend; ++buf /*, ++digiId*/)
50 {
51 uint32_t digi = *buf;
52 if (((digi>>18) & 0x3FFF) == 0) {
53 //digiId--;
54 continue;
55 }
56
57 m_builder.unPack(digi, REId, TEData, TEOverflow, TETorQ);
58
59 TEId = m_builder.getTEID( REId );
60 if ( TEId == 0xFFFFFFFF ) continue;
61
62 curTag = m_mdcTag[REId];
63
64 if ( curTag[0] == 0 ) { //1st signal from detector-unit-REId
65 curTag[1] = 0x7FFFFFFF;
66 curTag[2] = 0x7FFFFFFF;
67 curTag[3] = 0;
68
69 int layer = MdcID::layer(Identifier(TEId));
70 int wire = MdcID::wire(Identifier(TEId));
71 //yzhang exchange pre-amplifier
72 if ( m_runId >= m_runFrom && m_runId <= m_runTo ) {
73 if (layer == 20 && wire >= 0 && wire <= 7){
74 TEId = 268456960 + wire;
75 curTag[3] |= 0x10; //16
76 }
77 else if (layer == 42 && wire >= 0 && wire <= 7){
78 TEId = 268478464 + wire;
79 curTag[3] |= 0x10; //16
80 }
81 else if (layer == 40 && wire >= 200 && wire <= 207){
82 TEId += 8;
83 curTag[3] |= 0x10; //16
84 }
85 else if (layer == 40 && wire >= 208 && wire <= 215){
86 TEId -= 8;
87 curTag[3] |= 0x10; //16
88 }
89 }
90
91 curTag[0] = (TEId << 2);
92
93 vHits.push_back( REId );
94 }
95
96 if ( TETorQ == 0 ) { //T
97 if ( (curTag[0]&1) == 0 ) { //1st-found-T
98 curTag[0] |= 1;
99 curTag[1] = TEData;
100 curTag[3] |= TEOverflow; //0 or 1
101 }
102 else { //multi-T
103 curTag[3] |= 0xC; //12, set the multi-T and 1st-T bits
104 if ( TEData >= curTag[1] ) {
105 if ( TEOverflow ) TEData |= (1<<31); //LastBit
106 vmTDC.push_back( make_pair(REId, TEData) );
107 }
108 else {
109 if ( curTag[3] & 1 ) curTag[1] |= (1<<31);
110 vmTDC.push_back( make_pair(REId, curTag[1]) );
111 curTag[1] = TEData;
112 curTag[3] &= (0xFFFFFFFF-1);
113 curTag[3] |= TEOverflow;
114 }
115 }
116 }
117 else { //Q
118 curTag[0] |= 2;
119 curTag[2] = TEData;
120 if ( TEOverflow ) curTag[3] |= 2;
121 }
122 }
123 }
124
125 MdcDigi* mdcDigi;
126 if ( m_runMode == 1 ) { //OnlineMode, discard the hits that only have T or Q
127 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
128 curTag = m_mdcTag[it->first];
129 if ( (curTag[0]&3) == 3 ) {
130 uint32_t data = it->second;
131 if(data>>31) continue;
132 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
133 mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
134 des->push_back(mdcDigi);
135 }
136 }
137
138 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
139 curTag = m_mdcTag[*it];
140 if ( (curTag[0]&3) == 3 ) {
141 if( ((curTag[3]&3)>0) || (((curTag[3]&12)!=12) && ((curTag[3]&12)!=0)) ) {
142 curTag[0] = 0;
143 continue;
144 }
145 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
146 mdcDigi->setOverflow(curTag[3]);
147 des->push_back(mdcDigi);
148 }
149 curTag[0] = 0;
150 }
151 }
152 else { //Not OnlineMode, keep all the hits found
153 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
154 curTag = m_mdcTag[it->first];
155 uint32_t data = it->second;
156 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), (data&0x7FFFFFFF), curTag[2]);
157 mdcDigi->setOverflow( (curTag[3] & 0x16) | (data>>31) );
158 des->push_back(mdcDigi);
159 }
160
161 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
162 curTag = m_mdcTag[*it];
163 mdcDigi = new MdcDigi(Identifier(curTag[0]>>2), curTag[1], curTag[2]);
164 mdcDigi->setOverflow(curTag[3]);
165 des->push_back(mdcDigi);
166 curTag[0] = 0;
167 }
168 }
169
170 ////////////////////////////////////
171 return StatusCode::SUCCESS;
172}
TTree * data
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
Definition: MdcBuilder.cxx:22
void setOverflow(const unsigned int overflow)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54

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

◆ convert() [2/4]

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

◆ convert() [3/4]

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

Definition at line 174 of file MdcConverter.cxx.

175{
176 return m_builder.pack(src, des);
177}
virtual StatusCode pack(MdcDigiCol *digiCol, WriteRawEvent *&re)
Definition: MdcBuilder.cxx:35

◆ convert() [4/4]

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

◆ destroy() [1/2]

void MdcConverter::destroy ( )
static

Definition at line 15 of file MdcConverter.cxx.

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

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

◆ destroy() [2/2]

static void MdcConverter::destroy ( )
static

◆ init() [1/2]

void MdcConverter::init ( int  runFrom,
int  runTo 
)

Definition at line 23 of file MdcConverter.cxx.

24{
25 m_runFrom = runFrom;
26 m_runTo = runTo;
27
28 memset((void*)m_mdcTag, 0, 16384*4*4);
29}

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

◆ init() [2/2]

void MdcConverter::init ( int  runFrom,
int  runTo 
)

◆ instance() [1/2]

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

Definition at line 6 of file MdcConverter.cxx.

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

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

◆ instance() [2/2]

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

◆ setRunId() [1/2]

void MdcConverter::setRunId ( int  runId)
inline

◆ setRunId() [2/2]

void MdcConverter::setRunId ( int  runId)
inline

Definition at line 19 of file InstallArea/include/RawDataCnv/RawDataCnv/Util/MdcConverter.h.

19{ m_runId = runId; }

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