42{
43
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 )
60 {
61 uint32_t digi = *buf;
62 if (((digi>>18) & 0x3FFF) == 0) {
63
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 ) {
75 curTag[1] = 0x7FFFFFFF;
76 curTag[2] = 0x7FFFFFFF;
77 curTag[3] = 0;
78
79
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
96
97
98
99
100
101
102
103
104 curTag[0] = (TEId << 2);
105
106 vHits.push_back( REId );
107 }
108
109 if ( TETorQ == 0 ) {
110 if ( (curTag[0]&1) == 0 ) {
111 curTag[0] |= 1;
112 curTag[1] = TEData;
113 curTag[3] |= TEOverflow;
114 }
115 else {
116 curTag[3] |= 0xC;
117 if ( TEData >= curTag[1] ) {
118 if ( TEOverflow ) TEData |= (1<<31);
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 {
131 curTag[0] |= 2;
132 curTag[2] = TEData;
133 if ( TEOverflow ) curTag[3] |= 2;
134 }
135 }
136 }
137
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);
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 }
160 des->push_back(mdcDigi);
161 }
162 curTag[0] = 0;
163 }
164 }
165 else {
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);
172 }
173
174 for ( vector<uint32_t>::iterator it = vHits.begin(); it != vHits.end(); ++it) {
175 curTag = m_mdcTag[*it];
178 des->push_back(mdcDigi);
179 curTag[0] = 0;
180 }
181 }
182
183
184 return StatusCode::SUCCESS;
185}
uint32_t bufSize(int i) const
virtual uint32_t getTEID(uint32_t reid)
virtual void unPack(uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
void setOverflow(const unsigned int overflow)