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 82 of file MatacqProducer.h.

Constructor & Destructor Documentation

◆ PosEstimator()

MatacqProducer::PosEstimator::PosEstimator ( )
inline

Definition at line 87 of file MatacqProducer.h.

Member Function Documentation

◆ eventLength()

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

Definition at line 91 of file MatacqProducer.h.

91 { return eventLength_; }

References eventLength_.

Referenced by MatacqProducer::getMatacqEvent().

◆ firstOrbit()

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

Definition at line 92 of file MatacqProducer.h.

92 { return firstOrbit_; }

References firstOrbit_.

◆ init()

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

Definition at line 724 of file MatacqProducer.cc.

724  {
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 }

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

Referenced by MatacqProducer::getMatacqFile().

◆ invalid()

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

Definition at line 89 of file MatacqProducer.h.

89 { return invalid_; }

References invalid_.

Referenced by MatacqProducer::getMatacqEvent().

◆ pos()

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

Definition at line 804 of file MatacqProducer.cc.

804  {
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 }

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

Referenced by MatacqProducer::getMatacqEvent().

◆ verbosity()

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

Definition at line 93 of file MatacqProducer.h.

93 { verbosity_ = verb; }

References verbosity_.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

◆ eventLength_

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 96 of file MatacqProducer.h.

Referenced by eventLength(), and init().

◆ firstOrbit_

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 98 of file MatacqProducer.h.

Referenced by firstOrbit(), and init().

◆ invalid_

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 99 of file MatacqProducer.h.

Referenced by init(), and invalid().

◆ orbitStepMean_

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 97 of file MatacqProducer.h.

Referenced by init().

◆ verbosity_

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 100 of file MatacqProducer.h.

Referenced by init(), and verbosity().

MatacqProducer::filepos_t
off_t filepos_t
Definition: MatacqProducer.h:50
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MatacqProducer::PosEstimator::firstOrbit_
int firstOrbit_
Definition: MatacqProducer.h:98
MatacqProducer::mread
bool mread(char *buf, size_t n, const char *mess=nullptr, bool peek=false)
Definition: MatacqProducer.cc:1011
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MatacqProducer::PosEstimator::eventLength_
int eventLength_
Definition: MatacqProducer.h:96
alignCSCRings.s
s
Definition: alignCSCRings.py:92
dqmdumpme.last
last
Definition: dqmdumpme.py:56
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
now
static std::string now()
Definition: MatacqProducer.cc:48
MatacqProducer::mrewind
bool mrewind()
Definition: MatacqProducer.cc:1055
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MatacqProducer::PosEstimator::invalid_
bool invalid_
Definition: MatacqProducer.h:99
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
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:41
MatacqProducer::msize
bool msize(filepos_t &s)
Definition: MatacqProducer.cc:1042