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 
24  const edm::EventSetup& iSetup) {
25  edm::LogInfo("MillePedeFileActions")
26  << "Inserting all data from file " << inputDir_ + inputFileName_
27  << " as a FileBlob to the lumi, using label \"" << fileBlobLabel_
28  << "\".";
29  // Preparing the FileBlobCollection:
30  auto fileBlobCollection = std::make_unique<FileBlobCollection>();
31 
32  // Creating the FileBlob:
33  // (The FileBlob will signal problems with the file itself.)
34  FileBlob fileBlob{inputDir_ + inputFileName_, true};
35 
36  if (fileBlob.size() > 0) { // skip if no data or FileBlob file not found
37  // Adding the FileBlob to the lumi:
38  fileBlobCollection->addFileBlob(fileBlob);
39  }
40  iLumi.put(std::move(fileBlobCollection), fileBlobLabel_);
41 }
42 
43 // Manage the parameters for the module:
44 // (Note that this will autogenerate the _cfi.py file.)
46  edm::ConfigurationDescriptions& descriptions) {
48 
49  desc.add<std::string>("fileDir", "")->setComment(
50  "Keep the fileDir empty if you want to write to the current "
51  "directory. If you use it, it should end with a slash.");
52 
53  desc.add<std::string>("inputBinaryFile", "milleBinary.dat")->setComment(
54  "Filename of the file created by Mille in the AlignmentProducer");
55 
56  desc.add<std::string>("fileBlobLabel", "milleBinary.dat")->setComment(
57  "It's probably a good idea to keep the label the same as the "
58  "original filename(s). See configuration of "
59  "MillePedeFileExtractor, it should be the same there.");
60 
61  descriptions.add("millePedeFileConverter", desc);
62  descriptions.setComment(
63  "This is the generic cfi file for the "
64  "MillePedeFileConverter");
65 }
const std::string fileBlobLabel_
virtual void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup &) override final
MillePedeFileConverter(const edm::ParameterSet &)
void put(std::unique_ptr< PROD > product)
Put a new product.
const std::string inputFileName_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
def move(src, dest)
Definition: eostools.py:510