CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

edm::ConfigurableInputSource Class Reference

#include <ConfigurableInputSource.h>

Inheritance diagram for edm::ConfigurableInputSource:
edm::InputSource edm::ProductRegistryHelper cond::EmptyIOVSource edm::ExternalInputSource edm::GeneratedInputSource LmfSource AlpgenSource edm::H2RootNtplSource edm::MCFileSource ErrorStreamSource HcalTBSource L1MuGMTHWFileReader LHESource MCatNLOSource PixelSLinkDataInputSource EcalSimpleSource edm::BaseFlatGunSource edm::BeamHaloSource edm::CosMuoGenSource edm::EmptySource edm::FlatBaseThetaGunSource LaserAlignmentSource

List of all members.

Public Member Functions

 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
EventNumber_t event () const
unsigned int eventCreationDelay () const
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number.
unsigned int numberEventsInLumi () const
unsigned int numberEventsInRun () const
unsigned int numberEventsInThisLumi () const
unsigned int numberEventsInThisRun () const
TimeValue_t presentTime () const
RunNumber_t run () const
 Accessor for current run number.
unsigned int timeBetweenEvents () const
virtual ~ConfigurableInputSource ()

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)

Protected Member Functions

void reallyReadEvent ()
void setEventNumber (EventNumber_t e)
void setTime (TimeValue_t t)

Private Member Functions

void advanceToNext ()
virtual void beginLuminosityBlock (LuminosityBlock &)
virtual void beginRun (Run &)
virtual void endLuminosityBlock (LuminosityBlock &)
virtual void endRun (Run &)
virtual ItemType getNextItemType ()
virtual void postForkReacquireResources (boost::shared_ptr< edm::multicore::MessageReceiverForSource >)
virtual bool produce (Event &e)=0
virtual EventPrincipalreadEvent_ ()
virtual boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
virtual boost::shared_ptr
< RunAuxiliary
readRunAuxiliary_ ()
void retreatToPrevious ()
virtual void rewind_ ()
virtual void setLumi (LuminosityBlockNumber_t lb)
virtual void setRun (RunNumber_t r)
virtual void setRunAndEventInfo ()
virtual void skip (int offset)

Private Attributes

EventAuxiliary::ExperimentType eType_
bool eventCached_
unsigned int eventCreationDelay_
EventID eventID_
bool eventSet_
bool isRealData_
bool lumiSet_
bool newLumi_
bool newRun_
unsigned int numberEventsInLumi_
unsigned int numberEventsInRun_
unsigned int numberEventsInThisLumi_
unsigned int numberEventsInThisRun_
unsigned int numberOfEventsBeforeBigSkip_
unsigned int numberOfSequentialEvents_
EventID origEventID_
TimeValue_t origTime_
TimeValue_t presentTime_
boost::shared_ptr
< edm::multicore::MessageReceiverForSource
receiver_
TimeValue_t timeBetweenEvents_
unsigned int const zerothEvent_

Detailed Description

Definition at line 19 of file ConfigurableInputSource.h.


Constructor & Destructor Documentation

edm::ConfigurableInputSource::ConfigurableInputSource ( ParameterSet const &  pset,
InputSourceDescription const &  desc,
bool  realData = true 
) [explicit]

Definition at line 20 of file ConfigurableInputSource.cc.

References presentTime_, and edm::InputSource::setTimestamp().

                                                                                          :
    InputSource(pset, desc),
    numberEventsInRun_(pset.getUntrackedParameter<unsigned int>("numberEventsInRun", remainingEvents())),
    numberEventsInLumi_(pset.getUntrackedParameter<unsigned int>("numberEventsInLuminosityBlock", remainingEvents())),
    presentTime_(pset.getUntrackedParameter<unsigned long long>("firstTime", 1ULL)),  //time in ns
    origTime_(presentTime_),
    timeBetweenEvents_(pset.getUntrackedParameter<unsigned long long>("timeBetweenEvents", kNanoSecPerSec/kAveEventPerSec)),
    eventCreationDelay_(pset.getUntrackedParameter<unsigned int>("eventCreationDelay", 0)),
    numberEventsInThisRun_(0),
    numberEventsInThisLumi_(0),
    zerothEvent_(pset.getUntrackedParameter<unsigned int>("firstEvent", 1) - 1),
    eventID_(pset.getUntrackedParameter<unsigned int>("firstRun", 1), pset.getUntrackedParameter<unsigned int>("firstLuminosityBlock", 1), zerothEvent_),
    origEventID_(eventID_),
    newRun_(true),
    newLumi_(true),
    eventCached_(false),
    lumiSet_(false),
    eventSet_(false),
    isRealData_(realData),
    eType_(EventAuxiliary::Undefined),
    numberOfEventsBeforeBigSkip_(0),
    numberOfSequentialEvents_(0)
  { 

    setTimestamp(Timestamp(presentTime_));
    // We need to map this string to the EventAuxiliary::ExperimentType enumeration
    // std::string eType = pset.getUntrackedParameter<std::string>("experimentType", std::string("Any"))),
  }
