Project

General

Profile

dump_gsimple_file3.C

R-3_X_Y & ROOT6 - Robert Hatcher, 04/03/2018 04:59 PM

 
1
#include "Framework/Numerical/RandomGen.h"
2
#include "Tools/Flux/GSimpleNtpFlux.h"
3
#include "Framework/Utils/UnitUtils.h"
4

    
5
#include "TSystem.h"
6
#include "TStopwatch.h"
7
#include "TLorentzVector.h"
8
#include "TNtuple.h"
9
#include "TFile.h"
10
#include "TChain.h"
11

    
12
#include <iostream>
13
#include <iomanip>
14
#include <string>
15
#include <sstream>
16
#include <set>
17

    
18
using namespace std;
19
using namespace genie;
20
using namespace genie::flux;
21

    
22
//========================================================================
23
// main routine
24

    
25
// assumes a single input file (meta-data handling)
26

    
27

    
28
void dump_gsimple_file3(string fname="gsimple_output.root",
29
                        long int nentries=10)
30
{
31
    string fluxfname(gSystem->ExpandPathName(fname.c_str()));
32
  flux::GSimpleNtpFlux* gsimplein = new GSimpleNtpFlux();
33
  gsimplein->LoadBeamSimData(fluxfname,"<<no-offset-index>>");
34
  gsimplein->SetEntryReuse(1); // don't reuse entries when dumping
35
  gsimplein->GenerateWeighted(true); // don't deweight, we want to see file entries
36
  gsimplein->SetUpstreamZ(-3e38);  // leave ray on flux window
37

    
38
  const string sepline =
39
    "========================================================================";
40

    
41
  cout << sepline << endl << flush;
42
  gsimplein->PrintConfig();
43
  cout << sepline << endl << flush;
44

    
45
  GFluxI* fdriver = dynamic_cast<GFluxI*>(gsimplein);
46

    
47
  // if unspecified do all the entries in the input file
48
  if (nentries <= 0) {
49
    // nentries = 2147483647;
50
    nentries = gsimplein->GetFluxTChain()->GetEntries();
51
  }
52

    
53
  UInt_t last_metakey = 0;
54
  for ( long int ientry = 0; ientry < nentries; ++ientry ) {
55
    fdriver->GenerateNext();
56

    
57
    const genie::flux::GSimpleNtpEntry* entry = gsimplein->GetCurrentEntry();
58
    const genie::flux::GSimpleNtpAux*   aux   = gsimplein->GetCurrentAux();
59
    const genie::flux::GSimpleNtpNuMI*  numi  = gsimplein->GetCurrentNuMI();
60

    
61
    if ( entry ) {
62
      cout << *(entry) << "\n";
63
    } else {
64
      cout << "no genie::flux::GSimpleNtpEntry\n";
65
    }
66
    if ( aux ) {
67
      cout << *(aux) << "\n";
68
    } else {
69
      cout << "no genie::flux::GSimpleNtpAux\n";
70
    }
71
    if ( numi ) {
72
      cout << *(numi) << "\n";
73
    } else {
74
      cout << "no genie::flux::GSimpleNtpNuMI\n";
75
    }
76
    cout << flush;
77

    
78
    const genie::flux::GSimpleNtpMeta* fmeta_in = gsimplein->GetCurrentMeta();
79
    if ( last_metakey != fmeta_in->metakey ) {
80
      cout << *fmeta_in << endl << flush;
81
      last_metakey = fmeta_in->metakey;
82
    }
83

    
84
  }
85

    
86
  cout << "=========================== Complete " << endl;
87

    
88
  cout << "Generated/Dumped " << nentries << " entries"
89
       << endl
90
       << gsimplein->UsedPOTs() << " POTs "
91
       << ", pulled NFluxNeutrinos " << gsimplein->NFluxNeutrinos()
92
       << endl;
93

    
94
}