Functions | Variables
dump_event.C File Reference
#include "TBox.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH2.h"
#include "TSystem.h"
#include "stdio.h"
#include "LEM/func/Library.h"
#include <iostream>

Go to the source code of this file.

Functions

void draw_event (TCanvas *theCanvas, TH2F *h[2], const MatchableEvent &sum)
 
void printEventToJson (const MatchableEvent sum, FILE *, int idx=0)
 
void dump_event (TString libPath, int idx=0, const char *outfile_name=NULL, bool draw=true, bool flipEven=false, bool flipOdd=false, bool idxs=false)
 
void next_event ()
 
void dump_lib (int start=1, int nEvts=1, const char *outfile_name=NULL, bool draw=false)
 

Variables

int evt_idx =0
 
FILE * outfile =NULL
 

Function Documentation

void draw_event ( TCanvas *  theCanvas,
TH2F *  h[2],
const MatchableEvent sum 
)

Definition at line 76 of file dump_event.C.

References b, lem::kVertexCell, lem::kVertexPlane, lem::EventSummary::trueVtxCell, lem::EventSummary::trueVtxCellOther, lem::EventSummary::trueVtxPlane, and registry_explorer::v.

Referenced by adjusttick(), animation_step(), draw_whole_user_event(), dump_event(), and toggle_cum_ani().

