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::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 56 of file DaqSource.cc.

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

58  : InputSource(pset,desc)
59  , evf::ModuleWeb("DaqSource")
60  , reader_(0)
61  , lumiSegmentSizeInEvents_(pset.getUntrackedParameter<unsigned int>("evtsPerLS",0))
62  , useEventCounter_(pset.getUntrackedParameter<bool>("useEventCounter",false))
63  , eventCounter_(0)
64  , keepUsingPsidFromTrigger_(pset.getUntrackedParameter<bool>("keepUsingPsidFromTrigger",false))
68  , noMoreEvents_(false)
69  , newRun_(true)
70  , newLumi_(true)
71  , eventCached_(false)
72  , alignLsToLast_(false)
73  , is_(0)
74  , mis_(0)
75  , thisEventLSid(0)
76  , goToStopping(false)
77  {
78  count = 0;
79  pthread_mutex_init(&mutex_,0);
80  pthread_mutex_init(&signal_lock_,0);
81  pthread_cond_init(&cond_,0);
82  produces<FEDRawDataCollection>();
84 
85  // Instantiate the requested data source
86  std::string reader = pset.getUntrackedParameter<std::string>("readerPluginName");
87 
88  try{
89  reader_=
90  DaqReaderPluginFactory::get()->create(reader,
91  pset.getUntrackedParameter<ParameterSet>("readerPset"));
93  }
94  catch(edm::Exception &e) {
95  if(e.category() == "Configuration" && reader_ == 0) {
96  reader_ = DaqReaderPluginFactoryU::get()->create(reader);
97  if(reader_ == 0) throw;
99  }
100  else {
101  throw;
102  }
103  }
104  }
DaqBaseReader * reader_
Definition: DaqSource.h:61
xdata::InfoSpace * mis_
Definition: DaqSource.h:85
static LuminosityBlockID firstValidLuminosityBlock()
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:69
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:588
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 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
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:582
bool keepUsingPsidFromTrigger_
Definition: DaqSource.h:65
bool goToStopping
Definition: DaqSource.h:88
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:87
InputSource(ParameterSet const &, InputSourceDescription const &)
Constructor.
Definition: InputSource.cc:74
bool noMoreEvents_
Definition: DaqSource.h:70
xdata::InfoSpace * is_
Definition: DaqSource.h:84
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 107 of file DaqSource.cc.

References reader_.

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

Member Function Documentation

void DaqSource::closeBackDoor ( )
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 467 of file DaqSource.cc.

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

