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_ |
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.
MatacqProducer::PosEstimator::PosEstimator | ( | ) | [inline] |
Definition at line 102 of file MatacqProducer.h.
:eventLength_(0), orbitStepMean_(0), firstOrbit_(0), invalid_(true), verbosity_(0) { }
int MatacqProducer::PosEstimator::eventLength | ( | ) | const [inline] |
Definition at line 107 of file MatacqProducer.h.
References eventLength_.
Referenced by MatacqProducer::getMatacqEvent().
{ return eventLength_; }
int MatacqProducer::PosEstimator::firstOrbit | ( | ) | const [inline] |
void MatacqProducer::PosEstimator::init | ( | MatacqProducer * | mp | ) |
Definition at line 681 of file MatacqProducer.cc.
References gather_cfg::cout, data, eventLength_, firstOrbit_, MatacqRawEvent::getDccLen(), MatacqProducer::getOrbitId(), invalid_, prof2calltree::last, MatacqProducer::mread(), MatacqProducer::mrewind(), MatacqProducer::mseek(), MatacqProducer::msize(), nEvents, now(), orbitStepMean_, alignCSCRings::s, and verbosity_.
Referenced by MatacqProducer::getMatacqFile().
{ mp->mrewind(); const size_t headerSize = 8*8; unsigned char data[headerSize]; if(!mp->mread((char*)data, headerSize)){ if(verbosity_) cout << "[Matacq " << now() << "] reached end of file!\n"; firstOrbit_ = eventLength_ = orbitStepMean_ = 0; return; } else{ firstOrbit_ = MatacqRawEvent::getOrbitId(data, headerSize); eventLength_ = MatacqRawEvent::getDccLen(data, headerSize); if(verbosity_>1) cout << "[Matacq " << now() << "] First event orbit: " << firstOrbit_ << " event length: " << eventLength_ << "*8 byte\n"; } mp->mrewind(); if(eventLength_==0){ if(verbosity_) cout << "[Matacq " << now() << "] event length is null!" << endl; return; } filepos_t s; mp->msize(s); //number of complete events: const unsigned nEvents = s/eventLength_/8; if(nEvents==0){ if(verbosity_) cout << "[Matacq " << now() << "] File is empty!" << endl; orbitStepMean_ = 0; return; } if(verbosity_>1) cout << "[Matacq " << now() << "] File size: " << s << " Number of events: " << nEvents << endl; //position of last complete events: off_t last = (nEvents-1)*(off_t)eventLength_*8; mp->mseek(last, SEEK_SET, "Moving to beginning of last complete " "matacq event"); if(!mp->mread((char*) data, headerSize, "Reading matacq header", true)){ LogWarning("Matacq") << "Fast matacq event retrieval failure. " "Falling back to safe retrieval mode."; orbitStepMean_ = 0; } int32_t lastOrb = MatacqRawEvent::getOrbitId(data, headerSize); int32_t lastLen = MatacqRawEvent::getDccLen(data, headerSize); if(verbosity_>1) cout << "[Matacq " << now() << "] Last event orbit: " << lastOrb << " last event length: " << lastLen << endl; //some consistency check if(lastLen!=eventLength_){ LogWarning("Matacq") //throw cms::Exception("Matacq") << "Fast matacq event retrieval failure: it looks like " "the matacq file contains events of different sizes."; // " Falling back to safe retrieval mode."; invalid_ = false; //true; orbitStepMean_ = 112; //0; return; } orbitStepMean_ = (lastOrb - firstOrbit_)/nEvents; if(verbosity_>1) cout << "[Matacq " << now() << "] Orbit step mean: " << orbitStepMean_ << "\n"; invalid_ = false; }
bool MatacqProducer::PosEstimator::invalid | ( | ) | const [inline] |
Definition at line 105 of file MatacqProducer.h.
References invalid_.
Referenced by MatacqProducer::getMatacqEvent().
{ 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 MatacqProducer::getMatacqEvent().
{ if(orb<firstOrbit_) return -1; uint64_t r = orbitStepMean_!=0? (((uint64_t)(orb-firstOrbit_))/orbitStepMean_)*eventLength_*8 :0; if(verbosity_>2) cout << "[Matacq " << now() << "] Estimated Position for orbit " << orb << ": " << r << endl; return r; }
void MatacqProducer::PosEstimator::verbosity | ( | int | verb | ) | [inline] |
Definition at line 109 of file MatacqProducer.h.
References verbosity_.
Referenced by MatacqProducer::MatacqProducer().
{ verbosity_ = verb; }
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.
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().