Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:48

0001 #ifndef FWCore_Framework_ProductSelector_h
0002 #define FWCore_Framework_ProductSelector_h
0003 
0004 //////////////////////////////////////////////////////////////////////
0005 //
0006 // Class ProductSelector. Class for user to select specific products in event.
0007 //
0008 // Author: Bill Tanenbaum, Marc Paterno
0009 //
0010 //////////////////////////////////////////////////////////////////////
0011 
0012 #include "DataFormats/Provenance/interface/BranchID.h"
0013 
0014 #include <iosfwd>
0015 #include <map>
0016 #include <string>
0017 #include <vector>
0018 
0019 namespace edm {
0020   class BranchDescription;
0021   class BranchID;
0022   class ProductRegistry;
0023   class ProductSelectorRules;
0024   class ParameterSet;
0025 
0026   class ProductSelector {
0027   public:
0028     ProductSelector();
0029 
0030     // N.B.: we assume there are not null pointers in the vector allBranches.
0031     void initialize(ProductSelectorRules const& rules, std::vector<BranchDescription const*> const& branchDescriptions);
0032 
0033     bool selected(BranchDescription const& desc) const;
0034 
0035     // Printout intended for debugging purposes.
0036     void print(std::ostream& os) const;
0037 
0038     bool initialized() const { return initialized_; }
0039 
0040     static void checkForDuplicateKeptBranch(BranchDescription const& desc,
0041                                             std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc);
0042 
0043     static void fillDroppedToKept(ProductRegistry const& preg,
0044                                   std::map<BranchID, BranchDescription const*> const& trueBranchIDToKeptBranchDesc,
0045                                   std::map<BranchID::value_type, BranchID::value_type>& droppedBranchIDToKeptBranchID_);
0046 
0047   private:
0048     // We keep a sorted collection of branch names, indicating the
0049     // products which are to be selected.
0050 
0051     // TODO: See if we can keep pointer to (const) BranchDescriptions,
0052     // so that we can do pointer comparison rather than string
0053     // comparison. This will work if the BranchDescription we are
0054     // given in the 'selected' member function is one of the instances
0055     // that are managed by the ProductRegistry used to initialize the
0056     // entity that contains this ProductSelector.
0057     std::vector<std::string> productsToSelect_;
0058     bool initialized_;
0059   };
0060 
0061   std::ostream& operator<<(std::ostream& os, const ProductSelector& gs);
0062 
0063 }  // namespace edm
0064 
0065 #endif