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

edm::EDGetTokenT
< FileBlobCollection
theFileBlobToken
 
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 31 of file MillePedeFileExtractor.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file MillePedeFileExtractor.cc.

References MillePedeFileExtractor_cfg::fileBlobInputTag, edm::ParameterSet::getParameter(), and theFileBlobToken.

14  : theOutputDir(iConfig.getParameter<std::string>("fileDir")),
15  theOutputFileName(iConfig.getParameter<std::string>("outputBinaryFile")) {
16 
17  edm::InputTag fileBlobInputTag = iConfig.getParameter<edm::InputTag>("fileBlobInputTag");
18  theFileBlobToken = consumes<FileBlobCollection, edm::BranchType::InRun>(fileBlobInputTag);
19  // nothing else in the constructor
20 }
T getParameter(std::string const &) const
edm::EDGetTokenT< FileBlobCollection > theFileBlobToken
MillePedeFileExtractor::~MillePedeFileExtractor ( )

Definition at line 22 of file MillePedeFileExtractor.cc.

22 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 39 of file MillePedeFileExtractor.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 24 of file MillePedeFileExtractor.cc.

References edm::Run::getByToken(), edm::HandleBase::isValid(), theFileBlobToken, theOutputDir, and theOutputFileName.

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

Definition at line 62 of file MillePedeFileExtractor.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_25ns14e33_v1_cff::InputTag, 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<edm::InputTag>("fileBlobInputTag", edm::InputTag("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 
82  descriptions.add("millePedeFileExtractor", desc);
83  descriptions.setComment(
84  "This is the generic cfi file for the "
85  "MillePedeFileExtractor");
86 }
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

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

Definition at line 44 of file MillePedeFileExtractor.h.

Referenced by endRun(), and MillePedeFileExtractor().

std::string MillePedeFileExtractor::theOutputDir
private

Definition at line 41 of file MillePedeFileExtractor.h.

Referenced by endRun().

std::string MillePedeFileExtractor::theOutputFileName
private

Definition at line 42 of file MillePedeFileExtractor.h.

Referenced by endRun().