Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Services
0004 // Class  :     FixMissingStreamerInfos
0005 //
0006 // Implementation:
0007 
0008 /** \class edm::service::FixMissingStreamerInfos
0009 
0010 This service is used to open and close a ROOT file that contains
0011 StreamerInfo objects causing them to be saved in memory. It is
0012 used when reading a file written with a version of ROOT with a
0013 bug that caused it to fail to write out StreamerInfo objects.
0014 (see Issue 41246).
0015 
0016 CMSSW_13_0_0 had such a problem and files were written with
0017 this problem. When using this service to read files written
0018 with this release set the "fileInPath" parameter to the string
0019 "IOPool/Input/data/fileContainingStreamerInfos_13_0_0.root".
0020 This file is saved in the cms-data repository for IOPool/Input.
0021 Note that it was difficult to identify all the problem classes
0022 and we might have missed some. If there are additional problem
0023 classes a new version of this file can be generated with script
0024 IOPool/Input/scripts/makeFileContainingStreamerInfos.C. If the
0025 problem ever recurs in ROOT with a different release, one could
0026 use that script to generate a file containing StreamerInfos for
0027 other releases.
0028 
0029     \author W. David Dagenhart, created 30 October, 2023
0030 
0031 */
0032 
0033 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0036 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0037 #include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
0038 #include "FWCore/Utilities/interface/EDMException.h"
0039 #include "FWCore/Utilities/interface/FileInPath.h"
0040 
0041 #include "TFile.h"
0042 
0043 namespace edm {
0044   namespace service {
0045 
0046     class FixMissingStreamerInfos {
0047     public:
0048       FixMissingStreamerInfos(ParameterSet const&, ActivityRegistry&);
0049       static void fillDescriptions(ConfigurationDescriptions&);
0050 
0051     private:
0052       FileInPath fileInPath_;
0053     };
0054 
0055     FixMissingStreamerInfos::FixMissingStreamerInfos(ParameterSet const& pset, edm::ActivityRegistry&)
0056         : fileInPath_(pset.getUntrackedParameter<FileInPath>("fileInPath")) {
0057       auto tFile = TFile::Open(fileInPath_.fullPath().c_str());
0058       if (!tFile || tFile->IsZombie()) {
0059         throw cms::Exception("FixMissingStreamerInfo")
0060             << "Failed opening file containing missing StreamerInfos: " << fileInPath_.fullPath();
0061       }
0062       tFile->Close();
0063     }
0064 
0065     void FixMissingStreamerInfos::fillDescriptions(ConfigurationDescriptions& descriptions) {
0066       ParameterSetDescription desc;
0067       desc.addUntracked<FileInPath>("fileInPath");
0068       descriptions.add("FixMissingStreamerInfos", desc);
0069     }
0070   }  // namespace service
0071 }  // namespace edm
0072 
0073 using namespace edm::service;
0074 DEFINE_FWK_SERVICE(FixMissingStreamerInfos);