9 if ( s_instance == 0 ) {
18 if ( s_instance != 0 ) {
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);
38 memset((
void*)m_mdcTag, 0, 16384*4*4);
44 uint32_t TEId, REId, TEData, TEOverflow, TETorQ;
46 typedef pair<uint32_t, uint32_t> PairII;
47 vector<uint32_t> vHits;
53 uint32_t nbuf = src.
nBuf();
55 for (uint32_t i = 0; i < nbuf; ++i)
57 uint32_t* buf = src(i);
58 uint32_t* bufend= buf + src.
bufSize(i);
59 for ( ; buf < bufend; ++buf )
62 if (((digi>>18) & 0x3FFF) == 0) {
67 m_builder.
unPack(digi, REId, TEData, TEOverflow, TETorQ);
69 TEId = m_builder.
getTEID( REId );
70 if ( TEId == 0xFFFFFFFF )
continue;
72 curTag = m_mdcTag[REId];
74 if ( curTag[0] == 0 ) {
75 curTag[1] = 0x7FFFFFFF;
76 curTag[2] = 0x7FFFFFFF;
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;
88 else if ((TEId&rule.mask) == rule.value2) {
89 TEId = (TEId&rule.reverse_mask) | rule.value1;
104 curTag[0] = (TEId << 2);
106 vHits.push_back( REId );
110 if ( (curTag[0]&1) == 0 ) {
113 curTag[3] |= TEOverflow;
117 if ( TEData >= curTag[1] ) {
118 if ( TEOverflow ) TEData |= (1<<31);
119 vmTDC.push_back( make_pair(REId, TEData) );
122 if ( curTag[3] & 1 ) curTag[1] |= (1<<31);
123 vmTDC.push_back( make_pair(REId, curTag[1]) );
125 curTag[3] &= (0xFFFFFFFF-1);
126 curTag[3] |= TEOverflow;
133 if ( TEOverflow ) curTag[3] |= 2;
139 if ( m_runMode == 1 ) {
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;
147 des->push_back(mdcDigi);
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)) ) {
160 des->push_back(mdcDigi);
166 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
167 curTag = m_mdcTag[it->first];
168 uint32_t
data = it->second;
171 des->push_back(mdcDigi);
174 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
175 curTag = m_mdcTag[*it];
178 des->push_back(mdcDigi);
184 return StatusCode::SUCCESS;
189 return m_builder.
pack(src, des);
192MdcConverter::MdcConverter(
int runMode)
193 : m_runMode( runMode )
197MdcConverter::~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)
StatusCode convert(const BufferHolder &src, MdcDigiCol *des)
void init(const SniperJSON &config)
void setOverflow(const unsigned int overflow)
std::vector< SniperJSON >::const_iterator vec_iterator
vec_iterator vec_end() const
vec_iterator vec_begin() const