GraphDrawer.cxx
Go to the documentation of this file.
2 
3 #include "CAFAna/Core/Spectrum.h"
5 
7 
8 #include "TGraph.h"
9 
10 namespace ana
11 {
12  //----------------------------------------------------------------------
13  TGraph* MakeGraph(const std::string& wildcard,
14  const Cut& cut,
15  const Var& VarX,
16  const Var& VarY,
17  const SpillCut* spillCut)
18  {
19  /// Helper class for \ref MakeGraph
20  class GraphMaker: public SpectrumLoader
21  {
22  public:
23  GraphMaker(const std::string& wildcard, const Cut& cut,
24  TGraph* gr,
25  const Var& VarX,
26  const Var& VarY)
27  : SpectrumLoader(wildcard),
28  fCut(cut),
29  fGraph(gr),
30  fVarX(VarX),
31  fVarY(VarY),
32  fNPassed(0)
33  {
34  }
35 
36  ~GraphMaker()
37  {
38  }
39 
40  void HandleRecord(caf::SRProxy* sr) override
41  {
42  if(fSpillCut && !(*fSpillCut)(&sr->spill)) return;
43  if(!fCut(sr)) return;
44 
45  ++fNPassed;
46 
47  double fX = fVarX(sr);
48  double fY = fVarY(sr);
49 
50  fGraph->SetPoint(fGraph->GetN(), fX, fY);
51 
52  }
53  protected:
54  Cut fCut;
55  TGraph* fGraph;
56  Var fVarX;
57  Var fVarY;
58  int fNPassed;
59  };
60 
61  TGraph* gr = new TGraph();
62 
63  GraphMaker maker(wildcard, cut, gr, VarX, VarY);
64  if(spillCut) maker.SetSpillCut(*spillCut);
65  maker.Go();
66 
67  return gr;
68 
69  }
70 }
caf::Proxy< caf::SRSpill > spill
Definition: SRProxy.h:2143
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
caf::StandardRecord * sr
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
TGraph * MakeGraph(const std::string &wildcard, const Cut &cut, const Var &VarX, const Var &VarY, const SpillCut *spillCut)
Get a graph with two variables when a histogram is not the best choice.
Definition: GraphDrawer.cxx:13
enum BeamMode string