File indexing completed on 2024-04-06 11:56:34
0001
0002
0003
0004 #include "Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeFileConverter.h"
0005 #include "FWCore/Framework/interface/LuminosityBlock.h"
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "CondFormats/Common/interface/FileBlobCollection.h"
0009
0010 #include <memory>
0011 #include <fstream>
0012
0013 MillePedeFileConverter::MillePedeFileConverter(const edm::ParameterSet& iConfig)
0014 : inputDir_(iConfig.getParameter<std::string>("fileDir")),
0015 inputFileName_(iConfig.getParameter<std::string>("inputBinaryFile")),
0016 fileBlobLabel_(iConfig.getParameter<std::string>("fileBlobLabel")) {
0017
0018 produces<FileBlobCollection, edm::Transition::EndLuminosityBlock>(fileBlobLabel_);
0019 }
0020
0021 void MillePedeFileConverter::endLuminosityBlockProduce(edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) {
0022 auto const& moduleType = moduleDescription().moduleName();
0023 auto const& moduleLabel = moduleDescription().moduleLabel();
0024
0025 edm::LogInfo("MillePedeFileActions") << "Inserting all data from file " << inputDir_ + inputFileName_
0026 << " as a FileBlob to the lumi, using label \"" << fileBlobLabel_ << "\".";
0027
0028 auto fileBlobCollection = std::make_unique<FileBlobCollection>();
0029
0030
0031
0032 FileBlob fileBlob{inputDir_ + inputFileName_, true};
0033
0034 if (fileBlob.size() > 0) {
0035
0036 fileBlobCollection->addFileBlob(fileBlob);
0037 edm::LogInfo(moduleType) << "[" << moduleLabel << "] fileBlob size was not empty, putting file blob with size "
0038 << fileBlob.size() << std::endl;
0039 }
0040
0041 edm::LogInfo(moduleType) << "[" << moduleLabel << "]"
0042 << " Root file contains " << fileBlobCollection->size() << " FileBlob(s).";
0043 iLumi.put(std::move(fileBlobCollection), fileBlobLabel_);
0044 }
0045
0046
0047
0048 void MillePedeFileConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0049 edm::ParameterSetDescription desc;
0050
0051 desc.add<std::string>("fileDir", "")
0052 ->setComment(
0053 "Keep the fileDir empty if you want to write to the current "
0054 "directory. If you use it, it should end with a slash.");
0055
0056 desc.add<std::string>("inputBinaryFile", "milleBinary.dat")
0057 ->setComment("Filename of the file created by Mille in the AlignmentProducer");
0058
0059 desc.add<std::string>("fileBlobLabel", "milleBinary.dat")
0060 ->setComment(
0061 "It's probably a good idea to keep the label the same as the "
0062 "original filename(s). See configuration of "
0063 "MillePedeFileExtractor, it should be the same there.");
0064
0065 descriptions.add("millePedeFileConverter", desc);
0066 descriptions.setComment(
0067 "This is the generic cfi file for the "
0068 "MillePedeFileConverter");
0069 }