CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
MillePedeFileExtractor Class Reference

#include <MillePedeFileExtractor.h>

Inheritance diagram for MillePedeFileExtractor:
edm::one::EDAnalyzer< edm::one::WatchLuminosityBlocks > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 MillePedeFileExtractor (const edm::ParameterSet &)
 
 ~MillePedeFileExtractor ()
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchLuminosityBlocks >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
bool enoughBinaries ()
 
bool hasBinaryNumberLimit ()
 

Private Attributes

edm::EDGetTokenT
< FileBlobCollection
fileBlobToken_
 
const int maxNumberOfBinaries_
 
int nBinaries_ {0}
 
const std::string outputDir_
 
const std::string outputFileName_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 31 of file MillePedeFileExtractor.h.

Constructor & Destructor Documentation

MillePedeFileExtractor::MillePedeFileExtractor ( const edm::ParameterSet iConfig)
explicit

Definition at line 11 of file MillePedeFileExtractor.cc.

References MillePedeFileExtractor_cfg::fileBlobInputTag, fileBlobToken_, edm::ParameterSet::getParameter(), hasBinaryNumberLimit(), and maxNumberOfBinaries_.

12  : outputDir_(iConfig.getParameter<std::string>("fileDir")),
13  outputFileName_(iConfig.getParameter<std::string>("outputBinaryFile")),
14  maxNumberOfBinaries_(iConfig.getParameter<int>("maxNumberOfBinaries")) {
15 
16  auto fileBlobInputTag = iConfig.getParameter<edm::InputTag>("fileBlobInputTag");
17  fileBlobToken_ = consumes<FileBlobCollection, edm::BranchType::InLumi>(fileBlobInputTag);
18  if (hasBinaryNumberLimit()) {
19  edm::LogInfo("MillePedeFileActions")
20  << "Limiting the number of extracted binary files to "
22  }
23 }
T getParameter(std::string const &) const
edm::EDGetTokenT< FileBlobCollection > fileBlobToken_
const std::string outputFileName_
MillePedeFileExtractor::~MillePedeFileExtractor ( )

Definition at line 25 of file MillePedeFileExtractor.cc.

25 {}

Member Function Documentation

virtual void MillePedeFileExtractor::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineoverrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 43 of file MillePedeFileExtractor.h.

43 {}
virtual void MillePedeFileExtractor::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
)
inlineoverrideprivatevirtual

Definition at line 39 of file MillePedeFileExtractor.h.

40  {}
void MillePedeFileExtractor::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup  
)
overrideprivatevirtual

Definition at line 27 of file MillePedeFileExtractor.cc.

References enoughBinaries(), fileBlobToken_, edm::LuminosityBlock::getByToken(), edm::HandleBase::isValid(), nBinaries_, outputDir_, and outputFileName_.

29 {
30  if (enoughBinaries()) return;
31 
32  // Getting our hands on the vector of FileBlobs
33  edm::Handle<FileBlobCollection> fileBlobCollection;
34  iLumi.getByToken(fileBlobToken_, fileBlobCollection);
35  if (fileBlobCollection.isValid()) {
36  // Logging the amount of FileBlobs in the vector
37  edm::LogInfo("MillePedeFileActions")
38  << "Root file contains " << fileBlobCollection->size() << " FileBlob(s).";
39  // Loop over the FileBlobs in the vector, and write them to files:
40  for (const auto& blob: *fileBlobCollection) {
41  if (enoughBinaries()) break;
42  // We format the filename with a number, starting from 0 to the size of
43  // our vector.
44  // For this to work, the outputBinaryFile config parameter must contain a
45  // formatting directive for a number, like %04d.
46  char theNumberedOutputFileName[200];
47  sprintf(theNumberedOutputFileName, outputFileName_.c_str(), nBinaries_);
48  // Log the filename to which we will write...
49  edm::LogInfo("MillePedeFileActions")
50  << "Writing FileBlob file to file "
51  << outputDir_ + theNumberedOutputFileName << ".";
52  // ...and perform the writing operation.
53  blob.write(outputDir_ + theNumberedOutputFileName);
54  // Careful, it seems that when writing to an impossible file, this is
55  // swallowed by the FileBlob.write operation and no error is thrown.
56  ++nBinaries_;
57  }
58  } else {
59  edm::LogError("MillePedeFileActions")
60  << "Error: The root file does not contain any vector of FileBlob.";
61  }
62 }
edm::EDGetTokenT< FileBlobCollection > fileBlobToken_
const std::string outputFileName_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool isValid() const
Definition: HandleBase.h:75
bool MillePedeFileExtractor::enoughBinaries ( )
inlineprivate
void MillePedeFileExtractor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 67 of file MillePedeFileExtractor.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_25ns10e33_v2_cff::InputTag, edm::ConfigurationDescriptions::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

68  {
70 
71  desc.add<std::string>("fileDir", "")->setComment(
72  "Keep the fileDir empty if you want to write to the current "
73  "directory.");
74 
75  desc.add<std::string>("outputBinaryFile", "milleBinary%04d.dat")->setComment(
76  "Base filename of the files that will be created. This must "
77  "contain "
78  "a placeholder for an index number in the standard C formatting "
79  "style, like %04d.");
80 
81  desc.add<edm::InputTag>("fileBlobInputTag", edm::InputTag("millePedeFileConverter",""))->setComment(
82  "Name of the module that should have generated the blob in the "
83  "root file. Make sure you overwrite this, if you have changed "
84  "this is the configuration of the MillePedeFileConverter.");
85 
86  desc.add<int>("maxNumberOfBinaries", 1000)->setComment(
87  "Number of binaries to be extracted from the input files. "
88  "Use a negative value to apply no limit.");
89 
90  descriptions.add("millePedeFileExtractor", desc);
91  descriptions.setComment(
92  "This is the generic cfi file for the "
93  "MillePedeFileExtractor");
94 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool MillePedeFileExtractor::hasBinaryNumberLimit ( )
inlineprivate

Definition at line 47 of file MillePedeFileExtractor.h.

References maxNumberOfBinaries_.

Referenced by enoughBinaries(), and MillePedeFileExtractor().

47 { return maxNumberOfBinaries_ > -1; }

Member Data Documentation

edm::EDGetTokenT<FileBlobCollection> MillePedeFileExtractor::fileBlobToken_
private

Definition at line 52 of file MillePedeFileExtractor.h.

Referenced by endLuminosityBlock(), and MillePedeFileExtractor().

const int MillePedeFileExtractor::maxNumberOfBinaries_
private
int MillePedeFileExtractor::nBinaries_ {0}
private

Definition at line 55 of file MillePedeFileExtractor.h.

Referenced by endLuminosityBlock(), and enoughBinaries().

const std::string MillePedeFileExtractor::outputDir_
private
const std::string MillePedeFileExtractor::outputFileName_
private

Definition at line 50 of file MillePedeFileExtractor.h.

Referenced by endLuminosityBlock().