edm::ConfigurableInputSource::~ConfigurableInputSource ( ) [virtual]

Definition at line 50 of file ConfigurableInputSource.cc.

                                                    {
  }

Member Function Documentation

void edm::ConfigurableInputSource::advanceToNext ( ) [private]
void edm::ConfigurableInputSource::beginLuminosityBlock ( LuminosityBlock ) [private, virtual]

Reimplemented from edm::InputSource.

Reimplemented in ErrorStreamSource.

Definition at line 123 of file ConfigurableInputSource.cc.

                                                                {
  }
void edm::ConfigurableInputSource::beginRun ( Run ) [private, virtual]

Reimplemented from edm::InputSource.

Reimplemented in ErrorStreamSource, AlpgenSource, LHESource, and MCatNLOSource.

Definition at line 115 of file ConfigurableInputSource.cc.

                                        {
  }
void edm::ConfigurableInputSource::endLuminosityBlock ( LuminosityBlock ) [private, virtual]

Reimplemented from edm::InputSource.

Reimplemented in ErrorStreamSource.

Definition at line 127 of file ConfigurableInputSource.cc.

                                                              {
  }
void edm::ConfigurableInputSource::endRun ( Run ) [private, virtual]

Reimplemented from edm::InputSource.

Reimplemented in ErrorStreamSource, edm::CosMuoGenSource, and LHESource.

Definition at line 119 of file ConfigurableInputSource.cc.

                                      {
  }
EventNumber_t edm::ConfigurableInputSource::event ( ) const [inline]
unsigned int edm::ConfigurableInputSource::eventCreationDelay ( ) const [inline]

Definition at line 28 of file ConfigurableInputSource.h.

References eventCreationDelay_.

void edm::ConfigurableInputSource::fillDescription ( ParameterSetDescription desc) [static]

Reimplemented from edm::InputSource.

Reimplemented in edm::ExternalInputSource.

Definition at line 296 of file ConfigurableInputSource.cc.

References edm::ParameterSetDescription::addOptionalUntracked(), edm::ParameterSetDescription::addUntracked(), edm::kAveEventPerSec, and edm::kNanoSecPerSec.

Referenced by edm::EmptySource::fillDescriptions().

                                                                        {
    desc.addOptionalUntracked<unsigned int>("numberEventsInRun")->setComment("Number of events to generate in each run.");
    desc.addOptionalUntracked<unsigned int>("numberEventsInLuminosityBlock")->setComment("Number of events to generate in each lumi.");
    desc.addUntracked<unsigned long long>("firstTime", 1)->setComment("Time before first event (ns) (for timestamp).");
    desc.addUntracked<unsigned long long>("timeBetweenEvents", kNanoSecPerSec/kAveEventPerSec)->setComment("Time between consecutive events (ns) (for timestamp).");
    desc.addUntracked<unsigned int>("eventCreationDelay", 0)->setComment("Real time delay between generation of consecutive events (ms).");
    desc.addUntracked<unsigned int>("firstEvent", 1)->setComment("Event number of first event to generate.");
    desc.addUntracked<unsigned int>("firstLuminosityBlock", 1)->setComment("Luminosity block number of first lumi to generate.");
    desc.addUntracked<unsigned int>("firstRun", 1)->setComment("Run number of first run to generate.");
    InputSource::fillDescription(desc);
  }
InputSource::ItemType edm::ConfigurableInputSource::getNextItemType ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 178 of file ConfigurableInputSource.cc.

