Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:05

0001 #ifndef IOPool_Input_InputFile_h
0002 #define IOPool_Input_InputFile_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 Holder for an input TFile.
0007 ----------------------------------------------------------------------*/
0008 #include "FWCore/MessageLogger/interface/JobReport.h"
0009 #include "FWCore/Utilities/interface/InputType.h"
0010 #include "FWCore/Utilities/interface/propagate_const.h"
0011 
0012 #include "TFile.h"
0013 
0014 #include <map>
0015 #include <string>
0016 #include <vector>
0017 
0018 class TObject;
0019 
0020 namespace edm {
0021   class InputFile {
0022   public:
0023     explicit InputFile(char const* fileName, char const* msg, InputType inputType);
0024     ~InputFile();
0025 
0026     InputFile(InputFile const&) = delete;             // Disallow copying and moving
0027     InputFile& operator=(InputFile const&) = delete;  // Disallow copying and moving
0028 
0029     void Close();
0030     void inputFileOpened(std::string const& logicalFileName,
0031                          std::string const& inputType,
0032                          std::string const& moduleName,
0033                          std::string const& label,
0034                          std::string const& fid,
0035                          std::vector<std::string> const& branchNames);
0036     void eventReadFromFile() const;
0037     void reportInputRunNumber(unsigned int run) const;
0038     void reportInputLumiSection(unsigned int run, unsigned int lumi) const;
0039     static void reportSkippedFile(std::string const& fileName, std::string const& logicalFileName);
0040     static void reportFallbackAttempt(std::string const& pfn,
0041                                       std::string const& logicalFileName,
0042                                       std::string const& errorMessage);
0043     // reportReadBranches is a per job report, rather than per file report.
0044     // Nevertheless, it is defined here for convenience.
0045     static void reportReadBranches();
0046     static void reportReadBranch(InputType inputType, std::string const& branchname);
0047 
0048     TObject* Get(char const* name) { return file_->Get(name); }
0049     TFileCacheRead* GetCacheRead() const { return file_->GetCacheRead(); }
0050     void SetCacheRead(TFileCacheRead* tfcr) { file_->SetCacheRead(tfcr, nullptr, TFile::kDoNotDisconnect); }
0051     void logFileAction(char const* msg, char const* fileName) const;
0052 
0053   private:
0054     edm::propagate_const<std::unique_ptr<TFile>> file_;
0055     std::string fileName_;
0056     JobReport::Token reportToken_;
0057     InputType inputType_;
0058   };
0059 }  // namespace edm
0060 #endif