CMS 3D CMS Logo

MatacqProducer.cc
Go to the documentation of this file.
1 #include <csignal>
2 #include <cstdio>
3 #include <fstream>
4 #include <iomanip>
5 #include <iostream>
6 #include <memory>
7 
8 #include <glob.h>
9 #include <sys/stat.h>
10 #include <sys/types.h>
11 #include <unistd.h>
12 
13 #include <fmt/printf.h>
14 #include <boost/algorithm/string.hpp>
15 
28 
29 using namespace std;
30 using namespace boost;
31 using namespace edm;
32 
33 // #undef LogInfo
34 // #define LogInfo(a) cout << "INFO " << a << ": "
35 // #undef LogWarning
36 // #define LogWarning(a) cout << "WARN " << a << ": "
37 // #undef LogDebug
38 // #define LogDebug(a) cout << "DBG " << a << ": "
39 
40 //verbose mode for matacq event retrieval debugging:
41 //static const bool searchDbg = false;
42 
43 //laser freq is 1 every 112 orbit => >80 orbit
44 const int MatacqProducer::orbitTolerance_ = 80;
45 
47 
48 static std::string now() {
49  struct timeval t;
50  gettimeofday(&t, nullptr);
51 
52  char buf[256];
53  strftime(buf, sizeof(buf), "%F %R %S s", localtime(&t.tv_sec));
54  buf[sizeof(buf) - 1] = 0;
55 
56  stringstream buf2;
57  buf2 << buf << " " << ((t.tv_usec + 500) / 1000) << " ms";
58 
59  return buf2.str();
60 }
61 
63  : fileNames_(params.getParameter<std::vector<std::string> >("fileNames")),
64  digiInstanceName_(params.getParameter<string>("digiInstanceName")),
65  rawInstanceName_(params.getParameter<string>("rawInstanceName")),
66  timing_(params.getUntrackedParameter<bool>("timing", false)),
67  disabled_(params.getParameter<bool>("disabled")),
68  verbosity_(params.getUntrackedParameter<int>("verbosity", 0)),
69  produceDigis_(params.getParameter<bool>("produceDigis")),
70  produceRaw_(params.getParameter<bool>("produceRaw")),
71  inputRawCollection_(params.getParameter<edm::InputTag>("inputRawCollection")),
72  mergeRaw_(params.getParameter<bool>("mergeRaw")),
73  ignoreTriggerType_(params.getParameter<bool>("ignoreTriggerType")),
74  matacq_(nullptr, 0),
75  inFile_(nullptr),
76  data_(bufferSize),
77  openedFileRunNumber_(0),
78  lastOrb_(0),
79  fastRetrievalThresh_(0),
80  orbitOffsetFile_(params.getUntrackedParameter<std::string>("orbitOffsetFile", "")),
81  inFileName_(""),
82  stats_(stats_init),
83  logFileName_(params.getUntrackedParameter<std::string>("logFileName", "matacqProducer.log")),
84  eventSkipCounter_(0),
85  onErrorDisablingEvtCnt_(params.getParameter<int>("onErrorDisablingEvtCnt")),
86  timeLogFile_(params.getUntrackedParameter<std::string>("timeLogFile", "")),
87  runNumber_(0) {
88  if (verbosity_ >= 4)
89  cout << "[Matacq " << now() << "] in MatacqProducer ctor" << endl;
90 
91  gettimeofday(&timer_, nullptr);
92 
93  if (!timeLogFile_.empty()) {
94  timeLog_.open(timeLogFile_.c_str());
95  if (timeLog_.fail()) {
96  cout << "[LaserSorter " << now() << "] "
97  << "Failed to open file " << timeLogFile_ << " to log timing.\n";
98  logTiming_ = false;
99  } else {
100  logTiming_ = true;
101  }
102  }
103 
105 
106  logFile_.open(logFileName_.c_str(), ios::app | ios::out);
107 
108  if (logFile_.bad()) {
109  throw cms::Exception("FileOpen") << "Failed to open file " << logFileName_ << " for logging.\n";
110  }
111 
112  inputRawCollectionToken_ = consumes<FEDRawDataCollection>(params.getParameter<InputTag>("inputRawCollection"));
113 
114  if (produceDigis_) {
115  if (verbosity_ > 0)
116  cout << "[Matacq " << now()
117  << "] registering new "
118  "EcalMatacqDigiCollection product with instance name '"
119  << digiInstanceName_ << "'\n";
120  produces<EcalMatacqDigiCollection>(digiInstanceName_);
121  }
122 
123  if (produceRaw_) {
124  if (verbosity_ > 0)
125  cout << "[Matacq " << now()
126  << "] registering new FEDRawDataCollection "
127  "product with instance name '"
128  << rawInstanceName_ << "'\n";
129  produces<FEDRawDataCollection>(rawInstanceName_);
130  }
131 
132  startTime_.tv_sec = startTime_.tv_usec = 0;
133  if (!orbitOffsetFile_.empty()) {
134  doOrbitOffset_ = true;
135  loadOrbitOffset();
136  } else {
137  doOrbitOffset_ = false;
138  }
139  if (verbosity_ >= 4)
140  cout << "[Matacq " << now() << "] exiting MatacqProducer ctor" << endl;
141 }
142 
144  if (verbosity_ >= 4)
145  cout << "[Matacq " << now() << "] in MatacqProducer::produce" << endl;
146  if (logTiming_) {
147  timeval t;
148  gettimeofday(&t, nullptr);
149 
150  timeLog_ << t.tv_sec << "." << setfill('0') << setw(3) << (t.tv_usec + 500) / 1000 << setfill(' ') << "\t"
151  << (t.tv_usec - timer_.tv_usec) * 1. + (t.tv_sec - timer_.tv_sec) * 1.e6 << "\t";
152  timer_ = t;
153  }
154 
155  if (startTime_.tv_sec == 0)
156  gettimeofday(&startTime_, nullptr);
157  ++stats_.nEvents;
158  if (disabled_)
159  return;
160  const uint32_t runNumber = getRunNumber(event);
161  if (runNumber != runNumber_) {
163  }
165 
166  if (logTiming_) {
167  timeval t;
168  gettimeofday(&t, nullptr);
169  timeLog_ << (t.tv_usec - timer_.tv_usec) * 1. + (t.tv_sec - timer_.tv_sec) * 1.e6 << "\n";
170  timer_ = t;
171  }
172 }
173 
176  event.getByToken(inputRawCollectionToken_, sourceColl);
177 
178  std::unique_ptr<FEDRawDataCollection> rawColl;
179  if (produceRaw_) {
180  if (mergeRaw_) {
181  rawColl = std::make_unique<FEDRawDataCollection>(*sourceColl);
182  } else {
183  rawColl = std::make_unique<FEDRawDataCollection>();
184  }
185  }
186 
187  auto digiColl = std::make_unique<EcalMatacqDigiCollection>();
188 
189  if (eventSkipCounter_ == 0) {
190  if (sourceColl->FEDData(matacqFedId_).size() > 4 && !produceRaw_) {
191  //input raw data collection already contains matacqData
193  } else {
194  bool isLaserEvent = (getCalibTriggerType(event) == laserType);
195 
196  // cout << "---> " << (ignoreTriggerType_?"yes":"no") << " " << getCalibTriggerType(event) << endl;
197 
198  if (isLaserEvent || ignoreTriggerType_) {
199  const uint32_t runNumber = getRunNumber(event);
200  const uint32_t orbitId = getOrbitId(event);
201 
202  LogInfo("Matacq") << "Run " << runNumber << "\t Orbit " << orbitId << "\n";
203 
204  bool fileChange;
205  if (doOrbitOffset_) {
206  map<uint32_t, uint32_t>::iterator it = orbitOffset_.find(runNumber);
207  if (it == orbitOffset_.end()) {
208  LogWarning("Matacq") << "Orbit offset not found for run " << runNumber
209  << ". No orbit correction will be applied.";
210  }
211  }
212 
213  if (getMatacqFile(runNumber, orbitId, &fileChange)) {
214  //matacq file retrieval succeeded
215  LogInfo("Matacq") << "Matacq data file found for "
216  << "run " << runNumber << " orbit " << orbitId;
217  if (getMatacqEvent(runNumber, orbitId, fileChange)) {
218  if (produceDigis_) {
220  }
221  if (produceRaw_) {
222  uint32_t dataLen64 = matacq_.getParsedLen();
223  if (dataLen64 > bufferSize * 8 || matacq_.getDccLen() != dataLen64) {
224  LogWarning("Matacq") << " Error in Matacq event fragment length! "
225  << "DCC len: " << matacq_.getDccLen()
226  << "*8 Bytes, Parsed len: " << matacq_.getParsedLen() << "*8 Bytes. "
227  << "Matacq data will not be included for this event.\n";
228  } else {
229  rawColl->FEDData(matacqFedId_).resize(dataLen64 * 8);
230  copy(data_.begin(), data_.begin() + dataLen64 * 8, rawColl->FEDData(matacqFedId_).data());
231  }
232  }
233  LogInfo("Matacq") << "Associating matacq data with orbit id " << matacq_.getOrbitId()
234  << " to dcc event with orbit id " << orbitId << std::endl;
235  if (isLaserEvent) {
237  } else {
239  }
240  } else {
241  if (isLaserEvent) {
242  LogWarning("Matacq") << "No matacq data found for laser event "
243  << "of run " << runNumber << " orbit " << orbitId;
244  }
245  }
246  } else {
247  LogWarning("Matacq") << "No matacq file found for event " << event.id();
248  }
249  }
250  }
251  if (eventSkipCounter_ > 0) { //error occured for this events
252  // and some events will be skipped following
253  // to this error.
254  LogInfo("Matacq") << " [" << now() << "] " << eventSkipCounter_
255  << " next events will be skipped, following to an "
256  << "error on the last processed event, "
257  << "which is expected to be persistant.";
258  }
259  } else {
261  }
262 
263  if (produceRaw_) {
264  if (verbosity_ > 1)
265  cout << "[Matacq " << now() << "] "
266  << "Adding FEDRawDataCollection collection "
267  << " to event.\n";
268  event.put(std::move(rawColl), rawInstanceName_);
269  }
270 
271  if (produceDigis_) {
272  if (verbosity_ > 1)
273  cout << "[Matacq " << now() << "] "
274  << "Adding EcalMatacqDigiCollection collection "
275  << " to event.\n";
276  event.put(std::move(digiColl), digiInstanceName_);
277  }
278 }
279 
280 // #if 0
281 // bool
282 // MatacqProducer::getMatacqEvent(std::ifstream& f,
283 // uint32_t runNumber,
284 // uint32_t orbitId,
285 // bool doWrap,
286 // std::streamoff maxPos){
287 // bool found = false;
288 // streampos startPos = f.tellg();
289 
290 // while(!f.eof()
291 // && !found
292 // && (maxPos<0 || f.tellg()<=maxPos)){
293 // const streamsize headerSize = 8*8;
294 // f.read((char*)&data_[0], headerSize);
295 // if(f.eof()) break;
296 // int32_t orb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
297 // uint32_t len = MatacqRawEvent::getDccLen(&data_[0], headerSize);
298 // uint32_t run = MatacqRawEvent::getRunNum(&data_[0], headerSize);
299 // // cout << "Matacq: orbit = " << orb
300 // // << " len = " << len
301 // // << " run = " << run << endl;
302 // if((abs(orb-(int32_t)orbitId) < orbitTolerance_)
303 // && (runNumber==0 || runNumber==run)){
304 // found = true;
305 // //reads the rest of the event:
306 // if(data_.size() < len*8){
307 // throw cms::Exception("Matacq") << "Buffer overflow";
308 // }
309 // f.read((char*)&data_[0]+headerSize, len*8-headerSize);
310 // matacq_ = MatacqRawEvent((unsigned char*)&data_[0], len*8);
311 // } else{
312 // //moves to next event:
313 // f.seekg(len*8 - headerSize, ios::cur);
314 // }
315 // }
316 
317 // f.clear(); //clears eof error to allow seekg
318 // if(doWrap && !found){
319 // f.seekg(0, ios::beg);
320 // found = getMatacqEvent(f, runNumber, orbitId, false, startPos);
321 // }
322 // return found;
323 // }
324 //#endif
325 
326 bool MatacqProducer::getMatacqEvent(uint32_t runNumber, int32_t orbitId, bool fileChange) {
327  filepos_t startPos;
328  if (!mtell(startPos))
329  return false;
330 
331  int32_t startOrb = -1;
332  const size_t headerSize = 8 * 8;
333  if (mread((char*)&data_[0], headerSize, "Reading matacq header", true)) {
334  startOrb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
335  if (startOrb < 0)
336  startOrb = 0;
337  } else {
338  if (verbosity_ > 2) {
339  cout << "[Matacq " << now()
340  << "] Failed to read matacq header. Moved to start of "
341  " the file.\n";
342  }
343  mrewind();
344  if (mread((char*)&data_[0], headerSize, "Reading matacq header", true)) {
345  startPos = 0;
346  startOrb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
347  } else {
348  if (verbosity_ > 2)
349  cout << "[Matacq " << now() << "] Looks like matacq file is empty"
350  << "\n";
351  return false;
352  }
353  }
354 
355  if (verbosity_ > 2)
356  cout << "[Matacq " << now() << "] Last read orbit: " << lastOrb_ << " looking for orbit " << orbitId
357  << ". Current file position: " << startPos << " Orbit at current position: " << startOrb << "\n";
358 
359  // f.clear();
360  bool didCoarseMove = false;
361 
362  //FIXME: case where posEtim_.invalid() is false
363  if (!posEstim_.invalid() && (abs(lastOrb_ - orbitId) > fastRetrievalThresh_)) {
364  filepos_t pos = posEstim_.pos(orbitId);
365 
366  // struct stat st;
367  filepos_t fsize = -1;
368  // if(0==stat(inFileName_.c_str(), &st)){
369  if (msize(fsize)) {
370  // const int64_t fsize = st.st_size;
371  if (0 != posEstim_.eventLength() && pos > fsize) {
372  //estimated position is beyong end of file
373  //-> move to beginning of last event:
374  int64_t evtSize = posEstim_.eventLength() * sizeof(uint64_t);
375  pos = ((int64_t)fsize / evtSize - 1) * evtSize;
376  if (verbosity_ > 2) {
377  cout << "[Matacq " << now()
378  << "] Estimated position was beyond end of file. "
379  "Changed to "
380  << pos << "\n";
381  }
382  }
383  } else {
384  LogWarning("Matacq") << "Failed to access file " << inFileName_ << ".";
385  }
386  if (pos >= 0) {
387  if (verbosity_ > 2)
388  cout << "[Matacq " << now() << "] jumping to estimated position " << pos << "\n";
389  mseek(pos, SEEK_SET, "Jumping to estimated event position");
390  if (mread((char*)&data_[0], headerSize, "Reading matacq header", true)) {
391  didCoarseMove = true;
392  } else {
393  //estimated position might have been beyond the end of the file,
394  //try, with original position:
395  didCoarseMove = false;
396  if (!mread((char*)&data_[0], headerSize, "Reading event header", true)) {
397  return false;
398  }
399  }
400  } else {
401  if (verbosity_)
402  cout << "[Matacq " << now()
403  << "] Event orbit outside of orbit range "
404  "of matacq data file events\n";
405  return false;
406  }
407  }
408 
409  int32_t orb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
410 
411  if (didCoarseMove) {
412  //autoadjustement of threshold for coarse move:
413  if (abs(orb - orbitId) > fastRetrievalThresh_) {
414  if (verbosity_ > 2)
415  cout << "[Matacq " << now() << "] Fast retrieval threshold increased from " << fastRetrievalThresh_;
416  fastRetrievalThresh_ = 2 * abs(orb - orbitId);
417  if (verbosity_ > 2)
418  cout << " to " << fastRetrievalThresh_ << "\n";
419  }
420 
421  //if coarse move did not improve situation, rolls back:
422  if (startOrb > 0 && (abs(orb - orbitId) > abs(startOrb - orbitId))) {
423  if (verbosity_ > 2)
424  cout << "[Matacq " << now() << "] Estimation (-> orbit " << orb
425  << ") "
426  "was worst than original position (-> orbit "
427  << startOrb << "). Restoring position (" << startPos << ").\n";
428  mseek(startPos, SEEK_SET);
429  mread((char*)&data_[0], headerSize, "Reading event header", true);
430  orb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
431  }
432  }
433 
434  bool searchBackward = (orb > orbitId) ? true : false;
435  //BEWARE: len must be signed, because we are using latter in the code (-len)
436  //expression
437  int len = (int)MatacqRawEvent::getDccLen(&data_[0], headerSize);
438 
439  if (len == 0) {
440  cout << "[Matacq " << now() << "] read DCC length is null! Cancels matacq event search "
441  << " and move matacq file pointer to beginning of the file. "
442  << "(" << __FILE__ << ":" << __LINE__ << ")."
443  << "\n";
444  //rewind(f);
445  mrewind();
446  return false;
447  }
448 
449  enum state_t { searching, found, failed } state = searching;
450 
451  while (state == searching) {
452  orb = MatacqRawEvent::getOrbitId(&data_[0], headerSize);
453  len = (int)MatacqRawEvent::getDccLen(&data_[0], headerSize);
454  uint32_t run = MatacqRawEvent::getRunNum(&data_[0], headerSize);
455  if (verbosity_ > 3) {
456  filepos_t pos = -1;
457  mtell(pos);
458  cout << "[Matacq " << now() << "] Header read at file position " << pos << ": orbit = " << orb
459  << " len = " << len << "x8 Byte"
460  << " run = " << run << "\n";
461  }
462  if ((abs(orb - orbitId) < orbitTolerance_) && (runNumber == 0 || runNumber == run)) {
463  state = found;
464  lastOrb_ = orb;
465  //reads the rest of the event:
466  if ((int)data_.size() < len * 8) {
467  throw cms::Exception("Matacq") << "Buffer overflow";
468  }
469  if (verbosity_ > 2)
470  cout << "[Matacq " << now()
471  << "] Event found. Reading "
472  " matacq event."
473  << "\n";
474  if (!mread((char*)&data_[0], len * 8, "Reading matacq event")) {
475  if (verbosity_ > 2)
476  cout << "[Matacq " << now() << "] Failed to read matacq event."
477  << "\n";
478  state = failed;
479  }
480  matacq_ = MatacqRawEvent((unsigned char*)&data_[0], len * 8);
481  } else {
482  if ((searchBackward && (orb < orbitId)) || (!searchBackward && (orb > orbitId))) { //search ended
483  lastOrb_ = orb;
484  state = failed;
485  if (verbosity_ > 2)
486  cout << "[Matacq " << now() << "] No matacq data found for run " << run << ", orbit ID " << orbitId << "."
487  << "\n";
488  } else {
489  off_t offset = (searchBackward ? -len : len) * 8;
490  lastOrb_ = orb;
491  if (verbosity_ > 3) {
492  cout << "[Matacq " << now() << "] In matacq file, moving " << abs(offset) << " byte "
493  << (offset > 0 ? "forward" : "backward") << ".\n";
494  }
495 
496  if (mseek(offset, SEEK_CUR, (searchBackward ? "Moving to previous event" : "Moving to next event")) &&
497  mread((char*)&data_[0], headerSize, "Reading event header", true)) {
498  } else {
499  if (!searchBackward)
500  mseek(-len * 8, SEEK_CUR, "Moving to start of last complete event");
501  state = failed;
502  }
503  }
504  }
505  }
506 
507  if (state == found) {
508  filepos_t pos = -1;
509  filepos_t fsize = -1;
510  mtell(pos);
511  msize(fsize);
512  if (pos == fsize - 1) { //last byte.
513  if (verbosity_ > 2) {
514  cout << "[Matacq " << now()
515  << "] Event found was at the end of the file. Moving "
516  "stream position to beginning of this event."
517  << "\n";
518  }
519  mseek(-(int)len * 8 - 1, SEEK_CUR, "Moving to beginning of last matacq event");
520  }
521  }
522  return (state == found);
523 }
524 
525 bool MatacqProducer::getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool* fileChange) {
527  uint32_t firstOrb, lastOrb;
528  bool goodRange = getOrbitRange(firstOrb, lastOrb);
529  // if(orbitId < firstOrb || orbitId > lastOrb) continue;
530  if (goodRange && firstOrb <= orbitId && orbitId <= lastOrb) {
531  if (fileChange != nullptr)
532  *fileChange = false;
533  return misOpened();
534  }
535  }
536 
537  if (fileNames_.empty())
538  return false;
539 
540  const string runNumberFormat = "%08d{,_*}";
541  string sRunNumber = fmt::sprintf(runNumberFormat, runNumber);
542  //cout << "Run number string: " << sRunNumber << "\n";
543  bool found = false;
544  string fname;
545  uint32_t maxOrb = 0;
546  //we make two iterations to handle the case where the event is procesed
547  //before the matacq data are available. In such case we would have
548  //orbitId > maxOrb (maxOrb: orbit of last written matacq event)
549  // for(int itry = 0; itry < 2 && (orbitId > maxOrb); ++itry){
550  for (int itry = 0; itry < 1 && (orbitId > maxOrb); ++itry) {
551  if (itry > 0) {
552  int n_sec = 1;
553  std::cout << "[Matacq " << now() << "] Event orbit id (" << orbitId
554  << ") goes "
555  "beyound the range of available one. Waiting for "
556  << n_sec
557  << " seconds in case "
558  "it was not written yet to disk.";
559  sleep(n_sec);
560  }
561 
562  for (unsigned i = 0; i < fileNames_.size() && !found; ++i) {
563  fname = fileNames_[i];
564  boost::algorithm::replace_all(fname, "%run_subdir%", runSubDir(runNumber));
565  boost::algorithm::replace_all(fname, "%run_number%", sRunNumber);
566 
567  glob_t g;
568  int rc = glob(fname.c_str(), GLOB_BRACE, nullptr, &g);
569  if (rc) {
570  if (verbosity_ > 1) {
571  switch (rc) {
572  case GLOB_NOSPACE:
573  std::cout << "[Matacq " << now()
574  << "] Running out of memory while calling glob function to look for matacq file paths\n";
575  break;
576  case GLOB_ABORTED:
577  std::cout << "[Matacq " << now()
578  << "] Read error while calling glob function to look for matacq file paths\n";
579  break;
580  case GLOB_NOMATCH:
581  //ok. No message to report.
582  break;
583  }
584  continue;
585  }
586  } //rc
587  for (unsigned iglob = 0; iglob < g.gl_pathc; ++iglob) {
588  char* thePath = g.gl_pathv[iglob];
589  //FIXME: add sanity check on the path
590  static std::atomic<int> nOpenErrors{0};
591  const int maxOpenErrors = 50;
592  if (!mopen(thePath) && nOpenErrors < maxOpenErrors) {
593  std::cout << "[Matacq " << now() << "] Failed to open file " << thePath;
594  ++nOpenErrors;
595  if (nOpenErrors == maxOpenErrors) {
596  std::cout << nOpenErrors << "This is the " << maxOpenErrors
597  << "th occurence of this error. Report of this error is now disabled.\n";
598  } else {
599  std::cout << "\n";
600  }
601  }
602  uint32_t firstOrb;
603  uint32_t lastOrb;
604  bool goodRange = getOrbitRange(firstOrb, lastOrb);
605  std::cout << "Get orbit range " << (goodRange ? "succeeded" : "failed") << ". Range: " << firstOrb << "..."
606  << lastOrb << "\n";
607  if (goodRange && lastOrb > maxOrb)
608  maxOrb = lastOrb;
609  if (goodRange && firstOrb <= orbitId && orbitId <= lastOrb) {
610  found = true;
611  //continue;
612  fname = thePath;
613  if (verbosity_ > 1)
614  std::cout << "[Matacq " << now() << "] Switching to file " << fname << "\n";
615  break;
616  }
617  } //next iglob
618  globfree(&g);
619  } //next filenames
620  } //next itry
621 
622  if (found) {
623  LogInfo("Matacq") << "Uses matacq data file: '" << fname << "'\n";
624  } else {
625  if (verbosity_ >= 0)
626  cout << "[Matacq " << now()
627  << "] no matacq file found "
628  "for run "
629  << runNumber << ", orbit " << orbitId << "\n";
632  if (fileChange != nullptr)
633  *fileChange = false;
634  return false;
635  }
636 
637  if (found) {
639  lastOrb_ = 0;
640  posEstim_.init(this);
641  if (fileChange != nullptr)
642  *fileChange = true;
643  return true;
644  } else {
645  return false;
646  }
647 }
648 
649 uint32_t MatacqProducer::getRunNumber(edm::Event& ev) const { return ev.run(); }
650 
652  //on CVS HEAD (June 4, 08), class Event has a method orbitNumber()
653  //we could use here. The code would be shorten to:
654  //return ev.orbitNumber();
655  //we have to deal with what we have in current CMSSW releases:
657  ev.getByToken(inputRawCollectionToken_, rawdata);
658  if (!(rawdata.isValid())) {
659  throw cms::Exception("NotFound") << "No FED raw data collection found. ECAL raw data are "
660  "required to retrieve the orbit ID";
661  }
662 
663  int orbit = 0;
664  for (int id = 601; id <= 654; ++id) {
665  if (!FEDNumbering::inRange(id))
666  continue;
667  const FEDRawData& data = rawdata->FEDData(id);
668  const int orbitIdOffset64 = 3;
669  if (data.size() >= 8 * (orbitIdOffset64 + 1)) { //orbit id is in 4th 64-bit word
670  const unsigned char* pOrbit = data.data() + orbitIdOffset64 * 8;
671  int thisOrbit = pOrbit[0] | (pOrbit[1] << 8) | (pOrbit[2] << 16) | (pOrbit[3] << 24);
672  if (orbit != 0 && thisOrbit != 0 && abs(orbit - thisOrbit) > orbitTolerance_) {
673  //throw cms::Exception("EventCorruption")
674  // << "Orbit ID inconsitency in DCC headers";
675  LogWarning("EventCorruption") << "Orbit ID inconsitency in DCC headers";
676  orbit = 0;
677  break;
678  }
679  if (thisOrbit != 0)
680  orbit = thisOrbit;
681  }
682  }
683 
684  if (orbit == 0) {
685  // throw cms::Exception("NotFound")
686  // << "Failed to retrieve orbit ID of event "<< ev.id();
687  LogWarning("NotFound") << "Failed to retrieve orbit ID of event " << ev.id();
688  }
689  return orbit;
690 }
691 
694  ev.getByToken(inputRawCollectionToken_, rawdata);
695  if (!(rawdata.isValid())) {
696  throw cms::Exception("NotFound") << "No FED raw data collection found. ECAL raw data are "
697  "required to retrieve the trigger type";
698  }
699 
701  for (int id = 601; id <= 654; ++id) {
702  if (!FEDNumbering::inRange(id))
703  continue;
704  const FEDRawData& data = rawdata->FEDData(id);
705  const int detailedTrigger32 = 5;
706  if (data.size() >= 4 * (detailedTrigger32 + 1)) {
707  const unsigned char* pTType = data.data() + detailedTrigger32 * 4;
708  int tType = pTType[1] & 0x7;
709  stat.add(tType);
710  }
711  }
712  double p;
713  int tType = stat.result(&p);
714  if (p < 0) {
715  //throw cms::Exception("NotFound") << "No ECAL DCC data found\n";
716  LogWarning("NotFound") << "No ECAL DCC data found\n";
717  tType = -1;
718  }
719  if (p < .8) {
720  //throw cms::Exception("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
721  LogWarning("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
722  tType = -1;
723  }
724  return tType;
725 }
726 
728  mp->mrewind();
729 
730  const size_t headerSize = 8 * 8;
731  unsigned char data[headerSize];
732  if (!mp->mread((char*)data, headerSize)) {
733  if (verbosity_)
734  cout << "[Matacq " << now() << "] reached end of file!\n";
736  return;
737  } else {
740  if (verbosity_ > 1)
741  cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_ << " event length: " << eventLength_
742  << "*8 byte\n";
743  }
744 
745  mp->mrewind();
746 
747  if (eventLength_ == 0) {
748  if (verbosity_)
749  cout << "[Matacq " << now() << "] event length is null!" << endl;
750  return;
751  }
752 
753  filepos_t s = -1;
754  mp->msize(s);
755 
756  if (s == -1) {
757  if (verbosity_)
758  cout << "[Matacq " << now() << "] File is missing!" << endl;
759  orbitStepMean_ = 0;
760  return;
761  } else if (s == 0) {
762  if (verbosity_)
763  cout << "[Matacq " << now() << "] File is empty!" << endl;
764  orbitStepMean_ = 0;
765  return;
766  }
767 
768  //number of complete events:
769  const unsigned nEvents = s / eventLength_ / 8;
770 
771  if (verbosity_ > 1)
772  cout << "[Matacq " << now() << "] File size: " << s << " Number of events: " << nEvents << endl;
773 
774  //position of last complete events:
775  off_t last = (nEvents - 1) * (off_t)eventLength_ * 8;
776  mp->mseek(last,
777  SEEK_SET,
778  "Moving to beginning of last complete "
779  "matacq event");
780  if (!mp->mread((char*)data, headerSize, "Reading matacq header", true)) {
781  LogWarning("Matacq") << "Fast matacq event retrieval failure. "
782  "Falling back to safe retrieval mode.";
783  orbitStepMean_ = 0;
784  }
785 
786  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
787  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
788 
789  if (verbosity_ > 1)
790  cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb << " last event length: " << lastLen << endl;
791 
792  //some consistency check
793  if (lastLen != eventLength_) {
794  LogWarning("Matacq")
795  //throw cms::Exception("Matacq")
796  << "Fast matacq event retrieval failure: it looks like "
797  "the matacq file contains events of different sizes.";
798  // " Falling back to safe retrieval mode.";
799  invalid_ = false; //true;
800  orbitStepMean_ = 112; //0;
801  return;
802  }
803 
804  orbitStepMean_ = (lastOrb - firstOrbit_) / nEvents;
805 
806  if (verbosity_ > 1)
807  cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_ << "\n";
808 
809  invalid_ = false;
810 }
811 
812 int64_t MatacqProducer::PosEstimator::pos(int orb) const {
813  if (orb < firstOrbit_)
814  return -1;
815  uint64_t r = orbitStepMean_ != 0 ? (((uint64_t)(orb - firstOrbit_)) / orbitStepMean_) * eventLength_ * 8 : 0;
816  if (verbosity_ > 2)
817  cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb << ": " << r << endl;
818  return r;
819 }
820 
822  mclose();
823  timeval t;
824  gettimeofday(&t, nullptr);
825  if (logTiming_ && startTime_.tv_sec != 0) {
826  //not using logger, to allow timing with different logging options
827  cout << "[Matacq " << now()
828  << "] Time elapsed between first event and "
829  "destruction of MatacqProducer: "
830  << ((t.tv_sec - startTime_.tv_sec) * 1. + (t.tv_usec - startTime_.tv_usec) * 1.e-6) << "s\n";
831  }
832 }
833 
835  std::ifstream f(orbitOffsetFile_.c_str());
836  if (f.bad()) {
837  throw cms::Exception("Matacq") << "Failed to open orbit ID correction file '" << orbitOffsetFile_ << "'\n";
838  }
839 
840  cout << "[Matacq " << now() << "] "
841  << "Offset to substract to Matacq events Orbit ID: \n"
842  << "#Run Number\t Offset\n";
843 
844  int iline = 0;
845  string s;
846  stringstream buf;
847  while (f.eof()) {
848  getline(f, s);
849  ++iline;
850  if (s[0] == '#') { //comment
851  //skip line:
852  f.ignore(numeric_limits<streamsize>::max(), '\n');
853  continue;
854  }
855  buf.str("");
856  buf << s;
857  int run;
858  int orbit;
859  buf >> run;
860  buf >> orbit;
861  if (buf.bad()) {
862  throw cms::Exception("Matacq") << "Syntax error in Orbit offset file '" << orbitOffsetFile_ << "'";
863  }
864  cout << run << "\t" << orbit << "\n";
865  orbitOffset_.insert(pair<int, int>(run, orbit));
866  }
867 }
868 
869 #ifdef USE_STORAGE_MANAGER
870 bool MatacqProducer::mseek(filepos_t offset, int whence, const char* mess) {
871  if (0 == inFile_.get())
872  return false;
873  try {
875  if (whence == SEEK_SET)
876  wh = Storage::SET;
877  else if (whence == SEEK_CUR)
878  wh = Storage::CURRENT;
879  else if (whence == SEEK_END)
880  wh = Storage::END;
881  else
882  throw cms::Exception("Bug") << "Bug found in " << __FILE__ << ": " << __LINE__ << "\n";
883 
884  inFile_->position(offset, wh);
885  } catch (cms::Exception& e) {
886  if (verbosity_) {
887  cout << "[Matacq " << now() << "] ";
888  if (mess)
889  cout << mess << ". ";
890  cout << "Random access error on input matacq file. ";
891  if (whence == SEEK_SET)
892  cout << "Failed to seek absolute position " << offset;
893  else if (whence == SEEK_CUR)
894  cout << "Failed to move " << offset << " bytes forward";
895  else if (whence == SEEK_END)
896  cout << "Failed to seek position at " << offset << " bytes before end of file";
897  cout << ". Reopening file. " << e.what() << "\n";
899  return false;
900  }
901  }
902  return true;
903 }
904 
906  if (0 == inFile_.get())
907  return false;
908  pos = inFile_->position();
909  return true;
910 }
911 
912 bool MatacqProducer::mread(char* buf, size_t n, const char* mess, bool peek) {
913  if (0 == inFile_.get())
914  return false;
915 
916  filepos_t pos = -1;
917  if (!mtell(pos))
918  return false;
919 
920  bool rc = false;
921  try {
922  rc = (n == inFile_->xread(buf, n));
923  } catch (cms::Exception& e) {
924  if (verbosity_) {
925  cout << "[Matacq " << now() << "] ";
926  if (mess)
927  cout << mess << ". ";
928  cout << "Read failure from input matacq file: " << e.what() << "\n";
929  }
930  //recovering from error:
932  mseek(pos);
933  return false;
934  }
935  if (peek) { //asked to restore original file position
936  mseek(pos);
937  }
938  return rc;
939 }
940 
942  if (inFile_.get() == 0)
943  return false;
944  s = inFile_.get()->size();
945  return true;
946 }
947 
949  Storage* file = inFile_.get();
950  if (file == 0)
951  return false;
952  try {
953  file->rewind();
954  } catch (cms::Exception e) {
955  if (verbosity_)
956  cout << "Exception cautgh while rewinding file " << inFileName_ << ": " << e.what() << ". "
957  << "File will be reopened.";
958  return mopen(inFileName_);
959  }
960  return true;
961 }
962 
964 
966  //close already opened file if any:
967  mclose();
968 
969  try {
970  inFile_ = unique_ptr<Storage>(StorageFactory::get()->open(name, IOFlags::OpenRead));
971  inFileName_ = name;
972  } catch (cms::Exception& e) {
973  LogWarning("Matacq") << e.what();
974  inFile_.reset();
975  inFileName_ = "";
976  return false;
977  }
978  return true;
979 }
980 
981 void MatacqProducer::mclose() {
982  if (inFile_.get() != 0) {
983  inFile_->close();
984  inFile_.reset();
985  }
986 }
987 
988 bool MatacqProducer::misOpened() { return inFile_.get() != 0; }
989 
990 bool MatacqProducer::meof() {
991  if (inFile_.get() == 0)
992  return true;
993  return inFile_->eof();
994 }
995 
996 #else //USE_STORAGE_MANAGER not defined
997 bool MatacqProducer::mseek(off_t offset, int whence, const char* mess) {
998  if (nullptr == inFile_)
999  return false;
1000  const int rc = fseeko(inFile_, offset, whence);
1001  if (rc != 0 && verbosity_) {
1002  cout << "[Matacq " << now() << "] ";
1003  if (mess)
1004  cout << mess << ". ";
1005  cout << "Random access error on input matacq file. "
1006  "Rewind file.\n";
1007  mrewind();
1008  }
1009  return rc == 0;
1010 }
1011 
1013  if (nullptr == inFile_)
1014  return false;
1015  pos = ftello(inFile_);
1016  return pos != -1;
1017 }
1018 
1019 bool MatacqProducer::mread(char* buf, size_t n, const char* mess, bool peek) {
1020  if (nullptr == inFile_)
1021  return false;
1022  off_t pos = ftello(inFile_);
1023  bool rc = (pos != -1) && (1 == fread(buf, n, 1, inFile_));
1024  if (!rc) {
1025  if (verbosity_) {
1026  cout << "[Matacq " << now() << "] ";
1027  if (mess)
1028  cout << mess << ". ";
1029  cout << "Read failure from input matacq file.\n";
1030  }
1031  clearerr(inFile_);
1032  }
1033  if (peek || !rc) { //need to restore file position
1034  if (0 != fseeko(inFile_, pos, SEEK_SET)) {
1035  if (verbosity_) {
1036  cout << "[Matacq " << now() << "] ";
1037  if (mess)
1038  cout << mess << ". ";
1039  cout << "Failed to restore file position of "
1040  "before read error. Rewind file.\n";
1041  }
1042  //rewind(inFile_.get());
1043  mrewind();
1044  lastOrb_ = 0;
1045  }
1046  }
1047  return rc;
1048 }
1049 
1051  if (nullptr == inFile_)
1052  return false;
1053  struct stat buf;
1054  if (0 != fstat(fileno(inFile_), &buf)) {
1055  s = 0;
1056  return false;
1057  } else {
1058  s = buf.st_size;
1059  return true;
1060  }
1061 }
1062 
1064  if (nullptr == inFile_)
1065  return false;
1066  clearerr(inFile_);
1067  return fseeko(inFile_, 0, SEEK_SET) != 0;
1068 }
1069 
1071  struct stat dummy;
1072  return 0 == stat(name.c_str(), &dummy);
1073  // if(stat(name.c_str(), &dummy)==0){
1074  // return true;
1075  // } else{
1076  // cout << "[Matacq " << now() << "] Failed to stat file '"
1077  // << name.c_str() << "'. "
1078  // << "Error " << errno << ": " << strerror(errno) << "\n";
1079  // return false;
1080  // }
1081 }
1082 
1084  if (inFile_ != nullptr)
1085  mclose();
1086  inFile_ = fopen(name.c_str(), "r");
1087  if (inFile_ != nullptr) {
1088  inFileName_ = name;
1089  return true;
1090  } else {
1091  inFileName_ = "";
1092  return false;
1093  }
1094 }
1095 
1097  if (inFile_ != nullptr)
1098  fclose(inFile_);
1099  inFile_ = nullptr;
1100 }
1101 
1102 bool MatacqProducer::misOpened() { return inFile_ != nullptr; }
1103 
1105  if (nullptr == inFile_)
1106  return true;
1107  return feof(inFile_) == 0;
1108 }
1109 
1110 #endif //USE_STORAGE_MANAGER defined
1111 
1113  int millions = runNumber / (1000 * 1000);
1114  int thousands = (runNumber - millions * 1000 * 1000) / 1000;
1115  int units = runNumber - millions * 1000 * 1000 - thousands * 1000;
1116  return fmt::sprintf("%03d/%03d/%03d", millions, thousands, units);
1117 }
1118 
1119 void MatacqProducer::newRun(int prevRun, int newRun) {
1120  runNumber_ = newRun;
1121  eventSkipCounter_ = 0;
1122  logFile_ << "[" << now() << "] Event count for run " << runNumber_ << ": "
1123  << "total: " << stats_.nEvents << ", "
1124  << "Laser event with Matacq data: " << stats_.nLaserEventsWithMatacq << ", "
1125  << "Non laser event (according to DCC header) with Matacq data: " << stats_.nNonLaserEventsWithMatacq << "\n"
1126  << flush;
1127 
1128  stats_.nEvents = 0;
1131 }
1132 
1133 bool MatacqProducer::getOrbitRange(uint32_t& firstOrb, uint32_t& lastOrb) {
1134  filepos_t pos = -1;
1135  filepos_t fsize = -1;
1136  mtell(pos);
1137  msize(fsize);
1138  const unsigned headerSize = 8 * 8;
1139  unsigned char header[headerSize];
1140  //FIXME: Don't we need here to rewind?
1141  mseek(0);
1142  if (!mread((char*)header, headerSize, nullptr, false))
1143  return false;
1144  firstOrb = MatacqRawEvent::getOrbitId(header, headerSize);
1145  int len = (int)MatacqRawEvent::getDccLen(header, headerSize);
1146  //number of complete events. If last event is partially written,
1147  //it won't be included in the count.
1148  unsigned nEvts = fsize / (len * 8);
1149  //Position of last complete event:
1150  filepos_t lastEvtPos = (filepos_t)(nEvts - 1) * len * 8;
1151  // std::cout << "Move to position : " << lastEvtPos
1152  // << "(" << (nEvts - 1) << "*" << len << "*" << 64 << ")"
1153  //<< "\n";
1154  mseek(lastEvtPos);
1155  filepos_t tmp;
1156  mtell(tmp);
1157  //std::cout << "New position, sizeof(tmp): " << tmp << "," << sizeof(tmp) << "\n";
1158  mread((char*)header, headerSize, nullptr, false);
1159  lastOrb = MatacqRawEvent::getOrbitId(header, headerSize);
1160 
1161  //restore file position:
1162  mseek(pos);
1163 
1164  return true;
1165 }
MatacqDataFormatter::interpretRawData
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
Definition: MatacqDataFormatter.cc:19
MatacqProducer::inFile_
FILE_t inFile_
Definition: MatacqProducer.h:241
FEDNumbering.h
MatacqRawEvent::getParsedLen
int getParsedLen()
Definition: MatacqRawEvent.h:286
DigiToRawDM_cff.digiColl
digiColl
Definition: DigiToRawDM_cff.py:32
MatacqProducer::inputRawCollectionToken_
edm::EDGetTokenT< FEDRawDataCollection > inputRawCollectionToken_
Definition: MatacqProducer.h:226
Majority.h
MatacqProducer::MatacqProducer
MatacqProducer(const edm::ParameterSet &params)
Definition: MatacqProducer.cc:62
MatacqProducer::getOrbitId
uint32_t getOrbitId(edm::Event &ev) const
Definition: MatacqProducer.cc:651
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
MatacqProducer::verbosity_
int verbosity_
Definition: MatacqProducer.h:208
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
MatacqProducer::runNumber_
uint32_t runNumber_
Definition: MatacqProducer.h:316
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
ESHandle.h
MatacqProducer::stats_
struct MatacqProducer::stats_t stats_
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
MatacqProducer::inFileName_
std::string inFileName_
Definition: MatacqProducer.h:272
MatacqProducer::getMatacqEvent
bool getMatacqEvent(uint32_t runNumber, int32_t orbitId, bool fileChange)
Definition: MatacqProducer.cc:326
MatacqProducer::orbitOffset_
std::map< uint32_t, uint32_t > orbitOffset_
Definition: MatacqProducer.h:264
MatacqProducer::stats_init
const static stats_t stats_init
Definition: MatacqProducer.h:282
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
MatacqProducer::misOpened
bool misOpened()
Definition: MatacqProducer.cc:1102
MatacqProducer::filepos_t
off_t filepos_t
Definition: MatacqProducer.h:50
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
MatacqProducer::PosEstimator::firstOrbit_
int firstOrbit_
Definition: MatacqProducer.h:98
MatacqProducer::timeLogFile_
std::string timeLogFile_
Definition: MatacqProducer.h:301
Storage::END
Definition: Storage.h:22
runEdmFileComparison.failed
failed
Definition: runEdmFileComparison.py:224
MatacqProducer::mread
bool mread(char *buf, size_t n, const char *mess=nullptr, bool peek=false)
Definition: MatacqProducer.cc:1019
MatacqProducer::rawInstanceName_
std::string rawInstanceName_
Definition: MatacqProducer.h:196
Storage::SET
Definition: Storage.h:22
MatacqProducer::mcheck
bool mcheck(const std::string &name)
Definition: MatacqProducer.cc:1070
Storage::Relative
Relative
Definition: Storage.h:22
EcalMatacqDigi.h
MatacqProducer::laserType
Definition: MatacqProducer.h:43
MatacqProducer::getMatacqFile
bool getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool *fileChange=nullptr)
Definition: MatacqProducer.cc:525
MatacqProducer::matacq_
MatacqRawEvent matacq_
Definition: MatacqProducer.h:237
MatacqProducer::PosEstimator::invalid
bool invalid() const
Definition: MatacqProducer.h:89
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MatacqProducer::mtell
bool mtell(filepos_t &pos)
Definition: MatacqProducer.cc:1012
MatacqProducer::formatter_
MatacqDataFormatter formatter_
Definition: MatacqProducer.h:246
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
MatacqRawEvent::getOrbitId
static unsigned getOrbitId(unsigned char *data, size_t size)
Definition: MatacqRawEvent.h:216
boost
Definition: CLHEP.h:16
FEDRawData.h
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle< FEDRawDataCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MatacqProducer::PosEstimator::eventLength_
int eventLength_
Definition: MatacqProducer.h:96
MatacqRawEvent::getRunNum
unsigned getRunNum() const
Definition: MatacqRawEvent.h:247
FEDRawData
Definition: FEDRawData.h:19
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
MatacqProducer::produce
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: MatacqProducer.cc:143
MatacqProducer::PosEstimator::init
void init(MatacqProducer *mp)
Definition: MatacqProducer.cc:727
units
TString units(TString variable, Char_t axis)
MatacqProducer::orbitTolerance_
const static int orbitTolerance_
Definition: MatacqProducer.h:247
MatacqProducer::logFile_
std::ofstream logFile_
Definition: MatacqProducer.h:289
alignCSCRings.s
s
Definition: alignCSCRings.py:92
dqmdumpme.last
last
Definition: dqmdumpme.py:56
MatacqProducer::openedFileRunNumber_
uint32_t openedFileRunNumber_
Definition: MatacqProducer.h:248
nEvts
const int nEvts
Definition: recycleTccEmu.cc:12
MatacqProducer::PosEstimator::verbosity_
int verbosity_
Definition: MatacqProducer.h:100
MatacqRawEvent::getDccLen
unsigned getDccLen() const
Definition: MatacqRawEvent.h:195
MatacqProducer::PosEstimator::orbitStepMean_
int orbitStepMean_
Definition: MatacqProducer.h:97
MatacqProducer
Definition: MatacqProducer.h:41
MatacqProducer::getOrbitRange
bool getOrbitRange(uint32_t &firstOrb, uint32_t &lastOrb)
Definition: MatacqProducer.cc:1133
MatacqProducer::posEstim_
PosEstimator posEstim_
Definition: MatacqProducer.h:252
MatacqProducer::logFileName_
std::string logFileName_
Definition: MatacqProducer.h:285
MatacqProducer::ignoreTriggerType_
bool ignoreTriggerType_
Definition: MatacqProducer.h:235
StorageFactory::get
static const StorageFactory * get(void)
Definition: StorageFactory.cc:28
EcalDigiCollections.h
IOFlags::OpenRead
Definition: IOFlags.h:7
now
static std::string now()
Definition: MatacqProducer.cc:48
MatacqProducer::meof
bool meof()
Definition: MatacqProducer.cc:1104
MatacqProducer::logTiming_
bool logTiming_
Definition: MatacqProducer.h:312
MatacqRawEvent
Definition: MatacqRawEvent.h:30
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
MatacqProducer::timer_
timeval timer_
Definition: MatacqProducer.h:304
geometryDiff.file
file
Definition: geometryDiff.py:13
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Event.h
MatacqProducer::stats_t::nEvents
double nEvents
Definition: MatacqProducer.h:277
MatacqProducer.h
MatacqProducer::produceRaw_
bool produceRaw_
Definition: MatacqProducer.h:216
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MatacqProducer::lastOrb_
int32_t lastOrb_
Definition: MatacqProducer.h:249
MatacqProducer::fileNames_
std::vector< std::string > fileNames_
Definition: MatacqProducer.h:188
StorageFactory::check
bool check(const std::string &url, IOOffset *size=nullptr) const
Definition: StorageFactory.cc:181
MatacqProducer::fastRetrievalThresh_
int fastRetrievalThresh_
Definition: MatacqProducer.h:250
MatacqProducer::produceDigis_
bool produceDigis_
Definition: MatacqProducer.h:212
MatacqProducer::disabled_
bool disabled_
Definition: MatacqProducer.h:204
MatacqProducer::orbitOffsetFile_
std::string orbitOffsetFile_
Definition: MatacqProducer.h:260
MatacqProducer::runSubDir
static std::string runSubDir(uint32_t runNumber)
Definition: MatacqProducer.cc:1112
createfilelist.int
int
Definition: createfilelist.py:10
MatacqProducer::onErrorDisablingEvtCnt_
int onErrorDisablingEvtCnt_
Definition: MatacqProducer.h:297
FEDNumbering::inRange
static bool inRange(int)
Definition: FEDNumbering.cc:106
ntuplemaker.iline
iline
Definition: ntuplemaker.py:186
MatacqProducer::PosEstimator::eventLength
int eventLength() const
Definition: MatacqProducer.h:91
MatacqProducer::eventSkipCounter_
int eventSkipCounter_
Definition: MatacqProducer.h:293
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
MatacqProducer::getRunNumber
uint32_t getRunNumber(edm::Event &ev) const
Definition: MatacqProducer.cc:649
MatacqProducer::PosEstimator::verbosity
void verbosity(int verb)
Definition: MatacqProducer.h:93
MatacqProducer::loadOrbitOffset
void loadOrbitOffset()
Definition: MatacqProducer.cc:834
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
MatacqProducer::data_
std::vector< unsigned char > data_
Definition: MatacqProducer.h:245
MatacqProducer::matacqFedId_
static const int matacqFedId_
Definition: MatacqProducer.h:274
MatacqProducer::mrewind
bool mrewind()
Definition: MatacqProducer.cc:1063
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
MatacqProducer::stats_t
Definition: MatacqProducer.h:276
MatacqProducer::doOrbitOffset_
bool doOrbitOffset_
Definition: MatacqProducer.h:268
MatacqProducer::~MatacqProducer
~MatacqProducer() override
Definition: MatacqProducer.cc:821
MatacqProducer::newRun
void newRun(int prevRun, int newRun)
Definition: MatacqProducer.cc:1119
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MatacqProducer::mergeRaw_
bool mergeRaw_
Definition: MatacqProducer.h:231
MatacqProducer::stats_t::nNonLaserEventsWithMatacq
double nNonLaserEventsWithMatacq
Definition: MatacqProducer.h:279
MatacqProducer::addMatacqData
void addMatacqData(edm::Event &event)
Definition: MatacqProducer.cc:174
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
MatacqProducer::PosEstimator::invalid_
bool invalid_
Definition: MatacqProducer.h:99
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
MatacqProducer::stats_t::nLaserEventsWithMatacq
double nLaserEventsWithMatacq
Definition: MatacqProducer.h:278
MatacqProducer::PosEstimator::pos
int64_t pos(int orb) const
Definition: MatacqProducer.cc:812
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
Exception
Definition: hltDiff.cc:245
MatacqRawEvent::getOrbitId
uint32_t getOrbitId() const
Definition: MatacqRawEvent.h:312
MatacqProducer::mseek
bool mseek(filepos_t offset, int whence=SEEK_SET, const char *mess=nullptr)
Definition: MatacqProducer.cc:997
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
MatacqProducer::timeLog_
std::ofstream timeLog_
Definition: MatacqProducer.h:308
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
Storage::CURRENT
Definition: Storage.h:22
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::Exception
Definition: Exception.h:70
MatacqProducer::startTime_
timeval startTime_
Definition: MatacqProducer.h:254
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
dummy
Definition: DummySelector.h:38
MatacqProducer::mopen
bool mopen(const std::string &name)
Definition: MatacqProducer.cc:1083
MatacqProducer::mclose
void mclose()
Definition: MatacqProducer.cc:1096
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:40
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::Event
Definition: Event.h:73
Storage
Definition: Storage.h:20
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MatacqProducer::msize
bool msize(filepos_t &s)
Definition: MatacqProducer.cc:1050
edm::InputTag
Definition: InputTag.h:15
sistrip::runNumber_
static const char runNumber_[]
Definition: ConstantsForDqm.h:33
Majority
Definition: Majority.h:12
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
MatacqProducer::bufferSize
static const int bufferSize
Definition: MatacqProducer.h:243
MatacqProducer::getCalibTriggerType
int getCalibTriggerType(edm::Event &ev) const
Definition: MatacqProducer.cc:692
MatacqProducer::digiInstanceName_
std::string digiInstanceName_
Definition: MatacqProducer.h:192