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 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.

Referenced by MatacqProducer::getMatacqEvent().

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

Definition at line 110 of file MatacqProducer.h.

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

Definition at line 738 of file MatacqProducer.cc.

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

Referenced by MatacqProducer::getMatacqFile().

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

Definition at line 107 of file MatacqProducer.h.

References sistrip::invalid_.

Referenced by MatacqProducer::getMatacqEvent().

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

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

813  {
814  if(orb<firstOrbit_) return -1;
817  :0;
818  if(verbosity_>2) cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb
819  << ": " << r << endl;
820  return r;
821 }
unsigned long long uint64_t
Definition: Time.h:15
static std::string now()
void MatacqProducer::PosEstimator::verbosity ( int  verb)
inline

Definition at line 111 of file MatacqProducer.h.

Referenced by MatacqProducer::MatacqProducer().

Member Data Documentation

int MatacqProducer::PosEstimator::eventLength_
private

Definition at line 113 of file MatacqProducer.h.

int MatacqProducer::PosEstimator::firstOrbit_
private

Definition at line 115 of file MatacqProducer.h.

bool MatacqProducer::PosEstimator::invalid_
private

Definition at line 116 of file MatacqProducer.h.

int MatacqProducer::PosEstimator::orbitStepMean_
private

Definition at line 114 of file MatacqProducer.h.

int MatacqProducer::PosEstimator::verbosity_
private

Definition at line 117 of file MatacqProducer.h.