Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GSimpleNtpFlux Class Reference

A GENIE flux driver using a simple ntuple format. More...

#include <GSimpleNtpFlux.h>

Inheritance diagram for genie::flux::GSimpleNtpFlux:
genie::GFluxI genie::flux::GFluxExposureI genie::flux::GFluxFileConfigI

Public Member Functions

 GSimpleNtpFlux ()
 
 ~GSimpleNtpFlux ()
 
const PDGCodeListFluxParticles (void)
 declare list of flux neutrinos that can be generated (for init. purposes) More...
 
double MaxEnergy (void)
 declare the max flux neutrino energy that can be generated (for init. purposes) More...
 
bool GenerateNext (void)
 generate the next flux neutrino (return false in err) More...
 
int PdgCode (void)
 returns the flux neutrino pdg code More...
 
double Weight (void)
 returns the flux neutrino weight (if any) More...
 
const TLorentzVector & Momentum (void)
 returns the flux neutrino 4-momentum More...
 
const TLorentzVector & Position (void)
 returns the flux neutrino 4-position (note: expect SI rather than physical units) More...
 
bool End (void)
 true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples) More...
 
long int Index (void)
 returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current entry number) More...
 
void Clear (Option_t *opt)
 reset state variables based on opt More...
 
void GenerateWeighted (bool gen_weighted)
 set whether to generate weighted or unweighted neutrinos More...
 
const genie::flux::GSimpleNtpEntryGetCurrentEntry (void)
 GSimpleNtpEntry. More...
 
const genie::flux::GSimpleNtpNuMIGetCurrentNuMI (void)
 GSimpleNtpNuMI. More...
 
const genie::flux::GSimpleNtpAuxGetCurrentAux (void)
 GSimpleNtpAux. More...
 
const genie::flux::GSimpleNtpMetaGetCurrentMeta (void)
 GSimpleNtpMeta. More...
 
TChain * GetFluxTChain (void)
 
double GetDecayDist () const
 dist (user units) from dk to current pos More...
 
void MoveToZ0 (double z0)
 move ray origin to user coord Z0 More...
 
void SetIncludeVtxt (bool it=true)
 should X4 include CurEntry.vtxt More...
 
bool GetIncludeVtxt ()
 
virtual double GetTotalExposure () const
 GFluxExposureI interface. More...
 
virtual long int NFluxNeutrinos () const
 

of rays generated

More...
 
double UsedPOTs (void) const
 

of protons-on-target used

More...
 
long int NEntriesUsed (void) const
 number of entries read from files More...
 
double SumWeight (void) const
 integrated weight for flux neutrinos looped so far More...
 
void PrintCurrent (void)
 print current entry from leaves More...
 
void PrintConfig ()
 print the current configuration More...
 
std::vector< std::stringGetFileList ()
 list of files currently part of chain More...
 
virtual void LoadBeamSimData (const std::vector< string > &filenames, const std::string &det_loc)
 
virtual void GetBranchInfo (std::vector< std::string > &branchNames, std::vector< std::string > &branchClassNames, std::vector< void ** > &branchObjPointers)
 
virtual TTree * GetMetaDataTree ()
 
void SetRequestedBranchList (string blist="entry,numi,aux")
 
void SetMaxEnergy (double Ev)
 specify maximum flx neutrino energy More...
 
void SetGenWeighted (bool genwgt=false)
 toggle whether GenerateNext() returns weight=1 flux (initial default false) More...
 
void SetEntryReuse (long int nuse=1)
 

of times to use entry before moving to next

More...
 
void ProcessMeta (void)
 scan for max flux energy, weight More...
 
void GetFluxWindow (TVector3 &p1, TVector3 &p2, TVector3 &p3) const
 3 points define a plane in beam coordinate More...
 
- Public Member Functions inherited from genie::GFluxI
virtual ~GFluxI ()
 
- Public Member Functions inherited from genie::flux::GFluxExposureI
 GFluxExposureI (genie::flux::Exposure_t etype)
 
virtual ~GFluxExposureI ()
 
const char * GetExposureUnits () const
 what units are returned by GetTotalExposure? More...
 
genie::flux::Exposure_t GetExposureType () const
 
- Public Member Functions inherited from genie::flux::GFluxFileConfigI
 GFluxFileConfigI ()
 
virtual ~GFluxFileConfigI ()
 
virtual void LoadBeamSimData (const std::set< std::string > &filenames, const std::string &det_loc)
 
virtual void LoadBeamSimData (const std::string &filename, const std::string &det_loc)
 
virtual void SetXMLFileBase (std::string xmlbasename="")
 
virtual std::string GetXMLFileBase () const
 
virtual void SetFluxParticles (const PDGCodeList &particles)
 specify list of flux neutrino species More...
 
virtual void SetUpstreamZ (double z0)
 
virtual void SetNumOfCycles (long int ncycle)
 limit cycling through input files More...
 

Private Member Functions

bool GenerateNext_weighted (void)
 
void Initialize (void)
 
void SetDefaults (void)
 
void CleanUp (void)
 
void ResetCurrent (void)
 
void AddFile (TTree *fluxtree, TTree *metatree, string fname)
 
bool OptionalAttachBranch (std::string bname)
 
void CalcEffPOTsPerNu (void)
 
void ScanMeta (void)
 

Private Attributes

double fMaxEv
 maximum energy More...
 
bool fEnd
 end condition reached More...
 
std::vector< stringfNuFluxFilePatterns
 (potentially wildcarded) path(s) More...
 
string fNuFluxBranchRequest
 list of requested branches "entry,numi,au" More...
 
TChain * fNuFluxTree
 TTree // REF ONLY. More...
 
TChain * fNuMetaTree
 TTree // REF ONLY. More...
 
int fNFiles
 number of files in chain More...
 
Long64_t fNEntries
 number of flux ntuple entries More...
 
Long64_t fIEntry
 current flux ntuple entry More...
 
Int_t fIFileNumber
 which file for the current entry More...
 
Double_t fFilePOTs
 

of protons-on-target represented by all files

More...
 
double fWeight
 current neutrino weight More...
 
double fMaxWeight
 max flux neutrino weight in input file More...
 
long int fNUse
 how often to use same entry in a row More...
 
long int fIUse
 current # of times an entry has been used More...
 
double fSumWeight
 sum of weights for nus thrown so far More...
 
long int fNNeutrinos
 number of flux neutrinos thrown so far More...
 
long int fNEntriesUsed
 number of entries read from files More...
 
double fEffPOTsPerNu
 what a entry is worth ... More...
 
double fAccumPOTs
 POTs used so far. More...
 
bool fGenWeighted
 does GenerateNext() give weights? More...
 
bool fAlreadyUnwgt
 are input files already unweighted More...
 
bool fAllFilesMeta
 do all files in chain have meta data More...
 
GSimpleNtpEntryfCurEntry
 current entry More...
 
GSimpleNtpNuMIfCurNuMI
 current "numi" branch extra info More...
 
GSimpleNtpAuxfCurAux
 current "aux" branch extra info More...
 
TLorentzVector fP4
 reconstituted p4 vector More...
 
TLorentzVector fX4
 reconstituted position vector More...
 
GSimpleNtpMetafCurMeta
 current meta data More...
 
GSimpleNtpEntryfCurEntryCopy
 current entry More...
 
GSimpleNtpNuMIfCurNuMICopy
 current "numi" branch extra info More...
 
GSimpleNtpAuxfCurAuxCopy
 current "aux" branch extra info More...
 
bool fIncludeVtxt
 does fX4 include CurEntry.vtxt or 0 More...
 

Additional Inherited Members

- Static Public Member Functions inherited from genie::flux::GFluxExposureI
static const char * AsString (genie::flux::Exposure_t etype)
 
static genie::flux::Exposure_t StringToEnum (const char *chars, int maxChar=0)
 
- Protected Member Functions inherited from genie::GFluxI
 GFluxI ()
 
- Protected Attributes inherited from genie::flux::GFluxFileConfigI
PDGCodeListfPdgCList
 list of neutrino pdg-codes to generate More...
 
PDGCodeListfPdgCListRej
 list of nu pdg-codes seen but rejected More...
 
std::string fXMLbasename
 XML file that might hold config param_sets. More...
 
long int fNCycles
 

times to cycle through the ntuple(s)

More...
 
long int fICycle
 
double fZ0
 

Detailed Description

A GENIE flux driver using a simple ntuple format.

GSimpleNtpFlux:

