CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ExternalLHEAsciiDumper Class Reference
Inheritance diagram for ExternalLHEAsciiDumper:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 ExternalLHEAsciiDumper (const edm::ParameterSet &)
 
 ~ExternalLHEAsciiDumper () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

edm::EDGetTokenT< LHEXMLStringProductLHEAsciiToken_
 
std::string lheFileName_
 
edm::InputTag lheProduct_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 32 of file ExternalLHEAsciiDumper.cc.

Constructor & Destructor Documentation

ExternalLHEAsciiDumper::ExternalLHEAsciiDumper ( const edm::ParameterSet ps)
explicit

Definition at line 51 of file ExternalLHEAsciiDumper.cc.

References LHEAsciiToken_, and lheProduct_.

51  :
52  lheProduct_( ps.getParameter<edm::InputTag>("lheProduct") ),
53  lheFileName_( ps.getParameter<std::string>("lheFileName") )
54 {
55 
56  LHEAsciiToken_ = consumes <LHEXMLStringProduct,edm::InRun> (edm::InputTag(lheProduct_));
57 
58  return;
59 
60 }
T getParameter(std::string const &) const
edm::EDGetTokenT< LHEXMLStringProduct > LHEAsciiToken_
ExternalLHEAsciiDumper::~ExternalLHEAsciiDumper ( )
override

Definition at line 62 of file ExternalLHEAsciiDumper.cc.

63 {
64 }

Member Function Documentation

void ExternalLHEAsciiDumper::analyze ( const edm::Event ,
const edm::EventSetup  
)
overrideprivate

Definition at line 67 of file ExternalLHEAsciiDumper.cc.

68 {
69 }
void ExternalLHEAsciiDumper::endRun ( edm::Run const &  iRun,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file ExternalLHEAsciiDumper.cc.

References estimatePileup::basename, DEFINE_FWK_MODULE, electrons_cff::extension, alignmentValidation::fname, edm::Run::getByToken(), LHEXMLStringProduct::getCompressed(), LHEXMLStringProduct::getStrings(), mps_fire::i, LHEAsciiToken_, lheFileName_, MillePedeFileConverter_cfg::out, lumiCalc2::outfile, AlCaHLTBitMon_QueryRunRegistry::string, and LHEXMLStringProduct::writeCompressedContent().

74  {
75 
77  iRun.getByToken(LHEAsciiToken_,LHEAscii);
78 
79  const std::vector<std::string>& lheOutputs = LHEAscii->getStrings();
80 
81  unsigned int iout = 0;
82 
83  size_t lastdot = lheFileName_.find_last_of(".");
84  std::string basename = lheFileName_.substr(0, lastdot);
85  std::string extension = lastdot != std::string::npos ? lheFileName_.substr(lastdot+1, std::string::npos) : "";
86 
87  for (unsigned int i = 0; i < lheOutputs.size(); ++i){
88  std::ofstream outfile;
89  if (iout == 0)
90  outfile.open (lheFileName_.c_str(), std::ofstream::out | std::ofstream::app);
91  else {
92  std::stringstream fname;
93  fname << basename << "_" << iout ;
94  if (!extension.empty())
95  fname << "." << extension;
96  outfile.open (fname.str().c_str(), std::ofstream::out | std::ofstream::app);
97  }
98  outfile << lheOutputs[i];
99  outfile.close();
100  ++iout;
101  }
102 
103  for (unsigned int i = 0; i < LHEAscii->getCompressed().size(); ++i){
104  std::ofstream outfile;
105  if (iout == 0)
106  outfile.open (lheFileName_.c_str(), std::ofstream::out | std::ofstream::app);
107  else {
108  std::stringstream fname;
109  fname << basename << "_" << iout ;
110  if (!extension.empty())
111  fname << "." << extension;
112  outfile.open (fname.str().c_str(), std::ofstream::out | std::ofstream::app);
113  }
114  LHEAscii->writeCompressedContent(outfile,i);
115  outfile.close();
116  ++iout;
117  }
118 
119 }
const std::vector< std::string > & getStrings() const
const std::vector< std::vector< uint8_t > > & getCompressed() const
edm::EDGetTokenT< LHEXMLStringProduct > LHEAsciiToken_
string fname
main script
void writeCompressedContent(std::ostream &output, unsigned int i) const

Member Data Documentation

edm::EDGetTokenT<LHEXMLStringProduct> ExternalLHEAsciiDumper::LHEAsciiToken_
private

Definition at line 45 of file ExternalLHEAsciiDumper.cc.

Referenced by endRun(), and ExternalLHEAsciiDumper().

std::string ExternalLHEAsciiDumper::lheFileName_
private

Definition at line 43 of file ExternalLHEAsciiDumper.cc.

Referenced by endRun().

edm::InputTag ExternalLHEAsciiDumper::lheProduct_
private

Definition at line 42 of file ExternalLHEAsciiDumper.cc.

Referenced by ExternalLHEAsciiDumper().