hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
Loading...
Searching...
No Matches
ApOptimizationProcessor.h
Go to the documentation of this file.
1#ifndef __APOPTIMIZATION_ANAPROCESSOR_H__
2#define __APOPTIMIZATION_ANAPROCESSOR_H__
3
4// HPSTR
6#include "Particle.h"
7#include "Processor.h"
8#include "SimpEquations.h"
9#include "TreeCutSelector.h"
10#include "Vertex.h"
11#include "ZBiHistos.h"
12
13// ROOT
14#include "TBranch.h"
15#include "TEfficiency.h"
16#include "TF1.h"
17#include "TFile.h"
18#include "TGraph.h"
19#include "TGraphErrors.h"
20#include "TH1F.h"
21#include "TH2F.h"
22#include "TLorentzVector.h"
23#include "TRefArray.h"
24#include "TTree.h"
25#include "TTreeReader.h"
26#include "TVector3.h"
27
28// C++
29#include <memory>
30
31using namespace ROOT;
32
37 public:
38 ApOptimizationProcessor(const std::string& name, Process& process);
39
41
45 virtual void configure(const ParameterSet& parameters);
46
50 virtual void initialize(TTree* tree) {};
51
55 virtual bool process(IEvent* event) {};
56
60 virtual void finalize();
61
65 virtual bool process();
66
70 virtual void initialize(std::string inFilename, std::string outFilename);
71
72 // void configureGraphs(TGraph* zcutscan_zbi_g, TGraph* zcutscan_nsig_g, TGraph* zcutscan_nbkg_g, TGraph*
73 // nbkg_zbi_g,
74 // TGraph* nsig_zbi_g, std::string cutname);
75
77 double computeTruthSignalShape(double z, double EAp);
78 double computePromptYield();
79 double computeDisplacedYield(TH1* h_chi_eff, double EAp);
80
81 std::vector<double> fitZBkgTail(TH1* h_bkg_vtxz, std::string fitname);
82
83 double* getBinsAndLimits(json histo_cfg, std::string varname);
84
85 // Get mass resolution in GeV
86 double getMassResolution(double mass);
87
88 std::string getHitCategoryCut();
89 void initializeTestCutPDF(std::string cut_name, std::string cut_var, std::string persistent_cuts);
90 void initializeGraphs(std::string cut_name);
91
92 std::vector<std::pair<double, double>> getZoffsetAlpha(TH2F* h_y0_vs_z, int n_quantiles, int nbins);
93 double* getQuantileArray(std::pair<double, double> range, int n_quantiles, double initial_cut_frac = -999.9);
94
95 std::vector<double> findZcut(TH1* h_bkg_vtxz_cut, bool fromTailFit, int iteration = 0);
96
97 private:
98 // Configuration parameters
99 std::string outFileName_{"zbi_out.root"}; //<! description
100
101 std::string variableHistCfgFilename_{""}; //<! histogram config file
102 bool scan_zcut_ = false; //<! use zBi to optimize zcut
103 double min_ztail_events_ = 1; //<! number of events (from fit) past zcut
104 double fixed_zcut_ = -1.0; //<! fixed zcut value in mm
105
106 // Signal config
107 // std::string signalVtxSubsetAnaFilename_{""}; //<! description
108 std::string signalVtxMCSelection_{""}; //<! description
109 TTree* signal_tree_{nullptr}; //<! description
110 TTree* signal_pretrig_sim_tree_{nullptr}; //<! description
111
112 // Background config
113 TTree* bkg_tree_{nullptr}; //<! description
114
115 // Total A' Rate terms
116 double radFrac_ = 0.05; //<! radiative fraction (rad/(tritrig+wab))
117
118 double ztarget_ = -0.5; //<! target position in mm
119 double psum_cut_ = 3.0; //<! Psum cut in GeV
120
121 typedef std::map<std::string, std::pair<std::pair<double, double>, int>>::iterator
122 cut_iter_; //<! iterator for cuts
123
124 TreeCutSelector* testCutsSelector_{nullptr}; //<! cuts to be optimized
125 TreeCutSelector* persistentCutsSelector_{nullptr}; //<! cuts that are always applied
126
127 std::map<std::string, std::string> persistentCutStrings_;
128
129 std::map<std::string, std::pair<std::pair<double, double>, int>>* persistentCutsPtr_{nullptr};
130 std::map<std::string, std::pair<std::pair<double, double>, int>>* testCutsPtr_{nullptr};
131
132 std::map<std::string, TH1F*> testVarPDFs_; //<! PDFs for test variables
133 std::map<std::string, TH1F*> testVarCDFs_; //<! CDFs for test variables
134 std::map<std::string, double*> testVarQuantiles_; //<! quantiles for test variables
135 std::map<std::string, double*> testVarQuantilePos_; //<! quantile positions for test variables
136 std::map<std::string, std::vector<std::pair<double, double>>>
137 testZoffsetAlpha_; //<! zoffset and alpha for z0 cut, key is cutname, sorted by quantile
138
140 // TH1D* h_signal_vtxz_rad_subset_;
143 // TH1D* h_signal_mass_;
144 // TH1F* h_xi_eff_;
146
147 std::string hit_category_{""};
148 std::string massWindow_{""};
149 std::string initialCuts_{""};
150
151 double zbins_[3]{400., -10., 140.};
152 std::string zbin_str_ =
153 "(" + std::to_string((int)zbins_[0]) + "," + std::to_string(zbins_[1]) + "," + std::to_string(zbins_[2]) + ")";
154 double z_bin_width_ = (zbins_[2] - zbins_[1]) / zbins_[0];
156 double massbins_[3]{400., 0., 0.4};
158};
159
160#endif
nlohmann::json json
Class used to encapsulate information about a particle.
Base classes for all user event processing components to extend.
Class used to encapsulate Vertex information.
TreeCutSelector * persistentCutsSelector_
std::map< std::string, TH1F * > testVarPDFs_
virtual void configure(const ParameterSet &parameters)
description
virtual void initialize(TTree *tree)
description
double * getBinsAndLimits(json histo_cfg, std::string varname)
virtual void finalize()
description
std::map< std::string, std::vector< std::pair< double, double > > > testZoffsetAlpha_
std::map< std::string, std::string > persistentCutStrings_
std::map< std::string, std::pair< std::pair< double, double >, int > >::iterator cut_iter_
std::map< std::string, TH1F * > testVarCDFs_
std::vector< double > fitZBkgTail(TH1 *h_bkg_vtxz, std::string fitname)
void initializeGraphs(std::string cut_name)
std::map< std::string, std::pair< std::pair< double, double >, int > > * persistentCutsPtr_
std::vector< double > findZcut(TH1 *h_bkg_vtxz_cut, bool fromTailFit, int iteration=0)
std::vector< std::pair< double, double > > getZoffsetAlpha(TH2F *h_y0_vs_z, int n_quantiles, int nbins)
std::map< std::string, std::pair< std::pair< double, double >, int > > * testCutsPtr_
double computeDisplacedYield(TH1 *h_chi_eff, double EAp)
double computeTruthSignalShape(double z, double EAp)
ApOptimizationProcessor(const std::string &name, Process &process)
std::map< std::string, double * > testVarQuantiles_
std::map< std::string, double * > testVarQuantilePos_
virtual bool process(IEvent *event)
description
double * getQuantileArray(std::pair< double, double > range, int n_quantiles, double initial_cut_frac=-999.9)
virtual bool process()
description
void initializeTestCutPDF(std::string cut_name, std::string cut_var, std::string persistent_cuts)
Definition IEvent.h:7
OptimizationProcessor(const std::string &name, Process &process)
description