Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-31 02:19:21

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 #include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"
0014 
0015 #include <iosfwd>
0016 #include <map>
0017 #include <string>
0018 #include <vector>
0019 
0020 namespace edm {
0021   class ProductRegistry;
0022   class ProductSelectorRules;
0023   class ParameterSet;
0024 
0025   class ProductSelector {
0026   public:
0027     ProductSelector();
0028 
0029     // N.B.: we assume there are not null pointers in the vector allBranches.
0030     void initialize(ProductSelectorRules const& rules,
0031                     std::vector<ProductDescription const*> const& productDescriptions);
0032 
0033     bool selected(ProductDescription 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(
0041         ProductDescription const& desc, std::map<BranchID, ProductDescription const*>& trueBranchIDToKeptBranchDesc);
0042 
0043     static void fillDroppedToKept(ProductRegistry const& preg,
0044                                   std::map<BranchID, ProductDescription 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) ProductDescriptions,
0052     // so that we can do pointer comparison rather than string
0053     // comparison. This will work if the ProductDescription 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