31 LogDebug(
"CSCFileReader|ctor")<<
"Started ...";
37 std::ostringstream ruiName, fuName;
38 ruiName<<
"RUI"<<(
unit<10?
"0":
"")<<
unit<<std::ends;
39 fuName <<
"FU" <<
unit<<std::ends;
40 std::vector<std::string> ruiFiles = pset.
getUntrackedParameter< std::vector<std::string> >(ruiName.str().c_str(),std::vector<std::string>(0));
41 std::vector<std::string> fuFiles = pset.
getUntrackedParameter< std::vector<std::string> >(fuName.str().c_str(),std::vector<std::string>(0));
42 if( ruiFiles.begin() != ruiFiles.end() )
nActiveRUIs++;
43 if( fuFiles.begin() != fuFiles.end() )
nActiveFUs++;
46 throw cms::Exception(
"CSCFileReader|configuration")<<
"RUIs and FUs in conflict: either RUI or FU may be defined at a time, not both";
48 throw cms::Exception(
"CSCFileReader|configuration")<<
"Module lacks configuration";
52 for(
int rui=0; rui<nRUIs && !
nActiveFUs; rui++){
53 std::ostringstream
name;
54 name<<
"RUI"<<(rui<10?
"0":
"")<<rui<<std::ends;
64 }
catch ( std::runtime_error err ){
65 throw cms::Exception(
"CSCFileReader")<<
"InputFileMissing: "<<err.what()<<
" (errno="<<errno<<
")";
80 std::ostringstream
name;
81 name<<
"FU"<<fu<<std::ends;
91 }
catch ( std::runtime_error err ){
92 throw cms::Exception(
"CSCFileReader")<<
"InputFileMissing: "<<err.what()<<
" (errno="<<errno<<
")";
108 std::ostringstream
name;
109 name<<
"FED"<<fed<<std::ends;
110 std::vector<std::string> rui_list = pset.
getUntrackedParameter< std::vector<std::string> >(name.str().c_str(),std::vector<std::string>(0));
111 for(std::vector<std::string>::const_iterator rui=rui_list.begin(); rui!=rui_list.end(); rui++)
112 FED[fed].push_back((
unsigned int)atoi(rui->c_str()+rui->length()-2));
116 std::ostringstream
name;
117 name<<
"FED"<<fed<<std::ends;
118 std::vector<std::string> rui_list = pset.
getUntrackedParameter< std::vector<std::string> >(name.str().c_str(),std::vector<std::string>(0));
119 for(std::vector<std::string>::const_iterator rui=rui_list.begin(); rui!=rui_list.end(); rui++)
120 FED[fed].push_back((
unsigned int)atoi(rui->c_str()+rui->length()-2));
133 tmpBuf =
new unsigned short[200000*nRUIs+4*4];
140 for(
int rui=0; rui<
nRUIs; rui++){
144 LogDebug(
"CSCFileReader|ctor")<<
"... and finished";
154 }
catch ( std::runtime_error err ){
155 throw cms::Exception(
"CSCFileReader|reading")<<
"EndOfStream: "<<err.what()<<
" (errno="<<errno<<
")";
161 }
catch ( std::runtime_error err ){
162 throw cms::Exception(
"CSCFileReader|reading")<<
"InputFileMissing: "<<err.what()<<
" (errno="<<errno<<
")";
166 }
while( length==0 );
167 return buf[2]|((buf[3]&0xFF)<<16);
174 length =
FU[fu].
next(buf);
175 }
catch ( std::runtime_error err ){
176 throw cms::Exception(
"CSCFileReader|reading")<<
"EndOfStream: "<<err.what()<<
" (errno="<<errno<<
")";
182 }
catch ( std::runtime_error err ){
183 throw cms::Exception(
"CSCFileReader|reading")<<
"InputFileMissing: "<<err.what()<<
" (errno="<<errno<<
")";
187 }
while( length==0 );
189 return buf[2+8]|((buf[3+8]&0xFF)<<16);
197 for(
int rui=0; rui<
nRUIs; rui++){
207 for(
int rui=0; rui<
nRUIs; rui++)
210 if( eventNumber<0 )
return -1;
216 for(
std::map<
unsigned int,std::list<unsigned int> >::const_iterator fed=
FED.begin(); fed!=
FED.end(); fed++)
219 unsigned short *dccBuf=
tmpBuf, *dccCur=dccBuf;
220 dccCur[3] = 0x5000; dccCur[2] = 0x0000; dccCur[1] = 0x0000; dccCur[0] = 0x005F;
221 dccCur[7] = 0xD900; dccCur[6] = 0x0000; dccCur[5] = 0x0000; dccCur[4] = 0x0017;
224 for(std::list<unsigned int>::const_iterator rui=fed->second.begin(); rui!=fed->second.end(); rui++){
227 if(dccCur-dccBuf+
ruBufSize[*rui]>=200000*
nRUIs+8)
throw cms::Exception(
"CSCFileReader|eventBuffer")<<
"OutOfBuffer: Event size exceeds maximal size allowed!";
228 memcpy(dccCur,
ruBuf[*rui],
ruBufSize[*rui]*
sizeof(
unsigned short));
232 dccCur[3] = 0xEF00; dccCur[2] = 0x0000; dccCur[1] = 0x0000; dccCur[0] = 0x0000;
233 dccCur[7] = 0xAF00; dccCur[6] = 0x0000; dccCur[5] = 0x0000; dccCur[4] = 0x0007;
237 fedRawData.
resize((dccCur-dccBuf)*
sizeof(
unsigned short));
238 std::copy((
unsigned char*)dccBuf,(
unsigned char*)dccCur,fedRawData.
data());
240 for(std::list<unsigned int>::const_iterator rui=fed->second.begin(); rui!=fed->second.end(); rui++){
255 for(
int fu=0; fu<
nFUs; fu++)
262 for(
int fu=0; fu<
nFUs; fu++){
270 if( readyToGo<0 )
return -1;
275 unsigned long long *
start = (
unsigned long long *)
fuEvent[readyToGo];
276 unsigned long long *
end = 0;
277 enum {
Header=1,Trailer=2};
278 unsigned int eventStatus = 0;
279 for(
int dduRecord=0; dduRecord<=
tfDDUnumber; dduRecord++){
280 unsigned long long word_0=0, word_1=0, word_2=0;
281 size_t dduWordCount = 0;
282 while( !end && dduWordCount<
fuEventSize[readyToGo] ){
283 unsigned long long *dduWord =
start;
289 if( (word_2&0xFFFFFFFFFFFF0000LL)==0x8000000180000000LL ){
297 if( (word_0&0xFFFFFFFFFFFF0000LL)==0x8000FFFF80000000LL ){
298 eventStatus |= Trailer;
314 if( start>(
unsigned long long *)
fuEvent[readyToGo] && (*(start-1)&0xF000000000000000LL)==0x5000000000000000LL ) start--;
319 if( !end )
throw cms::Exception(
"CSCFileReader|lookingForTF")<<
" Sanity check failed (end==0)! Should never happen";
322 tfRawData.
resize((end-start)*
sizeof(
unsigned long long));
323 std::copy((
unsigned char*)start,(
unsigned char*)end,tfRawData.
data());
326 unsigned short *
event =
tmpBuf;
327 memcpy(
event,
fuEvent[readyToGo],((
unsigned short*)start-
fuEvent[readyToGo])*
sizeof(
unsigned short));
328 event += ((
unsigned short*)start-
fuEvent[readyToGo]);
332 fedRawData.
resize((
fuEventSize[readyToGo]-((
unsigned short*)end-(
unsigned short*)start))*
sizeof(
unsigned short));
357 if( eventNumber<0 )
return false;
T getUntrackedParameter(std::string const &, T const &) const
const unsigned short * fuEvent[4]
int open(const char *filename)
tuple start
Check for commandline option errors.
virtual ~CSCFileReader(void)
std::vector< std::string > fileNames[40]
std::map< unsigned int, std::list< unsigned int > > FED
int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
int buildEventFromRUIs(FEDRawDataCollection *data)
void select(unsigned int criteria)
void select(unsigned int criteria)
std::vector< std::string >::const_iterator currentFile[40]
size_t next(const unsigned short *&buf)
int readRUI(int rui, const unsigned short *&buf, size_t &length)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void reject(unsigned int criteria)
size_t next(const unsigned short *&buf, int prescaling=1)
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int readFU(int fu, const unsigned short *&buf, size_t &length)
void reject(unsigned int criteria)
int nextEventFromFUs(FEDRawDataCollection *data)
int open(const char *filename)
const unsigned short * ruBuf[40]
CSCFileReader(const edm::ParameterSet &pset)