6 #include "art/Framework/Core/EDProducer.h"
7 #include "art/Framework/Principal/Event.h"
8 #include "art/Framework/Principal/Handle.h"
9 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 #include "art/Persistency/Common/PtrMaker.h"
11 #include "art/Utilities/ToolMacros.h"
12 #include "cetlib/cpu_timer.h"
13 #include "fhiclcpp/ParameterSet.h"
14 #include "messagefacility/MessageLogger/MessageLogger.h"
15 #include "CLHEP/Random/RandFlat.h"
16 #include "ifdh_art/IFDHService/IFDH_service.h"
18 #include "nusimdata/SimulationBase/MCFlux.h"
24 #include "dk2nu/tree/dk2nu.h"
25 #include "dk2nu/tree/dkmeta.h"
26 #include "dk2nu/tree/NuChoice.h"
32 #include "TTreeReader.h"
33 #include "TTreeReaderValue.h"
62 simb::MCFlux
GetNext()
override;
64 void configure(
const fhicl::ParameterSet&)
override;
68 simb::MCFlux
MakeMCFlux(
const bsim::Dk2Nu &dk2nu);
140 fMaxFluxFileMB = pset.get<
unsigned long>(
"MaxFluxFileMB", 2 * 1024);
142 fTreeName = pset.get<std::string>(
"TreeName");
148 for (
const std::string &
s: fSearchPatterns)
std::cout <<
s << std::endl;
149 std::cout <<
"With copy method: " << fFluxCopyMethod << std::endl;
153 art::ServiceHandle<IFDH> ifdhp;
155 std::vector<std::pair<std::string, long>> allFiles;
160 std::copy (thisList.begin(), thisList.end(), std::back_inserter(allFiles));
164 std::vector<unsigned long> order(allFiles.size(), 0);
166 std::vector<double> rand(allFiles.size(), 0.);
167 CLHEP::RandFlat::shootArray(
fEngine, rand.size(), &rand[0]);
168 TMath::Sort(allFiles.size(), &rand[0], &order[0],
false);
171 for (
unsigned i = 0; i < order.size(); i++) {
178 std::cout <<
"DIRECTLY ACCESSING FLUX FILES.\n";
179 std::vector<std::string> files(allFiles.size());
180 for (
unsigned i = 0; i < order.size(); i++) {
181 files[i] = allFiles[order[i]].first;
187 std::vector<std::pair<std::string, long>> selected;
188 unsigned long totalBytes = 0;
190 while (totalBytes < (
fMaxFluxFileMB * 1024 * 1024) && ind < allFiles.size()) {
191 selected.push_back(allFiles[order[ind]]);
192 totalBytes += allFiles[order[ind]].second;
197 std::vector<std::pair<std::string, long>> localFiles = ifdhp->fetchSharedFiles(selected,
fFluxCopyMethod);
199 std::vector<std::string> files(localFiles.size());
200 for (
unsigned i = 0; i < localFiles.size(); i++) {
201 files[i] = localFiles[i].first;
209 TTreeReaderValue<double> pot(metaReader,
"pots");
211 double total_pot = 0.;
213 while (metaReader.Next()) {
277 flux.fFluxType = simb::kDk2Nu;
278 flux.fntype = dk2nu.decay.ntype;
279 flux.fnimpwt = dk2nu.decay.nimpwt;
280 flux.fvx = dk2nu.decay.vx;
281 flux.fvy = dk2nu.decay.vy;
282 flux.fvz = dk2nu.decay.vz;
283 flux.fpdpx = dk2nu.decay.pdpx;
284 flux.fpdpy = dk2nu.decay.pdpy;
285 flux.fpdpz = dk2nu.decay.pdpz;
286 flux.fppdxdz = dk2nu.decay.ppdxdz;
287 flux.fppdydz = dk2nu.decay.ppdydz;
288 flux.fpppz = dk2nu.decay.pppz;
289 flux.fppenergy = dk2nu.decay.ppenergy;
290 flux.fppmedium = dk2nu.decay.ppmedium;
291 flux.fptype = dk2nu.decay.ptype;
292 flux.fndecay = dk2nu.decay.ndecay;
293 flux.fmuparpx = dk2nu.decay.muparpx;
294 flux.fmuparpy = dk2nu.decay.muparpy;
295 flux.fmuparpz = dk2nu.decay.muparpz;
296 flux.fmupare = dk2nu.decay.mupare;
297 flux.fnecm = dk2nu.decay.necm;
299 flux.fppvx = dk2nu.ppvx;
300 flux.fppvy = dk2nu.ppvy;
301 flux.fppvz = dk2nu.ppvz;
303 flux.ftvx = dk2nu.tgtexit.tvx;
304 flux.ftvy = dk2nu.tgtexit.tvy;
305 flux.ftvz = dk2nu.tgtexit.tvz;
306 flux.ftpx = dk2nu.tgtexit.tpx;
307 flux.ftpy = dk2nu.tgtexit.tpy;
308 flux.ftpz = dk2nu.tgtexit.tpz;
309 flux.ftptype = dk2nu.tgtexit.tptype;
310 flux.ftgen = dk2nu.tgtexit.tgen;
312 flux.frun = dk2nu.job;
313 flux.fevtno = dk2nu.potnum;
314 flux.ftgptype = dk2nu.ancestor[1].pdg;
320 flux.fnwtnear = flux.fnwtfar = -1;
324 flux.fxpoint = dk2nu.ancestor.back().startt;
NuMiKaonGen(fhicl::ParameterSet const &pset)
Constructor.
const bsim::Dk2Nu * GetNextEntry()
unsigned long fMaxFluxFileMB
simb::MCFlux GetNext() override
simb::MCFlux MakeMCFlux(const bsim::Dk2Nu &dk2nu)
CLHEP::HepRandomEngine * fEngine
IMesonGen interface class definiton.
This is an interface for an art Tool which sources MCFlux objects for downstream processing and tabul...
IMeVPrtlStage interface class definiton. General interface behind each stage. Provides random number ...
double MaxWeight() override
std::string fMetaTreeName
std::string fFluxCopyMethod
std::vector< std::string > fSearchPatterns
void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
std::vector< std::string > fFluxFiles
then echo File list $list not found else cat $list while read file do echo $file sed s
NuMiKaonGen class definiton.
std::vector< std::string > LoadFluxFiles()
BEGIN_PROLOG could also be cout
~NuMiKaonGen()
Destructor.