References eventCached_, eventID_, eventSet_, edm::InputSource::IsEvent, edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, edm::EventID::luminosityBlock(), lumiSet_, newLumi_, newRun_, origEventID_, edm::InputSource::processingMode(), reallyReadEvent(), edm::EventID::run(), edm::InputSource::Runs, edm::EventID::setLuminosityBlockNumber(), and setRunAndEventInfo().

                                           {
    if (newRun_) {
      if (eventID_.run() == RunNumber_t()) {
        eventCached_ = false;
        return IsStop;
      }
      return IsRun;
    }
    if (newLumi_) {
      return IsLumi;
    }
    if(eventCached_) {
      return IsEvent;
    }
    EventID oldEventID = eventID_;
    LuminosityBlockNumber_t oldLumi = eventID_.luminosityBlock();
    if (!eventSet_) {
      lumiSet_ = false;
      setRunAndEventInfo();
      eventSet_ = true;
    }
    if (eventID_.run() == RunNumber_t()) {
      eventCached_ = false;
      return IsStop;
    }
    if (oldEventID.run() != eventID_.run()) {
      //  New Run
      // If the user did not explicitly set the luminosity block number,
      // reset it back to the beginning.
      if (!lumiSet_) {
        eventID_.setLuminosityBlockNumber(origEventID_.luminosityBlock());
      }
      newRun_ = newLumi_ = true;
      return IsRun;
    }
      // Same Run
    if (oldLumi != eventID_.luminosityBlock()) {
      // New Lumi
      newLumi_ = true;
      if (processingMode() != Runs) {
        return IsLumi;
      }
    }
    reallyReadEvent();
    if(!eventCached_) {
      return IsStop;
    }
    eventSet_ = false;
    return IsEvent;
  }
LuminosityBlockNumber_t edm::ConfigurableInputSource::luminosityBlock ( ) const [inline]

Accessor for current luminosity block number.

Reimplemented from edm::InputSource.

Definition at line 33 of file ConfigurableInputSource.h.

References eventID_, and edm::EventID::luminosityBlock().

Referenced by setEventNumber().

{return eventID_.luminosityBlock();}
unsigned int edm::ConfigurableInputSource::numberEventsInLumi ( ) const [inline]

Definition at line 25 of file ConfigurableInputSource.h.

References numberEventsInLumi_.

unsigned int edm::ConfigurableInputSource::numberEventsInRun ( ) const [inline]
unsigned int edm::ConfigurableInputSource::numberEventsInThisLumi ( ) const [inline]

Definition at line 30 of file ConfigurableInputSource.h.

References numberEventsInThisLumi_.

unsigned int edm::ConfigurableInputSource::numberEventsInThisRun ( ) const [inline]

Definition at line 29 of file ConfigurableInputSource.h.

References numberEventsInThisRun_.

void edm::ConfigurableInputSource::postForkReacquireResources ( boost::shared_ptr< edm::multicore::MessageReceiverForSource iReceiver) [private, virtual]

Definition at line 146 of file ConfigurableInputSource.cc.

References numberOfEventsBeforeBigSkip_, numberOfSequentialEvents_, receiver_, edm::InputSource::repeat(), and edm::InputSource::rewind().

                                                                                                                     {
    receiver_ = iReceiver;
    receiver_->receive();
    numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices() + 1;
    numberOfSequentialEvents_ = receiver_->numberOfConsecutiveIndices();
    repeat();
    rewind();
  }
TimeValue_t edm::ConfigurableInputSource::presentTime ( ) const [inline]

Definition at line 26 of file ConfigurableInputSource.h.

References presentTime_.

Referenced by HcalTBSource::setRunAndEventInfo().

{return presentTime_;}
virtual bool edm::ConfigurableInputSource::produce ( Event e) [private, pure virtual]
EventPrincipal * edm::ConfigurableInputSource::readEvent_ ( ) [private, virtual]
boost::shared_ptr< LuminosityBlockAuxiliary > edm::ConfigurableInputSource::readLuminosityBlockAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 61 of file ConfigurableInputSource.cc.

References eventID_, edm::Timestamp::invalidTimestamp(), edm::EventID::luminosityBlock(), newLumi_, presentTime_, edm::InputSource::processingMode(), edm::EventID::run(), and edm::InputSource::Runs.

                                                         {
    if (processingMode() == Runs) return boost::shared_ptr<LuminosityBlockAuxiliary>();
    Timestamp ts = Timestamp(presentTime_);
    newLumi_ = false;
    return boost::shared_ptr<LuminosityBlockAuxiliary>(new LuminosityBlockAuxiliary(eventID_.run(), eventID_.luminosityBlock(), ts, Timestamp::invalidTimestamp()));
  }
boost::shared_ptr< RunAuxiliary > edm::ConfigurableInputSource::readRunAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 54 of file ConfigurableInputSource.cc.

