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

726  {
727  mp->mrewind();
728 
729  const size_t headerSize = 8 * 8;
730  unsigned char data[headerSize];
731  if (!mp->mread((char*)data, headerSize)) {
732  if (verbosity_)
733  cout << "[Matacq " << now() << "] reached end of file!\n";
735  return;
736  } else {
739  if (verbosity_ > 1)
740  cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_ << " event length: " << eventLength_
741  << "*8 byte\n";
742  }
743 
744  mp->mrewind();
745 
746  if (eventLength_ == 0) {
747  if (verbosity_)
748  cout << "[Matacq " << now() << "] event length is null!" << endl;
749  return;
750  }
751 
752  filepos_t s;
753  mp->msize(s);
754 
755  //number of complete events:
756  const unsigned nEvents = s / eventLength_ / 8;
757 
758  if (nEvents == 0) {
759  if (verbosity_)
760  cout << "[Matacq " << now() << "] File is empty!" << endl;
761  orbitStepMean_ = 0;
762  return;
763  }
764 
765  if (verbosity_ > 1)
766  cout << "[Matacq " << now() << "] File size: " << s << " Number of events: " << nEvents << endl;
767 
768  //position of last complete events:
769  off_t last = (nEvents - 1) * (off_t)eventLength_ * 8;
770  mp->mseek(last,
771  SEEK_SET,
772  "Moving to beginning of last complete "
773  "matacq event");
774  if (!mp->mread((char*)data, headerSize, "Reading matacq header", true)) {
775  LogWarning("Matacq") << "Fast matacq event retrieval failure. "
776  "Falling back to safe retrieval mode.";
777  orbitStepMean_ = 0;
778  }
779 
780  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
781  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
782 
783  if (verbosity_ > 1)
784  cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb << " last event length: " << lastLen << endl;
785 
786  //some consistency check
787  if (lastLen != eventLength_) {
788  LogWarning("Matacq")
789  //throw cms::Exception("Matacq")
790  << "Fast matacq event retrieval failure: it looks like "
791  "the matacq file contains events of different sizes.";
792  // " Falling back to safe retrieval mode.";
793  invalid_ = false; //true;
794  orbitStepMean_ = 112; //0;
795  return;
796  }
797 
798  orbitStepMean_ = (lastOrb - firstOrbit_) / nEvents;
799 
800  if (verbosity_ > 1)
801  cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_ << "\n";
802 
803  invalid_ = false;
804 }

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

806  {
807  if (orb < firstOrbit_)
808  return -1;
809  uint64_t r = orbitStepMean_ != 0 ? (((uint64_t)(orb - firstOrbit_)) / orbitStepMean_) * eventLength_ * 8 : 0;
810  if (verbosity_ > 2)
811  cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb << ": " << r << endl;
812  return r;
813 }

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:1013
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:50
edm::LogWarning
Definition: MessageLogger.h:141
MatacqProducer::mrewind
bool mrewind()
Definition: MatacqProducer.cc:1057
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:991
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:1044