CMS 3D CMS Logo

MillePedeFileConverter.cc
Go to the documentation of this file.
1 // Original Author: Broen van Besien
2 // Created: Thu, 19 Mar 2015 18:12:35 GMT
3 
6 
9 
10 #include <memory>
11 #include <fstream>
12 
14  : inputDir_(iConfig.getParameter<std::string>("fileDir")),
15  inputFileName_(iConfig.getParameter<std::string>("inputBinaryFile")),
16  fileBlobLabel_(iConfig.getParameter<std::string>("fileBlobLabel")) {
17  // We define what this producer produces: A FileBlobCollection
18  produces<FileBlobCollection, edm::Transition::EndLuminosityBlock>(fileBlobLabel_);
19 }
20 
22  auto const& moduleType = moduleDescription().moduleName();
23  auto const& moduleLabel = moduleDescription().moduleLabel();
24 
25  edm::LogInfo("MillePedeFileActions") << "Inserting all data from file " << inputDir_ + inputFileName_
26  << " as a FileBlob to the lumi, using label \"" << fileBlobLabel_ << "\".";
27  // Preparing the FileBlobCollection:
28  auto fileBlobCollection = std::make_unique<FileBlobCollection>();
29 
30  // Creating the FileBlob:
31  // (The FileBlob will signal problems with the file itself.)
32  FileBlob fileBlob{inputDir_ + inputFileName_, true};
33 
34  if (fileBlob.size() > 0) { // skip if no data or FileBlob file not found
35  // Adding the FileBlob to the lumi:
36  fileBlobCollection->addFileBlob(fileBlob);
37  edm::LogInfo(moduleType) << "[" << moduleLabel << "] fileBlob size was not empty, putting file blob with size "
38  << fileBlob.size() << std::endl;
39  }
40 
41  edm::LogInfo(moduleType) << "[" << moduleLabel << "]"
42  << " Root file contains " << fileBlobCollection->size() << " FileBlob(s).";
43  iLumi.put(std::move(fileBlobCollection), fileBlobLabel_);
44 }
45 
46 // Manage the parameters for the module:
47 // (Note that this will autogenerate the _cfi.py file.)
50 
51  desc.add<std::string>("fileDir", "")
52  ->setComment(
53  "Keep the fileDir empty if you want to write to the current "
54  "directory. If you use it, it should end with a slash.");
55 
56  desc.add<std::string>("inputBinaryFile", "milleBinary.dat")
57  ->setComment("Filename of the file created by Mille in the AlignmentProducer");
58 
59  desc.add<std::string>("fileBlobLabel", "milleBinary.dat")
60  ->setComment(
61  "It's probably a good idea to keep the label the same as the "
62  "original filename(s). See configuration of "
63  "MillePedeFileExtractor, it should be the same there.");
64 
65  descriptions.add("millePedeFileConverter", desc);
66  descriptions.setComment(
67  "This is the generic cfi file for the "
68  "MillePedeFileConverter");
69 }
const std::string fileBlobLabel_
ModuleDescription const & moduleDescription() const
std::string const & moduleName() const
MillePedeFileConverter(const edm::ParameterSet &)
void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup &) final
const std::string inputFileName_
Log< level::Info, false > LogInfo
void setComment(std::string const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & moduleLabel() const
def move(src, dest)
Definition: eostools.py:511