16 #include "nutools/EventGeneratorBase/GENIE/GENIE2ART.h" 17 #include "nutools/EventGeneratorBase/GENIE/MCTruthAndFriendsItr.h" 21 #include "GENIE/Messenger/Messenger.h" 26 #include "PDG/PDGLibrary.h" 29 #include "GENIE/Framework/Messenger/Messenger.h" 30 #include "GENIE/Framework/ParticleData/PDGLibrary.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" 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"),
172 , fSeparateOutputNtpWriters(false)
173 , fSeparateDumpStreams(false)
221 std::ofstream*
fout =
dynamic_cast<std::ofstream*
>(mitrd->second);
239 while ( ( flag = mcitr.
Next() ) ) {
246 static int ievt = -1;
252 pgtruth = &nullGTruth;
266 <<
" ** Event: GenieOutput_module " << ievt
272 std::ostringstream dumpSimBaseObj;
273 dumpSimBaseObj <<
" after Next() " << indx <<
" " << flag
276 if ( pmctruth ) dumpSimBaseObj << *pmctruth <<
std::endl;
277 else dumpSimBaseObj <<
"no simb::MCTruth available" <<
std::endl;
284 }
else dumpSimBaseObj <<
"no simb::GTruth available" <<
std::endl;
287 if ( pmcflux ) dumpSimBaseObj << *pmcflux <<
std::endl;
288 else dumpSimBaseObj <<
"no simb::MCFlux available" <<
std::endl;
290 mf::LogInfo(
"GenieOutput") << dumpSimBaseObj.str();
306 if ( ntpwret )
return ntpwret;
312 size_t posl = finalFileName.find(
"%l");
313 if ( posl != std::string::npos ) {
314 finalFileName.replace(posl,2,label);
334 std::ostream* osret = 0;
338 if ( osret )
return osret;
348 osret = &(std::cout);
352 size_t posl = finalFileName.find(
"%l");
353 if ( posl != std::string::npos ) {
354 finalFileName.replace(posl,2,label);
357 osret =
new std::ofstream(finalFileName.c_str(),
358 std::ios_base::trunc|std::ios_base::out);
def analyze(root, level, gtrees, gbranches, doprint)
static void SetPrintLevel(int print_level)
std::vector< std::string > fInputModuleLabels
label(s) of existing MCTruth/GTruth/MCFlux
bool fSeparateDumpStreams
void CustomizeFilename(string filename)
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
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
void Save(void)
get the even tree
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
A more convenient interface to the log4cpp Message Service.
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void Initialize(void)
add event
static PDGLibrary * Instance(void)
genie::NtpWriter * FetchNtpWriter(const std::string &label)
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
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
QTextStream & endl(QTextStream &s)
std::string fOutputGHEPFilePattern