468  {
469  count--;
470  pthread_cond_signal(&cond_);
471  pthread_mutex_unlock(&mutex_);
472  pthread_mutex_lock(&signal_lock_);
473  lsTimedOut_->value_ = false;
474  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:82
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 489 of file DaqSource.cc.

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

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

References alignLsToLast_, cond_, FEDRawData::data(), ExpressReco_HICollisions_FallBack::e, 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_, 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_.

118  {
119  // std::cout << getpid() << " enter getNextItemType " << std::endl;
120  if(goToStopping){noMoreEvents_ = true; goToStopping=false;}
121  if (noMoreEvents_) {
122  pthread_mutex_lock(&mutex_);
123  pthread_cond_signal(&cond_);
124  pthread_mutex_unlock(&mutex_);
125  return IsStop;
126  }
127  if (newRun_) {
128  return IsRun;
129  }
131  // std::cout << "newLumi & lumiblock valid " << std::endl;
132  return IsLumi;
133  }
134  if (alignLsToLast_) { //here we are recovering from a gap in Ls number so an event may already be cached but
135  // we hold onto it until we have issued all the necessary endLumi/beginLumi
136 // std::cout << getpid() << "alignLsToLast was set and ls number is "
137 // << luminosityBlockNumber_ << " before signaling" << std::endl;
140 // std::cout << getpid() << "alignLsToLast signaled and incremented "
141 // << luminosityBlockNumber_ << " eventcached "
142 // << eventCached_ << std::endl;
143  newLumi_ = true;
147  {
148  alignLsToLast_ = false;
149  }
151  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
153 
156  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
157  }
158  return IsLumi;
159  }
160  if (eventCached_) {
161  // std::cout << "read event already cached " << std::endl;
162  return IsEvent;
163  }
164  if(reader_ == 0) {
166  << "DaqSource is used without a reader. Check your configuration !";
167  }
168  EventID eventId;
169  TimeValue_t time = 0LL;
170  timeval stv;
171  gettimeofday(&stv,0);
172  time = stv.tv_sec;
173  time = (time << 32) + stv.tv_usec;
174  Timestamp tstamp(time);
175 
176  int bunchCrossing = EventAuxiliary::invalidBunchXing;
177  int orbitNumber = EventAuxiliary::invalidBunchXing;
178 
179  // pass a 0 pointer to fillRawData()!
180  FEDRawDataCollection* fedCollection(0);
181 
183 
184  // let reader_ fill the fedCollection
185  int retval = reader_->fillRawData(eventId, tstamp, fedCollection);
186  if(retval==0) {
187  // fillRawData() failed, clean up the fedCollection in case it was allocated!
188  if (0 != fedCollection) delete fedCollection;
189  noMoreEvents_ = true;
190  pthread_mutex_lock(&mutex_);
191  pthread_cond_signal(&cond_);
192  pthread_mutex_unlock(&mutex_);
193  return IsStop;
194  }
195  else if(retval<0)
196  {
197 
198  unsigned int nextLsFromSignal = (-1)*retval+1;
199 // std::cout << getpid() << "::got end-of-lumi for " << (-1)*retval
200 // << " was " << luminosityBlockNumber_ << std::endl;
201  if(luminosityBlockNumber_ < nextLsFromSignal)
202  {
203  if(lsToBeRecovered_->value_){
204 // std::cout << getpid() << "eol::recover ls::for " << (-1)*retval << std::endl;
207  newLumi_ = true;
210  thisEventLSid = nextLsFromSignal - 1;
212  alignLsToLast_ = true;
213  // std::cout << getpid() << "eol::::alignLsToLast_ " << alignLsToLast_ << std::endl;
214  }
215  else{
216  // std::cout << getpid() << "eol::realign ls::for " << (-1)*retval << std::endl;
217  luminosityBlockNumber_ = nextLsFromSignal;
218  newLumi_ = true;
221  }
222  }
223  // else
224  // std::cout << getpid() << "::skipping end-of-lumi for " << (-1)*retval << std::endl;
225  }
226  else
227  {
228  if (eventId.event() == 0) {
230  << "The reader used with DaqSource has returned an invalid (zero) event number!\n"
231  << "Event numbers must begin at 1, not 0.";
232  }
233  EventSourceSentry(*this);
234  setTimestamp(tstamp);
235 
236  unsigned char *gtpFedAddr = fedCollection->FEDData(daqsource::gtpEvmId_).size()!=0 ? fedCollection->FEDData(daqsource::gtpEvmId_).data() : 0;
237  uint32_t gtpsize = 0;
238  if(gtpFedAddr !=0) gtpsize = fedCollection->FEDData(daqsource::gtpEvmId_).size();
239  unsigned char *gtpeFedAddr = fedCollection->FEDData(daqsource::gtpeId_).size()!=0 ? fedCollection->FEDData(daqsource::gtpeId_).data() : 0;
240 
241  unsigned int nextFakeLs = 0;
242  eventCounter_++;
244  (nextFakeLs = useEventCounter_ ? ((eventCounter_-1)/lumiSegmentSizeInEvents_ + 1) :
245  ((eventId.event() - 1)/lumiSegmentSizeInEvents_ + 1))) {
246  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
247  prescaleSetIndex_->value_ = 0; // since we do not know better but we want to be able to run
248 
249  if(luminosityBlockNumber_ == nextFakeLs-1)
251  luminosityBlockNumber_ = nextFakeLs;
252  thisEventLSid = nextFakeLs-1;
253  newLumi_ = true;
257  gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
258  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
259  }
260  }
261  else if(!fakeLSid_){
262 
263  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
264  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
265  thisEventLSid = evf::evtn::getlbn(gtpFedAddr);
266  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
269  // we got here in a running process and some Ls might have been skipped so set the flag,
270  // increase by one, check and if appropriate set the flag then continue
271  if(lsToBeRecovered_->value_){
272  // std::cout << getpid() << "eve::recover ls::for " << thisEventLSid << std::endl;
275  newLumi_ = true;
279  // std::cout << getpid() << "eve::::alignLsToLast_ " << alignLsToLast_ << std::endl;
280  }
281  else{ // we got here because the process was restarted. just realign the ls id and proceed with this event
282  // std::cout << getpid() << "eve::realign ls::for " << thisEventLSid << std::endl;
284  newLumi_ = true;
287  lsToBeRecovered_->value_ = true;
288  }
289  }
290  }
291  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
292  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
293  thisEventLSid = evf::evtn::gtpe_getlbn(gtpeFedAddr);
294  prescaleSetIndex_->value_ = 0; //waiting to get a PS index from gtpe
300  newLumi_ = true;
303  }
304  }
305  }
306  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
307  bunchCrossing = int(evf::evtn::getfdlbx(gtpFedAddr));
308  orbitNumber = int(evf::evtn::getorbit(gtpFedAddr));
309  TimeValue_t time = evf::evtn::getgpshigh(gtpFedAddr);
310  time = (time << 32) + evf::evtn::getgpslow(gtpFedAddr);
311  Timestamp tstamp(time);
312  setTimestamp(tstamp);
313  }
314  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
315  bunchCrossing = int(evf::evtn::gtpe_getbx(gtpeFedAddr));
316  orbitNumber = int(evf::evtn::gtpe_getorbit(gtpeFedAddr));
317  }
318  }
319 
320  // std::cout << "lumiblockaux = " << luminosityBlockAuxiliary() << std::endl;
321  // If there is no luminosity block principal, make one.
323  newLumi_ = true;
324  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
326 
329  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
330  }
331  // std::cout << "here retval = " << retval << std::endl;
332  if(retval<0){
333  // std::cout << getpid() << " returning from getnextitem because retval < 0 - IsLumi "
334  // << IsLumi << std::endl;
335  if(newLumi_) return IsLumi; else return getNextItemType();
336  }
337 
338  // make a brand new event
339  eventId = EventID(runNumber_,thisEventLSid+1, eventId.event());
340  std::auto_ptr<EventAuxiliary> eventAux(
341  new EventAuxiliary(eventId, processGUID(),
342  timestamp(),
343  true,
344  evttype,
345  bunchCrossing,
347  orbitNumber));
349  eventCached_ = true;
350 
351  // have fedCollection managed by a std::auto_ptr<>
352  std::auto_ptr<FEDRawDataCollection> bare_product(fedCollection);
353 
354  std::auto_ptr<Event> e(new Event(*eventPrincipalCache(), moduleDescription()));
355  // put the fed collection into the transient event store
356  e->put(bare_product);
357  // The commit is needed to complete the "put" transaction.
358  e->commit_();
359  if (newLumi_) {
360  return IsLumi;
361  }
362  return IsEvent;
363  }
DaqBaseReader * reader_
Definition: DaqSource.h:61
unsigned int getgpshigh(const unsigned char *)
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:69
unsigned int getfdlbx(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
virtual ItemType getNextItemType()
Definition: DaqSource.cc:118
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:79
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:588
unsigned int eventCounter_
Definition: DaqSource.h:64
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:83
EventPrincipal *const eventPrincipalCache()
Definition: InputSource.cc:156
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
RunNumber_t runNumber_
Definition: DaqSource.h:68
unsigned int getfdlpsc(const unsigned char *)
pthread_cond_t cond_
Definition: DaqSource.h:78
static unsigned int gtpeId_
Definition: DaqSource.cc:52
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:476
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:88
unsigned int getorbit(const unsigned char *)
static unsigned int gtpEvmId_
Definition: DaqSource.cc:51
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:87
ModuleDescription const & moduleDescription() const
Accessor for &#39;module&#39; description.
Definition: InputSource.h:187
boost::shared_ptr< LuminosityBlockPrincipal > const luminosityBlockPrincipal() const
Definition: InputSource.cc:280
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
void readAndCacheLumi()
Read next luminosity block.
Definition: InputSource.cc:309
bool alignLsToLast_
Definition: DaqSource.h:74
void DaqSource::openBackDoor ( unsigned int  timeout_sec)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 446 of file DaqSource.cc.

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

447  {
448  count++;
449  if(count==2) throw;
450  pthread_mutex_lock(&mutex_);
451  pthread_mutex_unlock(&signal_lock_);
452  timespec ts;
453 #if _POSIX_TIMERS > 0
454  clock_gettime(CLOCK_REALTIME, &ts);
455 #else
456  struct timeval tv;
457  gettimeofday(&tv, NULL);
458  ts.tv_sec = tv.tv_sec + 0;
459  ts.tv_nsec = 0;
460 #endif
461  ts.tv_sec += timeout_sec;
462 
463  int rc = pthread_cond_timedwait(&cond_, &mutex_, &ts);
464  if(rc == ETIMEDOUT) lsTimedOut_->value_ = true;
465  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:82
#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 432 of file DaqSource.cc.

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

433  {
434  is_ = is;
435  lumiSectionIndex_ = (xdata::UnsignedInteger32*)is_->find("lumiSectionIndex");
436  prescaleSetIndex_ = (xdata::UnsignedInteger32*)is_->find("prescaleSetIndex");
437  lastLumiPrescaleIndex_ = (xdata::UnsignedInteger32*)is_->find("lastLumiPrescaleIndex");
438  lsTimedOut_ = (xdata::Boolean*)is_->find("lsTimedOut");
439  lsToBeRecovered_ = (xdata::Boolean*)is_->find("lsToBeRecovered");
440  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:82
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:79
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:83
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:80
xdata::InfoSpace * is_
Definition: DaqSource.h:84
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:81
void DaqSource::publishToXmas ( xdata::InfoSpace *  is)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 441 of file DaqSource.cc.

References mis_.

442  {
443  mis_ = is;
444  }
xdata::InfoSpace * mis_
Definition: DaqSource.h:85
EventPrincipal * DaqSource::readEvent_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 397 of file DaqSource.cc.

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

397  {
398  // std::cout << "assert not newRun " << std::endl;
399  assert(!newRun_);
400  // std::cout << "assert not newLumi " << std::endl;
401  assert(!newLumi_);
402  // std::cout << "assert not noMoreEvents " << std::endl;
403  assert(!noMoreEvents_);
404  // std::cout << "assert eventCached " << std::endl;
405  assert(eventCached_);
406  // std::cout << "asserts done " << std::endl;
407  eventCached_ = false;
408  return eventPrincipalCache();
409  }
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 419 of file DaqSource.cc.

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

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

Implements edm::InputSource.

Definition at line 385 of file DaqSource.cc.

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

385  {
386  assert(!newRun_);
387  assert(newLumi_);
388  assert(!noMoreEvents_);
389  assert(luminosityBlockAuxiliary());
390  //assert(eventCached_); //the event may or may not be cached - rely on
391  // the call to getNextItemType to detect that.
392  newLumi_ = false;
393  return luminosityBlockAuxiliary();
394  }
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 377 of file DaqSource.cc.

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

377  {
378  assert(newRun_);
379  assert(!noMoreEvents_);
380  newRun_ = false;
381  return boost::shared_ptr<RunAuxiliary>(new RunAuxiliary(runNumber_, timestamp(), Timestamp::invalidTimestamp()));
382  }
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 412 of file DaqSource.cc.

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

412  {
413  throw edm::Exception(errors::LogicError,"DaqSource::setLumi(LuminosityBlockNumber_t lumiNumber)")
414  << "The luminosity block number cannot be set externally for DaqSource.\n"
415  << "Contact a Framework developer.\n";
416  }
void DaqSource::setRun ( RunNumber_t  r)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 366 of file DaqSource.cc.

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

366  {
367  assert(!eventCached_);
368  reset();
369  newRun_ = newLumi_ = true;
370  runNumber_ = r;
372  noMoreEvents_ = false;
374  }
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 476 of file DaqSource.cc.

References cond_, mutex_, and signal_lock_.

Referenced by getNextItemType().

477  {
478  pthread_mutex_lock(&signal_lock_);
479  pthread_mutex_lock(&mutex_);
480  pthread_mutex_unlock(&signal_lock_);
481  // std::cout << getpid() << " DS::signal from evloop " << std::endl;
482  pthread_cond_signal(&cond_);
483  // std::cout << getpid() << " DS::go to wait for scalers wl " << std::endl;
484  pthread_cond_wait(&cond_, &mutex_);
485  pthread_mutex_unlock(&mutex_);
486  ::usleep(1000);//allow other thread to lock
487  }
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 426 of file DaqSource.cc.

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

426  {
427  throw edm::Exception(errors::LogicError,"DaqSource::skip(int offset)")
428  << "Random access skip cannot be used for DaqSource\n"
429  << "Contact a Framework developer.\n";
430  }

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 86 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 88 of file DaqSource.h.

Referenced by defaultWebPage(), and getNextItemType().

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

Definition at line 84 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::Boolean* edm::DaqSource::lsTimedOut_
private

Definition at line 82 of file DaqSource.h.

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

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

Definition at line 83 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 85 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 87 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::useEventCounter_
private

Definition at line 63 of file DaqSource.h.

Referenced by getNextItemType().