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 680 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().

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

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