31 #include <sys/types.h>
33 #include "xgi/Method.h"
34 #include "xgi/Utils.h"
36 #include "cgicc/Cgicc.h"
37 #include "cgicc/FormEntry.h"
38 #include "cgicc/HTMLClasses.h"
40 #include "boost/tokenizer.hpp"
59 , evf::ModuleWeb(
"DaqSource")
61 , lumiSegmentSizeInEvents_(pset.getUntrackedParameter<unsigned int>(
"evtsPerLS",0))
62 , useEventCounter_(pset.getUntrackedParameter<bool>(
"useEventCounter",
false))
64 , keepUsingPsidFromTrigger_(pset.getUntrackedParameter<bool>(
"keepUsingPsidFromTrigger",
false))
65 , fakeLSid_(lumiSegmentSizeInEvents_ != 0)
67 , luminosityBlockNumber_(
LuminosityBlockID::firstValidLuminosityBlock().luminosityBlock())
69 , noMoreEvents_(
false)
73 , alignLsToLast_(
false)
78 , immediateStop(
false)
81 , beginRunTiming_(
false)
84 pthread_mutex_init(&
mutex_,0);
86 pthread_cond_init(&
cond_,0);
147 gettimeofday(&tsTmp,
NULL);
148 long tusecs = (tsTmp.tv_sec-
tvStat_.tv_sec)*1000000 + tsTmp.tv_usec -
tvStat_.tv_usec;
149 double tsecs = ((
double)(tusecs/10000))/100.;
150 std::cout <<
"DaqSource: FWK beginRun elapsed time: " << tsecs <<
" seconds in master EP"<< std::endl;
151 edm::LogInfo(
"DaqSource") <<
"FWK beginRun elapsed time: " << tsecs <<
" seconds in master EP";
162 std::cout <<
"ERROR (DaqSource): not notified to be either in master or slave process after fork" << std::endl;
175 int slotToRestart=-1;
233 pthread_mutex_lock(&
mutex_);
234 pthread_cond_signal(&
cond_);
235 pthread_mutex_unlock(&
mutex_);
245 gettimeofday(&tsTmp,
NULL);
246 long tusecs = (tsTmp.tv_sec-
tvStat_.tv_sec)*1000000 + tsTmp.tv_usec -
tvStat_.tv_usec;
247 double tsecs = ((
double)(tusecs/10000))/100.;
248 std::cout <<
"DaqSource (slave pid "<< getpid() <<
" ): FWK beginRun elapsed time: "
249 << tsecs <<
" seconds "<< std::endl;
250 edm::LogInfo(
"DaqSource") <<
"DaqSource (slave pid "<< getpid() <<
" ): FWK beginRun elapsed time: "
251 << tsecs <<
" seconds ";
290 <<
"DaqSource is used without a reader. Check your configuration !";
295 gettimeofday(&stv,0);
297 time = (time << 32) + stv.tv_usec;
312 if (0 != fedCollection)
delete fedCollection;
314 pthread_mutex_lock(&
mutex_);
315 pthread_cond_signal(&
cond_);
316 pthread_mutex_unlock(&
mutex_);
322 unsigned int nextLsFromSignal = (-1)*retval+1;
350 edm::LogError(
"DaqSource") <<
"Got EOL event with value " << retval
351 <<
" nextLS would be " << nextLsFromSignal
377 if (eventId.
event() == 0) {
379 <<
"The reader used with DaqSource has returned an invalid (zero) event number!\n"
380 <<
"Event numbers must begin at 1, not 0.";
386 uint32_t gtpsize = 0;
390 unsigned int nextFakeLs = 0;
422 std::ostringstream excptmsg;
423 excptmsg <<
"DaqSource::event with late LS (" <<
thisEventLSid + 1 <<
")received.";
504 eventAux.setProcessHistoryID(
phid_);
509 std::auto_ptr<FEDRawDataCollection> bare_product(fedCollection);
538 boost::shared_ptr<RunAuxiliary>
544 ra->setProcessHistoryID(
phid_);
548 boost::shared_ptr<LuminosityBlockAuxiliary>
579 <<
"The luminosity block number cannot be set externally for DaqSource.\n"
580 <<
"Contact a Framework developer.\n";
586 <<
"Random access read cannot be used for DaqSource.\n"
587 <<
"Contact a Framework developer.\n";
593 <<
"Random access skip cannot be used for DaqSource\n"
594 <<
"Contact a Framework developer.\n";
616 pthread_mutex_lock(&
mutex_);
617 if (running) *running=
true;
620 #if _POSIX_TIMERS > 0
624 gettimeofday(&tv,
NULL);
625 ts.tv_sec = tv.tv_sec + 0;
628 ts.tv_sec += timeout_sec;
630 int rc = pthread_cond_timedwait(&
cond_, &
mutex_, &ts);
637 pthread_cond_signal(&
cond_);
638 pthread_mutex_unlock(&
mutex_);
646 pthread_mutex_lock(&
mutex_);
649 pthread_cond_signal(&
cond_);
652 pthread_mutex_unlock(&
mutex_);
662 std::string original_referrer_;
665 cgicc::Cgicc cgi(in);
666 if ( xgi::Utils::hasFormElement(cgi,
"gotostopping") )
670 if ( xgi::Utils::hasFormElement(cgi,
"module") )
671 mname = xgi::Utils::getFormElement(cgi,
"module")->getValue();
672 cgicc::CgiEnvironment cgie(in);
673 if(original_referrer_ ==
"")
674 original_referrer_ = cgie.getReferrer();
675 path = cgie.getPathInfo();
676 query = cgie.getQueryString();
684 *out <<
"<html>" << endl;
685 *out <<
"<head>" << endl;
688 *out <<
"<STYLE type=\"text/css\"> #T1 {border-width: 2px; border: solid blue; text-align: center} </STYLE> " << endl;
689 *out <<
"<link type=\"text/css\" rel=\"stylesheet\"";
690 *out <<
" href=\"/" << urn
691 <<
"/styles.css\"/>" << endl;
694 <<
" MAIN</title>" << endl;
696 *out <<
"</head>" << endl;
697 *out <<
"<body onload=\"loadXMLDoc()\">" << endl;
698 *out <<
"<table border=\"0\" width=\"100%\">" << endl;
699 *out <<
"<tr>" << endl;
700 *out <<
" <td align=\"left\">" << endl;
701 *out <<
" <img" << endl;
702 *out <<
" align=\"middle\"" << endl;
703 *out <<
" src=\"/evf/images/bugicon.jpg\"" << endl;
704 *out <<
" alt=\"main\"" << endl;
705 *out <<
" width=\"90\"" << endl;
706 *out <<
" height=\"64\"" << endl;
707 *out <<
" border=\"\"/>" << endl;
708 *out <<
" <b>" << endl;
710 *out <<
" </b>" << endl;
711 *out <<
" </td>" << endl;
712 *out <<
" <td width=\"32\">" << endl;
713 *out <<
" <a href=\"/urn:xdaq-application:lid=3\">" << endl;
714 *out <<
" <img" << endl;
715 *out <<
" align=\"middle\"" << endl;
716 *out <<
" src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
717 *out <<
" alt=\"HyperDAQ\"" << endl;
718 *out <<
" width=\"32\"" << endl;
719 *out <<
" height=\"32\"" << endl;
720 *out <<
" border=\"\"/>" << endl;
721 *out <<
" </a>" << endl;
722 *out <<
" </td>" << endl;
723 *out <<
" <td width=\"32\">" << endl;
724 *out <<
" </td>" << endl;
725 *out <<
" <td width=\"32\">" << endl;
726 *out <<
" <a href=\"" << original_referrer_ <<
"\">" << endl;
727 *out <<
" <img" << endl;
728 *out <<
" align=\"middle\"" << endl;
729 *out <<
" src=\"/evf/images/spoticon.jpg\"" << endl;
730 *out <<
" alt=\"main\"" << endl;
731 *out <<
" width=\"32\"" << endl;
732 *out <<
" height=\"32\"" << endl;
733 *out <<
" border=\"\"/>" << endl;
734 *out <<
" </a>" << endl;
735 *out <<
" </td>" << endl;
736 *out <<
"</tr>" << endl;
737 *out <<
"</table>" << endl;
739 *out <<
"<hr/>" << endl;
741 *out << cgicc::form().set(
"method",
"GET").set(
"action", path )
743 boost::char_separator<char> sep(
"&");
744 boost::tokenizer<boost::char_separator<char> > tokens(query, sep);
745 for (
boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
746 tok_iter != tokens.end(); ++tok_iter){
747 size_t pos = (*tok_iter).find_first_of(
"=");
748 if(pos != std::string::npos){
749 std::string
first = (*tok_iter).substr(0 , pos);
750 std::string
second = (*tok_iter).substr(pos+1, (*tok_iter).length()-pos-1);
751 *out <<
cgicc::input().set(
"type",
"hidden").set(
"name",first).set(
"value", second)
756 *out <<
cgicc::input().set(
"type",
"hidden").set(
"name",
"gotostopping").set(
"value",
"true")
758 *out <<
cgicc::input().set(
"type",
"submit").set(
"value",
"Go To Stopping") << std::endl;
759 *out << cgicc::form() << std::endl;
761 *out <<
"</body>" << endl;
762 *out <<
"</html>" << endl;
static const char runNumber_[]
void setLuminosityBlockPrincipal(boost::shared_ptr< LuminosityBlockPrincipal > const &lbp)
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
xdata::Boolean * lsTimedOut_
unsigned int getgpshigh(const unsigned char *)
evf::moduleweb::ForkInfoObj * forkInfo_
LuminosityBlockNumber_t luminosityBlockNumber_
ProductProvenance dummyProvenance_
unsigned int getfdlbx(const unsigned char *)
bool gtpe_board_sense(const unsigned char *p)
virtual void closeBackDoor()
virtual ItemType getNextItemType()
xdata::UnsignedInteger32 * lumiSectionIndex_
virtual boost::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_()
unsigned int eventCounter_
xdata::Boolean * lsToBeRecovered_
virtual void publish(xdata::InfoSpace *)
boost::tokenizer< boost::char_separator< char > > tokenizer
DaqProvenanceHelper daqProvenanceHelper_
virtual void publishToXmas(xdata::InfoSpace *)
std::string const & category() const
xdata::UnsignedInteger32 * lastLumiUsingEol_
void(* forkHandler)(void *)
void put(ConstBranchDescription const &bd, WrapperOwningHolder const &edp, ProductProvenance const &productProvenance)
unsigned int getfdlpsc(const unsigned char *)
unsigned int LuminosityBlockNumber_t
size_t size() const
Lenght of the data buffer in bytes.
ProcessHistoryID daqInit(ProductRegistry &productRegistry) const
U second(std::pair< T, U > const &p)
pthread_mutex_t signal_lock_
unsigned int stopCondition
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static int const invalidBunchXing
unsigned int getlbn(const unsigned char *)
ConstBranchDescription constBranchDescription_
xdata::UnsignedInteger32 * prescaleSetIndex_
virtual void signalWaitingThreadAndBlock()
bool keepUsingPsidFromTrigger_
unsigned long long TimeValue_t
virtual void publishForkInfo(evf::moduleweb::ForkInfoObj *forkInfoObj)
bool evm_board_sense(const unsigned char *p, size_t size)
void fillEventPrincipal(EventAuxiliary const &aux, boost::shared_ptr< LuminosityBlockPrincipal > lbp, boost::shared_ptr< EventSelectionIDVector > eventSelectionIDs=boost::shared_ptr< EventSelectionIDVector >(), boost::shared_ptr< BranchListIndexes > branchListIndexes=boost::shared_ptr< BranchListIndexes >(), boost::shared_ptr< BranchMapper > mapper=boost::shared_ptr< BranchMapper >(new BranchMapper), DelayedReader *reader=0)
DaqSource(const ParameterSet &pset, const InputSourceDescription &desc)
virtual void skip(int offset)
virtual void setRun(RunNumber_t r)
unsigned int getorbit(const unsigned char *)
unsigned int gtpe_getorbit(const unsigned char *)
static Timestamp const & invalidTimestamp()
void defaultWebPage(xgi::Input *in, xgi::Output *out)
virtual int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)=0
unsigned int lumiSegmentSizeInEvents_
virtual void openBackDoor(unsigned int, bool *)
unsigned int getevtyp(const unsigned char *)
virtual EventPrincipal * readIt(EventID const &eventID)
static int const invalidStoreNumber
static Timestamp const & beginOfTime()
unsigned int gtpe_getbx(const unsigned char *)
virtual void setRunNumber(edm::RunNumber_t runNumber)
set the run number
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned int thisEventLSid
unsigned int gtpe_getlbn(const unsigned char *)
T first(std::pair< T, U > const &p)
virtual void setLumi(LuminosityBlockNumber_t lb)
virtual boost::shared_ptr< RunAuxiliary > readRunAuxiliary_()
unsigned int getgpslow(const unsigned char *)
T get(const Candidate &c)
xdata::UnsignedInteger32 * lastLumiPrescaleIndex_
virtual EventPrincipal * readEvent_()