#include <EventFilter/DTTFRawToDigi/interface/DTTFFEDSim.h>
Public Member Functions | |
DTTFFEDSim (const edm::ParameterSet &pset) | |
Constructor. | |
bool | fillRawData (edm::Event &e, FEDRawDataCollection &data) |
Generate and fill FED raw data for a full event. | |
void | produce (edm::Event &e, const edm::EventSetup &c) |
Produce digis out of raw data. | |
virtual | ~DTTFFEDSim () |
Destructor. | |
Private Member Functions | |
int | bxNr (int channel) |
void | calcCRC (long myD1, long myD2, int &myC) |
int | channel (int wheel, int sector, int bx) |
edm::InputTag | getDTDigiInputTag () |
edm::InputTag | getDTPHTFInputTag () |
int | sector (int channel) |
int | wheel (int channel) |
Private Attributes | |
edm::InputTag | DTDigiInputTag |
edm::InputTag | DTPHTFInputTag |
unsigned int | eventNum |
J. Troconiz UAM Madrid
Definition at line 26 of file DTTFFEDSim.h.
DTTFFEDSim::DTTFFEDSim | ( | const edm::ParameterSet & | pset | ) |
Constructor.
Definition at line 30 of file DTTFFEDSim.cc.
References DTDigiInputTag, DTPHTFInputTag, and edm::ParameterSet::getParameter().
00030 : eventNum(0) { 00031 00032 produces<FEDRawDataCollection>(); 00033 00034 DTDigiInputTag = pset.getParameter<edm::InputTag>("DTDigi_Source"); 00035 DTPHTFInputTag = pset.getParameter<edm::InputTag>("DTTracks_Source"); 00036 00037 }
DTTFFEDSim::~DTTFFEDSim | ( | ) | [virtual] |
Definition at line 285 of file DTTFFEDSim.cc.
00285 { 00286 00287 int myChannel = channel; 00288 00289 if (myChannel > 127) myChannel -= 2; 00290 00291 if (myChannel < 0 || myChannel > 251 ){ return -999; } 00292 00293 int myBx = 1-(myChannel%3); 00294 00295 return myBx; 00296 }
Definition at line 322 of file DTTFFEDSim.cc.
References funct::C, funct::D, and i.
Referenced by fillRawData().
00322 { 00323 00324 int myCRC[16],D[64],C[16]; 00325 00326 for( int i=0; i < 32; i++ ){ D[i]=(myD2>>i)&0x1; } 00327 for( int i=0; i < 32; i++ ){ D[i+32]=(myD1>>i)&0x1; } 00328 for( int i=0; i < 16; i++ ){ C[i]=(myC>>i)&0x1; } 00329 00330 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] + 00331 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] + 00332 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] + 00333 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] + 00334 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] + 00335 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] + 00336 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] + 00337 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] + 00338 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] + 00339 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] + 00340 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] + 00341 C[15] )%2; 00342 00343 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] + 00344 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] + 00345 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] + 00346 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] + 00347 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] + 00348 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] + 00349 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] + 00350 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] + 00351 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] + 00352 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] + 00353 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2; 00354 00355 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] + 00356 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] + 00357 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2; 00358 00359 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] + 00360 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] + 00361 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2; 00362 00363 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] + 00364 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] + 00365 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] + 00366 C[15] )%2; 00367 00368 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] + 00369 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] + 00370 D[3] + C[1] + C[11] + C[12] + C[15] )%2; 00371 00372 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] + 00373 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] + 00374 C[2] + C[12] + C[13] )%2; 00375 00376 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] + 00377 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] + 00378 C[3] + C[13] + C[14] )%2; 00379 00380 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] + 00381 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] + 00382 C[0] + C[4] + C[14] + C[15] )%2; 00383 00384 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] + 00385 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] + 00386 C[5] + C[15] )%2; 00387 00388 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] + 00389 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2; 00390 00391 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] + 00392 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2; 00393 00394 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] + 00395 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2; 00396 00397 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] + 00398 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2; 00399 00400 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] + 00401 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2; 00402 00403 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] + 00404 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] + 00405 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] + 00406 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] + 00407 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] + 00408 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] + 00409 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] + 00410 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] + 00411 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] + 00412 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] + 00413 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] + 00414 C[15] )%2; 00415 00416 int tempC = 0x0; 00417 for(int i=0; i<16 ; i++){ tempC = tempC + (myCRC[i]<<i); } 00418 myC = tempC ; 00419 return; 00420 }
Definition at line 265 of file DTTFFEDSim.cc.
References funct::abs().
Referenced by fillRawData().
00265 { 00266 00267 // wheel : -3 -2 -1 +1 +2 +3 <=> PHTF's : N2, N1, N0, P0, P1, P2 00268 // 0 <=> ETTF 00269 // sector : 0 -> 11 00270 // bx : -1 -> +1 00271 00272 int myChannel = 255; 00273 00274 if ( abs(bx) > 1) { return myChannel; } 00275 if ( sector < 0 || sector > 11) { return myChannel; } 00276 if ( abs(wheel) > 3) { return myChannel; } 00277 00278 myChannel = sector*21 + wheel*3 - bx + 10 ; 00279 00280 if (myChannel > 125) myChannel += 2; 00281 00282 return myChannel; 00283 }
bool DTTFFEDSim::fillRawData | ( | edm::Event & | e, | |
FEDRawDataCollection & | data | |||
) |
Generate and fill FED raw data for a full event.
Definition at line 53 of file DTTFFEDSim.cc.
References bti, calcCRC(), channel(), FEDRawData::data(), eventNum, FEDRawDataCollection::FEDData(), edm::Event::getByLabel(), getDTDigiInputTag(), getDTPHTFInputTag(), and FEDRawData::resize().
Referenced by produce().
00054 { 00055 00056 eventNum++; 00057 00058 int lines = 2; 00059 00060 edm::Handle<L1MuDTChambPhContainer> phtrig; 00061 e.getByLabel(getDTDigiInputTag(),phtrig); 00062 lines += phtrig->bxSize(-1, 1); 00063 00064 edm::Handle<L1MuDTChambThContainer> thtrig; 00065 e.getByLabel(getDTDigiInputTag(),thtrig); 00066 lines += thtrig->bxSize(-1, 1); 00067 00068 edm::Handle<L1MuDTTrackContainer> trtrig; 00069 e.getByLabel(getDTPHTFInputTag(),trtrig); 00070 lines += trtrig->bxSize(-1, 1)*3; 00071 00072 FEDRawData& dttfdata = data.FEDData(0x30C); 00073 dttfdata.resize(lines*8); // size in bytes 00074 unsigned char* LineFED=dttfdata.data(); 00075 00076 long* dataWord1 = new long; 00077 long* dataWord2 = new long; 00078 00079 //--> Header 00080 00081 *dataWord1 = 0x50000000 00082 + (eventNum&0xFFFFFF); 00083 *dataWord2 = 0x00030C00; 00084 00085 int newCRC = 0xFFFF; 00086 calcCRC(*dataWord1, *dataWord2, newCRC); 00087 *((long*)LineFED)=*dataWord2; 00088 LineFED+=4; 00089 *((long*)LineFED)=*dataWord1; 00090 00091 //--> DTTF data 00092 00093 int TS1Id[4], TS2Id[4]; // word identifier for TS #1,#2 for stations 00094 TS1Id[0] = 0x0E; 00095 TS2Id[0] = 0x1E; 00096 TS1Id[1] = 0x2E; 00097 TS2Id[1] = 0x3E; 00098 TS1Id[3] = 0x4E; 00099 TS2Id[3] = 0x5E; 00100 TS1Id[2] = 0x8FFF8; 00101 TS2Id[2] = 0x9FFF8; 00102 00103 //Input 00104 L1MuDTChambPhContainer::Phi_iterator tsphi; 00105 00106 for ( tsphi = phtrig->getContainer()->begin(); 00107 tsphi != phtrig->getContainer()->end(); 00108 tsphi++ ) { 00109 if ( tsphi->code() != 7 ) { 00110 00111 int wheelID = tsphi->whNum()+1; 00112 if ( wheelID <= 0 ) wheelID -= 2; 00113 int stationID = tsphi->stNum()-1; 00114 int is2nd = tsphi->Ts2Tag(); 00115 00116 int channelNr = channel(wheelID, tsphi->scNum(), tsphi->bxNum()-is2nd); 00117 if ( channelNr == 255 ) continue; 00118 int TSId = ( is2nd == 0 ) ? TS1Id[stationID] : TS2Id[stationID]; 00119 00120 *dataWord1 = ((channelNr&0xFF)<<24) 00121 + 0x00FFFFFF; 00122 00123 if ( stationID != 2 ){ 00124 *dataWord2 = ( (TSId&0x0FF)<<24) 00125 + (~(tsphi->code()+1)&0x007) 00126 + ( (~tsphi->phiB()&0x3FF)<<3) 00127 + ( (~tsphi->phi()&0xFFF)<<13); 00128 } 00129 else { 00130 *dataWord2 = ( (TSId&0xFFFFF)<<12) 00131 + (~(tsphi->code()+1)&0x00007) 00132 + ( (~tsphi->phi()&0x00FFF)<<3); 00133 } 00134 00135 calcCRC(*dataWord1, *dataWord2, newCRC); 00136 LineFED+=4; 00137 *((long*)LineFED)=*dataWord2; 00138 LineFED+=4; 00139 *((long*)LineFED)=*dataWord1; 00140 } 00141 } 00142 //Input 00143 00144 //Input 00145 L1MuDTChambThContainer::The_iterator tsthe; 00146 00147 for ( tsthe = thtrig->getContainer()->begin(); 00148 tsthe != thtrig->getContainer()->end(); 00149 tsthe++ ) { 00150 00151 int channelNr = channel(0, tsthe->scNum(), tsthe->bxNum()); 00152 if ( channelNr == 255 ) continue; 00153 int TSId = tsthe->whNum()+2; 00154 00155 *dataWord1 = ((channelNr&0xFF)<<24) 00156 + 0x00FFFFFF; 00157 00158 *dataWord2 = ((TSId&0x07)<<28) 00159 + 0x0FFFFFFF; 00160 00161 int stationID = tsthe->stNum()-1; 00162 for ( int bti = 0; bti < 7; bti++ ) 00163 *dataWord2 -= (tsthe->position(bti)&0x1)<<(stationID*7+bti); 00164 00165 calcCRC(*dataWord1, *dataWord2, newCRC); 00166 LineFED+=4; 00167 *((long*)LineFED)=*dataWord2; 00168 LineFED+=4; 00169 *((long*)LineFED)=*dataWord1; 00170 } 00171 //Input 00172 00173 //Output 00174 L1MuDTTrackContainer::Trackiterator tstrk; 00175 00176 for ( tstrk = trtrig->getContainer()->begin(); 00177 tstrk != trtrig->getContainer()->end(); 00178 tstrk++ ) { 00179 00180 int channelNr = channel(tstrk->whNum(), tstrk->scNum(), tstrk->bx()); 00181 if ( channelNr == 255 ) continue; 00182 int TSId = ( tstrk->TrkTag() == 0 ) ? 0xAFFF : 0xBFFF; 00183 00184 *dataWord1 = ((channelNr&0xFF)<<24) 00185 + 0x00FFFFFF; 00186 00187 *dataWord2 = ( (TSId&0xFFFF)<<16) 00188 + ( tstrk->stNum(4)&0x0000F) 00189 + ((tstrk->stNum(3)&0x0000F)<<4) 00190 + ((tstrk->stNum(2)&0x0000F)<<8) 00191 + ((tstrk->stNum(1)&0x00003)<<12); 00192 00193 calcCRC(*dataWord1, *dataWord2, newCRC); 00194 LineFED+=4; 00195 *((long*)LineFED)=*dataWord2; 00196 LineFED+=4; 00197 *((long*)LineFED)=*dataWord1; 00198 00199 TSId = ( tstrk->TrkTag() == 0 ) ? 0xCFFE : 0xDFFE; 00200 00201 *dataWord1 = ((channelNr&0xFF)<<24) 00202 + 0x00FFFFFF; 00203 00204 *dataWord2 = ( (TSId&0xFFFE)<<16) 00205 + ( ~tstrk->quality_packed()&0x0007) 00206 + ( (tstrk->phi_packed()&0x00FF)<<3) 00207 + ( (~tstrk->charge_packed()&0x0001)<<11) 00208 + ( (~tstrk->pt_packed()&0x001F)<<12); 00209 00210 calcCRC(*dataWord1, *dataWord2, newCRC); 00211 LineFED+=4; 00212 *((long*)LineFED)=*dataWord2; 00213 LineFED+=4; 00214 *((long*)LineFED)=*dataWord1; 00215 00216 channelNr = channel(0, tstrk->scNum(), tstrk->bx()); 00217 if ( channelNr == 255 ) continue; 00218 TSId = (tstrk->whNum()+3)<<16; 00219 TSId += ( tstrk->whNum() < 0 ) ? 0x8FFFC : 0x7FFFC; 00220 00221 *dataWord1 = ((channelNr&0xFF)<<24) 00222 + 0x00FFFFFF; 00223 00224 *dataWord2 = (TSId&0xFFFFC)<<12; 00225 00226 if ( tstrk->TrkTag() == 0 ) { 00227 *dataWord2 += 0x3F80 00228 + ( ~tstrk->eta_packed()&0x003F) 00229 + ((~tstrk->finehalo_packed()&0x0001)<<6); 00230 } 00231 else { 00232 *dataWord2 += 0x007F 00233 + ( (~tstrk->eta_packed()&0x003F)<<7) 00234 + ((~tstrk->finehalo_packed()&0x0001)<<13); 00235 } 00236 00237 calcCRC(*dataWord1, *dataWord2, newCRC); 00238 LineFED+=4; 00239 *((long*)LineFED)=*dataWord2; 00240 LineFED+=4; 00241 *((long*)LineFED)=*dataWord1; 00242 } 00243 //Output 00244 00245 //--> Trailer 00246 00247 *dataWord1 = 0xA0000000 00248 + (lines&0xFFFFFF); 00249 *dataWord2 = 0; 00250 00251 calcCRC(*dataWord1, *dataWord2&0xFFFF, newCRC); 00252 00253 *dataWord2 += (newCRC&0xFFFF)<<16; 00254 00255 LineFED+=4; 00256 *((long*)LineFED)=*dataWord2; 00257 LineFED+=4; 00258 *((long*)LineFED)=*dataWord1; 00259 00260 delete dataWord1; 00261 delete dataWord2; 00262 return true; 00263 }
edm::InputTag DTTFFEDSim::getDTDigiInputTag | ( | ) | [inline, private] |
Definition at line 61 of file DTTFFEDSim.h.
References DTDigiInputTag.
Referenced by fillRawData().
00061 { return DTDigiInputTag; }
edm::InputTag DTTFFEDSim::getDTPHTFInputTag | ( | ) | [inline, private] |
Definition at line 62 of file DTTFFEDSim.h.
References DTPHTFInputTag.
Referenced by fillRawData().
00062 { return DTPHTFInputTag; }
void DTTFFEDSim::produce | ( | edm::Event & | e, | |
const edm::EventSetup & | c | |||
) | [virtual] |
Produce digis out of raw data.
Implements edm::EDProducer.
Definition at line 41 of file DTTFFEDSim.cc.
References data, fillRawData(), and edm::Event::put().
00041 { 00042 00043 FEDRawDataCollection data; 00044 00045 if (!fillRawData(e, data)) return; 00046 00047 auto_ptr<FEDRawDataCollection> fed_product(new FEDRawDataCollection(data)); 00048 00049 e.put(fed_product); 00050 00051 }
Definition at line 298 of file DTTFFEDSim.cc.
00298 { 00299 00300 int myChannel = channel; 00301 00302 if (myChannel > 127) myChannel -= 2; 00303 00304 if (myChannel < 0 || myChannel > 251 ){ return -999; } 00305 00306 return myChannel/21; 00307 }
Definition at line 309 of file DTTFFEDSim.cc.
00309 { 00310 00311 int myChannel = channel; 00312 00313 if (myChannel > 127) myChannel -= 2; 00314 00315 if (myChannel < 0 || myChannel > 251 ){ return -999; } 00316 00317 int myWheel = ((myChannel%21)/3)-3; 00318 00319 return myWheel; 00320 }
edm::InputTag DTTFFEDSim::DTDigiInputTag [private] |
edm::InputTag DTTFFEDSim::DTPHTFInputTag [private] |
unsigned int DTTFFEDSim::eventNum [private] |