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

Constructor & Destructor Documentation

MatacqProducer::PosEstimator::PosEstimator ( )
inline

Member Function Documentation

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

Definition at line 107 of file MatacqProducer.h.

References eventLength_.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 108 of file MatacqProducer.h.

References firstOrbit_.

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

Definition at line 681 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().

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

Definition at line 105 of file MatacqProducer.h.

References invalid_.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 756 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().

756  {
757  if(orb<firstOrbit_) return -1;
760  :0;
761  if(verbosity_>2) cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb
762  << ": " << r << endl;
763  return r;
764 }
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 109 of file MatacqProducer.h.

References verbosity_.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 111 of file MatacqProducer.h.

Referenced by eventLength(), and init().

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 113 of file MatacqProducer.h.

Referenced by firstOrbit(), and init().

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 114 of file MatacqProducer.h.

Referenced by init(), and invalid().

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 112 of file MatacqProducer.h.

Referenced by init().

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 115 of file MatacqProducer.h.

Referenced by init(), and verbosity().