21 #include "libxml/xmlmemory.h" 22 #include "libxml/parser.h" 29 #include <TChainElement.h> 31 #include <TStopwatch.h> 34 #include "Framework/Conventions/GBuild.h" 38 #include "Tools/Flux/GNuMINtuple/g3numi.C" 40 #include "Tools/Flux/GNuMINtuple/g4numi.C" 42 #include "Tools/Flux/GNuMINtuple/flugg.C" 63 #ifdef GNUMI_TEST_XY_WGT 64 static genie::flux::xypartials gpartials;
67 using namespace genie;
81 std::vector<long int> GetIntVector(
std::string str);
85 void ParseParamSet(xmlDocPtr&, xmlNodePtr&);
86 void ParseBeamDir(xmlDocPtr&, xmlNodePtr&);
88 void ParseRotSeries(xmlDocPtr&, xmlNodePtr&);
89 void ParseWindowSeries(xmlDocPtr&, xmlNodePtr&);
101 TVector3 fFluxWindowPtXML[3];
109 const TLorentzVector kPosCenterNearBeam(0.,0., 1039.35,0.);
148 LOG(
"Flux",
pNOTICE) <<
"GenerateNext signaled End() ";
153 bool nextok = this->GenerateNext_weighted();
154 if ( fGenWeighted )
return nextok;
155 if ( ! nextok )
continue;
170 double f = this->Weight() / fMaxWeight;
174 fMaxWeight = this->Weight() * fMaxWgtFudge;
176 <<
"** Fractional weight = " << f
177 <<
" > 1 !! Bump fMaxWeight estimate to " << fMaxWeight
178 << PassThroughInfo();
180 double r = (f < 1.) ? rnd->
RndFlux().Rndm() : 0;
181 bool accept = ( r <
f );
184 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 186 <<
"Generated beam neutrino: " 187 <<
"\n pdg-code: " << fCurEntry->fgPdgC
210 if ( ! fG3NuMI && ! fG4NuMI && ! fFlugg ) {
212 <<
"The flux driver has not been properly configured";
221 if ( fIUse < fNUse && fIEntry >= 0 ) {
226 this->ResetCurrent();
229 if ( fIEntry >= fNEntries ) {
232 if ( fICycle < fNCycles || fNCycles == 0 ) {
237 <<
"No more entries in input flux neutrino ntuple, cycle " 238 << fICycle <<
" of " << fNCycles;
246 fG3NuMI->GetEntry(fIEntry);
247 fCurEntry->MakeCopy(fG3NuMI);
248 }
else if ( fG4NuMI ) {
249 fG4NuMI->GetEntry(fIEntry);
250 fCurEntry->MakeCopy(fG4NuMI);
251 }
else if ( fFlugg ) {
252 fFlugg->GetEntry(fIEntry);
253 fCurEntry->MakeCopy(fFlugg);
255 LOG(
"Flux",
pERROR) <<
"No ntuple configured";
260 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 262 <<
"got " << fNNeutrinos <<
" new fIEntry " << fIEntry
263 <<
" evtno " << fCurEntry->evtno;
267 fCurEntry->pcodes = 0;
268 fCurEntry->units = 0;
272 fCurEntry->ConvertPartCodes();
274 fCurEntry->fgPdgC = fCurEntry->ntype;
289 fAccumPOTs += fEffPOTsPerNu / fMaxWeight;
292 if ( ! fPdgCList->ExistsInPDGCodeList(fCurEntry->fgPdgC) ) {
296 int badpdg = fCurEntry->fgPdgC;
297 if ( ! fPdgCListRej->ExistsInPDGCodeList(badpdg) ) {
298 fPdgCListRej->push_back(badpdg);
300 <<
"Encountered neutrino specie (" << badpdg
301 <<
" pcodes=" << fCurEntry->pcodes <<
")" 302 <<
" that wasn't in SetFluxParticles() list, " 303 <<
"\nDeclared list of neutrino species: " << *fPdgCList;
318 fCurEntry->fgX4 = fFluxWindowBase;
321 double& wgt_xy = fCurEntry->fgXYWgt;
322 switch ( fUseFluxAtDetCenter ) {
324 wgt_xy = fCurEntry->nwtnear;
325 Ev = fCurEntry->nenergyn;
328 wgt_xy = fCurEntry->nwtfar;
329 Ev = fCurEntry->nenergyf;
333 fCurEntry->fgX4 += ( rnd->
RndFlux().Rndm()*fFluxWindowDir1 +
334 rnd->
RndFlux().Rndm()*fFluxWindowDir2 );
335 fCurEntry->CalcEnuWgt(fCurEntry->fgX4,Ev,wgt_xy);
341 <<
"Flux neutrino energy exceeds declared maximum neutrino energy" 342 <<
"\nEv = " << Ev <<
"(> Ev{max} = " << fMaxEv <<
")";
347 fgX4dkvtx = TLorentzVector( fCurEntry->vx,
352 TVector3 dirNu = (fCurEntry->fgX4.Vect() - fgX4dkvtx.Vect()).Unit();
353 fCurEntry->fgP4.SetPxPyPzE( Ev*dirNu.X(),
359 fWeight = fCurEntry->nimpwt * fCurEntry->fgXYWgt;
360 if ( fApplyTiltWeight ) {
361 double tiltwgt = dirNu.Dot( FluxWindowNormal() );
362 fWeight *= TMath::Abs( tiltwgt );
366 fSumWeight += this->Weight();
369 Beam2UserP4(fCurEntry->fgP4,fCurEntry->fgP4User);
370 Beam2UserPos(fCurEntry->fgX4,fCurEntry->fgX4User);
373 if ( TMath::Abs(fZ0) < 1.0e30 ) this->MoveToZ0(fZ0);
375 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 377 <<
"Generated neutrino: " << fIEntry <<
" " << fCurEntry->evtno
378 <<
" nenergyn " << fCurEntry->nenergyn
379 <<
"\n pdg-code: " << fCurEntry->fgPdgC
387 <<
"Generated neutrino had E_nu = " << Ev <<
" > " << fMaxEv
399 TVector3 x3diff = fCurEntry->fgX4.Vect() - fgX4dkvtx.Vect();
400 return x3diff.Mag() * fLengthScaleB2U;
408 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 410 <<
"MoveToZ0 (z0usr=" << z0usr <<
") before:" 415 double pzusr = fCurEntry->fgP4User.Pz();
416 if ( TMath::Abs(pzusr) < 1.0
e-30 ) {
419 <<
"MoveToZ0(" << z0usr <<
") not possible due to pz_usr (" << pzusr <<
")";
423 double scale = (z0usr - fCurEntry->fgX4User.Z()) / pzusr;
424 fCurEntry->fgX4User += (scale*fCurEntry->fgP4User);
425 fCurEntry->fgX4 += ((fLengthScaleU2B*scale)*fCurEntry->fgP4);
427 fCurEntry->fgX4.SetT(0);
428 fCurEntry->fgX4User.SetT(0);
430 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 432 <<
"MoveToZ0 (" << z0usr <<
") after:" 443 if (!fNuFluxTree)
return;
449 const double kRDET = 100.0;
450 const double kRDET2 = kRDET * kRDET;
451 double flux_area = fFluxWindowDir1.Vect().Cross(fFluxWindowDir2.Vect()).Mag();
452 LOG(
"Flux",
pNOTICE) <<
"in CalcEffPOTsPerNu, area = " << flux_area;
454 if ( flux_area < 1.0
e-30 ) {
456 <<
"CalcEffPOTsPerNu called with flux window area effectively zero";
459 double area_ratio = TMath::Pi() * kRDET2 / flux_area;
460 fEffPOTsPerNu = area_ratio * ( (double)fFilePOTs / (
double)fNEntries );
470 <<
"The flux driver has not been properly configured";
490 bool found_cfg = this->LoadConfig(config);
493 <<
"LoadBeamSimData could not find XML config \"" << config <<
"\"\n";
497 fNuFluxFilePatterns = patterns;
498 std::vector<int> nfiles_from_pattern;
502 std::set<std::string> fnames;
504 LOG(
"Flux",
pINFO) <<
"LoadBeamSimData was passed " << patterns.size()
507 for (
size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
508 string pattern = patterns[ipatt];
509 nfiles_from_pattern.push_back(0);
512 <<
"Loading gnumi flux tree from ROOT file pattern [" 513 <<
std::setw(3) << ipatt <<
"] \"" << pattern <<
"\"";
516 string dirname = gSystem->UnixPathName(gSystem->WorkingDirectory());
517 size_t slashpos = pattern.find_last_of(
"/");
519 if ( slashpos != std::string::npos ) {
520 dirname = pattern.substr(0,slashpos);
521 LOG(
"Flux",
pINFO) <<
"Look for flux using directory " << dirname;
522 fbegin = slashpos + 1;
523 }
else { fbegin = 0; }
525 void* dirp = gSystem->OpenDirectory(gSystem->ExpandPathName(dirname.c_str()));
528 pattern.substr(fbegin,pattern.size()-fbegin);
529 TRegexp re(basename.c_str(),kTRUE);
531 while ( ( onefile = gSystem->GetDirEntry(dirp) ) ) {
532 TString afile = onefile;
533 if ( afile==
"." || afile==
".." )
continue;
534 if ( basename!=afile && afile.Index(re) == kNPOS )
continue;
535 std::string fullname = dirname +
"/" + afile.Data();
536 fnames.insert(fullname);
537 nfiles_from_pattern[ipatt]++;
539 gSystem->FreeDirectory(dirp);
545 for ( ; sitr != fnames.end(); ++sitr, ++indx ) {
558 TFile*
tf = TFile::Open(filename.c_str(),
"READ");
559 int isflugg = ( filename.find(
"flugg") != string::npos ) ? 1 : 0;
561 const std::string gnames[] = {
"g3numi",
"g4numi",
"flugg",
"g4flugg"};
562 for (
int j = 0; j < 2 ; ++j ) {
563 TTree* atree = (TTree*)tf->Get(tnames[j].c_str());
566 const std::string gname_this = gnames[j+2*isflugg];
568 if ( ! fNuFluxTree ) {
569 this->SetTreeName(tname_this);
570 fNuFluxTree =
new TChain(fNuFluxTreeName.c_str());
571 fNuFluxGen = gname_this;
576 if ( fNuFluxTreeName != tname_this ||
577 fNuFluxGen != gname_this ) {
579 <<
"Inconsistent flux file types\n" 580 <<
"The input gnumi flux file \"" << filename
581 <<
"\"\ncontains a '" << tname_this <<
"' " << gname_this
583 <<
"but a '" << fNuFluxTreeName <<
"' " << fNuFluxGen
584 <<
" numi ntuple has alread been seen in the chain";
588 this->AddFile(atree,filename);
596 if ( fNuFluxTreeName ==
"" ) {
598 <<
"The input gnumi flux file doesn't exist! Initialization failed!";
601 if ( fNuFluxGen ==
"g3numi" ) fG3NuMI =
new g3numi(fNuFluxTree);
602 if ( fNuFluxGen ==
"g4numi" ) fG4NuMI =
new g4numi(fNuFluxTree);
603 if ( fNuFluxGen ==
"flugg" ) fFlugg =
new flugg(fNuFluxTree);
606 fNEntries = fNuFluxTree->GetEntries();
608 if ( fNEntries == 0 ) {
610 <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
612 <<
"Loaded flux tree contains " << fNEntries <<
" entries";
614 <<
"Was passed the file patterns: ";
615 for (
size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
616 string pattern = patterns[ipatt];
621 <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
624 <<
"Loaded flux tree contains " << fNEntries <<
" entries" 625 <<
" from " << fnames.size() <<
" unique files";
626 for (
size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
627 string pattern = patterns[ipatt];
629 <<
" pattern: " << pattern <<
" yielded " 630 << nfiles_from_pattern[ipatt] <<
" files";
637 <<
"LoadBeamSimData left detector location unset";
641 <<
"Run ScanForMaxWeight() as part of LoadBeamSimData";
642 this->ScanForMaxWeight();
651 fIEntry = rnd->
RndFlux().Integer(fNEntries) - 1;
658 LOG(
"Flux",
pNOTICE) <<
"about to CalcEffPOTsPerNu";
659 this->CalcEffPOTsPerNu();
664 std::vector<std::string>& branchClassNames,
665 std::vector<void**>& branchObjPointers)
672 branchNames.push_back(
"flux");
673 branchClassNames.push_back(
"genie::flux::GNuMIFluxPassThroughInfo");
674 branchObjPointers.push_back((
void**)&fCurEntry);
684 <<
"Specify a detector location before scanning for max weight";
689 int ipos_estimator = fUseFluxAtDetCenter;
690 if ( ipos_estimator == 0 ) {
692 double zbase = fFluxWindowBase.Z();
693 if ( TMath::Abs(zbase-103648.837) < 10000. ) ipos_estimator = -1;
694 if ( TMath::Abs(zbase-73534000. ) < 10000. ) ipos_estimator = +1;
696 if ( ipos_estimator != 0 ) {
700 const char* ntwgtstrv[4] = {
"Nimpwt*Nwtnear",
703 "Nimpwt*NWtFar[0]" };
705 if ( ipos_estimator > 0 ) strindx = 1;
706 if ( fG4NuMI ) strindx += 2;
708 Long64_t nscan = TMath::Min(fNEntries,200000LL);
710 fNuFluxTree->Draw(ntwgtstrv[strindx],
"",
"goff",nscan);
715 Long64_t idx = TMath::LocMax(fNuFluxTree->GetSelectedRows(),
716 fNuFluxTree->GetV1());
718 fMaxWeight = fNuFluxTree->GetV1()[idx];
719 LOG(
"Flux",
pNOTICE) <<
"Maximum flux weight from Nwt in ntuple = " 721 if ( fMaxWeight <= 0 ) {
722 LOG(
"Flux",
pFATAL) <<
"Non-positive maximum flux weight!";
728 double wgtgenmx = 0, enumx = 0;
731 for (
int itry=0; itry < fMaxWgtEntries; ++itry) {
732 this->GenerateNext_weighted();
733 double wgt = this->Weight();
734 if ( wgt > wgtgenmx ) wgtgenmx = wgt;
735 double enu = fCurEntry->fgP4.Energy();
736 if ( enu > enumx ) enumx =
enu;
740 LOG(
"Flux",
pNOTICE) <<
"Maximum flux weight for spin = " 741 << wgtgenmx <<
", energy = " << enumx
742 <<
" (" << fMaxWgtEntries <<
")";
744 if (wgtgenmx > fMaxWeight ) fMaxWeight = wgtgenmx;
746 fMaxWeight *= fMaxWgtFudge;
748 if ( enumx*fMaxEFudge > fMaxEv ) {
749 LOG(
"Flux",
pNOTICE) <<
"Adjust max: was=" << fMaxEv
750 <<
" now " << enumx <<
"*" << fMaxEFudge
751 <<
" = " << enumx*fMaxEFudge;
752 fMaxEv = enumx * fMaxEFudge;
755 LOG(
"Flux",
pNOTICE) <<
"Maximum flux weight = " << fMaxWeight
756 <<
", energy = " << fMaxEv;
762 fMaxEv = TMath::Max(0.,Ev);
765 <<
"Declared maximum flux neutrino energy: " << fMaxEv;
773 fNUse = TMath::Max(1L, nuse);
778 fNuFluxTreeName =
name;
784 fFluxWindowBase = kPosCenterNearBeam;
785 fFluxWindowDir1 = TLorentzVector();
786 fFluxWindowDir2 = TLorentzVector();
787 fUseFluxAtDetCenter = -1;
795 fFluxWindowDir1 = TLorentzVector();
796 fFluxWindowDir2 = TLorentzVector();
797 fUseFluxAtDetCenter = +1;
806 double padbeam = padding / fLengthScaleB2U;
808 <<
"SetBeamFluxWindow " << (
int)stdwindow <<
" padding " << padbeam <<
" cm";
811 switch ( stdwindow ) {
812 #ifdef THIS_IS_NOT_YET_IMPLEMENTED 814 SetBeamFluxWindow(103648.837);
817 SetBeamFluxWindow(73534000.);
826 case kMinosNearCenter:
829 fFluxWindowBase = kPosCenterNearBeam;
830 fFluxWindowDir1 = TLorentzVector();
831 fFluxWindowDir2 = TLorentzVector();
832 TLorentzVector usrpos;
833 Beam2UserPos(fFluxWindowBase, usrpos);
834 fFluxWindowPtUser[0] = usrpos.Vect();
835 fFluxWindowPtUser[1] = fFluxWindowPtUser[0];
836 fFluxWindowPtUser[2] = fFluxWindowPtUser[0];
841 case kMinosFarCenter:
845 fFluxWindowDir1 = TLorentzVector();
846 fFluxWindowDir2 = TLorentzVector();
847 TLorentzVector usrpos;
848 Beam2UserPos(fFluxWindowBase, usrpos);
849 fFluxWindowPtUser[0] = usrpos.Vect();
850 fFluxWindowPtUser[1] = fFluxWindowPtUser[0];
851 fFluxWindowPtUser[2] = fFluxWindowPtUser[0];
858 <<
"SetBeamFluxWindow - StdFluxWindow " << stdwindow
859 <<
" not yet implemented";
862 LOG(
"Flux",
pNOTICE) <<
"about to CalcEffPOTsPerNu";
863 this->CalcEffPOTsPerNu();
872 fUseFluxAtDetCenter = 0;
875 fFluxWindowPtUser[0] = p0;
876 fFluxWindowPtUser[1] = p1;
877 fFluxWindowPtUser[2] = p2;
881 TLorentzVector ptbm0, ptbm1, ptbm2;
882 User2BeamPos(TLorentzVector(fFluxWindowPtUser[0],0),ptbm0);
883 User2BeamPos(TLorentzVector(fFluxWindowPtUser[1],0),ptbm1);
884 User2BeamPos(TLorentzVector(fFluxWindowPtUser[2],0),ptbm2);
886 fFluxWindowBase = ptbm0;
887 fFluxWindowDir1 = ptbm1 - ptbm0;
888 fFluxWindowDir2 = ptbm2 - ptbm0;
890 fFluxWindowLen1 = fFluxWindowDir1.Mag();
891 fFluxWindowLen2 = fFluxWindowDir2.Mag();
892 fWindowNormal = fFluxWindowDir1.Vect().Cross(fFluxWindowDir2.Vect()).Unit();
894 double dot = fFluxWindowDir1.Dot(fFluxWindowDir2);
895 if ( TMath::Abs(dot) > 1.0
e-8 )
896 LOG(
"Flux",
pWARN) <<
"Dot product between window direction vectors was " 897 << dot <<
"; please check for orthoganality";
899 LOG(
"Flux",
pNOTICE) <<
"about to CalcEffPOTsPerNu";
900 this->CalcEffPOTsPerNu();
907 p0 = fFluxWindowPtUser[0];
908 p1 = fFluxWindowPtUser[1];
909 p2 = fFluxWindowPtUser[2];
916 fBeamRot = TLorentzRotation(beamrot);
917 fBeamRotInv = fBeamRot.Inverse();
924 fBeamZero = TLorentzVector(beam0,0);
934 const TLorentzRotation& rot4 = fBeamRot;
935 TVector3 newX(rot4.XX(),rot4.XY(),rot4.XZ());
936 TVector3 newY(rot4.YX(),rot4.YY(),rot4.YZ());
937 TVector3 newZ(rot4.ZX(),rot4.ZY(),rot4.ZZ());
938 rot3.RotateAxes(newX,newY,newZ);
939 return rot3.Inverse();
943 TVector3 beam0 = fBeamZero.Vect();
972 TLorentzVector& usrxyz)
const 974 usrxyz = fLengthScaleB2U*(fBeamRot*beamxyz) + fBeamZero;
977 TLorentzVector& usrdir)
const 979 usrdir = fLengthScaleB2U*(fBeamRot*beamdir);
982 TLorentzVector& usrp4 )
const 984 usrp4 = fBeamRot*beamp4;
988 TLorentzVector& beamxyz)
const 990 beamxyz = fLengthScaleU2B*(fBeamRotInv*(usrxyz-fBeamZero));
993 TLorentzVector& beamdir)
const 995 beamdir = fLengthScaleU2B*(fBeamRotInv*usrdir);
998 TLorentzVector& beamp4)
const 1000 beamp4 = fBeamRotInv*usrp4;
1006 LOG(
"Flux",
pNOTICE) <<
"CurrentEntry:" << *fCurEntry;
1013 LOG(
"Flux",
pWARN) <<
"GSimpleNtpFlux::Clear(" << opt <<
") called";
1027 fGenWeighted = gen_weighted;
1032 LOG(
"Flux",
pNOTICE) <<
"Initializing GNuMIFlux driver";
1043 fNuFluxTreeName =
"";
1057 fMaxWgtFudge = 1.05;
1058 fMaxWgtEntries = 2500000;
1066 fGenWeighted =
false;
1067 fApplyTiltWeight =
true;
1068 fUseFluxAtDetCenter = 0;
1069 fDetLocIsSet =
false;
1073 this->SetDefaults();
1074 this->ResetCurrent();
1089 LOG(
"Flux",
pNOTICE) <<
"Setting default GNuMIFlux driver options";
1097 this->SetFluxParticles (particles);
1098 this->SetMaxEnergy (120.);
1099 this->SetUpstreamZ (-3.4e38);
1100 this->SetNumOfCycles (0);
1101 this->SetEntryReuse (1);
1103 this->SetXMLFileBase(
"GNuMIFlux.xml");
1111 fCurEntry->ResetCurrent();
1112 fCurEntry->ResetCopy();
1119 if (fPdgCList)
delete fPdgCList;
1120 if (fPdgCListRej)
delete fPdgCListRej;
1121 if (fCurEntry)
delete fCurEntry;
1123 if ( fG3NuMI )
delete fG3NuMI;
1124 if ( fG4NuMI )
delete fG4NuMI;
1125 if ( fFlugg )
delete fFlugg;
1128 <<
" flux file cycles: " << fICycle <<
" of " << fNCycles
1129 <<
", entry " << fIEntry <<
" use: " << fIUse <<
" of " << fNUse;
1137 ULong64_t
nentries = thetree->GetEntries();
1148 thetree->SetMakeClass(1);
1154 TBranch* br_evtno = 0;
1155 thetree->SetBranchAddress(
"evtno",&evtno, &br_evtno);
1156 Int_t evt_1 = 0x7FFFFFFF;
1160 for (
int j=0; j<50; ++j) {
1161 thetree->GetEntry(j);
1162 if (evtno != 0) evt_1 = TMath::Min(evtno,evt_1);
1163 thetree->GetEntry(nentries-1 -j );
1164 if (evtno != 0) evt_N = TMath::Max(evtno,evt_N);
1172 const Int_t nquant = 1000;
1173 const Double_t rquant = nquant;
1175 for (
int j=0; j<50; ++j) {
1176 thetree->GetEntry(j);
1177 if (evtno != 0) evt_1 = TMath::Min(evtno,evt_1);
1178 std::cout <<
"[" << j <<
"] evtno=" << evtno <<
" evt_1=" << evt_1 <<
std::endl;
1180 for (
int j=0; j<50; ++j) {
1181 thetree->GetEntry(nentries-1 -j );
1182 if (evtno != 0) evt_N = TMath::Max(evtno,evt_N);
1183 std::cout <<
"[" << (nentries-1-j) <<
"] evtno=" << evtno <<
" evt_N=" << evt_N <<
std::endl;
1186 Int_t nquant = 1000;
1187 Double_t rquant = nquant;
1190 Int_t est_1 = (TMath::FloorNint(evt_1/rquant))*nquant + 1;
1191 Int_t est_N = (TMath::FloorNint((evt_N-1)/rquant)+1)*nquant;
1192 ULong64_t npots = est_N - est_1 + 1;
1194 << fNuFluxTreeName <<
"->AddFile() of " << nentries <<
" entries [" 1195 << evt_1 <<
":" << evt_N <<
"%" << nquant
1196 <<
"(" << est_1 <<
":" << est_N <<
")=" 1197 << npots <<
" POTs] in {" << fNuFluxGen <<
"} file: " <<
fname;
1202 fNuFluxTree->AddFile(fname.c_str());
1218 double rescale = fLengthUnits / user_units;
1219 fLengthUnits = user_units;
1221 fLengthScaleB2U = cm / user_units;
1222 fLengthScaleU2B = user_units /
cm;
1226 fCurEntry->fgX4User *=
rescale;
1228 fFluxWindowPtUser[0] *=
rescale;
1229 fFluxWindowPtUser[1] *=
rescale;
1230 fFluxWindowPtUser[2] *=
rescale;
1244 return fLengthScaleB2U *
cm ;
1324 #ifndef SKIP_MINERVA_MODS 1331 for (
unsigned int itclear = 0; itclear <
MAX_N_TRAJ; itclear++ ) {
1364 fgP4.SetPxPyPzE(0.,0.,0.,0.);
1365 fgX4.SetXYZT(0.,0.,0.,0.);
1456 <<
"ConvertPartCodes saw ntype " <<
ntype <<
" -- unknown ";
1461 }
else if (
pcodes != 1 ) {
1464 <<
"ConvertPartCodes saw pcodes flag as " <<
pcodes;
1549 const int kNearIndx = 0;
1550 const int kFarIndx = 0;
1617 #ifndef SKIP_MINERVA_MODS
1628 for ( Int_t ic = 0; ic < ntraj; ++ic ) {
1730 double&
enu,
double& wgt_xy)
const 1775 const double kPIMASS = 0.13957;
1776 const double kKMASS = 0.49368;
1777 const double kK0MASS = 0.49767;
1778 const double kMUMASS = 0.105658389;
1779 const double kOMEGAMASS = 1.67245;
1781 const int kpdg_nue = 12;
1782 const int kpdg_nuebar = -12;
1783 const int kpdg_numu = 14;
1784 const int kpdg_numubar = -14;
1786 const int kpdg_muplus = -13;
1787 const int kpdg_muminus = 13;
1788 const int kpdg_pionplus = 211;
1789 const int kpdg_pionminus = -211;
1790 const int kpdg_k0long = 130;
1791 const int kpdg_k0short = 310;
1792 const int kpdg_k0mix = 311;
1793 const int kpdg_kaonplus = 321;
1794 const int kpdg_kaonminus = -321;
1795 const int kpdg_omegaminus = 3334;
1796 const int kpdg_omegaplus = -3334;
1798 const double kRDET = 100.0;
1800 double xpos = xyz.X();
1801 double ypos = xyz.Y();
1802 double zpos = xyz.Z();
1810 double parent_mass = kPIMASS;
1811 switch ( this->
ptype ) {
1813 case kpdg_pionminus:
1814 parent_mass = kPIMASS;
1817 case kpdg_kaonminus:
1818 parent_mass = kKMASS;
1823 parent_mass = kK0MASS;
1827 parent_mass = kMUMASS;
1829 case kpdg_omegaminus:
1830 case kpdg_omegaplus:
1831 parent_mass = kOMEGAMASS;
1834 std::cerr <<
"NU_REWGT unknown particle type " << this->
ptype 1836 LOG(
"Flux",
pFATAL) <<
"NU_REWGT unknown particle type " << this->
ptype;
1841 double parentp2 = ( this->
pdpx*this->
pdpx +
1844 double parent_energy = TMath::Sqrt( parentp2 +
1845 parent_mass*parent_mass);
1846 double parentp = TMath::Sqrt( parentp2 );
1848 double gamma = parent_energy / parent_mass;
1849 double gamma_sqr = gamma *
gamma;
1850 double beta_mag = TMath::Sqrt( ( gamma_sqr - 1.0 )/gamma_sqr );
1853 double enuzr = this->
necm;
1855 double rad = TMath::Sqrt( (xpos-this->
vx)*(xpos-this->
vx) +
1856 (ypos-this->
vy)*(ypos-this->
vy) +
1857 (zpos-this->
vz)*(zpos-this->
vz) );
1860 double costh_pardet = -999., theta_pardet = -999.;
1863 if ( parentp > 0. ) {
1864 costh_pardet = ( this->
pdpx*(xpos-this->
vx) +
1865 this->
pdpy*(ypos-this->
vy) +
1866 this->
pdpz*(zpos-this->
vz) )
1868 if ( costh_pardet > 1.0 ) costh_pardet = 1.0;
1869 if ( costh_pardet < -1.0 ) costh_pardet = -1.0;
1870 theta_pardet = TMath::ACos(costh_pardet);
1873 emrat = 1.0 / ( gamma * ( 1.0 - beta_mag * costh_pardet ));
1876 enu = emrat * enuzr;
1882 std::cout <<
"xyz (" << xpos <<
"," << ypos <<
"," << zpos <<
")" <<
std::endl;
1883 std::cout <<
"ptype " << this->
ptype <<
" m " << parent_mass
1884 <<
" p " << parentp <<
" e " << parent_energy <<
" gamma " << gamma
1887 std::cout <<
" enuzr " << enuzr <<
" rad " << rad <<
" costh " << costh_pardet
1888 <<
" theta " << theta_pardet <<
" emrat " << emrat
1892 #ifdef GNUMI_TEST_XY_WGT 1893 gpartials.xdet =
xpos;
1894 gpartials.ydet =
ypos;
1895 gpartials.zdet =
zpos;
1896 gpartials.parent_mass = parent_mass;
1897 gpartials.parentp = parentp;
1898 gpartials.parent_energy = parent_energy;
1899 gpartials.gamma =
gamma;
1900 gpartials.beta_mag = beta_mag;
1901 gpartials.enuzr = enuzr;
1902 gpartials.rad =
rad;
1903 gpartials.costh_pardet = costh_pardet;
1904 gpartials.theta_pardet = theta_pardet;
1905 gpartials.emrat = emrat;
1906 gpartials.eneu =
enu;
1913 double sanddetcomp = TMath::Sqrt(( (xpos-this->
vx)*(xpos-this->
vx) ) +
1914 ( (ypos-this->
vy)*(ypos-this->
vy) ) +
1915 ( (zpos-this->
vz)*(zpos-this->
vz) ) );
1916 double sangdet = ( 1.0 - TMath::Cos(TMath::ATan( kRDET / sanddetcomp)))/2.0;
1919 wgt_xy = sangdet * ( emrat * emrat );
1921 #ifdef GNUMI_TEST_XY_WGT 1922 gpartials.sangdet = sangdet;
1923 gpartials.wgt = wgt_xy;
1924 gpartials.ptype = this->
ptype;
1930 if ( this->
ptype == kpdg_muplus || this->
ptype == kpdg_muminus) {
1931 double beta[3], p_dcm_nu[4], p_nu[3], p_pcm_mp[3], partial;
1934 beta[0] = this->
pdpx / parent_energy;
1935 beta[1] = this->
pdpy / parent_energy;
1936 beta[2] = this->
pdpz / parent_energy;
1937 p_nu[0] = (xpos-this->
vx)*enu/rad;
1938 p_nu[1] = (ypos-this->
vy)*enu/rad;
1939 p_nu[2] = (zpos-this->
vz)*enu/rad;
1941 (beta[0]*p_nu[0] + beta[1]*p_nu[1] + beta[2]*p_nu[2] );
1942 partial = enu - partial/(gamma+1.0);
1947 p_dcm_nu[0] = p_nu[0] - beta[0]*gamma*partial;
1948 p_dcm_nu[1] = p_nu[1] - beta[1]*gamma*partial;
1949 p_dcm_nu[2] = p_nu[2] - beta[2]*gamma*partial;
1950 p_dcm_nu[3] = TMath::Sqrt( p_dcm_nu[0]*p_dcm_nu[0] +
1951 p_dcm_nu[1]*p_dcm_nu[1] +
1952 p_dcm_nu[2]*p_dcm_nu[2] );
1954 #ifdef GNUMI_TEST_XY_WGT 1955 gpartials.betanu[0] = beta[0];
1956 gpartials.betanu[1] = beta[1];
1957 gpartials.betanu[2] = beta[2];
1958 gpartials.p_nu[0] = p_nu[0];
1959 gpartials.p_nu[1] = p_nu[1];
1960 gpartials.p_nu[2] = p_nu[2];
1961 gpartials.partial1 = partial;
1962 gpartials.p_dcm_nu[0] = p_dcm_nu[0];
1963 gpartials.p_dcm_nu[1] = p_dcm_nu[1];
1964 gpartials.p_dcm_nu[2] = p_dcm_nu[2];
1965 gpartials.p_dcm_nu[3] = p_dcm_nu[3];
1969 double particle_energy = this->
ppenergy;
1970 gamma = particle_energy/parent_mass;
1971 beta[0] = this->
ppdxdz * this->
pppz / particle_energy;
1972 beta[1] = this->
ppdydz * this->
pppz / particle_energy;
1973 beta[2] = this->
pppz / particle_energy;
1974 partial = gamma * ( beta[0]*this->
muparpx +
1977 partial = this->
mupare - partial/(gamma+1.0);
1978 p_pcm_mp[0] = this->
muparpx - beta[0]*gamma*partial;
1979 p_pcm_mp[1] = this->
muparpy - beta[1]*gamma*partial;
1980 p_pcm_mp[2] = this->
muparpz - beta[2]*gamma*partial;
1981 double p_pcm = TMath::Sqrt ( p_pcm_mp[0]*p_pcm_mp[0] +
1982 p_pcm_mp[1]*p_pcm_mp[1] +
1983 p_pcm_mp[2]*p_pcm_mp[2] );
1992 #ifdef GNUMI_TEST_XY_WGT 1993 gpartials.muparent_px = this->
muparpx;
1994 gpartials.muparent_py = this->
muparpy;
1995 gpartials.muparent_pz = this->
muparpz;
1996 gpartials.gammamp =
gamma;
1997 gpartials.betamp[0] = beta[0];
1998 gpartials.betamp[1] = beta[1];
1999 gpartials.betamp[2] = beta[2];
2000 gpartials.partial2 = partial;
2001 gpartials.p_pcm_mp[0] = p_pcm_mp[0];
2002 gpartials.p_pcm_mp[1] = p_pcm_mp[1];
2003 gpartials.p_pcm_mp[2] = p_pcm_mp[2];
2004 gpartials.p_pcm = p_pcm;
2007 const double eps = 1.0e-30;
2008 if ( p_pcm < eps || p_dcm_nu[3] < eps ) {
2012 double costh = ( p_dcm_nu[0]*p_pcm_mp[0] +
2013 p_dcm_nu[1]*p_pcm_mp[1] +
2014 p_dcm_nu[2]*p_pcm_mp[2] ) /
2015 ( p_dcm_nu[3]*p_pcm );
2016 if ( costh > 1.0 ) costh = 1.0;
2017 if ( costh < -1.0 ) costh = -1.0;
2019 double wgt_ratio = 0.0;
2020 switch ( this->
ntype ) {
2023 wgt_ratio = 1.0 - costh;
2028 double xnu = 2.0 * enuzr / kMUMASS;
2029 wgt_ratio = ( (3.0-2.0*xnu ) - (1.0-2.0*xnu)*costh ) / (3.0-2.0*xnu);
2035 wgt_xy = wgt_xy * wgt_ratio;
2037 #ifdef GNUMI_TEST_XY_WGT 2038 gpartials.ntype = this->
ntype;
2039 gpartials.costhmu = costh;
2040 gpartials.wgt_ratio = wgt_ratio;
2057 stream <<
"\nGNuMIFlux run " << info.
run <<
" evtno " << info.
evtno 2058 <<
" (pcodes " << info.
pcodes <<
" units " << info.
units <<
")" 2059 <<
"\n random dk: dx/dz " << info.
ndxdz 2060 <<
" dy/dz " << info.
ndydz 2061 <<
" pz " << info.
npz <<
" E " << info.
nenergy 2062 <<
"\n near00 dk: dx/dz " << info.
ndxdznea 2065 <<
"\n far00 dk: dx/dz " << info.
ndxdzfar 2068 <<
"\n norig " << info.
norig <<
" ndecay " << info.
ndecay 2069 <<
" ntype " << info.
ntype 2070 <<
"\n had vtx " << info.
vx <<
" " << info.
vy <<
" " << info.
vz 2071 <<
"\n parent p3 @ dk " << info.
pdpx <<
" " << info.
pdpy <<
" " << info.
pdpz 2072 <<
"\n parent prod: dx/dz " << info.
ppdxdz 2073 <<
" dy/dz " << info.
ppdydz 2075 <<
"\n ppmedium " << info.
ppmedium <<
" ptype " << info.
ptype 2076 <<
" ppvtx " << info.
ppvx <<
" " << info.
ppvy <<
" " << info.
ppvz 2079 <<
"\n necm " << info.
necm <<
" nimpwt " << info.
nimpwt 2080 <<
"\n point x,y,z " << info.
xpoint <<
" " << info.
ypoint 2082 <<
"\n tv x,y,z " << info.
tvx <<
" " << info.
tvy <<
" " << info.
tvz 2083 <<
"\n tptype " << info.
tptype <<
" tgen " << info.
tgen 2084 <<
" tgptype " << info.
tgptype 2085 <<
"\n tgp px,py,pz " << info.
tgppx <<
" " << info.
tgppy 2086 <<
" " << info.
tgppz 2087 <<
"\n tpriv x,y,z " << info.
tprivx <<
" " << info.
tprivy 2089 <<
"\n beam x,y,z " << info.
beamx <<
" " << info.
beamy 2090 <<
" " << info.
beamz 2091 <<
"\n beam px,py,pz " << info.
beampx <<
" " << info.
beampy 2095 #ifndef SKIP_MINERVA_MODS 2099 stream <<
"\nNeutrino History : ntrajectories " << info.
ntrajectory 2100 <<
"\n (trkID, pdg) of nu parents: [";
2104 for ( Int_t itt = 0; itt < ntraj; ++itt )
2105 stream <<
"(" << info.
trackId[itt-1] <<
", " << info.
pdgcode[itt] <<
") ";
2110 stream <<
"\nCurrent: pdg " << info.
fgPdgC 2117 #ifdef GNUMI_TEST_XY_WGT 2118 stream <<
"\n" << xypartials::GetStaticInstance();
2149 #ifdef GNUMI_TEST_XY_WGT 2151 double fabserr(
double a,
double b)
2152 {
return TMath::Abs(a-b)/TMath::Max(TMath::Abs(b),1.0
e-30); }
2154 int outdiff(
double a,
double b,
double eps,
const char*
label)
2156 double err = fabserr(a,b);
2158 std::cout <<
std::setw(15) << label <<
" err " << err
2159 <<
" vals " << a <<
" " << b <<
std::endl;
2165 int gnumi2pdg(
int igeant)
2168 case 52:
return -12;
2170 case 55:
return -14;
2172 case 58:
return -16;
2179 void xypartials::ReadStream(std::ifstream& myfile)
2181 myfile >> parent_mass >> parentp >> parent_energy;
2182 myfile >>
gamma >> beta_mag >> enuzr >>
rad;
2183 myfile >> costh_pardet >> theta_pardet >> emrat >> eneu;
2184 myfile >> sangdet >> wgt;
2187 ptype = gnumi2pdg(ptype_g);
2190 myfile >> betanu[0] >> betanu[1] >> betanu[2]
2191 >> p_nu[0] >> p_nu[1] >> p_nu[2];
2193 >> p_dcm_nu[0] >> p_dcm_nu[1] >> p_dcm_nu[2] >> p_dcm_nu[3];
2195 myfile >> muparent_px >> muparent_py >> muparent_pz;
2196 myfile >> gammamp >> betamp[0] >> betamp[1] >> betamp[2];
2198 >> p_pcm_mp[0] >> p_pcm_mp[1] >> p_pcm_mp[2] >> p_pcm;
2200 if ( p_pcm != 0.0 && p_dcm_nu[3] != 0.0 ) {
2202 myfile >> costhmu >> ntype_g >> wgt_ratio;
2203 ntype = gnumi2pdg(ntype_g);
2208 int xypartials::Compare(
const xypartials&
other)
const 2210 double eps1 = 2.5e-5;
2211 double eps2 = 2.5e-5;
2212 double epsX = 2.5e-5;
2214 np += outdiff(parent_mass ,other.parent_mass ,eps1,
"parent_mass");
2215 np += outdiff(parentp ,other.parentp ,eps1,
"parentp");
2216 np += outdiff(parent_energy,other.parent_energy,eps1,
"parent_energy");
2217 np += outdiff(
gamma ,other.gamma ,eps1,
"gamma");
2218 np += outdiff(beta_mag ,other.beta_mag ,eps1,
"beta_mag");
2219 np += outdiff(enuzr ,other.enuzr ,eps1,
"enuzr");
2220 np += outdiff(
rad ,other.rad ,eps1,
"rad");
2221 np += outdiff(costh_pardet ,other.costh_pardet ,eps1,
"costh_pardet");
2223 np += outdiff(emrat ,other.emrat ,eps1,
"emrat");
2224 np += outdiff(eneu ,other.eneu ,epsX,
"eneu");
2225 np += outdiff(sangdet ,other.sangdet ,eps1,
"sangdet");
2226 np += outdiff(wgt ,other.wgt ,epsX,
"wgt");
2227 if (
ptype != other.ptype ) {
2228 std::cout <<
"ptype mismatch " <<
ptype <<
" " << other.ptype <<
std::endl;
2231 if ( TMath::Abs(
ptype)==13 || TMath::Abs(other.ptype)==13 ) {
2233 np += outdiff(betanu[0] ,other.betanu[0] ,eps2,
"betanu[0]");
2234 np += outdiff(betanu[1] ,other.betanu[1] ,eps2,
"betanu[1]");
2235 np += outdiff(betanu[2] ,other.betanu[2] ,eps2,
"betanu[2]");
2236 np += outdiff(p_nu[0] ,other.p_nu[0] ,eps2,
"p_nu[0]");
2237 np += outdiff(p_nu[1] ,other.p_nu[1] ,eps2,
"p_nu[1]");
2238 np += outdiff(p_nu[2] ,other.p_nu[2] ,eps2,
"p_nu[2]");
2239 np += outdiff(partial1 ,other.partial1 ,eps2,
"partial1");
2240 np += outdiff(p_dcm_nu[0] ,other.p_dcm_nu[0] ,eps2,
"p_dcm_nu[0]");
2241 np += outdiff(p_dcm_nu[1] ,other.p_dcm_nu[1] ,eps2,
"p_dcm_nu[1]");
2242 np += outdiff(p_dcm_nu[2] ,other.p_dcm_nu[2] ,eps2,
"p_dcm_nu[2]");
2243 np += outdiff(p_dcm_nu[3] ,other.p_dcm_nu[3] ,eps2,
"p_dcm_nu[3]");
2245 np += outdiff(muparent_px ,other.muparent_px ,eps2,
"muparent_px");
2246 np += outdiff(muparent_py ,other.muparent_py ,eps2,
"muparent_py");
2247 np += outdiff(muparent_pz ,other.muparent_pz ,eps2,
"muparent_pz");
2248 np += outdiff(gammamp ,other.gammamp ,eps1,
"gammamp");
2249 np += outdiff(betamp[0] ,other.betamp[0] ,eps1,
"betamp[0]");
2250 np += outdiff(betamp[1] ,other.betamp[1] ,eps1,
"betamp[1]");
2251 np += outdiff(betamp[2] ,other.betamp[2] ,eps1,
"betamp[2]");
2252 np += outdiff(partial2 ,other.partial2 ,eps1,
"partial2");
2253 np += outdiff(p_pcm_mp[0] ,other.p_pcm_mp[0] ,eps1,
"p_pcm_mp[0]");
2254 np += outdiff(p_pcm_mp[1] ,other.p_pcm_mp[1] ,eps1,
"p_pcm_mp[1]");
2255 np += outdiff(p_pcm_mp[2] ,other.p_pcm_mp[2] ,eps1,
"p_pcm_mp[2]");
2256 np += outdiff(p_pcm ,other.p_pcm ,eps1,
"p_pcm");
2258 if (
ntype != other.ntype ) {
2259 std::cout <<
"ntype mismatch " <<
ntype <<
" " << other.ntype <<
std::endl;
2262 np += outdiff(costhmu ,other.costhmu ,eps1,
"costhmu");
2263 np += outdiff(wgt_ratio ,other.wgt_ratio ,eps1,
"wgt_ratio");
2269 void xypartials::Print(
const Option_t* )
const 2278 stream <<
"GNuMIFlux xypartials " <<
std::endl;
2279 stream <<
" xyzdet (" << xyp.xdet <<
"," << xyp.ydet <<
"," 2281 stream <<
" parent: mass=" << xyp.parent_mass <<
" p=" << xyp.parentp
2282 <<
" e=" << xyp.parent_energy <<
" gamma=" << xyp.gamma
2283 <<
" beta_mag=" << xyp.beta_mag <<
std::endl;
2284 stream <<
" enuzr=" << xyp.enuzr <<
" rad=" << xyp.rad
2285 <<
" costh_pardet=" << xyp.costh_pardet <<
std::endl;
2286 stream <<
" emrat=" << xyp.emrat <<
" sangdet=" << xyp.sangdet
2288 stream <<
" ptype=" << xyp.ptype <<
" " 2289 << ((TMath::Abs(xyp.ptype) == 13)?
"is-muon":
"not-muon")
2292 if ( TMath::Abs(xyp.ptype)==13 ) {
2293 stream <<
" betanu: [" << xyp.betanu[0] <<
"," << xyp.betanu[1]
2294 <<
"," << xyp.betanu[2] <<
"]" <<
std::endl;
2295 stream <<
" p_nu: [" << xyp.p_nu[0] <<
"," << xyp.p_nu[1]
2296 <<
"," << xyp.p_nu[2] <<
"]" <<
std::endl;
2297 stream <<
" partial1=" << xyp.partial1 <<
std::endl;
2298 stream <<
" p_dcm_nu: [" << xyp.p_dcm_nu[0] <<
"," << xyp.p_dcm_nu[1]
2299 <<
"," << xyp.p_dcm_nu[2]
2300 <<
"," << xyp.p_dcm_nu[3] <<
"]" <<
std::endl;
2301 stream <<
" muparent_p: [" << xyp.muparent_px <<
"," << xyp.muparent_py
2302 <<
"," << xyp.muparent_pz <<
"]" <<
std::endl;
2303 stream <<
" gammamp=" << xyp.gammamp <<
std::endl;
2304 stream <<
" betamp: [" << xyp.betamp[0] <<
"," << xyp.betamp[1] <<
"," 2306 stream <<
" partial2=" << xyp.partial2 <<
std::endl;
2307 stream <<
" p_pcm_mp: [" << xyp.p_pcm_mp[0] <<
"," << xyp.p_pcm_mp[1]
2308 <<
"," << xyp.p_pcm_mp[2] <<
"] p_pcm=" 2310 stream <<
" ntype=" << xyp.ntype
2311 <<
" costhmu=" << xyp.costhmu
2312 <<
" wgt_ratio=" << xyp.wgt_ratio <<
std::endl;
2319 xypartials& xypartials::GetStaticInstance()
2320 {
return gpartials; }
2326 const char* altxml = gSystem->Getenv(
"GNUMIFLUXXML");
2328 SetXMLFileBase(altxml);
2339 std::ostringstream
s;
2341 for ( ; itr != fPdgCList->end(); ++itr) s << (*itr) <<
" ";
2343 itr = fPdgCListRej->begin();
2344 for ( ; itr != fPdgCListRej->end(); ++itr) s << (*itr) <<
" ";
2347 std::ostringstream fpattout;
2348 for (
size_t i = 0; i < fNuFluxFilePatterns.size(); ++i)
2349 fpattout <<
"\n [" <<
std::setw(3) << i <<
"] " << fNuFluxFilePatterns[i];
2351 std::ostringstream flistout;
2352 std::vector<std::string>
flist = GetFileList();
2353 for (
size_t i = 0; i < flist.size(); ++i)
2354 flistout <<
"\n [" <<
std::setw(3) << i <<
"] " << flist[i];
2356 TLorentzVector usr0(0,0,0,0);
2357 TLorentzVector usr0asbeam;
2358 User2BeamPos(usr0,usr0asbeam);
2360 const int w=10,
p=6;
2361 std::ostringstream beamrot_str, beamrotinv_str;
2367 <<
std::setw(w) << fBeamRot.XZ() <<
" ]\n" 2371 <<
std::setw(w) << fBeamRot.YZ() <<
" ]\n" 2375 <<
std::setw(w) << fBeamRot.ZZ() <<
" ]";
2379 <<
std::setw(w) << fBeamRotInv.XX() <<
" " 2380 <<
std::setw(w) << fBeamRotInv.XY() <<
" " 2381 <<
std::setw(w) << fBeamRotInv.XZ() <<
" ]\n" 2383 <<
std::setw(w) << fBeamRotInv.YX() <<
" " 2384 <<
std::setw(w) << fBeamRotInv.YY() <<
" " 2385 <<
std::setw(w) << fBeamRotInv.YZ() <<
" ]\n" 2387 <<
std::setw(w) << fBeamRotInv.ZX() <<
" " 2388 <<
std::setw(w) << fBeamRotInv.ZY() <<
" " 2389 <<
std::setw(w) << fBeamRotInv.ZZ() <<
" ]";
2392 <<
"GNuMIFlux Config:" 2393 <<
"\n Enu_max " << fMaxEv
2394 <<
"\n pdg-codes: " << s.str() <<
"\n " 2395 << (fG3NuMI?
"g3numi":
"")
2396 << (fG4NuMI?
"g4numi":
"")
2397 << (fFlugg?
"flugg":
"")
2398 <<
"/" << fNuFluxGen <<
" " 2399 <<
"(" << fNuFluxTreeName <<
"), " << fNEntries <<
" entries" 2400 <<
" (FilePOTs " << fFilePOTs <<
") " 2401 <<
"in " << fNFiles <<
" files: " 2403 <<
"\n from file patterns:" 2405 <<
"\n wgt max=" << fMaxWeight <<
" fudge=" << fMaxWgtFudge <<
" using " 2406 << fMaxWgtEntries <<
" entries" 2407 <<
"\n Z0 pushback " << fZ0
2408 <<
"\n used entry " << fIEntry <<
" " << fIUse <<
"/" << fNUse
2409 <<
" times, in " << fICycle <<
"/" << fNCycles <<
" cycles" 2410 <<
"\n SumWeight " << fSumWeight <<
" for " << fNNeutrinos <<
" neutrinos" 2411 <<
"\n EffPOTsPerNu " << fEffPOTsPerNu <<
" AccumPOTs " << fAccumPOTs
2412 <<
"\n GenWeighted \"" << (fGenWeighted?
"true":
"false") <<
", " 2413 <<
"\", Detector location set \"" << (fDetLocIsSet?
"true":
"false") <<
"\"" 2414 <<
"\n LengthUnits " << fLengthUnits <<
", scale b2u " << fLengthScaleB2U
2415 <<
", scale u2b " << fLengthScaleU2B
2416 <<
"\n User Flux Window: " 2420 <<
"\n Flux Window (cm, beam coord): " 2425 <<
"\n User Beam Origin: " 2427 <<
"\n " << beamrot_str.str() <<
" " 2428 <<
"\n Detector Origin (beam coord): " 2430 <<
"\n " << beamrotinv_str.str() <<
" " 2431 <<
"\n UseFluxAtDetCenter " << fUseFluxAtDetCenter;
2438 std::vector<std::string>
flist;
2439 TObjArray *fileElements=fNuFluxTree->GetListOfFiles();
2440 TIter next(fileElements);
2441 TChainElement *chEl=0;
2442 while (( chEl=(TChainElement*)next() )) {
2443 flist.push_back(chEl->GetTitle());
2455 std::vector<double> vect;
2456 size_t ntok = strtokens.size();
2459 std::cout <<
"GetDoubleVector \"" << str <<
"\"" <<
std::endl;
2461 for (
size_t i=0; i < ntok; ++i) {
2463 if (
" " == trimmed ||
"" == trimmed )
continue;
2464 double val = strtod(trimmed.c_str(), (
char**)NULL);
2466 std::cout <<
"(" << vect.size() <<
") = " << val <<
std::endl;
2467 vect.push_back(val);
2478 std::vector<long int> vect;
2479 size_t ntok = strtokens.size();
2482 std::cout <<
"GetIntVector \"" << str <<
"\"" <<
std::endl;
2484 for (
size_t i=0; i < ntok; ++i) {
2486 if (
" " == trimmed ||
"" == trimmed )
continue;
2487 long int val = strtol(trimmed.c_str(),(
char**)NULL,10);
2489 std::cout <<
"(" << vect.size() <<
") = " << val <<
std::endl;
2490 vect.push_back(val);
2500 bool is_accessible = ! (gSystem->AccessPathName(fname.c_str()));
2501 if (!is_accessible) {
2503 <<
"The XML doc doesn't exist! (filename: " << fname <<
")";
2507 xmlDocPtr xml_doc = xmlParseFile( fname.c_str() );
2508 if ( xml_doc == NULL) {
2510 <<
"The XML doc can't be parsed! (filename: " << fname <<
")";
2514 xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2515 if ( xml_root == NULL ) {
2517 <<
"The XML doc is empty! (filename: " << fname <<
")";
2521 string rootele =
"gnumi_config";
2522 if ( xmlStrcmp(xml_root->name, (
const xmlChar*)rootele.c_str() ) ) {
2524 <<
"The XML doc has invalid root element! (filename: " << fname <<
")" 2525 <<
" expected \"" << rootele <<
"\", saw \"" << xml_root->name <<
"\"";
2529 SLOG(
"GNuMIFlux",
pINFO) <<
"Attempt to load config \"" << cfg
2530 <<
"\" from file: " <<
fname;
2532 bool found = this->LoadParamSet(xml_doc,cfg);
2542 xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2549 xmlNodePtr xml_pset = xml_root->xmlChildrenNode;
2550 for ( ; xml_pset != NULL ; xml_pset = xml_pset->next ) {
2551 if ( ! xmlStrEqual(xml_pset->name, (
const xmlChar*)
"param_set") )
continue;
2553 string param_set_name =
2556 if ( param_set_name != cfg )
continue;
2558 SLOG(
"GNuMIFlux",
pINFO) <<
"Found config \"" << cfg;
2560 this->ParseParamSet(xml_doc,xml_pset);
2571 xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2572 for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2577 if ( pname ==
"text" || pname ==
"comment" )
continue;
2580 xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2584 <<
" pname \"" << pname <<
"\", string value \"" << pval <<
"\"";
2586 if ( pname ==
"verbose" ) {
2587 fVerbose = atoi(pval.c_str());
2589 }
else if ( pname ==
"using_param_set" ) {
2590 SLOG(
"GNuMIFlux",
pWARN) <<
"start using_param_set: \"" << pval <<
"\"";
2591 bool found = this->LoadParamSet(xml_doc,pval);
2593 SLOG(
"GNuMIFlux",
pFATAL) <<
"using_param_set: \"" << pval <<
"\" NOT FOUND";
2596 SLOG(
"GNuMIFlux",
pWARN) <<
"done using_param_set: \"" << pval <<
"\"";
2597 }
else if ( pname ==
"units" ) {
2599 fGNuMI->SetLengthUnits(scale);
2600 SLOG(
"GNuMIFlux",
pINFO) <<
"set user units to \"" << pval <<
"\"";
2602 }
else if ( pname ==
"beamdir" ) {
2603 ParseBeamDir(xml_doc,xml_child);
2604 fGNuMI->SetBeamRotation(fBeamRotXML);
2606 }
else if ( pname ==
"beampos" ) {
2608 fGNuMI->SetBeamCenter(fBeamPosXML);
2610 }
else if ( pname ==
"window" ) {
2611 ParseWindowSeries(xml_doc,xml_child);
2618 fGNuMI->SetFluxWindow(fFluxWindowPtXML[0],
2619 fFluxWindowPtXML[1],
2620 fFluxWindowPtXML[2]);
2622 }
else if ( pname ==
"enumax" ) {
2625 }
else if ( pname ==
"upstreamz" ) {
2626 double z0usr = -3.4e38;
2627 std::vector<double> v = GetDoubleVector(pval);
2628 if ( v.size() > 0 ) z0usr = v[0];
2629 fGNuMI->SetUpstreamZ(z0usr);
2630 SLOG(
"GNuMIFlux",
pINFO) <<
"set upstreamz = " << z0usr;
2632 }
else if ( pname ==
"reuse" ) {
2633 long int nreuse = 1;
2634 std::vector<long int> v = GetIntVector(pval);
2635 if ( v.size() > 0 ) nreuse = v[0];
2636 fGNuMI->SetEntryReuse(nreuse);
2637 SLOG(
"GNuMIFlux",
pINFO) <<
"set entry reuse = " << nreuse;
2641 <<
" NOT HANDLED: pname \"" << pname
2642 <<
"\", string value \"" << pval <<
"\"";
2652 fBeamRotXML.SetToIdentity();
2660 xmlNodeListGetString(xml_doc, xml_beamdir->xmlChildrenNode, 1));
2662 if ( dirtype ==
"series" ) {
2664 ParseRotSeries(xml_doc,xml_beamdir);
2666 }
else if ( dirtype ==
"thetaphi3") {
2668 std::vector<double> thetaphi3 = GetDoubleVector(pval);
2671 if ( thetaphi3.size() == 6 ) {
2673 TVector3 newX = AnglesToAxis(thetaphi3[0],thetaphi3[1],units);
2674 TVector3 newY = AnglesToAxis(thetaphi3[2],thetaphi3[3],units);
2675 TVector3 newZ = AnglesToAxis(thetaphi3[4],thetaphi3[5],units);
2676 fTempRot.RotateAxes(newX,newY,newZ);
2677 fBeamRotXML = fTempRot;
2680 <<
" type=\"" << dirtype <<
"\" within <beamdir> needs 6 values";
2683 }
else if ( dirtype ==
"newxyz" ) {
2685 std::vector<double> newdir = GetDoubleVector(pval);
2686 if ( newdir.size() == 9 ) {
2688 TVector3 newX = TVector3(newdir[0],newdir[1],newdir[2]).Unit();
2689 TVector3 newY = TVector3(newdir[3],newdir[4],newdir[5]).Unit();
2690 TVector3 newZ = TVector3(newdir[6],newdir[7],newdir[8]).Unit();
2691 fTempRot.RotateAxes(newX,newY,newZ);
2692 fBeamRotXML = fTempRot.Inverse();
2695 <<
" type=\"" << dirtype <<
"\" within <beamdir> needs 9 values";
2701 <<
" UNHANDLED type=\"" << dirtype <<
"\" within <beamdir>";
2704 if ( fVerbose > 1 ) {
2708 <<
std::setw(w) << fBeamRotXML.XX() <<
" " 2709 <<
std::setw(w) << fBeamRotXML.XY() <<
" " 2712 <<
std::setw(w) << fBeamRotXML.YX() <<
" " 2713 <<
std::setw(w) << fBeamRotXML.YY() <<
" " 2716 <<
std::setw(w) << fBeamRotXML.ZX() <<
" " 2717 <<
std::setw(w) << fBeamRotXML.ZY() <<
" " 2726 std::vector<double> xyz = GetDoubleVector(str);
2727 if ( xyz.size() == 3 ) {
2728 fBeamPosXML = TVector3(xyz[0],xyz[1],xyz[2]);
2729 }
else if ( xyz.size() == 6 ) {
2732 TVector3 userpos(xyz[0],xyz[1],xyz[2]);
2733 TVector3 beampos(xyz[3],xyz[4],xyz[5]);
2734 fBeamPosXML = userpos - fBeamRotXML*beampos;
2737 <<
"Unable to parse " << xyz.size() <<
" values in <beampos>";
2740 if ( fVerbose > 1 ) {
2743 <<
std::setw(w) << fBeamPosXML.X() <<
" , " 2744 <<
std::setw(w) << fBeamPosXML.Y() <<
" , " 2745 <<
std::setw(w) << fBeamPosXML.Z() <<
" ] " 2752 std::vector<double> v = GetDoubleVector(str);
2753 size_t n = v.size();
2755 fGNuMI->SetMaxEnergy(v[0]);
2757 std::cout <<
"ParseEnuMax SetMaxEnergy(" << v[0] <<
") " <<
std::endl;
2760 fGNuMI->SetMaxEFudge(v[1]);
2762 std::cout <<
"ParseEnuMax SetMaxEFudge(" << v[1] <<
")" <<
std::endl;
2766 fGNuMI->SetMaxWgtScan(v[2]);
2768 std::cout <<
"ParseEnuMax SetMaxWgtScan(" << v[2] <<
")" <<
std::endl;
2771 fGNuMI->SetMaxWgtScan(v[2],nentries);
2773 std::cout <<
"ParseEnuMax SetMaxWgtScan(" << v[2] <<
"," << nentries <<
")" <<
std::endl;
2782 xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2783 for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2788 if ( name ==
"text" || name ==
"comment" )
continue;
2790 if ( name ==
"rotation" ) {
2792 xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2799 double rot = atof(val.c_str());
2801 if (
'd' == units[0] ||
'D' == units[0] ) rot *= TMath::DegToRad();
2805 <<
" rotate " << rot <<
" radians around " << axis <<
" axis";
2807 if ( axis[0] ==
'x' || axis[0] ==
'X' ) fTempRot.RotateX(rot);
2808 else if ( axis[0] ==
'y' || axis[0] ==
'Y' ) fTempRot.RotateY(rot);
2809 else if ( axis[0] ==
'z' || axis[0] ==
'Z' ) fTempRot.RotateZ(rot);
2812 <<
" no " << axis <<
" to rotate around";
2817 <<
" found <" << name <<
"> within <beamdir type=\"series\">";
2821 fBeamRotXML = fTempRot.Inverse();
2829 xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2830 for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2835 if ( name ==
"text" || name ==
"comment" )
continue;
2837 if ( name ==
"point" ) {
2840 xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2844 std::vector<double> xyz = GetDoubleVector(val);
2845 if ( xyz.size() != 3 || coord !=
"det" ) {
2847 <<
"parsing <window> found <point> but size=" << xyz.size()
2848 <<
" (expect 3) and coord=\"" << coord <<
"\" (expect \"det\")" 2849 <<
" IGNORE problem";
2852 if ( ientry < 3 && ientry >= 0 ) {
2853 TVector3 pt(xyz[0],xyz[1],xyz[2]);
2854 if ( fVerbose > 0 ) {
2862 fFluxWindowPtXML[ientry] = pt;
2865 <<
" <window><point> ientry " << ientry <<
" out of range (0-2)";
2870 <<
" found <" << name <<
"> within <window>";
2880 double scale = (
'd'==units[0]||
'D'==units[0]) ? TMath::DegToRad() : 1.0 ;
2882 xyz[0] = TMath::Cos(scale*phi)*TMath::Sin(scale*theta);
2883 xyz[1] = TMath::Sin(scale*phi)*TMath::Sin(scale*theta);
2884 xyz[2] = TMath::Cos(scale*theta);
2886 for (
int i=0; i<3; ++i) {
2887 const double eps = 1.0e-15;
2888 if (TMath::Abs(xyz[i]) < eps ) xyz[i] = 0;
2889 if (TMath::Abs(xyz[i]-1) < eps ) xyz[i] = 1;
2890 if (TMath::Abs(xyz[i]+1) < eps ) xyz[i] = -1;
2892 return TVector3(xyz[0],xyz[1],xyz[2]);
2897 std::vector<double> xyz = GetDoubleVector(str);
2898 if ( xyz.size() != 3 ) {
2901 <<
" ParseTV3 \"" << str <<
"\" had " << xyz.size() <<
" elements ";
2903 return TVector3(xyz[0],xyz[1],xyz[2]);
2908 #ifndef SKIP_MINERVA_MODS 2914 if(sval==
"AddedLV")ival=1;
2915 else if(sval==
"AlTube1LV")ival=2;
2916 else if(sval==
"AlTube2LV")ival=3;
2917 else if(sval==
"Al_BLK1")ival=4;
2918 else if(sval==
"Al_BLK2")ival=5;
2919 else if(sval==
"Al_BLK3")ival=6;
2920 else if(sval==
"Al_BLK4")ival=7;
2921 else if(sval==
"Al_BLK5")ival=8;
2922 else if(sval==
"Al_BLK6")ival=9;
2923 else if(sval==
"Al_BLK7")ival=10;
2924 else if(sval==
"Al_BLK8")ival=11;
2925 else if(sval==
"AlholeL")ival=12;
2926 else if(sval==
"AlholeR")ival=13;
2927 else if(sval==
"BEndLV")ival=14;
2928 else if(sval==
"BFrontLV")ival=15;
2929 else if(sval==
"BeDWLV")ival=16;
2930 else if(sval==
"BeUp1LV")ival=17;
2931 else if(sval==
"BeUp2LV")ival=18;
2932 else if(sval==
"BeUp3LV")ival=19;
2933 else if(sval==
"BodyLV")ival=20;
2934 else if(sval==
"BudalMonitor")ival=21;
2935 else if(sval==
"CLid1LV")ival=22;
2936 else if(sval==
"CLid2LV")ival=23;
2937 else if(sval==
"CShld_BLK11")ival=24;
2938 else if(sval==
"CShld_BLK12")ival=25;
2939 else if(sval==
"CShld_BLK2")ival=26;
2940 else if(sval==
"CShld_BLK3")ival=27;
2941 else if(sval==
"CShld_BLK4")ival=28;
2942 else if(sval==
"CShld_BLK7")ival=29;
2943 else if(sval==
"CShld_BLK8")ival=30;
2944 else if(sval==
"CShld_stl,BLK")ival=31;
2945 else if(sval==
"CerTubeLV")ival=32;
2946 else if(sval==
"CeramicRod")ival=33;
2947 else if(sval==
"ConcShield")ival=34;
2948 else if(sval==
"Concrete Chase Section")ival=35;
2949 else if(sval==
"Conn1LV")ival=36;
2950 else if(sval==
"Conn2LV")ival=37;
2951 else if(sval==
"Conn3LV")ival=38;
2952 else if(sval==
"DNWN")ival=39;
2953 else if(sval==
"DPIP")ival=40;
2954 else if(sval==
"DVOL")ival=41;
2955 else if(sval==
"DuratekBlock")ival=42;
2956 else if(sval==
"DuratekBlockCovering")ival=43;
2957 else if(sval==
"HadCell")ival=44;
2958 else if(sval==
"HadronAbsorber")ival=45;
2959 else if(sval==
"MuMonAlcvFill_0")ival=46;
2960 else if(sval==
"MuMonAlcv_0")ival=47;
2961 else if(sval==
"MuMonAlcv_1")ival=48;
2962 else if(sval==
"MuMonAlcv_2")ival=49;
2963 else if(sval==
"MuMon_0")ival=50;
2964 else if(sval==
"MuMon_1")ival=51;
2965 else if(sval==
"MuMon_2")ival=52;
2966 else if(sval==
"PHorn1CPB1slv")ival=53;
2967 else if(sval==
"PHorn1CPB2slv")ival=54;
2968 else if(sval==
"PHorn1F")ival=55;
2969 else if(sval==
"PHorn1Front")ival=56;
2970 else if(sval==
"PHorn1IC")ival=57;
2971 else if(sval==
"PHorn1InsRingslv")ival=58;
2972 else if(sval==
"PHorn1OC")ival=59;
2973 else if(sval==
"PHorn2CPB1slv")ival=60;
2974 else if(sval==
"PHorn2CPB2slv")ival=61;
2975 else if(sval==
"PHorn2F")ival=62;
2976 else if(sval==
"PHorn2Front")ival=63;
2977 else if(sval==
"PHorn2IC")ival=64;
2978 else if(sval==
"PHorn2InsRingslv")ival=65;
2979 else if(sval==
"PHorn2OC")ival=66;
2980 else if(sval==
"PVHadMon")ival=67;
2981 else if(sval==
"Pipe1")ival=68;
2982 else if(sval==
"Pipe1_water")ival=69;
2983 else if(sval==
"Pipe2")ival=70;
2984 else if(sval==
"Pipe2_water")ival=71;
2985 else if(sval==
"Pipe3")ival=72;
2986 else if(sval==
"Pipe3_water")ival=73;
2987 else if(sval==
"Pipe4")ival=74;
2988 else if(sval==
"Pipe4_water")ival=75;
2989 else if(sval==
"Pipe5")ival=76;
2990 else if(sval==
"Pipe5_water")ival=77;
2991 else if(sval==
"Pipe6")ival=78;
2992 else if(sval==
"Pipe6_water")ival=79;
2993 else if(sval==
"Pipe7")ival=80;
2994 else if(sval==
"Pipe8")ival=81;
2995 else if(sval==
"Pipe8_water")ival=82;
2996 else if(sval==
"Pipe9")ival=83;
2997 else if(sval==
"PipeAdapter1")ival=84;
2998 else if(sval==
"PipeAdapter1_water")ival=85;
2999 else if(sval==
"PipeAdapter2")ival=86;
3000 else if(sval==
"PipeAdapter2_water")ival=87;
3001 else if(sval==
"PipeBellowB")ival=88;
3002 else if(sval==
"PipeBellowB_water")ival=89;
3003 else if(sval==
"PipeBellowT")ival=90;
3004 else if(sval==
"PipeBellowT_water")ival=91;
3005 else if(sval==
"PipeC1")ival=92;
3006 else if(sval==
"PipeC1_water")ival=93;
3007 else if(sval==
"PipeC2")ival=94;
3008 else if(sval==
"PipeC2_water")ival=95;
3009 else if(sval==
"ROCK")ival=96;
3010 else if(sval==
"Ring1LV")ival=97;
3011 else if(sval==
"Ring2LV")ival=98;
3012 else if(sval==
"Ring3LV")ival=99;
3013 else if(sval==
"Ring4LV")ival=100;
3014 else if(sval==
"Ring5LV")ival=101;
3015 else if(sval==
"SC01")ival=102;
3016 else if(sval==
"SpiderSupport")ival=103;
3017 else if(sval==
"Stl_BLK1")ival=104;
3018 else if(sval==
"Stl_BLK10")ival=105;
3019 else if(sval==
"Stl_BLK2")ival=106;
3020 else if(sval==
"Stl_BLK3")ival=107;
3021 else if(sval==
"Stl_BLK4")ival=108;
3022 else if(sval==
"Stl_BLK5")ival=109;
3023 else if(sval==
"Stl_BLK6")ival=110;
3024 else if(sval==
"Stl_BLK7")ival=111;
3025 else if(sval==
"Stl_BLK8")ival=112;
3026 else if(sval==
"Stl_BLK9")ival=113;
3027 else if(sval==
"Stlhole")ival=114;
3028 else if(sval==
"TGAR")ival=115;
3029 else if(sval==
"TGT1")ival=116;
3030 else if(sval==
"TGTExitCyl2LV")ival=117;
3031 else if(sval==
"TUNE")ival=118;
3032 else if(sval==
"Tube1aLV")ival=119;
3033 else if(sval==
"Tube1bLV")ival=120;
3034 else if(sval==
"UpWn1")ival=121;
3035 else if(sval==
"UpWn2")ival=122;
3036 else if(sval==
"UpWnAl1SLV")ival=123;
3037 else if(sval==
"UpWnAl2SLV")ival=124;
3038 else if(sval==
"UpWnAl3SLV")ival=125;
3039 else if(sval==
"UpWnFe1SLV")ival=126;
3040 else if(sval==
"UpWnFe2SLV")ival=127;
3041 else if(sval==
"UpWnPolyCone")ival=128;
3042 else if(sval==
"blu_BLK25")ival=129;
3043 else if(sval==
"blu_BLK26")ival=130;
3044 else if(sval==
"blu_BLK27")ival=131;
3045 else if(sval==
"blu_BLK28")ival=132;
3046 else if(sval==
"blu_BLK29")ival=133;
3047 else if(sval==
"blu_BLK32")ival=134;
3048 else if(sval==
"blu_BLK37")ival=135;
3049 else if(sval==
"blu_BLK38")ival=136;
3050 else if(sval==
"blu_BLK39")ival=137;
3051 else if(sval==
"blu_BLK40")ival=138;
3052 else if(sval==
"blu_BLK45")ival=139;
3053 else if(sval==
"blu_BLK46")ival=140;
3054 else if(sval==
"blu_BLK47")ival=141;
3055 else if(sval==
"blu_BLK48")ival=142;
3056 else if(sval==
"blu_BLK49")ival=143;
3057 else if(sval==
"blu_BLK50")ival=144;
3058 else if(sval==
"blu_BLK51")ival=145;
3059 else if(sval==
"blu_BLK53")ival=146;
3060 else if(sval==
"blu_BLK55")ival=147;
3061 else if(sval==
"blu_BLK57")ival=148;
3062 else if(sval==
"blu_BLK59")ival=149;
3063 else if(sval==
"blu_BLK61")ival=150;
3064 else if(sval==
"blu_BLK63")ival=151;
3065 else if(sval==
"blu_BLK64")ival=152;
3066 else if(sval==
"blu_BLK65")ival=153;
3067 else if(sval==
"blu_BLK66")ival=154;
3068 else if(sval==
"blu_BLK67")ival=155;
3069 else if(sval==
"blu_BLK68")ival=156;
3070 else if(sval==
"blu_BLK69")ival=157;
3071 else if(sval==
"blu_BLK70")ival=158;
3072 else if(sval==
"blu_BLK72")ival=159;
3073 else if(sval==
"blu_BLK73")ival=160;
3074 else if(sval==
"blu_BLK75")ival=161;
3075 else if(sval==
"blu_BLK77")ival=162;
3076 else if(sval==
"blu_BLK78")ival=163;
3077 else if(sval==
"blu_BLK79")ival=164;
3078 else if(sval==
"blu_BLK81")ival=165;
3079 else if(sval==
"conc_BLK")ival=166;
3080 else if(sval==
"pvBaffleMother")ival=167;
3081 else if(sval==
"pvDPInnerTrackerTube")ival=168;
3082 else if(sval==
"pvMHorn1Mother")ival=169;
3083 else if(sval==
"pvMHorn2Mother")ival=170;
3084 else if(sval==
"pvTargetMother")ival=171;
3085 else if(sval==
"stl_slab1")ival=172;
3086 else if(sval==
"stl_slab4")ival=173;
3087 else if(sval==
"stl_slab5")ival=174;
3088 else if(sval==
"stl_slabL")ival=175;
3089 else if(sval==
"stl_slabR")ival=176;
3095 if(sval==
"AntiLambdaInelastic")ival=1;
3096 else if(sval==
"AntiNeutronInelastic")ival=2;
3097 else if(sval==
"AntiOmegaMinusInelastic")ival=3;
3098 else if(sval==
"AntiProtonInelastic")ival=4;
3099 else if(sval==
"AntiSigmaMinusInelastic")ival=5;
3100 else if(sval==
"AntiSigmaPlusInelastic")ival=6;
3101 else if(sval==
"AntiXiMinusInelastic")ival=7;
3102 else if(sval==
"AntiXiZeroInelastic")ival=8;
3103 else if(sval==
"Decay")ival=9;
3104 else if(sval==
"KaonMinusInelastic")ival=10;
3105 else if(sval==
"KaonPlusInelastic")ival=11;
3106 else if(sval==
"KaonZeroLInelastic")ival=12;
3107 else if(sval==
"KaonZeroSInelastic")ival=13;
3108 else if(sval==
"LambdaInelastic")ival=14;
3109 else if(sval==
"NeutronInelastic")ival=15;
3110 else if(sval==
"OmegaMinusInelastic")ival=16;
3111 else if(sval==
"PionMinusInelastic")ival=17;
3112 else if(sval==
"PionPlusInelastic")ival=18;
3113 else if(sval==
"Primary")ival=19;
3114 else if(sval==
"ProtonInelastic")ival=20;
3115 else if(sval==
"SigmaMinusInelastic")ival=21;
3116 else if(sval==
"SigmaPlusInelastic")ival=22;
3117 else if(sval==
"XiMinusInelastic")ival=23;
3118 else if(sval==
"XiZeroInelastic")ival=24;
3119 else if(sval==
"hElastic")ival=25;
static constexpr double cm
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
bool LoadParamSet(xmlDocPtr &, std::string cfg)
TVector3 AnglesToAxis(double theta, double phi, std::string units="deg")
std::vector< long int > GetIntVector(std::string str)
void User2BeamP4(const TLorentzVector &usrp4, TLorentzVector &beamp4) const
static constexpr double rad
TVector3 GetBeamCenter() const
beam origin in user frame
virtual void GetBranchInfo(std::vector< std::string > &branchNames, std::vector< std::string > &branchClassNames, std::vector< void ** > &branchObjPointers)
TLorentzVector fgP4
generated nu 4-momentum beam coord
string P4AsShortString(const TLorentzVector *p)
void GetFluxWindow(TVector3 &p1, TVector3 &p2, TVector3 &p3) const
3 points define a plane in beam coordinate
void SetEntryReuse(long int nuse=1)
of times to use entry before moving to next
double beta(double KE, const simb::MCParticle *part)
static const unsigned int MAX_N_TRAJ
Maximum number of trajectories to store.
THE MAIN GENIE PROJECT NAMESPACE
double POT_curr(void)
current average POT (RWH?)
Int_t run
current Tree number in a TChain
static RandomGen * Instance()
Access instance.
void SetLengthUnits(double user_units)
Set units assumed by user.
void UseFluxAtNearDetCenter(void)
force weights at MINOS detector "center" as found in ntuple
double pprodpx[MAX_N_TRAJ]
string TrimSpaces(xmlChar *xmls)
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
TLorentzVector fgX4User
generated nu 4-position user coord
bool LoadConfig(string cfg)
load a named configuration
void ParseParamSet(xmlDocPtr &, xmlNodePtr &)
double stoppz[MAX_N_TRAJ]
double stoppy[MAX_N_TRAJ]
void ParseBeamDir(xmlDocPtr &, xmlNodePtr &)
int fVerbose
how noisy to be when parsing XML
Int_t run
current Tree number in a TChain
void SetTreeName(string name)
set input tree name (default: "h10")
virtual double GetTotalExposure() const
GNuMIFluxXMLHelper(GNuMIFlux *gnumi)
void Beam2UserP4(const TLorentzVector &beamp4, TLorentzVector &usrp4) const
TRotation GetBeamRotation() const
rotation to apply from beam->user
double startx[MAX_N_TRAJ]
double pprodpy[MAX_N_TRAJ]
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Q_EXPORT QTSManip setprecision(int p)
void MakeCopy(const g3numi *)
pull in from g3 ntuple
friend ostream & operator<<(ostream &stream, const GNuMIFluxPassThroughInfo &info)
A GENIE flux driver encapsulating the NuMI neutrino flux. It reads-in the official GNUMI neutrino flu...
void User2BeamPos(const TLorentzVector &usrxyz, TLorentzVector &beamxyz) const
int GeantToPdg(int geant_code)
TLorentzVector fgX4
generated nu 4-position beam coord
virtual void LoadBeamSimData(const std::vector< std::string > &filenames, const std::string &det_loc)
void MoveToZ0(double z0)
move ray origin to user coord Z0
void ParseBeamPos(std::string)
void ParseEnuMax(std::string)
std::vector< std::string > GetFileList()
list of files currently part of chain
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Int_t run
current Tree number in a TChain
void SetBeamRotation(TRotation beamrot)
< beam (0,0,0) relative to user frame, beam direction in user frame
double UnitFromString(string u)
QTextStream & flush(QTextStream &s)
GENIE interface for uniform flux exposure iterface.
string GetXMLFilePath(string basename)
void ParseRotSeries(xmlDocPtr &, xmlNodePtr &)
double pprodpz[MAX_N_TRAJ]
int CalcEnuWgt(const TLorentzVector &xyz, double &enu, double &wgt_xy) const
void SetBeamCenter(TVector3 beam0)
bool GenerateNext_weighted(void)
int getVolID(TString sval)
GNuMIFluxPassThroughInfo()
void PrintCurrent(void)
print current entry from leaves
bool SetFluxWindow(StdFluxWindow_t stdwindow, double padding=0)
return false if unhandled
bool GenerateNext(void)
generate the next flux neutrino (return false in err)
double gamma(double KE, const simb::MCParticle *part)
bool LoadConfig(std::string cfg)
double startpz[MAX_N_TRAJ]
void err(const char *fmt,...)
double LengthUnits(void) const
Return user units.
double startz[MAX_N_TRAJ]
void Print(const Option_t *opt="") const
ClassImp(GNuMIFluxPassThroughInfo) const TLorentzVector kPosCenterNearBeam(0.
Q_EXPORT QTSManip setw(int w)
string TrimSpaces(string input)
void Clear(Option_t *opt)
reset state variables based on opt
TVector3 ParseTV3(const std::string &)
double GetDecayDist() const
dist (user units) from dk to current pos
void Beam2UserPos(const TLorentzVector &beamxyz, TLorentzVector &usrxyz) const
const TLorentzVector kPosCenterFarBeam(0., 0., 735340.00, 0.)
double startpx[MAX_N_TRAJ]
double startpy[MAX_N_TRAJ]
vector< string > Split(string input, string delim)
Quantity< ScaledUnit< typename Q::unit_t::baseunit_t, R >, T > rescale
Type of a quantity like Q, but with a different unit scale R.
int fgPdgC
generated nu pdg-code
enum genie::flux::GNuMIFlux::EStdFluxWindow StdFluxWindow_t
void ParseWindowSeries(xmlDocPtr &, xmlNodePtr &)
virtual TTree * GetMetaDataTree()
double stoppx[MAX_N_TRAJ]
void User2BeamDir(const TLorentzVector &usrdir, TLorentzVector &beamdir) const
void PrintConfig()
print the current configuration
void ScanForMaxWeight(void)
scan for max flux weight (before generating unweighted flux neutrinos)
int getProcessID(TString sval)
void SetMaxEnergy(double Ev)
specify maximum flx neutrino energy
TLorentzVector fgP4User
generated nu 4-momentum user coord
std::vector< double > GetDoubleVector(std::string str)
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
string X4AsString(const TLorentzVector *x)
double starty[MAX_N_TRAJ]
virtual long int NFluxNeutrinos() const
of rays generated
void Beam2UserDir(const TLorentzVector &beamdir, TLorentzVector &usrdir) const
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
#define FLUXDRIVERREG4(_nsa, _nsb, _name, _fqname)
string Vec3AsString(const TVector3 *vec)
void AddFile(TTree *tree, string fname)
void UseFluxAtFarDetCenter(void)
void GenerateWeighted(bool gen_weighted)
set whether to generate weighted or unweighted neutrinos
QTextStream & endl(QTextStream &s)
void CalcEffPOTsPerNu(void)
void push_back(int pdg_code)
double UsedPOTs(void) const
of protons-on-target used