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

Constructor & Destructor Documentation

MatacqProducer::PosEstimator::PosEstimator ( )
inline

Member Function Documentation

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

Definition at line 109 of file MatacqProducer.h.

References eventLength_.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 110 of file MatacqProducer.h.

References firstOrbit_.

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

Definition at line 682 of file MatacqProducer.cc.

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

Referenced by MatacqProducer::getMatacqFile().

682  {
683  mp->mrewind();
684 
685  const size_t headerSize = 8*8;
686  unsigned char data[headerSize];
687  if(!mp->mread((char*)data, headerSize)){
688  if(verbosity_) cout << "[Matacq " << now() << "] reached end of file!\n";
690  return;
691  } else{
692  firstOrbit_ = MatacqRawEvent::getOrbitId(data, headerSize);
693  eventLength_ = MatacqRawEvent::getDccLen(data, headerSize);
694  if(verbosity_>1) cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_
695  << " event length: " << eventLength_
696  << "*8 byte\n";
697  }
698 
699  mp->mrewind();
700 
701  if(eventLength_==0){
702  if(verbosity_) cout << "[Matacq " << now() << "] event length is null!" << endl;
703  return;
704  }
705 
706  filepos_t s;
707  mp->msize(s);
708 
709  //number of complete events:
710  const unsigned nEvents = s/eventLength_/8;
711 
712  if(nEvents==0){
713  if(verbosity_) cout << "[Matacq " << now() << "] File is empty!" << endl;
714  orbitStepMean_ = 0;
715  return;
716  }
717 
718  if(verbosity_>1) cout << "[Matacq " << now() << "] File size: " << s
719  << " Number of events: " << nEvents << endl;
720 
721  //position of last complete events:
722  off_t last = (nEvents-1)*(off_t)eventLength_*8;
723  mp->mseek(last, SEEK_SET, "Moving to beginning of last complete "
724  "matacq event");
725  if(!mp->mread((char*) data, headerSize, "Reading matacq header", true)){
726  LogWarning("Matacq") << "Fast matacq event retrieval failure. "
727  "Falling back to safe retrieval mode.";
728  orbitStepMean_ = 0;
729  }
730 
731  int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize);
732  int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize);
733 
734  if(verbosity_>1) cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb
735  << " last event length: " << lastLen << endl;
736 
737  //some consistency check
738  if(lastLen!=eventLength_){
739  LogWarning("Matacq")
740  //throw cms::Exception("Matacq")
741  << "Fast matacq event retrieval failure: it looks like "
742  "the matacq file contains events of different sizes.";
743  // " Falling back to safe retrieval mode.";
744  invalid_ = false; //true;
745  orbitStepMean_ = 112; //0;
746  return;
747  }
748 
749  orbitStepMean_ = (lastOrb - firstOrbit_)/nEvents;
750 
751  if(verbosity_>1) cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_
752  << "\n";
753 
754  invalid_ = false;
755 }
uint32_t getOrbitId() const
unsigned getDccLen() const
bool mread(char *buf, size_t n, const char *mess=0, bool peek=false)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static std::string now()
bool mseek(filepos_t offset, int whence=SEEK_SET, const char *mess=0)
tuple cout
Definition: gather_cfg.py:121
UInt_t nEvents
Definition: hcalCalib.cc:42
bool msize(filepos_t &s)
bool MatacqProducer::PosEstimator::invalid ( ) const
inline

Definition at line 107 of file MatacqProducer.h.

References invalid_.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 757 of file MatacqProducer.cc.

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

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

757  {
758  if(orb<firstOrbit_) return -1;
761  :0;
762  if(verbosity_>2) cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb
763  << ": " << r << endl;
764  return r;
765 }
unsigned long long uint64_t
Definition: Time.h:15
static std::string now()
tuple cout
Definition: gather_cfg.py:121
void MatacqProducer::PosEstimator::verbosity ( int  verb)
inline

Definition at line 111 of file MatacqProducer.h.

References verbosity_.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 113 of file MatacqProducer.h.

Referenced by eventLength(), and init().

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 115 of file MatacqProducer.h.

Referenced by firstOrbit(), and init().

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 116 of file MatacqProducer.h.

Referenced by init(), and invalid().

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 114 of file MatacqProducer.h.

Referenced by init().

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 117 of file MatacqProducer.h.

Referenced by init(), and verbosity().