Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-27 07:19:50

0001 #ifndef DataFormats_Provenance_interface_ProductNamePattern_h
0002 #define DataFormats_Provenance_interface_ProductNamePattern_h
0003 
0004 #include <string>
0005 #include <regex>
0006 #include <vector>
0007 
0008 #include "DataFormats/Provenance/interface/ProductDescription.h"
0009 
0010 namespace edm {
0011 
0012   /* ProductNamePattern
0013    *
0014    * A ProductNamePattern is constructed from a string representing either a module label (e.g. "<module label>") or a
0015    * a branch name (e.g. "<product type>_<module label>_<instance name>_<process name>").
0016    *
0017    * A ProductNamePattern object can be compared with a ProductDescription object using the match() method:
0018    *
0019    *     productPattern.match(product)
0020    *
0021    * .
0022    * Glob expressions ("?" and "*") are supported in module labels and within the individual fields of branch names,
0023    * similar to an OutputModule's "keep" statements.
0024    * Use "*" to match all products of a given category.
0025    *
0026    * If a module label is used, it must not contain any underscores ("_"); the resulting ProductNamePattern will match all
0027    * the branches prodced by a module with the given label, including those with a non-empty instance names, and those
0028    * produced by the Transformer functionality (such as the implicitly copied-to-host products in case of Alpaka-based
0029    * modules).
0030    * If a branch name is used, all four fields must be present, separated by underscores; the resulting ProductNamePattern
0031    * will match the branches matching all four fields.
0032    * Only in this case and only for transient products, the module label may contain additional underscores.
0033    *
0034    * For example, in the case of products from an Alpaka-based producer running on a device
0035    *
0036    *     ProductNamePattern("module")
0037    *
0038    * would match all branches produced by "module", including the automatic host copy of its device products.
0039    * While
0040    *
0041    *     ProductNamePattern( "*DeviceProduct_module_*_*" )
0042    *
0043    * would match only the branches corresponding to the device products.
0044    */
0045 
0046   class ProductNamePattern {
0047   public:
0048     explicit ProductNamePattern(std::string const& label);
0049 
0050     bool match(edm::ProductDescription const& product) const;
0051 
0052   private:
0053     std::regex type_;
0054     std::regex moduleLabel_;
0055     std::regex productInstanceName_;
0056     std::regex processName_;
0057   };
0058 
0059   /* productPatterns
0060    *
0061    * Utility function to construct a vector<edm::ProductNamePattern> from a vector<std::string>.
0062    */
0063   std::vector<ProductNamePattern> productPatterns(std::vector<std::string> const& labels);
0064 
0065 }  // namespace edm
0066 
0067 #endif  // DataFormats_Provenance_interface_ProductNamePattern_h