76  {
77  for(int v = 0; v < 2; ++v){
78  theCanvas->cd(v+1);
79  h[v]->Draw("colz");
80 
81  TBox* b = new TBox(lem::kVertexPlane, lem::kVertexCell,
83  b->SetLineColor(kRed);
84  b->SetFillStyle(0);
85  b->SetLineWidth(2);
86  b->SetLineStyle(7);
87  b->Draw();
88 
89  const int trueCell = (sum.trueVtxPlane%2 == v) ? sum.trueVtxCellOther : sum.trueVtxCell;
90  TBox* b2 = new TBox(sum.trueVtxPlane, trueCell,
91  sum.trueVtxPlane+1, trueCell+1);
92  b2->SetLineColor(kGreen+2);
93  b2->SetFillStyle(0);
94  b2->SetLineWidth(2);
95  b2->SetLineStyle(7);
96  b2->Draw();
97  }
98 }
const int kVertexPlane
Definition: EventSummary.h:22
const int kVertexCell
Definition: EventSummary.h:23
const hit & b
Definition: hits.cxx:21
void dump_event ( TString  libPath,
int  idx = 0,
const char *  outfile_name = NULL,
bool  draw = true,
bool  flipEven = false,
bool  flipOdd = false,
bool  idxs = false 
)

Definition at line 18 of file dump_event.C.

References draw_event(), lem::Library::Event(), evt_idx, lem::EventSummary::FillHists(), lem::Library::FromMMap(), make_syst_table_plots::h, MECModelEnuComparisons::i, compare_h5_caf::idx, allTimeWatchdog::index, outfile, printEventToJson(), make_template_knob_config::stdout, and sum.

Referenced by dump_lib(), and next_event().

19 {
20  static Library* lib = NULL;
21  static TCanvas* theCanvas = NULL;
22  static int views = 2;
23  static TH2F* h[2] = {NULL,NULL};
24  long long int index=idx;
25  evt_idx=idx;
26 
27  //FILE* outfile=NULL;
28 
29  if(outfile==NULL){
30  if(outfile_name!=NULL){
31  outfile = fopen(outfile_name,"w");
32  }else{
33  outfile = stdout;
34  }
35  }
36 
37  // Map the Library File if we haven't already mapped it
38  if(lib==NULL){
39  // Open the Library via Memory Map
40  lib = Library::FromMMap(libPath.Data(), false);
41  }
42 
43  // Create a Canvase for drawing the events
44  if(theCanvas==NULL){
45  theCanvas = new TCanvas("a", "b", 1200, 600);
46  theCanvas->Divide(2, 1);
47  }
48 
49  // Retrieve the template from the library
50  const MatchableEvent& sum = lib->Event(idx);
51 
52  printEventToJson(sum,outfile,index); // Write the event out in JSon
53 
54  if(draw){
55 
56  // Book the histograms for drawing the event or clear them if they exist
57  if(h[0]==NULL){
58  for(int i=0; i<2; ++i){
59  h[i] = new TH2F("", ";plane;cell", 128, 0, 128, 128, 64, 192);
60  } // endfor
61  }else{
62  for(int i=0; i<2; ++i){
63  // Clear/Reset the Histograms
64  h[i]->Reset();
65  } // endfor
66  } //endif
67 
68  // Fill the histograms (even view first, then the odd view)
69  sum.FillHists(h[0], h[1], flipEven, flipOdd, idxs);
70 
71  draw_event(theCanvas, h, sum); // Draw the Event in question
72  }
73 
74 };
void draw_event(TCanvas *theCanvas, TH2F *h[2], const MatchableEvent &sum)
Definition: dump_event.C:76
Attach some information used in matching to an EventSummary.
Collection of events for matching.
Definition: Library.h:18
Definition: __init__.py:1
int evt_idx
Definition: dump_event.C:12
const MatchableEvent & Event(int i) const
Definition: Library.h:32
Double_t sum
Definition: plot.C:31
void printEventToJson(const MatchableEvent sum, FILE *, int idx=0)
Definition: dump_event.C:100
void FillHists(TH2 *h1, TH2 *h2, bool flipEven=false, bool flipOdd=false, bool idxs=false) const
FILE * outfile
Definition: dump_event.C:13
void dump_lib ( int  start = 1,
int  nEvts = 1,
const char *  outfile_name = NULL,
bool  draw = false 
)

Definition at line 138 of file dump_event.C.

References dump_event(), fclose(), MECModelEnuComparisons::i, nEvts, outfile, febshutoff_auto::start, and make_template_knob_config::stdout.

138  {
139 
140  // Close any open output files
141  if(outfile!=NULL){
142  fclose(outfile);
143  outfile==NULL;
144  }
145 
146  // Open a new file for output
147  if(outfile_name!=NULL){
148  outfile = fopen(outfile_name,"w");
149  }else{
150  outfile = stdout;
151  }
152 
153  fprintf(outfile,"{ \"Library\": [");
154  for(int i=start; i<(start+nEvts); ++i){
155  dump_event("",i,outfile_name,false);
156  if(i!=(start+nEvts-1)){
157  fprintf(outfile,",\n");
158  }
159  }
160  fprintf(outfile,"]\n }\n");
161  fflush(outfile);
162  fclose(outfile);
163  outfile=NULL;
164  return;
165 };
void dump_event(TString libPath, int idx=0, const char *outfile_name=NULL, bool draw=true, bool flipEven=false, bool flipOdd=false, bool idxs=false)
Definition: dump_event.C:18
unsigned int nEvts
fclose(fg1)
FILE * outfile
Definition: dump_event.C:13
void next_event ( )

Definition at line 132 of file dump_event.C.

References dump_event(), and evt_idx.

132  {
133  evt_idx++;
134  dump_event("",evt_idx);
135 };
void dump_event(TString libPath, int idx=0, const char *outfile_name=NULL, bool draw=true, bool flipEven=false, bool flipOdd=false, bool idxs=false)
Definition: dump_event.C:18
int evt_idx
Definition: dump_event.C:12
void printEventToJson ( const MatchableEvent  sum,
FILE *  theOutput,
int  idx = 0 
)

Definition at line 100 of file dump_event.C.

References lem::EventSummary::ccnc, getBrightness::cell, lem::LiteHit::Cell(), energy, lem::EventSummary::hits, MECModelEnuComparisons::i, lem::EventSummary::mode, lem::EventSummary::nhits, lem::EventSummary::nParts, lem::EventSummary::partPdgs, lem::EventSummary::pdg, lem::LiteHit::pecorr, lem::EventSummary::photE0, lem::EventSummary::photE1, lem::EventSummary::photL0, lem::EventSummary::photL1, lem::LiteHit::Plane(), NDAPDHVSetting::plane, lem::EventSummary::totalPE, lem::EventSummary::trueEVis, and POTSpillRate::view.

Referenced by dump_event().

100  {
101 
102  // Print out the event's information
103  fprintf(theOutput,"{\"Event\": { \n\"EventID\": %lld,\n",index);
104  fprintf(theOutput," \"Truth\": {\n");
105  fprintf(theOutput," \"PE\": %2.2f ,\n" ,sum.totalPE);
106  fprintf(theOutput," \"VisE\": %2.2f ,\n" ,sum.trueEVis);
107  fprintf(theOutput," \"CC\": %d ,\n" ,sum.ccnc);
108  fprintf(theOutput," \"PDG\": %d ,\n" ,sum.pdg);
109  fprintf(theOutput," \"Mode\": %d ,\n" ,sum.mode);
110  fprintf(theOutput," \"PhotonL\": [ %2.2f, %2.2f ],\n",sum.photL0,sum.photL1);
111  fprintf(theOutput," \"PhotonE\": [ %2.2f, %2.2f ],\n",sum.photE0,sum.photE1);
112 
113  fprintf(theOutput," \"ParticlesPDG\": [ ");
114  for(int i=0; i< sum.nParts; ++i){
115  fprintf(theOutput,"%d,",sum.partPdgs[i]);
116  }
117  fprintf(theOutput," ]\n },\n");
118  fprintf(theOutput," \"NHits\": %d,\n",sum.nhits);
119  fprintf(theOutput," \"HitList\": [\n");
120  for(unsigned int i =0; i<sum.nhits; ++i){
121  if(i!=0){fprintf(theOutput,",\n");}
122  const int plane = sum.hits[i].Plane();
123  const int cell = sum.hits[i].Cell();
124  const int view = plane%2;
125  const float energy = sum.hits[i].pecorr;
126  fprintf(theOutput," [ %3d, %3d, %3d, %7.4f ]", plane, cell, view, energy);
127  }
128  fprintf(theOutput,"\n ]\n");
129  fprintf(theOutput," }\n}\n");
130 };
unsigned short nhits
Definition: EventSummary.h:53
float pecorr
Definition: LiteHit.h:24
int Cell() const
Definition: LiteHit.h:39
int Plane() const
Definition: LiteHit.h:38
double energy
Definition: plottest35.C:25
unsigned char nParts
Definition: EventSummary.h:67

Variable Documentation

int evt_idx =0

Definition at line 12 of file dump_event.C.

Referenced by dump_event(), and next_event().

FILE* outfile =NULL

Definition at line 13 of file dump_event.C.

Referenced by add_and_normalize_LLhistos(), novaddt::Evaluation::analyze(), air::AirKalmanAna::analyze(), BestFit(), BuildMetricsTree(), BuildMetricsTree_OnMon(), BuildOldTree(), CAF_makeCAFSensitivities_for_FNEX(), cafe_FD_predictions(), CalcFiberLoopCorr(), compare_cos_numi(), ConsolidateSystMaker(), CreateKNNTrainingTrees(), d3sigma_calc(), d4sigma_calc(), d4sigma_hist(), d4sigma_plot(), demoBarChart(), demoFitContours(), demoFitSlices(), doUnfolding(), dump_event(), dump_lib(), calib::AttenFit::endJob(), energyResolution(), generate_fake_data(), get_cosmic_sample(), getHists_FNEX(), joint_fit_2017_contours(), joint_fit_2017_slices(), joint_fit_2018_contours(), joint_fit_2018_slices(), joint_fit_2019_bestfit(), joint_fit_2019_contours(), joint_fit_2019_slices(), joint_fit_future_bestfit_univ(), joint_fit_future_contour_univ(), jointsensitivity(), main(), make_BPF_Energy_Estimator_KNN_regression(), make_BPF_muon_PID_KNN(), make_DataMCComp_numu(), make_files_for_decomp_plots(), MakeCAFSensitivities_for_FNEX(), MakeISysts(), MakeNus17CosBkgd(), MakeNus18CosBkgd(), MakeNus2019CovMxSysts(), MakeSurface(), MakeSurfaceNoNDOsc(), MakeSysts(), makeXSecPlots_TemplateFit(), NDFDCVNBDTCutSelector(), neut_code_from_rootracker(), nue_fnex_vs_caf(), nue_fnex_vs_caf_noextrapolation(), evdb::ScanWindow::OpenOutputFile(), INukeNucleonCorr::OutputFiles(), plot_BEN(), readTree(), evdb::ScanFrame::Record(), reduce_the_predfile_nue_numu(), run_joint_fit_2020_bestfit(), run_joint_fit_2020_contours(), run_joint_fit_2020_slices(), sensitivity2018(), sensitivity2020(), specprod_systematics(), Tutorial2019FitContours(), Tutorial2019FitSlices(), validation(), calib::AttenuationFit::writeResults(), and fnex::Correlations::~Correlations().