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...
 
boost::shared_ptr
< BranchIDListHelper
branchIDListHelper () const
 Accessor for branchIDListHelper. More...
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 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, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 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...
 
 InputSource (InputSource const &)=delete
 
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 maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
InputSourceoperator= (InputSource const &)=delete
 
bool 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...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
boost::shared_ptr
< LuminosityBlockPrincipal
readAndCacheLumi (HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
boost::shared_ptr< RunPrincipalreadAndCacheRun (HistoryAppender &historyAppender)
 Read next run (new run) More...
 
void readAndMergeLumi (boost::shared_ptr< LuminosityBlockPrincipal > lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (boost::shared_ptr< RunPrincipal > rp)
 Read next run (same as a prior run) More...
 
EventPrincipalreadEvent (EventPrincipal &ep)
 
EventPrincipalreadEvent (EventPrincipal &ep, EventID const &)
 Read a specific event. More...
 
std::unique_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...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
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)
 
bool skipForForking ()
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Private Member Functions

virtual void closeBackDoor ()
 
void defaultWebPage (xgi::Input *in, xgi::Output *out)
 
int doMyBeginRun ()
 
virtual ItemType getNextItemType ()
 
virtual void openBackDoor (unsigned int, bool *)
 
virtual void publish (xdata::InfoSpace *)
 
virtual void publishForkInfo (evf::moduleweb::ForkInfoObj *forkInfoObj)
 
virtual void publishToXmas (xdata::InfoSpace *)
 
virtual EventPrincipalreadEvent_ (EventPrincipal &eventPrincipal)
 
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_
 
bool beginRunTiming_
 
int bunchCrossing_
 
pthread_cond_t cond_
 
int count
 
DaqProvenanceHelper daqProvenanceHelper_
 
unsigned int eventCounter_
 
EventID eventID_
 
EventAuxiliary::ExperimentType evttype_
 
bool fakeLSid_
 
FEDRawDataCollectionfedCollection_
 
evf::moduleweb::ForkInfoObjforkInfo_
 
bool goToStopping
 
bool immediateStop
 
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_
 
unsigned int lumiSegmentSizeInSeconds_
 
xdata::InfoSpace * mis_
 
pthread_mutex_t mutex_
 
bool noMoreEvents_
 
int orbitNumber_
 
ProcessHistoryID phid_
 
xdata::UnsignedInteger32 * prescaleSetIndex_
 
DaqBaseReaderreader_
 
bool runFork_
 
RunNumber_t runNumber_
 
pthread_mutex_t signal_lock_
 
struct timeval startOfLastLumi
 
unsigned int thisEventLSid
 
timeval tvStat_
 
bool useEventCounter_
 
bool useTimer_
 
- 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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
bool newLumi () const
 
bool newRun () const
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
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 39 of file DaqSource.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file DaqSource.cc.

References edm::Timestamp::beginOfTime(), cms::Exception::category(), cond_, count, gather_cfg::cout, edm::DaqProvenanceHelper::daqInit(), daqProvenanceHelper_, alignCSCRings::e, fakeLSid_, reco::get(), edm::ParameterSet::getUntrackedParameter(), lumiSegmentSizeInEvents_, lumiSegmentSizeInSeconds_, mutex_, phid_, edm::InputSource::productRegistryUpdate(), matplotRender::reader, reader_, runNumber_, DaqBaseReader::setRunNumber(), edm::InputSource::setTimestamp(), signal_lock_, startOfLastLumi, and AlCaHLTBitMon_QueryRunRegistry::string.

57  : InputSource(pset,desc)
58  , evf::ModuleWeb("DaqSource")
59  , reader_(0)
60  , lumiSegmentSizeInEvents_(pset.getUntrackedParameter<unsigned int>("evtsPerLS",0))
61  , lumiSegmentSizeInSeconds_(pset.getUntrackedParameter<unsigned int>("secondsPerLS",0))
62  , useEventCounter_(pset.getUntrackedParameter<bool>("useEventCounter",false))
64  , eventCounter_(0)
65  , keepUsingPsidFromTrigger_(pset.getUntrackedParameter<bool>("keepUsingPsidFromTrigger",false))
67  , runNumber_(pset.getUntrackedParameter<unsigned int>("runNumber",RunID::firstValidRun().run()))
70  , noMoreEvents_(false)
71  , alignLsToLast_(false)
76  , lsTimedOut_(0)
77  , lsToBeRecovered_(0)
78  , is_(0)
79  , mis_(0)
80  , thisEventLSid(0)
81  , goToStopping(false)
82  , immediateStop(false)
83  , forkInfo_(nullptr)
84  , runFork_(false)
85  , beginRunTiming_(false)
89  , eventID_(0,0,0)
90  , fedCollection_(nullptr)
91  {
92  count = 0;
93  pthread_mutex_init(&mutex_,0);
94  pthread_mutex_init(&signal_lock_,0);
95  pthread_cond_init(&cond_,0);
96 
97  std::cout << " DaqSourceFake will use fake ls id ? " << fakeLSid_ << std::endl;
98  if(fakeLSid_) std::cout << " DaqSourceFake set to make a new ls every " << lumiSegmentSizeInEvents_ << " events " << std::endl;
99  if(fakeLSid_) std::cout << " DaqSourceFake set to make a new ls every " << lumiSegmentSizeInSeconds_ << " seconds " << std::endl;
100 
102 
103  // Instantiate the requested data source
104  std::string reader = pset.getUntrackedParameter<std::string>("readerPluginName");
105 
106  try{
107  reader_=
108  DaqReaderPluginFactory::get()->create(reader,
109  pset.getUntrackedParameter<ParameterSet>("readerPset"));
111  }
112  catch(edm::Exception &e) {
113  if(e.category() == "Configuration" && reader_ == 0) {
114  reader_ = DaqReaderPluginFactoryU::get()->create(reader);
115  if(reader_ == 0) throw;
117  }
118  else {
119  throw;
120  }
121  }
122 
123  // Initialize LS timer if requested
124  if(lumiSegmentSizeInSeconds_ != 0) gettimeofday(&startOfLastLumi,0);
125 
126  // Initialize metadata, and save the process history ID for use every event.
128 
129  }
DaqBaseReader * reader_
Definition: DaqSource.h:69
xdata::InfoSpace * mis_
Definition: DaqSource.h:95
ProcessHistoryID phid_
Definition: DaqSource.h:81
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:92
evf::moduleweb::ForkInfoObj * forkInfo_
Definition: DaqSource.h:101
static LuminosityBlockID firstValidLuminosityBlock()
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:79
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:88
RunNumber_t run() const
Definition: RunID.h:44
unsigned int eventCounter_
Definition: DaqSource.h:74
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:93
DaqProvenanceHelper daqProvenanceHelper_
Definition: DaqSource.h:80
std::string const & category() const
Definition: Exception.cc:183
void setTimestamp(Timestamp const &theTime)
To set the current time, as seen by the input source.
Definition: InputSource.h:314
xdata::UnsignedInteger32 * lastLumiUsingEol_
Definition: DaqSource.h:91
RunNumber_t runNumber_
Definition: DaqSource.h:78
static RunID firstValidRun()
Definition: RunID.h:82
bool useTimer_
Definition: DaqSource.h:73
pthread_cond_t cond_
Definition: DaqSource.h:87
ProcessHistoryID daqInit(ProductRegistry &productRegistry) const
FEDRawDataCollection * fedCollection_
Definition: DaqSource.h:109
pthread_mutex_t signal_lock_
Definition: DaqSource.h:86
static int const invalidBunchXing
bool fakeLSid_
Definition: DaqSource.h:76
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:89
bool keepUsingPsidFromTrigger_
Definition: DaqSource.h:75
bool goToStopping
Definition: DaqSource.h:98
int bunchCrossing_
Definition: DaqSource.h:105
EventAuxiliary::ExperimentType evttype_
Definition: DaqSource.h:107
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:611
bool beginRunTiming_
Definition: DaqSource.h:104
unsigned int lumiSegmentSizeInSeconds_
Definition: DaqSource.h:71
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:316
unsigned int lumiSegmentSizeInEvents_
Definition: DaqSource.h:70
bool useEventCounter_
Definition: DaqSource.h:72
static Timestamp const & beginOfTime()
Definition: Timestamp.cc:96
EventID eventID_
Definition: DaqSource.h:108
pthread_mutex_t mutex_
Definition: DaqSource.h:85
virtual void setRunNumber(edm::RunNumber_t runNumber)
set the run number
Definition: DaqBaseReader.h:37
tuple cout
Definition: gather_cfg.py:121
struct timeval startOfLastLumi
Definition: DaqSource.h:99
unsigned int thisEventLSid
Definition: DaqSource.h:97
bool noMoreEvents_
Definition: DaqSource.h:82
InputSource(ParameterSet const &, InputSourceDescription const &)
Constructor.
Definition: InputSource.cc:55
bool immediateStop
Definition: DaqSource.h:100
xdata::InfoSpace * is_
Definition: DaqSource.h:94
T get(const Candidate &c)
Definition: component.h:56
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:90
bool alignLsToLast_
Definition: DaqSource.h:83
DaqSource::~DaqSource ( )
virtual

Definition at line 132 of file DaqSource.cc.

References reader_.

132  {
133  delete reader_;
134  }
DaqBaseReader * reader_
Definition: DaqSource.h:69

Member Function Documentation

void DaqSource::closeBackDoor ( )
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 692 of file DaqSource.cc.

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

693  {
694  count--;
695  pthread_cond_signal(&cond_);
696  pthread_mutex_unlock(&mutex_);
697  pthread_mutex_lock(&signal_lock_);
698  if (lsTimedOut_ != 0)
699  lsTimedOut_->value_ = false;
700  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:92
pthread_cond_t cond_
Definition: DaqSource.h:87
pthread_mutex_t signal_lock_
Definition: DaqSource.h:86
pthread_mutex_t mutex_
Definition: DaqSource.h:85
void DaqSource::defaultWebPage ( xgi::Input in,
xgi::Output out 
)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 717 of file DaqSource.cc.

References alignCSCRings::e, cppFunctionSkipper::exception, edm::first(), goToStopping, LaserDQM_cfg::input, evf::ModuleWeb::moduleName_, getHLTPrescaleColumns::path, pos, o2o::query, edm::second(), and AlCaHLTBitMon_QueryRunRegistry::string.

718  {
720  std::string urn;
721  std::string mname;
723  std::string original_referrer_;
724  try
725  {
726  cgicc::Cgicc cgi(in);
727  if ( xgi::Utils::hasFormElement(cgi,"gotostopping") )
728  {
729  goToStopping=true;
730  }
731  if ( xgi::Utils::hasFormElement(cgi,"module") )
732  mname = xgi::Utils::getFormElement(cgi, "module")->getValue();
733  cgicc::CgiEnvironment cgie(in);
734  if(original_referrer_ == "")
735  original_referrer_ = cgie.getReferrer();
736  path = cgie.getPathInfo();
737  query = cgie.getQueryString();
738  }
739  catch (const std::exception & e)
740  {
741  // don't care if it did not work
742  }
743 
744  using std::endl;
745  *out << "<html>" << endl;
746  *out << "<head>" << endl;
747 
748 
749  *out << "<STYLE type=\"text/css\"> #T1 {border-width: 2px; border: solid blue; text-align: center} </STYLE> " << endl;
750  *out << "<link type=\"text/css\" rel=\"stylesheet\"";
751  *out << " href=\"/" << urn
752  << "/styles.css\"/>" << endl;
753 
754  *out << "<title>" << moduleName_
755  << " MAIN</title>" << endl;
756 
757  *out << "</head>" << endl;
758  *out << "<body onload=\"loadXMLDoc()\">" << endl;
759  *out << "<table border=\"0\" width=\"100%\">" << endl;
760  *out << "<tr>" << endl;
761  *out << " <td align=\"left\">" << endl;
762  *out << " <img" << endl;
763  *out << " align=\"middle\"" << endl;
764  *out << " src=\"/evf/images/bugicon.jpg\"" << endl;
765  *out << " alt=\"main\"" << endl;
766  *out << " width=\"90\"" << endl;
767  *out << " height=\"64\"" << endl;
768  *out << " border=\"\"/>" << endl;
769  *out << " <b>" << endl;
770  *out << moduleName_ << endl;
771  *out << " </b>" << endl;
772  *out << " </td>" << endl;
773  *out << " <td width=\"32\">" << endl;
774  *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
775  *out << " <img" << endl;
776  *out << " align=\"middle\"" << endl;
777  *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
778  *out << " alt=\"HyperDAQ\"" << endl;
779  *out << " width=\"32\"" << endl;
780  *out << " height=\"32\"" << endl;
781  *out << " border=\"\"/>" << endl;
782  *out << " </a>" << endl;
783  *out << " </td>" << endl;
784  *out << " <td width=\"32\">" << endl;
785  *out << " </td>" << endl;
786  *out << " <td width=\"32\">" << endl;
787  *out << " <a href=\"" << original_referrer_ << "\">" << endl;
788  *out << " <img" << endl;
789  *out << " align=\"middle\"" << endl;
790  *out << " src=\"/evf/images/spoticon.jpg\"" << endl;
791  *out << " alt=\"main\"" << endl;
792  *out << " width=\"32\"" << endl;
793  *out << " height=\"32\"" << endl;
794  *out << " border=\"\"/>" << endl;
795  *out << " </a>" << endl;
796  *out << " </td>" << endl;
797  *out << "</tr>" << endl;
798  *out << "</table>" << endl;
799 
800  *out << "<hr/>" << endl;
801 
802  *out << cgicc::form().set("method","GET").set("action", path )
803  << std::endl;
804  boost::char_separator<char> sep("&");
805  boost::tokenizer<boost::char_separator<char> > tokens(query, sep);
806  for (boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
807  tok_iter != tokens.end(); ++tok_iter){
808  size_t pos = (*tok_iter).find_first_of("=");
809  if(pos != std::string::npos){
810  std::string first = (*tok_iter).substr(0 , pos);
811  std::string second = (*tok_iter).substr(pos+1, (*tok_iter).length()-pos-1);
812  *out << cgicc::input().set("type","hidden").set("name",first).set("value", second)
813  << std::endl;
814  }
815  }
816 
817  *out << cgicc::input().set("type","hidden").set("name","gotostopping").set("value","true")
818  << std::endl;
819  *out << cgicc::input().set("type","submit").set("value","Go To Stopping") << std::endl;
820  *out << cgicc::form() << std::endl;
821 
822  *out << "</body>" << endl;
823  *out << "</html>" << endl;
824  }
boost::tokenizer< boost::char_separator< char > > tokenizer
U second(std::pair< T, U > const &p)
bool goToStopping
Definition: DaqSource.h:98
std::string moduleName_
Definition: ModuleWeb.h:61
tuple out
Definition: dbtoconf.py:99
tuple query
Definition: o2o.py:269
T first(std::pair< T, U > const &p)
int DaqSource::doMyBeginRun ( )
private

Definition at line 149 of file DaqSource.cc.

References beginRunTiming_, evf::moduleweb::ForkInfoObj::control_sem_, gather_cfg::cout, evf::moduleweb::ForkInfoObj::forkHandler, forkInfo_, evf::moduleweb::ForkInfoObj::forkParams, evf::moduleweb::ForkInfoObj::fuAddr, immediateStop, evf::moduleweb::ForkParams::isMaster, evf::moduleweb::ForkInfoObj::lock(), edm::InputSource::newRun(), NULL, evf::moduleweb::ForkInfoObj::receivedStop_, evf::moduleweb::ForkParams::restart, evf::moduleweb::ForkParams::slotId, evf::moduleweb::ForkInfoObj::stopCondition, tvStat_, and evf::moduleweb::ForkInfoObj::unlock().

Referenced by getNextItemType().

149  {
150 
151  if (forkInfo_) {
152  while (!immediateStop) {
153  //queue new run to Framework (causes EP beginRun to be executed)
154  if (newRun()) {
155  beginRunTiming_=true;
156  gettimeofday(&tvStat_, NULL);
157  return 2;
158  }
159  //measure time in fwk beginRun
160  if (beginRunTiming_) {
161  timeval tsTmp;
162  gettimeofday(&tsTmp,NULL);
163  long tusecs = (tsTmp.tv_sec-tvStat_.tv_sec)*1000000 + tsTmp.tv_usec - tvStat_.tv_usec;
164  double tsecs = ((double)(tusecs/10000))/100.;
165  std::cout << "DaqSource: FWK beginRun elapsed time: " << tsecs << " seconds in master EP"<< std::endl;
166  edm::LogInfo("DaqSource") << "FWK beginRun elapsed time: " << tsecs << " seconds in master EP";
167  beginRunTiming_=false;
168  usleep(10000);//short sleep before fork
169  }
170  //first or new run init
171  if (forkInfo_->forkParams.isMaster==-1) {
172  forkInfo_->lock();//keeping it locked during init!
173  forkInfo_->forkHandler(forkInfo_->fuAddr); //fork all slaves
174  }
175  if (forkInfo_->forkParams.isMaster==-1) {
176  forkInfo_->unlock();
177  std::cout << "ERROR (DaqSource): not notified to be either in master or slave process after fork" << std::endl;
178  return -2;
179  }
180 
181  //slave process after fork: exit all this
182  if (forkInfo_->forkParams.isMaster==0) {
183  forkInfo_->unlock();
184  return 1;
185  }
186 
187  //master process after fork:
188  if (forkInfo_->forkParams.isMaster==1) {
189  forkInfo_->unlock();
190  int slotToRestart=-1;
191  sem_wait(forkInfo_->control_sem_);
192  forkInfo_->lock();
193 
194  //got unblocked due to next run
195  if (forkInfo_->forkParams.isMaster==-1) {
196  forkInfo_->unlock();
197  continue; // check here for newRun()?
198  }
199  //check if asked to stop
201  if (immediateStop) {
202  forkInfo_->receivedStop_=true;
203  break;
204  }
205 
206  //check if asked to restart
207  slotToRestart = forkInfo_->forkParams.slotId;
208 
209  if (slotToRestart==-1 && forkInfo_->forkParams.restart==0) {
210  //this will deal with spurious semaphore signals when slave is killed
211  forkInfo_->unlock();
212  continue;
213  }
214  //restart single slave
216  }
217  }
218  //loop exit
219  forkInfo_->unlock();
220  return 0;
221  }
222  return -1; //no forkInfo_
223  }
evf::moduleweb::ForkInfoObj * forkInfo_
Definition: DaqSource.h:101
timeval tvStat_
Definition: DaqSource.h:103
#define NULL
Definition: scimark2.h:8
void(* forkHandler)(void *)
Definition: ModuleWeb.h:44
unsigned int stopCondition
Definition: ModuleWeb.h:46
bool newRun() const
Definition: InputSource.h:341
bool beginRunTiming_
Definition: DaqSource.h:104
tuple cout
Definition: gather_cfg.py:121
bool immediateStop
Definition: DaqSource.h:100
InputSource::ItemType DaqSource::getNextItemType ( )
privatevirtual

Implements edm::InputSource.

Definition at line 228 of file DaqSource.cc.

References alignLsToLast_, beginRunTiming_, bunchCrossing_, cond_, gather_cfg::cout, FEDRawData::data(), doMyBeginRun(), edm::EventID::event(), edm::InputSource::eventCached(), eventCounter_, eventID_, evf::evtn::evm_board_sense(), evttype_, edm::hlt::Exception, fakeLSid_, fedCollection_, FEDRawDataCollection::FEDData(), DaqBaseReader::fillRawData(), forkInfo_, 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_, immediateStop, edm::EventAuxiliary::invalidBunchXing, 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_, lumiSectionIndex_, lumiSegmentSizeInEvents_, lumiSegmentSizeInSeconds_, mutex_, edm::InputSource::newLumi(), edm::InputSource::newRun(), noMoreEvents_, NULL, nullptr, orbitNumber_, phid_, edm::EventAuxiliary::PhysicsTrigger, prescaleSetIndex_, reader_, edm::InputSource::resetLuminosityBlockAuxiliary(), runFork_, runNumber_, edm::InputSource::setEventCached(), edm::InputSource::setLuminosityBlockAuxiliary(), edm::InputSource::setNewLumi(), edm::InputSource::setTimestamp(), signalWaitingThreadAndBlock(), FEDRawData::size(), startOfLastLumi, thisEventLSid, cond::rpcobgas::time, edm::InputSource::timestamp(), tvStat_, edm::EventAuxiliary::Undefined, and useEventCounter_.

228  {
229  // std::cout << getpid() << " enter getNextItemType " << std::endl;
230  if (runFork_) {
231  runFork_=false;
232  int queueNext = doMyBeginRun();
233  //check if new run (requires returning IsRun once)
234  if (queueNext == 2) runFork_=true;
235  }
236 
237  //get initial time before beginRun (used with old forking)
238  if (!forkInfo_ && newRun()) {
239  beginRunTiming_=true;
240  gettimeofday(&tvStat_, NULL);
241  }
242 
243  if (immediateStop) return IsStop;
244 
245  // --------------
246  if(goToStopping){noMoreEvents_ = true; goToStopping=false;}
247  if (noMoreEvents_) {
248  pthread_mutex_lock(&mutex_);
249  pthread_cond_signal(&cond_);
250  pthread_mutex_unlock(&mutex_);
251  return IsStop;
252  }
253  if (newRun()) {
254  return IsRun;
255  }
256 
257  //calculate and print the beginRun the timing
258  if (beginRunTiming_) {
259  timeval tsTmp;
260  gettimeofday(&tsTmp,NULL);
261  long tusecs = (tsTmp.tv_sec-tvStat_.tv_sec)*1000000 + tsTmp.tv_usec - tvStat_.tv_usec;
262  double tsecs = ((double)(tusecs/10000))/100.;
263  std::cout << "DaqSource (slave pid "<< getpid() << " ): FWK beginRun elapsed time: "
264  << tsecs << " seconds "<< std::endl;
265  edm::LogInfo("DaqSource") << "DaqSource (slave pid "<< getpid() << " ): FWK beginRun elapsed time: "
266  << tsecs << " seconds ";
267  beginRunTiming_=false;
268  }
269 
270  if (newLumi() && luminosityBlockAuxiliary()) {
271  // std::cout << "newLumi & lumiblock valid " << std::endl;
272  return IsLumi;
273  }
274  if (alignLsToLast_) { //here we are recovering from a gap in Ls number so an event may already be cached but
275  // we hold onto it until we have issued all the necessary endLumi/beginLumi
276  // std::cout << getpid() << "alignLsToLast was set and ls number is "
277  // << luminosityBlockNumber_ << " before signaling" << std::endl;
280  // std::cout << getpid() << "alignLsToLast signaled and incremented "
281  // << luminosityBlockNumber_ << " eventcached "
282  // << eventCached() << std::endl;
283  setNewLumi();
284  if (lumiSectionIndex_!=0)
288  {
289  alignLsToLast_ = false;
290  }
292  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
294  luminosityBlockAuxiliary()->setProcessHistoryID(phid_);
295 
296  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
297  }
298  return IsLumi;
299  }
300  if (eventCached()) {
301  // std::cout << "read event already cached " << std::endl;
302  return IsEvent;
303  }
304 
305  if(reader_ == 0) {
307  << "DaqSource is used without a reader. Check your configuration !";
308  }
309  TimeValue_t time = 0LL;
310  timeval stv;
311  gettimeofday(&stv,0);
312  time = stv.tv_sec;
313  time = (time << 32) + stv.tv_usec;
314  Timestamp tstamp(time);
315 
319 
320  // pass a null pointer to fillRawData()!
322 
323 
324  // let reader_ fill the fedCollection
325  int retval = reader_->fillRawData(eventID_, tstamp, fedCollection_);
326  if(retval==0) {
327  // fillRawData() failed, clean up the fedCollection in case it was allocated!
328  if (nullptr != fedCollection_) delete fedCollection_;
329  noMoreEvents_ = true;
330  pthread_mutex_lock(&mutex_);
331  pthread_cond_signal(&cond_);
332  pthread_mutex_unlock(&mutex_);
333  return IsStop;
334  }
335  else if(retval<0)
336  {
337 
338  unsigned int nextLsFromSignal = (-1)*retval+1;
339 // std::cout << getpid() << "::got end-of-lumi for " << (-1)*retval
340 // << " was " << luminosityBlockNumber_ << std::endl;
341  if(luminosityBlockNumber_ == (nextLsFromSignal-1) )
342  {
343  if (lastLumiUsingEol_ != 0)
344  lastLumiUsingEol_->value_ = nextLsFromSignal;
345  if(lsToBeRecovered_ != 0 && lsToBeRecovered_->value_){
346 // std::cout << getpid() << "eol::recover ls::for " << (-1)*retval << std::endl;
349  setNewLumi();
350  if (lumiSectionIndex_ != 0)
353  thisEventLSid = nextLsFromSignal - 1;
355  alignLsToLast_ = true;
356  // std::cout << getpid() << "eol::::alignLsToLast_ " << alignLsToLast_ << std::endl;
357  }
358  else{
359  // std::cout << getpid() << "eol::realign ls::for " << (-1)*retval << std::endl;
360  luminosityBlockNumber_ = nextLsFromSignal;
361  setNewLumi();
362  if (lumiSectionIndex_ != 0)
365  }
366  }
367  else {
368  if(nextLsFromSignal >(luminosityBlockNumber_+100) ) {
369  edm::LogError("DaqSource") << "Got EOL event with value " << retval
370  << " nextLS would be " << nextLsFromSignal
371  << " while we expected " << luminosityBlockNumber_+1 << " - disregarding... ";
372  }
373  if (nextLsFromSignal > luminosityBlockNumber_+2) //recover on delta > 2
374  {
375  if (lastLumiUsingEol_ != 0)
376  lastLumiUsingEol_->value_ = nextLsFromSignal;
377  thisEventLSid=nextLsFromSignal-1;//set new LS
380  setNewLumi();
381  if (lumiSectionIndex_ != 0)
383  alignLsToLast_ = true;
384 
385  //set new lumi block
387  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
389  luminosityBlockAuxiliary()->setProcessHistoryID(phid_);
390  }
391 
392  }
393  // else
394  // std::cout << getpid() << "::skipping end-of-lumi for " << (-1)*retval << std::endl;
395  }
396  else
397  {
398  if (eventID_.event() == 0) {
400  << "The reader used with DaqSource has returned an invalid (zero) event number!\n"
401  << "Event numbers must begin at 1, not 0.";
402  }
403  EventSourceSentry(*this);
404  setTimestamp(tstamp);
405 
406  unsigned char *gtpFedAddr = fedCollection_->FEDData(daqsource::gtpEvmId_).size()!=0 ? fedCollection_->FEDData(daqsource::gtpEvmId_).data() : 0;
407  uint32_t gtpsize = 0;
408  if(gtpFedAddr !=0) gtpsize = fedCollection_->FEDData(daqsource::gtpEvmId_).size();
409  unsigned char *gtpeFedAddr = fedCollection_->FEDData(daqsource::gtpeId_).size()!=0 ? fedCollection_->FEDData(daqsource::gtpeId_).data() : 0;
410 
411  unsigned int nextFakeLs = 0;
412  eventCounter_++;
413  if (fakeLSid_)
415  bool fakeLSFromEventCount = fakeLSid_ && (lumiSegmentSizeInEvents_ != 0);
416  bool fakeLSFromTimer = fakeLSid_ && (lumiSegmentSizeInSeconds_ != 0);
417  if(fakeLSFromEventCount && luminosityBlockNumber_ !=
418  (nextFakeLs = useEventCounter_ ? ((eventCounter_-1)/lumiSegmentSizeInEvents_ + 1) :
419  ((eventID_.event() - 1)/lumiSegmentSizeInEvents_ + 1))) {
420  if (prescaleSetIndex_ != 0 && lastLumiPrescaleIndex_!= 0) {
421  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
422  prescaleSetIndex_->value_ = 0; // since we do not know better but we want to be able to run
423  }
424  if(luminosityBlockNumber_ == nextFakeLs-1)
426  luminosityBlockNumber_ = nextFakeLs;
427  thisEventLSid = nextFakeLs-1;
428  setNewLumi();
429  if (lumiSectionIndex_ != 0)
433  gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
434  if (prescaleSetIndex_ != 0)
435  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
436  }
437  }
438  else if(fakeLSFromTimer){
439  struct timeval tv;
440  gettimeofday(&tv,0);
441  unsigned int elapsed_time = tv.tv_sec - startOfLastLumi.tv_sec;
442  // std::cout << "daqsource elapsed time " << elapsed_time << std::endl;
444  (nextFakeLs = elapsed_time/lumiSegmentSizeInSeconds_ + 1)) {
445  if(prescaleSetIndex_ != 0){
446  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
447  prescaleSetIndex_->value_ = 0; // since we do not know better but we want to be able to run
448  }
449  if(luminosityBlockNumber_ == (nextFakeLs-1))
451  luminosityBlockNumber_ = nextFakeLs;
452  thisEventLSid = nextFakeLs-1;
453  setNewLumi();
454  if(lumiSectionIndex_!=0)
458  gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
459  if(prescaleSetIndex_ != 0)
460  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
461  }
462  }
463  }
464  else if(!fakeLSid_){
465 
466  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
467  if (lastLumiPrescaleIndex_ != 0 && prescaleSetIndex_ != 0)
468  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
469  thisEventLSid = evf::evtn::getlbn(gtpFedAddr);
470  if (prescaleSetIndex_ != 0)
471  prescaleSetIndex_->value_ = (evf::evtn::getfdlpsc(gtpFedAddr) & 0xffff);
474  {
475  //late event,throw fwk exception
476  std::ostringstream excptmsg;
477  excptmsg << "DaqSource::event with late LS (" << thisEventLSid + 1 << ")received.";
478  throw edm::Exception(errors::LogicError,excptmsg.str());
479  }
480  if(luminosityBlockNumber_ != (thisEventLSid + 1)){
481  // we got here in a running process and some Ls might have been skipped so set the flag,
482  // increase by one, check and if appropriate set the flag then continue
483  if(lsToBeRecovered_!=0 && lsToBeRecovered_->value_){
484  // std::cout << getpid() << "eve::recover ls::for " << thisEventLSid << std::endl;
487  setNewLumi();
488  if (lumiSectionIndex_ !=0 )
491  if(luminosityBlockNumber_ != thisEventLSid+1) alignLsToLast_ = true;
492  // std::cout << getpid() << "eve::::alignLsToLast_ " << alignLsToLast_ << std::endl;
493  }
494  else{ // we got here because the process was restarted. just realign the ls id and proceed with this event
495  // std::cout << getpid() << "eve::realign ls::for " << thisEventLSid << std::endl;
496  luminosityBlockNumber_ = thisEventLSid + 1;
497  setNewLumi();
498  if (lumiSectionIndex_ !=0)
501  if (lsToBeRecovered_ !=0)
502  lsToBeRecovered_->value_ = true;
503  }
504  }
505  }
506  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
507  if (lastLumiPrescaleIndex_ != 0 && prescaleSetIndex_ != 0)
508  lastLumiPrescaleIndex_->value_ = prescaleSetIndex_->value_;
509  thisEventLSid = evf::evtn::gtpe_getlbn(gtpeFedAddr);
510  if (prescaleSetIndex_ != 0)
511  prescaleSetIndex_->value_ = 0; //waiting to get a PS index from gtpe
513  if(luminosityBlockNumber_ != (thisEventLSid + 1)){
514  if(luminosityBlockNumber_ == thisEventLSid)
516  luminosityBlockNumber_ = thisEventLSid + 1;
517  setNewLumi();
518  if (lumiSectionIndex_ !=0 )
521  }
522  }
523  }
524  if(gtpFedAddr!=0 && evf::evtn::evm_board_sense(gtpFedAddr,gtpsize)){
525  bunchCrossing_ = int(evf::evtn::getfdlbx(gtpFedAddr));
526  orbitNumber_ = int(evf::evtn::getorbit(gtpFedAddr));
527  TimeValue_t time = evf::evtn::getgpshigh(gtpFedAddr);
528  time = (time << 32) + evf::evtn::getgpslow(gtpFedAddr);
529  Timestamp tstamp(time);
530  setTimestamp(tstamp);
531  }
532  else if(gtpeFedAddr!=0 && evf::evtn::gtpe_board_sense(gtpeFedAddr)){
533  bunchCrossing_ = int(evf::evtn::gtpe_getbx(gtpeFedAddr));
534  orbitNumber_ = int(evf::evtn::gtpe_getorbit(gtpeFedAddr));
535  }
536  }
537 
538  // std::cout << "lumiblockaux = " << luminosityBlockAuxiliary() << std::endl;
539  // If there is no luminosity block principal, make one.
541  setNewLumi();
542  setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(
544  luminosityBlockAuxiliary()->setProcessHistoryID(phid_);
545 
546  // std::cout << "nextItemType: dealt with new lumi block principal, retval is " << retval << std::endl;
547  }
548  // std::cout << "here retval = " << retval << std::endl;
549  if(retval<0){
550  // std::cout << getpid() << " returning from getnextitem because retval < 0 - IsLumi "
551  // << IsLumi << std::endl;
552  if(newLumi()) return IsLumi; else return getNextItemType();
553  }
554  if (newLumi()) {
555  return IsLumi;
556  }
557  setEventCached();
558  return IsEvent;
559  }
DaqBaseReader * reader_
Definition: DaqSource.h:69
EventNumber_t event() const
Definition: EventID.h:44
int doMyBeginRun()
Definition: DaqSource.cc:149
ProcessHistoryID phid_
Definition: DaqSource.h:81
unsigned int getgpshigh(const unsigned char *)
evf::moduleweb::ForkInfoObj * forkInfo_
Definition: DaqSource.h:101
LuminosityBlockNumber_t luminosityBlockNumber_
Definition: DaqSource.h:79
unsigned int getfdlbx(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
virtual ItemType getNextItemType()
Definition: DaqSource.cc:228
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:88
unsigned int eventCounter_
Definition: DaqSource.h:74
bool newLumi() const
Definition: InputSource.h:344
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:93
timeval tvStat_
Definition: DaqSource.h:103
#define nullptr
boost::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:247
#define NULL
Definition: scimark2.h:8
void setTimestamp(Timestamp const &theTime)
To set the current time, as seen by the input source.
Definition: InputSource.h:314
xdata::UnsignedInteger32 * lastLumiUsingEol_
Definition: DaqSource.h:91
constexpr unsigned int gtpEvmId_
Definition: DaqSource.cc:50
RunNumber_t runNumber_
Definition: DaqSource.h:78
unsigned int getfdlpsc(const unsigned char *)
pthread_cond_t cond_
Definition: DaqSource.h:87
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
FEDRawDataCollection * fedCollection_
Definition: DaqSource.h:109
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static int const invalidBunchXing
unsigned int getlbn(const unsigned char *)
bool fakeLSid_
Definition: DaqSource.h:76
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:89
void setLuminosityBlockAuxiliary(LuminosityBlockAuxiliary *lbp)
Definition: InputSource.h:322
bool newRun() const
Definition: InputSource.h:341
virtual void signalWaitingThreadAndBlock()
Definition: DaqSource.cc:702
bool keepUsingPsidFromTrigger_
Definition: DaqSource.h:75
bool evm_board_sense(const unsigned char *p, size_t size)
bool goToStopping
Definition: DaqSource.h:98
void setEventCached()
Called by the framework to merge or ached() const {return eventCached_;}.
Definition: InputSource.h:349
constexpr unsigned int gtpeId_
Definition: DaqSource.cc:51
int bunchCrossing_
Definition: DaqSource.h:105
EventAuxiliary::ExperimentType evttype_
Definition: DaqSource.h:107
LuminosityBlockNumber_t luminosityBlock() const
Accessor for current luminosity block number.
Definition: InputSource.cc:611
unsigned int getorbit(const unsigned char *)
unsigned int gtpe_getorbit(const unsigned char *)
bool beginRunTiming_
Definition: DaqSource.h:104
static Timestamp const & invalidTimestamp()
Definition: Timestamp.cc:83
unsigned int lumiSegmentSizeInSeconds_
Definition: DaqSource.h:71
virtual int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)=0
unsigned int lumiSegmentSizeInEvents_
Definition: DaqSource.h:70
Timestamp const & timestamp() const
Accessor for the current time, as seen by the input source.
Definition: InputSource.h:224
unsigned int getevtyp(const unsigned char *)
bool useEventCounter_
Definition: DaqSource.h:72
void resetLuminosityBlockAuxiliary(bool isNewLumi=true) const
Definition: InputSource.h:330
EventID eventID_
Definition: DaqSource.h:108
unsigned int gtpe_getbx(const unsigned char *)
pthread_mutex_t mutex_
Definition: DaqSource.h:85
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:121
struct timeval startOfLastLumi
Definition: DaqSource.h:99
unsigned int thisEventLSid
Definition: DaqSource.h:97
unsigned int gtpe_getlbn(const unsigned char *)
bool noMoreEvents_
Definition: DaqSource.h:82
unsigned int getgpslow(const unsigned char *)
bool immediateStop
Definition: DaqSource.h:100
unsigned long long TimeValue_t
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:90
bool alignLsToLast_
Definition: DaqSource.h:83
bool eventCached() const
Definition: InputSource.h:347
void DaqSource::openBackDoor ( unsigned int  timeout_sec,
bool *  running 
)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 670 of file DaqSource.cc.

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

