21 #include "GENIE/Messenger/Messenger.h" 22 #include "Ntuple/NtpMCFormat.h" 23 #include "Ntuple/NtpWriter.h" 24 #include "Ntuple/NtpMCEventRecord.h" 26 #include "PDG/PDGLibrary.h" 27 #include "GHEP/GHepRecord.h" 29 #include "GENIE/Framework/Messenger/Messenger.h" 31 #include "GENIE/Framework/GHEP/GHepRecord.h" 32 #include "GENIE/Framework/Ntuple/NtpMCFormat.h" 33 #include "GENIE/Framework/Ntuple/NtpWriter.h" 34 #include "GENIE/Framework/Ntuple/NtpMCEventRecord.h" 44 using genie::Messenger;
58 Name(
"inputModuleLabels"),
59 Comment(
"list of input module labels to use, if empty use everything")
63 Name(
"outputGHEPFile"),
64 Comment(
"name of file to write in std GENIE gntp.*.ghep.root format\n" 65 "if blank don't write file, if name contains '%l' then\n" 66 "events from different input labels will go to separate outputs\n"),
70 Name(
"dumpFilePattern"),
71 Comment(
"name of file for formatted dumps; if name contains '%l' then\n" 72 "events from different input labels will go to separate streams\n" 73 "if blank use std::cout"),
77 Name(
"dumpGeniePrintLevel"),
78 Comment(
"print fetched genie::EventRecord -1=no, 13=max info\n" 79 "see GENIE manual for legal values"),
84 Comment(
"dump the MCTruth objects (std:cout) as they're retrieved"),
89 Comment(
"dump the GTruth objects (std:cout) as they're retrieved"),
94 Comment(
"dump the MCFlux objects (std:cout) as they're retrieved"),
141 genie::NtpWriter* FetchNtpWriter(
const std::string& label);
142 std::ostream* FetchDumpStream(
const std::string& label);
172 , fSeparateOutputNtpWriters(false)
173 , fSeparateDumpStreams(false)
178 genie::PDGLibrary::Instance();
187 (*genie::Messenger::Instance())(
"GENIE") << log4cpp::Priority::INFO
188 <<
"Trigger GENIE banner";
222 std::string label = mitro->first;
223 genie::NtpWriter* ntpw = mitro->second;
234 std::string label = mitrd->first;
235 std::ofstream* fout =
dynamic_cast<std::ofstream*
>(mitrd->second);
253 while ( ( flag = mcitr.
Next() ) ) {
255 std::string label = mcitr.
GetLabel();
260 static int ievt = -1;
266 pgtruth = &nullGTruth;
274 ntpWriter->AddEventRecord(ievt,grec);
280 <<
" ** Event: GenieOutput_module " << ievt
286 std::ostringstream dumpSimBaseObj;
287 dumpSimBaseObj <<
" after Next() " << indx <<
" " << flag
290 if ( pmctruth ) dumpSimBaseObj << *pmctruth << std::endl;
291 else dumpSimBaseObj <<
"no simb::MCTruth available" << std::endl;
295 dumpSimBaseObj << *pgtruth << std::endl;
298 }
else dumpSimBaseObj <<
"no simb::GTruth available" << std::endl;
301 if ( pmcflux ) dumpSimBaseObj << *pmcflux << std::endl;
302 else dumpSimBaseObj <<
"no simb::MCFlux available" << std::endl;
304 mf::LogInfo(
"GenieOutput") << dumpSimBaseObj.str();
316 genie::NtpWriter* ntpwret = 0;
320 if ( ntpwret )
return ntpwret;
326 size_t posl = finalFileName.find(
"%l");
327 if ( posl != std::string::npos ) {
328 finalFileName.replace(posl,2,label);
331 ntpwret =
new genie::NtpWriter(genie::kNFGHEP,0);
332 ntpwret->CustomizeFilename(finalFileName);
333 ntpwret->Initialize();
348 std::ostream* osret = 0;
352 if ( osret )
return osret;
362 osret = &(std::cout);
366 size_t posl = finalFileName.find(
"%l");
367 if ( posl != std::string::npos ) {
368 finalFileName.replace(posl,2,label);
371 osret =
new std::ofstream(finalFileName.c_str(),
372 std::ios_base::trunc|std::ios_base::out);
std::vector< std::string > fInputModuleLabels
label(s) of existing MCTruth/GTruth/MCFlux
bool fSeparateDumpStreams
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
genie::EventRecord * RetrieveGHEP(const simb::MCTruth &truth, const simb::GTruth >ruth, bool useFirstTrajPosition=true)
return genie::EventRecord pointer; callee takes possession
std::string fDumpFilePattern
const simb::MCTruth * GetMCTruth() const
Functions for transforming GENIE objects into ART objects (and back)
bool fSeparateOutputNtpWriters
std::map< std::string, genie::NtpWriter * > fOutputNtpWriters
Atom< int > dumpGeniePrintLevel
object containing MC flux information
std::map< std::string, std::ostream * > fDumpStreams
Atom< std::string > outputGHEPFilePattern
#define DEFINE_ART_MODULE(klass)
const simb::MCFlux * GetMCFlux() const
genie::NtpWriter * FetchNtpWriter(const std::string &label)
GenieOutput(const Parameters ¶ms)
const simb::GTruth * GetGTruth() const
std::ostream * FetchDumpStream(const std::string &label)
void analyze(art::Event const &e) override
Atom< std::string > dumpFilePattern
Event generator information.
Sequence< std::string > inputModuleLabels
std::string GetLabel() const
std::string fOutputGHEPFilePattern