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 Member Functions | Private Attributes
edm::DaqSource Class Reference

#include <DaqSource.h>

Inheritance diagram for edm::DaqSource:
edm::InputSource evf::ModuleWeb edm::ProductRegistryHelper

Public Member Functions

 DaqSource (const ParameterSet &pset, const InputSourceDescription &desc)
 
virtual ~DaqSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool const primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryID const & processHistoryID () const
 Accessor for the input process history ID of the current run. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi ()
 Read next luminosity block. More...
 
void readAndCacheRun ()
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
void wakeUp ()
 Wake up the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Private Member Functions

virtual void closeBackDoor ()
 
void defaultWebPage (xgi::Input *in, xgi::Output *out)
 
virtual ItemType getNextItemType ()
 
virtual void openBackDoor (unsigned int)
 
virtual void publish (xdata::InfoSpace *)
 
virtual void publishToXmas (xdata::InfoSpace *)
 
virtual EventPrincipalreadEvent_ ()
 
virtual EventPrincipalreadIt (EventID const &eventID)
 
virtual boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
 
virtual boost::shared_ptr
< RunAuxiliary
readRunAuxiliary_ ()
 
virtual void setLumi (LuminosityBlockNumber_t lb)
 
virtual void setRun (RunNumber_t r)
 
virtual void signalWaitingThreadAndBlock ()
 
virtual void skip (int offset)
 
- Private Member Functions inherited from evf::ModuleWeb
 ModuleWeb (const std::string &)
 
virtual ~ModuleWeb ()
 

Private Attributes

bool alignLsToLast_
 
pthread_cond_t cond_
 
int count
 
bool eventCached_
 
unsigned int eventCounter_
 
bool fakeLSid_
 
bool goToStopping
 
xdata::InfoSpace * is_
 
bool keepUsingPsidFromTrigger_
 
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
 
xdata::UnsignedInteger32 * lastLumiUsingEol_
 
xdata::Boolean * lsTimedOut_
 
xdata::Boolean * lsToBeRecovered_
 
LuminosityBlockNumber_t luminosityBlockNumber_
 
xdata::UnsignedInteger32 * lumiSectionIndex_
 
unsigned int lumiSegmentSizeInEvents_
 
xdata::InfoSpace * mis_
 
pthread_mutex_t mutex_
 
bool newLumi_
 
bool newRun_
 
bool noMoreEvents_
 
xdata::UnsignedInteger32 * prescaleSetIndex_
 
DaqBaseReaderreader_
 
RunNumber_t runNumber_
 
pthread_mutex_t signal_lock_
 
unsigned int thisEventLSid
 
bool useEventCounter_
 
- Private Attributes inherited from evf::ModuleWeb
std::string moduleName_
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipal *const eventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setLumiPrematurelyRead ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setRunPrematurelyRead ()
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Definition at line 34 of file DaqSource.h.

Constructor & Destructor Documentation

DaqSource::DaqSource ( const ParameterSet pset,
const InputSourceDescription desc 
)
explicit

Definition at line 57 of file DaqSource.cc.

References edm::Timestamp::beginOfTime(), cms::Exception::category(), cond_, count, reco::get(), edm::ParameterSet::getUntrackedParameter(), mutex_, reader_, runNumber_, DaqBaseReader::setRunNumber(), edm::InputSource::setTimestamp(), and signal_lock_.

59  : InputSource(pset,desc)
60  , evf::ModuleWeb("DaqSource")
61  , reader_(0)
62  , lumiSegmentSizeInEvents_(pset.getUntrackedParameter<unsigned int>("evtsPerLS",0))
63  , useEventCounter_(pset.getUntrackedParameter<bool>("useEventCounter",false))
64  , eventCounter_(0)
65  , keepUsingPsidFromTrigger_(pset.getUntrackedParameter<bool>("keepUsingPsidFromTrigger",false))
69  , noMoreEvents_(false)
70  , newRun_(true)
71  , newLumi_(true)
72  , eventCached_(false)
73  , alignLsToLast_(false)
74  , is_(0)
75  , mis_(0)
76  , thisEventLSid(0)
77  , goToStopping(false)
78  {
79  count = 0;
80  pthread_mutex_init(&mutex_,0);
81  pthread_mutex_init(&signal_lock_,0);
82  pthread_cond_init(&cond_,0);
83  produces<FEDRawDataCollection>();
85 
86  // Instantiate the requested data source
87  std::string reader = pset.getUntrackedParameter<std::string>("readerPluginName");
88 
89  try{
90  reader_=
91  DaqReaderPluginFactory::get()->create(reader,
92  pset.getUntrackedParameter<ParameterSet>("readerPset"));
94  }
95  catch(edm::Exception &e) {
96  if(e.category() == "Configuration" && reader_ == 0) {
97  reader_ = DaqReaderPluginFactoryU::get()->create(reader);
98  if(reader_ == 0) throw;
100  }
101  else {
102  throw;
103  }
104  }
105  }
DaqBaseReader * reader_
Definition: DaqSource.h:61
xdata::InfoSpace * mis_
Definition: DaqSource.h:86
static LuminosityBlockID firstValidLuminosityBlock()
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:69
unsigned int eventCounter_
Definition: DaqSource.h:64
void setTimestamp(Timestamp const &theTime)
To set the current time, as seen by the input source.
Definition: InputSource.h:297
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:582
RunNumber_t runNumber_
Definition: DaqSource.h:68
static RunID firstValidRun()
Definition: RunID.h:82
pthread_cond_t cond_
Definition: DaqSource.h:78
pthread_mutex_t signal_lock_
Definition: DaqSource.h:77
bool fakeLSid_
Definition: DaqSource.h:66
bool keepUsingPsidFromTrigger_
Definition: DaqSource.h:65
bool goToStopping
Definition: DaqSource.h:89
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:588
unsigned int lumiSegmentSizeInEvents_
Definition: DaqSource.h:62
bool useEventCounter_
Definition: DaqSource.h:63
static Timestamp const & beginOfTime()
Definition: Timestamp.cc:96
pthread_mutex_t mutex_
Definition: DaqSource.h:76
virtual void setRunNumber(edm::RunNumber_t runNumber)
set the run number
Definition: DaqBaseReader.h:37
bool eventCached_
Definition: DaqSource.h:73
unsigned int thisEventLSid
Definition: DaqSource.h:88
bool noMoreEvents_
Definition: DaqSource.h:70
InputSource(ParameterSet const &, InputSourceDescription const &)
Constructor.
Definition: InputSource.cc:74
xdata::InfoSpace * is_
Definition: DaqSource.h:85
T get(const Candidate &c)
Definition: component.h:56
bool alignLsToLast_
Definition: DaqSource.h:74
std::string category() const
Definition: Exception.cc:74
DaqSource::~DaqSource ( )
virtual

Definition at line 108 of file DaqSource.cc.

References reader_.

108  {
109  delete reader_;
110  }
DaqBaseReader * reader_
Definition: DaqSource.h:61

Member Function Documentation

void DaqSource::closeBackDoor ( )
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 475 of file DaqSource.cc.

References cond_, count, lsTimedOut_, mutex_, and signal_lock_.

