30 #include <sys/types.h>
32 #include "xgi/Method.h"
33 #include "xgi/Utils.h"
35 #include "cgicc/Cgicc.h"
36 #include "cgicc/FormEntry.h"
37 #include "cgicc/HTMLClasses.h"
39 #include "boost/tokenizer.hpp"
58 , evf::ModuleWeb(
"DaqSource")
60 , lumiSegmentSizeInEvents_(pset.getUntrackedParameter<unsigned int>(
"evtsPerLS",0))
61 , lumiSegmentSizeInSeconds_(pset.getUntrackedParameter<unsigned int>(
"secondsPerLS",0))
62 , useEventCounter_(pset.getUntrackedParameter<bool>(
"useEventCounter",
false))
63 , useTimer_(lumiSegmentSizeInSeconds_!=0)
65 , keepUsingPsidFromTrigger_(pset.getUntrackedParameter<bool>(
"keepUsingPsidFromTrigger",
false))
66 , fakeLSid_(lumiSegmentSizeInEvents_ != 0 || lumiSegmentSizeInSeconds_ != 0)
67 ,
runNumber_(pset.getUntrackedParameter<unsigned int>(
"runNumber",
RunID::firstValidRun().
run()))
68 , luminosityBlockNumber_(
LuminosityBlockID::firstValidLuminosityBlock().luminosityBlock())
70 , noMoreEvents_(
false)
71 , alignLsToLast_(
false)
72 , lumiSectionIndex_(0)
73 , prescaleSetIndex_(0)
74 , lastLumiPrescaleIndex_(0)
75 , lastLumiUsingEol_(0)
82 , immediateStop(
false)
85 , beginRunTiming_(
false)
93 pthread_mutex_init(&
mutex_,0);
95 pthread_cond_init(&
cond_,0);
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";
177 std::cout <<
"ERROR (DaqSource): not notified to be either in master or slave process after fork" << std::endl;
190 int slotToRestart=-1;
248 pthread_mutex_lock(&
mutex_);
249 pthread_cond_signal(&
cond_);
250 pthread_mutex_unlock(&
mutex_);
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 ";
307 <<
"DaqSource is used without a reader. Check your configuration !";
311 gettimeofday(&stv,0);
313 time = (time << 32) + stv.tv_usec;
330 pthread_mutex_lock(&
mutex_);
331 pthread_cond_signal(&
cond_);
332 pthread_mutex_unlock(&
mutex_);
338 unsigned int nextLsFromSignal = (-1)*retval+1;
369 edm::LogError(
"DaqSource") <<
"Got EOL event with value " << retval
370 <<
" nextLS would be " << nextLsFromSignal
400 <<
"The reader used with DaqSource has returned an invalid (zero) event number!\n"
401 <<
"Event numbers must begin at 1, not 0.";
407 uint32_t gtpsize = 0;
411 unsigned int nextFakeLs = 0;
438 else if(fakeLSFromTimer){
476 std::ostringstream excptmsg;
477 excptmsg <<
"DaqSource::event with late LS (" <<
thisEventLSid + 1 <<
")received.";
572 boost::shared_ptr<RunAuxiliary>
578 ra->setProcessHistoryID(
phid_);
582 boost::shared_ptr<LuminosityBlockAuxiliary>
615 eventAux.setProcessHistoryID(
phid_);
631 return &eventPrincipal;
637 <<
"The luminosity block number cannot be set externally for DaqSource.\n"
638 <<
"Contact a Framework developer.\n";
644 <<
"Random access read cannot be used for DaqSource.\n"
645 <<
"Contact a Framework developer.\n";
651 <<
"Random access skip cannot be used for DaqSource\n"
652 <<
"Contact a Framework developer.\n";
674 pthread_mutex_lock(&
mutex_);
675 if (running) *running=
true;
678 #if _POSIX_TIMERS > 0
682 gettimeofday(&tv,
NULL);
683 ts.tv_sec = tv.tv_sec + 0;
686 ts.tv_sec += timeout_sec;
688 int rc = pthread_cond_timedwait(&
cond_, &
mutex_, &ts);
695 pthread_cond_signal(&
cond_);
696 pthread_mutex_unlock(&
mutex_);
707 pthread_mutex_lock(&
mutex_);
710 pthread_cond_signal(&
cond_);
713 pthread_mutex_unlock(&
mutex_);
726 cgicc::Cgicc cgi(in);
727 if ( xgi::Utils::hasFormElement(cgi,
"gotostopping") )
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();
745 *out <<
"<html>" << endl;
746 *out <<
"<head>" << endl;
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;
755 <<
" MAIN</title>" << endl;
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;
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;
800 *out <<
"<hr/>" << endl;
802 *out << cgicc::form().set(
"method",
"GET").set(
"action", path )
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){
812 *out <<
cgicc::input().set(
"type",
"hidden").set(
"name",first).set(
"value", second)
817 *out <<
cgicc::input().set(
"type",
"hidden").set(
"name",
"gotostopping").set(
"value",
"true")
819 *out <<
cgicc::input().set(
"type",
"submit").set(
"value",
"Go To Stopping") << std::endl;
820 *out << cgicc::form() << std::endl;
822 *out <<
"</body>" << endl;
823 *out <<
"</html>" << endl;
static const char runNumber_[]
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
xdata::Boolean * lsTimedOut_
void fillEventPrincipal(EventAuxiliary const &aux, 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)
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 *)
virtual EventPrincipal * readEvent_(EventPrincipal &eventPrincipal)
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 *)
constexpr unsigned int gtpEvmId_
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
FEDRawDataCollection * fedCollection_
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)
DaqSource(const ParameterSet &pset, const InputSourceDescription &desc)
constexpr unsigned int gtpeId_
EventAuxiliary::ExperimentType evttype_
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)
unsigned int lumiSegmentSizeInSeconds_
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.
struct timeval startOfLastLumi
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_