References eventID_, edm::Timestamp::invalidTimestamp(), newRun_, presentTime_, and edm::EventID::run().

                                             {
    Timestamp ts = Timestamp(presentTime_);
    newRun_ = false;
    return boost::shared_ptr<RunAuxiliary>(new RunAuxiliary(eventID_.run(), ts, Timestamp::invalidTimestamp()));
  }
void edm::ConfigurableInputSource::reallyReadEvent ( ) [protected]
void edm::ConfigurableInputSource::retreatToPrevious ( ) [private]

Definition at line 252 of file ConfigurableInputSource.cc.

References eventID_, edm::EventID::luminosityBlock(), numberEventsInLumi_, numberEventsInRun_, numberEventsInThisLumi_, numberEventsInThisRun_, origEventID_, presentTime_, edm::EventID::previous(), edm::EventID::previousRunLastEvent(), edm::EventID::run(), and timeBetweenEvents_.

Referenced by skip().

                                              {
    if (numberEventsInRun_ < 1 || numberEventsInThisRun_ > 0) {
      // same run
      --numberEventsInThisRun_;
      eventID_ = eventID_.previous(eventID_.luminosityBlock());
      if (!(numberEventsInLumi_ < 1 || numberEventsInThisLumi_ > 0)) {
        // new lumi
        eventID_ = eventID_.previous(eventID_.luminosityBlock() - 1);
        numberEventsInThisLumi_ = numberEventsInLumi_;
      } else {
        --numberEventsInThisLumi_;
      }
    } else {
      // new run
      eventID_ = eventID_.previousRunLastEvent(origEventID_.luminosityBlock() + numberEventsInRun_/numberEventsInLumi_);
      eventID_ = EventID(numberEventsInRun_, eventID_.luminosityBlock(), eventID_.run());
      numberEventsInThisLumi_ = numberEventsInLumi_;
      numberEventsInThisRun_ = numberEventsInRun_;
    }
    presentTime_ -= timeBetweenEvents_;
  }
void edm::ConfigurableInputSource::rewind_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 156 of file ConfigurableInputSource.cc.

References edm::InputSource::decreaseRemainingEventsBy(), eventID_, newLumi_, newRun_, numberEventsInThisLumi_, numberEventsInThisRun_, numberOfEventsBeforeBigSkip_, origEventID_, origTime_, presentTime_, receiver_, and skip().

                                   {
    presentTime_ = origTime_;
    eventID_ = origEventID_;
    numberEventsInThisRun_ = 0;
    numberEventsInThisLumi_ = 0;

    if(receiver_) {
      unsigned int numberToSkip = receiver_->numberToSkip();
      numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices() + 1;
      //NOTE: skip() will decrease numberOfEventsBeforeBigSkip_ and therefore we need
      // to be sure it is large enough so that it never goes to 0 during the skipping
      if(numberOfEventsBeforeBigSkip_ < numberToSkip) {
        numberOfEventsBeforeBigSkip_ = numberToSkip+1;
      }
      skip(numberToSkip);
      decreaseRemainingEventsBy(numberToSkip);
      numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices() + 1;
    }
    newRun_ = newLumi_ = true;
  }
RunNumber_t edm::ConfigurableInputSource::run ( void  ) const [inline]

Accessor for current run number.

Reimplemented from edm::InputSource.

Definition at line 31 of file ConfigurableInputSource.h.

References eventID_, and edm::EventID::run().

Referenced by setEventNumber().

{return eventID_.run();}
void edm::ConfigurableInputSource::setEventNumber ( EventNumber_t  e) [inline, protected]
void edm::ConfigurableInputSource::setLumi ( LuminosityBlockNumber_t  lb) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 131 of file ConfigurableInputSource.cc.

References eventID_, edm::EventID::luminosityBlock(), lumiSet_, newLumi_, numberEventsInThisLumi_, origEventID_, and edm::EventID::setLuminosityBlockNumber().

                                                             {
    // Protect against invalid lumi.
    if (lb == LuminosityBlockNumber_t()) {
        lb = origEventID_.luminosityBlock();
    }
    // Do nothing if the lumi block is not changed.
    if (lb != eventID_.luminosityBlock()) {
      eventID_.setLuminosityBlockNumber(lb);
      numberEventsInThisLumi_ = 0;
      newLumi_ = true;
    }
    lumiSet_ = true;
  }
void edm::ConfigurableInputSource::setRun ( RunNumber_t  r) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 102 of file ConfigurableInputSource.cc.

