CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MatacqProducer::PosEstimator Class Reference

Public Member Functions

int eventLength () const
 
int firstOrbit () const
 
void init (MatacqProducer *mp)
 
bool invalid () const
 
int64_t pos (int orb) const
 
 PosEstimator ()
 
void verbosity (int verb)
 

Private Attributes

int eventLength_
 
int firstOrbit_
 
bool invalid_
 
int orbitStepMean_
 
int verbosity_
 

Detailed Description

Estimates matacq event position in a file from its orbit id. This estimator requires that every event in the file has the same length. A linear extrapolation of pos=f(orbit) function from first and last event is performed. It gives only a rough estimate, relevant only to initiliaze the event search.

Definition at line 78 of file MatacqProducer.cc.

Constructor & Destructor Documentation

◆ PosEstimator()

MatacqProducer::PosEstimator::PosEstimator ( )
inline

Member Function Documentation

◆ eventLength()

int MatacqProducer::PosEstimator::eventLength ( ) const
inline

Definition at line 87 of file MatacqProducer.cc.

References eventLength_.

Referenced by MatacqProducer::getMatacqEvent().

◆ firstOrbit()

int MatacqProducer::PosEstimator::firstOrbit ( ) const
inline

Definition at line 88 of file MatacqProducer.cc.

References firstOrbit_.

◆ init()

void MatacqProducer::PosEstimator::init ( MatacqProducer mp)

Definition at line 1037 of file MatacqProducer.cc.

References gather_cfg::cout, data, eventLength_, firstOrbit_, MatacqRawEvent::getDccLen(), MatacqRawEvent::getOrbitId(), invalid_, dqmdumpme::last, MatacqProducer::mread(), MatacqProducer::mrewind(), MatacqProducer::mseek(), MatacqProducer::msize(), submitPVValidationJobs::nEvents, now(), orbitStepMean_, alignCSCRings::s, and verbosity_.

Referenced by MatacqProducer::getMatacqFile().

1037  {
1038  mp->mrewind();
1039 
1040  const size_t headerSize = 8 * 8;
1041  unsigned char data[headerSize];
1042  if (!mp->mread((char*)data, headerSize)) {
1043  if (verbosity_)
1044  cout << "[Matacq " << now() << "] reached end of file!\n";
1046  return;
1047  } else {
1050  if (verbosity_ > 1)
1051  cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_ << " event length: " << eventLength_
1052  << "*8 byte\n";
1053  }
1054 
1055  mp->mrewind();
1056 
1057  if (eventLength_ == 0) {
1058  if (verbosity_)
1059  cout << "[Matacq " << now() << "] event length is null!" << endl;
1060  return;
1061  }
1062 
1063  filepos_t s = -1;
1064  mp->msize(s);
1065 
1066  if (s == -1) {
1067  if (verbosity_)
1068  cout << "[Matacq " << now() << "] File is missing!" << endl;
1069  orbitStepMean_ = 0;
1070  return;
1071  } else if (s == 0) {
1072  if (verbosity_)
1073  cout << "[Matacq " << now() << "] File is empty!" << endl;
1074  orbitStepMean_ = 0;
1075  return;
1076  }
1077 
1078  //number of complete events:
1079  const unsigned nEvents = s / eventLength_ / 8;
1080 
1081  if (verbosity_ > 1)
1082  cout << "[Matacq " << now() << "] File size: " << s << " Number of events: " << nEvents << endl;
1083 
1084  //position of last complete events:
1085  off_t last = (nEvents - 1) * (off_t)eventLength_ * 8;
1086  mp->mseek(last,
1087  SEEK_SET,
1088  "Moving to beginning of last complete "
1089  "matacq event");
1090  if (!mp->mread((char*)data, headerSize, "Reading matacq header", true)) {
1091  LogWarning("Matacq") << "Fast matacq event retrieval failure. "
1092  "Falling back to safe retrieval mode.";
1093  orbitStepMean_ = 0;
1094  }
1095 
1096  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
1097  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
1098 
1099  if (verbosity_ > 1)
1100  cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb << " last event length: " << lastLen << endl;
1101 
1102  //some consistency check
1103  if (lastLen != eventLength_) {
1104  LogWarning("Matacq")
1105  //throw cms::Exception("Matacq")
1106  << "Fast matacq event retrieval failure: it looks like "
1107  "the matacq file contains events of different sizes.";
1108  // " Falling back to safe retrieval mode.";
1109  invalid_ = false; //true;
1110  orbitStepMean_ = 112; //0;
1111  return;
1112  }
1113 
1114  orbitStepMean_ = (lastOrb - firstOrbit_) / nEvents;
1115 
1116  if (verbosity_ > 1)
1117  cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_ << "\n";
1118 
1119  invalid_ = false;
1120 }
bool mseek(filepos_t offset, int whence=SEEK_SET, const char *mess=nullptr)
unsigned getDccLen() const
bool mread(char *buf, size_t n, const char *mess=nullptr, bool peek=false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
static std::string now()
uint32_t getOrbitId() const
Log< level::Warning, false > LogWarning
bool msize(filepos_t &s)

◆ invalid()

bool MatacqProducer::PosEstimator::invalid ( ) const
inline

Definition at line 85 of file MatacqProducer.cc.

References invalid_.

Referenced by MatacqProducer::getMatacqEvent().

◆ pos()

int64_t MatacqProducer::PosEstimator::pos ( int  orb) const

Definition at line 1122 of file MatacqProducer.cc.

References gather_cfg::cout, now(), alignCSCRings::r, and MatacqProducer::verbosity_.

Referenced by MatacqProducer::getMatacqEvent().

1122  {
1123  if (orb < firstOrbit_)
1124  return -1;
1125  uint64_t r = orbitStepMean_ != 0 ? (((uint64_t)(orb - firstOrbit_)) / orbitStepMean_) * eventLength_ * 8 : 0;
1126  if (verbosity_ > 2)
1127  cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb << ": " << r << endl;
1128  return r;
1129 }
unsigned long long uint64_t
Definition: Time.h:13
static std::string now()

◆ verbosity()

void MatacqProducer::PosEstimator::verbosity ( int  verb)
inline

Definition at line 89 of file MatacqProducer.cc.

References verbosity_.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

◆ eventLength_

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 92 of file MatacqProducer.cc.

Referenced by eventLength(), and init().

◆ firstOrbit_

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 94 of file MatacqProducer.cc.

Referenced by firstOrbit(), and init().

◆ invalid_

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 95 of file MatacqProducer.cc.

Referenced by init(), and invalid().

◆ orbitStepMean_

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 93 of file MatacqProducer.cc.

Referenced by init().

◆ verbosity_

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 96 of file MatacqProducer.cc.

Referenced by init(), and verbosity().