Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:34

0001 #ifndef MillePedeFileExtractor_h
0002 #define MillePedeFileExtractor_h
0003 
0004 // Original Author:  Broen van Besien
0005 //         Created:  Mon, 23 Mar 2015 14:56:15 GMT
0006 
0007 /*
0008  * This analyzer will extract all fileblobs in the input edm/root file and
0009  * write them as files to the file system.
0010  *
0011  * It searches for the files in the vector of fileblobs that should exist on
0012  * the level of the run. Unique filenames for each file are generated based
0013  * on a formating directive in the output filename parameter.
0014  *
0015  * The operation is performed during the endRun phase.
0016  *
0017  * The original embedding of the (binary) files in the edm/root files can be
0018  * done with the corresponding module MillePedeFileConverer.
0019  *
0020  * For more info about the possible parameters, type:
0021  * edmPluginHelp -p MillePedeFileExtractor
0022  */
0023 
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "CondFormats/Common/interface/FileBlobCollection.h"
0030 
0031 class MillePedeFileExtractor : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBlocks> {
0032 public:
0033   explicit MillePedeFileExtractor(const edm::ParameterSet&);
0034   ~MillePedeFileExtractor() override = default;
0035   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0036 
0037 private:
0038   void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override {}
0039   void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
0040   void analyze(const edm::Event&, const edm::EventSetup&) override {}
0041 
0042   bool enoughBinaries() { return (nBinaries_ >= maxNumberOfBinaries_) && hasBinaryNumberLimit(); }
0043   bool hasBinaryNumberLimit() { return maxNumberOfBinaries_ > -1; }
0044 
0045   static void writeGzipped(const FileBlob&, const std::string&);
0046 
0047   const std::string outputDir_;
0048   const std::string outputFileName_;
0049 
0050   edm::InputTag fileBlobInputTag_;
0051   edm::EDGetTokenT<FileBlobCollection> fileBlobToken_;
0052 
0053   const int maxNumberOfBinaries_;
0054   int nBinaries_{0};
0055 };
0056 
0057 // define this as a plug-in
0058 DEFINE_FWK_MODULE(MillePedeFileExtractor);
0059 
0060 #endif