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  : theInputDir(iConfig.getParameter<std::string>("fileDir")),
14  theInputFileName(iConfig.getParameter<std::string>("inputBinaryFile")),
15  theFileBlobLabel(iConfig.getParameter<std::string>("fileBlobLabel")) {
16  // We define what this producer produces: A FileBlobCollection
17  produces<FileBlobCollection, edm::InRun>(theFileBlobLabel);
18 }
19 
21 
23  const edm::EventSetup& iSetup) {
24  edm::LogInfo("MillePedeFileActions")
25  << "Inserting all data from file " << theInputDir + theInputFileName
26  << " as a FileBlob to the run, using label \"" << theFileBlobLabel
27  << "\".";
28  // Preparing the FileBlobCollection:
29  std::unique_ptr<FileBlobCollection> theFileBlobCollection(
30  new FileBlobCollection());
31  FileBlob theFileBlob;
32  try {
33  // Creating the FileBlob:
34  // (The FileBlob will signal problems with the file itself.)
35  theFileBlob = FileBlob(theInputDir + theInputFileName, true);
36  }
37  catch (...) {
38  // When creation of the FileBlob fails:
39  edm::LogError("MillePedeFileActions")
40  << "Error: No FileBlob could be created from the file \""
41  << theInputDir + theInputFileName << "\".";
42  throw;
43  }
44  if (theFileBlob.size() > 0) {
45  // Adding the FileBlob to the run:
46  theFileBlobCollection->addFileBlob(theFileBlob);
47  iRun.put(std::move(theFileBlobCollection), theFileBlobLabel);
48  }
49 }
50 
51 // Manage the parameters for the module:
52 // (Note that this will autogenerate the _cfi.py file.)
54  edm::ConfigurationDescriptions& descriptions) {
56 
57  desc.add<std::string>("fileDir", "")->setComment(
58  "Keep the fileDir empty if you want to write to the current "
59  "directory. If you use it, it should end with a slash.");
60 
61  desc.add<std::string>("inputBinaryFile", "milleBinary.dat")->setComment(
62  "Filename of the file created by Mille in the AlignmentProducer");
63 
64  desc.add<std::string>("fileBlobLabel", "milleBinary.dat")->setComment(
65  "It's probably a good idea to keep the label the same as the "
66  "original filename(s). See configuration of "
67  "MillePedeFileExtractor, it should be the same there.");
68 
69  descriptions.add("millePedeFileConverter", desc);
70  descriptions.setComment(
71  "This is the generic cfi file for the "
72  "MillePedeFileConverter");
73 }
MillePedeFileConverter(const edm::ParameterSet &)
virtual void endRunProduce(edm::Run &run, const edm::EventSetup &iSetup) overridefinal
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int size() const
Definition: FileBlob.h:33
void setComment(std::string const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:107
Definition: Run.h:41