Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:15:36

0001 #ifndef __SPINDB_QA__
0002 #define __SPINDB_QA__
0003 
0004 #include <uspin/SpinDBContent.h>
0005 #include <uspin/SpinDBOutput.h>
0006 #include <uspin/SpinDBInput.h>
0007 
0008 #include <vector>
0009 #include <string>
0010 #include <map>
0011 #include <memory>
0012 
0013 // Forward declarations
0014 class SpinDBContent;
0015 class SpinDBOutput;
0016 class SpinDBInput;
0017 
0018 class TGraphErrors;
0019 
0020 
0021 class SpinDBQA
0022 {
0023 public:
0024     SpinDBQA();
0025     ~SpinDBQA() = default;
0026 
0027     void SetCNIPath(std::string cnipath = "/gpfs02/eic/cnipol/jet_run24/results"){_cnipathname = cnipath;};
0028     void SetMarkdownFilename(std::string markdownfile = "README.md"){_markdownfilename = markdownfile;};
0029     void SetHtmlFilename(std::string htmlfile = "runsummary.html"){_htmlfilename = htmlfile;};
0030     void SetRootFilename(std::string rootfile = "qa_results.root"){_rootfilename = rootfile;};
0031 
0032     void SetRunList(std::string runlist);
0033     void SetCrossingAngleStdThreshold(float threshold){_crossanglestdthreshold = threshold;};
0034 
0035     void DefaultQA(){b_defaultQA = true;};
0036     void SetQALevel(int level){b_defaultQA = false; qalevel = level;};
0037 
0038     void ReadSpinDBData();
0039     void doQA();
0040 
0041     void WriteHtml();
0042     void WriteMarkdown();
0043     void WriteRootFile();
0044 
0045     void WriteNewQALevel(int newqalevel = -999);
0046     //void WriteSpinDBData();
0047     //void PrintSpinDBData();
0048 
0049 private:
0050     SpinDBContent spin_cont;
0051     SpinDBOutput spin_out;
0052     SpinDBInput spin_in;
0053     
0054     void LocalPolQA(std::string &stringMarkdown,std::string &stringHtml);
0055     void GL1pScalersQA(std::string &stringMarkdown,std::string &stringHtml);
0056     void CNIHjetQA(std::string &stringMarkdown,std::string &stringHtml);
0057     void CrossingAngleQA(std::string &stringMarkdown,std::string &stringHtml);
0058 
0059     void PrepareHtml();
0060     std::string HtmlContent();
0061 
0062     void PrepareUpdatedCrossingShifts();
0063     void PrepareUpdatedBeamPolarizations();
0064     void PrepareUpdatedSpinPatterns();
0065 
0066     std::vector<int> runlistvect;
0067     std::map<std::string, std::vector<int>> map_spindbqa_markdown;
0068     std::map<std::string, std::vector<int>> map_spindbqa_html;
0069     
0070     std::string _cnipathname = "/gpfs02/eic/cnipol/jet_run24/results";
0071     std::string _markdownfilename;
0072     std::string _htmlfilename;
0073     std::string _rootfilename;
0074 
0075     float _crossanglestdthreshold = 0.1;  // mrad, mark runs with crossing angle std above this threshold as bad. Not very elegant to have this hardcoded cut, Dylan's fault
0076 
0077     // local pol checks
0078     float bf_phase_mean = 0;
0079     float bf_phase_rmse = 0.507;
0080     float yf_phase_mean = 0.006;
0081     float yf_phase_rmse = 0.447;
0082     float bf_mean = -2.269;
0083     float bf_rmse = 2.249;
0084     float yf_mean = -2.527;
0085     float yf_rmse = 1.007;
0086 
0087 
0088     int runnumber;
0089 
0090     bool b_defaultQA = true;
0091     int qalevel;
0092 
0093     //std::map<int, int> map_defaultQA, 
0094     std::map<int, int> map_fillnumber, map_qa_level, map_crossingshift;
0095     std::map<int, double> map_bluepol, map_yellpol, map_bluepolerr, map_yellpolerr;
0096     std::map<int, double> map_bluepolbyfill, map_yellpolbyfill, map_bluepolbyfillerr, map_yellpolbyfillerr;
0097     std::map<int, int> map_badrunqa;
0098     std::map<int, float> map_crossingangle, map_crossanglestd, map_crossanglemin, map_crossanglemax;
0099     std::map<int, float> map_asymbf, map_asymbb, map_asymyf, map_asymyb;
0100     std::map<int, float> map_asymerrbf, map_asymerrbb, map_asymerryf, map_asymerryb;
0101     std::map<int, float> map_phasebf, map_phasebb, map_phaseyf, map_phaseyb;
0102     std::map<int, float> map_phaseerrbf, map_phaseerrbb, map_phaseerryf, map_phaseerryb;
0103 
0104     std::map<int, std::vector<int>> map_bluespin;
0105     std::map<int, std::vector<int>> map_yellspin;
0106     std::map<int, std::vector<long long>> map_mbdns;
0107     std::map<int, std::vector<long long>> map_mbdvtx;
0108     std::map<int, std::vector<long long>> map_zdcns;
0109 
0110 
0111     // TGraphErrors for local polarimetry qa
0112     TGraphErrors *locpolbf;
0113     TGraphErrors *locpolbb;
0114     TGraphErrors *locpolyf;
0115     TGraphErrors *locpolyb;
0116     TGraphErrors *locpolphasebf;
0117     TGraphErrors *locpolphasebb;
0118     TGraphErrors *locpolphaseyf;
0119     TGraphErrors *locpolphaseyb;
0120 
0121 };
0122 
0123 
0124 
0125 
0126 
0127 
0128 #endif