References eventID_, edm::EventID::luminosityBlock(), newLumi_, newRun_, numberEventsInThisLumi_, numberEventsInThisRun_, origEventID_, edm::EventID::run(), and zerothEvent_.

                                               {
    // No need to check for invalid (zero) run number,
    // as this is a legitimate way of stopping the job.
    // Do nothing if the run is not changed.
    if (r != eventID_.run()) {
      eventID_ = EventID(r, origEventID_.luminosityBlock(), zerothEvent_);
      numberEventsInThisRun_ = 0;
      numberEventsInThisLumi_ = 0;
      newRun_ = newLumi_ = true;
    }
  }
void edm::ConfigurableInputSource::setRunAndEventInfo ( ) [private, virtual]

Reimplemented in LmfSource, cond::EmptyIOVSource, ErrorStreamSource, HcalTBSource, and L1MuGMTHWFileReader.

Definition at line 275 of file ConfigurableInputSource.cc.

References advanceToNext(), edm::InputSource::decreaseRemainingEventsBy(), eventCreationDelay_, eventID_, numberOfEventsBeforeBigSkip_, receiver_, edm::InputSource::remainingEvents(), edm::InputSource::remainingLuminosityBlocks(), and skip().

Referenced by getNextItemType().

                                              {
    if(receiver_ && 0 == --numberOfEventsBeforeBigSkip_) {
      receiver_->receive();
      unsigned long numberOfEventsToSkip = receiver_->numberToSkip();
      if (numberOfEventsToSkip !=0) {
        skip(numberOfEventsToSkip);
        decreaseRemainingEventsBy(numberOfEventsToSkip);
      }
      numberOfEventsBeforeBigSkip_ = receiver_->numberOfConsecutiveIndices();
      //Since we decrease 'remaining events' count we need to see if we reached 0 and therefore are at the end
      if(0 == numberOfEventsBeforeBigSkip_ or 0==remainingEvents() or 0 == remainingLuminosityBlocks()) {
        //this means we are to stop
        eventID_ = EventID();
        return;
      }
    }
    advanceToNext();
    if (eventCreationDelay_ > 0) {usleep(eventCreationDelay_);}
  }
void edm::ConfigurableInputSource::setTime ( TimeValue_t  t) [inline, protected]
void edm::ConfigurableInputSource::skip ( int  offset) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 91 of file ConfigurableInputSource.cc.

References advanceToNext(), evf::evtn::offset(), and retreatToPrevious().

Referenced by rewind_(), and setRunAndEventInfo().

                                          {
    for (; offset < 0; ++offset) {
      retreatToPrevious();
    }
    for (; offset > 0; --offset) {
      advanceToNext();
    }
  }
unsigned int edm::ConfigurableInputSource::timeBetweenEvents ( ) const [inline]

Definition at line 27 of file ConfigurableInputSource.h.

References timeBetweenEvents_.

Referenced by HcalTBSource::setRunAndEventInfo().


Member Data Documentation

Definition at line 85 of file ConfigurableInputSource.h.

Referenced by reallyReadEvent().

Definition at line 81 of file ConfigurableInputSource.h.

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

Definition at line 72 of file ConfigurableInputSource.h.

Referenced by eventCreationDelay(), and setRunAndEventInfo().

Definition at line 83 of file ConfigurableInputSource.h.

Referenced by getNextItemType(), and setEventNumber().

Definition at line 84 of file ConfigurableInputSource.h.

Referenced by reallyReadEvent().

Definition at line 82 of file ConfigurableInputSource.h.

Referenced by getNextItemType(), and setLumi().

Definition at line 79 of file ConfigurableInputSource.h.

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

Definition at line 68 of file ConfigurableInputSource.h.

Referenced by advanceToNext(), numberEventsInLumi(), and retreatToPrevious().

Definition at line 67 of file ConfigurableInputSource.h.

Referenced by advanceToNext(), numberEventsInRun(), and retreatToPrevious().

Definition at line 90 of file ConfigurableInputSource.h.

Referenced by postForkReacquireResources().

Definition at line 70 of file ConfigurableInputSource.h.

Referenced by rewind_().

Definition at line 71 of file ConfigurableInputSource.h.

Referenced by advanceToNext(), retreatToPrevious(), and timeBetweenEvents().

unsigned int const edm::ConfigurableInputSource::zerothEvent_ [private]

Definition at line 76 of file ConfigurableInputSource.h.

Referenced by setRun().