476  {
477  count--;
478  pthread_cond_signal(&cond_);
479  pthread_mutex_unlock(&mutex_);
480  pthread_mutex_lock(&signal_lock_);
481  lsTimedOut_->value_ = false;
482  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:83
pthread_cond_t cond_
Definition: DaqSource.h:78
pthread_mutex_t signal_lock_
Definition: DaqSource.h:77
pthread_mutex_t mutex_
Definition: DaqSource.h:76
void DaqSource::defaultWebPage ( xgi::Input in,
xgi::Output out 
)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 497 of file DaqSource.cc.

References cmsCodeRules.cppFunctionSkipper::exception, edm::first(), goToStopping, collect_tpl::input, evf::ModuleWeb::moduleName_, path(), pos, o2o::query, edm::second(), and EcalElecEmulTccFlatFileProducerFromTPG_cfg::tokens.

498  {
499  std::string path;
500  std::string urn;
501  std::string mname;
502  std::string query;
503  std::string original_referrer_;
504  try
505  {
506  cgicc::Cgicc cgi(in);
507  if ( xgi::Utils::hasFormElement(cgi,"gotostopping") )
508  {
509  goToStopping=true;
510  }
511  if ( xgi::Utils::hasFormElement(cgi,"module") )
512  mname = xgi::Utils::getFormElement(cgi, "module")->getValue();
513  cgicc::CgiEnvironment cgie(in);
514  if(original_referrer_ == "")
515  original_referrer_ = cgie.getReferrer();
516  path = cgie.getPathInfo();
517  query = cgie.getQueryString();
518  }
519  catch (const std::exception & e)
520  {
521  // don't care if it did not work
522  }
523 
524  using std::endl;
525  *out << "<html>" << endl;
526  *out << "<head>" << endl;
527 
528 
529  *out << "<STYLE type=\"text/css\"> #T1 {border-width: 2px; border: solid blue; text-align: center} </STYLE> " << endl;
530  *out << "<link type=\"text/css\" rel=\"stylesheet\"";
531  *out << " href=\"/" << urn
532  << "/styles.css\"/>" << endl;
533 
534  *out << "<title>" << moduleName_
535  << " MAIN</title>" << endl;
536 
537  *out << "</head>" << endl;
538  *out << "<body onload=\"loadXMLDoc()\">" << endl;
539  *out << "<table border=\"0\" width=\"100%\">" << endl;
540  *out << "<tr>" << endl;
541  *out << " <td align=\"left\">" << endl;
542  *out << " <img" << endl;
543  *out << " align=\"middle\"" << endl;
544  *out << " src=\"/evf/images/bugicon.jpg\"" << endl;
545  *out << " alt=\"main\"" << endl;
546  *out << " width=\"90\"" << endl;
547  *out << " height=\"64\"" << endl;
548  *out << " border=\"\"/>" << endl;
549  *out << " <b>" << endl;
550  *out << moduleName_ << endl;
551  *out << " </b>" << endl;
552  *out << " </td>" << endl;
553  *out << " <td width=\"32\">" << endl;
554  *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
555  *out << " <img" << endl;
556  *out << " align=\"middle\"" << endl;
557  *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
558  *out << " alt=\"HyperDAQ\"" << endl;
559  *out << " width=\"32\"" << endl;
560  *out << " height=\"32\"" << endl;
561  *out << " border=\"\"/>" << endl;
562  *out << " </a>" << endl;
563  *out << " </td>" << endl;
564  *out << " <td width=\"32\">" << endl;
565  *out << " </td>" << endl;
566  *out << " <td width=\"32\">" << endl;
567  *out << " <a href=\"" << original_referrer_ << "\">" << endl;
568  *out << " <img" << endl;
569  *out << " align=\"middle\"" << endl;
570  *out << " src=\"/evf/images/spoticon.jpg\"" << endl;
571  *out << " alt=\"main\"" << endl;
572  *out << " width=\"32\"" << endl;
573  *out << " height=\"32\"" << endl;
574  *out << " border=\"\"/>" << endl;
575  *out << " </a>" << endl;
576  *out << " </td>" << endl;
577  *out << "</tr>" << endl;
578  *out << "</table>" << endl;
579 
580  *out << "<hr/>" << endl;
581 
582  *out << cgicc::form().set("method","GET").set("action", path )
583  << std::endl;
584  boost::char_separator<char> sep("&");
585  boost::tokenizer<boost::char_separator<char> > tokens(query, sep);
586  for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
587  tok_iter != tokens.end(); ++tok_iter){
588  size_t pos = (*tok_iter).find_first_of("=");
589  if(pos != std::string::npos){
590  std::string first = (*tok_iter).substr(0 , pos);
591  std::string second = (*tok_iter).substr(pos+1, (*tok_iter).length()-pos-1);
592  *out << cgicc::input().set("type","hidden").set("name",first).set("value", second)
593  << std::endl;
594  }
595  }
596 
597  *out << cgicc::input().set("type","hidden").set("name","gotostopping").set("value","true")
598  << std::endl;
599  *out << cgicc::input().set("type","submit").set("value","Go To Stopping") << std::endl;
600  *out << cgicc::form() << std::endl;
601 
602  *out << "</body>" << endl;
603  *out << "</html>" << endl;
604  }
boost::tokenizer< boost::char_separator< char > > tokenizer
int path() const
Definition: HLTadd.h:3
U second(std::pair< T, U > const &p)
bool goToStopping
Definition: DaqSource.h:89
std::string moduleName_
Definition: ModuleWeb.h:23
tuple input
Definition: collect_tpl.py:10
tuple out
Definition: dbtoconf.py:99
tuple query
Definition: o2o.py:269
T first(std::pair< T, U > const &p)
InputSource::ItemType DaqSource::getNextItemType ( )
privatevirtual

Implements edm::InputSource.

Definition at line 119 of file DaqSource.cc.

References alignLsToLast_, cond_, FEDRawData::data(), edm::EventID::event(), eventCached_, eventCounter_, edm::InputSource::eventPrincipalCache(), evf::evtn::evm_board_sense(), edm::hlt::Exception, fakeLSid_, FEDRawDataCollection::FEDData(), edm::EventPrincipal::fillEventPrincipal(), DaqBaseReader::fillRawData(), evf::evtn::getevtyp(), evf::evtn::getfdlbx(), evf::evtn::getfdlpsc(), evf::evtn::getgpshigh(), evf::evtn::getgpslow(), evf::evtn::getlbn(), evf::evtn::getorbit(), goToStopping, evf::evtn::gtpe_board_sense(), evf::evtn::gtpe_getbx(), evf::evtn::gtpe_getlbn(), evf::evtn::gtpe_getorbit(), edm::daqsource::gtpeId_, edm::daqsource::gtpEvmId_, edm::EventAuxiliary::invalidBunchXing, edm::EventAuxiliary::invalidStoreNumber, edm::Timestamp::invalidTimestamp(), edm::InputSource::IsEvent, edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, keepUsingPsidFromTrigger_, lastLumiPrescaleIndex_, lastLumiUsingEol_, edm::errors::LogicError, lsToBeRecovered_, edm::InputSource::luminosityBlock(), edm::InputSource::luminosityBlockAuxiliary(), luminosityBlockNumber_, edm::InputSource::luminosityBlockPrincipal(), lumiSectionIndex_, lumiSegmentSizeInEvents_, edm::InputSource::moduleDescription(), mutex_, newLumi_, newRun_, noMoreEvents_, edm::EventAuxiliary::PhysicsTrigger, prescaleSetIndex_, edm::InputSource::processGUID(), edm::InputSource::readAndCacheLumi(), reader_, edm::InputSource::resetLuminosityBlockAuxiliary(), runNumber_, edm::InputSource::setLuminosityBlockAuxiliary(), edm::InputSource::setLumiPrematurelyRead(), edm::InputSource::setTimestamp(), signalWaitingThreadAndBlock(), FEDRawData::size(), thisEventLSid, cond::rpcobgas::time, edm::InputSource::timestamp(), edm::EventAuxiliary::Undefined, and useEventCounter_.

