Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubProcess does stream transitions #190

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions FWCore/Framework/interface/OutputModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ output stream.
#include "DataFormats/Provenance/interface/ModuleDescription.h"
#include "DataFormats/Provenance/interface/Selections.h"

#include "FWCore/Framework/interface/CachedProducts.h"
#include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/ProductSelectorRules.h"
#include "FWCore/Framework/interface/ProductSelector.h"
#include "FWCore/Framework/interface/EDConsumerBase.h"
#include "FWCore/Framework/interface/getAllTriggerNames.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"

#include <array>
Expand All @@ -29,9 +30,7 @@ output stream.

namespace edm {

typedef detail::CachedProducts::handle_t Trig;

std::vector<std::string> const& getAllTriggerNames();
typedef detail::TriggerResultsBasedEventSelector::handle_t Trig;

class OutputModule : public EDConsumerBase {
public:
Expand Down Expand Up @@ -74,9 +73,6 @@ namespace edm {

protected:

//Trig const& getTriggerResults(Event const& ep) const;
Trig getTriggerResults(Event const& ep) const;

// This function is needed for compatibility with older code. We
// need to clean up the use of Event and EventPrincipal, to avoid
// creation of multiple Event objects when handling a single
Expand Down Expand Up @@ -148,12 +144,8 @@ namespace edm {
// We do not own the pointed-to CurrentProcessingContext.
CurrentProcessingContext const* current_context_;

//This will store TriggerResults objects for the current event.
// mutable std::vector<Trig> prods_;
mutable bool prodsValid_;

bool wantAllEvents_;
mutable detail::CachedProducts selectors_;
mutable detail::TriggerResultsBasedEventSelector selectors_;
// ID of the ParameterSet that configured the event selector
// subsystem.
ParameterSetID selector_config_id_;
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/interface/ScheduleItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace edm {
class ActivityRegistry;
class BranchIDListHelper;
class CommonParams;
class OutputModule;
class SubProcess;
class ParameterSet;
class ProcessConfiguration;
class ProductRegistry;
Expand All @@ -25,7 +25,7 @@ namespace edm {
struct ScheduleItems {
ScheduleItems();

ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, OutputModule const& om);
ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, SubProcess const& om);

ScheduleItems(ScheduleItems const&) = delete; // Disallow copying and moving
ScheduleItems& operator=(ScheduleItems const&) = delete; // Disallow copying and moving
Expand Down
69 changes: 43 additions & 26 deletions FWCore/Framework/interface/SubProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
#define FWCore_Framework_SubProcess_h

#include "FWCore/Framework/interface/EventSetupProvider.h"
#include "FWCore/Framework/interface/OutputModule.h"
#include "FWCore/Framework/src/PrincipalCache.h"
#include "FWCore/Framework/interface/ScheduleItems.h"
#include "FWCore/Framework/interface/Schedule.h"
#include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h"
#include "FWCore/Framework/interface/ProductSelectorRules.h"
#include "FWCore/Framework/interface/ProductSelector.h"
#include "FWCore/ServiceRegistry/interface/ServiceLegacy.h"
#include "FWCore/ServiceRegistry/interface/ServiceToken.h"
#include "FWCore/Utilities/interface/BranchType.h"

#include "DataFormats/Provenance/interface/Selections.h"

#include "boost/shared_ptr.hpp"

#include <map>
Expand All @@ -25,7 +29,7 @@ namespace edm {
namespace eventsetup {
class EventSetupsController;
}
class SubProcess : public OutputModule {
class SubProcess {
public:
SubProcess(ParameterSet& parameterSet,
ParameterSet const& topLevelParameterSet,
Expand All @@ -37,14 +41,13 @@ namespace edm {
serviceregistry::ServiceLegacy iLegacy);

virtual ~SubProcess();

//From OutputModule
void selectProducts(ProductRegistry const& preg);
SelectionsArray const& keptProducts() const {return keptProducts_;}

using OutputModule::doBeginJob;
using OutputModule::doEndJob;
using OutputModule::doBeginRun;
using OutputModule::doEndRun;
using OutputModule::doBeginLuminosityBlock;
using OutputModule::doEndLuminosityBlock;
using OutputModule::doEvent;
void doBeginJob();
void doEndJob();

void doEvent(EventPrincipal const& principal, IOVSyncValue const& ts);

Expand Down Expand Up @@ -204,25 +207,22 @@ namespace edm {
}

private:
struct ESInfo {
ESInfo(IOVSyncValue const& ts, eventsetup::EventSetupProvider& esp);
IOVSyncValue const& ts_;
EventSetup const& es_;
};

virtual void beginJob();
virtual void endJob();
virtual void write(EventPrincipal const& e);
virtual void beginRun(RunPrincipal const& r);
virtual void endRun(RunPrincipal const& r);
virtual void beginLuminosityBlock(LuminosityBlockPrincipal const& lb);
virtual void endLuminosityBlock(LuminosityBlockPrincipal const& lb);
virtual void writeRun(RunPrincipal const&) { throw 0; }
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&) { throw 0; }
void beginJob();
void endJob();
void process(EventPrincipal const& e, IOVSyncValue const& ts);
void beginRun(RunPrincipal const& r, IOVSyncValue const& ts);
void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException);
void beginLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts);
void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException);

void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const;
void fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID);

std::map<BranchID::value_type, BranchID::value_type> const& droppedBranchIDToKeptBranchID() {
return droppedBranchIDToKeptBranchID_;
}


ServiceToken serviceToken_;
boost::shared_ptr<ProductRegistry const> parentPreg_;
boost::shared_ptr<ProductRegistry const> preg_;
Expand All @@ -234,10 +234,27 @@ namespace edm {
std::auto_ptr<Schedule> schedule_;
std::map<ProcessHistoryID, ProcessHistoryID> parentToChildPhID_;
std::unique_ptr<HistoryAppender> historyAppender_;
std::auto_ptr<ESInfo> esInfo_;
std::auto_ptr<SubProcess> subProcess_;
bool cleaningUpAfterException_;
std::unique_ptr<ParameterSet> processParameterSet_;

// keptProducts_ are pointers to the BranchDescription objects describing
// the branches we are to write.
//
// We do not own the BranchDescriptions to which we point.
SelectionsArray keptProducts_;
ProductSelectorRules productSelectorRules_;
ProductSelector productSelector_;


//EventSelection
bool wantAllEvents_;
ParameterSetID selector_config_id_;
mutable detail::TriggerResultsBasedEventSelector selectors_;

// needed because of possible EDAliases.
// filled in only if key and value are different.
std::map<BranchID::value_type, BranchID::value_type> droppedBranchIDToKeptBranchID_;

};

// free function
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#ifndef Framework_CachedProducts_h
#define Framework_CachedProducts_h
#ifndef FWCore_Framework_TriggerResultsBasedEventSelector_h
#define FWCore_Framework_TriggerResultsBasedEventSelector_h

// -------------------------------------------------------------------
//
// CachedProducts: This class is used by OutputModule to interact with
// TriggerResultsBasedEventSelector: This class is used by OutputModule to interact with
// the TriggerResults objects upon which the decision to write out an
// event is made.
//
// -------------------------------------------------------------------
#include <string>
#include <utility>
#include <vector>
#include <map>

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
#include "FWCore/Framework/interface/EventSelector.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Utilities/interface/InputTag.h"
Expand All @@ -32,10 +33,7 @@ namespace edm
product_()
{ }

void fill(Event const& e)
{
e.getByLabel(inputTag_, product_);
}
void fill(EventPrincipal const& e);

bool match()
{
Expand All @@ -58,11 +56,10 @@ namespace edm
handle_t product_;
};


class CachedProducts
class TriggerResultsBasedEventSelector
{
public:
CachedProducts();
TriggerResultsBasedEventSelector();
typedef detail::handle_t handle_t;
typedef std::vector<NamedEventSelector> selectors_t;
typedef selectors_t::size_type size_type;
Expand All @@ -74,23 +71,20 @@ namespace edm
std::vector<std::string> const& triggernames,
const std::string& process_name);

bool wantEvent(Event const& e);
bool wantEvent(EventPrincipal const& e);

// Get all TriggerResults objects for the process names we're
// interested in.
size_type fill(Event const& ev);

handle_t getOneTriggerResults(Event const& e);
handle_t getOneTriggerResults(EventPrincipal const& e);

// Clear the cache
void clear();

private:
typedef selectors_t::iterator iter;

// Return the number of cached TriggerResult handles
//size_type size() const { return numberFound_; }

// Get all TriggerResults objects for the process names we're
// interested in.
size_type fill(EventPrincipal const& ev);

// If we have only one handle cached, return it; otherwise throw.
handle_t returnOneHandleOrThrow();

Expand All @@ -99,6 +93,36 @@ namespace edm
size_type numberFound_;
selectors_t selectors_;
};

class TRBESSentry {
public:
TRBESSentry(detail::TriggerResultsBasedEventSelector& prods) : p(prods) {}
~TRBESSentry() {
p.clear();
}
private:
detail::TriggerResultsBasedEventSelector& p;

TRBESSentry(TRBESSentry const&) = delete;
TRBESSentry& operator=(TRBESSentry const&) = delete;
};


/** Handles the final initialization of the TriggerResutsBasedEventSelector
\return true if all events will be selected
*/
bool configureEventSelector(edm::ParameterSet const& iPSet,
std::string const& iProcessName,
std::vector<std::string> const& iAllTriggerNames,
edm::detail::TriggerResultsBasedEventSelector& oSelector);
/** Takes the user specified SelectEvents PSet and creates a new one
which conforms to the canonical format required for provenance
*/
ParameterSetID registerProperSelectionInfo(edm::ParameterSet const& iInitial,
std::string const& iLabel,
std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
bool anyProductProduced);

}
}

Expand Down
31 changes: 31 additions & 0 deletions FWCore/Framework/interface/getAllTriggerNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef FWCore_Framework_getAllTriggerNames_h
#define FWCore_Framework_getAllTriggerNames_h
// -*- C++ -*-
//
// Package: Framework
// Class : getAllTriggerNames
//
/**\function getAllTriggerNames getAllTriggerNames.h "FWCore/Framework/interface/getAllTriggerNames.h"

Description: Returns a list of all the trigger names in the current process
Usage:
<usage>

*/
//
// Original Author: Chris Jones
// Created: Fri, 26 Jul 2013 20:40:50 GMT
// $Id$
//

// system include files
#include <vector>
#include <string>

// user include files

// forward declarations
namespace edm {
std::vector<std::string> const& getAllTriggerNames();
}
#endif
Loading