CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 105 of file MatacqProducer.h.

Constructor & Destructor Documentation

MatacqProducer::PosEstimator::PosEstimator ( )
inline

Member Function Documentation

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

Definition at line 115 of file MatacqProducer.h.

References eventLength_.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 116 of file MatacqProducer.h.

References firstOrbit_.

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

Definition at line 598 of file MatacqProducer.cc.

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

Referenced by MatacqProducer::getMatacqFile().

598  {
599  mp->mrewind();
600 
601  const size_t headerSize = 8*8;
602  unsigned char data[headerSize];
603  if(!mp->mread((char*)data, headerSize)){
604  if(verbosity_) cout << "[Matacq] reached end of file!\n";
606  return;
607  } else{
608  firstOrbit_ = MatacqRawEvent::getOrbitId(data, headerSize);
609  eventLength_ = MatacqRawEvent::getDccLen(data, headerSize);
610  if(verbosity_>1) cout << "[Matacq] First event orbit: " << firstOrbit_
611  << " event length: " << eventLength_
612  << "*8 byte\n";
613  }
614 
615  mp->mrewind();
616 
617  if(eventLength_==0){
618  if(verbosity_) cout << "[Matacq] event length is null!" << endl;
619  return;
620  }
621 
622  filepos_t s;
623  mp->msize(s);
624 
625  //number of complete events:
626  const unsigned nEvents = s/eventLength_/8;
627 
628  if(nEvents==0){
629  if(verbosity_) cout << "[Matacq] File is empty!" << endl;
630  orbitStepMean_ = 0;
631  return;
632  }
633 
634  if(verbosity_>1) cout << "[Matacq] File size: " << s
635  << " Number of events: " << nEvents << endl;
636 
637  //position of last complete events:
638  off_t last = (nEvents-1)*(off_t)eventLength_*8;
639  mp->mseek(last, SEEK_SET, "Moving to beginning of last complete "
640  "matacq event");
641  if(!mp->mread((char*) data, headerSize, "Reading matacq header", true)){
642  LogWarning("IncorrectLaserEvent") << "Fast matacq event retrieval failure. "
643  "Falling back to safe retrieval mode.";
644  orbitStepMean_ = 0;
645  }
646 
647  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
648  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
649 
650  if(verbosity_>1) cout << "[Matacq] Last event orbit: " << lastOrb
651  << " last event length: " << lastLen << endl;
652 
653  //some consistency check
654  if(lastLen!=eventLength_){
655  LogWarning("IncorrectLaserEvent")
656  << "Fast matacq event retrieval failure: it looks like "
657  "the matacq file contains events of different sizes. Falling back to "
658  "safe retrieval mode.";
659  invalid_ = true;
660  orbitStepMean_ = 0;
661  return;
662  }
663 
664  orbitStepMean_ = (lastOrb - firstOrbit_)/nEvents;
665 
666  if(verbosity_>1) cout << "[Matacq] Orbit step mean: " << orbitStepMean_
667  << "\n";
668 
669  invalid_ = false;
670 }
uint32_t getOrbitId() const
unsigned getDccLen() const
bool mread(char *buf, size_t n, const char *mess=0, bool peek=false)
bool mseek(filepos_t offset, int whence=SEEK_SET, const char *mess=0)
IOOffset filepos_t
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
UInt_t nEvents
Definition: hcalCalib.cc:43
bool msize(filepos_t &s)
bool MatacqProducer::PosEstimator::invalid ( ) const
inline

Definition at line 113 of file MatacqProducer.h.

References invalid_.

Referenced by MatacqProducer::getMatacqEvent().

113 { return invalid_; }
int64_t MatacqProducer::PosEstimator::pos ( int  orb) const

Definition at line 672 of file MatacqProducer.cc.

References gather_cfg::cout, csvReporter::r, and MatacqProducer::verbosity_.

Referenced by python.Vispa.Gui.PortWidget.PortWidget::connectionPoint(), python.Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), MatacqProducer::getMatacqEvent(), and python.Vispa.Gui.VispaWidget.VispaWidget::paintEvent().

672  {
673  if(orb<firstOrbit_) return -1;
676  :0;
677  if(verbosity_>2) cout << "[Matacq] Estimated Position for orbit " << orb
678  << ": " << r << endl;
679  return r;
680 }
unsigned long long uint64_t
Definition: Time.h:15
tuple cout
Definition: gather_cfg.py:41
void MatacqProducer::PosEstimator::verbosity ( int  verb)
inline

Definition at line 117 of file MatacqProducer.h.

References verbosity_.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 119 of file MatacqProducer.h.

Referenced by eventLength(), and init().

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 121 of file MatacqProducer.h.

Referenced by firstOrbit(), and init().

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 122 of file MatacqProducer.h.

Referenced by init(), and invalid().

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 120 of file MatacqProducer.h.

Referenced by init().

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 123 of file MatacqProducer.h.

Referenced by init(), and verbosity().