119  {
120  // std::cout << getpid() << " enter getNextItemType " << std::endl;
121  if(goToStopping){noMoreEvents_ = true; goToStopping=false;}
122  if (noMoreEvents_) {
123  pthread_mutex_lock(&mutex_);
124  pthread_cond_signal(&cond_);
125  pthread_mutex_unlock(&mutex_);
126  return IsStop;
127  }
128  if (newRun_) {
129  return IsRun;
130  }
132  // std::cout << "newLumi & lumiblock valid " << std::endl;
133  return IsLumi;
134  }
135  if (alignLsToLast_) { //here we are recovering from a gap in Ls number so an event may already be cached but
136  // we hold onto it until we have issued all the necessary endLumi/beginLumi
137 // std::cout << getpid() << "alignLsToLast was set and ls number is "
138 // << luminosityBlockNumber_ << " before signaling" << std::endl;
141 // std::cout << getpid() << "alignLsToLast signaled and incremented "
142 // << luminosityBlockNumber_ << " eventcached "
143 // << eventCached_ << std::endl;
144  newLumi_ = true;
148  {
149  alignLsToLast_ = false;
150  }
152  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
154 
157  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
158  }
159  return IsLumi;
160  }
161  if (eventCached_) {
162  // std::cout << "read event already cached " << std::endl;
163  return IsEvent;
164  }
165  if(reader_ == 0) {
167  << "DaqSource is used without a reader. Check your configuration !";
168  }
169  EventID eventId;
170  TimeValue_t time = 0LL;
171  timeval stv;
172  gettimeofday(&stv,0);
173  time = stv.tv_sec;
174  time = (time << 32) + stv.tv_usec;
175  Timestamp tstamp(time);
176 
177  int bunchCrossing = EventAuxiliary::invalidBunchXing;
178  int orbitNumber = EventAuxiliary::invalidBunchXing;
179 
180  // pass a 0 pointer to fillRawData()!
181  FEDRawDataCollection* fedCollection(0);
182 
184 
185  // let reader_ fill the fedCollection
186  int retval = reader_->fillRawData(eventId, tstamp, fedCollection);
187  if(retval==0) {
188  // fillRawData() failed, clean up the fedCollection in case it was allocated!
189  if (0 != fedCollection) delete fedCollection;
190  noMoreEvents_ = true;
191  pthread_mutex_lock(&mutex_);
192  pthread_cond_signal(&cond_);
193  pthread_mutex_unlock(&mutex_);
194  return IsStop;
195  }
196  else if(retval<0)
197  {
198 
199  unsigned int nextLsFromSignal = (-1)*retval+1;
200 // std::cout << getpid() << "::got end-of-lumi for " << (-1)*retval
201 // << " was " << luminosityBlockNumber_ << std::endl;
202  if(luminosityBlockNumber_ == (nextLsFromSignal-1) )
203  {
204  lastLumiUsingEol_->value_ = nextLsFromSignal;
205  if(lsToBeRecovered_->value_){
206 // std::cout << getpid() << "eol::recover ls::for " << (-1)*retval << std::endl;
209  newLumi_ = true;
212  thisEventLSid = nextLsFromSignal - 1;
214  alignLsToLast_ = true;
215  // std::cout << getpid() << "eol::::alignLsToLast_ " << alignLsToLast_ << std::endl;
216  }
217  else{
218  // std::cout << getpid() << "eol::realign ls::for " << (-1)*retval << std::endl;
219  luminosityBlockNumber_ = nextLsFromSignal;
220  newLumi_ = true;
223  }
224  }
225  else if(nextLsFromSignal >(luminosityBlockNumber_+100) ) {
226  edm::LogError("DaqSource") << "Got EOL event with value " << retval
227  << " nextLS would be " << nextLsFromSignal
228  << " while we expected " << luminosityBlockNumber_+1 << " - disregarding... ";
229  }
230  // else
231  // std::cout << getpid() << "::skipping end-of-lumi for " << (-1)*retval << std::endl;
232  }
233  else
234  {
235  if (eventId.event() == 0) {
237  << "The reader used with DaqSource has returned an invalid (zero) event number!\n"
238  << "Event numbers must begin at 1, not 0.";
239  }
240  EventSourceSentry(*this);
241  setTimestamp(tstamp);
242 
243  unsigned char *gtpFedAddr = fedCollection->FEDData(daqsource::gtpEvmId_).size()!=0 ? fedCollection->FEDData(daqsource::gtpEvmId_).data() : 0;
244  uint32_t gtpsize = 0;
245  if(gtpFedAddr !=0) gtpsize = fedCollection->FEDData(daqsource::gtpEvmId_).size();
246  unsigned char *gtpeFedAddr = fedCollection->FEDData(daqsource::gtpeId_).size()!=0 ? fedCollection->FEDData(daqsource::gtpeId_).data() : 0;
247 
248  unsigned int nextFakeLs = 0;
249  eventCounter_++;
251  (nextFakeLs = useEventCounter_ ? ((eventCounter_-1)/lumiSegmentSizeInEvents_ + 1) :
252  ((eventId.event() - 1)/lumiSegmentSizeInEvents_ + 1))) {
253  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
254  prescaleSetIndex_->value_ = 0; // since we do not know better but we want to be able to run
255 
256  if(luminosityBlockNumber_ == nextFakeLs-1)
258  luminosityBlockNumber_ = nextFakeLs;
259  thisEventLSid = nextFakeLs-1;
260  newLumi_ = true;
264  gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
265  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
266  }
267  }
268  else if(!fakeLSid_){
269 
270  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
271  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
272  thisEventLSid = evf::evtn::getlbn(gtpFedAddr);
273  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
276  // we got here in a running process and some Ls might have been skipped so set the flag,
277  // increase by one, check and if appropriate set the flag then continue
278  if(lsToBeRecovered_->value_){
279  // std::cout << getpid() << "eve::recover ls::for " << thisEventLSid << std::endl;
282  newLumi_ = true;
286  // std::cout << getpid() << "eve::::alignLsToLast_ " << alignLsToLast_ << std::endl;
287  }
288  else{ // we got here because the process was restarted. just realign the ls id and proceed with this event
289  // std::cout << getpid() << "eve::realign ls::for " << thisEventLSid << std::endl;
291  newLumi_ = true;
294  lsToBeRecovered_->value_ = true;
295  }
296  }
297  }
298  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
299  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
300  thisEventLSid = evf::evtn::gtpe_getlbn(gtpeFedAddr);
301  prescaleSetIndex_->value_ = 0; //waiting to get a PS index from gtpe
307  newLumi_ = true;
310  }
311  }
312  }
313  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
314  bunchCrossing = int(evf::evtn::getfdlbx(gtpFedAddr));
315  orbitNumber = int(evf::evtn::getorbit(gtpFedAddr));
316  TimeValue_t time = evf::evtn::getgpshigh(gtpFedAddr);
317  time = (time << 32) + evf::evtn::getgpslow(gtpFedAddr);
318  Timestamp tstamp(time);
319  setTimestamp(tstamp);
320  }
321  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
322  bunchCrossing = int(evf::evtn::gtpe_getbx(gtpeFedAddr));
323  orbitNumber = int(evf::evtn::gtpe_getorbit(gtpeFedAddr));
324  }
325  }
326 
327  // std::cout << "lumiblockaux = " << luminosityBlockAuxiliary() << std::endl;
328  // If there is no luminosity block principal, make one.
330  newLumi_ = true;
331  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
333 
336  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
337  }
338  // std::cout << "here retval = " << retval << std::endl;
339  if(retval<0){
340  // std::cout << getpid() << " returning from getnextitem because retval < 0 - IsLumi "
341  // << IsLumi << std::endl;
342  if(newLumi_) return IsLumi; else return getNextItemType();
343  }
344 
345  // make a brand new event
346  eventId = EventID(runNumber_,thisEventLSid+1, eventId.event());
347  std::auto_ptr<EventAuxiliary> eventAux(
348  new EventAuxiliary(eventId, processGUID(),
349  timestamp(),
350  true,
351  evttype,
352  bunchCrossing,
354  orbitNumber));
356  eventCached_ = true;
357 
358  // have fedCollection managed by a std::auto_ptr<>
359  std::auto_ptr<FEDRawDataCollection> bare_product(fedCollection);
360 
361  std::auto_ptr<Event> e(new Event(*eventPrincipalCache(), moduleDescription()));
362  // put the fed collection into the transient event store
363  e->put(bare_product);
364  // The commit is needed to complete the "put" transaction.
365  e->commit_();
366  if (newLumi_) {
367  return IsLumi;
368  }
369  return IsEvent;
370  }
DaqBaseReader * reader_
Definition: DaqSource.h:61
unsigned int getgpshigh(const unsigned char *)
EventPrincipal *const eventPrincipalCache()
Definition: InputSource.cc:156
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:69
unsigned int getfdlbx(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
void readAndCacheLumi()
Read next luminosity block.
Definition: InputSource.cc:309
virtual ItemType getNextItemType()
Definition: DaqSource.cc:119
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:79
unsigned int eventCounter_
Definition: DaqSource.h:64
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:84
boost::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:242
void setTimestamp(Timestamp const &theTime)
To set the current time, as seen by the input source.
Definition: InputSource.h:297
xdata::UnsignedInteger32 * lastLumiUsingEol_
Definition: DaqSource.h:82
RunNumber_t runNumber_
Definition: DaqSource.h:68
unsigned int getfdlpsc(const unsigned char *)
pthread_cond_t cond_
Definition: DaqSource.h:78
boost::shared_ptr< LuminosityBlockPrincipal > const luminosityBlockPrincipal() const
Definition: InputSource.cc:280
static unsigned int gtpeId_
Definition: DaqSource.cc:53
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:196
void resetLuminosityBlockAuxiliary() const
Definition: InputSource.h:306
static int const invalidBunchXing
unsigned int getlbn(const unsigned char *)
bool fakeLSid_
Definition: DaqSource.h:66
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:80
void setLuminosityBlockAuxiliary(LuminosityBlockAuxiliary *lbp)
Definition: InputSource.h:302
virtual void signalWaitingThreadAndBlock()
Definition: DaqSource.cc:484
bool keepUsingPsidFromTrigger_
Definition: DaqSource.h:65
unsigned long long TimeValue_t
Definition: Timestamp.h:27
bool evm_board_sense(const unsigned char *p, size_t size)
bool goToStopping
Definition: DaqSource.h:89
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:588
unsigned int getorbit(const unsigned char *)
static unsigned int gtpEvmId_
Definition: DaqSource.cc:52
void fillEventPrincipal(std::auto_ptr< EventAuxiliary > aux, boost::shared_ptr< LuminosityBlockPrincipal > lbp, boost::shared_ptr< EventSelectionIDVector > eventSelectionIDs=boost::shared_ptr< EventSelectionIDVector >(new EventSelectionIDVector), boost::shared_ptr< BranchListIndexes > branchListIndexes=boost::shared_ptr< BranchListIndexes >(new BranchListIndexes), boost::shared_ptr< BranchMapper > mapper=boost::shared_ptr< BranchMapper >(new BranchMapper), boost::shared_ptr< DelayedReader > rtrv=boost::shared_ptr< DelayedReader >(new NoDelayedReader))
unsigned int gtpe_getorbit(const unsigned char *)
static Timestamp const & invalidTimestamp()
Definition: Timestamp.cc:83
void setLumiPrematurelyRead()
Definition: InputSource.h:322
virtual int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)=0
unsigned int lumiSegmentSizeInEvents_
Definition: DaqSource.h:62
Timestamp const & timestamp() const
Accessor for the current time, as seen by the input source.
Definition: InputSource.h:221
unsigned int getevtyp(const unsigned char *)
bool useEventCounter_
Definition: DaqSource.h:63
static int const invalidStoreNumber
unsigned int gtpe_getbx(const unsigned char *)
pthread_mutex_t mutex_
Definition: DaqSource.h:76
bool eventCached_
Definition: DaqSource.h:73
unsigned int thisEventLSid
Definition: DaqSource.h:88
ModuleDescription const & moduleDescription() const
Accessor for &#39;module&#39; description.
Definition: InputSource.h:187
unsigned int gtpe_getlbn(const unsigned char *)
bool noMoreEvents_
Definition: DaqSource.h:70
unsigned int getgpslow(const unsigned char *)
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:81
bool alignLsToLast_
Definition: DaqSource.h:74
void DaqSource::openBackDoor ( unsigned int  timeout_sec)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 454 of file DaqSource.cc.