An implementation of the GFluxI interface that provides NuMI flux

Author
Robert Hatcher <rhatcher fnal.gov> Fermi National Accelerator Laboratory

Jan 25, 2010

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 199 of file GSimpleNtpFlux.h.

Constructor & Destructor Documentation

genie::flux::GSimpleNtpFlux::GSimpleNtpFlux ( )
GSimpleNtpFlux::~GSimpleNtpFlux ( )

Definition at line 72 of file GSimpleNtpFlux.cxx.

73 {
74  this->CleanUp();
75 }

Member Function Documentation

void GSimpleNtpFlux::AddFile ( TTree *  fluxtree,
TTree *  metatree,
string  fname 
)
private

Definition at line 791 of file GSimpleNtpFlux.cxx.

792 {
793  // Add a file to the chain
794  if ( ! fluxtree ) return;
795 
796  ULong64_t nentries = fluxtree->GetEntries();
797 
798  int stat = fNuFluxTree->AddFile(fname.c_str());
799  if ( metatree ) fNuMetaTree->AddFile(fname.c_str());
800  else fAllFilesMeta = false;
801 
802  LOG("Flux",pINFO)
803  << "flux->AddFile() of " << nentries
804  << " " << ((metatree)?"[+meta]":"[no-meta]")
805  << " [status=" << stat << "]"
806  << " entries in file: " << fname;
807 
808  if ( stat != 1 ) return;
809 
810  fNFiles++;
811 
812 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool fAllFilesMeta
do all files in chain have meta data
#define pINFO
Definition: Messenger.h:62
int fNFiles
number of files in chain
TChain * fNuMetaTree
TTree // REF ONLY.
TChain * fNuFluxTree
TTree // REF ONLY.
void GSimpleNtpFlux::CalcEffPOTsPerNu ( void  )
private

Definition at line 351 of file GSimpleNtpFlux.cxx.

352 {
353  // do this if flux window changes or # of files changes
354 
355  if (!fNuFluxTree) return; // not yet fully configured
356 
357  fEffPOTsPerNu = ( (double)fFilePOTs / (double)fNEntries );
358 }
Double_t fFilePOTs
of protons-on-target represented by all files
Long64_t fNEntries
number of flux ntuple entries
double fEffPOTsPerNu
what a entry is worth ...
TChain * fNuFluxTree
TTree // REF ONLY.
void GSimpleNtpFlux::CleanUp ( void  )
private

Definition at line 771 of file GSimpleNtpFlux.cxx.

772 {
773  LOG("Flux", pINFO) << "Cleaning up...";
774 
775  if (fPdgCList) delete fPdgCList;
776  if (fPdgCListRej) delete fPdgCListRej;
777  if (fCurEntry) delete fCurEntry;
778  if (fCurNuMI) delete fCurNuMI;
779  if (fCurAux) delete fCurAux;
780  if (fCurMeta) delete fCurMeta;
781 
782  if (fNuFluxTree) delete fNuFluxTree;
783  if (fNuMetaTree) delete fNuMetaTree;
784 
785  LOG("Flux", pNOTICE)
786  << " flux file cycles: " << fICycle << " of " << fNCycles
787  << ", entry " << fIEntry << " use: " << fIUse << " of " << fNUse;
788 }
GSimpleNtpAux * fCurAux
current "aux" branch extra info
GSimpleNtpMeta * fCurMeta
current meta data
long int fIUse
current # of times an entry has been used
PDGCodeList * fPdgCList
list of neutrino pdg-codes to generate
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
long int fNCycles
times to cycle through the ntuple(s)
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
PDGCodeList * fPdgCListRej
list of nu pdg-codes seen but rejected
TChain * fNuMetaTree
TTree // REF ONLY.
GSimpleNtpEntry * fCurEntry
current entry
Long64_t fIEntry
current flux ntuple entry
long int fNUse
how often to use same entry in a row
#define pNOTICE
Definition: Messenger.h:61
TChain * fNuFluxTree
TTree // REF ONLY.
void GSimpleNtpFlux::Clear ( Option_t *  opt)
virtual

reset state variables based on opt

Implements genie::GFluxI.

Definition at line 674 of file GSimpleNtpFlux.cxx.

675 {
676 // Clear the driver state
677 //
678  LOG("Flux", pWARN) << "GSimpleNtpFlux::Clear(" << opt << ") called";
679  // do it in all cases, but EVGDriver/GMCJDriver will pass "CycleHistory"
680 
681  fICycle = 0;
682 
683  fSumWeight = 0;
684  fNNeutrinos = 0;
685  fAccumPOTs = 0;
686 
687 }
long int fNNeutrinos
number of flux neutrinos thrown so far
double fSumWeight
sum of weights for nus thrown so far
opt
Definition: train.py:196
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
double fAccumPOTs
POTs used so far.
bool genie::flux::GSimpleNtpFlux::End ( void  )
inlinevirtual

true if no more flux nu's can be thrown (eg reaching end of beam sim ntuples)

Implements genie::GFluxI.

Definition at line 219 of file GSimpleNtpFlux.h.

219 { return fEnd; }
bool fEnd
end condition reached
const PDGCodeList& genie::flux::GSimpleNtpFlux::FluxParticles ( void  )
inlinevirtual

declare list of flux neutrinos that can be generated (for init. purposes)

Implements genie::GFluxI.

Definition at line 212 of file GSimpleNtpFlux.h.

212 { return *fPdgCList; }
PDGCodeList * fPdgCList
list of neutrino pdg-codes to generate
bool GSimpleNtpFlux::GenerateNext ( void  )
virtual

generate the next flux neutrino (return false in err)

Implements genie::GFluxI.

Definition at line 89 of file GSimpleNtpFlux.cxx.

90 {
91 // Get next (unweighted) flux ntuple entry on the specified detector location
92 //
94  while ( true ) {
95  // Check for end of flux ntuple
96  bool end = this->End();
97  if ( end ) {
98  LOG("Flux", pNOTICE) << "GenerateNext signaled End() ";
99  return false;
100  }
101 
102  // Get next weighted flux ntuple entry
103  bool nextok = this->GenerateNext_weighted();
104  if ( fGenWeighted ) return nextok;
105  if ( ! nextok ) continue;
106  if ( fAlreadyUnwgt ) return true;
107 
108  /* RWH - debug purposes
109  if ( fNCycles == 0 ) {
110  LOG("Flux", pNOTICE)
111  << "Got flux entry: " << fIEntry
112  << " - Cycle: "<< fICycle << "/ infinite";
113  } else {
114  LOG("Flux", pNOTICE)
115  << "Got flux entry: "<< fIEntry
116  << " - Cycle: "<< fICycle << "/"<< fNCycles;
117  }
118  */
119 
120  // Get fractional weight & decide whether to accept curr flux neutrino
121  double f = this->Weight() / fMaxWeight;
122  //LOG("Flux", pNOTICE)
123  // << "Curr flux neutrino fractional weight = " << f;
124  if (f > 1.) {
125  fMaxWeight = this->Weight() * 1.01; // bump the weight
126  LOG("Flux", pERROR)
127  << "** Fractional weight = " << f
128  << " > 1 !! Bump fMaxWeight estimate to " << fMaxWeight
129  << GetCurrentEntry();
130  std::cout << std::flush;
131  }
132  double r = (f < 1.) ? rnd->RndFlux().Rndm() : 0;
133  bool accept = ( r < f );
134  if ( accept ) {
135 
136 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
137  LOG("Flux", pNOTICE)
138  << "Generated beam neutrino: "
139  << "\n pdg-code: " << fCurEntry->pdg
140  << "\n p4: " << utils::print::P4AsShortString(&(fP4))
141  << "\n x4: " << utils::print::X4AsString(&(fX4));
142 #endif
143 
144  fWeight = 1.;
145  return true;
146  }
147 
148  //LOG("Flux", pNOTICE)
149  // << "** Rejecting current flux neutrino based on the flux weight only";
150  }
151  return false;
152 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
string P4AsShortString(const TLorentzVector *p)
Definition: PrintUtils.cxx:45
#define pERROR
Definition: Messenger.h:59
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
bool End(void)
true if no more flux nu&#39;s can be thrown (eg reaching end of beam sim ntuples)
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
const genie::flux::GSimpleNtpEntry * GetCurrentEntry(void)
GSimpleNtpEntry.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TLorentzVector fX4
reconstituted position vector
bool fGenWeighted
does GenerateNext() give weights?
QTextStream & flush(QTextStream &s)
double fMaxWeight
max flux neutrino weight in input file
double fWeight
current neutrino weight
GSimpleNtpEntry * fCurEntry
current entry
TLorentzVector fP4
reconstituted p4 vector
bool fAlreadyUnwgt
are input files already unweighted
#define pNOTICE
Definition: Messenger.h:61
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:71
string X4AsString(const TLorentzVector *x)
Definition: PrintUtils.cxx:57
double Weight(void)
returns the flux neutrino weight (if any)
bool GSimpleNtpFlux::GenerateNext_weighted ( void  )
private

user might modify list via SetFluxParticles() in order to reject certain flavors, even if they're found in the file. So don't make a big fuss. Spit out a single message and then stop reporting that flavor as problematic.

Definition at line 154 of file GSimpleNtpFlux.cxx.

155 {
156 // Get next (weighted) flux ntuple entry
157 //
158 
159  // Check whether a flux ntuple has been loaded
160  if ( ! fNuFluxTree ) {
161  LOG("Flux", pFATAL)
162  << "The flux driver has not been properly configured";
163  // return false; // don't do this - creates an infinite loop!
164  exit(1);
165  }
166 
167  // Reuse an entry?
168  //std::cout << " ***** iuse " << fIUse << " nuse " << fNUse
169  // << " ientry " << fIEntry << " nentry " << fNEntries
170  // << " icycle " << fICycle << " ncycle " << fNCycles << std::endl;
171  if ( fIUse < fNUse && fIEntry >= 0 ) {
172  // Reuse this entry
173  fIUse++;
174  } else {
175  // Reset previously generated neutrino code / 4-p / 4-x
176  this->ResetCurrent();
177  // Move on, read next flux ntuple entry
178  ++fIEntry;
179  ++fNEntriesUsed; // count total # used
180  if ( fIEntry >= fNEntries ) {
181  // Ran out of entries @ the current cycle of this flux file
182  // Check whether more (or infinite) number of cycles is requested
183  if (fICycle < fNCycles || fNCycles == 0 ) {
184  fICycle++;
185  fIEntry=0;
186  } else {
187  LOG("Flux", pWARN)
188  << "No more entries in input flux neutrino ntuple, cycle "
189  << fICycle << " of " << fNCycles;
190  fEnd = true;
191  //assert(0);
192  return false;
193  }
194  }
195 
196  int nbytes = fNuFluxTree->GetEntry(fIEntry);
197  UInt_t metakey = fCurEntry->metakey;
198  if ( fAllFilesMeta && ( fCurMeta->metakey != metakey ) ) {
199  UInt_t oldkey = fCurMeta->metakey;
200 #ifdef USE_INDEX_FOR_META
201  int nbmeta = fNuMetaTree->GetEntryWithIndex(metakey);
202 #else
203  // unordered indices makes ROOT call Error() which might,
204  // if not DefaultErrorHandler, be fatal.
205  // so find the right one by a simple linear search.
206  // not a large burden since it only happens infrequently and
207  // the list is normally quite short.
208  int nmeta = fNuMetaTree->GetEntries();
209  int nbmeta = 0;
210  for (int imeta = 0; imeta < nmeta; ++imeta ) {
211  nbmeta = fNuMetaTree->GetEntry(imeta);
212  if ( fCurMeta->metakey == metakey ) break;
213  }
214  // next condition should never happen
215  if ( fCurMeta->metakey != metakey ) {
216  fCurMeta = 0; // didn't find it!?
217  LOG("Flux",pERROR) << "Failed to find right metakey=" << metakey
218  << " (was " << oldkey << ") out of " << nmeta
219  << " entries";
220  }
221 #endif
222  LOG("Flux",pDEBUG) << "Get meta " << metakey
223  << " (was " << oldkey << ") "
224  << fCurMeta->metakey
225  << " nb " << nbytes << " " << nbmeta;
226 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
227  LOG("Flux",pDEBUG) << "Get meta " << *fCurMeta;
228 #endif
229  }
230 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
231  Int_t ifile = fNuFluxTree->GetFileNumber();
232  LOG("Flux",pDEBUG)
233  << "got " << fNNeutrinos << " nu, using fIEntry " << fIEntry
234  << " ifile " << ifile << " nbytes " << nbytes
235  << *fCurEntry << *fCurMeta;
236 #endif
237 
238  fIUse = 1;
239 
240  // here we might want to do flavor oscillations or simple mappings
241  //RWH modify: fPdgC = fCurEntry->pdg;
242 
243  // Check neutrino pdg against declared list of neutrino species declared
244  // by the current instance of the NuMI neutrino flux driver.
245  // No undeclared neutrino species will be accepted at this point as GENIE
246  // has already been configured to handle the specified list.
247  // Make sure that the appropriate list of flux neutrino species was set at
248  // initialization via GSimpleNtpFlux::SetFluxParticles(const PDGCodeList &)
249 
250  // update the # POTs, sum of weights & number of neutrinos
251  // do this HERE (before rejecting flavors that users might be weeding out)
252  // in order to keep the POT accounting correct. This allows one to get
253  // the right normalization for generating only events from the intrinsic
254  // nu_e entries.
256  fSumWeight += this->Weight();
257  fNNeutrinos++;
258 
260  /// user might modify list via SetFluxParticles() in order to reject certain
261  /// flavors, even if they're found in the file. So don't make a big fuss.
262  /// Spit out a single message and then stop reporting that flavor as problematic.
263  int badpdg = fCurEntry->pdg;
264  if ( ! fPdgCListRej->ExistsInPDGCodeList(badpdg) ) {
265  fPdgCListRej->push_back(badpdg);
266  LOG("Flux", pWARN)
267  << "Encountered neutrino specie (" << badpdg
268  << ") that wasn't in SetFluxParticles() list, "
269  << "\nDeclared list of neutrino species: " << *fPdgCList;
270  }
271  return false;
272  }
273 
274  }
275 
276  // Update the curr neutrino p4/x4 lorentz vector
277  double Ev = fCurEntry->E;
278  fP4.SetPxPyPzE(fCurEntry->px,fCurEntry->py,fCurEntry->pz,Ev);
279  double t0 = ((fIncludeVtxt) ? fCurEntry->vtxt : 0 );
280  fX4.SetXYZT(fCurEntry->vtxx,fCurEntry->vtxy,fCurEntry->vtxz,t0);
281 
282  fWeight = fCurEntry->wgt;
283 
284  if (Ev > fMaxEv) {
285  LOG("Flux", pWARN)
286  << "Flux neutrino energy exceeds declared maximum neutrino energy"
287  << "\nEv = " << Ev << "(> Ev{max} = " << fMaxEv << ")";
288  }
289 
290  // if desired, move to user specified user coord z
291  if ( TMath::Abs(fZ0) < 1.0e30 ) this->MoveToZ0(fZ0);
292 
293 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
294  LOG("Flux", pINFO)
295  << "Generated neutrino: " << fIEntry
296 #ifdef NOT_YET
297  << " run " << fCurNuMI->evtno
298  << " evtno " << fCurNuMI->evtno
299  << " entryno " << fCurNuMI->entryno
300 #endif
301  << "\n pdg-code: " << fCurEntry->pdg << " wgt " << fCurEntry->wgt
302  << "\n p4: " << utils::print::P4AsShortString(&fP4)
303  << "\n x4: " << utils::print::X4AsString(&fX4);
304 #endif
305  if ( Ev > fMaxEv ) {
306  LOG("Flux", pFATAL)
307  << "Generated neutrino had E_nu = " << Ev << " > " << fMaxEv
308  << " maximum ";
309  assert(0);
310  }
311 
312  return true;
313 }
code to link reconstructed objects back to the MC truth information
Double_t E
energy in lab frame
string P4AsShortString(const TLorentzVector *p)
Definition: PrintUtils.cxx:45
long int fNNeutrinos
number of flux neutrinos thrown so far
GSimpleNtpMeta * fCurMeta
current meta data
#define pERROR
Definition: Messenger.h:59
long int fIUse
current # of times an entry has been used
Double_t px
x momentum in lab frame (GeV)
double fSumWeight
sum of weights for nus thrown so far
Double_t vtxy
y position in lab frame
#define pFATAL
Definition: Messenger.h:56
bool ExistsInPDGCodeList(int pdg_code) const
void MoveToZ0(double z0)
move ray origin to user coord Z0
Double_t vtxt
time of ray start (seconds)
PDGCodeList * fPdgCList
list of neutrino pdg-codes to generate
bool fIncludeVtxt
does fX4 include CurEntry.vtxt or 0
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TLorentzVector fX4
reconstituted position vector
bool fAllFilesMeta
do all files in chain have meta data
Double_t vtxz
z position in lab frame
#define pINFO
Definition: Messenger.h:62
long int fNEntriesUsed
number of entries read from files
long int fNCycles
times to cycle through the ntuple(s)
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
#define pWARN
Definition: Messenger.h:60
PDGCodeList * fPdgCListRej
list of nu pdg-codes seen but rejected
double fWeight
current neutrino weight
TChain * fNuMetaTree
TTree // REF ONLY.
GSimpleNtpEntry * fCurEntry
current entry
TLorentzVector fP4
reconstituted p4 vector
UInt_t metakey
index key to tie to individual entries
Long64_t fIEntry
current flux ntuple entry
Long64_t fNEntries
number of flux ntuple entries
Double_t vtxx
x position in lab frame (meters)
Double_t pz
z momentum in lab frame
double fEffPOTsPerNu
what a entry is worth ...
bool fEnd
end condition reached
string X4AsString(const TLorentzVector *x)
Definition: PrintUtils.cxx:57
double fMaxEv
maximum energy
UInt_t metakey
key to meta data
Double_t py
y momentum in lab frame
double Weight(void)
returns the flux neutrino weight (if any)
double fAccumPOTs
POTs used so far.
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
TChain * fNuFluxTree
TTree // REF ONLY.
#define pDEBUG
Definition: Messenger.h:63
void GSimpleNtpFlux::GenerateWeighted ( bool  gen_weighted)
virtual

set whether to generate weighted or unweighted neutrinos

Implements genie::GFluxI.

Definition at line 689 of file GSimpleNtpFlux.cxx.

690 {
691 // Set whether to generate weighted rays
692 //
693  fGenWeighted = gen_weighted;
694 }
bool fGenWeighted
does GenerateNext() give weights?
void GSimpleNtpFlux::GetBranchInfo ( std::vector< std::string > &  branchNames,
std::vector< std::string > &  branchClassNames,
std::vector< void ** > &  branchObjPointers 
)
virtual

allow caller to copy current status / ntuple entry info in the output file by providing copies of internal info

Assumes that branch object pointers will not change which may require either a copy be made or, if using the class directly for reading the branch, one must force ROOT to not autodelete: myns::MyClassType* fCurrMyClass = new myns::MyClassType; myTree->SetBranchAddress("bname",&fCurMyClass); //? TBranch* b = myTree->GetBranch("bname"); //? b->SetAutoDelete(false);

ensure vectors are sized sufficiently (or use .push_back()) branchNames[i] = "bname" branchClassNames[i] = "myns::MyClassType" branchObjPointers[i] = (void**)

Reimplemented from genie::flux::GFluxFileConfigI.

Definition at line 553 of file GSimpleNtpFlux.cxx.

556 {
557  // allow flux driver to report back current status and/or ntuple entry
558  // info for possible recording in the output file by supplying
559  // the class name, and a pointer to the object that will be filled
560  // as well as a suggested name for the branch.
561 
562  if ( fCurEntry ) {
563  branchNames.push_back("simple");
564  branchClassNames.push_back("genie::flux::GSimpleNtpEntry");
565  branchObjPointers.push_back((void**)&fCurEntry);
566  }
567 
568  if ( fCurNuMI ) {
569  branchNames.push_back("numi");
570  branchClassNames.push_back("genie::flux::GSimpleNtpNuMI");
571  branchObjPointers.push_back((void**)&fCurNuMI);
572  }
573 
574  if ( fCurAux ) {
575  branchNames.push_back("aux");
576  branchClassNames.push_back("genie::flux::GSimpleNtpAux");
577  branchObjPointers.push_back((void**)&fCurAux);
578  }
579 }
GSimpleNtpAux * fCurAux
current "aux" branch extra info
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
GSimpleNtpEntry * fCurEntry
current entry
const genie::flux::GSimpleNtpAux* genie::flux::GSimpleNtpFlux::GetCurrentAux ( void  )
inline

GSimpleNtpAux.

Definition at line 238 of file GSimpleNtpFlux.h.

const genie::flux::GSimpleNtpEntry* genie::flux::GSimpleNtpFlux::GetCurrentEntry ( void  )
inline

GSimpleNtpEntry.

Definition at line 234 of file GSimpleNtpFlux.h.

const genie::flux::GSimpleNtpMeta* genie::flux::GSimpleNtpFlux::GetCurrentMeta ( void  )
inline

GSimpleNtpMeta.

Definition at line 240 of file GSimpleNtpFlux.h.

const genie::flux::GSimpleNtpNuMI* genie::flux::GSimpleNtpFlux::GetCurrentNuMI ( void  )
inline

GSimpleNtpNuMI.

Definition at line 236 of file GSimpleNtpFlux.h.

double GSimpleNtpFlux::GetDecayDist ( ) const

dist (user units) from dk to current pos

Definition at line 315 of file GSimpleNtpFlux.cxx.

316 {
317  // return distance (user units) between dk point and start position
318  // these are in beam units
319  return fCurEntry->dist;
320 }
GSimpleNtpEntry * fCurEntry
current entry
Double_t dist
distance from hadron decay
std::vector< std::string > GSimpleNtpFlux::GetFileList ( )

list of files currently part of chain

Definition at line 1109 of file GSimpleNtpFlux.cxx.

1110 {
1111  std::vector<std::string> flist;
1112  TObjArray *fileElements=fNuFluxTree->GetListOfFiles();
1113  TIter next(fileElements);
1114  TChainElement *chEl=0;
1115  while (( chEl=(TChainElement*)next() )) {
1116  flist.push_back(chEl->GetTitle());
1117  }
1118  return flist;
1119 }
TChain * fNuFluxTree
TTree // REF ONLY.
TChain* genie::flux::GSimpleNtpFlux::GetFluxTChain ( void  )
inline

Definition at line 244 of file GSimpleNtpFlux.h.

void GSimpleNtpFlux::GetFluxWindow ( TVector3 &  p1,
TVector3 &  p2,
TVector3 &  p3 
) const

3 points define a plane in beam coordinate

Definition at line 652 of file GSimpleNtpFlux.cxx.

653 {
654  // return flux window points
655 
656  p0 = TVector3(fCurMeta->windowBase[0],
657  fCurMeta->windowBase[1],
658  fCurMeta->windowBase[2]);
659  p1 = p0 + TVector3(fCurMeta->windowDir1[0],
660  fCurMeta->windowDir1[1],
661  fCurMeta->windowDir1[2]);
662  p2 = p0 + TVector3(fCurMeta->windowDir2[0],
663  fCurMeta->windowDir2[1],
664  fCurMeta->windowDir2[2]);
665 
666 }
GSimpleNtpMeta * fCurMeta
current meta data
Double_t windowDir1[3]
dx,dy,dz of window direction 1
Double_t windowDir2[3]
dx,dy,dz of window direction 2
Double_t windowBase[3]
x,y,z position of window base point
bool genie::flux::GSimpleNtpFlux::GetIncludeVtxt ( )
inline

Definition at line 250 of file GSimpleNtpFlux.h.

250 { return fIncludeVtxt; }
bool fIncludeVtxt
does fX4 include CurEntry.vtxt or 0
TTree * GSimpleNtpFlux::GetMetaDataTree ( )
virtual

Reimplemented from genie::flux::GFluxFileConfigI.

Definition at line 580 of file GSimpleNtpFlux.cxx.

580 { return fNuMetaTree; }
TChain * fNuMetaTree
TTree // REF ONLY.
double GSimpleNtpFlux::GetTotalExposure ( ) const
virtual

GFluxExposureI interface.

Implements genie::flux::GFluxExposureI.

Definition at line 77 of file GSimpleNtpFlux.cxx.

78 {
79  // complete the GFluxExposureI interface
80  return UsedPOTs();
81 }
double UsedPOTs(void) const
of protons-on-target used
long int genie::flux::GSimpleNtpFlux::Index ( void  )
inlinevirtual

returns corresponding index for current flux neutrino (e.g. for a flux ntuple returns the current entry number)

Implements genie::GFluxI.

Definition at line 220 of file GSimpleNtpFlux.h.

220 { return fIEntry; }
Long64_t fIEntry
current flux ntuple entry
void GSimpleNtpFlux::Initialize ( void  )
private

Definition at line 696 of file GSimpleNtpFlux.cxx.

697 {
698  LOG("Flux", pINFO) << "Initializing GSimpleNtpFlux driver";
699 
700  fMaxEv = 0;
701  fEnd = false;
702 
704  fCurNuMI = new GSimpleNtpNuMI;
705  fCurAux = new GSimpleNtpAux;
706  fCurMeta = new GSimpleNtpMeta;
707 
708  fCurEntryCopy = 0;
709  fCurNuMICopy = 0;
710  fCurAuxCopy = 0;
711 
712  fNuFluxTree = new TChain("flux");
713  fNuMetaTree = new TChain("meta");
714 
715  //fNuFluxFilePatterns = "";
716  fNuFluxBranchRequest = "entry,numi,aux"; // all branches
717 
718  fNFiles = 0;
719 
720  fNEntries = 0;
721  fIEntry = -1;
722  fIFileNumber = 0;
723  fICycle = 0;
724  fNUse = 1;
725  fIUse = 999999;
726 
727  fFilePOTs = 0;
728 
729  fMaxWeight = -1;
730 
731  fSumWeight = 0;
732  fNNeutrinos = 0;
733  fNEntriesUsed = 0;
734  fEffPOTsPerNu = 0;
735  fAccumPOTs = 0;
736 
737  fGenWeighted = false;
738  fAllFilesMeta = true;
739  fAlreadyUnwgt = false;
740 
741  fIncludeVtxt = false;
742 
743  this->SetDefaults();
744  this->ResetCurrent();
745 }
GSimpleNtpAux * fCurAux
current "aux" branch extra info
Int_t fIFileNumber
which file for the current entry
long int fNNeutrinos
number of flux neutrinos thrown so far
GSimpleNtpMeta * fCurMeta
current meta data
long int fIUse
current # of times an entry has been used
double fSumWeight
sum of weights for nus thrown so far
bool fIncludeVtxt
does fX4 include CurEntry.vtxt or 0
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool fAllFilesMeta
do all files in chain have meta data
Double_t fFilePOTs
of protons-on-target represented by all files
bool fGenWeighted
does GenerateNext() give weights?
GSimpleNtpNuMI * fCurNuMICopy
current "numi" branch extra info
#define pINFO
Definition: Messenger.h:62
long int fNEntriesUsed
number of entries read from files
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
int fNFiles
number of files in chain
double fMaxWeight
max flux neutrino weight in input file
TChain * fNuMetaTree
TTree // REF ONLY.
GSimpleNtpEntry * fCurEntry
current entry
bool fAlreadyUnwgt
are input files already unweighted
Long64_t fIEntry
current flux ntuple entry
Long64_t fNEntries
number of flux ntuple entries
GSimpleNtpAux * fCurAuxCopy
current "aux" branch extra info
long int fNUse
how often to use same entry in a row
GSimpleNtpEntry * fCurEntryCopy
current entry
double fEffPOTsPerNu
what a entry is worth ...
string fNuFluxBranchRequest
list of requested branches "entry,numi,au"
bool fEnd
end condition reached
double fMaxEv
maximum energy
double fAccumPOTs
POTs used so far.
TChain * fNuFluxTree
TTree // REF ONLY.
void GSimpleNtpFlux::LoadBeamSimData ( const std::vector< string > &  filenames,
const std::string det_loc 
)
virtual

first is primary method for loading root flux ntuple files and config others are alternatives that can be overloaded but have sensible defaults to fall back to calling the vector version

Implements genie::flux::GFluxFileConfigI.

Definition at line 374 of file GSimpleNtpFlux.cxx.

376 {
377 // Loads a beam simulation root file into the GSimpleNtpFlux driver.
378 
379  fNuFluxFilePatterns = patterns;
380  std::vector<int> nfiles_from_pattern;
381 
382  // create a (sorted) set of file names
383  // this also helps ensure that the same file isn't listed multiple times
384  std::set<std::string> fnames;
385 
386  LOG("Flux", pINFO) << "LoadBeamSimData was passed " << patterns.size()
387  << " patterns";
388 
389  for (size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
390  string pattern = patterns[ipatt];
391  nfiles_from_pattern.push_back(0);
392  LOG("Flux", pINFO)
393  << "Loading flux tree from ROOT file pattern ["
394  << std::setw(3) << ipatt << "] \"" << pattern << "\"";
395 
396  // !WILDCARD only works for file name ... NOT directory
397  string dirname = gSystem->UnixPathName(gSystem->WorkingDirectory());
398  size_t slashpos = pattern.find_last_of("/");
399  size_t fbegin;
400  if ( slashpos != std::string::npos ) {
401  dirname = pattern.substr(0,slashpos);
402  LOG("Flux", pDEBUG) << "Look for flux using directory " << dirname;
403  fbegin = slashpos + 1;
404  } else { fbegin = 0; }
405 
406  void* dirp = gSystem->OpenDirectory(gSystem->ExpandPathName(dirname.c_str()));
407  if ( dirp ) {
409  pattern.substr(fbegin,pattern.size()-fbegin);
410  TRegexp re(basename.c_str(),kTRUE);
411  const char* onefile;
412  while ( ( onefile = gSystem->GetDirEntry(dirp) ) ) {
413  TString afile = onefile;
414  if ( afile=="." || afile==".." ) continue;
415  if ( basename!=afile && afile.Index(re) == kNPOS ) continue;
416  std::string fullname = dirname + "/" + afile.Data();
417  fnames.insert(fullname);
418  nfiles_from_pattern[ipatt]++;
419  }
420  gSystem->FreeDirectory(dirp);
421  } // legal directory
422  } // loop over patterns
423 
424  size_t indx = 0;
425  std::set<string>::const_iterator sitr = fnames.begin();
426  for ( ; sitr != fnames.end(); ++sitr, ++indx) {
427  string filename = *sitr;
428  //std::cout << " [" << std::setw(3) << indx << "] \""
429  // << filename << "\"" << std::endl;
430  bool isok = true;
431  // this next test only works for local files, so we can't do that
432  // if we want to stream via xrootd
433  // ! (gSystem->AccessPathName(filename.c_str()));
434  if ( ! isok ) continue;
435  // open the file to see what it contains
436  LOG("Flux", pINFO) << "Load file " << filename;
437 
438  TFile* tf = TFile::Open(filename.c_str(),"READ");
439  TTree* etree = (TTree*)tf->Get("flux");
440  if ( etree ) {
441  TTree* mtree = (TTree*)tf->Get("meta");
442  // add the file to the chain
443  LOG("Flux", pDEBUG) << "AddFile " << filename
444  << " etree " << etree << " meta " << mtree;
445  this->AddFile(etree,mtree,filename);
446 
447  } // found a GSimpleNtpEntry "flux" tree
448  tf->Close();
449  delete tf;
450  } // loop over sorted file names
451 
452  // this will open all files and read headers!!
453  fNEntries = fNuFluxTree->GetEntries();
454 
455  if ( fNEntries == 0 ) {
456  LOG("Flux", pERROR)
457  << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
458  LOG("Flux", pERROR)
459  << "Loaded flux tree contains " << fNEntries << " entries";
460  LOG("Flux", pERROR)
461  << "Was passed the file patterns: ";
462  for (size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
463  string pattern = patterns[ipatt];
464  LOG("Flux", pERROR)
465  << " [" << std::setw(3) << ipatt <<"] " << pattern;
466  }
467  LOG("Flux", pERROR)
468  << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
469  } else {
470  LOG("Flux", pNOTICE)
471  << "Loaded flux tree contains " << fNEntries << " entries"
472  << " from " << fnames.size() << " unique files";
473  for (size_t ipatt = 0; ipatt < patterns.size(); ++ipatt ) {
474  string pattern = patterns[ipatt];
475  LOG("Flux", pINFO)
476  << " pattern: " << pattern << " yielded "
477  << nfiles_from_pattern[ipatt] << " files";
478  }
479  }
480 
481  int sba_status[3] = { -999, -999, -999 };
482  // "entry" branch isn't optional ... contains the neutrino info
483 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
484  sba_status[0] =
485 #endif
486  fNuFluxTree->SetBranchAddress("entry",&fCurEntry);
487 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
488  if ( sba_status[0] < 0 ) {
489  LOG("Flux", pFATAL)
490  << "flux chain has no \"entry\" branch " << sba_status[0];
491  assert(0);
492  }
493 #endif
494  //TBranch* bentry = fNuFluxTree->GetBranch("entry");
495  //bentry->SetAutoDelete(false);
496 
497  if ( OptionalAttachBranch("numi") ) {
498 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
499  sba_status[1] =
500 #endif
501  fNuFluxTree->SetBranchAddress("numi",&fCurNuMI);
502  //TBranch* bnumi = fNuFluxTree->GetBranch("numi");
503  //bnumi->SetAutoDelete(false);
504  } else { delete fCurNuMI; fCurNuMI = 0; }
505 
506  if ( OptionalAttachBranch("aux") ) {
507 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
508  sba_status[2] =
509 #endif
510  fNuFluxTree->SetBranchAddress("aux",&fCurAux);
511  //TBranch* baux = fNuFluxTree->GetBranch("aux");
512  //baux->SetAutoDelete(false);
513  } else { delete fCurAux; fCurAux = 0; }
514 
515  LOG("Flux", pDEBUG)
516  << " SetBranchAddress status: "
517  << " \"entry\"=" << sba_status[0]
518  << " \"numi\"=" << sba_status[1]
519  << " \"aux\"=" << sba_status[2];
520 
521  // attach requested branches
522 
523  if (fMaxWeight<=0) {
524  LOG("Flux", pDEBUG)
525  << "Run ProcessMeta() as part of LoadBeamSimData";
526  this->ProcessMeta();
527  }
528 
529  // current ntuple cycle # (flux ntuples may be recycled)
530  fICycle = 0;
531  // pick a starting entry index [0:fNEntries-1]
532  // pretend we just used up the the previous one
534  fIUse = 9999999;
535  fIEntry = rnd->RndFlux().Integer(fNEntries) - 1;
536  if ( config.find("no-offset-index") != string::npos ) {
537  LOG("Flux",pINFO) << "Config saw \"no-offset-index\"";
538  fIEntry = -1;
539  }
540  LOG("Flux",pINFO) << "Start with entry fIEntry=" << fIEntry;
541 
542  // don't count things we used to estimate max weight
543  fNEntriesUsed = 0;
544  fSumWeight = 0;
545  fNNeutrinos = 0;
546  fAccumPOTs = 0;
547 
548  LOG("Flux",pDEBUG) << "about to CalcEffPOTsPerNu";
549  this->CalcEffPOTsPerNu();
550 
551 }
GSimpleNtpAux * fCurAux
current "aux" branch extra info
std::vector< string > fNuFluxFilePatterns
(potentially wildcarded) path(s)
long int fNNeutrinos
number of flux neutrinos thrown so far
void AddFile(TTree *fluxtree, TTree *metatree, string fname)
#define pERROR
Definition: Messenger.h:59
long int fIUse
current # of times an entry has been used
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
double fSumWeight
sum of weights for nus thrown so far
std::string string
Definition: nybbler.cc:12
#define pFATAL
Definition: Messenger.h:56
intermediate_table::const_iterator const_iterator
Definition: tf_graph.h:23
string filename
Definition: train.py:213
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
void ProcessMeta(void)
scan for max flux energy, weight
bool OptionalAttachBranch(std::string bname)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static Config * config
Definition: config.cpp:1054
#define pINFO
Definition: Messenger.h:62
long int fNEntriesUsed
number of entries read from files
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
double fMaxWeight
max flux neutrino weight in input file
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
GSimpleNtpEntry * fCurEntry
current entry
Long64_t fIEntry
current flux ntuple entry
Long64_t fNEntries
number of flux ntuple entries
std::string pattern
Definition: regex_t.cc:35
#define pNOTICE
Definition: Messenger.h:61
TRandom3 & RndFlux(void) const
rnd number generator used by flux drivers
Definition: RandomGen.h:71
double fAccumPOTs
POTs used so far.
TChain * fNuFluxTree
TTree // REF ONLY.
#define pDEBUG
Definition: Messenger.h:63
double genie::flux::GSimpleNtpFlux::MaxEnergy ( void  )
inlinevirtual

declare the max flux neutrino energy that can be generated (for init. purposes)

Implements genie::GFluxI.

Definition at line 213 of file GSimpleNtpFlux.h.

213 { return fMaxEv; }
double fMaxEv
maximum energy
const TLorentzVector& genie::flux::GSimpleNtpFlux::Momentum ( void  )
inlinevirtual

returns the flux neutrino 4-momentum

Implements genie::GFluxI.

Definition at line 217 of file GSimpleNtpFlux.h.

217 { return fP4; }
TLorentzVector fP4
reconstituted p4 vector
void GSimpleNtpFlux::MoveToZ0 ( double  z0)

move ray origin to user coord Z0

Definition at line 322 of file GSimpleNtpFlux.cxx.

323 {
324  // move ray origin to specified user z0
325  // move beam coord entry correspondingly
326 
327  double pzusr = fP4.Pz();
328  if ( TMath::Abs(pzusr) < 1.0e-30 ) {
329  // neutrino is moving almost entirely in x-y plane
330  LOG("Flux", pWARN)
331  << "MoveToZ0(" << z0usr << ") not possible due to pz_usr (" << pzusr << ")";
332  return;
333  }
334 
335  double scale = (z0usr - fX4.Z()) / pzusr;
336  //LOG("Flux",pDEBUG)
337  // << "MoveToZ0: before x4=(" << fX4.X() << "," << fX4.Y() << "," << fX4.Z()
338  // << ") z0=" << z0usr << " pzusr=" << pzusr
339  // << " p4=(" << fP4.Px() << "," << fP4.Py() << "," << fP4.Pz() << ")";
340  fX4 += (scale*fP4);
341  //LOG("Flux",pDEBUG)
342  // << "MoveToZ0: after (" << fX4.X() << "," << fX4.Y() << "," << fX4.Z()
343  // << ")";
344 
345  // this scaling works for distances, but not the time component
346  fX4.SetT(0);
347 
348 }
const double e
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TLorentzVector fX4
reconstituted position vector
#define pWARN
Definition: Messenger.h:60
TLorentzVector fP4
reconstituted p4 vector
long int genie::flux::GSimpleNtpFlux::NEntriesUsed ( void  ) const
inline

number of entries read from files

Definition at line 260 of file GSimpleNtpFlux.h.

long int GSimpleNtpFlux::NFluxNeutrinos ( void  ) const
virtual

of rays generated

< number of flux neutrinos looped so far

Implements genie::flux::GFluxExposureI.

Definition at line 83 of file GSimpleNtpFlux.cxx.

84 {
85  ///< number of flux neutrinos looped so far
86  return fNNeutrinos;
87 }
long int fNNeutrinos
number of flux neutrinos thrown so far
bool GSimpleNtpFlux::OptionalAttachBranch ( std::string  bname)
private

Definition at line 816 of file GSimpleNtpFlux.cxx.

817 {
818 
819  if ( fNuFluxBranchRequest.find(name) == string::npos ) {
820  LOG("Flux", pINFO)
821  << "no request for \"" << name <<"\" branch ";
822  return false;
823  }
824 
825  if ( ( fNuFluxTree->GetBranch(name.c_str()) ) ) return true;
826 
827  LOG("Flux", pINFO)
828  << "no \"" << name << "\" branch in the \"flux\" tree";
829  return false;
830 }
static QCString name
Definition: declinfo.cpp:673
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
string fNuFluxBranchRequest
list of requested branches "entry,numi,au"
TChain * fNuFluxTree
TTree // REF ONLY.
int genie::flux::GSimpleNtpFlux::PdgCode ( void  )
inlinevirtual

returns the flux neutrino pdg code

Implements genie::GFluxI.

Definition at line 215 of file GSimpleNtpFlux.h.

215 { return fCurEntry->pdg; }
GSimpleNtpEntry * fCurEntry
current entry
const TLorentzVector& genie::flux::GSimpleNtpFlux::Position ( void  )
inlinevirtual

returns the flux neutrino 4-position (note: expect SI rather than physical units)

Implements genie::GFluxI.

Definition at line 218 of file GSimpleNtpFlux.h.

218 { return fX4; }
TLorentzVector fX4
reconstituted position vector
void GSimpleNtpFlux::PrintConfig ( void  )
virtual

print the current configuration

Implements genie::flux::GFluxFileConfigI.

Definition at line 1065 of file GSimpleNtpFlux.cxx.

1066 {
1067 
1068  std::ostringstream s;
1069  PDGCodeList::const_iterator itr = fPdgCList->begin();
1070  for ( ; itr != fPdgCList->end(); ++itr) s << (*itr) << " ";
1071  s << "[rejected: ";
1072  itr = fPdgCListRej->begin();
1073  for ( ; itr != fPdgCListRej->end(); ++itr) s << (*itr) << " ";
1074  s << " ] ";
1075 
1076  std::ostringstream fpattout;
1077  for (size_t i = 0; i < fNuFluxFilePatterns.size(); ++i)
1078  fpattout << "\n [" << std::setw(3) << i << "] " << fNuFluxFilePatterns[i];
1079 
1080  std::ostringstream flistout;
1081  std::vector<std::string> flist = GetFileList();
1082  for (size_t i = 0; i < flist.size(); ++i)
1083  flistout << "\n [" << std::setw(3) << i << "] " << flist[i];
1084 
1085  LOG("Flux", pNOTICE)
1086  << "GSimpleNtpFlux Config:"
1087  << "\n Enu_max " << fMaxEv
1088  << "\n pdg-codes: " << s.str() << "\n "
1089  << "\"flux\" " << fNEntries << " entries, "
1090  << "\"meta\" " << fNFiles << " entries"
1091  << " (FilePOTs " << fFilePOTs << ") in files:"
1092  << flistout.str()
1093  << "\n from file patterns: "
1094  << fpattout.str()
1095  << "\n wgt max=" << fMaxWeight
1096  << "\n Z0 pushback " << fZ0
1097  << "\n used entry " << fIEntry << " " << fIUse << "/" << fNUse
1098  << " times, in " << fICycle << "/" << fNCycles << " cycles"
1099  << "\n SumWeight " << fSumWeight << " for " << fNNeutrinos << " neutrinos"
1100  << " with " << fNEntriesUsed << " entries read"
1101  << "\n EffPOTsPerNu " << fEffPOTsPerNu << " AccumPOTs " << fAccumPOTs
1102  << "\n GenWeighted \"" << (fGenWeighted?"true":"false") << "\""
1103  << " AlreadyUnwgt \"" << (fAlreadyUnwgt?"true":"false") << "\""
1104  << " AllFilesMeta \"" << (fAllFilesMeta?"true":"false") << "\"";
1105 
1106 }
std::vector< string > fNuFluxFilePatterns
(potentially wildcarded) path(s)
long int fNNeutrinos
number of flux neutrinos thrown so far
long int fIUse
current # of times an entry has been used
double fSumWeight
sum of weights for nus thrown so far
intermediate_table::const_iterator const_iterator
PDGCodeList * fPdgCList
list of neutrino pdg-codes to generate
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...
Definition: Messenger.h:96
bool fAllFilesMeta
do all files in chain have meta data
Double_t fFilePOTs
of protons-on-target represented by all files
bool fGenWeighted
does GenerateNext() give weights?
long int fNEntriesUsed
number of entries read from files
long int fNCycles
times to cycle through the ntuple(s)
int fNFiles
number of files in chain
double fMaxWeight
max flux neutrino weight in input file
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
PDGCodeList * fPdgCListRej
list of nu pdg-codes seen but rejected
bool fAlreadyUnwgt
are input files already unweighted
Long64_t fIEntry
current flux ntuple entry
Long64_t fNEntries
number of flux ntuple entries
long int fNUse
how often to use same entry in a row
double fEffPOTsPerNu
what a entry is worth ...
#define pNOTICE
Definition: Messenger.h:61
double fMaxEv
maximum energy
double fAccumPOTs
POTs used so far.
static QCString * s
Definition: config.cpp:1042
void GSimpleNtpFlux::PrintCurrent ( void  )

print current entry from leaves

Definition at line 669 of file GSimpleNtpFlux.cxx.

670 {
671  LOG("Flux", pNOTICE) << "CurrentEntry:" << *fCurEntry;
672 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
GSimpleNtpEntry * fCurEntry
current entry
#define pNOTICE
Definition: Messenger.h:61
void GSimpleNtpFlux::ProcessMeta ( void  )

scan for max flux energy, weight

Definition at line 583 of file GSimpleNtpFlux.cxx.

584 {
585 
586  fAlreadyUnwgt = false;
587  fFilePOTs = 0;
588  double minwgt = +1.0e10;
589  double maxwgt = -1.0e10;
590  double maxenu = 0.0;
591 
592  // PDGLibrary* pdglib = PDGLibrary::Instance(); // get initialized now
593 
594  if ( fAllFilesMeta ) {
595  fNuMetaTree->SetBranchAddress("meta",&fCurMeta);
596 #ifdef USE_INDEX_FOR_META
597  int nindices = fNuMetaTree->BuildIndex("metakey"); // key used to tie entries to meta data
598  LOG("Flux", pDEBUG) << "ProcessMeta() BuildIndex nindices " << nindices;
599 #endif
600  int nmeta = fNuMetaTree->GetEntries();
601  for (int imeta = 0; imeta < nmeta; ++imeta ) {
602  fNuMetaTree->GetEntry(imeta);
603 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
604  LOG("Flux", pNOTICE) << "ProcessMeta() ifile " << imeta
605  << " (of " << fNFiles
606  << ") " << *fCurMeta;
607 #endif
608  minwgt = TMath::Min(minwgt,fCurMeta->minWgt);
609  maxwgt = TMath::Max(maxwgt,fCurMeta->maxWgt);
610  maxenu = TMath::Max(maxenu,fCurMeta->maxEnergy);
611  fFilePOTs += fCurMeta->protons;
612  for (size_t i = 0; i < fCurMeta->pdglist.size(); ++i)
613  fPdgCList->push_back(fCurMeta->pdglist[i]);
614  }
615  if ( minwgt == 1.0 && maxwgt == 1.0 ) fAlreadyUnwgt = true;
616  fMaxWeight = maxwgt;
617  this->SetMaxEnergy(maxenu);
618 
619  } else {
620  //
621  LOG("Flux", pFATAL) << "ProcessMeta() not all files have metadata";
622  // for now PUNT ... eventually could scan all the entries
623  }
624 
625 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
626  LOG("Flux", pNOTICE) << "ProcessMeta() Maximum flux weight = " << fMaxWeight
627  << ", energy = " << fMaxEv
628  << ", AlreadyUnwgt=" << (fAlreadyUnwgt?"true":"false");
629 #endif
630 
631  fCurMeta->Reset();
632  fIFileNumber = -999;
633 
634 }
Int_t fIFileNumber
which file for the current entry
GSimpleNtpMeta * fCurMeta
current meta data
#define pFATAL
Definition: Messenger.h:56
PDGCodeList * fPdgCList
list of neutrino pdg-codes to generate
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool fAllFilesMeta
do all files in chain have meta data
Double_t fFilePOTs
of protons-on-target represented by all files
void SetMaxEnergy(double Ev)
specify maximum flx neutrino energy
int fNFiles
number of files in chain
double fMaxWeight
max flux neutrino weight in input file
TChain * fNuMetaTree
TTree // REF ONLY.
bool fAlreadyUnwgt
are input files already unweighted
#define pNOTICE
Definition: Messenger.h:61
double fMaxEv
maximum energy
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
#define pDEBUG
Definition: Messenger.h:63
void GSimpleNtpFlux::ResetCurrent ( void  )
private

Definition at line 760 of file GSimpleNtpFlux.cxx.

761 {
762 // reset running values of neutrino pdg-code, 4-position & 4-momentum
763 // and the input ntuple leaves
764 
765  if (fCurEntry) fCurEntry->Reset();
766  if (fCurNuMI) fCurNuMI->Reset();
767  if (fCurAux) fCurAux->Reset();
768  //allow caching//if (fCurMeta) fCurMeta->Reset();
769 }
GSimpleNtpAux * fCurAux
current "aux" branch extra info
GSimpleNtpNuMI * fCurNuMI
current "numi" branch extra info
GSimpleNtpEntry * fCurEntry
current entry
void genie::flux::GSimpleNtpFlux::ScanMeta ( void  )
private
void GSimpleNtpFlux::SetDefaults ( void  )
private

Definition at line 747 of file GSimpleNtpFlux.cxx.

748 {
749 
750 // - Set the default flux neutrino start z position at use flux window
751 // - Set number of cycles to 1
752 
753  LOG("Flux", pINFO) << "Setting default GSimpleNtpFlux driver options";
754 
755  this->SetUpstreamZ (-3.4e38); // way upstream ==> use flux window
756  this->SetNumOfCycles (0);
757  this->SetEntryReuse (1);
758 }
void SetEntryReuse(long int nuse=1)
of times to use entry before moving to next
virtual void SetNumOfCycles(long int ncycle)
limit cycling through input files
virtual void SetUpstreamZ(double z0)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
void GSimpleNtpFlux::SetEntryReuse ( long int  nuse = 1)

of times to use entry before moving to next

Definition at line 644 of file GSimpleNtpFlux.cxx.

645 {
646 // With nuse > 1 then the same entry in the file is used "nuse" times
647 // before moving on to the next entry in the ntuple
648 
649  fNUse = TMath::Max(1L, nuse);
650 }
long int fNUse
how often to use same entry in a row
void genie::flux::GSimpleNtpFlux::SetGenWeighted ( bool  genwgt = false)
inline

toggle whether GenerateNext() returns weight=1 flux (initial default false)

Definition at line 287 of file GSimpleNtpFlux.h.

void genie::flux::GSimpleNtpFlux::SetIncludeVtxt ( bool  it = true)

should X4 include CurEntry.vtxt

void GSimpleNtpFlux::SetMaxEnergy ( double  Ev)

specify maximum flx neutrino energy

Definition at line 636 of file GSimpleNtpFlux.cxx.

637 {
638  fMaxEv = TMath::Max(0.,Ev);
639 
640  LOG("Flux", pINFO)
641  << "Declared maximum flux neutrino energy: " << fMaxEv;
642 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
double fMaxEv
maximum energy
void genie::flux::GSimpleNtpFlux::SetRequestedBranchList ( string  blist = "entry,numi,aux")
inline

Definition at line 283 of file GSimpleNtpFlux.h.

283 { fNuFluxBranchRequest = blist; }
string fNuFluxBranchRequest
list of requested branches "entry,numi,au"
double genie::flux::GSimpleNtpFlux::SumWeight ( void  ) const
inline

integrated weight for flux neutrinos looped so far

Definition at line 261 of file GSimpleNtpFlux.h.

double GSimpleNtpFlux::UsedPOTs ( void  ) const

of protons-on-target used

Definition at line 361 of file GSimpleNtpFlux.cxx.

362 {
363 // Compute current number of flux POTs
364 
365  if (!fNuFluxTree) {
366  LOG("Flux", pWARN)
367  << "The flux driver has not been properly configured";
368  return 0;
369  }
370  return fAccumPOTs;
371 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pWARN
Definition: Messenger.h:60
double fAccumPOTs
POTs used so far.
TChain * fNuFluxTree
TTree // REF ONLY.
double genie::flux::GSimpleNtpFlux::Weight ( void  )
inlinevirtual

returns the flux neutrino weight (if any)

Implements genie::GFluxI.

Definition at line 216 of file GSimpleNtpFlux.h.

216 { return fWeight; }
double fWeight
current neutrino weight

Member Data Documentation

double genie::flux::GSimpleNtpFlux::fAccumPOTs
private

POTs used so far.

Definition at line 335 of file GSimpleNtpFlux.h.

bool genie::flux::GSimpleNtpFlux::fAllFilesMeta
private

do all files in chain have meta data

Definition at line 340 of file GSimpleNtpFlux.h.

bool genie::flux::GSimpleNtpFlux::fAlreadyUnwgt
private

are input files already unweighted

Definition at line 338 of file GSimpleNtpFlux.h.

GSimpleNtpAux* genie::flux::GSimpleNtpFlux::fCurAux
private

current "aux" branch extra info

Definition at line 344 of file GSimpleNtpFlux.h.

GSimpleNtpAux* genie::flux::GSimpleNtpFlux::fCurAuxCopy
private

current "aux" branch extra info

Definition at line 351 of file GSimpleNtpFlux.h.

GSimpleNtpEntry* genie::flux::GSimpleNtpFlux::fCurEntry
private

current entry

Definition at line 342 of file GSimpleNtpFlux.h.

GSimpleNtpEntry* genie::flux::GSimpleNtpFlux::fCurEntryCopy
private

current entry

Definition at line 349 of file GSimpleNtpFlux.h.

GSimpleNtpMeta* genie::flux::GSimpleNtpFlux::fCurMeta
private

current meta data

Definition at line 347 of file GSimpleNtpFlux.h.

GSimpleNtpNuMI* genie::flux::GSimpleNtpFlux::fCurNuMI
private

current "numi" branch extra info

Definition at line 343 of file GSimpleNtpFlux.h.

GSimpleNtpNuMI* genie::flux::GSimpleNtpFlux::fCurNuMICopy
private

current "numi" branch extra info

Definition at line 350 of file GSimpleNtpFlux.h.

double genie::flux::GSimpleNtpFlux::fEffPOTsPerNu
private

what a entry is worth ...

Definition at line 334 of file GSimpleNtpFlux.h.

bool genie::flux::GSimpleNtpFlux::fEnd
private

end condition reached

Definition at line 312 of file GSimpleNtpFlux.h.

Double_t genie::flux::GSimpleNtpFlux::fFilePOTs
private

of protons-on-target represented by all files

Definition at line 324 of file GSimpleNtpFlux.h.

bool genie::flux::GSimpleNtpFlux::fGenWeighted
private

does GenerateNext() give weights?

Definition at line 337 of file GSimpleNtpFlux.h.

Long64_t genie::flux::GSimpleNtpFlux::fIEntry
private

current flux ntuple entry

Definition at line 321 of file GSimpleNtpFlux.h.

Int_t genie::flux::GSimpleNtpFlux::fIFileNumber
private

which file for the current entry

Definition at line 322 of file GSimpleNtpFlux.h.

bool genie::flux::GSimpleNtpFlux::fIncludeVtxt
private

does fX4 include CurEntry.vtxt or 0

Definition at line 353 of file GSimpleNtpFlux.h.

long int genie::flux::GSimpleNtpFlux::fIUse
private

current # of times an entry has been used

Definition at line 330 of file GSimpleNtpFlux.h.

double genie::flux::GSimpleNtpFlux::fMaxEv
private

maximum energy

Definition at line 311 of file GSimpleNtpFlux.h.

double genie::flux::GSimpleNtpFlux::fMaxWeight
private

max flux neutrino weight in input file

Definition at line 327 of file GSimpleNtpFlux.h.

Long64_t genie::flux::GSimpleNtpFlux::fNEntries
private

number of flux ntuple entries

Definition at line 320 of file GSimpleNtpFlux.h.

long int genie::flux::GSimpleNtpFlux::fNEntriesUsed
private

number of entries read from files

Definition at line 333 of file GSimpleNtpFlux.h.

int genie::flux::GSimpleNtpFlux::fNFiles
private

number of files in chain

Definition at line 319 of file GSimpleNtpFlux.h.

long int genie::flux::GSimpleNtpFlux::fNNeutrinos
private

number of flux neutrinos thrown so far

Definition at line 332 of file GSimpleNtpFlux.h.

string genie::flux::GSimpleNtpFlux::fNuFluxBranchRequest
private

list of requested branches "entry,numi,au"

Definition at line 315 of file GSimpleNtpFlux.h.

std::vector<string> genie::flux::GSimpleNtpFlux::fNuFluxFilePatterns
private

(potentially wildcarded) path(s)

Definition at line 314 of file GSimpleNtpFlux.h.

TChain* genie::flux::GSimpleNtpFlux::fNuFluxTree
private

TTree // REF ONLY.

Definition at line 316 of file GSimpleNtpFlux.h.

TChain* genie::flux::GSimpleNtpFlux::fNuMetaTree
private

TTree // REF ONLY.

Definition at line 317 of file GSimpleNtpFlux.h.

long int genie::flux::GSimpleNtpFlux::fNUse
private

how often to use same entry in a row

Definition at line 329 of file GSimpleNtpFlux.h.

TLorentzVector genie::flux::GSimpleNtpFlux::fP4
private

reconstituted p4 vector

Definition at line 345 of file GSimpleNtpFlux.h.

double genie::flux::GSimpleNtpFlux::fSumWeight
private

sum of weights for nus thrown so far

Definition at line 331 of file GSimpleNtpFlux.h.

double genie::flux::GSimpleNtpFlux::fWeight
private

current neutrino weight

Definition at line 326 of file GSimpleNtpFlux.h.

TLorentzVector genie::flux::GSimpleNtpFlux::fX4
private

reconstituted position vector

Definition at line 346 of file GSimpleNtpFlux.h.


The documentation for this class was generated from the following files: