Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:39:29

0001 // Original Author:  Broen van Besien
0002 //         Created:  Thu, 19 Mar 2015 18:12:35 GMT
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   // We define what this producer produces: A FileBlobCollection
0018   produces<FileBlobCollection, edm::Transition::EndLuminosityBlock>(fileBlobLabel_);
0019 }
0020 
0021 MillePedeFileConverter::~MillePedeFileConverter() {}
0022 
0023 void MillePedeFileConverter::endLuminosityBlockProduce(edm::LuminosityBlock& iLumi, const edm::EventSetup& iSetup) {
0024   edm::LogInfo("MillePedeFileActions") << "Inserting all data from file " << inputDir_ + inputFileName_
0025                                        << " as a FileBlob to the lumi, using label \"" << fileBlobLabel_ << "\".";
0026   // Preparing the FileBlobCollection:
0027   auto fileBlobCollection = std::make_unique<FileBlobCollection>();
0028 
0029   // Creating the FileBlob:
0030   // (The FileBlob will signal problems with the file itself.)
0031   FileBlob fileBlob{inputDir_ + inputFileName_, true};
0032 
0033   if (fileBlob.size() > 0) {  // skip if no data or FileBlob file not found
0034     // Adding the FileBlob to the lumi:
0035     fileBlobCollection->addFileBlob(fileBlob);
0036   }
0037   iLumi.put(std::move(fileBlobCollection), fileBlobLabel_);
0038 }
0039 
0040 // Manage the parameters for the module:
0041 // (Note that this will autogenerate the _cfi.py file.)
0042 void MillePedeFileConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0043   edm::ParameterSetDescription desc;
0044 
0045   desc.add<std::string>("fileDir", "")
0046       ->setComment(
0047           "Keep the fileDir empty if you want to write to the current "
0048           "directory. If you use it, it should end with a slash.");
0049 
0050   desc.add<std::string>("inputBinaryFile", "milleBinary.dat")
0051       ->setComment("Filename of the file created by Mille in the AlignmentProducer");
0052 
0053   desc.add<std::string>("fileBlobLabel", "milleBinary.dat")
0054       ->setComment(
0055           "It's probably a good idea to keep the label the same as the "
0056           "original filename(s). See configuration of "
0057           "MillePedeFileExtractor, it should be the same there.");
0058 
0059   descriptions.add("millePedeFileConverter", desc);
0060   descriptions.setComment(
0061       "This is the generic cfi file for the "
0062       "MillePedeFileConverter");
0063 }