15 #include <TStopwatch.h> 18 #include "Framework/Conventions/GBuild.h" 39 using namespace genie;
50 if(fUnphysEventMask)
delete fUnphysEventMask;
51 if (fGPool)
delete fGPool;
54 for( ; pmax_iter != fPmax.end(); ++pmax_iter) {
55 TH1D * pmax = pmax_iter->second;
57 delete pmax; pmax = 0;
62 if(fFluxIntTree)
delete fFluxIntTree;
63 if(fFluxIntProbFile)
delete fFluxIntProbFile;
69 <<
"Setting event generator list: " << listname;
71 fEventGenList = listname;
76 *fUnphysEventMask =
mask;
80 <<
" -> 0) : " << *fUnphysEventMask;
85 fFluxDriver = flux_driver;
90 fGeomAnalyzer = geom_analyzer;
106 fMaxPlXmlFilename = xml_filename;
108 bool is_accessible = !(gSystem->AccessPathName(fMaxPlXmlFilename.c_str()));
110 if ( is_accessible ) fUseExtMaxPl =
true;
112 fUseExtMaxPl =
false;
114 <<
"UseMaxPathLengths could not find file: \"" << xml_filename <<
"\"";
123 <<
"Keep on throwing flux neutrinos till one interacts? : " 125 fKeepThrowingFluxNu = keep_on;
130 fXSecSplineNbins =
nbins;
133 <<
"Number of bins in energy used for the xsec splines: " 139 fPmaxLogBinning =
true;
142 <<
"Pmax will be store in histogram with logarithmic energy bins";
150 <<
"Number of bins in energy used for maximum int. probability: " 156 fPmaxSafetyFactor = sf;
159 <<
"Pmax safety factor = " << fPmaxSafetyFactor;
166 fForceInteraction =
true;
169 <<
"GMCJDriver will generate weighted events forcing the interaction. ";
177 fGenerateUnweighted =
true;
180 <<
"GMCJDriver will generate un-weighted events. " 181 <<
"Note: That does not force unweighted event kinematics!";
189 fPreSelect = preselect;
203 bool save_to_file = fFluxIntProbFile == 0 && fFluxIntFileName.size()>0;
206 fSumFluxIntProbs.clear();
211 "Skipping pre-generation of flux interaction probabilities - "<<
212 "using pre-generated file";
219 fFluxIntProbFile =
new TFile(fFluxIntFileName.c_str(),
"CREATE");
220 if(fFluxIntProbFile->IsZombie()){
221 LOG(
"GMCJDriver",
pFATAL) <<
"Cannot overwrite an existing file. Exiting!";
227 fFluxIntTree =
new TTree(fFluxIntTreeName.c_str(),
228 "Tree storing pre-calculated flux interaction probs");
229 fFluxIntTree->Branch(
"FluxIndex", &fBrFluxIndex,
"FluxIndex/I");
230 fFluxIntTree->Branch(
"FluxIntProb", &fBrFluxIntProb,
"FluxIntProb/D");
231 fFluxIntTree->Branch(
"FluxEnu", &fBrFluxEnu,
"FluxEnu/D");
232 fFluxIntTree->Branch(
"FluxWeight", &fBrFluxWeight,
"FluxWeight/D");
233 fFluxIntTree->Branch(
"FluxPDG", &fBrFluxPDG,
"FluxPDG/I");
235 if(save_to_file) fFluxIntTree->SetDirectory(fFluxIntProbFile);
237 fFluxDriver->GenerateWeighted(
true);
242 TStopwatch stopwatch;
244 long int first_index = -1;
245 bool first_loop =
true;
247 while(fFluxDriver->End() ==
false){
250 bool gotnext = fFluxDriver->GenerateNext();
252 LOG(
"GMCJDriver",
pWARN) <<
"*** Couldn't generate next flux ray! ";
258 bool already_been_here = first_loop ?
false : first_index == fFluxDriver->Index();
259 if(already_been_here)
break;
262 if(this->ComputePathLengths() ==
false){ success =
false;
break;}
265 double psum = this->ComputeInteractionProbabilities(
false );
267 fBrFluxIntProb = psum;
268 fBrFluxIndex = fFluxDriver->Index();
269 fBrFluxEnu = fFluxDriver->Momentum().E();
270 fBrFluxWeight = fFluxDriver->Weight();
271 fBrFluxPDG = fFluxDriver->PdgCode();
272 fFluxIntTree->Fill();
276 first_index = fFluxDriver->Index();
282 <<
"Finished pre-calculating flux interaction probabilities. " 283 <<
"Total CPU time to process "<< fFluxIntTree->GetEntries()
284 <<
" entries: "<< stopwatch.CpuTime();
288 fFluxDriver->Clear(
"CycleHistory");
295 double safety_factor = 1.01;
296 for(
int i = 0; i< fFluxIntTree->GetEntries(); i++){
297 fFluxIntTree->GetEntry(i);
302 fGlobPmax = TMath::Max(fGlobPmax, fBrFluxIntProb*safety_factor);
304 if(fSumFluxIntProbs.find(fBrFluxPDG) == fSumFluxIntProbs.end()){
305 fSumFluxIntProbs[fBrFluxPDG] = 0.0;
307 fSumFluxIntProbs[fBrFluxPDG] += fBrFluxIntProb * fBrFluxWeight;
310 "Updated global probability scale to fGlobPmax = "<< fGlobPmax;
314 "Saving pre-generated interaction probabilities to file: "<<
315 fFluxIntProbFile->GetName();
316 fFluxIntProbFile->cd();
317 fFluxIntTree->Write();
321 if(fFluxIntTree->BuildIndex(
"FluxIndex") != fFluxIntTree->GetEntries()){
323 "Cannot build index using branch \"FluxIndex\" for flux prob tree!";
329 this->PreSelectEvents(
false);
331 LOG(
"GMCJDriver",
pNOTICE) <<
"Successfully generated/loaded pre-calculate flux interaction probabilities";
334 else if(fFluxIntTree){
351 if(fFluxIntProbFile){
353 <<
"Can't load flux interaction prob file as one is already loaded";
357 fFluxIntProbFile =
new TFile(filename.c_str(),
"OPEN");
359 if(fFluxIntProbFile){
360 fFluxIntTree =
dynamic_cast<TTree*
>(fFluxIntProbFile->Get(fFluxIntTreeName.c_str()));
363 fFluxIntTree->SetBranchAddress(
"FluxIntProb", &fBrFluxIntProb) >= 0 &&
364 fFluxIntTree->SetBranchAddress(
"FluxIndex", &fBrFluxIndex) >= 0 &&
365 fFluxIntTree->SetBranchAddress(
"FluxPDG", &fBrFluxPDG) >= 0 &&
366 fFluxIntTree->SetBranchAddress(
"FluxWeight", &fBrFluxWeight) >= 0 &&
367 fFluxIntTree->SetBranchAddress(
"FluxEnu", &fBrFluxEnu) >= 0;
370 if(this->PreCalcFluxProbabilities()) {
372 <<
"Successfully loaded pre-generated flux interaction probabilities";
378 "Cannot find expected branches in input flux probability tree!";
379 delete fFluxIntTree; fFluxIntTree = 0;
382 <<
"Cannot find tree: "<< fFluxIntTreeName.c_str();
386 <<
"Unable to load flux interaction probabilities file";
396 fFluxIntFileName = outfilename;
406 this->GetParticleLists();
409 this->GetMaxFluxEnergy();
416 this->PopulateEventGenDriverPool();
428 this->BootstrapXSecSplines();
433 this->BootstrapXSecSplineSummation();
435 if(calc_prob_scales && !fForceInteraction){
438 this->GetMaxPathLengthList();
442 this->ComputeProbScales();
444 if (fForceInteraction) fGlobPmax = 1.;
445 LOG(
"GMCJDriver",
pNOTICE) <<
"Finished configuring GMCJDriver\n\n";
450 fEventGenList =
"Default";
455 fUnphysEventMask->SetBitNumber(i,
true);
462 fMaxPlXmlFilename =
"";
463 fUseExtMaxPl =
false;
467 fXSecSplineNbins = 100;
468 fPmaxLogBinning =
false;
470 fPmaxSafetyFactor = 1.2;
474 fForceInteraction =
false;
475 fGenerateUnweighted =
false;
480 fCurVtx.SetXYZT(0.,0.,0.,0.);
482 fFluxIntProbFile = 0;
483 fFluxIntTreeName =
"gFlxIntProb";
484 fFluxIntFileName =
"";
486 fBrFluxIntProb = -1.;
491 fSumFluxIntProbs.clear();
495 this->KeepOnThrowingFluxNeutrinos(
true);
515 fMaxPathLengths.clear();
516 fCurPathLengths.clear();
523 <<
"Asking the flux driver for its list of neutrinos";
524 fNuList = fFluxDriver->FluxParticles();
526 LOG(
"GMCJDriver",
pNOTICE) <<
"Flux particles: " << fNuList;
530 <<
"Asking the geometry driver for its list of targets";
531 fTgtList = fGeomAnalyzer->ListOfTargetNuclei();
533 LOG(
"GMCJDriver",
pNOTICE) <<
"Target materials: " << fTgtList;
540 <<
"Loading external max path-length list for input geometry from " 541 << fMaxPlXmlFilename;
542 fMaxPathLengths.LoadFromXml(fMaxPlXmlFilename);
546 <<
"Querying the geometry driver to compute the max path-length list";
547 fMaxPathLengths = fGeomAnalyzer->ComputeMaxPathLengths();
551 <<
"Maximum path length list: " << fMaxPathLengths;
557 <<
"Querying the flux driver for the maximum energy of flux neutrinos";
558 fEmax = fFluxDriver->MaxEnergy();
561 <<
"Maximum flux neutrino energy = " << fEmax <<
" GeV";
567 <<
"Creating GEVGPool & adding a GEVGDriver object per init-state";
569 if (fGPool)
delete fGPool;
575 for(nuiter = fNuList.begin(); nuiter != fNuList.end(); ++nuiter) {
576 for(tgtiter = fTgtList.begin(); tgtiter != fTgtList.end(); ++tgtiter) {
578 int target_pdgc = *tgtiter;
579 int neutrino_pdgc = *nuiter;
584 <<
"\n\n ---- Creating a GEVGDriver object configured for init-state: " 585 << init_state.
AsString() <<
" ----\n\n";
592 LOG(
"GMCJDriver",
pDEBUG) <<
"Adding new GEVGDriver object to GEVGPool";
593 fGPool->insert( GEVGPool::value_type(init_state.
AsString(), evgdriver) );
598 <<
"All necessary GEVGDriver object were pushed into GEVGPool\n";
606 if(!fUseSplines)
return;
609 <<
"Asking event generation drivers to compute all needed xsec splines";
613 for(nuiter = fNuList.begin(); nuiter != fNuList.end(); ++nuiter){
614 for(tgtiter = fTgtList.begin(); tgtiter != fTgtList.end(); ++tgtiter) {
615 int target_pdgc = *tgtiter;
616 int neutrino_pdgc = *nuiter;
619 <<
"Computing all splines needed for init-state: " 621 GEVGDriver * evgdriver = fGPool->FindDriver(init_state);
625 LOG(
"GMCJDriver",
pINFO) <<
"Finished creating cross section splines\n";
634 <<
"Summing-up splines to get total cross section for each init state";
637 for(diter = fGPool->begin(); diter != fGPool->end(); ++diter) {
638 string init_state = diter->first;
642 <<
"**** Summing xsec splines for init-state = " << init_state;
645 if (fEmax>rE.
max || fEmax<rE.
min)
647 <<
" rE (validEnergyRange) [" << rE.
min <<
"," << rE.
max <<
"] " 648 <<
" fEmax " << fEmax;
649 assert(fEmax<rE.max && fEmax>rE.
min);
655 double dE = fEmax/10.;
657 double max = (fEmax+dE < rE.
max) ? fEmax+dE : rE.
max;
664 <<
"Finished summing all interaction xsec splines per initial state";
681 <<
"Computing the max. interaction probability (probability scale)";
688 for( ; pmax_iter != fPmax.end(); ++pmax_iter) {
689 TH1D * pmax = pmax_iter->second;
691 delete pmax; pmax = 0;
698 if (fPmaxLogBinning) {
700 double de = (TMath::Log10(fEmax) - TMath::Log10(emin)) / fPmaxNbins;
701 ebins =
new double[fPmaxNbins+1];
702 for(
int i=0; i<=fPmaxNbins; i++) ebins[i] = TMath::Power(10., TMath::Log10(emin) + i * de);
707 double de = fEmax/fPmaxNbins;
709 double emax = fEmax + de;
711 ebins =
new double[fPmaxNbins+1];
712 for(
int i=0; i<=fPmaxNbins; i++) ebins[i] = emin + i * (emax-emin)/fPmaxNbins;
719 for(nuiter = fNuList.begin(); nuiter != fNuList.end(); ++nuiter) {
720 int neutrino_pdgc = *nuiter;
721 TH1D * pmax_hst =
new TH1D(
"pmax_hst",
722 "max interaction probability vs E | geom",fPmaxNbins,ebins);
723 pmax_hst->SetDirectory(0);
726 for(
int ie = 1; ie <= pmax_hst->GetNbinsX(); ie++) {
727 double EvLow = pmax_hst->GetBinCenter(ie) - 0.5*pmax_hst->GetBinWidth(ie);
728 double EvHigh = pmax_hst->GetBinCenter(ie) + 0.5*pmax_hst->GetBinWidth(ie);
734 for(tgtiter = fTgtList.begin(); tgtiter != fTgtList.end(); ++tgtiter) {
735 int target_pdgc = *tgtiter;
740 <<
"Computing Pmax for init-state: " << init_state.
AsString() <<
" E from " << EvLow <<
"-" << EvHigh;
743 GEVGDriver * evgdriver = fGPool->FindDriver(init_state);
750 double plmax = fMaxPathLengths.PathLength(target_pdgc);
754 double pmaxLow = this->InteractionProbability(sxsecLow, plmax, A);
755 double pmaxHigh = this->InteractionProbability(sxsecHigh, plmax, A);
757 double pmax = pmaxHigh;
758 if ( pmaxLow > pmaxHigh){
761 <<
"Lower energy neutrinos have a higher probability of interacting than those at higher energy." 762 <<
" pmaxLow(E=" << EvLow <<
")=" << pmaxLow <<
" and " <<
" pmaxHigh(E=" << EvHigh <<
")=" << pmaxHigh;
765 pmax_hst->SetBinContent(ie, pmax_hst->GetBinContent(ie) + pmax);
768 <<
"Pmax[" << init_state.
AsString() <<
", Ev from " << EvLow <<
"-" << EvHigh <<
"] = " << pmax;
771 pmax_hst->SetBinContent(ie, fPmaxSafetyFactor * pmax_hst->GetBinContent(ie));
774 <<
"Pmax[nu=" << neutrino_pdgc <<
", Ev from " << EvLow <<
"-" << EvHigh <<
"] = " 775 << pmax_hst->GetBinContent(ie);
778 fPmax.insert(map<int,TH1D*>::value_type(neutrino_pdgc,pmax_hst));
788 for(nuiter = fNuList.begin(); nuiter != fNuList.end(); ++nuiter) {
789 int neutrino_pdgc = *nuiter;
791 assert(pmax_iter != fPmax.end());
792 TH1D * pmax_hst = pmax_iter->second;
795 double pmax = pmax_hst->GetMaximum();
798 fGlobPmax = TMath::Max(pmax, fGlobPmax);
800 LOG(
"GMCJDriver",
pNOTICE) <<
"*** Probability scale = " << fGlobPmax;
806 fCurPathLengths.clear();
809 fCurVtx.SetXYZT(0.,0.,0.,0.);
814 LOG(
"GMCJDriver",
pNOTICE) <<
"Generating next event...";
816 this->InitEventGeneration();
819 bool flux_end = fFluxDriver->End();
822 <<
"No more neutrinos can be thrown by the flux driver";
829 if(fKeepThrowingFluxNu) {
831 <<
"Flux neutrino didn't interact - Trying the next one...";
837 LOG(
"GMCJDriver",
pINFO) <<
"Returning NULL event!";
847 double Pno=0, Psum=0;
848 double R = rnd->
RndEvg().Rndm();
849 LOG(
"GMCJDriver",
pDEBUG) <<
"Rndm [0,1] = " <<
R;
852 bool flux_ok = this->GenerateFluxNeutrino();
855 <<
"** Rejecting current flux neutrino (flux driver err)";
859 if (fForceInteraction) {
860 bool pl_ok = this->ComputePathLengths();
862 LOG(
"GMCJDriver",
pFATAL) <<
"** Cannot calculate path lenths!";
865 if(fCurPathLengths.AreAllZero()) {
867 <<
"** Rejecting current flux neutrino (misses generation volume)";
870 Psum = this->ComputeInteractionProbabilities(
false);
872 <<
"The interaction probability is: " << Psum;
884 <<
"Computing interaction probabilities for max. path lengths";
886 Psum = this->ComputeInteractionProbabilities(
true );
889 <<
"The no-interaction probability (max. path lengths) is: " 893 <<
"Negative no-interaction probability! (P = " << 100*Pno <<
" %)" 894 <<
" Particle E=" << fFluxDriver->Momentum().E() <<
" type=" << fFluxDriver->PdgCode() <<
"Psum=" << Psum;
900 <<
"** Rejecting current flux neutrino";
910 Psum = this->PreGenFluxInteractionProbability();
916 pl_ok = this->ComputePathLengths();
919 <<
"** Rejecting current flux neutrino (err computing path-lengths)";
922 if(fCurPathLengths.AreAllZero()) {
924 <<
"** Rejecting current flux neutrino (misses generation volume)";
927 Psum = this->ComputeInteractionProbabilities(
false );
933 <<
"** Rejecting current flux neutrino (has null interaction probability)";
940 <<
"The actual 'no interaction' probability is: " << 100*Pno <<
" %";
943 <<
"Negative no interactin probability! (P = " << 100*Pno <<
" %)";
946 int nupdg = fFluxDriver ->
PdgCode ();
947 const TLorentzVector & nup4 = fFluxDriver ->
Momentum ();
948 const TLorentzVector & nux4 = fFluxDriver -> Position ();
951 <<
"\n [-] Problematic neutrino: " 952 <<
"\n |----o PDG-code : " << nupdg
955 <<
"\n Emax : " << fEmax;
958 <<
"\n Problematic path lengths:" << fCurPathLengths;
961 <<
"\n Maximum path lengths:" << fMaxPathLengths;
967 <<
"** Rejecting current flux neutrino";
978 pl_ok = this->ComputePathLengths();
980 LOG(
"GMCJDriver",
pFATAL) <<
"** Cannot calculate path lenths!";
983 double Psum_curr = this->ComputeInteractionProbabilities(
false );
987 "** Mismatch between pre-calculated and current interaction "<<
995 fSelTgtPdg = this->SelectTargetMaterial(R);
998 <<
"** Rejecting current flux neutrino (failed to select tgt!)";
1004 this->GenerateEventKinematics();
1007 <<
"** Couldn't generate kinematics for selected interaction";
1013 this->GenerateVertexPosition();
1022 if(fForceInteraction) {
1023 double weight = 1. - TMath::Exp(-Psum);
1024 fCurEvt->SetProbability(Psum);
1025 fCurEvt->SetWeight(weight * fCurEvt->Weight());
1028 this->ComputeEventProbability();
1039 LOG(
"GMCJDriver",
pNOTICE) <<
"Generating a flux neutrino";
1041 bool ok = fFluxDriver->GenerateNext();
1044 <<
"*** The flux driver couldn't generate a flux neutrino!!";
1049 int nupdg = fFluxDriver ->
PdgCode ();
1050 const TLorentzVector & nup4 = fFluxDriver ->
Momentum ();
1051 const TLorentzVector & nux4 = fFluxDriver -> Position ();
1054 <<
"\n [-] Generated flux neutrino: " 1055 <<
"\n |----o PDG-code : " << nupdg
1059 if(nup4.Energy() > fEmax) {
1061 <<
"\n *** Flux driver error ***" 1062 <<
"\n Generated flux v with E = " << nup4.Energy() <<
" GeV" 1063 <<
"\n Max v energy (declared by flux driver) = " << fEmax <<
" GeV" 1064 <<
"\n My interaction probability scaling is invalidated!!";
1067 if(!fNuList.ExistsInPDGCodeList(nupdg)) {
1069 <<
"\n *** Flux driver error ***" 1070 <<
"\n Generated flux v with pdg = " << nupdg
1071 <<
"\n It does not belong to the declared list of flux neutrinos" 1072 <<
"\n I was not configured to handle this!!";
1084 fCurPathLengths.clear();
1086 const TLorentzVector & nup4 = fFluxDriver ->
Momentum ();
1087 const TLorentzVector & nux4 = fFluxDriver -> Position ();
1089 fCurPathLengths = fGeomAnalyzer->ComputePathLengths(nux4, nup4);
1091 LOG(
"GMCJDriver",
pNOTICE) << fCurPathLengths;
1093 if(fCurPathLengths.size() == 0) {
1095 <<
"\n *** Geometry driver error ***" 1096 <<
"\n Got an empty PathLengthList - No material found in geometry?";
1100 if(fCurPathLengths.AreAllZero()) {
1102 <<
"current flux v doesn't cross any geometry material...";
1110 <<
"Computing relative interaction probabilities for each material";
1113 int nupdg = fFluxDriver->PdgCode();
1114 const TLorentzVector & nup4 = fFluxDriver->Momentum();
1116 fCurCumulProbMap.clear();
1119 (use_max_path_length) ? fMaxPathLengths : fCurPathLengths;
1124 for(pliter = path_length_list.begin();
1125 pliter != path_length_list.end(); ++pliter) {
1126 int mpdg = pliter->first;
1127 double pl = pliter->second;
1135 GEVGDriver * evgdriver = fGPool->FindDriver(init_state);
1138 <<
"\n * The MC Job driver isn't properly configured!" 1139 <<
"\n * No event generation driver could be found for init state: " 1148 <<
"\n * The MC Job driver isn't properly configured!" 1149 <<
"\n * Couldn't retrieve total cross section spline for init state: " 1153 xsec = totxsecspl->
Evaluate( nup4.Energy() );
1155 prob = this->InteractionProbability(xsec,pl,A);
1157 <<
" (xsec, pl, A)=(" << xsec <<
"," << pl <<
"," << A <<
")";
1163 if(fForceInteraction) pmax = 1.;
1164 else if(fGenerateUnweighted) pmax = fGlobPmax;
1167 assert(pmax_iter != fPmax.end());
1168 TH1D * pmax_hst = pmax_iter->second;
1170 int ie = pmax_hst->FindBin(nup4.Energy());
1171 pmax = pmax_hst->GetBinContent(ie);
1178 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 1180 <<
"tgt: " << mpdg <<
" -> TotXSec = " 1181 << xsec/
units::cm2 <<
" cm^2, Norm.Prob = " << 100*probn <<
"%";
1185 fCurCumulProbMap.insert(map<int,double>::value_type(mpdg,probsum));
1195 LOG(
"GMCJDriver",
pNOTICE) <<
"Selecting target material";
1198 for( ; probiter != fCurCumulProbMap.end(); ++probiter) {
1199 double prob = probiter->second;
1201 tgtpdg = probiter->first;
1203 <<
"Selected target material = " << tgtpdg;
1208 <<
"Could not select target material for an interacting neutrino";
1214 int nupdg = fFluxDriver->PdgCode();
1215 const TLorentzVector & nup4 = fFluxDriver->Momentum();
1220 GEVGDriver * evgdriver = fGPool->FindDriver(init_state);
1223 <<
"No GEVGDriver object for init state: " << init_state.
AsString();
1233 <<
"Asking the selected GEVGDriver object to generate an event";
1242 <<
"Asking the geometry analyzer to generate a vertex";
1244 const TLorentzVector & p4 = fFluxDriver->Momentum ();
1245 const TLorentzVector & x4 = fFluxDriver->Position ();
1247 const TVector3 & vtx = fGeomAnalyzer->GenerateVertex(x4, p4, fSelTgtPdg);
1249 TVector3
origin(x4.X(), x4.Y(), x4.Z());
1252 double dL = origin.Mag();
1257 <<
"|vtx - origin|: dL = " << dL <<
" m, dt = " << dt <<
" sec";
1259 fCurVtx.SetXYZT(vtx.x(), vtx.y(), vtx.z(), x4.T() + dt);
1261 fCurEvt->SetVertex(fCurVtx);
1269 double xsec = fCurEvt->XSec();
1273 double path_length = pliter->second;
1279 double P = this->InteractionProbability(xsec, path_length, A);
1286 int nu_pdg = nu->
Pdg();
1287 double Ev = nu->
P4()->Energy();
1290 if(!fGenerateUnweighted) {
1292 assert(pmax_iter != fPmax.end());
1293 TH1D * pmax_hst = pmax_iter->second;
1295 double pmax = pmax_hst->GetBinContent(pmax_hst->FindBin(Ev));
1297 weight = pmax/fGlobPmax;
1301 fCurEvt->SetProbability(P);
1302 fCurEvt->SetWeight(weight * fCurEvt->Weight());
1315 return kNA*(xsec*pL)/A;
1326 "Cannot get pre-computed flux interaction probability as no tree!";
1330 assert(fFluxDriver->Index() >= 0);
1334 bool found_entry = fFluxIntTree->GetEntryWithIndex(fFluxDriver->Index()) > 0;
1335 bool enu_match =
false;
1337 double rel_err = fBrFluxEnu-fFluxDriver->Momentum().E();
1340 if(enu_match ==
false){
1342 "Mismatch between: Enu_curr = "<< fFluxDriver->Momentum().E() <<
1343 ", Enu_pre_gen = "<< fBrFluxEnu;
1347 LOG(
"GMCJDriver",
pERROR) <<
"Cannot find flux entry in interaction prob tree!";
1351 bool success = found_entry && enu_match;
1354 "Cannot find pre-generated interaction probability! Check you "<<
1355 "are using the correct pre-generated interaction prob file " <<
1356 "generated using current flux input file with same input " <<
1357 "config (same geom TopVol, neutrino species list)";
1361 return fBrFluxIntProb/fGlobPmax;
void CreateXSecSumSpline(int nk, double Emin, double Emax, bool inlogE=true)
void SetUnphysEventMask(const TBits &mask)
void ForceInteraction(void)
void PopulateEventGenDriverPool(void)
bool PreCalcFluxProbabilities(void)
THE MAIN GENIE PROJECT NAMESPACE
void GetMaxPathLengthList(void)
static RandomGen * Instance()
Access instance.
void SetEventGeneratorList(string listname)
const TLorentzVector * P4(void) const
static constexpr double gram
void InitEventGeneration(void)
A simple [min,max] interval for doubles.
string BoolAsYNString(bool b)
A numeric analysis tool class for interpolating 1-D functions.
int IonPdgCodeToA(int pdgc)
bool GenerateFluxNeutrino(void)
bool ComputePathLengths(void)
string P4AsString(const TLorentzVector *p)
std::pair< float, std::string > P
const Spline * XSecSumSpline(void) const
double Evaluate(double x) const
A singleton holding random number generator classes. All random number generation in GENIE should tak...
void ComputeEventProbability(void)
Range1D_t ValidEnergyRange(void) const
void UseFluxDriver(GFluxI *flux)
Object to be filled with the neutrino path-length, for all detector geometry materials, when starting from a position x and travelling along the direction of the neutrino 4-momentum.
void KeepOnThrowingFluxNeutrinos(bool keep_on)
void GetMaxFluxEnergy(void)
static constexpr double second
static unsigned int NFlags(void)
int PdgCode(Resonance_t res, int Q)
(resonance id, charge) -> PDG code
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
static constexpr double kilogram
void SetEventGeneratorList(string listname)
static constexpr double m2
void SetPmaxSafetyFactor(double sf)
static constexpr double cm2
void ForceSingleProbScale(void)
double PreGenFluxInteractionProbability(void)
static Messenger * Instance(void)
bool UseMaxPathLengths(string xml_filename)
void Configure(bool calc_prob_scales=true)
string AsString(void) const
static const double kASmallNum
TRandom3 & RndEvg(void) const
rnd number generator used by the event generation drivers
GENIE Event Generation Driver. A minimalist user interface object for generating neutrino interaction...
void SetPmaxLogBinning(void)
static int max(int a, int b)
void BootstrapXSecSplines(void)
double ComputeInteractionProbabilities(bool use_max_path_length)
static const double kLightSpeed
EventRecord * GenerateEvent(void)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
double InteractionProbability(double xsec, double pl, int A)
void SetPmaxNbins(int nbins)
void PreSelectEvents(bool preselect=true)
static constexpr double meter
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void GenerateEventKinematics(void)
int SelectTargetMaterial(double R)
void GenerateVertexPosition(void)
void SetXSecSplineNbins(int nbins)
void ComputeProbScales(void)
void Configure(int nu_pdgc, int Z, int A)
bool LoadFluxProbabilities(string filename)
EventRecord * GenerateEvent1Try(void)
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
void CreateSplines(int nknots=-1, double emax=-1, bool inLogE=true)
void BootstrapXSecSplineSummation(void)
Defines the GENIE Geometry Analyzer Interface.
string X4AsString(const TLorentzVector *x)
void SetUnphysEventMask(const TBits &mask)
STDHEP-like event record entry that can fit a particle or a nucleus.
void UseGeomAnalyzer(GeomAnalyzerI *geom)
void UseSplines(bool useLogE=true)
void SaveFluxProbabilities(string outfilename)
constexpr Point origin()
Returns a origin position with a point of the specified type.
void GetParticleLists(void)
Event finding and building.
static AlgConfigPool * Instance()
Initial State information.
GENIE Interface for user-defined flux classes.
EventRecord * GenerateEvent(const TLorentzVector &nu4p)
A pool of GEVGDriver objects with an initial state key.