34 runNumber =
pset.getUntrackedParameter<
unsigned int>(
"runNumber", 1);
35 LogDebug(
"CSCFileReader|ctor") <<
"Started ...";
47 std::ostringstream ruiName, fuName;
48 ruiName <<
"RUI" << (
unit < 10 ?
"0" :
"") <<
unit << std::ends;
49 fuName <<
"FU" <<
unit << std::ends;
50 std::vector<std::string> ruiFiles =
51 pset.getUntrackedParameter<std::vector<std::string> >(ruiName.str().c_str(), std::vector<std::string>(0));
52 std::vector<std::string> fuFiles =
53 pset.getUntrackedParameter<std::vector<std::string> >(fuName.str().c_str(), std::vector<std::string>(0));
54 if (ruiFiles.begin() != ruiFiles.end())
56 if (fuFiles.begin() != fuFiles.end())
61 <<
"RUIs and FUs in conflict: either RUI or FU may be defined at a time, not both";
63 throw cms::Exception(
"CSCFileReader|configuration") <<
"Module lacks configuration";
67 std::ostringstream
name;
68 name <<
"RUI" << (rui < 10 ?
"0" :
"") << rui << std::ends;
72 pset.getUntrackedParameter<std::vector<std::string> >(
name.str().c_str(), std::vector<std::string>(0));
79 }
catch (std::runtime_error &
err) {
80 throw cms::Exception(
"CSCFileReader") <<
"InputFileMissing: " <<
err.what() <<
" (errno=" << errno <<
")";
95 std::ostringstream
name;
96 name <<
"FU" << fu << std::ends;
100 pset.getUntrackedParameter<std::vector<std::string> >(
name.str().c_str(), std::vector<std::string>(0));
107 }
catch (std::runtime_error &
err) {
108 throw cms::Exception(
"CSCFileReader") <<
"InputFileMissing: " <<
err.what() <<
" (errno=" << errno <<
")";
124 std::ostringstream
name;
125 name <<
"FED" << fed << std::ends;
126 std::vector<std::string> rui_list =
127 pset.getUntrackedParameter<std::vector<std::string> >(
name.str().c_str(), std::vector<std::string>(0));
128 for (std::vector<std::string>::const_iterator rui = rui_list.begin(); rui != rui_list.end(); rui++)
129 FED[fed].
push_back((
unsigned int)atoi(rui->c_str() + rui->length() - 2));
132 std::ostringstream
name;
133 name <<
"FED" << fed << std::ends;
134 std::vector<std::string> rui_list =
135 pset.getUntrackedParameter<std::vector<std::string> >(
name.str().c_str(), std::vector<std::string>(0));
136 for (std::vector<std::string>::const_iterator rui = rui_list.begin(); rui != rui_list.end(); rui++)
137 FED[fed].
push_back((
unsigned int)atoi(rui->c_str() + rui->length() - 2));
142 std::ostringstream
name;
143 name <<
"FED" << fed << std::ends;
144 std::vector<std::string> rui_list =
145 pset.getUntrackedParameter<std::vector<std::string> >(
name.str().c_str(), std::vector<std::string>(0));
146 for (std::vector<std::string>::const_iterator rui = rui_list.begin(); rui != rui_list.end(); rui++)
147 FED[fed].
push_back((
unsigned int)atoi(rui->c_str() + rui->length() - 2));
160 tmpBuf =
new unsigned short[200000 *
nRUIs + 4 * 4];
171 for (
int rui = 0; rui <
nRUIs; rui++) {
172 ruBuf[rui] =
nullptr;
175 LogDebug(
"CSCFileReader|ctor") <<
"... and finished";
176 produces<FEDRawDataCollection>();
190 }
catch (std::runtime_error &
err) {
191 throw cms::Exception(
"CSCFileReader|reading") <<
"EndOfStream: " <<
err.what() <<
" (errno=" << errno <<
")";
198 }
catch (std::runtime_error &
err) {
200 <<
"InputFileMissing: " <<
err.what() <<
" (errno=" << errno <<
")";
205 }
while (length == 0);
206 return buf[2] | ((
buf[3] & 0xFF) << 16);
215 }
catch (std::runtime_error &
err) {
216 throw cms::Exception(
"CSCFileReader|reading") <<
"EndOfStream: " <<
err.what() <<
" (errno=" << errno <<
")";
223 }
catch (std::runtime_error &
err) {
225 <<
"InputFileMissing: " <<
err.what() <<
" (errno=" << errno <<
")";
230 }
while (length == 0);
232 return buf[2 + 8] | ((
buf[3 + 8] & 0xFF) << 16);
236 int eventNumber = -1;
240 for (
int rui = 0; rui <
nRUIs; rui++) {
252 for (
int rui = 0; rui <
nRUIs; rui++)
263 for (
std::map<
unsigned int, std::list<unsigned int> >::const_iterator fed =
FED.begin(); fed !=
FED.end(); fed++)
266 unsigned short *dccBuf =
tmpBuf, *dccCur = dccBuf;
277 for (std::list<unsigned int>::const_iterator rui = fed->second.begin(); rui != fed->second.end(); rui++) {
282 <<
"OutOfBuffer: Event size exceeds maximal size allowed!";
283 memcpy(dccCur,
ruBuf[*rui],
ruBufSize[*rui] *
sizeof(
unsigned short));
298 fedRawData.resize((dccCur - dccBuf) *
sizeof(
unsigned short));
301 for (std::list<unsigned int>::const_iterator rui = fed->second.begin(); rui != fed->second.end(); rui++) {
312 int eventNumber = -1;
316 for (
int fu = 0; fu <
nFUs; fu++)
323 for (
int fu = 0; fu <
nFUs; fu++) {
337 unsigned long long *
start = (
unsigned long long *)
fuEvent[readyToGo];
338 unsigned long long *
end =
nullptr;
339 enum {
Header = 1, Trailer = 2 };
340 unsigned int eventStatus = 0;
341 for (
int dduRecord = 0; dduRecord <=
tfDDUnumber; dduRecord++) {
342 unsigned long long word_0 = 0, word_1 = 0, word_2 = 0;
343 size_t dduWordCount = 0;
345 unsigned long long *dduWord =
start;
351 if ((word_2 & 0xFFFFFFFFFFFF0000LL) == 0x8000000180000000
LL) {
360 if ((word_0 & 0xFFFFFFFFFFFF0000LL) == 0x8000FFFF80000000
LL) {
361 eventStatus |= Trailer;
377 if (
start > (
unsigned long long *)
fuEvent[readyToGo] && (*(
start - 1) & 0xF000000000000000LL) == 0x5000000000000000
LL)
384 throw cms::Exception(
"CSCFileReader|lookingForTF") <<
" Sanity check failed (end==0)! Should never happen";
391 unsigned short *
event =
tmpBuf;
393 event += ((
unsigned short *)
start -
fuEvent[readyToGo]);
398 sizeof(
unsigned short));
424 int eventNumber = -1;
445 std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
const unsigned short * fuEvent[4]
int open(const char *filename)
void produce(edm::Event &, edm::EventSetup const &) override
std::vector< std::string > fileNames[40]
std::map< unsigned int, std::list< unsigned int > > 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)
Basic3DVector unit() const
~CSCFileReader(void) override
void reject(unsigned int criteria)
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
size_t next(const unsigned short *&buf, int prescaling=1)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
char data[epos_bytes_allocation]
int readFU(int fu, const unsigned short *&buf, size_t &length)
void reject(unsigned int criteria)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int nextEventFromFUs(FEDRawDataCollection *data)
int open(const char *filename)
const unsigned short * ruBuf[40]
CSCFileReader(const edm::ParameterSet &pset)