671  {
672  count++;
673  if(count==2) throw;
674  pthread_mutex_lock(&mutex_);
675  if (running) *running=true;
676  pthread_mutex_unlock(&signal_lock_);
677  timespec ts;
678 #if _POSIX_TIMERS > 0
679  clock_gettime(CLOCK_REALTIME, &ts);
680 #else
681  struct timeval tv;
682  gettimeofday(&tv, NULL);
683  ts.tv_sec = tv.tv_sec + 0;
684  ts.tv_nsec = 0;
685 #endif
686  ts.tv_sec += timeout_sec;
687 
688  int rc = pthread_cond_timedwait(&cond_, &mutex_, &ts);
689  if(rc == ETIMEDOUT && lsTimedOut_ != 0) lsTimedOut_->value_ = true;
690  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:92
#define NULL
Definition: scimark2.h:8
pthread_cond_t cond_
Definition: DaqSource.h:87
pthread_mutex_t signal_lock_
Definition: DaqSource.h:86
pthread_mutex_t mutex_
Definition: DaqSource.h:85
#define CLOCK_REALTIME
Definition: TimerService.h:28
void DaqSource::publish ( xdata::InfoSpace *  is)
privatevirtual

Implements evf::ModuleWeb.

Definition at line 655 of file DaqSource.cc.

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

656  {
657  is_ = is;
658  lumiSectionIndex_ = (xdata::UnsignedInteger32*)is_->find("lumiSectionIndex");
659  prescaleSetIndex_ = (xdata::UnsignedInteger32*)is_->find("prescaleSetIndex");
660  lastLumiPrescaleIndex_ = (xdata::UnsignedInteger32*)is_->find("lastLumiPrescaleIndex");
661  lastLumiUsingEol_ = (xdata::UnsignedInteger32*)is_->find("lastLumiUsingEol");
662  lsTimedOut_ = (xdata::Boolean*)is_->find("lsTimedOut");
663  lsToBeRecovered_ = (xdata::Boolean*)is_->find("lsToBeRecovered");
664  }
xdata::Boolean * lsTimedOut_
Definition: DaqSource.h:92
xdata::UnsignedInteger32 * lumiSectionIndex_
Definition: DaqSource.h:88
xdata::Boolean * lsToBeRecovered_
Definition: DaqSource.h:93
xdata::UnsignedInteger32 * lastLumiUsingEol_
Definition: DaqSource.h:91
xdata::UnsignedInteger32 * prescaleSetIndex_
Definition: DaqSource.h:89
xdata::InfoSpace * is_
Definition: DaqSource.h:94
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
Definition: DaqSource.h:90
void DaqSource::publishForkInfo ( evf::moduleweb::ForkInfoObj forkInfoObj)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 136 of file DaqSource.cc.

References forkInfo_, immediateStop, noMoreEvents_, and runFork_.

136  {
137  forkInfo_ = forkInfoObj;
138  runFork_=true;
139  immediateStop=false;
140  noMoreEvents_=false;
141  }
evf::moduleweb::ForkInfoObj * forkInfo_
Definition: DaqSource.h:101
bool noMoreEvents_
Definition: DaqSource.h:82
bool immediateStop
Definition: DaqSource.h:100
void DaqSource::publishToXmas ( xdata::InfoSpace *  is)
privatevirtual

Reimplemented from evf::ModuleWeb.

Definition at line 665 of file DaqSource.cc.

References mis_.

666  {
667  mis_ = is;
668  }
xdata::InfoSpace * mis_
Definition: DaqSource.h:95
EventPrincipal * DaqSource::readEvent_ ( EventPrincipal eventPrincipal)
privatevirtual

Implements edm::InputSource.

Definition at line 593 of file DaqSource.cc.

References bunchCrossing_, edm::DaqProvenanceHelper::constBranchDescription_, daqProvenanceHelper_, edm::DaqProvenanceHelper::dummyProvenance_, edm::EventID::event(), edm::InputSource::eventCached(), eventID_, evttype_, fedCollection_, edm::EventPrincipal::fillEventPrincipal(), edm::EventAuxiliary::invalidStoreNumber, edm::InputSource::newLumi(), edm::InputSource::newRun(), noMoreEvents_, orbitNumber_, phid_, edm::InputSource::processGUID(), edm::EventPrincipal::put(), edm::InputSource::resetEventCached(), runNumber_, thisEventLSid, and edm::InputSource::timestamp().

593  {
594  // std::cout << "assert not newRun " << std::endl;
595  assert(!newRun());
596  // std::cout << "assert not newLumi " << std::endl;
597  assert(!newLumi());
598  // std::cout << "assert not noMoreEvents " << std::endl;
599  assert(!noMoreEvents_);
600  // std::cout << "assert eventCached " << std::endl;
601  assert(eventCached());
602  // std::cout << "asserts done " << std::endl;
603 
605 
606  // make a brand new event principal
608  EventAuxiliary eventAux(eventID_, processGUID(),
609  timestamp(),
610  true,
611  evttype_,
614  orbitNumber_);
615  eventAux.setProcessHistoryID(phid_);
616  eventPrincipal.fillEventPrincipal(eventAux);
617 
618  // have fedCollection managed by a std::auto_ptr<>
619  std::auto_ptr<FEDRawDataCollection> bare_product(fedCollection_);
620 
621  WrapperOwningHolder edp(new Wrapper<FEDRawDataCollection>(bare_product), Wrapper<FEDRawDataCollection>::getInterface());
623 
624 /*
625  Event e(eventPrincipal, md_);
626  // put the fed collection into the transient event store
627  e.put(bare_product);
628  // The commit is needed to complete the "put" transaction.
629  e.commit_();
630 */
631  return &eventPrincipal;
632  }
EventNumber_t event() const
Definition: EventID.h:44
ProcessHistoryID phid_
Definition: DaqSource.h:81
ProductProvenance dummyProvenance_
bool newLumi() const
Definition: InputSource.h:344
DaqProvenanceHelper daqProvenanceHelper_
Definition: DaqSource.h:80
RunNumber_t runNumber_
Definition: DaqSource.h:78
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:199
FEDRawDataCollection * fedCollection_
Definition: DaqSource.h:109
ConstBranchDescription constBranchDescription_
bool newRun() const
Definition: InputSource.h:341
void resetEventCached()
Definition: InputSource.h:350
int bunchCrossing_
Definition: DaqSource.h:105
EventAuxiliary::ExperimentType evttype_
Definition: DaqSource.h:107
Timestamp const & timestamp() const
Accessor for the current time, as seen by the input source.
Definition: InputSource.h:224
static int const invalidStoreNumber
EventID eventID_
Definition: DaqSource.h:108
unsigned int thisEventLSid
Definition: DaqSource.h:97
bool noMoreEvents_
Definition: DaqSource.h:82
bool eventCached() const
Definition: InputSource.h:347
EventPrincipal * DaqSource::readIt ( EventID const &  eventID)
privatevirtual

Definition at line 642 of file DaqSource.cc.

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

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

Implements edm::InputSource.

Definition at line 583 of file DaqSource.cc.

References edm::InputSource::luminosityBlockAuxiliary(), edm::InputSource::newLumi(), edm::InputSource::newRun(), noMoreEvents_, and edm::InputSource::resetNewLumi().

583  {
584  assert(!newRun());
585  assert(newLumi());
586  assert(!noMoreEvents_);
587  assert(luminosityBlockAuxiliary());
588  resetNewLumi();
589  return luminosityBlockAuxiliary();
590  }
bool newLumi() const
Definition: InputSource.h:344
boost::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:247
bool newRun() const
Definition: InputSource.h:341
bool noMoreEvents_
Definition: DaqSource.h:82
boost::shared_ptr< RunAuxiliary > DaqSource::readRunAuxiliary_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 573 of file DaqSource.cc.

References edm::Timestamp::invalidTimestamp(), edm::InputSource::newRun(), noMoreEvents_, phid_, edm::InputSource::resetNewRun(), runNumber_, and edm::InputSource::timestamp().

573  {
574  assert(newRun());
575  assert(!noMoreEvents_);
576  resetNewRun();
577  boost::shared_ptr<RunAuxiliary> ra(new RunAuxiliary(runNumber_, timestamp(), Timestamp::invalidTimestamp()));
578  ra->setProcessHistoryID(phid_);
579  return ra;
580  }
ProcessHistoryID phid_
Definition: DaqSource.h:81
RunNumber_t runNumber_
Definition: DaqSource.h:78
bool newRun() const
Definition: InputSource.h:341
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:224
bool noMoreEvents_
Definition: DaqSource.h:82
void DaqSource::setLumi ( LuminosityBlockNumber_t  lb)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 635 of file DaqSource.cc.

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

635  {
636  throw edm::Exception(errors::LogicError,"DaqSource::setLumi(LuminosityBlockNumber_t lumiNumber)")
637  << "The luminosity block number cannot be set externally for DaqSource.\n"
638  << "Contact a Framework developer.\n";
639  }
void DaqSource::setRun ( RunNumber_t  r)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 562 of file DaqSource.cc.

References edm::InputSource::eventCached(), noMoreEvents_, alignCSCRings::r, reader_, edm::InputSource::reset(), edm::InputSource::resetLuminosityBlockAuxiliary(), runNumber_, edm::InputSource::setNewRun(), and DaqBaseReader::setRunNumber().

562  {
563  assert(!eventCached());
564  reset();
565  setNewRun();
566  runNumber_ = r;
568  noMoreEvents_ = false;
570  }
DaqBaseReader * reader_
Definition: DaqSource.h:69
RunNumber_t runNumber_
Definition: DaqSource.h:78
void resetLuminosityBlockAuxiliary(bool isNewLumi=true) const
Definition: InputSource.h:330
void reset() const
Definition: InputSource.h:334
virtual void setRunNumber(edm::RunNumber_t runNumber)
set the run number
Definition: DaqBaseReader.h:37
bool noMoreEvents_
Definition: DaqSource.h:82
bool eventCached() const
Definition: InputSource.h:347
void DaqSource::signalWaitingThreadAndBlock ( )
privatevirtual

Definition at line 702 of file DaqSource.cc.

References cond_, is_, mutex_, and signal_lock_.

Referenced by getNextItemType().

703  {
704  //check if we are running offline, in which case return immediately
705  if(is_ == 0) return;
706  pthread_mutex_lock(&signal_lock_);
707  pthread_mutex_lock(&mutex_);
708  pthread_mutex_unlock(&signal_lock_);
709  // std::cout << getpid() << " DS::signal from evloop " << std::endl;
710  pthread_cond_signal(&cond_);
711  // std::cout << getpid() << " DS::go to wait for scalers wl " << std::endl;
712  pthread_cond_wait(&cond_, &mutex_);
713  pthread_mutex_unlock(&mutex_);
714  ::usleep(1000);//allow other thread to lock
715  }
pthread_cond_t cond_
Definition: DaqSource.h:87
pthread_mutex_t signal_lock_
Definition: DaqSource.h:86
pthread_mutex_t mutex_
Definition: DaqSource.h:85
xdata::InfoSpace * is_
Definition: DaqSource.h:94
void DaqSource::skip ( int  offset)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 649 of file DaqSource.cc.

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

649  {
650  throw edm::Exception(errors::LogicError,"DaqSource::skip(int offset)")
651  << "Random access skip cannot be used for DaqSource\n"
652  << "Contact a Framework developer.\n";
653  }

Member Data Documentation

bool edm::DaqSource::alignLsToLast_
private

Definition at line 83 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::beginRunTiming_
private

Definition at line 104 of file DaqSource.h.

Referenced by doMyBeginRun(), and getNextItemType().

int edm::DaqSource::bunchCrossing_
private

Definition at line 105 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

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

Definition at line 96 of file DaqSource.h.

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

DaqProvenanceHelper edm::DaqSource::daqProvenanceHelper_
private

Definition at line 80 of file DaqSource.h.

Referenced by DaqSource(), and readEvent_().

unsigned int edm::DaqSource::eventCounter_
private

Definition at line 74 of file DaqSource.h.

Referenced by getNextItemType().

EventID edm::DaqSource::eventID_
private

Definition at line 108 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

EventAuxiliary::ExperimentType edm::DaqSource::evttype_
private

Definition at line 107 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

bool edm::DaqSource::fakeLSid_
private

Definition at line 76 of file DaqSource.h.

Referenced by DaqSource(), and getNextItemType().

FEDRawDataCollection* edm::DaqSource::fedCollection_
private

Definition at line 109 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

evf::moduleweb::ForkInfoObj* edm::DaqSource::forkInfo_
private

Definition at line 101 of file DaqSource.h.

Referenced by doMyBeginRun(), getNextItemType(), and publishForkInfo().

bool edm::DaqSource::goToStopping
private

Definition at line 98 of file DaqSource.h.

Referenced by defaultWebPage(), and getNextItemType().

bool edm::DaqSource::immediateStop
private

Definition at line 100 of file DaqSource.h.

Referenced by doMyBeginRun(), getNextItemType(), and publishForkInfo().

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

Definition at line 94 of file DaqSource.h.

Referenced by publish(), and signalWaitingThreadAndBlock().

bool edm::DaqSource::keepUsingPsidFromTrigger_
private

Definition at line 75 of file DaqSource.h.

Referenced by getNextItemType().

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

Definition at line 90 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

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

Definition at line 91 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

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

Definition at line 92 of file DaqSource.h.

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

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

Definition at line 93 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

LuminosityBlockNumber_t edm::DaqSource::luminosityBlockNumber_
private

Definition at line 79 of file DaqSource.h.

Referenced by getNextItemType().

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

Definition at line 88 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

unsigned int edm::DaqSource::lumiSegmentSizeInEvents_
private

Definition at line 70 of file DaqSource.h.

Referenced by DaqSource(), and getNextItemType().

unsigned int edm::DaqSource::lumiSegmentSizeInSeconds_
private

Definition at line 71 of file DaqSource.h.

Referenced by DaqSource(), and getNextItemType().

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

Definition at line 95 of file DaqSource.h.

Referenced by publishToXmas().

pthread_mutex_t edm::DaqSource::mutex_
private
bool edm::DaqSource::noMoreEvents_
private
int edm::DaqSource::orbitNumber_
private

Definition at line 106 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

ProcessHistoryID edm::DaqSource::phid_
private

Definition at line 81 of file DaqSource.h.

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

xdata::UnsignedInteger32* edm::DaqSource::prescaleSetIndex_
private

Definition at line 89 of file DaqSource.h.

Referenced by getNextItemType(), and publish().

DaqBaseReader* edm::DaqSource::reader_
private

Definition at line 69 of file DaqSource.h.

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

bool edm::DaqSource::runFork_
private

Definition at line 102 of file DaqSource.h.

Referenced by getNextItemType(), and publishForkInfo().

RunNumber_t edm::DaqSource::runNumber_
private

Definition at line 78 of file DaqSource.h.

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

pthread_mutex_t edm::DaqSource::signal_lock_
private

Definition at line 86 of file DaqSource.h.

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

struct timeval edm::DaqSource::startOfLastLumi
private

Definition at line 99 of file DaqSource.h.

Referenced by DaqSource(), and getNextItemType().

unsigned int edm::DaqSource::thisEventLSid
private

Definition at line 97 of file DaqSource.h.

Referenced by getNextItemType(), and readEvent_().

timeval edm::DaqSource::tvStat_
private

Definition at line 103 of file DaqSource.h.

Referenced by doMyBeginRun(), and getNextItemType().

bool edm::DaqSource::useEventCounter_
private

Definition at line 72 of file DaqSource.h.

Referenced by getNextItemType().

bool edm::DaqSource::useTimer_
private

Definition at line 73 of file DaqSource.h.