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 727 of file MatacqProducer.cc.

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

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 812 of file MatacqProducer.cc.

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

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:1019
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:1063
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:997
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:40
MatacqProducer::msize
bool msize(filepos_t &s)
Definition: MatacqProducer.cc:1050