File indexing completed on 2026-04-07 08:08:32
0001 #ifndef __AN_NEUTRAL_MESON_NANO_H__
0002 #define __AN_NEUTRAL_MESON_NANO_H__
0003
0004 #include <fun4all/SubsysReco.h>
0005 #include <cmath>
0006 #include <algorithm>
0007 #include <vector>
0008 #include <iostream>
0009
0010 #include <TFile.h>
0011 #include <TTree.h>
0012 #include <TH1.h>
0013 #include <TH1F.h>
0014
0015
0016 class PHCompositeNode;
0017
0018 class AnNeutralMeson_nano : public SubsysReco
0019 {
0020 public:
0021
0022
0023 AnNeutralMeson_nano(const std::string &name = "AnNeutralMeson_nano", const std::string &inputlistname = "inputruns.txt", const std::string& inputfiletemplate = "analysis_diphoton_minimal_", const std::string &outputfilename = "analysis_0.root");
0024
0025
0026 virtual ~AnNeutralMeson_nano();
0027
0028
0029 int Init(PHCompositeNode *);
0030
0031
0032 int process_event(PHCompositeNode *);
0033
0034
0035 int End(PHCompositeNode *);
0036
0037 int FindBinBinary(float val, const float* binEdges, int nBins)
0038 {
0039 const float *it = std::upper_bound(binEdges, binEdges + nBins, val);
0040 int ibin = static_cast<int>(it - binEdges) -1;
0041 return ibin;
0042 }
0043
0044 int FindBinDirect(float val, float valMin, float valMax, int nBins)
0045 {
0046 if (val < valMin || val > valMax) {
0047 return -1;
0048 }
0049 int ibin = static_cast<int>((val - valMin) * nBins / (valMax - valMin));
0050 if (ibin == nBins) ibin = nBins - 1;
0051 else if (ibin < 0) ibin = 0;
0052 return ibin;
0053 }
0054
0055 void shuffle_spin_pattern(const int irun);
0056
0057 void set_store_bunch_yields(bool val,
0058 const std::string& filename_template)
0059 {
0060 store_bunch_yields = val;
0061 outbunchtemplate = filename_template;
0062 }
0063
0064
0065 void set_ptcut(float pTMin = 1.0, float pTMax = 1000.0)
0066 {
0067 pTCutMin = pTMin;
0068 pTCutMax = pTMax;
0069 }
0070
0071
0072 void BookHistos(const std::string &outputfilename = "");
0073
0074 void SaveBunchYields(const std::string &outputfilename);
0075
0076
0077 float WrapAngle(const float);
0078
0079
0080 void set_phenix_cut(bool val) { require_phenix_cut = val; }
0081 void set_high_xf_cut(bool val) { require_high_xf_cut = val; }
0082 void set_low_xf_cut(bool val) { require_low_xf_cut = val; }
0083 void set_low_vtx_cut(bool val) { require_low_vtx_cut = val; }
0084 void set_high_vtx_cut(bool val) { require_high_vtx_cut = val; }
0085
0086
0087 void set_trigger_mbd(bool val) { trigger_mbd = val; }
0088 void set_trigger_photon(bool val) { trigger_photon = val; }
0089
0090 private:
0091
0092
0093 bool trigger_mbd = false;
0094 bool trigger_photon = false;
0095
0096
0097 std::vector<int> runList;
0098 int nRuns = 0;
0099
0100
0101 int seednb = 0;
0102
0103
0104 std::string inlistname;
0105 std::string infiletemplate;
0106 std::string treename;
0107
0108
0109 float diphoton_vertex_z;
0110 int diphoton_bunchnumber;
0111 float diphoton_mass;
0112 float diphoton_eta;
0113 float diphoton_phi;
0114 float diphoton_pt;
0115 float diphoton_xf;
0116
0117
0118 bool require_phenix_cut = false;
0119 bool require_high_xf_cut = false;
0120 bool require_low_xf_cut = false;
0121 bool require_low_vtx_cut = false;
0122 bool require_high_vtx_cut = false;
0123
0124
0125 static constexpr int nBeams = 2;
0126 const std::string beams[nBeams] = {"yellow", "blue"};
0127 static constexpr int nParticles = 2;
0128 const std::string particle[nParticles] = {"pi0", "eta"};
0129 static constexpr int nRegions = 2;
0130 const std::string regions[nRegions] = {"peak", "side"};
0131 static constexpr int nSpins = 2;
0132 const std::string spins[nSpins] = {"up", "down"};
0133
0134
0135 static constexpr int nPtBins = 9;
0136 const float pTBins[nPtBins + 1] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 20};
0137
0138
0139 static constexpr int nEtaBins = 8;
0140 const float etaBins[nEtaBins + 1] = {-2.00, -1.05, -0.86, -0.61, 0.0, 0.61, 0.86, 1.05, 2.0};
0141
0142
0143 static constexpr int nXfBins = 8;
0144 const float xfBins[nXfBins + 1] = {-0.200, -0.048, -0.035, -0.022, 0.0, 0.022, 0.035, 0.048, 0.200};
0145
0146 static constexpr int nDirections = 2;
0147 const std::string directions[nDirections] = {"forward", "backward"};
0148 static constexpr int nPhiBins = 12;
0149 const float phiMin = - M_PI;
0150 const float phiMax = + M_PI;
0151
0152
0153 const float phi_shift[nBeams] = {M_PI / 2, -M_PI / 2};
0154 const float beamDirection[nBeams] = {-1, 1};
0155 static constexpr int nEtaRegions = 2;
0156 static constexpr double etaThreshold = 0.35;
0157
0158
0159 static constexpr int nBunches = 120;
0160 int crossingshift;
0161 int beamspinpat[nBeams][nBunches];
0162
0163
0164 float pTCutMin = 1.0;
0165 float pTCutMax = 1000.0;
0166
0167
0168 std::string outfiletemplate;
0169 TFile *outfile = nullptr;
0170
0171
0172 TH1F *h_pair_mass;
0173 TH1F *h_pair_mass_pt[nPtBins];
0174 TH1F *h_pair_mass_eta[nEtaBins];
0175 TH1F *h_pair_mass_xf[nXfBins];
0176
0177
0178 TH1F* h_average_pt[nParticles];
0179 TH1F* h_average_eta[nParticles];
0180 TH1F* h_average_xf[nParticles];
0181 TH1F* h_norm_pt[nParticles];
0182 TH1F* h_norm_eta[nParticles];
0183 TH1F* h_norm_xf[nParticles];
0184
0185
0186 TH1F *h_pair_meson_zvtx[2] = {nullptr};
0187 TH1F *h_pair_meson_pt_eta[2][9] = {nullptr};
0188 TH1F *h_pair_meson_pt_xf[2][9] = {nullptr};
0189 TH1F *h_pair_meson_eta_pt[2][8] = {nullptr};
0190 TH1F *h_pair_meson_eta_xf[2][8] = {nullptr};
0191 TH1F *h_pair_meson_xf_pt[2][8] = {nullptr};
0192 TH1F *h_pair_meson_xf_eta[2][8] = {nullptr};
0193
0194
0195 bool store_bunch_yields = false;
0196 std::string outbunchtemplate = "";
0197 uint32_t array_yield_pt[nBeams][nParticles][nRegions][nPtBins][nDirections][nSpins][nPhiBins][nBunches] = {0};
0198 uint32_t array_yield_eta[nBeams][nParticles][nRegions][nEtaBins][nSpins][nPhiBins][nBunches] = {0};
0199 uint32_t array_yield_xf[nBeams][nParticles][nRegions][nXfBins][nSpins][nPhiBins][nBunches] = {0};
0200
0201
0202 TH1F *h_yield_pt[nBeams][nParticles][nRegions][nPtBins][nDirections][nSpins];
0203
0204
0205 TH1F *h_yield_eta[nBeams][nParticles][nRegions][nEtaBins][nSpins];
0206
0207
0208 TH1F *h_yield_xf[nBeams][nParticles][nRegions][nXfBins][nSpins];
0209
0210
0211 float band_limits[nParticles * (nRegions + 1) * 2] =
0212 {0.030, 0.070,
0213 0.080, 0.199,
0214 0.209, 0.249,
0215 0.257, 0.371,
0216 0.399,0.739,
0217 0.767, 0.880};
0218 };
0219
0220 #endif