References cond_, count, lsTimedOut_, mutex_, NULL, and signal_lock_.

455  {
456  count++;
457  if(count==2) throw;
458  pthread_mutex_lock(&mutex_);
459  pthread_mutex_unlock(&signal_lock_);
460  timespec ts;
461 #if _POSIX_TIMERS > 0
462  clock_gettime(CLOCK_REALTIME, &ts);
463 #else
464  struct timeval tv;
465  gettimeofday(&tv, NULL);
466  ts.tv_sec = tv.tv_sec + 0;
467  ts.tv_nsec = 0;
468 #endif
469  ts.tv_sec += timeout_sec;
470 
471  int rc = pthread_cond_timedwait(&cond_, &mutex_, &ts);
472  if(rc == ETIMEDOUT) lsTimedOut_->value_ = true;
473  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:83
#define NULL
Definition: scimark2.h:8
pthread_cond_t cond_
Definition: DaqSource.h:78
pthread_mutex_t signal_lock_
Definition: DaqSource.h:77
pthread_mutex_t mutex_
Definition: DaqSource.h:76
void DaqSource::publish ( xdata::InfoSpace *  is)
privatevirtual

Implements evf::ModuleWeb.

Definition at line 439 of file DaqSource.cc.

References is_, lastLumiPrescaleIndex_, lastLumiUsingEol_, lsTimedOut_, lsToBeRecovered_, lumiSectionIndex_, and prescaleSetIndex_.

440  {
441  is_ = is;
442  lumiSectionIndex_ = (xdata::UnsignedInteger32*)is_->find("lumiSectionIndex");
443  prescaleSetIndex_ = (xdata::UnsignedInteger32*)is_->find("prescaleSetIndex");
444  lastLumiPrescaleIndex_ = (xdata::UnsignedInteger32*)is_->find("lastLumiPrescaleIndex");
445  lastLumiUsingEol_ = (xdata::UnsignedInteger32*)is_->find("lastLumiUsingEol");
446  lsTimedOut_ = (xdata::Boolean*)is_->find("lsTimedOut");
447  lsToBeRecovered_ = (xdata::Boolean*)is_->find("lsToBeRecovered");
448  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:83
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:79
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:84
xdata::UnsignedInteger32 * lastLumiUsingEol_
Definition: DaqSource.h:82
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:80
xdata::InfoSpace * is_
Definition: DaqSource.h:85
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:81
void DaqSource::publishToXmas ( xdata::InfoSpace *  is)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 449 of file DaqSource.cc.

References mis_.

450  {
451  mis_ = is;
452  }
xdata::InfoSpace * mis_
Definition: DaqSource.h:86
EventPrincipal * DaqSource::readEvent_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 404 of file DaqSource.cc.

References eventCached_, edm::InputSource::eventPrincipalCache(), newLumi_, newRun_, and noMoreEvents_.

404  {
405  // std::cout << "assert not newRun " << std::endl;
406  assert(!newRun_);
407  // std::cout << "assert not newLumi " << std::endl;
408  assert(!newLumi_);
409  // std::cout << "assert not noMoreEvents " << std::endl;
410  assert(!noMoreEvents_);
411  // std::cout << "assert eventCached " << std::endl;
412  assert(eventCached_);
413  // std::cout << "asserts done " << std::endl;
414  eventCached_ = false;
415  return eventPrincipalCache();
416  }
EventPrincipal *const eventPrincipalCache()
Definition: InputSource.cc:156
bool eventCached_
Definition: DaqSource.h:73
bool noMoreEvents_
Definition: DaqSource.h:70
EventPrincipal * DaqSource::readIt ( EventID const &  eventID)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 426 of file DaqSource.cc.

References edm::hlt::Exception, and edm::errors::LogicError.

426  {
427  throw edm::Exception(errors::LogicError,"DaqSource::readIt(EventID const& eventID)")
428  << "Random access read cannot be used for DaqSource.\n"
429  << "Contact a Framework developer.\n";
430  }
boost::shared_ptr< LuminosityBlockAuxiliary > DaqSource::readLuminosityBlockAuxiliary_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 392 of file DaqSource.cc.

References edm::InputSource::luminosityBlockAuxiliary(), newLumi_, newRun_, and noMoreEvents_.

392  {
393  assert(!newRun_);
394  assert(newLumi_);
395  assert(!noMoreEvents_);
396  assert(luminosityBlockAuxiliary());
397  //assert(eventCached_); //the event may or may not be cached - rely on
398  // the call to getNextItemType to detect that.
399  newLumi_ = false;
400  return luminosityBlockAuxiliary();
401  }
boost::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:242
bool noMoreEvents_
Definition: DaqSource.h:70
boost::shared_ptr< RunAuxiliary > DaqSource::readRunAuxiliary_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 384 of file DaqSource.cc.

References edm::Timestamp::invalidTimestamp(), newRun_, noMoreEvents_, runNumber_, and edm::InputSource::timestamp().

384  {
385  assert(newRun_);
386  assert(!noMoreEvents_);
387  newRun_ = false;
388  return boost::shared_ptr<RunAuxiliary>(new RunAuxiliary(runNumber_, timestamp(), Timestamp::invalidTimestamp()));
389  }
RunNumber_t runNumber_
Definition: DaqSource.h:68
static Timestamp const & invalidTimestamp()
Definition: Timestamp.cc:83
Timestamp const & timestamp() const
Accessor for the current time, as seen by the input source.
Definition: InputSource.h:221
bool noMoreEvents_
Definition: DaqSource.h:70
void DaqSource::setLumi ( LuminosityBlockNumber_t  lb)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 419 of file DaqSource.cc.

References edm::hlt::Exception, and edm::errors::LogicError.

419  {
420  throw edm::Exception(errors::LogicError,"DaqSource::setLumi(LuminosityBlockNumber_t lumiNumber)")
421  << "The luminosity block number cannot be set externally for DaqSource.\n"
422  << "Contact a Framework developer.\n";
423  }
void DaqSource::setRun ( RunNumber_t  r)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 373 of file DaqSource.cc.

References eventCached_, newLumi_, newRun_, noMoreEvents_, csvReporter::r, reader_, edm::InputSource::reset(), edm::InputSource::resetLuminosityBlockAuxiliary(), runNumber_, and DaqBaseReader::setRunNumber().

373  {
374  assert(!eventCached_);
375  reset();
376  newRun_ = newLumi_ = true;
377  runNumber_ = r;
379  noMoreEvents_ = false;
381  }
DaqBaseReader * reader_
Definition: DaqSource.h:61
RunNumber_t runNumber_
Definition: DaqSource.h:68
void resetLuminosityBlockAuxiliary() const
Definition: InputSource.h:306
void reset() const
Definition: InputSource.h:309
virtual void setRunNumber(edm::RunNumber_t runNumber)
set the run number
Definition: DaqBaseReader.h:37
bool eventCached_
Definition: DaqSource.h:73
bool noMoreEvents_
Definition: DaqSource.h:70
void DaqSource::signalWaitingThreadAndBlock ( )
privatevirtual

Definition at line 484 of file DaqSource.cc.

References cond_, mutex_, and signal_lock_.

Referenced by getNextItemType().

485  {
486  pthread_mutex_lock(&signal_lock_);
487  pthread_mutex_lock(&mutex_);
488  pthread_mutex_unlock(&signal_lock_);
489  // std::cout << getpid() << " DS::signal from evloop " << std::endl;
490  pthread_cond_signal(&cond_);
491  // std::cout << getpid() << " DS::go to wait for scalers wl " << std::endl;
492  pthread_cond_wait(&cond_, &mutex_);
493  pthread_mutex_unlock(&mutex_);
494  ::usleep(1000);//allow other thread to lock
495  }
pthread_cond_t cond_
Definition: DaqSource.h:78
pthread_mutex_t signal_lock_
Definition: DaqSource.h:77
pthread_mutex_t mutex_
Definition: DaqSource.h:76
void DaqSource::skip ( int  offset)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 433 of file DaqSource.cc.

References edm::hlt::Exception, and edm::errors::LogicError.

433  {
434  throw edm::Exception(errors::LogicError,"DaqSource::skip(int offset)")
435  << "Random access skip cannot be used for DaqSource\n"
436  << "Contact a Framework developer.\n";
437  }

Member Data Documentation

bool edm::DaqSource::alignLsToLast_
private

Definition at line 74 of file DaqSource.h.

Referenced by getNextItemType().

pthread_cond_t edm::DaqSource::cond_
private
int edm::DaqSource::count
private

Definition at line 87 of file DaqSource.h.

Referenced by closeBackDoor(), DaqSource(), and openBackDoor().

bool edm::DaqSource::eventCached_
private

Definition at line 73 of file DaqSource.h.

Referenced by getNextItemType(), readEvent_(), and setRun().

unsigned int edm::DaqSource::eventCounter_
private

Definition at line 64 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::fakeLSid_
private

Definition at line 66 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::goToStopping
private

Definition at line 89 of file DaqSource.h.

Referenced by defaultWebPage(), and getNextItemType().

xdata::InfoSpace* edm::DaqSource::is_
private

Definition at line 85 of file DaqSource.h.

Referenced by publish().

bool edm::DaqSource::keepUsingPsidFromTrigger_
private

Definition at line 65 of file DaqSource.h.

Referenced by getNextItemType().

xdata::UnsignedInteger32* edm::DaqSource::lastLumiPrescaleIndex_
private

Definition at line 81 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

xdata::UnsignedInteger32* edm::DaqSource::lastLumiUsingEol_
private

Definition at line 82 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

xdata::Boolean* edm::DaqSource::lsTimedOut_
private

Definition at line 83 of file DaqSource.h.

Referenced by closeBackDoor(), openBackDoor(), and publish().

xdata::Boolean* edm::DaqSource::lsToBeRecovered_
private

Definition at line 84 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

LuminosityBlockNumber_t edm::DaqSource::luminosityBlockNumber_
private

Definition at line 69 of file DaqSource.h.

Referenced by getNextItemType().

xdata::UnsignedInteger32* edm::DaqSource::lumiSectionIndex_
private

Definition at line 79 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

unsigned int edm::DaqSource::lumiSegmentSizeInEvents_
private

Definition at line 62 of file DaqSource.h.

Referenced by getNextItemType().

xdata::InfoSpace* edm::DaqSource::mis_
private

Definition at line 86 of file DaqSource.h.

Referenced by publishToXmas().

pthread_mutex_t edm::DaqSource::mutex_
private
bool edm::DaqSource::newLumi_
private

Definition at line 72 of file DaqSource.h.

Referenced by getNextItemType(), readEvent_(), readLuminosityBlockAuxiliary_(), and setRun().

bool edm::DaqSource::newRun_
private
bool edm::DaqSource::noMoreEvents_
private
xdata::UnsignedInteger32* edm::DaqSource::prescaleSetIndex_
private

Definition at line 80 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

DaqBaseReader* edm::DaqSource::reader_
private

Definition at line 61 of file DaqSource.h.

Referenced by DaqSource(), getNextItemType(), setRun(), and ~DaqSource().

RunNumber_t edm::DaqSource::runNumber_
private

Definition at line 68 of file DaqSource.h.

Referenced by DaqSource(), getNextItemType(), readRunAuxiliary_(), and setRun().

pthread_mutex_t edm::DaqSource::signal_lock_
private

Definition at line 77 of file DaqSource.h.

Referenced by closeBackDoor(), DaqSource(), openBackDoor(), and signalWaitingThreadAndBlock().

unsigned int edm::DaqSource::thisEventLSid
private

Definition at line 88 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::useEventCounter_
private

Definition at line 63 of file DaqSource.h.

Referenced by getNextItemType().