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;
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  if (itry > 0) {
551  int n_sec = 1;
552  std::cout << "[Matacq " << now() << "] Event orbit id (" << orbitId
553  << ") goes "
554  "beyound the range of available one. Waiting for "
555  << n_sec
556  << " seconds in case "
557  "it was not written yet to disk.";
558  sleep(n_sec);
559  }
560 
561  for (unsigned i = 0; i < fileNames_.size() && !found; ++i) {
562  fname = fileNames_[i];
563  boost::algorithm::replace_all(fname, "%run_subdir%", runSubDir(runNumber));
564  boost::algorithm::replace_all(fname, "%run_number%", sRunNumber);
565 
566  glob_t g;
567  int rc = glob(fname.c_str(), GLOB_BRACE, nullptr, &g);
568  if (rc) {
569  if (verbosity_ > 1) {
570  switch (rc) {
571  case GLOB_NOSPACE:
572  std::cout << "[Matacq " << now()
573  << "] Running out of memory while calling glob function to look for matacq file paths\n";
574  break;
575  case GLOB_ABORTED:
576  std::cout << "[Matacq " << now()
577  << "] Read error while calling glob function to look for matacq file paths\n";
578  break;
579  case GLOB_NOMATCH:
580  //ok. No message to report.
581  break;
582  }
583  continue;
584  }
585  } //rc
586  for (unsigned iglob = 0; iglob < g.gl_pathc; ++iglob) {
587  char* thePath = g.gl_pathv[iglob];
588  //FIXME: add sanity check on the path
589  static std::atomic<int> nOpenErrors{0};
590  const int maxOpenErrors = 50;
591  if (!mopen(thePath) && nOpenErrors < maxOpenErrors) {
592  std::cout << "[Matacq " << now() << "] Failed to open file " << thePath;
593  ++nOpenErrors;
594  if (nOpenErrors == maxOpenErrors) {
595  std::cout << nOpenErrors << "This is the " << maxOpenErrors
596  << "th occurence of this error. Report of this error is now disabled.\n";
597  } else {
598  std::cout << "\n";
599  }
600  }
601  uint32_t firstOrb;
602  uint32_t lastOrb;
603  bool goodRange = getOrbitRange(firstOrb, lastOrb);
604  if (goodRange && lastOrb > maxOrb)
605  maxOrb = lastOrb;
606  if (goodRange && firstOrb <= orbitId && orbitId <= lastOrb) {
607  found = true;
608  //continue;
609  fname = thePath;
610  if (verbosity_ > 1)
611  std::cout << "[Matacq " << now() << "] Switching to file " << fname << "\n";
612  break;
613  }
614  } //next iglob
615  globfree(&g);
616  } //next filenames
617  } //next itry
618 
619  if (found) {
620  LogInfo("Matacq") << "Uses matacq data file: '" << fname << "'\n";
621  } else {
622  if (verbosity_ >= 0)
623  cout << "[Matacq " << now()
624  << "] no matacq file found "
625  "for run "
626  << runNumber << "\n";
629  if (fileChange != nullptr)
630  *fileChange = false;
631  return false;
632  }
633 
634  if (found) {
636  lastOrb_ = 0;
637  posEstim_.init(this);
638  if (fileChange != nullptr)
639  *fileChange = true;
640  return true;
641  } else {
642  return false;
643  }
644 }
645 
646 uint32_t MatacqProducer::getRunNumber(edm::Event& ev) const { return ev.run(); }
647 
649  //on CVS HEAD (June 4, 08), class Event has a method orbitNumber()
650  //we could use here. The code would be shorten to:
651  //return ev.orbitNumber();
652  //we have to deal with what we have in current CMSSW releases:
654  ev.getByToken(inputRawCollectionToken_, rawdata);
655  if (!(rawdata.isValid())) {
656  throw cms::Exception("NotFound") << "No FED raw data collection found. ECAL raw data are "
657  "required to retrieve the orbit ID";
658  }
659 
660  int orbit = 0;
661  for (int id = 601; id <= 654; ++id) {
662  if (!FEDNumbering::inRange(id))
663  continue;
664  const FEDRawData& data = rawdata->FEDData(id);
665  const int orbitIdOffset64 = 3;
666  if (data.size() >= 8 * (orbitIdOffset64 + 1)) { //orbit id is in 4th 64-bit word
667  const unsigned char* pOrbit = data.data() + orbitIdOffset64 * 8;
668  int thisOrbit = pOrbit[0] | (pOrbit[1] << 8) | (pOrbit[2] << 16) | (pOrbit[3] << 24);
669  if (orbit != 0 && thisOrbit != 0 && abs(orbit - thisOrbit) > orbitTolerance_) {
670  //throw cms::Exception("EventCorruption")
671  // << "Orbit ID inconsitency in DCC headers";
672  LogWarning("EventCorruption") << "Orbit ID inconsitency in DCC headers";
673  orbit = 0;
674  break;
675  }
676  if (thisOrbit != 0)
677  orbit = thisOrbit;
678  }
679  }
680 
681  if (orbit == 0) {
682  // throw cms::Exception("NotFound")
683  // << "Failed to retrieve orbit ID of event "<< ev.id();
684  LogWarning("NotFound") << "Failed to retrieve orbit ID of event " << ev.id();
685  }
686  return orbit;
687 }
688 
691  ev.getByToken(inputRawCollectionToken_, rawdata);
692  if (!(rawdata.isValid())) {
693  throw cms::Exception("NotFound") << "No FED raw data collection found. ECAL raw data are "
694  "required to retrieve the trigger type";
695  }
696 
698  for (int id = 601; id <= 654; ++id) {
699  if (!FEDNumbering::inRange(id))
700  continue;
701  const FEDRawData& data = rawdata->FEDData(id);
702  const int detailedTrigger32 = 5;
703  if (data.size() >= 4 * (detailedTrigger32 + 1)) {
704  const unsigned char* pTType = data.data() + detailedTrigger32 * 4;
705  int tType = pTType[1] & 0x7;
706  stat.add(tType);
707  }
708  }
709  double p;
710  int tType = stat.result(&p);
711  if (p < 0) {
712  //throw cms::Exception("NotFound") << "No ECAL DCC data found\n";
713  LogWarning("NotFound") << "No ECAL DCC data found\n";
714  tType = -1;
715  }
716  if (p < .8) {
717  //throw cms::Exception("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
718  LogWarning("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
719  tType = -1;
720  }
721  return tType;
722 }
723 
725  mp->mrewind();
726 
727  const size_t headerSize = 8 * 8;
728  unsigned char data[headerSize];
729  if (!mp->mread((char*)data, headerSize)) {
730  if (verbosity_)
731  cout << "[Matacq " << now() << "] reached end of file!\n";
733  return;
734  } else {
737  if (verbosity_ > 1)
738  cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_ << " event length: " << eventLength_
739  << "*8 byte\n";
740  }
741 
742  mp->mrewind();
743 
744  if (eventLength_ == 0) {
745  if (verbosity_)
746  cout << "[Matacq " << now() << "] event length is null!" << endl;
747  return;
748  }
749 
750  filepos_t s;
751  mp->msize(s);
752 
753  //number of complete events:
754  const unsigned nEvents = s / eventLength_ / 8;
755 
756  if (nEvents == 0) {
757  if (verbosity_)
758  cout << "[Matacq " << now() << "] File is empty!" << endl;
759  orbitStepMean_ = 0;
760  return;
761  }
762 
763  if (verbosity_ > 1)
764  cout << "[Matacq " << now() << "] File size: " << s << " Number of events: " << nEvents << endl;
765 
766  //position of last complete events:
767  off_t last = (nEvents - 1) * (off_t)eventLength_ * 8;
768  mp->mseek(last,
769  SEEK_SET,
770  "Moving to beginning of last complete "
771  "matacq event");
772  if (!mp->mread((char*)data, headerSize, "Reading matacq header", true)) {
773  LogWarning("Matacq") << "Fast matacq event retrieval failure. "
774  "Falling back to safe retrieval mode.";
775  orbitStepMean_ = 0;
776  }
777 
778  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
779  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
780 
781  if (verbosity_ > 1)
782  cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb << " last event length: " << lastLen << endl;
783 
784  //some consistency check
785  if (lastLen != eventLength_) {
786  LogWarning("Matacq")
787  //throw cms::Exception("Matacq")
788  << "Fast matacq event retrieval failure: it looks like "
789  "the matacq file contains events of different sizes.";
790  // " Falling back to safe retrieval mode.";
791  invalid_ = false; //true;
792  orbitStepMean_ = 112; //0;
793  return;
794  }
795 
796  orbitStepMean_ = (lastOrb - firstOrbit_) / nEvents;
797 
798  if (verbosity_ > 1)
799  cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_ << "\n";
800 
801  invalid_ = false;
802 }
803 
804 int64_t MatacqProducer::PosEstimator::pos(int orb) const {
805  if (orb < firstOrbit_)
806  return -1;
807  uint64_t r = orbitStepMean_ != 0 ? (((uint64_t)(orb - firstOrbit_)) / orbitStepMean_) * eventLength_ * 8 : 0;
808  if (verbosity_ > 2)
809  cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb << ": " << r << endl;
810  return r;
811 }
812 
814  mclose();
815  timeval t;
816  gettimeofday(&t, nullptr);
817  if (logTiming_ && startTime_.tv_sec != 0) {
818  //not using logger, to allow timing with different logging options
819  cout << "[Matacq " << now()
820  << "] Time elapsed between first event and "
821  "destruction of MatacqProducer: "
822  << ((t.tv_sec - startTime_.tv_sec) * 1. + (t.tv_usec - startTime_.tv_usec) * 1.e-6) << "s\n";
823  }
824 }
825 
827  std::ifstream f(orbitOffsetFile_.c_str());
828  if (f.bad()) {
829  throw cms::Exception("Matacq") << "Failed to open orbit ID correction file '" << orbitOffsetFile_ << "'\n";
830  }
831 
832  cout << "[Matacq " << now() << "] "
833  << "Offset to substract to Matacq events Orbit ID: \n"
834  << "#Run Number\t Offset\n";
835 
836  int iline = 0;
837  string s;
838  stringstream buf;
839  while (f.eof()) {
840  getline(f, s);
841  ++iline;
842  if (s[0] == '#') { //comment
843  //skip line:
844  f.ignore(numeric_limits<streamsize>::max(), '\n');
845  continue;
846  }
847  buf.str("");
848  buf << s;
849  int run;
850  int orbit;
851  buf >> run;
852  buf >> orbit;
853  if (buf.bad()) {
854  throw cms::Exception("Matacq") << "Syntax error in Orbit offset file '" << orbitOffsetFile_ << "'";
855  }
856  cout << run << "\t" << orbit << "\n";
857  orbitOffset_.insert(pair<int, int>(run, orbit));
858  }
859 }
860 
861 #ifdef USE_STORAGE_MANAGER
862 bool MatacqProducer::mseek(filepos_t offset, int whence, const char* mess) {
863  if (0 == inFile_.get())
864  return false;
865  try {
867  if (whence == SEEK_SET)
868  wh = Storage::SET;
869  else if (whence == SEEK_CUR)
870  wh = Storage::CURRENT;
871  else if (whence == SEEK_END)
872  wh = Storage::END;
873  else
874  throw cms::Exception("Bug") << "Bug found in " << __FILE__ << ": " << __LINE__ << "\n";
875 
876  inFile_->position(offset, wh);
877  } catch (cms::Exception& e) {
878  if (verbosity_) {
879  cout << "[Matacq " << now() << "] ";
880  if (mess)
881  cout << mess << ". ";
882  cout << "Random access error on input matacq file. ";
883  if (whence == SEEK_SET)
884  cout << "Failed to seek absolute position " << offset;
885  else if (whence == SEEK_CUR)
886  cout << "Failed to move " << offset << " bytes forward";
887  else if (whence == SEEK_END)
888  cout << "Failed to seek position at " << offset << " bytes before end of file";
889  cout << ". Reopening file. " << e.what() << "\n";
891  return false;
892  }
893  }
894  return true;
895 }
896 
898  if (0 == inFile_.get())
899  return false;
900  pos = inFile_->position();
901  return true;
902 }
903 
904 bool MatacqProducer::mread(char* buf, size_t n, const char* mess, bool peek) {
905  if (0 == inFile_.get())
906  return false;
907 
908  filepos_t pos = -1;
909  if (!mtell(pos))
910  return false;
911 
912  bool rc = false;
913  try {
914  rc = (n == inFile_->xread(buf, n));
915  } catch (cms::Exception& e) {
916  if (verbosity_) {
917  cout << "[Matacq " << now() << "] ";
918  if (mess)
919  cout << mess << ". ";
920  cout << "Read failure from input matacq file: " << e.what() << "\n";
921  }
922  //recovering from error:
924  mseek(pos);
925  return false;
926  }
927  if (peek) { //asked to restore original file position
928  mseek(pos);
929  }
930  return rc;
931 }
932 
934  if (inFile_.get() == 0)
935  return false;
936  s = inFile_.get()->size();
937  return true;
938 }
939 
941  Storage* file = inFile_.get();
942  if (file == 0)
943  return false;
944  try {
945  file->rewind();
946  } catch (cms::Exception e) {
947  if (verbosity_)
948  cout << "Exception cautgh while rewinding file " << inFileName_ << ": " << e.what() << ". "
949  << "File will be reopened.";
950  return mopen(inFileName_);
951  }
952  return true;
953 }
954 
956 
958  //close already opened file if any:
959  mclose();
960 
961  try {
962  inFile_ = unique_ptr<Storage>(StorageFactory::get()->open(name, IOFlags::OpenRead));
963  inFileName_ = name;
964  } catch (cms::Exception& e) {
965  LogWarning("Matacq") << e.what();
966  inFile_.reset();
967  inFileName_ = "";
968  return false;
969  }
970  return true;
971 }
972 
973 void MatacqProducer::mclose() {
974  if (inFile_.get() != 0) {
975  inFile_->close();
976  inFile_.reset();
977  }
978 }
979 
980 bool MatacqProducer::misOpened() { return inFile_.get() != 0; }
981 
982 bool MatacqProducer::meof() {
983  if (inFile_.get() == 0)
984  return true;
985  return inFile_->eof();
986 }
987 
988 #else //USE_STORAGE_MANAGER not defined
989 bool MatacqProducer::mseek(off_t offset, int whence, const char* mess) {
990  if (nullptr == inFile_)
991  return false;
992  const int rc = fseeko(inFile_, offset, whence);
993  if (rc != 0 && verbosity_) {
994  cout << "[Matacq " << now() << "] ";
995  if (mess)
996  cout << mess << ". ";
997  cout << "Random access error on input matacq file. "
998  "Rewind file.\n";
999  mrewind();
1000  }
1001  return rc == 0;
1002 }
1003 
1005  if (nullptr == inFile_)
1006  return false;
1007  pos = ftello(inFile_);
1008  return pos != -1;
1009 }
1010 
1011 bool MatacqProducer::mread(char* buf, size_t n, const char* mess, bool peek) {
1012  if (nullptr == inFile_)
1013  return false;
1014  off_t pos = ftello(inFile_);
1015  bool rc = (pos != -1) && (1 == fread(buf, n, 1, inFile_));
1016  if (!rc) {
1017  if (verbosity_) {
1018  cout << "[Matacq " << now() << "] ";
1019  if (mess)
1020  cout << mess << ". ";
1021  cout << "Read failure from input matacq file.\n";
1022  }
1023  clearerr(inFile_);
1024  }
1025  if (peek || !rc) { //need to restore file position
1026  if (0 != fseeko(inFile_, pos, SEEK_SET)) {
1027  if (verbosity_) {
1028  cout << "[Matacq " << now() << "] ";
1029  if (mess)
1030  cout << mess << ". ";
1031  cout << "Failed to restore file position of "
1032  "before read error. Rewind file.\n";
1033  }
1034  //rewind(inFile_.get());
1035  mrewind();
1036  lastOrb_ = 0;
1037  }
1038  }
1039  return rc;
1040 }
1041 
1043  if (nullptr == inFile_)
1044  return false;
1045  struct stat buf;
1046  if (0 != fstat(fileno(inFile_), &buf)) {
1047  s = 0;
1048  return false;
1049  } else {
1050  s = buf.st_size;
1051  return true;
1052  }
1053 }
1054 
1056  if (nullptr == inFile_)
1057  return false;
1058  clearerr(inFile_);
1059  return fseeko(inFile_, 0, SEEK_SET) != 0;
1060 }
1061 
1063  struct stat dummy;
1064  return 0 == stat(name.c_str(), &dummy);
1065  // if(stat(name.c_str(), &dummy)==0){
1066  // return true;
1067  // } else{
1068  // cout << "[Matacq " << now() << "] Failed to stat file '"
1069  // << name.c_str() << "'. "
1070  // << "Error " << errno << ": " << strerror(errno) << "\n";
1071  // return false;
1072  // }
1073 }
1074 
1076  if (inFile_ != nullptr)
1077  mclose();
1078  inFile_ = fopen(name.c_str(), "r");
1079  if (inFile_ != nullptr) {
1080  inFileName_ = name;
1081  return true;
1082  } else {
1083  inFileName_ = "";
1084  return false;
1085  }
1086 }
1087 
1089  if (inFile_ != nullptr)
1090  fclose(inFile_);
1091  inFile_ = nullptr;
1092 }
1093 
1094 bool MatacqProducer::misOpened() { return inFile_ != nullptr; }
1095 
1097  if (nullptr == inFile_)
1098  return true;
1099  return feof(inFile_) == 0;
1100 }
1101 
1102 #endif //USE_STORAGE_MANAGER defined
1103 
1105  int millions = runNumber / (1000 * 1000);
1106  int thousands = (runNumber - millions * 1000 * 1000) / 1000;
1107  int units = runNumber - millions * 1000 * 1000 - thousands * 1000;
1108  return fmt::sprintf("%03d/%03d/%03d", millions, thousands, units);
1109 }
1110 
1111 void MatacqProducer::newRun(int prevRun, int newRun) {
1112  runNumber_ = newRun;
1113  eventSkipCounter_ = 0;
1114  logFile_ << "[" << now() << "] Event count for run " << runNumber_ << ": "
1115  << "total: " << stats_.nEvents << ", "
1116  << "Laser event with Matacq data: " << stats_.nLaserEventsWithMatacq << ", "
1117  << "Non laser event (according to DCC header) with Matacq data: " << stats_.nNonLaserEventsWithMatacq << "\n"
1118  << flush;
1119 
1120  stats_.nEvents = 0;
1123 }
1124 
1125 bool MatacqProducer::getOrbitRange(uint32_t& firstOrb, uint32_t& lastOrb) {
1126  filepos_t pos = -1;
1127  filepos_t fsize = -1;
1128  mtell(pos);
1129  msize(fsize);
1130  const unsigned headerSize = 8 * 8;
1131  unsigned char header[headerSize];
1132  //FIXME: Don't we need here to rewind?
1133  mseek(0);
1134  if (!mread((char*)header, headerSize, nullptr, false))
1135  return false;
1136  firstOrb = MatacqRawEvent::getOrbitId(header, headerSize);
1137  int len = (int)MatacqRawEvent::getDccLen(header, headerSize);
1138  //number of complete events. If last event is partially written,
1139  //it won't be included in the count.
1140  unsigned nEvts = fsize / (len * 64);
1141  //Position of last complete event:
1142  filepos_t lastEvtPos = (nEvts - 1) * len * 64;
1143  mseek(lastEvtPos);
1144  mread((char*)header, headerSize, nullptr, false);
1145  lastOrb = MatacqRawEvent::getOrbitId(header, headerSize);
1146 
1147  //restore file position:
1148  mseek(pos);
1149 
1150  return true;
1151 }
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:648
electrons_cff.bool
bool
Definition: electrons_cff.py:393
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:1094
MatacqProducer::filepos_t
off_t filepos_t
Definition: MatacqProducer.h:50
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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:225
MatacqProducer::mread
bool mread(char *buf, size_t n, const char *mess=nullptr, bool peek=false)
Definition: MatacqProducer.cc:1011
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:1062
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:1004
MatacqProducer::formatter_
MatacqDataFormatter formatter_
Definition: MatacqProducer.h:246
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
Definition: AssociativeIterator.h:50
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:724
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
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
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:1125
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:1096
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
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:1104
createfilelist.int
int
Definition: createfilelist.py:10
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
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:646
MatacqProducer::PosEstimator::verbosity
void verbosity(int verb)
Definition: MatacqProducer.h:93
MatacqProducer::loadOrbitOffset
void loadOrbitOffset()
Definition: MatacqProducer.cc:826
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:57
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:1055
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
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:813
MatacqProducer::newRun
void newRun(int prevRun, int newRun)
Definition: MatacqProducer.cc:1111
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:31
MatacqProducer::stats_t::nLaserEventsWithMatacq
double nLaserEventsWithMatacq
Definition: MatacqProducer.h:278
MatacqProducer::PosEstimator::pos
int64_t pos(int orb) const
Definition: MatacqProducer.cc:804
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Exception
Definition: hltDiff.cc:246
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:989
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:292
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:1075
MatacqProducer::mclose
void mclose()
Definition: MatacqProducer.cc:1088
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:41
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:1042
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:689
MatacqProducer::digiInstanceName_
std::string digiInstanceName_
Definition: MatacqProducer.h:192