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::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 MillePedeFileExtractor (const edm::ParameterSet &)
 
 ~MillePedeFileExtractor ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 

Private Attributes

std::string theFileBlobLabel
 
std::string theFileBlobModule
 
std::string theOutputDir
 
std::string theOutputFileName
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer 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 30 of file MillePedeFileExtractor.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file MillePedeFileExtractor.cc.

13  : theOutputDir(iConfig.getParameter<std::string>("fileDir")),
14  theOutputFileName(iConfig.getParameter<std::string>("outputBinaryFile")),
15  theFileBlobModule(iConfig.getParameter<std::string>("fileBlobModule")),
16  theFileBlobLabel(iConfig.getParameter<std::string>("fileBlobLabel")) {
17  // nothing else in the constructor
18 }
T getParameter(std::string const &) const
MillePedeFileExtractor::~MillePedeFileExtractor ( )

Definition at line 20 of file MillePedeFileExtractor.cc.

20 {}

Member Function Documentation

void MillePedeFileExtractor::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 38 of file MillePedeFileExtractor.h.

38 {}
void MillePedeFileExtractor::endRun ( edm::Run const &  iRun,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 22 of file MillePedeFileExtractor.cc.

References edm::Run::getByLabel(), edm::HandleBase::isValid(), theFileBlobLabel, theFileBlobModule, theOutputDir, and theOutputFileName.

23  {
24  // Getting our hands on the vector of FileBlobs
25  edm::Handle<FileBlobCollection> theFileBlobCollection;
26  iRun.getByLabel(theFileBlobModule, theFileBlobLabel, theFileBlobCollection);
27  if (theFileBlobCollection.isValid()) {
28  // Logging the amount of FileBlobs in the vector
29  int theVectorSize = theFileBlobCollection->size();
30  edm::LogInfo("MillePedeFileActions") << "Root file contains "
31  << theVectorSize << " FileBlob(s).";
32  // Loop over the FileBlobs in the vector, and write them to files:
33  for (std::vector<FileBlob>::const_iterator it =
34  theFileBlobCollection->begin();
35  it != theFileBlobCollection->end(); ++it) {
36  // We format the filename with a number, starting from 0 to the size of
37  // our vector.
38  // For this to work, the outputBinaryFile config parameter must contain a
39  // formatting directive for a number, like %04d.
40  char theNumberedOutputFileName[200];
41  int theNumber = it - theFileBlobCollection->begin();
42  sprintf(theNumberedOutputFileName, theOutputFileName.c_str(), theNumber);
43  // Log the filename to which we will write...
44  edm::LogInfo("MillePedeFileActions")
45  << "Writing FileBlob file to file "
46  << theOutputDir + theNumberedOutputFileName << ".";
47  // ...and perform the writing operation.
48  it->write(theOutputDir + theNumberedOutputFileName);
49  // Carefull, it seems that when writing to an impossible file, this is
50  // swallowed by the FileBlob->write operation and no error is thrown.
51  }
52  } else {
53  edm::LogError("MillePedeFileActions")
54  << "Error: The root file does not contain any vector of FileBlob "
55  "created by module \"" << theFileBlobModule << "\", with label \""
56  << theFileBlobLabel << "\".";
57  }
58 }
bool isValid() const
Definition: HandleBase.h:75
void MillePedeFileExtractor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 62 of file MillePedeFileExtractor.cc.

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

63  {
65 
66  desc.add<std::string>("fileDir", "")->setComment(
67  "Keep the fileDir empty if you want to write to the current "
68  "directory.");
69 
70  desc.add<std::string>("outputBinaryFile", "milleBinary%04d.dat")->setComment(
71  "Base filename of the files that will be created. This must "
72  "contain "
73  "a placeholder for an index number in the standard C formatting "
74  "style, like %04d.");
75 
76  desc.add<std::string>("fileBlobModule", "millePedeFileConverter")->setComment(
77  "Name of the module that should have generated the blob in the "
78  "root file. Make sure you overwrite this, if you have changed "
79  "this is the configuration of the MillePedeFileConverter.");
80 
81  desc.add<std::string>("fileBlobLabel", "milleBinary.dat")->setComment(
82  "It's probably a good idea to keep the label the same as the "
83  "original filename(s). See configuration of "
84  "MillePedeFileConverter, it should be the same there.");
85 
86  descriptions.add("millePedeFileExtractor", desc);
87  descriptions.setComment(
88  "This is the generic cfi file for the "
89  "MillePedeFileExtractor");
90 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

std::string MillePedeFileExtractor::theFileBlobLabel
private

Definition at line 43 of file MillePedeFileExtractor.h.

Referenced by endRun().

std::string MillePedeFileExtractor::theFileBlobModule
private

Definition at line 42 of file MillePedeFileExtractor.h.

Referenced by endRun().

std::string MillePedeFileExtractor::theOutputDir
private

Definition at line 40 of file MillePedeFileExtractor.h.

Referenced by endRun().

std::string MillePedeFileExtractor::theOutputFileName
private

Definition at line 41 of file MillePedeFileExtractor.h.

Referenced by endRun().