test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
5 
8 
9 #include <memory>
10 #include <fstream>
11 
13  : inputDir_(iConfig.getParameter<std::string>("fileDir")),
14  inputFileName_(iConfig.getParameter<std::string>("inputBinaryFile")),
15  fileBlobLabel_(iConfig.getParameter<std::string>("fileBlobLabel")) {
16  // We define what this producer produces: A FileBlobCollection
17  produces<FileBlobCollection, edm::InLumi>(fileBlobLabel_);
18 }
19 
21 
23  const edm::EventSetup& iSetup) {
24  edm::LogInfo("MillePedeFileActions")
25  << "Inserting all data from file " << inputDir_ + inputFileName_
26  << " as a FileBlob to the lumi, using label \"" << fileBlobLabel_
27  << "\".";
28  // Preparing the FileBlobCollection:
29  auto fileBlobCollection = std::make_unique<FileBlobCollection>();
30  FileBlob fileBlob;
31  try {
32  // Creating the FileBlob:
33  // (The FileBlob will signal problems with the file itself.)
34  fileBlob = FileBlob(inputDir_ + inputFileName_, true);
35  }
36  catch (...) {
37  // When creation of the FileBlob fails:
38  edm::LogError("MillePedeFileActions")
39  << "Error: No FileBlob could be created from the file \""
40  << inputDir_ + inputFileName_ << "\".";
41  throw;
42  }
43  if (fileBlob.size() > 0) {
44  // Adding the FileBlob to the lumi:
45  fileBlobCollection->addFileBlob(fileBlob);
46  }
47  iLumi.put(std::move(fileBlobCollection), fileBlobLabel_);
48 }
49 
50 // Manage the parameters for the module:
51 // (Note that this will autogenerate the _cfi.py file.)
53  edm::ConfigurationDescriptions& descriptions) {
55 
56  desc.add<std::string>("fileDir", "")->setComment(
57  "Keep the fileDir empty if you want to write to the current "
58  "directory. If you use it, it should end with a slash.");
59 
60  desc.add<std::string>("inputBinaryFile", "milleBinary.dat")->setComment(
61  "Filename of the file created by Mille in the AlignmentProducer");
62 
63  desc.add<std::string>("fileBlobLabel", "milleBinary.dat")->setComment(
64  "It's probably a good idea to keep the label the same as the "
65  "original filename(s). See configuration of "
66  "MillePedeFileExtractor, it should be the same there.");
67 
68  descriptions.add("millePedeFileConverter", desc);
69  descriptions.setComment(
70  "This is the generic cfi file for the "
71  "MillePedeFileConverter");
72 }
const std::string fileBlobLabel_
MillePedeFileConverter(const edm::ParameterSet &)
def move
Definition: eostools.py:510
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)
virtual void endLuminosityBlockProduce(edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
void put(std::auto_ptr< PROD > product)
Put a new product.