32{
33
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 )
50 {
51 uint32_t digi = *buf;
52 if (((digi>>18) & 0x3FFF) == 0) {
53
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 ) {
65 curTag[1] = 0x7FFFFFFF;
66 curTag[2] = 0x7FFFFFFF;
67 curTag[3] = 0;
68
71
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;
76 }
77 else if (layer == 42 && wire >= 0 && wire <= 7){
78 TEId = 268478464 + wire;
79 curTag[3] |= 0x10;
80 }
81 else if (layer == 40 && wire >= 200 && wire <= 207){
82 TEId += 8;
83 curTag[3] |= 0x10;
84 }
85 else if (layer == 40 && wire >= 208 && wire <= 215){
86 TEId -= 8;
87 curTag[3] |= 0x10;
88 }
89 }
90
91 curTag[0] = (TEId << 2);
92
93 vHits.push_back( REId );
94 }
95
96 if ( TETorQ == 0 ) {
97 if ( (curTag[0]&1) == 0 ) {
98 curTag[0] |= 1;
99 curTag[1] = TEData;
100 curTag[3] |= TEOverflow;
101 }
102 else {
103 curTag[3] |= 0xC;
104 if ( TEData >= curTag[1] ) {
105 if ( TEOverflow ) TEData |= (1<<31);
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 {
118 curTag[0] |= 2;
119 curTag[2] = TEData;
120 if ( TEOverflow ) curTag[3] |= 2;
121 }
122 }
123 }
124
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;
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 }
147 des->push_back(mdcDigi);
148 }
149 curTag[0] = 0;
150 }
151 }
152 else {
153 for ( vector<PairII>::iterator it = vmTDC.begin(); it != vmTDC.end(); ++it ) {
154 curTag = m_mdcTag[it->first];
155 uint32_t data = it->second;
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];
165 des->push_back(mdcDigi);
166 curTag[0] = 0;
167 }
168 }
169
170
171 return StatusCode::SUCCESS;
172}
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)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)