1#include "Identifier/MdcID.h"
2#include "RawDataCnv/Util/MdcConverter.h"
8 if ( s_instance == 0 ) {
17 if ( s_instance != 0 ) {
28 memset((
void*)m_mdcTag, 0, 16384*4*4);
34 uint32_t TEId, REId, TEData, TEOverflow, TETorQ;
36 typedef pair<uint32_t, uint32_t> PairII;
37 vector<uint32_t> vHits;
43 uint32_t nbuf = src.
nBuf();
45 for (uint32_t i = 0; i < nbuf; ++i)
47 uint32_t* buf = src(i);
48 uint32_t* bufend= buf + src.
bufSize(i);
49 for ( ; buf < bufend; ++buf )
52 if (((digi>>18) & 0x3FFF) == 0) {
57 m_builder.
unPack(digi, REId, TEData, TEOverflow, TETorQ);
59 TEId = m_builder.
getTEID( REId );
60 if ( TEId == 0xFFFFFFFF )
continue;
62 curTag = m_mdcTag[REId];
64 if ( curTag[0] == 0 ) {
65 curTag[1] = 0x7FFFFFFF;
66 curTag[2] = 0x7FFFFFFF;
72 if ( m_runId >= m_runFrom && m_runId <= m_runTo ) {
73 if (layer == 20 && wire >= 0 && wire <= 7){
74 TEId = 268456960 + wire;
77 else if (layer == 42 && wire >= 0 && wire <= 7){
78 TEId = 268478464 + wire;
81 else if (layer == 40 && wire >= 200 && wire <= 207){
85 else if (layer == 40 && wire >= 208 && wire <= 215){
91 curTag[0] = (TEId << 2);
93 vHits.push_back( REId );
97 if ( (curTag[0]&1) == 0 ) {
100 curTag[3] |= TEOverflow;
104 if ( TEData >= curTag[1] ) {
105 if ( TEOverflow ) TEData |= (1<<31);
106 vmTDC.push_back( make_pair(REId, TEData) );
109 if ( curTag[3] & 1 ) curTag[1] |= (1<<31);
110 vmTDC.push_back( make_pair(REId, curTag[1]) );
112 curTag[3] &= (0xFFFFFFFF-1);
113 curTag[3] |= TEOverflow;
120 if ( TEOverflow ) curTag[3] |= 2;
126 if ( m_runMode == 1 ) {
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;
134 des->push_back(mdcDigi);
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)) ) {
147 des->push_back(mdcDigi);
153 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
154 curTag = m_mdcTag[it->first];
155 uint32_t
data = it->second;
158 des->push_back(mdcDigi);
161 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
162 curTag = m_mdcTag[*it];
165 des->push_back(mdcDigi);
171 return StatusCode::SUCCESS;
176 return m_builder.
pack(src, des);
179MdcConverter::MdcConverter(
int runMode)
180 : m_runMode( runMode )
184MdcConverter::~MdcConverter()
ObjectVector< MdcDigi > MdcDigiCol
uint32_t bufSize(int i) const
virtual uint32_t getTEID(uint32_t reid)
virtual StatusCode pack(MdcDigiCol *digiCol, WriteRawEvent *&re)
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
static MdcConverter * instance(int runMode=2)
void init(int runFrom, int runTo)
StatusCode convert(const BufferHolder &src, MdcDigiCol *des)
void setOverflow(const unsigned int overflow)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)