From f429aa488cdfb2abe067f88bde0c38072e0b6453 Mon Sep 17 00:00:00 2001 From: Zilong Chang Date: Tue, 2 Apr 2024 12:02:16 -0400 Subject: [PATCH] spin tune moter and noise study by zchang (#2) * spin tune moter and noise study by zchang * spin tune moter and noise study by zchang * modified to LinkDef.h and root-helper/utils/binary.h(cc) for spin tune study * modified with default streamer provided by ROOT * add afterburner code * first version for run22 offline monitoring * first version for run22 offline monitoring * first version for run22 offline monitoring * test * test * first version for run22 offline monitoring * new crontab scripts * test * test * add fit function to graph instead of histogram * ready for run22 pC offline analysis * run22 pC * updates * updates to cnipol webpages, added spin pattern, fixed bug with masym so that it will run with only one measurement in the input * load ags polarization from FDAcombined --- .gitmodules | 9 +- CMakeLists.txt | 23 +- LinkDef.h | 12 +- contrib/RunPeriod.inc | 152 ++++ contrib/opencdev | 2 +- contrib/polarim-online | 2 +- contrib/root-helper | 2 +- inc/AfterBurner.h | 24 + inc/AnaFillExternResult.h | 1 + inc/AnaFillResult.h | 10 + inc/AnaInfo.h | 4 +- inc/AnaMeasResult.h | 1 + inc/AsymAnaInfo.h | 5 +- inc/AsymCommon.h | 3 +- inc/AsymOnline.h | 60 ++ inc/AsymRecoverUserDefined.h | 16 +- inc/AsymRoot.h | 11 +- inc/CMakeLists.txt | 4 + inc/Calibrator.h | 2 +- inc/ChannelEvent.h | 2 + inc/CnipolAsymHists.h | 2 +- inc/CnipolSpinTuneMotorHists.h | 37 + inc/MAsymBiasHists.h | 3 +- inc/MeasInfo.h | 5 +- inc/SpinTuneMotor.h | 44 + inc/SshLogReader.h | 7 + inc/UserGroup.h | 33 + script/r22asym.csh | 70 ++ script/r22setup.csh | 79 ++ script/runAsymR22.cron | 1 + script/runAsymR22.sh | 64 ++ script/run_asym_r22.sh | 61 ++ script/runstar.cron | 1 + script/runstar.csh | 39 + script/setup.csh | 79 ++ script/setup.sh | 85 +- script/setup64b.csh | 79 ++ src/AfterBurner.cxx | 114 +++ src/AnaFillExternResult.cxx | 42 +- src/AnaFillResult.cxx | 160 +++- src/AnaGlobResult.cxx | 21 +- src/AnaInfo.cxx | 9 +- src/AnaMeasResult.cxx | 14 +- src/AsymAnaInfo.cxx | 34 +- src/AsymCommon.cxx | 8 +- src/AsymDbSql.cxx | 6 +- src/AsymOnline.cxx | 21 +- src/AsymRecover.cxx | 9 +- src/AsymRoot.cxx | 78 +- src/CMakeLists.txt | 2 + src/ChannelEvent.cxx | 28 + src/CnipolAlphaHists.cxx | 3 +- src/CnipolAsymHists.cxx | 66 +- src/CnipolKinemaCleanHists.cxx | 24 +- src/CnipolPreprocHists.cxx | 2 + src/CnipolPulserHists.cxx | 3 +- src/CnipolRawHists.cxx | 7 + src/CnipolSpinTuneMotorHists.cxx | 233 +++++ src/DrawObjContainer.cxx | 1 - src/MAsymAnaInfo.cxx | 2 +- src/MAsymBiasHists.cxx | 10 +- src/MAsymFillHists.cxx | 18 +- src/MAsymRunHists.cxx | 73 +- src/MAsymSingleFillHists.cxx | 16 +- src/MeasInfo.cxx | 36 +- src/RawDataReader.cxx | 56 +- src/RunConfig.cxx | 14 +- src/SshLogReader.cxx | 34 +- src/asym.cxx | 27 +- src/malpha.cxx | 4 +- src/masym.cxx | 38 +- webview/fills/index.php | 2 + webview/head.html | 14 +- webview/index.php | 6 +- webview/rundb/FillResult.php | 2 + webview/rundb/FillSelector.php | 11 +- webview/rundb/RunSelector.php | 2 +- webview/rundb/RunSelector_test.php | 187 ++++ webview/rundb/SqlDbReader_test.php | 102 +++ webview/rundb/TargetSelector.php | 2 +- webview/rundb/bottom.html | 9 +- webview/rundb/config.php | 50 +- webview/rundb/index.php | 20 +- webview/rundb/main.css.php | 370 +++++++- webview/rundb/runinfo.html | 15 + webview/rundb/runinfo_index_test.html | 341 ++++++++ webview/rundb/runinfo_r22.html | 959 +++++++++++++++++++++ webview/rundb/test.php | 164 ++++ webview/summary/index.php | 53 +- webview/summary/summary.html | 2 +- webview/summary/summary_bes.html | 109 +++ webview/summary/summary_index.html | 16 + webview/summary/summary_r22.html | 1138 +++++++++++++++++++++++++ webview/summary/summary_r22_254.html | 1138 +++++++++++++++++++++++++ 94 files changed, 6652 insertions(+), 307 deletions(-) create mode 100644 inc/AfterBurner.h create mode 100644 inc/CnipolSpinTuneMotorHists.h create mode 100644 inc/SpinTuneMotor.h create mode 100644 inc/UserGroup.h create mode 100755 script/r22asym.csh create mode 100755 script/r22setup.csh create mode 100644 script/runAsymR22.cron create mode 100755 script/runAsymR22.sh create mode 100755 script/run_asym_r22.sh create mode 100644 script/runstar.cron create mode 100755 script/runstar.csh create mode 100755 script/setup.csh create mode 100755 script/setup64b.csh create mode 100644 src/AfterBurner.cxx create mode 100644 src/CnipolSpinTuneMotorHists.cxx create mode 100644 webview/rundb/RunSelector_test.php create mode 100644 webview/rundb/SqlDbReader_test.php mode change 120000 => 100644 webview/rundb/main.css.php create mode 100644 webview/rundb/runinfo_index_test.html create mode 100644 webview/rundb/runinfo_r22.html create mode 100644 webview/rundb/test.php create mode 100644 webview/summary/summary_bes.html create mode 100644 webview/summary/summary_r22.html create mode 100644 webview/summary/summary_r22_254.html diff --git a/.gitmodules b/.gitmodules index c4de23cf..25b11cc8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,13 +1,12 @@ [submodule "contrib/root-helper"] path = contrib/root-helper - url = git://github.com/rhicspin/root-helper.git + url = git@github.com:zlchang/root-helper.git [submodule "contrib/opencdev"] path = contrib/opencdev - url = git://github.com/rhicspin/opencdev.git + url = git@github.com:zlchang/opencdev.git [submodule "contrib/mysqlpp"] path = contrib/mysqlpp - url = git://github.com/veprbl/mysqlpp.git - branch = cmake + url = git@github.com:zlchang/mysqlpp.git [submodule "contrib/polarim-online"] path = contrib/polarim-online - url = https://github.com/rhicspin/polarim-online.git + url = git@github.com:zlchang/polarim-online.git diff --git a/CMakeLists.txt b/CMakeLists.txt index e2e5d444..25ed9164 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ # # After that you will only need to use make. # +SET(CMAKE_C_FLAGS "-m32") +SET(CMAKE_CXX_FLAGS "-m32") +SET(CMAKE_SHARED_LINKER_FLAGS "-m32") CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(CNIPOL) @@ -19,8 +22,10 @@ ELSE() SET(CMAKE_CXX_STANDARD 11) ENDIF() + SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) -OPTION(FORCE_32BIT "should be OFF" OFF) # ON value is not supported +#OPTION(FORCE_32BIT "should be OFF" OFF) # ON value is not supported +#OPTION(FORCE_32BIT "force 32bit" ON) ADD_DEFINITIONS("-DCNIPOL_ROOT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"") @@ -34,14 +39,14 @@ IF(${ROOT_VERSION} VERSION_GREATER "6.0") RecordTargetParams, AnaInfo.) ENDIF() -EXECUTE_PROCESS( - COMMAND git submodule init - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) -EXECUTE_PROCESS( - COMMAND git submodule update - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) +#EXECUTE_PROCESS( +# COMMAND git submodule init +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +# ) +#EXECUTE_PROCESS( +# COMMAND git submodule update +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +# ) ADD_SUBDIRECTORY(contrib/root-helper EXCLUDE_FROM_ALL) SET(Boost_USE_MULTITHREADED OFF) # this is what we have at AFS installation ADD_SUBDIRECTORY(contrib/opencdev EXCLUDE_FROM_ALL) diff --git a/LinkDef.h b/LinkDef.h index 75de59bd..d9fa54b7 100644 --- a/LinkDef.h +++ b/LinkDef.h @@ -11,7 +11,7 @@ #pragma link C++ class AnaFillExternResult; #pragma link C++ class AnaFillResult; #pragma link C++ class AnaGlobResult; -#pragma link C++ class AnaInfo; +#pragma link C++ class AnaInfo+; #pragma link C++ class AsymAnaInfo+; #pragma link C++ class BeamBunch+; #pragma link C++ class CalibCoefSet+; @@ -34,6 +34,7 @@ #pragma link C++ class CnipolRunHists+; #pragma link C++ class CnipolScalerHists+; #pragma link C++ class CnipolSpinStudyHists+; +#pragma link C++ class CnipolSpinTuneMotorHists+; #pragma link C++ class CnipolTargetHists+; #pragma link C++ class DeadLayerCalibrator+; #pragma link C++ class DeadLayerCalibratorEDepend+; @@ -52,13 +53,16 @@ #pragma link C++ class MAsymRateHists+; #pragma link C++ class MAsymRoot+; #pragma link C++ class MAsymRunHists+; - +#pragma link C++ class UserGroup; +#pragma link C++ class RecordHeaderStruct_t; +#pragma link C++ class RecordMachineParams_t; +#pragma link C++ class RecordTargetParams_t; // src #pragma link C++ class AnaFillExternResult; #pragma link C++ class AnaFillResult; #pragma link C++ class AnaGlobResult; -#pragma link C++ class AnaMeasResult-; -#pragma link C++ class MeasInfo-; +#pragma link C++ class AnaMeasResult+; +#pragma link C++ class MeasInfo+; // misc #pragma link C++ class ChannelCalibMap+; diff --git a/contrib/RunPeriod.inc b/contrib/RunPeriod.inc index 9c24858e..20359f41 100644 --- a/contrib/RunPeriod.inc +++ b/contrib/RunPeriod.inc @@ -1286,3 +1286,155 @@ .cut_pulser_tdc_min = 255.0, .cut_pulser_tdc_max = 0.0, }, +{ + .start_time = MK_UNIXTIME_NY_TZ(2021, 11, 28, 23, 0, 0) /* 2021-11-28 23:00:00 */, + .polarimeter_id = kB1U, + .alpha_calib_run_name = "291121a.blu1.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2021, 11, 28, 23, 0, 0) /* 2021-11-28 23:00:00 */, + .polarimeter_id = kY1D, + .alpha_calib_run_name = "291121a.yel1.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2021, 11, 28, 23, 0, 0) /* 2021-11-28 23:00:00 */, + .polarimeter_id = kB2D, + .alpha_calib_run_name = "291121a.blu2.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2021, 11, 28, 23, 0, 0) /* 2021-11-28 23:00:00 */, + .polarimeter_id = kY2U, + .alpha_calib_run_name = "291121a.yel2.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2022, 1, 5, 15, 0, 0) /* 2022-1-5 15:00:00 */, + .polarimeter_id = kB1U, + .alpha_calib_run_name = "050122a.blu1.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2022, 1, 5, 15, 0, 0) /* 2022-1-5 15:00:00 */, + .polarimeter_id = kY1D, + .alpha_calib_run_name = "050122.yel1.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2022, 1, 5, 15, 0, 0) /* 2021-1-5 15:00:00 */, + .polarimeter_id = kB2D, + .alpha_calib_run_name = "050122a.blu2.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, +{ + .start_time = MK_UNIXTIME_NY_TZ(2022, 1, 5, 15, 0, 0) /* 2021-1-5 15:00:00 */, + .polarimeter_id = kY2U, + .alpha_calib_run_name = "050122.yel2.alpha0", /* 2 hr. calib. run */ + .alpha_source_count = -1, + .disabled_channels = "", + .disabled_bunches = "", + .cut_proto_slope = -0.25, + .cut_proto_offset = 65.0, + .cut_proto_width = 20, + .cut_proto_adc_min = 20.0, + .cut_proto_adc_max = 210.0, + .cut_proto_tdc_min = 0.0, + .cut_proto_tdc_max = 255.0, + .cut_pulser_adc_min = 255.0, + .cut_pulser_adc_max = 0.0, + .cut_pulser_tdc_min = 255.0, + .cut_pulser_tdc_max = 0.0, +}, \ No newline at end of file diff --git a/contrib/opencdev b/contrib/opencdev index 10e0f9e4..d8be3af2 160000 --- a/contrib/opencdev +++ b/contrib/opencdev @@ -1 +1 @@ -Subproject commit 10e0f9e4cf4d23912130e73ce80df75a98289eb8 +Subproject commit d8be3af25cbf7699a25de6c2ff9e9be37a4bf2d7 diff --git a/contrib/polarim-online b/contrib/polarim-online index 03a6153f..e1ece0ad 160000 --- a/contrib/polarim-online +++ b/contrib/polarim-online @@ -1 +1 @@ -Subproject commit 03a6153f17eab69e6365e591c7d0fc4946ee0169 +Subproject commit e1ece0ad03b238cd14255e34768dafed1c18d833 diff --git a/contrib/root-helper b/contrib/root-helper index 1e163939..1eaab703 160000 --- a/contrib/root-helper +++ b/contrib/root-helper @@ -1 +1 @@ -Subproject commit 1e163939b20c7cc209582bb8bd124b85dbef9f16 +Subproject commit 1eaab703867ace8b46b7e2e0fb0741526ab56a5f diff --git a/inc/AfterBurner.h b/inc/AfterBurner.h new file mode 100644 index 00000000..82a464f4 --- /dev/null +++ b/inc/AfterBurner.h @@ -0,0 +1,24 @@ +// fit one set of spin U/D detector hits for aymmetry etc. +// +// input: nup[6] - # Up hits in [det = 0-5] +// nup[6] - # Dn hits in [det = 0-5] +// fixpar - integer, bit(s) 0-2 = 1 => fix paramater(2) 0-2 to value in par[0-2] +// +// output: par[3] - results [0]=asymmetry magnitude, [1]=spin tilt (rad.), [2]=lumi asym. +// epar[3] - error +// chi2 - minimized chi-square +// +// + +#include +#include + +using namespace std; + +namespace afterburner{ + // function prototypes: + void myFcn(int & /*nPar*/, double * /*grad*/ , double &fval, double *par, int /*iflag */ ); + //void myFcn(Int_t & /*nPar*/, Double_t * /*grad*/ , Double_t &fval, Double_t *par, Int_t /*iflag */ ); + pair asym_err(double lambda, double nup, double ndn); + void fit1asym(double nup[] , double ndn[] , double par[], double epar[] , double &chi2, int fixpar = 0); +} diff --git a/inc/AnaFillExternResult.h b/inc/AnaFillExternResult.h index 34d5ac85..dc45fb38 100644 --- a/inc/AnaFillExternResult.h +++ b/inc/AnaFillExternResult.h @@ -40,6 +40,7 @@ class AnaFillExternResult : public TObject TGraphErrors* MakeGraph(const std::map &values, int thin_out_factor=1); void LoadAgsInfo(opencdev::LogReader &log_reader); + void LoadAgsInfo(opencdev::LogReader &log_reader, int fillId); void LoadInfo(UInt_t fillId); public: diff --git a/inc/AnaFillResult.h b/inc/AnaFillResult.h index 5b59ead2..9c2ebb38 100644 --- a/inc/AnaFillResult.h +++ b/inc/AnaFillResult.h @@ -40,6 +40,8 @@ class AnaFillResult : public TObject PolId2TGraphMap fPCPolarInjGraphs; // polarization measurements at 24 GeV by polarimeter PolId2TgtOrient2TGraphMap fPCProfRGraphs; PolId2TgtOrient2TGraphMap fPCProfRInjGraphs; //! + PolId2TGraphMap fPCPolarPhaseGraphs; // spin tilt at flattop + PolId2TGraphMap fPCPolarPhaseInjGraphs; // spin tilt at 24 GeV by polarimeter PolId2TargetUIdMap fPCTargets; TFitResultPtr fPCPolarFitRes; @@ -57,6 +59,7 @@ class AnaFillResult : public TObject PolId2ValErrMap fPCPolars; // (Nominal) intensity weighted polarization measurement results PolId2ValErrMap fPCPolarUnWs; // The same as fPCPolars but not weighted with intensity + PolId2ValErrMap fPCPolarPhases; // average spin tilt angle PolId2TgtOrient2ValErrMap fPCProfRs; //! //PolId2TgtOrient2ValErrMap fPCProfRInjs; //! TargetUId2ValErrMap fPCPolarsByTargets; @@ -122,6 +125,7 @@ class AnaFillResult : public TObject Bool_t IsValidFlattopMeas(const MeasInfo &measInfo); ValErrPair GetPCPolar(EPolarimeterId polId, PolId2ValErrMap *normJC=0) const; ValErrPair GetPCPolarUnW(EPolarimeterId polId, PolId2ValErrMap *normJC=0) const; + ValErrPair GetPCPolarPhase(EPolarimeterId polId) const; TGraphErrors* GetPCPolarGraph(EPolarimeterId polId) const; TGraphErrors* GetPCPolarInjGraph(EPolarimeterId polId); ValErrPair GetPCPolarP0(EPolarimeterId polId) const; @@ -155,6 +159,7 @@ class AnaFillResult : public TObject PolId2ValErrMap CalcSystProfPolar(PolId2ValErrMap &normPP); ValErrPair CalcAvrgPolar(EPolarimeterId polId); ValErrPair CalcAvrgPolarUnweighted(EPolarimeterId polId); + ValErrPair CalcAvrgPolarPhase(EPolarimeterId polId); ValErrPair CalcAvrgPolProfPolar(EPolarimeterId polId); //ValErrPair CalcAvrgProfRInj(EPolarimeterId polid, ETargetOrient tgtOrient); ValErrPair CalcAvrgProfR(EPolarimeterId polid, ETargetOrient tgtOrient); @@ -175,6 +180,11 @@ class AnaFillResult : public TObject void AppendToPCPolarInjGraph(EPolarimeterId polId, Double_t x, Double_t y, Double_t xe, Double_t ye); void AppendToPCProfRGraph(EPolarimeterId polId, ETargetOrient tgtOrient, Double_t x, Double_t y, Double_t xe, Double_t ye); void AppendToPCProfRInjGraph(EPolarimeterId polId, ETargetOrient tgtOrient, Double_t x, Double_t y, Double_t xe, Double_t ye); + // + TGraphErrors* GetPCPolarPhaseGraph(EPolarimeterId polId) const; + TGraphErrors* GetPCPolarPhaseInjGraph(EPolarimeterId polId); + void AppendToPCPolarPhaseGraph(EPolarimeterId polId, Double_t x, Double_t y, Double_t xe, Double_t ye); + void AppendToPCPolarPhaseInjGraph(EPolarimeterId polId, Double_t x, Double_t y, Double_t xe, Double_t ye); ClassDef(AnaFillResult, 1) }; diff --git a/inc/AnaInfo.h b/inc/AnaInfo.h index a2233a06..177f2963 100644 --- a/inc/AnaInfo.h +++ b/inc/AnaInfo.h @@ -7,8 +7,8 @@ #include #include "TObject.h" -#include "TSystem.h" +#include "UserGroup.h" #include "AsymCommon.h" @@ -59,7 +59,7 @@ class AnaInfo : public TObject Bool_t fFlagUpdateDb; Bool_t fFlagCreateThumbs; Bool_t fFlagVerbose; //! - UserGroup_t fUserGroup; + UserGroup fUserGroup; Short_t fAlphaSourceCount; public: diff --git a/inc/AnaMeasResult.h b/inc/AnaMeasResult.h index e08654ac..5fd0e07b 100644 --- a/inc/AnaMeasResult.h +++ b/inc/AnaMeasResult.h @@ -77,6 +77,7 @@ class AnaMeasResult : public TObject time_t GetStartTime() const { return fStartTime; } void SetStartTime(time_t time) { fStartTime = time; } + ValErrPair GetPCPolarX90() const; //polarization from 90 degree detectors zchang ValErrPair GetPCPolar() const; ValErrPair GetPCPolarPhase() const; ValErrPair GetPCProfR() const; diff --git a/inc/AsymAnaInfo.h b/inc/AsymAnaInfo.h index 3b48e243..63e07653 100644 --- a/inc/AsymAnaInfo.h +++ b/inc/AsymAnaInfo.h @@ -36,6 +36,8 @@ class AsymAnaInfo : public AnaInfo MODE_PMT = 0x00000100, MODE_PULSER = 0x00000200, MODE_STUDIES = 0x00000400, + MODE_STM = 0x01800000, //zchang + MODE_NOISE = 0x02800000, //zchang noise study MODE_NO_GAIN_CORRECTION = 0x00000800}; enum Option {OPTION_AC_DIPOLE_PERIOD = 0x20000004}; @@ -53,7 +55,6 @@ class AsymAnaInfo : public AnaInfo std::string fAlphaCalibRun; // Name of alpha calib run FILE *fFileRunConf; //! uint32_t fAcDipolePeriod; //! AC dipole magnet period in revolutions - public: AsymAnaInfo(); @@ -87,6 +88,8 @@ class AsymAnaInfo : public AnaInfo Bool_t HasPmtBit() const; Bool_t HasPulserBit() const; Bool_t HasStudiesBit() const; + Bool_t HasSTMBit() const; //zchang + Bool_t HasNoiseBit() const; //zchang noise study Bool_t HasNoGainCorrectionBit() const; ClassDef(AsymAnaInfo, 7) diff --git a/inc/AsymCommon.h b/inc/AsymCommon.h index 4535336c..674d0398 100644 --- a/inc/AsymCommon.h +++ b/inc/AsymCommon.h @@ -28,7 +28,8 @@ enum EBeamId {kBLUE_BEAM = 1, kYELLOW_BEAM = 2, kUNKNOWN_BEAM}; enum ERingId {kBLUE_RING = 1, kYELLOW_RING = 2, kUNKNOWN_RING}; enum EStreamId {kUPSTREAM = 1, kDOWNSTREAM = 2, kUNKNOWN_STREAM}; enum ETargetOrient {kTARGET_H = 0, kTARGET_V = 1, kUNKNOWN_ORIENT}; -enum EBeamEnergy {kINJECTION = 24, kBEAM_ENERGY_100 = 100, kBEAM_ENERGY_104 = 104,kBEAM_ENERGY_250 = 250, kBEAM_ENERGY_255 = 255}; +//enum EBeamEnergy {kINJECTION = 24, kBEAM_ENERGY_100 = 100, kBEAM_ENERGY_104 = 104,kBEAM_ENERGY_250 = 250, kBEAM_ENERGY_255 = 255}; +enum EBeamEnergy {kINJECTION = 24, kBEAM_ENERGY_100 = 100, kBEAM_ENERGY_104 = 104,kBEAM_ENERGY_250 = 250, kBEAM_ENERGY_255 = 255, kBEAM_ENERGY_254 = 254, kBEAM_ENERGY_253 = 253}; enum ESpinState {kSPIN_DOWN = -1, kSPIN_NULL = 0, kSPIN_UP = +1}; enum EAsymType {kPHYS_ASYM = 1, kGEOM_ASYM = 2, kLUMI_ASYM = 3}; enum EFillType {kFILLTYPE_UNKNOWN = 0, kFILLTYPE_PHYSICS}; diff --git a/inc/AsymOnline.h b/inc/AsymOnline.h index 2afba09c..8e2407a4 100644 --- a/inc/AsymOnline.h +++ b/inc/AsymOnline.h @@ -5,6 +5,66 @@ #include "rpoldata.h" +class RecordHeaderStruct_t : public TObject{ + public: + int len; // total length = header size + data size + int type; // record type, see above + int num; // record number + int time; // local UNIX time in most cases + int delim; // when read from memory + RecordHeaderStruct_t & operator = (const RecordHeaderStruct &hd){ + len = hd.len; + type = hd.type; + num = hd.type; + time = hd.timestamp.time; + delim = hd.timestamp.delim; + return *this; + } + private: + ClassDef(RecordHeaderStruct_t, 1); +}; + + +class RecordMachineParams_t : public TObject{ + public: + RecordHeaderStruct_t header; + int fCavity197MHzVoltage[N_BEAMS]; + float fSnakeCurrents[N_BEAMS]; + float fStarRotatorCurrents[N_BEAMS]; + float fPhenixRotatorCurrents[N_BEAMS]; + RecordMachineParams_t & operator = (const RecordMachineParams &par){ + header = par.header; + for(int ib = 0; ib < N_BEAMS; ib++){ + fCavity197MHzVoltage[ib] = par.fCavity197MHzVoltage[ib]; + fSnakeCurrents[ib] = par.fSnakeCurrents[ib]; + fStarRotatorCurrents[ib] = par.fStarRotatorCurrents[ib]; + fPhenixRotatorCurrents[ib] = par.fPhenixRotatorCurrents[ib]; + } + return *this; + } + private: + ClassDef(RecordMachineParams_t, 1); +}; + + +class RecordTargetParams_t : public TObject{ + public: + RecordHeaderStruct_t header; + int fVelocity; + int fProfileStartPosition; + int fProfileEndPosition; + int fProfilePeakPosition; + RecordTargetParams_t & operator = (const RecordTargetParams &par){ + header = par.header; + fVelocity = par.fVelocity; + fProfileStartPosition = par.fProfileStartPosition; + fProfileEndPosition = par.fProfileEndPosition; + fProfilePeakPosition = par.fProfilePeakPosition; + return *this; + } + private: + ClassDef(RecordTargetParams_t, 1); +}; #endif diff --git a/inc/AsymRecoverUserDefined.h b/inc/AsymRecoverUserDefined.h index faa00502..0a9faaaf 100644 --- a/inc/AsymRecoverUserDefined.h +++ b/inc/AsymRecoverUserDefined.h @@ -9,7 +9,7 @@ #ifndef ASYM_RECOVER_USER_DEFINED_H #define ASYM_RECOVER_USER_DEFINED_H -int UserDefinedSpinPattern[13][N_BUNCHES]= +int UserDefinedSpinPattern[14][N_BUNCHES]= { // ----------------------- Run5 Spin Patterns -------------------// // index=0; @@ -77,13 +77,23 @@ int UserDefinedSpinPattern[13][N_BUNCHES]= {1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1, 1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1, 1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1, - 1,-1,1,0,0,0,0,0,0,0,0,0} + 1,-1,1,0,0,0,0,0,0,0,0,0}, + // index=13 (run22 fill 32923.004) + {1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1, + 1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1, + 1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1, + 1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1, + 1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1,-1,1,0,0,0,0,0,0,0,0,0} }; -int UserDefinedFillPattern[1][N_BUNCHES] = { +int UserDefinedFillPattern[2][N_BUNCHES] = { // -------------------- All (112 bunches on) True Fill Pattern -------------------// // index=0; + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0}, + // index=1; {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0} diff --git a/inc/AsymRoot.h b/inc/AsymRoot.h index c687540a..b0c661b7 100644 --- a/inc/AsymRoot.h +++ b/inc/AsymRoot.h @@ -17,7 +17,8 @@ #include "ChannelEvent.h" #include "DrawObjContainer.h" #include "EventConfig.h" - +//zchang +#include "SpinTuneMotor.h" class AsymAnaInfo; @@ -28,7 +29,8 @@ enum ECut { kCUT_PMT, kCUT_CARBON_EB, kCUT_PASSTWO, - kCUT_PASSONE_STEPPER + kCUT_PASSONE_STEPPER, + kCUT_NOISE_LOWER //zchang }; typedef std::map > Cut2DrawObjContainerMap; @@ -55,6 +57,8 @@ class AsymRoot ChannelData *fChannelData; //! ChannelEventSet fChannelEvents; //! EventConfig *fEventConfig; //! + //zchang + SpinTuneMotor *fSpinTuneMotor; DrawObjContainer *fHists; //! public: @@ -71,6 +75,8 @@ class AsymRoot void AddSpinFlipperMarker(); void ProcessEvent() {}; void FillPassOne(ECut cut); + //zchang + void FillSpinTuneMotor(); void FillDerivedPassOne(); void PostFillPassOne(); void PreFill(); @@ -81,6 +87,7 @@ class AsymRoot void FillTargetHists(Int_t n, Double_t *hData); void FillProfileHists(UInt_t n, Int_t *hData); void FillRunHists(); + //void AfterBurner(); void AddChannelEvent(); void PrintEventMap(); void PrintChannelEvent(); diff --git a/inc/CMakeLists.txt b/inc/CMakeLists.txt index 95c59f0d..f3fffa33 100644 --- a/inc/CMakeLists.txt +++ b/inc/CMakeLists.txt @@ -32,6 +32,7 @@ SET( ${CMAKE_CURRENT_SOURCE_DIR}/CnipolRunHists.h ${CMAKE_CURRENT_SOURCE_DIR}/CnipolScalerHists.h ${CMAKE_CURRENT_SOURCE_DIR}/CnipolSpinStudyHists.h + ${CMAKE_CURRENT_SOURCE_DIR}/CnipolSpinTuneMotorHists.h ${CMAKE_CURRENT_SOURCE_DIR}/CnipolTargetHists.h ${CMAKE_CURRENT_SOURCE_DIR}/DeadLayerCalibrator.h ${CMAKE_CURRENT_SOURCE_DIR}/DeadLayerCalibratorEDepend.h @@ -48,6 +49,9 @@ SET( ${CMAKE_CURRENT_SOURCE_DIR}/RunConfig.h ${CMAKE_CURRENT_SOURCE_DIR}/RunQA.h ${CMAKE_CURRENT_SOURCE_DIR}/Target.h + ${CMAKE_CURRENT_SOURCE_DIR}/SpinTuneMotor.h + ${CMAKE_CURRENT_SOURCE_DIR}/UserGroup.h + ${CMAKE_CURRENT_SOURCE_DIR}/AfterBurner.h ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/polarim-online/include/rpoldata.h ${OPENCDEV_INCLUDE_DIR}/opencdev.h PARENT_SCOPE diff --git a/inc/Calibrator.h b/inc/Calibrator.h index 88090c36..61ab326e 100644 --- a/inc/Calibrator.h +++ b/inc/Calibrator.h @@ -28,7 +28,7 @@ class Calibrator : public TObject Float_t fRMSBananaChi2Ndf; Float_t fRMSOfLogsBananaChi2Ndf; -public: +//public: Calibrator(); ~Calibrator(); diff --git a/inc/ChannelEvent.h b/inc/ChannelEvent.h index b3b31243..1c84d7d3 100644 --- a/inc/ChannelEvent.h +++ b/inc/ChannelEvent.h @@ -68,6 +68,7 @@ class ChannelEvent : public TObject virtual void Print(const Option_t* opt="") const; Bool_t PassCutRawAlpha(); Bool_t PassCutSiliconChannel(); + Bool_t PassCutSpinTuneChannel(); Bool_t PassCutDepEnergyTime(); Bool_t PassCutKinEnergyAEDepend(); Bool_t PassCutKinEnergyAEDependAverage(); @@ -76,6 +77,7 @@ class ChannelEvent : public TObject Bool_t PassCutCarbonMassEstimate(); Bool_t PassCutPulser(); Bool_t PassCutNoise(); + Bool_t PassCutNoiseLower(); Bool_t PassCutEnabledChannel(); Bool_t PassCutTargetChannel(); Bool_t PassCutPmtChannel() const; diff --git a/inc/CnipolAsymHists.h b/inc/CnipolAsymHists.h index 4d4959fe..2c4ff688 100644 --- a/inc/CnipolAsymHists.h +++ b/inc/CnipolAsymHists.h @@ -30,7 +30,7 @@ class CnipolAsymHists : public DrawObjContainer void FillDerived(); void FillDerived(DrawObjContainer &oc); void PostFill(); - + void AfterBurner(); ClassDef(CnipolAsymHists, 1) }; diff --git a/inc/CnipolSpinTuneMotorHists.h b/inc/CnipolSpinTuneMotorHists.h new file mode 100644 index 00000000..f989aeb5 --- /dev/null +++ b/inc/CnipolSpinTuneMotorHists.h @@ -0,0 +1,37 @@ + +#ifndef CnipolSpinTuneMotorHists_h +#define CnipolSpinTuneMotorHists_h + +#include + +#include "TDirectoryFile.h" + +//#include "SpinTuneMotorHeader.h" + +#include "ChannelEvent.h" +#include "DrawObjContainer.h" + + +/** + * + */ +class CnipolSpinTuneMotorHists : public DrawObjContainer +{ + +public: + + CnipolSpinTuneMotorHists(); + CnipolSpinTuneMotorHists(TDirectory *dir); + ~CnipolSpinTuneMotorHists(); + + void BookHists(); + //void PreFill(); + void Fill(ChannelEvent *ch); + void FillDerived(); + //void FillDerived(DrawObjContainer &oc); + void PostFill(); + + ClassDef(CnipolSpinTuneMotorHists, 1) +}; + +#endif diff --git a/inc/MAsymBiasHists.h b/inc/MAsymBiasHists.h index e214f851..3f5a34a6 100644 --- a/inc/MAsymBiasHists.h +++ b/inc/MAsymBiasHists.h @@ -23,7 +23,8 @@ class MAsymBiasHists : public DrawObjContainer MAsymBiasHists(); MAsymBiasHists(TDirectory *dir); - void BookHists(std::string sid=""); + //void BookHists(std::string sid=""); + void BookHists(); void BookHistsPolarimeter(EPolarimeterId polId); void Fill(const EventConfig &rc); virtual void SaveAllAs(ImageFormat fmt_ext, TCanvas &default_canvas, std::string pattern, std::string path, Bool_t thumbs); diff --git a/inc/MeasInfo.h b/inc/MeasInfo.h index 9a3076f9..f981e2e4 100644 --- a/inc/MeasInfo.h +++ b/inc/MeasInfo.h @@ -40,9 +40,9 @@ class MeasInfo : public TObject protected: Float_t fBeamEnergy; - RecordMachineParams fMachineParams; + RecordMachineParams_t fMachineParams; Bool_t fHasMachineParamsInRawData; - RecordTargetParams fTargetParams; + RecordTargetParams_t fTargetParams; Short_t fExpectedGlobalTdcOffset; Float_t fExpectedGlobalTimeOffset; std::string fRunName; @@ -172,6 +172,7 @@ class MeasInfo : public TObject void EnableChannel(UShort_t chId); Bool_t IsDisabledChannel(UShort_t chId); Bool_t IsSiliconChannel(UShort_t chId); + Bool_t IsSpinTuneChannel(UShort_t chId); UShort_t GetNumActiveSiChannels() const; UShort_t GetNumDisabledChannels() const; Bool_t IsPmtChannel(UShort_t chId) const; diff --git a/inc/SpinTuneMotor.h b/inc/SpinTuneMotor.h new file mode 100644 index 00000000..7e992de7 --- /dev/null +++ b/inc/SpinTuneMotor.h @@ -0,0 +1,44 @@ +#ifndef SPINTUNEMOTOR_H +#define SPINTUNEMOTOR_H +#include +#include +#include +class SpinTuneMotor +{ + public: + SpinTuneMotor(const unsigned long size = 6000000){ + //spinTM = (unsigned long long*) (size*sizeof(unsigned long long)); + spinTM = new unsigned long long[size]; + //memset(spinTM, 0, size);// * sizeof(unsigned long long)); + cntTM = 0; + printf("finish initializing spin tune\n"); + } + ~SpinTuneMotor(){ + //free(spinTM); + } + void Add(unsigned long long value){ + if(cntTM < 6000000){ + spinTM[cntTM] = value; + }else{ + printf("Memory Out of Range\n"); + } + cntTM++; + } + unsigned long long *Array() const{ + return spinTM; + } + unsigned long long At(unsigned int i) const{ + if(i < cntTM){ + return spinTM[i]; + }else + return 0; + } + unsigned int Size() const{ + return cntTM; + } + private: + unsigned long long *spinTM; + unsigned long cntTM; + +}; +#endif diff --git a/inc/SshLogReader.h b/inc/SshLogReader.h index 6072e06f..f7ced0ba 100644 --- a/inc/SshLogReader.h +++ b/inc/SshLogReader.h @@ -36,6 +36,13 @@ class SshLogReader : public opencdev::LogReader virtual void query_timerange(const string &logger, opencdev::cdev_time_t start, opencdev::cdev_time_t end, opencdev::result_t *values) override; virtual void query_fill(const string &logger, int fill_id, opencdev::result_t *values) override; virtual void get_fill_events(int fill_id, const string &ev_name, vector *values); + + /*zchang*/ + /* + //templateV val_add(V sum, const std::pair &p); + void calculate_mean(const opencdev::result_t &result, opencdev::mean_result_t *mean_result) const; + void query_timerange_mean(const std::string &logger, opencdev::cdev_time_t starttime, opencdev::cdev_time_t endtime, opencdev::mean_result_t *mean_result); + */ }; #endif diff --git a/inc/UserGroup.h b/inc/UserGroup.h new file mode 100644 index 00000000..293e8552 --- /dev/null +++ b/inc/UserGroup.h @@ -0,0 +1,33 @@ +#ifndef USER_GROUP_H +#define USER_GROUP_H +#include "TObject.h" +#include "TSystem.h" + +class UserGroup : public TObject{ + public: + UserGroup() : fUid(0), fGid(0), fUser(), fGroup(), fPasswd(), + fRealName (), fShell() { } + + Int_t fUid; // user id + Int_t fGid; // group id + TString fUser; // user name + TString fGroup; // group name + TString fPasswd; // password + TString fRealName; // user full name + TString fShell; // user preferred shell + + UserGroup& operator = (const UserGroup_t &ug){ + fUid = ug.fUid; + fGid = ug.fGid; + fUser = ug.fUser; + fGroup = ug.fGroup; + fPasswd = ug.fPasswd; + fRealName = ug.fRealName; + fShell = ug.fShell; + return *this; + } + private: + ClassDef(UserGroup, 1); +}; + +#endif diff --git a/script/r22asym.csh b/script/r22asym.csh new file mode 100755 index 00000000..6f1fbfe7 --- /dev/null +++ b/script/r22asym.csh @@ -0,0 +1,70 @@ +#!/bin/csh +set MY_HOME_DIR=/star/u/zchang + +if ( -e ${MY_HOME_DIR}/ASYMLOCK ) then + exit; +else + touch ${MY_HOME_DIR}/ASYMLOCK +# echo ${MY_HOME_DIR}/ASYMLOCK +endif + +#set CHECKINGPERIOD=60 # in sec + +source /star/u/zchang/.cshrc +source /star/u/zchang/.login + +source /star/u/zchang/run22/cnipol/script/r22setup.csh 22 > /dev/null + +setenv MY_REMOTE_HOME_DIR /home/cfsd/zchang +setenv CNIPOL_ONLINE_DIR /gpfs02/eic/eichome/cnipol/root + +set CNIPOL_REMOTE_BLUE_DATA_DIR=/home/blue/20$RUN_ID/data +set CNIPOL_REMOTE_YELLOW_DATA_DIR=/home/yellow/20$RUN_ID/data +set RUNLIST=/gpfs02/eic/cnipol/runXX/lists/run${RUN_ID}_all + +#echo PATH=$PATH +#echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH + +# check bluepc tunnel +date > ${MY_HOME_DIR}/TSTTUNBLU +rsync -av ${MY_HOME_DIR}/TSTTUNBLU bluepc:${MY_REMOTE_HOME_DIR}/. +rm ${MY_HOME_DIR}/TSTTUNBLU +rsync -av bluepc:${MY_REMOTE_HOME_DIR}/TSTTUNBLU ${MY_HOME_DIR}/. + +# check yellpc tunnel +date > ${MY_HOME_DIR}/TSTTUNYEL +rsync -av ${MY_HOME_DIR}/TSTTUNYEL yellpc:${MY_REMOTE_HOME_DIR}/. +rm ${MY_HOME_DIR}/TSTTUNYEL +rsync -av yellpc:${MY_REMOTE_HOME_DIR}/TSTTUNYEL ${MY_HOME_DIR}/. + +set blue_file_list="`rsync -av --min-size=500k --include='*.data' --exclude='*' bluepc:${CNIPOL_REMOTE_BLUE_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2`" +#echo "blue: $blue_file_list" +set yellow_file_list="`rsync -av --min-size=500k --include='*.data' --exclude='*' yellpc:${CNIPOL_REMOTE_YELLOW_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2`" +#echo "yellow: $yellow_file_list" +set file_list=`echo -n ${blue_file_list}${yellow_file_list} | grep -oP '\S*.data(?=\s|$)'` + +if ("$file_list" != "") then + echo Processing following files: + echo "$file_list" + @ counter = 0 + foreach file ($file_list) + echo $file >> ${RUNLIST} + set run_name=`echo $file | grep -oP "\S*(?=.data)"` + if ($counter == 4) then + wait + @ counter = 0 + endif + /usr/bin/nohup /star/u/zchang/run22/cnipol/script/runpc.csh ${run_name} >& /dev/null & + #/star/u/zchang/run22/cnipol/script/runpc.csh ${run_name} >& /dev/null + @ counter += 1 + end + cat ${RUNLIST} | sort | uniq > ${RUNLIST}.bak + mv ${RUNLIST}.bak ${RUNLIST} +endif + +wait +#/star/u/zchang/run22/cnipol/script/mAsymR22.csh +#/star/u/zchang/run22/cnipol/script/mAlphaR22.csh +rm ${MY_HOME_DIR}/ASYMLOCK +#sleep ${CHECKINGPERIOD} + diff --git a/script/r22setup.csh b/script/r22setup.csh new file mode 100755 index 00000000..29a642fc --- /dev/null +++ b/script/r22setup.csh @@ -0,0 +1,79 @@ +#!/bin/csh + +setenv RUN_ID 22 + +if ( $#argv > 0) then + setenv RUN_ID $argv[1] +endif + +#RUN_ID=$(printf '%02d' $RUN_ID) + +#RUN_ID=13 + +echo "Setting environment variables for RUN_ID=${RUN_ID}:" + +# ROOT +#setenv BOOST_ROOT /afs/rhic/x8664_sl6/opt/star/sl64_x8664_gcc482 +#setenv PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/bin:$PATH +#setenv LD_LIBRARY_PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/lib64:$LD_LIBRARY_PATH +#source /eicdata/eic0005/root_gcc49/bin/thisroot.sh +#setenv PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/bin:$PATH +#setenv LD_LIBRARY_PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/lib64:$LD_LIBRARY_PATH +#source /afs/rhic.bnl.gov/star/ROOT/5.34.38/.sl64_gcc482/rootdeb/bin/thisroot.csh + +# CERNLIB (required for online programs) +#setenv CERNLIB_DIR /cern/2006b +#setenv PATH $PATH\:${CERNLIB_DIR}/bin + +# MySQL +#setenv MYSQL_LIB_DIR=/usr/lib/mysql +#setenv MYSQLPP_LIB_DIR=/eicdata/eic0005/mysql++ +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQL_LIB_DIR +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQLPP_LIB_DIR +#echo "\$MYSQL_LIB_DIR=$MYSQL_LIB_DIR" +#echo "\$MYSQLPP_LIB_DIR=$MYSQLPP_LIB_DIR" + +setenv CNIPOL_DB_NAME cnipol +setenv CNIPOL_DB_HOST eicsrv1.sdcc.bnl.gov +setenv CNIPOL_DB_USER cnipol +setenv CNIPOL_DB_PASSWORD \(n\!P0l +echo $CNIPOL_DB_PASSWORD + +# CNIPOL +#setenv CNIPOL_DIR=~/pCpol/cnipol +setenv CNIPOL_DIR /star/u/zchang/run22/cnipol +setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/run$RUN_ID/data +setenv CNIPOL_RESULTS_DIR /gpfs02/eic/cnipol/run$RUN_ID/root +#setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/data +#setenv CNIPOL_RESULTS_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/root +#setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/run17/data +#setenv CNIPOL_RESULTS_DIR /eicdata/eic0005/run$RUN_ID/root_rp + +setenv PATH $PATH\:$CNIPOL_DIR/build +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$CNIPOL_DIR/build + +# UTILS +setenv UTILS_LIB_DIR $CNIPOL_DIR/build/contrib/root-helper/utils/ + +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$UTILS_LIB_DIR + +# CDEV +#setenv CDEV_DIR /usr/local/cdev +#setenv CDEVDDL ${CNIPOL_DIR}/online/cdev/PolarClient.ddl +#setenv CDEV_NAME_SERVER acnserver01.pbn.bnl.gov +#echo "CERNLIB_DIR=$CERNLIB_DIR" + +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:${CDEV_DIR}/lib +#echo "\$CDEV_DIR=$CDEV_DIR" +#echo "\$CDEVDDL=$CDEVDDL" +#echo "\$CDEV_NAME_SERVER=$CDEV_NAME_SERVER" +echo +echo "ROOTSYS=$ROOTSYS" +echo "CNIPOL_DIR=$CNIPOL_DIR" +echo "CNIPOL_DATA_DIR=$CNIPOL_DATA_DIR" +echo "CNIPOL_RESULTS_DIR=$CNIPOL_RESULTS_DIR" +echo +echo "UTILS_LIB_DIR=$UTILS_LIB_DIR" +echo +echo "PATH=$PATH" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/script/runAsymR22.cron b/script/runAsymR22.cron new file mode 100644 index 00000000..3e0fece4 --- /dev/null +++ b/script/runAsymR22.cron @@ -0,0 +1 @@ +*/1 * * * * /star/u/zchang/run22/cnipol/script/r22asym.csh > /dev/null diff --git a/script/runAsymR22.sh b/script/runAsymR22.sh new file mode 100755 index 00000000..39243702 --- /dev/null +++ b/script/runAsymR22.sh @@ -0,0 +1,64 @@ +#!/bin/bash +MY_HOME_DIR=/star/u/zchang + +if [ -e ${MY_HOME_DIR}/ASYMLOCK ]; then + exit; +else + touch ${MY_HOME_DIR}/ASYMLOCK +fi + +#CHECKINGPERIOD=60 # in sec + +source /star/u/zchang/run22/cnipol/script/setup.sh 22 > /dev/null + +MY_REMOTE_HOME_DIR=/home/cfsd/zchang + +CNIPOL_REMOTE_BLUE_DATA_DIR=/home/blue/20$RUN_ID/data +CNIPOL_REMOTE_YELLOW_DATA_DIR=/home/yellow/20$RUN_ID/data +CNIPOL_ONLINE_DIR=/gpfs02/eic/eichome/cnipol/root +RUNLIST=/gpfs02/eic/cnipol/runXX/lists/run${RUN_ID}_all + +echo "PATH=$PATH" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + + +# check bluepc tunnel +date > ${MY_HOME_DIR}/TSTTUNBLU +rsync -av ${MY_HOME_DIR}/TSTTUNBLU bluepc:${MY_REMOTE_HOME_DIR}/. +rm ${MY_HOME_DIR}/TSTTUNBLU +rsync -av bluepc:${MY_REMOTE_HOME_DIR}/TSTTUNBLU ${MY_HOME_DIR}/. + +# check yellpc tunnel +date > ${MY_HOME_DIR}/TSTTUNYEL +rsync -av ${MY_HOME_DIR}/TSTTUNYEL yellpc:${MY_REMOTE_HOME_DIR}/. +rm ${MY_HOME_DIR}/TSTTUNYEL +rsync -av yellpc:${MY_REMOTE_HOME_DIR}/TSTTUNYEL ${MY_HOME_DIR}/. + +blue_file_list="$(rsync -av --min-size=100k --include='*.data' --exclude='*' bluepc:${CNIPOL_REMOTE_BLUE_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2)" +yellow_file_list="$(rsync -av --min-size=100k --include='*.data' --exclude='*' yellpc:${CNIPOL_REMOTE_YELLOW_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2)" + +file_list="$(echo -n "${blue_file_list}${yellow_file_list}" | egrep "\.data$" | sort)" + +echo Processing following files: +echo "$file_list" +echo "$file_list" >> ${RUNLIST} +cat ${RUNLIST} | sort | uniq > ${RUNLIST}.bak +mv ${RUNLIST}.bak ${RUNLIST} + +echo "$file_list" | while read -r file_name; do + if [[ ! -z $file_name ]]; then + run_name=${file_name%.data} + args="--update-db -g -r $run_name" + #args="-g -r $run_name" + if [[ $run_name == *".alpha0" ]]; then + args="--alpha $args" + fi + echo $CNIPOL_DIR/build/asym $args + ls $CNIPOL_DIR/build/asym + $CNIPOL_DIR/build/asym $args + rsync -av --exclude='*.root' ${CNIPOL_RESULTS_DIR}/${run_name} ${CNIPOL_ONLINE_DIR} > /dev/null + fi +done +rm ${MY_HOME_DIR}/ASYMLOCK +#sleep ${CHECKINGPERIOD} + diff --git a/script/run_asym_r22.sh b/script/run_asym_r22.sh new file mode 100755 index 00000000..e9d04471 --- /dev/null +++ b/script/run_asym_r22.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +CHECKINGPERIOD=60 # in sec + +source /star/u/zchang/run22/cnipol/script/setup.sh 22 > /dev/null + +MY_HOME_DIR=/star/u/zchang +MY_REMOTE_HOME_DIR=/home/cfsd/zchang + +CNIPOL_REMOTE_BLUE_DATA_DIR=/home/blue/20$RUN_ID/data +CNIPOL_REMOTE_YELLOW_DATA_DIR=/home/yellow/20$RUN_ID/data +CNIPOL_ONLINE_DIR=/gpfs02/eic/eichome/cnipol/root +RUNLIST=/gpfs02/eic/cnipol/runXX/lists/run${RUN_ID}_all + +while true; do + if [ -e ${MY_HOME_DIR}/ASYMLOCK ]; then + exit; + else + touch ${MY_HOME_DIR}/ASYMLOCK + fi + + # check bluepc tunnel + date > ${MY_HOME_DIR}/TSTTUNBLU + rsync -av ${MY_HOME_DIR}/TSTTUNBLU bluepc:${MY_REMOTE_HOME_DIR}/. + rm ${MY_HOME_DIR}/TSTTUNBLU + rsync -av bluepc:${MY_REMOTE_HOME_DIR}/TSTTUNBLU ${MY_HOME_DIR}/. + + # check yellpc tunnel + date > ${MY_HOME_DIR}/TSTTUNYEL + rsync -av ${MY_HOME_DIR}/TSTTUNYEL yellpc:${MY_REMOTE_HOME_DIR}/. + rm ${MY_HOME_DIR}/TSTTUNYEL + rsync -av yellpc:${MY_REMOTE_HOME_DIR}/TSTTUNYEL ${MY_HOME_DIR}/. + + blue_file_list="$(rsync -av --min-size=100k --include='*.data' --exclude='*' bluepc:${CNIPOL_REMOTE_BLUE_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2)" + yellow_file_list="$(rsync -av --min-size=100k --include='*.data' --exclude='*' yellpc:${CNIPOL_REMOTE_YELLOW_DATA_DIR}/ ${CNIPOL_DATA_DIR}/ | tee -a /dev/fd/2)" + + file_list="$(echo -n "${blue_file_list}${yellow_file_list}" | egrep "\.data$" | sort)" + + echo Processing following files: + echo "$file_list" + echo "$file_list" >> ${RUNLIST} + cat ${RUNLIST} | sort | uniq > ${RUNLIST}.bak + mv ${RUNLIST}.bak ${RUNLIST} + + echo "$file_list" | while read -r file_name; do + if [[ ! -z $file_name ]]; then + run_name=${file_name%.data} + args="--update-db -g -r $run_name" + #args="-g -r $run_name" + if [[ $run_name == *".alpha0" ]]; then + args="--alpha $args" + fi + echo $CNIPOL_DIR/build/asym $args + $CNIPOL_DIR/build/asym $args + rsync -av --exclude='*.root' ${CNIPOL_RESULTS_DIR}/${run_name} ${CNIPOL_ONLINE_DIR} > /dev/null + fi + done + rm ${MY_HOME_DIR}/ASYMLOCK + sleep ${CHECKINGPERIOD} +# exit +done diff --git a/script/runstar.cron b/script/runstar.cron new file mode 100644 index 00000000..0b87ee1c --- /dev/null +++ b/script/runstar.cron @@ -0,0 +1 @@ +*/1 * * * * /star/u/zchang/run22/cnipol/script/runstar.csh > /dev/null diff --git a/script/runstar.csh b/script/runstar.csh new file mode 100755 index 00000000..2424bd84 --- /dev/null +++ b/script/runstar.csh @@ -0,0 +1,39 @@ +#!/bin/csh + +#set dir=`pwd` +source /star/u/zchang/.login +source /star/u/zchang/.cshrc + +source /star/u/zchang/run22/cnipol/script/r22setup.csh 22 > /dev/null + +#set MY_REMOTE_HOME_DIR=/home/cfsd/zchang + +#set CNIPOL_REMOTE_BLUE_DATA_DIR=/home/blue/20$RUN_ID/data +#set CNIPOL_REMOTE_YELLOW_DATA_DIR=/home/yellow/20$RUN_ID/data +setenv CNIPOL_ONLINE_DIR /gpfs02/eic/eichome/cnipol/root +#exec /star/u/zchang/run22/cnipol/script/runAsymR22.sh + +#set fill=32923 +#set names = ("304" "305" "306" "307" "308" "309" "310" "311" "312" "313" "314" "315" "316" "317") +#set names = ("005" "205" "206") +set fill=32960 +set names = ("204" "005" "104") +set opt="" +#set opt="--spin-pattern 13 --fill-pattern 1" +#set names = ("305" "304" "105") +#set opt="--spin-pattern 3 --fill-pattern 1" +@ cntr=0 +foreach nn ($names) + echo $fill.$nn.data + if ( $cntr == 4) then + wait + @ cntr=0 + endif + #/usr/bin/nohup sleep 10 & + echo $cntr + /usr/bin/nohup ./runtest.csh $fill.$nn $opt>& /dev/null & + #./runtest.csh $fill.$nn $opt + @ cntr += 1 +end + +wait diff --git a/script/setup.csh b/script/setup.csh new file mode 100755 index 00000000..97359246 --- /dev/null +++ b/script/setup.csh @@ -0,0 +1,79 @@ +#!/bin/csh + +setenv RUN_ID 22 + +if ( $#argv > 0) then + setenv RUN_ID $argv[1] +endif + +#RUN_ID=$(printf '%02d' $RUN_ID) + +#RUN_ID=13 + +echo "Setting environment variables for RUN_ID=${RUN_ID}:" + +# ROOT +#setenv BOOST_ROOT /afs/rhic/x8664_sl6/opt/star/sl64_x8664_gcc482 +#setenv PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/bin:$PATH +#setenv LD_LIBRARY_PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/lib64:$LD_LIBRARY_PATH +#source /eicdata/eic0005/root_gcc49/bin/thisroot.sh +#setenv PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/bin:$PATH +#setenv LD_LIBRARY_PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/lib64:$LD_LIBRARY_PATH +#source /afs/rhic.bnl.gov/star/ROOT/5.34.38/.sl64_gcc482/rootdeb/bin/thisroot.csh + +# CERNLIB (required for online programs) +#setenv CERNLIB_DIR /cern/2006b +#setenv PATH $PATH\:${CERNLIB_DIR}/bin + +# MySQL +#setenv MYSQL_LIB_DIR=/usr/lib/mysql +#setenv MYSQLPP_LIB_DIR=/eicdata/eic0005/mysql++ +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQL_LIB_DIR +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQLPP_LIB_DIR +#echo "\$MYSQL_LIB_DIR=$MYSQL_LIB_DIR" +#echo "\$MYSQLPP_LIB_DIR=$MYSQLPP_LIB_DIR" + +setenv CNIPOL_DB_NAME cnipol +setenv CNIPOL_DB_HOST eicsrv1.sdcc.bnl.gov +setenv CNIPOL_DB_USER cnipol +setenv CNIPOL_DB_PASSWORD \(n\!P0l +echo $CNIPOL_DB_PASSWORD + +# CNIPOL +#setenv CNIPOL_DIR=~/pCpol/cnipol +setenv CNIPOL_DIR /star/u/zchang/run22/cnipol +#setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/run$RUN_ID/data +#setenv CNIPOL_RESULTS_DIR /gpfs02/eic/cnipol/run$RUN_ID/root +setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/data +setenv CNIPOL_RESULTS_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/root +#setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/run17/data +#setenv CNIPOL_RESULTS_DIR /eicdata/eic0005/run$RUN_ID/root_rp + +setenv PATH $PATH\:$CNIPOL_DIR/test +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$CNIPOL_DIR/test + +# UTILS +setenv UTILS_LIB_DIR $CNIPOL_DIR/test/contrib/root-helper/utils/ + +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$UTILS_LIB_DIR + +# CDEV +#setenv CDEV_DIR /usr/local/cdev +#setenv CDEVDDL ${CNIPOL_DIR}/online/cdev/PolarClient.ddl +#setenv CDEV_NAME_SERVER acnserver01.pbn.bnl.gov +#echo "CERNLIB_DIR=$CERNLIB_DIR" + +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:${CDEV_DIR}/lib +#echo "\$CDEV_DIR=$CDEV_DIR" +#echo "\$CDEVDDL=$CDEVDDL" +#echo "\$CDEV_NAME_SERVER=$CDEV_NAME_SERVER" +echo +echo "ROOTSYS=$ROOTSYS" +echo "CNIPOL_DIR=$CNIPOL_DIR" +echo "CNIPOL_DATA_DIR=$CNIPOL_DATA_DIR" +echo "CNIPOL_RESULTS_DIR=$CNIPOL_RESULTS_DIR" +echo +echo "UTILS_LIB_DIR=$UTILS_LIB_DIR" +echo +echo "PATH=$PATH" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/script/setup.sh b/script/setup.sh index b0c0d350..dc2bdb26 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,74 +1,49 @@ #!/bin/bash -if [ -n "$1" ]; then RUN_ID=$1; else RUN_ID="13"; fi +if [ -n "$1" ]; then + export RUN_ID=$1 +else + export RUN_ID="22" +fi -#RUN_ID=$(printf '%02d' $RUN_ID) - -#RUN_ID=13 - -echo "Setting environment variables for RUN_ID=$RUN_ID:" - -# ROOT -export BOOST_ROOT=/afs/rhic/x8664_sl6/opt/star/sl64_x8664_gcc482 -export PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/bin:$PATH -export LD_LIBRARY_PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/lib64:$LD_LIBRARY_PATH -source /eicdata/eic0005/root_gcc49/bin/thisroot.sh - -# CERNLIB (required for online programs) -export CERNLIB_DIR=/cern/2006b -export PATH+=:$CERNLIB_DIR/bin - -# MySQL -export MYSQL_LIB_DIR=/usr/lib/mysql -export MYSQLPP_LIB_DIR=/eicdata/eic0005/mysql++ +echo "Setting environment variables for RUN_ID=${RUN_ID}" export CNIPOL_DB_NAME="cnipol" -#export CNIPOL_DB_HOST="pc2pc.phy.bnl.gov" -export CNIPOL_DB_HOST="eicsrv1.phy.bnl.gov" +export CNIPOL_DB_HOST="eicsrv1.sdcc.bnl.gov" export CNIPOL_DB_USER="cnipol" export CNIPOL_DB_PASSWORD="(n!P0l" - -export LD_LIBRARY_PATH+=:$MYSQL_LIB_DIR -export LD_LIBRARY_PATH+=:$MYSQLPP_LIB_DIR +#echo $CNIPOL_DB_PASSWORD # CNIPOL -#export CNIPOL_DIR=~/pCpol/cnipol -export CNIPOL_DIR=/direct/eic+u/schmidke/pCpro/pro2/cnipol -export CNIPOL_DATA_DIR=/eicdata/eic0005/run$RUN_ID/data -#export CNIPOL_RESULTS_DIR=/eicdata/eic0005/run$RUN_ID/root_rp -export CNIPOL_RESULTS_DIR=/eicdata/eic0005/run$RUN_ID/root -#export CNIPOL_RESULTS_DIR=/star/u/gdwebb/pCpol/polroot +export CNIPOL_DIR=/star/u/zchang/run22/cnipol +export CNIPOL_DATA_DIR=/gpfs02/eic/cnipol/run$RUN_ID/data +export CNIPOL_RESULTS_DIR=/gpfs02/eic/cnipol/run$RUN_ID/root -export PATH+=:$CNIPOL_DIR/build -export LD_LIBRARY_PATH+=:$CNIPOL_DIR/build +export PATH=$PATH\:$CNIPOL_DIR/build +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH\:$CNIPOL_DIR/build # UTILS export UTILS_LIB_DIR=$CNIPOL_DIR/build/contrib/root-helper/utils/ -export LD_LIBRARY_PATH+=:$UTILS_LIB_DIR +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH\:$UTILS_LIB_DIR # CDEV -export CDEV_DIR=/usr/local/cdev -export CDEVDDL=${CNIPOL_DIR}/online/cdev/PolarClient.ddl -export CDEV_NAME_SERVER=acnserver01.pbn.bnl.gov - -export LD_LIBRARY_PATH+=:${CDEV_DIR}/lib - - -echo "\$ROOTSYS=$ROOTSYS" -echo "\$CERNLIB_DIR=$CERNLIB_DIR" -echo "\$CNIPOL_DIR=$CNIPOL_DIR" -echo "\$CNIPOL_DATA_DIR=$CNIPOL_DATA_DIR" -echo "\$CNIPOL_RESULTS_DIR=$CNIPOL_RESULTS_DIR" -echo -echo "\$UTILS_LIB_DIR=$UTILS_LIB_DIR" +#export CDEV_DIR=/usr/local/cdev +#export CDEVDDL=${CNIPOL_DIR}/online/cdev/PolarClient.ddl +#export CDEV_NAME_SERVER=acnserver01.pbn.bnl.gov +#echo "CERNLIB_DIR=$CERNLIB_DIR" + +#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH\:${CDEV_DIR}/lib +#echo "\$CDEV_DIR=$CDEV_DIR" +#echo "\$CDEVDDL=$CDEVDDL" +#echo "\$CDEV_NAME_SERVER=$CDEV_NAME_SERVER" echo -echo "\$MYSQL_LIB_DIR=$MYSQL_LIB_DIR" -echo "\$MYSQLPP_LIB_DIR=$MYSQLPP_LIB_DIR" +echo "ROOTSYS=$ROOTSYS" +echo "CNIPOL_DIR=$CNIPOL_DIR" +echo "CNIPOL_DATA_DIR=$CNIPOL_DATA_DIR" +echo "CNIPOL_RESULTS_DIR=$CNIPOL_RESULTS_DIR" echo -echo "\$CDEV_DIR=$CDEV_DIR" -echo "\$CDEVDDL=$CDEVDDL" -echo "\$CDEV_NAME_SERVER=$CDEV_NAME_SERVER" +echo "UTILS_LIB_DIR=$UTILS_LIB_DIR" echo -echo "\$PATH=$PATH" -echo "\$LD_LIBRARY_PATH=$LD_LIBRARY_PATH" +echo "PATH=$PATH" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/script/setup64b.csh b/script/setup64b.csh new file mode 100755 index 00000000..11ebf78d --- /dev/null +++ b/script/setup64b.csh @@ -0,0 +1,79 @@ +#!/bin/csh + +setup 64b + +set RUN_ID="22" + +if ( $#argv > 0) then + set RUN_ID=$argv[1] +endif + +#RUN_ID=$(printf '%02d' $RUN_ID) + +#RUN_ID=13 + +echo "Setting environment variables for RUN_ID=${RUN_ID}:" + +# ROOT +#setenv BOOST_ROOT /afs/rhic/x8664_sl6/opt/star/sl64_x8664_gcc482 +#setenv PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/bin:$PATH +#setenv LD_LIBRARY_PATH=/afs/rhic/rcassoft/x8664_sl6/gcc492/lib64:$LD_LIBRARY_PATH +#source /eicdata/eic0005/root_gcc49/bin/thisroot.sh +#setenv PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/bin:$PATH +#setenv LD_LIBRARY_PATH /afs/rhic/rcassoft/x8664_sl6/gcc482/lib64:$LD_LIBRARY_PATH +#source /afs/rhic.bnl.gov/star/ROOT/5.34.38/.sl64_gcc482/rootdeb/bin/thisroot.csh + +# CERNLIB (required for online programs) +setenv CERNLIB_DIR /cern/2006b +setenv PATH $PATH\:${CERNLIB_DIR}/bin + +# MySQL +#setenv MYSQL_LIB_DIR=/usr/lib/mysql +#setenv MYSQLPP_LIB_DIR=/eicdata/eic0005/mysql++ +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQL_LIB_DIR +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$MYSQLPP_LIB_DIR +#echo "\$MYSQL_LIB_DIR=$MYSQL_LIB_DIR" +#echo "\$MYSQLPP_LIB_DIR=$MYSQLPP_LIB_DIR" + +setenv CNIPOL_DB_NAME cnipol +setenv CNIPOL_DB_HOST eicsrv1.sdcc.bnl.gov +setenv CNIPOL_DB_USER cnipol +setenv CNIPOL_DB_PASSWORD \(n\!P0l +echo $CNIPOL_DB_PASSWORD + +# CNIPOL +#setenv CNIPOL_DIR=~/pCpol/cnipol +setenv CNIPOL_DIR /star/u/zchang/run22/cnipol +setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/data +#setenv CNIPOL_DATA_DIR /gpfs02/eic/cnipol/run17/data +#setenv CNIPOL_RESULTS_DIR /eicdata/eic0005/run$RUN_ID/root_rp +setenv CNIPOL_RESULTS_DIR /gpfs02/eic/cnipol/zchang/run$RUN_ID/root + +setenv PATH $PATH\:$CNIPOL_DIR/build +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$CNIPOL_DIR/build + +# UTILS +setenv UTILS_LIB_DIR $CNIPOL_DIR/build/contrib/root-helper/utils/ + +setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:$UTILS_LIB_DIR + +# CDEV +#setenv CDEV_DIR /usr/local/cdev +#setenv CDEVDDL ${CNIPOL_DIR}/online/cdev/PolarClient.ddl +#setenv CDEV_NAME_SERVER acnserver01.pbn.bnl.gov + +#setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\:${CDEV_DIR}/lib +#echo "\$CDEV_DIR=$CDEV_DIR" +#echo "\$CDEVDDL=$CDEVDDL" +#echo "\$CDEV_NAME_SERVER=$CDEV_NAME_SERVER" +echo +echo "ROOTSYS=$ROOTSYS" +echo "CERNLIB_DIR=$CERNLIB_DIR" +echo "CNIPOL_DIR=$CNIPOL_DIR" +echo "CNIPOL_DATA_DIR=$CNIPOL_DATA_DIR" +echo "CNIPOL_RESULTS_DIR=$CNIPOL_RESULTS_DIR" +echo +echo "UTILS_LIB_DIR=$UTILS_LIB_DIR" +echo +echo "PATH=$PATH" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" diff --git a/src/AfterBurner.cxx b/src/AfterBurner.cxx new file mode 100644 index 00000000..036db194 --- /dev/null +++ b/src/AfterBurner.cxx @@ -0,0 +1,114 @@ +// fit one set of spin U/D detector hits for aymmetry etc. +// +// input: nup[6] - # Up hits in [det = 0-5] +// nup[6] - # Dn hits in [det = 0-5] +// fixpar - integer, bit(s) 0-2 = 1 => fix paramater(2) 0-2 to value in par[0-2] +// +// output: par[3] - results [0]=asymmetry magnitude, [1]=spin tilt (rad.), [2]=lumi asym. +// epar[3] - error +// chi2 - minimized chi-square +// +// +#include "AfterBurner.h" + +#include "TVirtualFitter.h" +#include "TGraph2D.h" +#include "TMath.h" + +using namespace TMath; + +// function prototypes: + +void afterburner::fit1asym(double nup[] , double ndn[] , double par[], double epar[] , double &chi2, int fixpar) +{ + + double phidet[6] = { 45. , 90. , 135. , 225. , 270. , 315. }; + + // fitter wants a TObject to fit: TGraph2D X=phi, Y=nhits_up, Z=nhits_dn + TGraph2D* gdata = new TGraph2D(); + int npfit = 0; + for (int i=0; i<6; i++){ + if ( nup[i]>0. && ndn[i]>0. ) { // require hits in detector + gdata->SetPoint(npfit,DegToRad()*phidet[i],nup[i],ndn[i]); + npfit++; + } + } + + // set up fitter + TVirtualFitter::SetDefaultFitter("Minuit"); // default is Minuit + TVirtualFitter *fitter = TVirtualFitter::Fitter(0, 3); // need to check what this means; 3=nparam + fitter->SetFCN(myFcn); + fitter->TVirtualFitter::SetObjectFit(gdata); + + // define pareters with reasonable init. values and ranges, fix if specified: + if (!(fixpar & 1)) { + fitter->SetParameter(0, "epsilon", 0.01, 0.001, 0., 0.02); + } + else { + fitter->SetParameter(0, "epsilon", par[0], 0., par[0], par[0]); fitter->FixParameter(0); + } + if (!(fixpar & 2)) { + fitter->SetParameter(1, "phi", 0., 0.001, -Pi(), Pi()); + } + else { + fitter->SetParameter(1, "phi", par[1], 0., par[1], par[1]); fitter->FixParameter(1); + } + if (!(fixpar & 4)) { + fitter->SetParameter(2, "lambda", 0., 0.001, -1., 1.); + } + else { + fitter->SetParameter(2, "lambda", par[2], 0., par[2], par[2]); fitter->FixParameter(2); + } + /* + // fixed parmaeters: + if (fixpar & 4) { + fitter->SetParameter(2, "lambda", par[2], 0., par[2], par[2]); + fitter->FixParameter(2); + } + */ + Double_t arglist[1] = {0}; + fitter->ExecuteCommand("MIGRAD", arglist, 0); + + for (int i=0; i<3; i++) {par[i] = fitter->GetParameter(i); epar[i] = fitter->GetParError(i);} + + Int_t nPar; Double_t *grad = 0x0; + myFcn(nPar,grad,chi2,par,0); + +} + +// fit function: (form of user func. from tutorials/fit/fit2dHist.C) +void afterburner::myFcn(int & /*nPar*/, double * /*grad*/ , double &fval, double *par, int /*iflag */ ) +{ + + TGraph2D * gdata = dynamic_cast( (TVirtualFitter::GetFitter())->GetObjectFit() ); + + double epsilon = par[0]; double phi = par[1]; double lambda = par[2]; + + fval = 0.; + + for (int i=0; iGetN(); i++) { + double phidet = gdata->GetX()[i]; + double asymfit = epsilon * Sin(phidet - phi); + + double nup = gdata->GetY()[i]; double ndn = gdata->GetZ()[i]; + pair asympair = asym_err(lambda,nup,ndn); + double asym = asympair.first; double easym = asympair.second; + + fval += pow(asym-asymfit,2) / pow(easym,2); + } + +} + +// asymmetry & error pair: +pair afterburner::asym_err(double lambda, double nup, double ndn) +{ + pair result; + + double denom = ( (1.-lambda)*nup + (1.+lambda)*ndn ); + + result.first = ( (1.-lambda)*nup - (1.+lambda)*ndn ) / denom; + result.second = 2.*(1.-pow(lambda,2))*Sqrt(nup*ndn*(nup+ndn)) / pow(denom,2); + + return result; + +} diff --git a/src/AnaFillExternResult.cxx b/src/AnaFillExternResult.cxx index ea088442..1cbbe667 100644 --- a/src/AnaFillExternResult.cxx +++ b/src/AnaFillExternResult.cxx @@ -64,8 +64,10 @@ void AnaFillExternResult::LoadAgsInfo(opencdev::LogReader &log_reader) log_reader.query_timerange("Ags/Polarized_protons/CNIpolarimeter", ags_time_start, ags_time_end, &ags_pol_result); + { std::map &values = ags_pol_result["start"]; + //Printf("ags size: %d", values.size()); fAgsPolFitGraph = new TGraphErrors(values.size()); int i = 0; @@ -73,11 +75,41 @@ void AnaFillExternResult::LoadAgsInfo(opencdev::LogReader &log_reader) { opencdev::cdev_time_t time = it->first; double startTime = it->second; - + Printf("time: %.0lf start: %.0lf pol: %lf", time, startTime, ags_pol_result["AgsPolarFit"][time]); fAgsPolFitGraph->SetPoint(i, (startTime + time) / 2, ags_pol_result["AgsPolarFit"][time]); fAgsPolFitGraph->SetPointError(i, fabs(startTime - time) / 2, ags_pol_result["AgsPolarFitErr"][time]); + //fAgsPolFitGraph->SetPoint(i, time, ags_pol_result["AgsPolarFit"][time]); + //fAgsPolFitGraph->SetPointError(i, 0, ags_pol_result["AgsPolarFitErr"][time]); i++; } + //fAgsPolFitGraph->Print(); + } +} + +void AnaFillExternResult::LoadAgsInfo(opencdev::LogReader &log_reader, int fillId) +{ + opencdev::result_t ags_pol_result; + + log_reader.query_fill("RHIC/Analysis/FDAImport/FDAcombined", fillId, &ags_pol_result); + + { + const map &values = ags_pol_result["agsPolT1"]; + const map &errors = ags_pol_result["agsPolT1Err"]; + fAgsPolFitGraph = new TGraphErrors(values.size()); + int i = 0; + std::map::const_iterator ie = errors.begin(); + for(std::map::const_iterator it = values.begin(); it != values.end(); it++) + { + opencdev::cdev_time_t time = it->first; + double pol = it->second; + opencdev::cdev_time_t time_e = ie->first; + double polerr = ie->second; + Printf("Loading AGS polarization: %.0lf(%.0lf) pol: %lg +/- %lg", time, time_e, pol, polerr); + fAgsPolFitGraph->SetPoint(i, (time + time_e) / 2, pol); + fAgsPolFitGraph->SetPointError(i, fabs(time - time_e) / 2, polerr); + i++;ie++; + } + //fAgsPolFitGraph->Print(); } } @@ -137,6 +169,7 @@ void AnaFillExternResult::LoadInfo(UInt_t fillId) opencdev::result_t bc_result; log_reader.query_fill("RHIC/Polarimeter/Blue/biasReadbacks", fillId, &bc_result); log_reader.query_fill("RHIC/Polarimeter/Yellow/biasReadbacks", fillId, &bc_result); + //Printf("bias readbacks"); for(opencdev::result_t::const_iterator it = bc_result.begin(); it != bc_result.end(); it++) { const string &key = it->first; @@ -144,11 +177,14 @@ void AnaFillExternResult::LoadInfo(UInt_t fillId) EPolarimeterId polId = BiasCurrentUtil::ParseLoggerPolId(key); TGraphErrors *gr = MakeGraph(values); + //Printf("Bias Current Graph %s", key.c_str()); + //gr->Print();//zchang debug fBCCurGraph[polId].push_back(gr); } - + //Printf("on: %ld off: %ld", fTimeEventLumiOn, fTimeEventLumiOff); if (fTimeEventLumiOn && fTimeEventLumiOff) { - LoadAgsInfo(log_reader); + LoadAgsInfo(log_reader, fillId); + //LoadAgsInfo(log_reader); } } diff --git a/src/AnaFillResult.cxx b/src/AnaFillResult.cxx index ed21a7b1..019d94dd 100644 --- a/src/AnaFillResult.cxx +++ b/src/AnaFillResult.cxx @@ -24,6 +24,7 @@ using namespace std; AnaFillResult::AnaFillResult(UInt_t fillId) : TObject(), fFillId(fillId), fAnaGlobResult(0), fStartTime(LONG_MAX), fEndTime(0), fAnaFillExternResult(fillId), fPCPolarGraphs(), fPCPolarInjGraphs(), fPCProfRGraphs(), fPCProfRInjGraphs(), + fPCPolarPhaseGraphs(), fPCPolarPhaseInjGraphs(), fPCTargets(), fPCPolarFitRes(), fPolProfRFitRes(), fAgsPolFitRes(), @@ -31,6 +32,7 @@ AnaFillResult::AnaFillResult(UInt_t fillId) : TObject(), fFillId(fillId), fFillType(kFILLTYPE_UNKNOWN), fAnaMeasResults(), fMeasInfos(), fMeasInfosByPolId(), fPCPolars(), fPCPolarUnWs(), + fPCPolarPhases(), fPCProfRs(), fPCPolarsByTargets(), fPCProfPolars(), fHJPolars(), fHJAsyms(), @@ -192,9 +194,11 @@ ValErrPair AnaFillResult::GetIntensDecay(ERingId ringId) const Warning("GetIntensDecay", "Fill %d. No fit function defined in intensity graph for ringId %d", fFillId, ringId); return decay; } - - decay.first = func->GetParameter(1); - decay.second = func->GetParError(1); + double p1 = func->GetParameter(1); + double p1e = func->GetParError(1); + double ff = TMath::Log(0.99); + decay.first = p1 < 0 ? ff/p1 : 0; + decay.second = p1 < 0 ? -ff*p1e/p1/p1 : -1; return decay; } @@ -282,6 +286,7 @@ void AnaFillResult::AddMeasResult(EventConfig &mm) //Info("AddMeasResult", "fStartTime %d (meas)", mm.fMeasInfo->fStartTime); //Info("AddMeasResult", "fStartTime %d", GetStartTime()); + //Printf("AddMeasResult fStartTime %ld", GetStartTime()); // add or overwrite new AnaFillResult fAnaMeasResults[runName] = *mm.fAnaMeasResult; @@ -356,10 +361,15 @@ void AnaFillResult::Process(DrawObjContainer *ocOut) // Get polar meas result ValErrPair polarPC = anaMeasResult.GetPCPolar(); ValErrPair profRPC = anaMeasResult.GetPCProfR(); + ValErrPair phasePC = anaMeasResult.GetPCPolarPhase(); // Skip invalid results indicated by negative uncertainty - if (polarPC.second < 0 || profRPC.second < 0) continue; - + //if (polarPC.second < 0 || profRPC.second < 0) continue; + //Info("Process: ", "polarPC %lg +/- %lg", polarPC.first, polarPC.second); + //Info("Process: ", "profR %lg +/- %lg", profRPC.first, profRPC.second); + //Info("Process: ", "phase %lg +/- %lg", phasePC.first, phasePC.second); + if (polarPC.second < 0 || profRPC.second < 0 || phasePC.second < 0) continue; + //Info("Process: ", "meas start time %ld, start time %ld", anaMeasResult.GetStartTime(), GetStartTime()); time_t measRelTime = anaMeasResult.GetStartTime() - GetStartTime(); // Pick the graph for this measurement and corresponding polarimeter @@ -368,10 +378,12 @@ void AnaFillResult::Process(DrawObjContainer *ocOut) { AppendToPCPolarInjGraph(polId, measRelTime, polarPC.first, 0, polarPC.second); AppendToPCProfRInjGraph(polId, tgtOrient, measRelTime, profRPC.first, 0, profRPC.second); + AppendToPCPolarPhaseInjGraph(polId, measRelTime, phasePC.first, 0, phasePC.second); } else { AppendToPCPolarGraph(polId, measRelTime, polarPC.first, 0, polarPC.second); AppendToPCProfRGraph(polId, tgtOrient, measRelTime, profRPC.first, 0, profRPC.second); - + AppendToPCPolarPhaseGraph(polId, measRelTime, phasePC.first, 0, phasePC.second); + TargetUId newTarget(polId, tgtOrient, tgtId); TargetUId& curTarget = fPCTargets[polId]; @@ -423,6 +435,7 @@ void AnaFillResult::Process(DrawObjContainer *ocOut) // Calculate average polarizations fPCPolars[polId] = CalcAvrgPolar(polId); fPCPolarUnWs[polId] = CalcAvrgPolarUnweighted(polId); + fPCPolarPhases[polId] = CalcAvrgPolarPhase(polId); fPCProfPolars[polId] = CalcAvrgPolProfPolar(polId); fPCPolarsByTargets[fPCTargets[polId]] = fPCPolars[polId]; @@ -438,6 +451,7 @@ void AnaFillResult::Process(DrawObjContainer *ocOut) //fPCProfRInjs[polId][tgtOrient] = CalcAvrgProfRInj(polId, tgtOrient); fPCProfRs[polId][tgtOrient] = CalcAvrgProfR(polId, tgtOrient); //printf("fPCProfRs: %f, %f\n", fPCProfRs[polId][tgtOrient].first, fPCProfRs[polId][tgtOrient].second); + Info("Process", "polId %d, tgtOrient %d, fPCProfRs: %lg +/- %lg", polId, tgtOrient, fPCProfRs[polId][tgtOrient].first, fPCProfRs[polId][tgtOrient].second); } @@ -529,6 +543,23 @@ ValErrPair AnaFillResult::GetPCPolarUnW(EPolarimeterId polId, PolId2ValErrMap *n return result; } +/** */ +ValErrPair AnaFillResult::GetPCPolarPhase(EPolarimeterId polId) const +{ + ValErrPair pcPhase(0, -1); + + PolId2ValErrMapConstIter iPolar = fPCPolarPhases.find(polId); + + if (iPolar != fPCPolarPhases.end() ) + { + pcPhase.first = iPolar->second.first; + pcPhase.second = iPolar->second.second; + } + + return pcPhase; +} + + /** Function can return an empty graph. */ TGraphErrors* AnaFillResult::GetPCPolarGraph(EPolarimeterId polId) const @@ -1048,14 +1079,18 @@ ValErrPair AnaFillResult::CalcAvrgPolar(EPolarimeterId polId) denom += intens; // assume no correlation between the polarization slope (par1) and norm (par0) - polarErr = sqrt( polarSlopeErr*polarSlopeErr*(time - GetLumiOnRelTime())*(time - GetLumiOnRelTime())/3600/3600 + polarNormErr*polarNormErr); + //polarErr = sqrt( polarSlopeErr*polarSlopeErr*(time - GetLumiOnRelTime())*(time - GetLumiOnRelTime())/3600/3600 + polarNormErr*polarNormErr); + //zchang + polarErr = (time - GetLumiOnRelTime())/3600; numerErr += polarErr*intens; denomErr += intens; } // Internaly all polarization values are between 0 and 1 except graphs avrgPol.first = numer/denom/100.; - avrgPol.second = numerErr/denomErr/100.; // weighted error + //avrgPol.second = numerErr/denomErr/100.; // weighted error + //zchang + avrgPol.second = TMath::Sqrt(TMath::Power(numerErr/denomErr*polarSlopeErr, 2)+TMath::Power(polarNormErr, 2))/100.; // weighted error return avrgPol; } @@ -1083,9 +1118,9 @@ ValErrPair AnaFillResult::CalcAvrgPolarUnweighted(EPolarimeterId polId) // Exclude points only if the lumi/phys period is defined && > 600 sec // Otherwise include all available measurements in the average - if ( abs(GetLumiOffRelTime() - GetLumiOnRelTime()) > 600 && - (time < GetLumiOnRelTime() || time > GetLumiOffRelTime()) ) continue; - + //if ( abs(GetLumiOffRelTime() - GetLumiOnRelTime()) > 600 && + // (time < GetLumiOnRelTime() || time > GetLumiOffRelTime()) ) continue; + //zchang polarErr = grPCPolar->GetErrorY(iPoint); // Internaly all polarization values are between 0 and 1 except graphs @@ -1097,6 +1132,42 @@ ValErrPair AnaFillResult::CalcAvrgPolarUnweighted(EPolarimeterId polId) return avrgPol; } +/** */ +ValErrPair AnaFillResult::CalcAvrgPolarPhase(EPolarimeterId polId) +{ + // Create a container to keep all measurements for polarimeter polId + ValErrPair avrgPhase(0, -1); + + const TGraphErrors *grPCPolarPhase = GetPCPolarPhaseGraph(polId); + + if (!grPCPolarPhase) { + Warning("CalcAvrgPolarPhase", "No graph defined for polId %d", polId); + return avrgPhase; + } + + Double_t time, phase, phaseErr; + + // Loop over all polarization points + for (UInt_t iPoint=0; iPoint<(UInt_t) grPCPolarPhase->GetN(); iPoint++) + { + grPCPolarPhase->GetPoint(iPoint, time, phase); + + // Exclude points only if the lumi/phys period is defined && > 600 sec + // Otherwise include all available measurements in the average + //if ( abs(GetLumiOffRelTime() - GetLumiOnRelTime()) > 600 && + //(time < GetLumiOnRelTime() || time > GetLumiOffRelTime()) ) continue; + + phaseErr = grPCPolarPhase->GetErrorY(iPoint); + + // Internaly all polarization values are between 0 and 1 except graphs + ValErrPair phaseVE(phase, phaseErr); + + avrgPhase = utils::CalcWeightedAvrgErr(avrgPhase, phaseVE); + } + + return avrgPhase; +} + /** */ ValErrPair AnaFillResult::CalcAvrgPolProfPolar(EPolarimeterId polId) @@ -1154,11 +1225,11 @@ ValErrPair AnaFillResult::CalcAvrgProfR(EPolarimeterId polId, ETargetOrient tgtO { Double_t time, profR; grPCProfR->GetPoint(iPoint, time, profR); - + //Info("CalcAvrgProR", "time: %lg lumi_off: %ld lumi_on: %ld", time, GetLumiOffRelTime(), GetLumiOnRelTime()); // Exclude points only if the lumi/phys period is defined && > 600 sec // Otherwise include all available measurements in the average - if ( abs(GetLumiOffRelTime() - GetLumiOnRelTime()) > 600 && - (time < GetLumiOnRelTime() || time > GetLumiOffRelTime()) ) continue; + //if ( abs(GetLumiOffRelTime() - GetLumiOnRelTime()) > 600 && + //(time < GetLumiOnRelTime() || time > GetLumiOffRelTime()) ) continue; Double_t profRErr = grPCProfR->GetErrorY(iPoint); @@ -1447,7 +1518,8 @@ void AnaFillResult::UpdateExternGraphRange() for(vector::const_iterator it = grs.begin(); it != grs.end(); it++) { TGraphErrors *gr = *it; - for (Int_t i=0; iGetN(); ++i) { gr->GetPoint(i, x, y); gr->SetPoint(i, x - fStartTime, y); } + for (Int_t i=0; iGetN(); ++i) { gr->GetPoint(i, x, y); gr->SetPoint(i, x - fStartTime, y); //if(i==0) Printf("time diff: %.0lf start: %ld bc: %lf", x-fStartTime, fStartTime, y); +} } } @@ -1455,7 +1527,8 @@ void AnaFillResult::UpdateExternGraphRange() Double_t x, y; TGraphErrors *gr = GetAgsPolFitGraph(); if (gr) { - for (Int_t i=0; iGetN(); ++i) { gr->GetPoint(i, x, y); gr->SetPoint(i, x - fStartTime, y); } + for (Int_t i=0; iGetN(); ++i) { gr->GetPoint(i, x, y); gr->SetPoint(i, x - fStartTime, y); //Printf("time diff: %.0lf pol: %lf", x-fStartTime, y); +} } } @@ -1488,7 +1561,6 @@ void AnaFillResult::UpdateExternGraphRange() } } - /** */ void AnaFillResult::FitPCPolarGraphs() { @@ -1662,7 +1734,8 @@ void AnaFillResult::FitAgsPol() { TGraphErrors *gr = GetAgsPolFitGraph(); if (gr) { - fAgsPolFitRes = gr->Fit("pol0", "QS", "", -0.5 * 60 * 60, 0); // Q - Quiet, S - return FitResult + //fAgsPolFitRes = gr->Fit("pol0", "QS", "", -0.5 * 60 * 60, 0); // Q - Quiet, S - return FitResult + fAgsPolFitRes = gr->Fit("pol0", "QS",""); // Q - Quiet, S - return FitResult } } @@ -1741,3 +1814,54 @@ void AnaFillResult::AppendToPCProfRInjGraph(EPolarimeterId polId, ETargetOrient Info("AppendToPCProfRInjGraph", "Fill %d. Added measurement to graph polId %d, tgtOrient %d", fFillId, polId, tgtOrient); utils::AppendToGraph(graph, x, y, xe, ye); } +/** Function can return an empty graph. */ +TGraphErrors* AnaFillResult::GetPCPolarPhaseGraph(EPolarimeterId polId) const +{ + if (fPCPolarPhaseGraphs.find(polId) == fPCPolarPhaseGraphs.end()) { + return 0; + } + + return (TGraphErrors*) fPCPolarPhaseGraphs.find(polId)->second; +} + + +/** Function cannot return empty graph. */ +TGraphErrors* AnaFillResult::GetPCPolarPhaseInjGraph(EPolarimeterId polId) +{ + if (fPCPolarPhaseInjGraphs.find(polId) == fPCPolarPhaseInjGraphs.end()) { + return 0; + } + + return (TGraphErrors*) fPCPolarPhaseInjGraphs.find(polId)->second; +} + + +/** */ +void AnaFillResult::AppendToPCPolarPhaseGraph(EPolarimeterId polId, Double_t x, Double_t y, Double_t xe, Double_t ye) +{ + TGraphErrors *graph = GetPCPolarPhaseGraph(polId); + + if (!graph) { + Info("AppendToPCPolarPhaseGraph", "Fill %d. Created new graph for polId %d", fFillId, polId); + graph = new TGraphErrors(); + fPCPolarPhaseGraphs[polId] = graph; + } + + Info("AppendToPCPolarPhaseGraph", "Fill %d. Added measurement to graph polId %d", fFillId, polId); + utils::AppendToGraph(graph, x, y, xe, ye); +} + + +/** */ +void AnaFillResult::AppendToPCPolarPhaseInjGraph(EPolarimeterId polId, Double_t x, Double_t y, Double_t xe, Double_t ye) +{ + TGraphErrors *graph = GetPCPolarPhaseInjGraph(polId); + + if (!graph) { + Info("AppendToPCPolarPhaseInjGraph", "Fill %d. Created new injection graph for polId %d", fFillId, polId); + graph = new TGraphErrors(); + fPCPolarPhaseInjGraphs[polId] = graph; + } + + utils::AppendToGraph(graph, x, y, xe, ye); +} diff --git a/src/AnaGlobResult.cxx b/src/AnaGlobResult.cxx index b5311da2..cd8d7ca3 100644 --- a/src/AnaGlobResult.cxx +++ b/src/AnaGlobResult.cxx @@ -299,8 +299,8 @@ void AnaGlobResult::AddHJMeasResult(Int_t runID) tiltYelAngle=-0.1571;// The tilt angle in the yellow ring -9 degrees } if(runID ==17){ - tiltBluAngle=0.2094; // The tilt angle in the blue ring +12.0 degrees (Final asym processing) - tiltYelAngle=-0.1326;// The tilt angle in the yellow ring -7.6 degrees (Final asym processing) + tiltBluAngle=0.2042; // The tilt angle in the blue ring +11.7 degrees (04.03.17) + tiltYelAngle=-0.1309;// The tilt angle in the yellow ring -7.5 degrees (04.03.17) } printf("AnaGlobalResult: Tilt angles blue %f yellow %f \n", cos(tiltBluAngle), cos(tiltYelAngle)); bluPolar = bluPolar/ cos(tiltBluAngle); @@ -508,18 +508,21 @@ void AnaGlobResult::CalcPolarNorm() AnaFillResult *fillRslt = &iFill->second; PolId2ValErrMapConstIter iPolar = fillRslt->fPCPolars.begin(); + PolId2ValErrMapConstIter iPolarPhase = fillRslt->fPCPolarPhases.begin(); PolId2ValErrMapConstIter iProfPolar = fillRslt->fPCProfPolars.begin(); for ( ; iPolar != fillRslt->fPCPolars.end(); ++iPolar, ++iProfPolar) { EPolarimeterId polId = iPolar->first; ValErrPair polarPC = iPolar->second; + ValErrPair phasePC = iPolarPhase->second; ValErrPair polarPCProf = iProfPolar->second; ERingId ringId = RunConfig::GetRingId(polId); string sPolId = RunConfig::AsString(polId); // Polarization profile scale factor - if (polarPC.second >= 0 && polarPCProf.second >= 0) { + //if (polarPC.second >= 0 && polarPCProf.second >= 0) { + if (polarPC.second >= 0 && polarPCProf.second >= 0 && phasePC.second > 0) { polarCrbAllSet [polId].insert(polarPC); polarCrbProfAllSet[polId].insert(polarPCProf); @@ -529,8 +532,9 @@ void AnaGlobResult::CalcPolarNorm() ValErrPair polarHJ = fillRslt->GetHJPolar(ringId); // For HJet normalization: Skip if there is no corresponding hjet result for this fill - if (polarPC.second < 0 || polarHJ.second < 0) { - Warning("CalcPolarNorm", "Fill %d, %s: p-Carbon or H-jet polarization not available", fillId, sPolId.c_str()); + //if (polarPC.second < 0 || polarHJ.second < 0) { + if (polarPC.second < 0 || polarHJ.second < 0 || phasePC.second < 0) { + Warning("CalcPolarNorm", "Fill %d, %s: p-Carbon (%lg +/- %lg) or H-jet polarization (%lg +/- %lg) not available", fillId, sPolId.c_str(), polarPC.first, polarPC.second, polarHJ.first, polarHJ.second); continue; } @@ -544,11 +548,12 @@ void AnaGlobResult::CalcPolarNorm() polarCrbSet[polId].insert(polarPC); polarJetSet[polId].insert(polarHJ); - ValErrPair norm = utils::CalcDivision(polarHJ, polarPC); + //ValErrPair norm = utils::CalcDivision(polarHJ, polarPC); + ValErrPair norm = utils::CalcDivisionPhase(polarHJ, polarPC, phasePC); fNormJetCarbon2[polId] = utils::CalcWeightedAvrgErr(fNormJetCarbon2[polId], norm); // for debugging - //cout << "jjjj " << fillId << " "; + //cout << "Normalization for fill " << fillId << " "; //cout << ": " << PairAsPhpArray(norm) << " " << PairAsPhpArray(fNormJetCarbon2[polId]) << endl; //printf("%d: %s: %16.7f +/- %16.7f %16.7f +/- %16.7f\n", // fillId, sPolId.c_str(), polarPC.first, polarPC.second, polarHJ.first, polarHJ.second); @@ -764,7 +769,7 @@ void AnaGlobResult::UpdateInsertDb(AsymDbSql *asymDbSql) ValErrPair fillPCProfR = fillResult.GetPCProfR(polId, tgtOrient); if (fillPCProfR.second < 0) { Info("UpdateInsert", "Skip invalid profile measurement in polId %d, tgtOrient %d", polId, tgtOrient); - continue; + //continue;//don't skip now zchang } diff --git a/src/AnaInfo.cxx b/src/AnaInfo.cxx index cc700a3e..12a88f70 100644 --- a/src/AnaInfo.cxx +++ b/src/AnaInfo.cxx @@ -28,7 +28,7 @@ AnaInfo::AnaInfo() : TObject(), fAnaTimeCpu (0), fAsymEnv(), fFileMeasInfo(0), fFileStdLog(0), - fFileStdLogName("stdoe"), fFlagCopyResults(kFALSE), fFlagUseDb(true), + fFileStdLogName("stdoe"), fFlagCopyResults(kFALSE), fFlagUseDb(kFALSE), fFlagUpdateDb(kFALSE), fFlagCreateThumbs(kFALSE), fFlagVerbose(false), fUserGroup(), fAlphaSourceCount(-1) @@ -160,16 +160,17 @@ void AnaInfo::VerifyOptions() } MakeOutDir(); - fFileMeasInfo = fopen(this->GetAnaInfoFileName().c_str(), "w"); gSystem->Chmod(this->GetAnaInfoFileName().c_str(), 0775); // Set default standard log output // TODO: make fFlagVerbose write log to file as well + Printf("%s", GetStdLogFileName().c_str()); //zchang if ((!fFileStdLogName.empty()) && (!fFlagVerbose)) { freopen(GetStdLogFileName().c_str(), "w", stdout); - fclose(stderr); - stderr = stdout; + //commented following 2 lines zchang + //fclose(stderr); + //stderr = stdout; gSystem->Chmod(GetStdLogFileName().c_str(), 0775); } else diff --git a/src/AnaMeasResult.cxx b/src/AnaMeasResult.cxx index 6325b0d9..c0ec717c 100644 --- a/src/AnaMeasResult.cxx +++ b/src/AnaMeasResult.cxx @@ -101,8 +101,15 @@ void AnaMeasResult::PrintAsPhp(FILE *f) const fprintf(f, "$rc['fPmtS1T0'] = %f;\n", fPmtS1T0); fprintf(f, "$rc['fPmtS1T0Err'] = %f;\n", fPmtS1T0Err); } - - +/** polarization from 90 degree detectors zchang*/ +ValErrPair AnaMeasResult::GetPCPolarX90() const +{ + ValErrPair val_err(0, -1); + ValErrPair asym = fAsymX90.at("phys"); + val_err.first = A_N[1] > 0 ? asym.first/A_N[1] : 0; + val_err.second = A_N[1] > 0 ? asym.second/A_N[1]: -1; + return val_err; +} /** */ ValErrPair AnaMeasResult::GetPCPolar() const { @@ -154,6 +161,7 @@ ValErrPair AnaMeasResult::GetPCProfR() const * "New system" streamer with backward-compatibility to old files. * Implemented as suggested in https://root.cern.ch/root/SchemaEvolution.html */ +/* void AnaMeasResult::Streamer(TBuffer &R__b) { // Stream an object of class AnaMeasResult. @@ -245,4 +253,4 @@ void AnaMeasResult::Streamer(TBuffer &R__b) } else { AnaMeasResult::Class()->WriteBuffer(R__b, this); } -} +}*/ diff --git a/src/AsymAnaInfo.cxx b/src/AsymAnaInfo.cxx index d272bc7b..8e7f8457 100644 --- a/src/AsymAnaInfo.cxx +++ b/src/AsymAnaInfo.cxx @@ -63,6 +63,8 @@ Bool_t AsymAnaInfo::HasKinematBit() const { return (fAsymModes & AsymAnaInfo Bool_t AsymAnaInfo::HasPmtBit() const { return (fAsymModes & AsymAnaInfo::MODE_PMT) == AsymAnaInfo::MODE_PMT; } Bool_t AsymAnaInfo::HasPulserBit() const { return (fAsymModes & AsymAnaInfo::MODE_PULSER) == AsymAnaInfo::MODE_PULSER; } Bool_t AsymAnaInfo::HasStudiesBit() const { return (fAsymModes & AsymAnaInfo::MODE_STUDIES) == AsymAnaInfo::MODE_STUDIES; } +Bool_t AsymAnaInfo::HasSTMBit() const { return (fAsymModes & AsymAnaInfo::MODE_STM) == AsymAnaInfo::MODE_STM; } //zchang +Bool_t AsymAnaInfo::HasNoiseBit() const { return (fAsymModes & AsymAnaInfo::MODE_NOISE) == AsymAnaInfo::MODE_NOISE; } //zchang noise study Bool_t AsymAnaInfo::HasNoGainCorrectionBit() const { return (fAsymModes & AsymAnaInfo::MODE_NO_GAIN_CORRECTION) == AsymAnaInfo::MODE_NO_GAIN_CORRECTION; } @@ -96,7 +98,7 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) //extern char *optarg; int option_index = 0; - char cfile[32]; +// char cfile[32]; static struct option long_options[] = { {"log", optional_argument, 0, 'l'}, @@ -125,6 +127,8 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) {"pmt", no_argument, 0, AsymAnaInfo::MODE_PMT}, {"pulser", no_argument, 0, AsymAnaInfo::MODE_PULSER}, {"studies", no_argument, 0, AsymAnaInfo::MODE_STUDIES}, + {"stm", no_argument, 0, AsymAnaInfo::MODE_STM}, //zchang + {"noise", no_argument, 0, AsymAnaInfo::MODE_NOISE}, //zchang {"mode-alpha", no_argument, 0, AsymAnaInfo::MODE_ALPHA}, {"mode-normal", no_argument, 0, AsymAnaInfo::MODE_NORMAL}, {"mode-no-normal", no_argument, 0, AsymAnaInfo::MODE_NO_NORMAL}, @@ -141,6 +145,8 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) {"disable-det", required_argument, 0, AsymAnaInfo::OPTION_DET_DISABLE}, {"alpha-sources", required_argument, 0, AsymAnaInfo::OPTION_ALPHA_SOURCES}, {"ac-dipole-period", required_argument, 0, AsymAnaInfo::OPTION_AC_DIPOLE_PERIOD}, + {"spin-pattern", required_argument, 0, 'x'}, + {"fill-pattern", required_argument, 0, 'p'}, {0, 0, 0, 0} }; @@ -177,7 +183,7 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) case AnaInfo::FLAG_USE_DB: fFlagUseDb = kTRUE; - fFlagUpdateDb = kTRUE; + //fFlagUpdateDb = kTRUE; //zchang break; case AnaInfo::FLAG_CREATE_THUMBS: @@ -189,6 +195,7 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) break; case AnaInfo::FLAG_UPDATE_DB: + fFlagUseDb = kTRUE; fFlagUpdateDb = kTRUE; break; @@ -295,16 +302,35 @@ void AsymAnaInfo::ProcessOptions(int argc, char **argv) break; case AsymAnaInfo::MODE_PULSER: - fAsymModes |= AsymAnaInfo::MODE_PULSER; + //fAsymModes |= AsymAnaInfo::MODE_PULSER; + fAsymModes = AsymAnaInfo::MODE_PULSER; //zchang break; case AsymAnaInfo::MODE_STUDIES: fAsymModes |= AsymAnaInfo::MODE_STUDIES; break; - + //zchang + case AsymAnaInfo::MODE_STM: + //Info("STM Modes", Form("%lx\n", fAsymModes)); + fAsymModes |= AsymAnaInfo::MODE_STM; + Info("STM Modes", Form("%lx\n", fAsymModes)); + break; + //zchang noise study + case AsymAnaInfo::MODE_NOISE: + //Info("Noise Modes", Form("%lx\n", fAsymModes)); + fAsymModes = AsymAnaInfo::MODE_NOISE; + Info("Noise Modes", Form("%lx\n", fAsymModes)); + break; + // case AsymAnaInfo::MODE_NO_GAIN_CORRECTION: fAsymModes |= AsymAnaInfo::MODE_NO_GAIN_CORRECTION; break; + case 'x': + ::Flag.spin_pattern = atoi(optarg); + break; + case 'p': + ::Flag.fill_pattern = atoi(optarg); + break; default: Error("ProcessOptions", "Unknown option provided"); diff --git a/src/AsymCommon.cxx b/src/AsymCommon.cxx index 70b5bdf3..0518114d 100644 --- a/src/AsymCommon.cxx +++ b/src/AsymCommon.cxx @@ -273,17 +273,17 @@ void RunConst::PrintAll() /** */ -TBuffer & operator<<(TBuffer &buf, TRecordConfigRhicStruct *&rec) +/*TBuffer & operator<<(TBuffer &buf, TRecordConfigRhicStruct *&rec) { if (!rec) return buf; //printf("operator<<(TBuffer &buf, TRecordConfigRhicStruct *rec) : \n"); rec->Streamer(buf); return buf; -} +}*/ /** */ -TBuffer & operator>>(TBuffer &buf, TRecordConfigRhicStruct *&rec) +/*TBuffer & operator>>(TBuffer &buf, TRecordConfigRhicStruct *&rec) { //printf("operator>>(TBuffer &buf, TRecordConfigRhicStruct *rec) : \n"); //if (!rec) return buf; // of course it is 0! @@ -299,7 +299,7 @@ TBuffer & operator>>(TBuffer &buf, TRecordConfigRhicStruct *&rec) rec->Streamer(buf); return buf; -} +}*/ //std::string strip(std::string const& str, char const* sepSet) diff --git a/src/AsymDbSql.cxx b/src/AsymDbSql.cxx index 5ef00a73..578efd05 100644 --- a/src/AsymDbSql.cxx +++ b/src/AsymDbSql.cxx @@ -338,21 +338,25 @@ vector AsymDbSql::SelectPriorRuns(const MseMeasInfoX& run) void AsymDbSql::UpdateInsert(const MseMeasInfoX* orun, const MseMeasInfoX* nrun) { OpenConnection(); - + Info("UpdateInsert", "Opening"); if (!fConnection) { Error("UpdateInsert", "Connection with MySQL server not established"); return; } + Info("UpdateInsert", "Querying"); Query query = fConnection->query(); // if original run is not defined just insert the new one if (!orun) { + Info("UpdateInsert", "Inserting"); + //query.update(*nrun, *nrun); query.insert(*nrun); cout << "Query: " << query << endl; query.execute(); } else { + Info("UpdateInsert", "Updating"); query.update(*orun, *nrun); cout << "Query: " << query << endl; query.execute(); diff --git a/src/AsymOnline.cxx b/src/AsymOnline.cxx index 48a30401..5bd09c62 100644 --- a/src/AsymOnline.cxx +++ b/src/AsymOnline.cxx @@ -2,7 +2,7 @@ #include - +/* RecordHeaderStruct& RecordHeaderStruct::operator=(const RecordHeaderStruct &rec) { len = rec.len; @@ -56,8 +56,8 @@ RecordMachineParams& RecordMachineParams::operator=(const RecordMachineParams &r return *this; } - - +*/ +/* void RecordMachineParams::Streamer(TBuffer &R__b) { // Stream an object of class RecordMachineParams. @@ -81,8 +81,8 @@ void RecordMachineParams::Streamer(TBuffer &R__b) //R__b.SetByteCount(R__c, kTRUE); } } - - +*/ +/* RecordTargetParams& RecordTargetParams::operator=(const RecordTargetParams &rec) { header = rec.header; @@ -94,8 +94,8 @@ RecordTargetParams& RecordTargetParams::operator=(const RecordTargetParams &rec) return *this; } - - +*/ +/* void RecordTargetParams::Streamer(TBuffer &R__b) { // Stream an object of class RecordMachineParams. @@ -119,8 +119,8 @@ void RecordTargetParams::Streamer(TBuffer &R__b) //R__b.SetByteCount(R__c, kTRUE); } } - - +*/ +/* RecordWcm::RecordWcm() : fFillDataM(), fWcmBeamM(0), fBunchDataM(), fBunchLengthM(0), fProfileHeaderM()//, fProfileDataM(0) { @@ -152,7 +152,6 @@ void RecordWcm::Print() } -/** */ void TRecordConfigRhicStruct::Streamer(TBuffer &buf) { if (buf.IsReading()) { @@ -200,7 +199,6 @@ void TRecordConfigRhicStruct::Streamer(TBuffer &buf) } -/** */ void TRecordConfigRhicStruct::Print(const Option_t* opt) const { //long len = header.len; @@ -220,3 +218,4 @@ void TRecordConfigRhicStruct::Print(const Option_t* opt) const printf(" acoef: %f, %f, TOFLength: %f\n", chanconf[i].acoef, chanconf[i].t0, chanconf[i].TOFLength); } } +*/ diff --git a/src/AsymRecover.cxx b/src/AsymRecover.cxx index f3eab439..c4339d8a 100644 --- a/src/AsymRecover.cxx +++ b/src/AsymRecover.cxx @@ -8,7 +8,6 @@ // // Creation : 4/12/2006 // - #include "AsymRecover.h" #include "AsymRecoverUserDefined.h" #include "RunConfig.h" @@ -21,12 +20,14 @@ using namespace std; // : were screwed up void AsymRecover::OverwriteSpinPattern(int index) { - cerr << "Recovery: Spin pattern is ovewritten by user defined pattern index(" + cout << "Recovery: Spin pattern is overwritten by user defined pattern index(" << index << ")" << endl; for (int bid=1; bidfBeamBunches[bid].SetBunchSpin( (ESpinState) UserDefinedFillPattern[index][bid-1] ); + gMeasInfo->fBeamBunches[bid].SetBunchSpin( (ESpinState) UserDefinedSpinPattern[index][bid-1] ); + //string sSS = gRunConfig.AsString( gMeasInfo->GetBunchSpin(bid) ); + //cerr<<"bid="<SetPalette(1); gStyle->SetOptFit(1111); @@ -116,7 +121,7 @@ AsymRoot::~AsymRoot() delete fChannelEvent; fChannelEvent = 0; delete fChannelData; fChannelData = 0; delete fEventConfig; fEventConfig = 0; - + if(fSpinTuneMotor) free(fSpinTuneMotor); if (!fHists) { delete fHists; fHists = 0; } } @@ -162,7 +167,16 @@ void AsymRoot::CreateRootFile(string filename) fHists->d["std"] = oc; fHistCuts[kCUT_CARBON].insert(oc); } + if (!gAsymAnaInfo->HasNormalBit() && gAsymAnaInfo->HasNoiseBit()) { + dir = new TDirectoryFile("calib", "calib", "", fOutRootFile); + fHists->d["calib"] = new CnipolCalibHists(dir); + dir = new TDirectoryFile("std", "std", "", fOutRootFile); + oc = new CnipolHists(dir); + fHists->d["std"] = oc; + fHistCuts[kCUT_CARBON].insert(oc); + //fHistCuts[kCUT_NOISE_LOWER].insert(oc); + } // If requested create scaler histograms and add them to the container if (gAsymAnaInfo->HasScalerBit()) { dir = new TDirectoryFile("scalers", "scalers", "", fOutRootFile); @@ -206,8 +220,33 @@ void AsymRoot::CreateRootFile(string filename) oc = new CnipolAsymHists(dir); fHists->d["asym"] = oc; fHistCuts[kCUT_CARBON].insert(oc); + //zchang + //dir = new TDirectoryFile("sptm", "sptm", "", fOutRootFile); + //oc = new CnipolSpinTuneMotorHists(dir); + //fHists->d["sptm"] = oc; + //fHistCuts[kCUT_CARBON].insert(oc); + // + } + //zchang + if(gAsymAnaInfo->HasSTMBit()) { + gAsymRoot->fSpinTuneMotor = new SpinTuneMotor; + dir = new TDirectoryFile("sptm", "sptm", "", fOutRootFile); + oc = new CnipolSpinTuneMotorHists(dir); + fHists->d["sptm"] = oc; + fHistCuts[kCUT_CARBON].insert(oc); } - + //zchang noise study + //if(gAsymAnaInfo->HasNoiseBit()) { + //dir = new TDirectoryFile("noise", "noise", "", fOutRootFile); + //oc = new CnipolAsymHists(dir); + //fHists->d["noise"] = oc; + //fHistCuts[kCUT_NOISE_LOWER].insert(oc); + // + //dir = new TDirectoryFile("npreproc", "npreproc", "", fOutRootFile); + //oc = new CnipolPreprocHists(dir); + //fHists->d["npreproc"] = oc; + //} + // if (gAsymAnaInfo->HasKinematBit()) { // Pre mass cut dir = new TDirectoryFile("kinema_premass", "kinema_premass", "", fOutRootFile); @@ -233,6 +272,7 @@ void AsymRoot::CreateRootFile(string filename) dir = new TDirectoryFile("pulser", "pulser", "", fOutRootFile); oc = new CnipolPulserHists(dir); fHists->d["pulser"] = oc; + fHistCuts[kCUT_PASSONE].insert(oc); //zchang //fHistCuts[kCUT_PASSONE_PULSER].insert(oc); //fHistCuts[kCUT_CARBON_EB].insert(oc); } @@ -245,7 +285,8 @@ void AsymRoot::CreateRootFile(string filename) } // Should be reconsidered once preproc is used to fill raw hists for alpha runs - if (!gAsymAnaInfo->HasAlphaBit()) { + //if (!gAsymAnaInfo->HasAlphaBit()) { + if (!gAsymAnaInfo->HasAlphaBit() && !gAsymAnaInfo->HasPulserBit()) {// zchang dir = new TDirectoryFile("run", "run", "", fOutRootFile); fHists->d["run"] = new CnipolRunHists(dir); @@ -320,8 +361,15 @@ void AsymRoot::AddSpinFlipperMarker() UInt_t revId = fChannelEvent->GetRevolutionId(); fEventConfig->GetMeasInfo()->AddSpinFlipperMarker(revId); } - - +void AsymRoot::FillSpinTuneMotor() +{ + UInt_t rev = fChannelEvent->GetRevolutionId(); + UChar_t bx = fChannelEvent->GetBunchId(); + unsigned long long mark = 120*rev + bx; + fSpinTuneMotor->Add(mark); + //test zchang + //cout<Size()<HasAsymBit() && gAsymAnaInfo->HasNormalBit() ) { fHists->d["asym"]->FillDerived( *fHists ); + //zchang + //if(gAsymAnaInfo->HasNoiseBit()) + //fHists->d["noise"]->FillDerived( *fHists ); } // profile depends on asym @@ -447,12 +498,18 @@ void AsymRoot::FillProfileHists(UInt_t n, int32_t *hData) /** */ void AsymRoot::FillRunHists() { - if (gAsymAnaInfo->HasAlphaBit()) return; + //if (gAsymAnaInfo->HasAlphaBit()) return; + if (gAsymAnaInfo->HasAlphaBit() || gAsymAnaInfo->HasPulserBit()) return; //zchang ((CnipolRunHists*) fHists->d["run"])->Fill(*gMeasInfo); } +/*void AsymRoot::AfterBurner() +{ + if(gAsymAnaInfo->HasAsymBit()) + ((CnipolAsymHists*) fHists->d["asym"])->AfterBurner(); +}*/ /** * */ @@ -603,14 +660,18 @@ void AsymRoot::UpdateCalibrator() fEventConfig->fCalibrator->CopyAlphaCoefs(*eventConfig->fCalibrator); if (!fEventConfig->GetAnaInfo()->HasNoGainCorrectionBit()) { + Info("UpdateCalibrator", "Apply bias current correction"); fEventConfig->fCalibrator->ApplyBiasCurrentCorrection(gMeasInfo, true); } else { + Info("UpdateCalibrator", "Use plain alpha gain"); fEventConfig->fCalibrator->UsePlainAlphaGain(); } delete eventConfig; delete f; + }else if (anaInfo->HasPulserBit()){ + Info("UpdateCalibrator", "Test pulser"); } else { Fatal("UpdateCalibrator", "Cannot select calibrator for this kind of run"); } @@ -797,7 +858,8 @@ void AsymRoot::Finalize() fHists->Write(); // this is NOT equivalent to fOutRootFile->Write(); fOutRootFile->cd(); - fEventConfig->Write("measConfig"); + //fEventConfig->Write("measConfig"); + if(!gAsymAnaInfo->HasPulserBit()) fEventConfig->Write("measConfig"); //zchang // close fOutRootFile fOutRootFile->Close(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a87ebf67..414f2924 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ ADD_LIBRARY( CnipolRunHists.cxx CnipolScalerHists.cxx CnipolSpinStudyHists.cxx + CnipolSpinTuneMotorHists.cxx CnipolTargetHists.cxx DeadLayerCalibrator.cxx DeadLayerCalibratorEDepend.cxx @@ -86,6 +87,7 @@ ADD_LIBRARY( Target.cxx TargetInfo.cxx TargetUId.cxx + AfterBurner.cxx revision-export.cxx Dict.cxx cnipol_toolkit.cxx diff --git a/src/ChannelEvent.cxx b/src/ChannelEvent.cxx index 21391861..e49861eb 100644 --- a/src/ChannelEvent.cxx +++ b/src/ChannelEvent.cxx @@ -220,6 +220,13 @@ Bool_t ChannelEvent::PassCutSiliconChannel() return false; } +Bool_t ChannelEvent::PassCutSpinTuneChannel() +{ + if ( gMeasInfo->IsSpinTuneChannel(GetChannelId()) ) + return true; + + return false; +} /** */ Bool_t ChannelEvent::PassCutDepEnergyTime() @@ -334,7 +341,28 @@ Bool_t ChannelEvent::PassCutNoise() return true; } +/** */ +Bool_t ChannelEvent::PassCutNoiseLower() +{ + Double_t extraOffset = 0; + if ( gMeasInfo->GetBeamEnergy() != kINJECTION) + extraOffset = -8; // 8 TDC units ~= ? ns, 6 TDC units ~= 8 ns + //zchang + //Printf("cut width: %d\n", gMeasInfo->GetProtoCutWidth()); + if ( //false + //GetAmpltd() < gMeasInfo->GetProtoCutAdcMin() || + //GetAmpltd() > gMeasInfo->GetProtoCutAdcMax() || + //GetTdc() < gMeasInfo->GetProtoCutTdcMin() || + //GetTdc() > gMeasInfo->GetProtoCutTdcMax() || + GetTdc() - ( gMeasInfo->GetProtoCutSlope() * (GetAmpltd()-10) + gMeasInfo->GetProtoCutOffset() + extraOffset) > + gMeasInfo->GetProtoCutWidth()*-1.0 + //20.*-1.0 + ) + return false; + + return true; +} /** */ Bool_t ChannelEvent::PassCutEnabledChannel() diff --git a/src/CnipolAlphaHists.cxx b/src/CnipolAlphaHists.cxx index 298d99ac..8e5065bf 100644 --- a/src/CnipolAlphaHists.cxx +++ b/src/CnipolAlphaHists.cxx @@ -204,7 +204,8 @@ void CnipolAlphaHists::BookHists() ((TH1*) oc->o[hName])->SetTitle("; Amplitude, ADC; Integral, ADC; "); sprintf(hName, "hAmGd_ch%02d", iCh); - oc->o[hName] = new TH2F(hName, hName, 0, 0, 0, 0, 0, 0); + //oc->o[hName] = new TH2F(hName, hName, 0, 0, 0, 0, 0, 0); + oc->o[hName] = new TH2F(hName, hName, 1, 0, 1, 1, 0, 1); //zchang //sprintf(hName,"t_vs_e_ch%d", iCh); //kinema.oc->o[hName] = new TH2F(); diff --git a/src/CnipolAsymHists.cxx b/src/CnipolAsymHists.cxx index ba831c4a..148e0d8f 100644 --- a/src/CnipolAsymHists.cxx +++ b/src/CnipolAsymHists.cxx @@ -8,6 +8,11 @@ #include "MeasInfo.h" #include "CnipolHists.h" +#include "TMath.h" + +#include "AfterBurner.h" + +using namespace afterburner; ClassImp(CnipolAsymHists) @@ -233,6 +238,21 @@ void CnipolAsymHists::BookHists() ((TH1*) o[shName])->SetTitle("; Time, s; Detector Id;"); ((TH1*) o[shName])->SetOption("colz NOIMG"); } + + TGraphErrors *gNdetasym_lam = new TGraphErrors(); + gNdetasym_lam->SetName("gNdetasym_lam"); + gNdetasym_lam->SetMarkerStyle(20); + gNdetasym_lam->SetMarkerSize(1); + gNdetasym_lam->SetMarkerColor(2); + gNdetasym_lam->SetLineColor(2); + + shName = "hNdetasym_lam"; + hist = new TH2C(shName.c_str(), shName.c_str(), 1, 0., 2*M_PI, 1, -0.012, 0.012); + hist->SetTitle("; #phi; Asymmetry;"); + hist->SetOption("DUMMY GRIDX"); + hist->GetListOfFunctions()->Add(gNdetasym_lam, "p"); + o[shName] = hist; + // } @@ -270,7 +290,6 @@ void CnipolAsymHists::Fill(ChannelEvent *ch) Double_t time = ((Double_t) ch->GetRevolutionId())/RHIC_REVOLUTION_FREQ; string sSS = gRunConfig.AsString( gMeasInfo->GetBunchSpin(bId) ); - ((TH1*) o.find("hChVsBunchId_" + sSS)->second) -> Fill(bId, chId); ((TH1*) o.find("hChVsKinEnergyA_" + sSS)->second) -> Fill(kinEnergy, chId); ((TH1*) o.find("hChVsDelim_" + sSS)->second) -> Fill(time, chId); @@ -466,4 +485,49 @@ void CnipolAsymHists::PostFill() gAnaMeasResult->fFitResAsymBunchY45[*iSS] = fitres; delete funcConst; } + AfterBurner(); +} + +/** */ +void CnipolAsymHists::AfterBurner() +{ + TH2I* hDetVsDelim_up = (TH2I*) o["hDetVsDelim_up"]; + TH2I* hDetVsDelim_down = (TH2I*) o["hDetVsDelim_down"]; + if (!hDetVsDelim_up) {return;} + if (!hDetVsDelim_down) {return;} + + TH1D* hCountsUp = hDetVsDelim_up->ProjectionY("hCountsUp"); + TH1D* hCountsDn = hDetVsDelim_down->ProjectionY("hCountsDn"); + + double nup[6], ndn[6]; + for (int i=0; i<6; i++) { + nup[i] = hCountsUp->GetBinContent(i+1); + ndn[i] = hCountsDn->GetBinContent(i+1); + //Info("AfterBurner", "i=%d nup=%lg ndn=%lg", i, nup[i], ndn[i]); + } + Info("AfterBurner", "fitting..."); + double par[3], epar[3], chi2; + fit1asym(nup,ndn,par,epar,chi2); + + TF1* fNdetasym_lam = new TF1("fNdetasym_lam","[0]*sin(x-[1])+0.*[2]",0.,2*M_PI); + fNdetasym_lam->SetParameters(par); fNdetasym_lam->SetParErrors(epar); + fNdetasym_lam->SetParNames("#epsilon_{0}","#phi_{0}","#lambda"); + Info("AfterBurner", "filling fit points"); + double phidet[6] = { 45. , 90. , 135. , 225. , 270. , 315. }; + TH1 *hNdetasym_lam = (TH1 *) o["hNdetasym_lam"]; + TGraphErrors* gNdetasym_lam = (TGraphErrors *) hNdetasym_lam->GetListOfFunctions()->FindObject("gNdetasym_lam"); + int npfit = 0; + for (int i=0; i<6; i++) { + if ( nup[i]>0. && ndn[i]>0. ) { // require hits in detector + pair asympair = asym_err(par[2],nup[i],ndn[i]); + gNdetasym_lam->SetPoint(npfit,TMath::DegToRad()*phidet[i],asympair.first); + gNdetasym_lam->SetPointError(npfit,0.,asympair.second); + npfit++; + } + } + + fNdetasym_lam->SetChisquare(chi2); + fNdetasym_lam->SetNDF(npfit-3); + gNdetasym_lam->GetListOfFunctions()->Add(fNdetasym_lam); + Info("AfterBurner", "Done chi2/ndf = %lg/%d", chi2, npfit-3); } diff --git a/src/CnipolKinemaCleanHists.cxx b/src/CnipolKinemaCleanHists.cxx index a393f30e..25407315 100644 --- a/src/CnipolKinemaCleanHists.cxx +++ b/src/CnipolKinemaCleanHists.cxx @@ -36,22 +36,22 @@ void CnipolKinemaCleanHists::BookHists() fDir->cd(); - shName = "hPseudoMass"; + shName = "hPseudoMassClean"; o[shName] = new TH1F(shName.c_str(), shName.c_str(), 50, 0, 20); ((TH1*) o[shName])->SetTitle("; Mass; Events;"); ((TH1*) o[shName])->SetOption("E1"); - shName = "hMassFitChi2ByChannel"; + shName = "hMassCleanFitChi2ByChannel"; o[shName] = new TH1F(shName.c_str(), shName.c_str(), N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); ((TH1*) o[shName])->SetTitle("; Channel Id; #chi^{2};"); ((TH1*) o[shName])->SetOption("hist GRIDX"); - shName = "hMassFitMeanByChannel"; + shName = "hMassCleanFitMeanByChannel"; o[shName] = new TH1F(shName.c_str(), shName.c_str(), N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); ((TH1*) o[shName])->SetTitle("; Channel Id; Mean Mass;"); ((TH1*) o[shName])->SetOption("E1 GRIDX"); - shName = "hMassFitSigmaByChannel"; + shName = "hMassCleanFitSigmaByChannel"; o[shName] = new TH1F(shName.c_str(), shName.c_str(), N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); ((TH1*) o[shName])->SetTitle("; Channel Id; Mass Width;"); ((TH1*) o[shName])->SetOption("E1 GRIDX"); @@ -79,7 +79,7 @@ void CnipolKinemaCleanHists::BookHists() oc->fDir->cd(); - shName = "hPseudoMass_ch" + sChId; + shName = "hPseudoMassClean_ch" + sChId; hist = new TH1F(shName.c_str(), shName.c_str(), 50, 0, 20); hist->SetTitle("; Mass; Events;"); hist->SetOption("E1"); @@ -111,7 +111,7 @@ void CnipolKinemaCleanHists::FillDerived() { Info("FillDerived()", "Called"); - TH1* hPseudoMass = (TH1*) o["hPseudoMass"]; + TH1* hPseudoMass = (TH1*) o["hPseudoMassClean"]; for (UShort_t iCh=1; iCh<=N_SILICON_CHANNELS; iCh++) { @@ -120,7 +120,7 @@ void CnipolKinemaCleanHists::FillDerived() DrawObjContainer *oc = d.find("channel" + sChId)->second; - TH1* hPseudoMass_ch = (TH1*) oc->o["hPseudoMass_ch" + sChId]; + TH1* hPseudoMass_ch = (TH1*) oc->o["hPseudoMassClean_ch" + sChId]; hPseudoMass->Add(hPseudoMass_ch); } } @@ -137,7 +137,7 @@ void CnipolKinemaCleanHists::PostFill() //fitfunc.SetParameter(1, 0); //fitfunc.SetParLimits(1, -1, 1); - TH1* hPseudoMass = (TH1*) o["hPseudoMass"]; + TH1* hPseudoMass = (TH1*) o["hPseudoMassClean"]; if (hPseudoMass->Integral() <= 0) { Error("PostFill", "Mass distribution is empty"); @@ -153,9 +153,9 @@ void CnipolKinemaCleanHists::PostFill() hPseudoMass->GetListOfFunctions()->Clear(); } - TH1* hMassFitChi2ByChannel = (TH1*) o["hMassFitChi2ByChannel"]; - TH1* hMassFitMeanByChannel = (TH1*) o["hMassFitMeanByChannel"]; - TH1* hMassFitSigmaByChannel = (TH1*) o["hMassFitSigmaByChannel"]; + TH1* hMassFitChi2ByChannel = (TH1*) o["hMassCleanFitChi2ByChannel"]; + TH1* hMassFitMeanByChannel = (TH1*) o["hMassCleanFitMeanByChannel"]; + TH1* hMassFitSigmaByChannel = (TH1*) o["hMassCleanFitSigmaByChannel"]; // Fit channel histograms ChannelSetIter iCh = gMeasInfo->fSiliconChannels.begin(); @@ -167,7 +167,7 @@ void CnipolKinemaCleanHists::PostFill() DrawObjContainer *oc_ch = d.find("channel" + sChId)->second; - TH1* hPseudoMass_ch = (TH1*) oc_ch->o["hPseudoMass_ch" + sChId]; + TH1* hPseudoMass_ch = (TH1*) oc_ch->o["hPseudoMassClean_ch" + sChId]; if (hPseudoMass_ch->Integral() <= 0) { Error("PostFill", "Mass distribution for channel %s is empty", sChId.c_str()); diff --git a/src/CnipolPreprocHists.cxx b/src/CnipolPreprocHists.cxx index 916a566a..fcb13988 100644 --- a/src/CnipolPreprocHists.cxx +++ b/src/CnipolPreprocHists.cxx @@ -334,6 +334,8 @@ void CnipolPreprocHists::FillDerivedPassOne_FillFromRawHists(CnipolRawHists *raw // Apply the "proto slope" cut if ( fabs( binTdc - ( gMeasInfo->GetProtoCutSlope() * binAdc + gMeasInfo->GetProtoCutOffset() + extraOffset) ) > 20 ) + //zchang noise test + //if ( binTdc - ( gMeasInfo->GetProtoCutSlope() * binAdc + gMeasInfo->GetProtoCutOffset() + extraOffset) > -20 ) continue; //printf("binx, biny, slope, offset: %d, %d, %f, %f\n", binx, biny, gMeasInfo->GetProtoCutSlope(), gMeasInfo->GetProtoCutOffset()); diff --git a/src/CnipolPulserHists.cxx b/src/CnipolPulserHists.cxx index 01a0ebb6..ea9f37ec 100644 --- a/src/CnipolPulserHists.cxx +++ b/src/CnipolPulserHists.cxx @@ -183,7 +183,6 @@ void CnipolPulserHists::FillPassOne(ChannelEvent *ch) string sChId(" "); sprintf(&sChId[0], "%02d", chId); - //DrawObjContainer *sd = d["channel" + sChId]; // Speed up the filling process by getting the global bin number @@ -209,7 +208,7 @@ void CnipolPulserHists::FillPassOne(ChannelEvent *ch) hTmp_ch->SetEntries(hTmp_ch->GetEntries()+1); //((TH1*) sd->o.find("hTimeVsEnergyA_ch" + sChId)->second) -> Fill(ch->GetEnergyA(), ch->GetTime()); - fhTimeVsEnergyA_ch[chId-1] -> Fill(ch->GetEnergyA(), ch->GetTime()); + //fhTimeVsEnergyA_ch[chId-1] -> Fill(ch->GetEnergyA(), ch->GetTime()); //zchang TH1* h1Tmp_ch; diff --git a/src/CnipolRawHists.cxx b/src/CnipolRawHists.cxx index e55d3de6..40e04299 100644 --- a/src/CnipolRawHists.cxx +++ b/src/CnipolRawHists.cxx @@ -102,6 +102,12 @@ void CnipolRawHists::BookHists() CanRebin(hist); o[shName] = hist; + shName = "hBunchIdVsRevolutionId"; + hist = new TH2I(shName.c_str(), shName.c_str(), 1000, 0, 1, N_BUNCHES, 0.5, N_BUNCHES+0.5); + hist->SetTitle("; Revolution Id; Events; BunchId;"); + CanRebin(hist); + o[shName] = hist; + shName = "hChIdVsBunchId"; hist = new TH2I(shName.c_str(), shName.c_str(), N_BUNCHES, 0.5, N_BUNCHES+0.5, N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); hist->SetTitle("; Bunch Id; Channel Id; "); @@ -207,6 +213,7 @@ void CnipolRawHists::FillPassOne(ChannelEvent *ch) fhTvsI_ch[chId-1]->Fill(adcI, tdc); fhIvsA_ch[chId-1]->Fill(adcA, adcI); ((TH1*) o["hRevolutionId"])->Fill(ch->GetRevolutionId()); + ((TH1*) o["hBunchIdVsRevolutionId"])->Fill(ch->GetRevolutionId(), bId); } if (gCh2WfdMap) { diff --git a/src/CnipolSpinTuneMotorHists.cxx b/src/CnipolSpinTuneMotorHists.cxx new file mode 100644 index 00000000..7961902b --- /dev/null +++ b/src/CnipolSpinTuneMotorHists.cxx @@ -0,0 +1,233 @@ +#include +#include + +#include "TFitResult.h" +#include "TFitResultPtr.h" +#include "TGraphErrors.h" +#include "TStyle.h" + +#include "utils/utils.h" +#include "utils/binary.h" + +#include "AsymRoot.h" +#include "AsymGlobals.h" +#include "AnaMeasResult.h" +#include "TargetInfo.h" +#include "CnipolAsymHists.h" + +#include "CnipolSpinTuneMotorHists.h" + +ClassImp(CnipolSpinTuneMotorHists) + +using namespace std; + +/** Default constructor. */ +CnipolSpinTuneMotorHists::CnipolSpinTuneMotorHists() : DrawObjContainer() +{ + BookHists(); +} + + +CnipolSpinTuneMotorHists::CnipolSpinTuneMotorHists(TDirectory *dir) : DrawObjContainer(dir) +{ + BookHists(); +} + + +/** Default destructor. */ +CnipolSpinTuneMotorHists::~CnipolSpinTuneMotorHists() +{ +} + + +/** */ +void CnipolSpinTuneMotorHists::BookHists() +{ + fDir->cd(); + + string shName; + //TH1 *hist; + TAttMarker styleMarker; + + styleMarker.SetMarkerStyle(kFullCircle); + styleMarker.SetMarkerSize(1); + styleMarker.SetMarkerColor(kGreen+2); + + shName = "hTimeInterval"; + o[shName] = new TH1F(shName.c_str(), shName.c_str(), 300, 0, 30000); + ((TH1*) o[shName])->SetTitle("; interval in bunch; counts"); + + shName = "hChVsPhase"; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); + ((TH1*) o[shName])->SetTitle("; Phase in bunch; Channel Id;"); + ((TH1*) o[shName])->SetOption("colz"); + + shName = "hDetVsPhase"; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, N_DETECTORS, 0.5, N_DETECTORS+0.5); + ((TH1*) o[shName])->SetTitle("; Phase in bunch; Detector Id;"); + ((TH1*) o[shName])->SetOption("colz"); + + for(SpinStateSetIter iSS = gRunConfig.fSpinStates.begin(); iSS != gRunConfig.fSpinStates.end(); ++iSS){ + string sSS = gRunConfig.AsString(*iSS); + //Color_t color = RunConfig::AsColor(*iSS); + // + shName = "hChVsPhase_" + sSS; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, N_SILICON_CHANNELS, 0.5, N_SILICON_CHANNELS+0.5); + ((TH1*) o[shName])->SetTitle("; Phase in bunch; Channel Id;"); + ((TH1*) o[shName])->SetOption("colz"); + + shName = "hDetVsPhase_" + sSS; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, N_DETECTORS, 0.5, N_DETECTORS+0.5); + ((TH1*) o[shName])->SetTitle("; Phase in bunch; Detector Id;"); + ((TH1*) o[shName])->SetOption("colz "); + } + + /* + shName = "hAsymVsPhase_X45"; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, 100, 0, 1); + o[shName]->SetTitle("; Phase; Asymmetry;"); + o[shName]->SetOption("E1"); + + shName = "hAsymVsPhase_Y45"; + o[shName] = new TH2F(shName.c_str(), shName.c_str(), 300, 0, 300, 100, 0, 1); + o[shName]->SetTitle("; Phase; Asymmetry;"); + o[shName]->SetOption("E1"); + */ +} + + +/** */ +void CnipolSpinTuneMotorHists::Fill(ChannelEvent *ch) +{ + UChar_t chId = ch->GetChannelId(); + UChar_t bId = ch->GetBunchId(); + string sSS = gRunConfig.AsString( gMeasInfo->GetBunchSpin(bId+1) ); + UInt_t rev = ch->GetRevolutionId(); + UShort_t detId = RunConfig::GetDetectorId(chId); + //Double_t time = ((Double_t) ch->GetRevolutionId())/RHIC_REVOLUTION_FREQ; + //UInt_t rev = gAsymRoot->fChannelEvent->GetRevolutionId(); + //UChar_t bx = gAsymRoot->fChannelEvent->GetBunchId(); + unsigned long long mark = 120*rev + bId; + if(gAsymRoot->fSpinTuneMotor){ + long long phase = mark - binary(mark, gAsymRoot->fSpinTuneMotor->Array(), 0, gAsymRoot->fSpinTuneMotor->Size()-1); + + ((TH1*) o.find("hChVsPhase")->second) -> Fill(phase, chId); + ((TH1*) o.find( "hChVsPhase_" + sSS)->second)->Fill(phase, chId); + + ((TH1*) o.find("hDetVsPhase")->second) -> Fill(phase, detId); + ((TH1*) o.find("hDetVsPhase_" + sSS)->second) -> Fill(phase, detId); + } +} + + + +void CnipolSpinTuneMotorHists::FillDerived() +{ + + Info("FillDerived()", "Called"); + if(gAsymRoot->fSpinTuneMotor){ + if(gAsymRoot->fSpinTuneMotor->Size() < 2) return; + for(unsigned int i = 1; i < gAsymRoot->fSpinTuneMotor->Size(); i++){ + ((TH1 *) o.find("hTimeInterval")->second)->Fill(gAsymRoot->fSpinTuneMotor->At(i) - gAsymRoot->fSpinTuneMotor->At(i-1)); + } + } + /* + TH2* hChVsOscillPhase = (TH2*) o["hChVsOscillPhase"]; + TH2* hDetVsOscillPhase = (TH2*) o["hDetVsOscillPhase"]; + + SpinStateSetIter iSS = gRunConfig.fSpinStates.begin(); + for ( ; iSS!=gRunConfig.fSpinStates.end(); ++iSS) + { + string sSS = gRunConfig.AsString(*iSS); + + TH2* hChVsOscillPhase_ = (TH2*) o["hChVsOscillPhase_" + sSS]; + TH2* hDetVsOscillPhase_ = (TH2*) o["hDetVsOscillPhase_" + sSS]; + + for (int iCh=1; iCh<=N_SILICON_CHANNELS; iCh++) + { + // Fill detector histograms from the channel ones + // Skip disabled channels + if (gMeasInfo->IsDisabledChannel(iCh)) continue; + + UShort_t iDet = RunConfig::GetDetectorId(iCh); + + for (int iBin=1; iBin<=hDetVsOscillPhase_->GetNbinsX(); iBin++) + { + Double_t bc_ch = hChVsOscillPhase_->GetBinContent(iBin, iCh); + Double_t bc_det = hDetVsOscillPhase_->GetBinContent(iBin, iDet); + hDetVsOscillPhase_->SetBinContent(iBin, iDet, bc_det + bc_ch); + } + } + + hChVsOscillPhase->Add(hChVsOscillPhase_); + hDetVsOscillPhase->Add(hDetVsOscillPhase_); + } +*/ +} + +void CnipolSpinTuneMotorHists::PostFill() +{ + /* + TH2& hDetVsPhase_up = (TH2&) *o.find("hDetVsPhase_up")->second; + TH2& hDetVsPhase_dw = (TH2&) *o.find("hDetVsPhase_down")->second; + TH1& hAsymVsPhase_X45 = (TH1&) *o.find("hAsymVsPhase_X45")->second; + TH1& hAsymVsPhase_Y45 = (TH1&) *o.find("hAsymVsPhase_Y45")->second; + + Double_t LU = 0., RU = 0., LD = 0., RD = 0.; + Int_t left = 1, right = 3; + for(int ib = 0; ib GetNbinsX(); ib++){ + LU = hDetVsPhase_up->GetBinContent(ib+1, left); + RU = hDetVsPhase_up->GetBinContent(ib+1, right); + LD = hDetVsPhase_dw->GetBinContent(ib+1, left); + RD = hDetVsPhase_dw->GetBinContent(ib+1, right); + ValErrPair asym = gAsymCalculator.CalcAsymSqrtFormula(RU, LD, RD, LU); + } + */ +/** + TH2& hDetVsOscillPhase_up = (TH2&) *o.find("hDetVsOscillPhase_up")->second; + TH2& hDetVsOscillPhase_down = (TH2&) *o.find("hDetVsOscillPhase_down")->second; + TH1& hAsymVsOscillPhase_X45 = (TH1&) *o.find("hAsymVsOscillPhase_X45")->second; + TH1& hAsymVsOscillPhase_Y45 = (TH1&) *o.find("hAsymVsOscillPhase_Y45")->second; + + gAsymCalculator.CalcOscillPhaseAsymSqrtFormula(hDetVsOscillPhase_up, hDetVsOscillPhase_down, hAsymVsOscillPhase_X45, AsymCalculator::X45Dets); + gAsymCalculator.CalcOscillPhaseAsymSqrtFormula(hDetVsOscillPhase_up, hDetVsOscillPhase_down, hAsymVsOscillPhase_Y45, AsymCalculator::Y45Dets); + + TF1 fitFunc("fitFunc", "[0] + [1]*sin(x + [2])", 0, _TWO_PI); + + hAsymVsOscillPhase_X45.Fit(&fitFunc); + //hAsymVsOscillPhase_Y45.Fit(&fitFunc); + fitFunc.SetParNames("Offset", "Amplitude", "Phase"); + + AsymTypeSetIter iAsymType = gRunConfig.fAsymTypes.begin(); + for (; iAsymType!=gRunConfig.fAsymTypes.end(); ++iAsymType) + { + string sAsymType = gRunConfig.AsString(*iAsymType); + TGraphErrors* graphErrs; + + // Fit every asymmetry type graph for X45 + string shName = "gr" + string(hAsymVsOscillPhase_X45.GetName()) + "_" + sAsymType; + graphErrs = (TGraphErrors*) hAsymVsOscillPhase_X45.GetListOfFunctions()->FindObject(shName.c_str()); + graphErrs->Fit(&fitFunc); + + // Add graphs for each bin to a single histograms + TH1* hist = (TH1*) o["hAsymVsOscillPhase_X45_" + sAsymType]; + hist->GetListOfFunctions()->Add(graphErrs->Clone(), "p"); + + utils::UpdateLimitsFromGraphs(hist, 2); + + // Fit every asymmetry type graph for Y45 + shName = "gr" + string(hAsymVsOscillPhase_Y45.GetName()) + "_" + sAsymType; + graphErrs = (TGraphErrors*) hAsymVsOscillPhase_Y45.GetListOfFunctions()->FindObject(shName.c_str()); + graphErrs->Fit(&fitFunc); + + // Add graphs for each bin to a single histograms + hist = (TH1*) o["hAsymVsOscillPhase_Y45_" + sAsymType]; + hist->GetListOfFunctions()->Add(graphErrs->Clone(), "p"); + + utils::UpdateLimitsFromGraphs(hist, 2); + } + + utils::UpdateLimitsFromGraphs(&hAsymVsOscillPhase_X45, 2); + utils::UpdateLimitsFromGraphs(&hAsymVsOscillPhase_Y45, 2); +*/ +} diff --git a/src/DrawObjContainer.cxx b/src/DrawObjContainer.cxx index 30e725f1..1a09fde6 100644 --- a/src/DrawObjContainer.cxx +++ b/src/DrawObjContainer.cxx @@ -678,7 +678,6 @@ void DrawObjContainer::FillPassOne(ChannelEvent *ch) void DrawObjContainer::FillDerivedPassOne() { DrawObjContainerMapIter isubd; - for (isubd=d.begin(); isubd!=d.end(); ++isubd) { isubd->second->FillDerivedPassOne(); } diff --git a/src/MAsymAnaInfo.cxx b/src/MAsymAnaInfo.cxx index a25514b8..3525432e 100644 --- a/src/MAsymAnaInfo.cxx +++ b/src/MAsymAnaInfo.cxx @@ -81,7 +81,6 @@ void MAsymAnaInfo::ProcessOptions(int argc, char **argv) case AnaInfo::FLAG_USE_DB: fFlagUseDb = kTRUE; - fFlagUpdateDb = kTRUE; break; case AnaInfo::FLAG_CREATE_THUMBS: @@ -93,6 +92,7 @@ void MAsymAnaInfo::ProcessOptions(int argc, char **argv) break; case AnaInfo::FLAG_UPDATE_DB: + fFlagUseDb = kTRUE; fFlagUpdateDb = kTRUE; break; diff --git a/src/MAsymBiasHists.cxx b/src/MAsymBiasHists.cxx index 03392e81..8e1d3363 100644 --- a/src/MAsymBiasHists.cxx +++ b/src/MAsymBiasHists.cxx @@ -16,7 +16,8 @@ MAsymBiasHists::MAsymBiasHists(TDirectory *dir) : DrawObjContainer(dir) } -void MAsymBiasHists::BookHists(string sid) +//void MAsymBiasHists::BookHists(string sid) +void MAsymBiasHists::BookHists() { fDir->cd(); @@ -52,13 +53,14 @@ void MAsymBiasHists::Fill(const EventConfig &rc) Double_t runId = rc.fMeasInfo->RUNID; Short_t polId = rc.fMeasInfo->fPolId; vector bc = rc.fMeasInfo->GetBiasCurrents(); - + Info("Fill", "Fill bc size=%d", bc.size()); for(int det = 0; det < N_DETECTORS; det++) { TGraphErrors *g = grBiasCurrent[polId][det]; if (std::isnan(bc[det])) continue; int nPoints = g->GetN(); + //Info("Fill", "npoints=%d det %d bc %lg", nPoints, det, bc[det]); g->SetPoint(nPoints, runId, bc[det]); g->SetPointError(nPoints, 0.0, 0.0); } @@ -84,8 +86,8 @@ void MAsymBiasHists::UpdateLimits() TGraphErrors *g = grBiasCurrent[*iPolId][det]; g->ComputeRange(xmin, ymin, xmax, ymax); - h->GetXaxis()->SetLimits(xmin, xmax); - h->GetYaxis()->SetLimits(-50., 0.); + h->GetXaxis()->SetLimits(xmin-0.5, xmax+0.5); + h->GetYaxis()->SetLimits(-25., 15.); } } } diff --git a/src/MAsymFillHists.cxx b/src/MAsymFillHists.cxx index 689785f3..1a590d2b 100644 --- a/src/MAsymFillHists.cxx +++ b/src/MAsymFillHists.cxx @@ -76,6 +76,7 @@ void MAsymFillHists::BookHists() hist->GetListOfFunctions()->SetOwner(kTRUE); o[shName] = hist; hAgsPolarVsFillId = hist; + } @@ -554,7 +555,7 @@ void MAsymFillHists::PostFill() /** */ void MAsymFillHists::PostFill(AnaGlobResult &agr) { - utils::SetXAxisIntBinsLabels(hAgsPolarVsFillId, agr.GetMinFill(), agr.GetMaxFill()); + utils::SetXAxisIntBinsLabels(hAgsPolarVsFillId, agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); // Should be moved to a new function RingIdSetIter iRingId = gRunConfig.fRings.begin(); @@ -563,12 +564,12 @@ void MAsymFillHists::PostFill(AnaGlobResult &agr) ERingId ringId = *iRingId; string sRingId = RunConfig::AsString(ringId); - utils::SetXAxisIntBinsLabels((TH1*) o["hBunchAsymChi2_" + sRingId], agr.GetMinFill(), agr.GetMaxFill()); - utils::SetXAxisIntBinsLabels((TH1*) o["hBunchAsymSigma_" + sRingId], agr.GetMinFill(), agr.GetMaxFill()); + utils::SetXAxisIntBinsLabels((TH1*) o["hBunchAsymChi2_" + sRingId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); + utils::SetXAxisIntBinsLabels((TH1*) o["hBunchAsymSigma_" + sRingId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); - utils::SetXAxisIntBinsLabels(hRotatorPCPolarRatiosByRing[ringId], agr.GetMinFill(), agr.GetMaxFill()); - utils::SetXAxisIntBinsLabels(hRampPCPolarRatiosByRing[ringId], agr.GetMinFill(), agr.GetMaxFill()); - utils::SetXAxisIntBinsLabels(hRhicAgsPolarRatiosByRing[ringId], agr.GetMinFill(), agr.GetMaxFill()); + utils::SetXAxisIntBinsLabels(hRotatorPCPolarRatiosByRing[ringId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); + utils::SetXAxisIntBinsLabels(hRampPCPolarRatiosByRing[ringId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); + utils::SetXAxisIntBinsLabels(hRhicAgsPolarRatiosByRing[ringId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); } @@ -578,8 +579,8 @@ void MAsymFillHists::PostFill(AnaGlobResult &agr) EPolarimeterId polId = *iPolId; string sPolId = RunConfig::AsString(polId); - utils::SetXAxisIntBinsLabels(hRotatorPCPolarRatiosByPol[polId], agr.GetMinFill(), agr.GetMaxFill()); - utils::SetXAxisIntBinsLabels(hRampPCPolarRatiosByPol[polId], agr.GetMinFill(), agr.GetMaxFill()); + utils::SetXAxisIntBinsLabels(hRotatorPCPolarRatiosByPol[polId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); + utils::SetXAxisIntBinsLabels(hRampPCPolarRatiosByPol[polId], agr.GetMinFill()-0.5, agr.GetMaxFill()+0.5); } @@ -630,6 +631,7 @@ void MAsymFillHists::PostFill(AnaGlobResult &agr) } ValErrPair agsPol = afr.GetAgsCniPolar(); + Printf("AGS polar %lg+/-%lg", agsPol.first, agsPol.second); if (agsPol.second >= 0) { utils::AppendToGraph(grAgsPolarVsFillId, fillId, agsPol.first, 0, agsPol.second); diff --git a/src/MAsymRunHists.cxx b/src/MAsymRunHists.cxx index cd97f5aa..9ff822e4 100644 --- a/src/MAsymRunHists.cxx +++ b/src/MAsymRunHists.cxx @@ -253,7 +253,7 @@ void MAsymRunHists::BookHistsByPolarimeter(DrawObjContainer &oc, EPolarimeterId styleMarker.Copy(*grSpinAngleVsMeas); shName = "hSpinAngleVsMeas_" + sPolId + "_" + sBeamE; - hist = new TH2C(shName.c_str(), shName.c_str(), 1, 0, 1, 1, -20, 20); + hist = new TH2C(shName.c_str(), shName.c_str(), 1, 0, 1, 1, -55, 55); hist->SetTitle("; Measurement Id; Spin Angle (Radial Comp.), degrees; "); hist->SetOption("DUMMY"); hist->GetListOfFunctions()->Add(grSpinAngleVsMeas, "p"); @@ -275,23 +275,32 @@ void MAsymRunHists::BookHistsByPolarimeter(DrawObjContainer &oc, EPolarimeterId // Add this pointer to the stack fHStacks["hsPolarVsMeas_" + sBeamE]->Add(hist); + //vs. fill + TGraphErrors *grPolarVsFill = new TGraphErrors(); + grPolarVsFill->SetName("grPolarVsFill"); + styleMarker.Copy(*grPolarVsFill); + shName = "hPolarVsFill_" + sPolId + "_" + sBeamE; hist = new TH1F(shName.c_str(), shName.c_str(), 1, 0, 1); hist->GetYaxis()->SetRangeUser(0, 100); hist->SetTitle("; Fill Id; Polarization, %;"); hist->SetOption("E1 GRIDX"); - hist->GetListOfFunctions()->Add(grPolarVsMeas, "p"); + hist->GetListOfFunctions()->Add(grPolarVsFill, "p"); styleMarker.Copy(*hist); oc.o[shName] = hist; // Add this pointer to the stack fHStacks["hsPolarVsFill_" + sBeamE]->Add(hist); + TGraphErrors *grPolarFirstVsFill = new TGraphErrors(); + grPolarFirstVsFill->SetName("grPolarFirstVsFill"); + styleMarker.Copy(*grPolarFirstVsFill); + shName = "hPolarFirstMeasVsFill_" + sPolId + "_" + sBeamE; hist = new TH1F(shName.c_str(), shName.c_str(), 1, 0, 1); hist->GetYaxis()->SetRangeUser(0, 100); //hist->GetXaxis()->SetNdivisions(1005); hist->SetTitle("; Fill Id; Polarization, %;"); hist->SetOption("E1 GRIDX"); - hist->GetListOfFunctions()->Add(grPolarVsMeas, "p"); + hist->GetListOfFunctions()->Add(grPolarFirstVsFill, "p"); styleMarker.Copy(*hist); oc.o[shName] = hist; shName = "hPolarHJVsFill_" + sPolId + "_" + sBeamE; @@ -842,8 +851,8 @@ void MAsymRunHists::BookHistsByRing(DrawObjContainer &oc, ERingId ringId, EBeamE // decay shName = "hIntensDecayVsFill_" + sRingId + "_" + sBeamE; hist = new TH1F(shName.c_str(), shName.c_str(), 1, 0, 1); - hist->GetYaxis()->SetRangeUser(0, 100); - hist->SetTitle("; Fill Id; Lifetime, hour;"); + hist->GetYaxis()->SetRangeUser(0,13); + hist->SetTitle("; Fill Id; Lifetime, hour (reduced by 1%);"); hist->SetOption("E1"); styleMarker.Copy(*hist); oc.o[shName] = hist; @@ -1392,10 +1401,15 @@ void MAsymRunHists::PostFill() hist = (TH1*) oc_pol->o["hSpinAngleVsMeas_" + sPolId + "_" + sBeamE]; graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grSpinAngleVsMeas"); graph->Fit("pol0"); + // Polarization + hist = (TH1*) oc_pol->o["hPolarVsMeas_" + sPolId + "_" + sBeamE]; + graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grPolarVsMeas"); + graph->Fit("pol0"); + // Polarization hist = (TH1*) oc_pol->o["hPolarVsFill_" + sPolId + "_" + sBeamE]; - graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grPolarVsMeas"); + graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grPolarVsFill"); hist->SetBins(fMaxFill-fMinFill, fMinFill, fMaxFill); utils::BinGraph(graph, hist); hist->GetListOfFunctions()->Remove(graph); @@ -1403,7 +1417,7 @@ void MAsymRunHists::PostFill() // Polarization: first measurement in fill hist = (TH1*) oc_pol->o["hPolarFirstMeasVsFill_" + sPolId + "_" + sBeamE]; - graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grPolarVsMeas"); + graph = (TGraphErrors*) hist->GetListOfFunctions()->FindObject("grPolarFirstVsFill"); hist->SetBins(fMaxFill-fMinFill, fMinFill, fMaxFill); utils::BinGraphByFirstOnly(graph, hist); hist->GetListOfFunctions()->Remove(graph); @@ -1514,13 +1528,13 @@ void MAsymRunHists::PostFill() TH1* hT0VsChannelDiff_ = (TH1*) oc_pol->o["hT0VsChannelDiff_"+sPolId]; TH1* hT0VsChannelInj_ = (TH1*) oc_pol->o["hT0VsChannel_"+sPolId+"_024"]; - TH1* hT0VsChannelFlt_ = (TH1*) oc_pol->o["hT0VsChannel_"+sPolId+"_250"]; + TH1* hT0VsChannelFlt_ = (TH1*) oc_pol->o["hT0VsChannel_"+sPolId+"_254"]; hT0VsChannelDiff_->Add(hT0VsChannelInj_, hT0VsChannelFlt_, 1, -1); TH1* hDLVsChannelDiff_ = (TH1*) oc_pol->o["hDLVsChannelDiff_"+sPolId]; TH1* hDLVsChannelInj = (TH1*) oc_pol->o["hDLVsChannel_"+sPolId+"_024"]; - TH1* hDLVsChannelFlt = (TH1*) oc_pol->o["hDLVsChannel_"+sPolId+"_250"]; + TH1* hDLVsChannelFlt = (TH1*) oc_pol->o["hDLVsChannel_"+sPolId+"_254"]; hDLVsChannelDiff_->Add(hDLVsChannelInj, hDLVsChannelFlt, 1, -1); @@ -1544,24 +1558,28 @@ void MAsymRunHists::PostFill() TH1F* hPolarInj = (TH1F*) oc_pol->o["hPolarVsFill_" + sPolId + "_024"]; //TH1F* hPolarFst = (TH1F*) oc_pol->o["hPolarFirstMeasVsFill_" + sPolId + "_100"]; //TH1F* hPolarFst = (TH1F*) oc_pol->o["hPolarFirstMeasVsFill_" + sPolId + "_250"]; - TH1F* hPolarFst = (TH1F*) oc_pol->o["hPolarFirstMeasVsFill_" + sPolId + "_255"]; + TH1F* hPolarFst = (TH1F*) oc_pol->o["hPolarFirstMeasVsFill_" + sPolId + "_254"]; hPolarFirstMeasRatioVsFill_->SetBins(fMaxFill-fMinFill, fMinFill, fMaxFill); hPolarFirstMeasRatioVsFill_->Divide(hPolarFst, hPolarInj); hPolarFirstMeasRatioVsFill_->Fit("pol0"); } - + TH1F* hPolarVsFill_B1U_024 = (TH1F*) d["B1U"]->o["hPolarVsFill_B1U_024"]; TH1F* hPolarVsFill_B2D_024 = (TH1F*) d["B2D"]->o["hPolarVsFill_B2D_024"]; TH1F* hPolarUDRatioVsFill_BLU_024 = (TH1F*) d["BLU"]->o["hPolarUDRatioVsFill_BLU_024"]; - hPolarUDRatioVsFill_BLU_024->Divide(hPolarVsFill_B1U_024, hPolarVsFill_B2D_024); - hPolarUDRatioVsFill_BLU_024->Fit("pol0"); + if(hPolarVsFill_B1U_024 && hPolarVsFill_B2D_024 && hPolarUDRatioVsFill_BLU_024){ + hPolarUDRatioVsFill_BLU_024->Divide(hPolarVsFill_B1U_024, hPolarVsFill_B2D_024); + hPolarUDRatioVsFill_BLU_024->Fit("pol0"); + } TH1F* hPolarVsFill_Y2U_024 = (TH1F*) d["Y2U"]->o["hPolarVsFill_Y2U_024"]; TH1F* hPolarVsFill_Y1D_024 = (TH1F*) d["Y1D"]->o["hPolarVsFill_Y1D_024"]; TH1F* hPolarUDRatioVsFill_YEL_024 = (TH1F*) d["YEL"]->o["hPolarUDRatioVsFill_YEL_024"]; - hPolarUDRatioVsFill_YEL_024->Divide(hPolarVsFill_Y2U_024, hPolarVsFill_Y1D_024); - hPolarUDRatioVsFill_YEL_024->Fit("pol0"); + if(hPolarVsFill_Y2U_024 && hPolarVsFill_Y1D_024 && hPolarUDRatioVsFill_YEL_024){ + hPolarUDRatioVsFill_YEL_024->Divide(hPolarVsFill_Y2U_024, hPolarVsFill_Y1D_024); + hPolarUDRatioVsFill_YEL_024->Fit("pol0"); + } } @@ -1572,6 +1590,8 @@ void MAsymRunHists::PostFillByPolarimeter(AnaGlobResult &agr, AnaFillResultMapIt AnaFillResult afr = iafr->second; if (afr.fPCPolars.find(polId) == afr.fPCPolars.end()) return; + //Info("PostFill", "flattop: %lg beam=%d", afr.GetFlattopEnergy(), beamE); + if ((UInt_t) afr.GetFlattopEnergy() != beamE && beamE != kINJECTION) return; //zchang match energy //if (afr.fProfPCPolars.find(polId) == afr.fProfPCPolars.end()) continue; string sPolId = RunConfig::AsString(polId); @@ -1609,6 +1629,12 @@ void MAsymRunHists::PostFillByPolarimeter(AnaGlobResult &agr, AnaFillResultMapIt //ValErrPair polarPCNorm = afr.GetPCPolar(polId, &agr.fNormJetCarbon); // ratio of average //ValErrPair polarProfNorm = afr.GetPCPolar(polId, &agr.fNormProfPolar); ValErrPair polarPCNorm = afr.GetPCPolar(polId, &agr.fNormJetCarbon2); // average of ratio + ValErrPair polarPhase = afr.GetPCPolarPhase(polId); // unnormalized value + //Info("PostFill", "polarHJ %lg +/- %lg", polarHJ.first, polarHJ.second); + //Info("PostFill", "polarPC %lg +/- %lg", polarPC.first, polarPC.second); + //Info("PostFill", "polarPhase %lg +/- %lg", polarPhase.first, polarPhase.second); + //if(polarHJ.second < 0 || polarPC.second < 0 || polarPhase.second < 0) return; + if(polarPC.second < 0 || polarPhase.second < 0) return; //ValErrPair polarProfNorm = afr.GetPCPolar(polId, &agr.fNormProfPolar2); //ValErrPair normJC2 = agr.GetNormJetCarbon(polId); @@ -1619,12 +1645,16 @@ void MAsymRunHists::PostFillByPolarimeter(AnaGlobResult &agr, AnaFillResultMapIt // polarHJ.first, polarHJ.second, polarPC.first, polarPC.second, // polarPCNorm.first, polarPCNorm.second); - if (polarPCNorm.second >= 0) //if (polarPC.second >= 0) + if (polarHJ.second >= 0 && polarPCNorm.second >= 0) //if (polarPC.second >= 0) { + ValErrPair polarHJt(0, -1); + polarHJt.first = polarHJ.first/TMath::Cos(polarPhase.first); + polarHJt.second = polarHJt.first*TMath::Sqrt(TMath::Power(polarHJ.second/polarHJ.first, 2)+TMath::Power(TMath::Tan(polarPhase.first)*polarPhase.second, 2)); + Info("FillByPolarimeter", "HJ: %lg +/- %lg HJt: %lg +/- %lg", polarHJ.first, polarHJ.second, polarHJt.first, polarHJt.second); // Save HJ only if corresponding pC is available - if (polarHJ.second >= 0) { - hPolarHJVsFill_->SetBinContent(ib, polarHJ.first*100); - hPolarHJVsFill_->SetBinError( ib, polarHJ.second*100); + if (polarHJt.second >= 0) { + hPolarHJVsFill_->SetBinContent(ib, polarHJt.first*100); + hPolarHJVsFill_->SetBinError( ib, polarHJt.second*100); hPolarPCScaledVsFill_HJOnly_->SetBinContent(ib, polarPCNorm.first*100); hPolarPCScaledVsFill_HJOnly_->SetBinError( ib, polarPCNorm.second*100); @@ -1638,6 +1668,7 @@ void MAsymRunHists::PostFillByPolarimeter(AnaGlobResult &agr, AnaFillResultMapIt } ValErrPair profPolar = afr.fPCProfPolars[polId]; + Info("PostFill", "profPolar = %lg +/- %lg", profPolar.first, profPolar.second); if (profPolar.second >= 0) { hProfPolarVsFill_->SetBinContent(ib, profPolar.first*100); @@ -1682,7 +1713,7 @@ void MAsymRunHists::PostFillByPolarimeter(AnaGlobResult &agr, AnaFillResultMapIt TGraph* grRVsMeas_O_ = (TGraph*) hRVsFill_O_->GetListOfFunctions()->FindObject(("grRVsMeas" + sTgtOrient).c_str()); ValErrPair pcProfR = beamE == kINJECTION ? afr.GetPCProfRInj(polId, tgtOrient) : afr.GetPCProfR(polId, tgtOrient); - + Info("PostFill", "target %s, prof r = %lg +/- %lg", sTgtOrient.c_str(), pcProfR.first, pcProfR.second); if (pcProfR.second >= 0) { utils::AppendToGraph(grRVsMeas, fillId, pcProfR.first, 0, pcProfR.second); utils::AppendToGraph(grRVsMeas_O_, fillId, pcProfR.first, 0, pcProfR.second); @@ -1714,6 +1745,8 @@ void MAsymRunHists::PostFillByRing(AnaGlobResult &agr, AnaFillResultMapIter iafr UInt_t fillId = iafr->first; AnaFillResult afr = iafr->second; + if ((UInt_t) afr.GetFlattopEnergy() != beamE && beamE != kINJECTION) return; //zchang match energy + string sRingId = RunConfig::AsString(ringId); string sBeamE = RunConfig::AsString(beamE); diff --git a/src/MAsymSingleFillHists.cxx b/src/MAsymSingleFillHists.cxx index e59898dd..ce3952fa 100644 --- a/src/MAsymSingleFillHists.cxx +++ b/src/MAsymSingleFillHists.cxx @@ -169,7 +169,8 @@ void MAsymSingleFillHists::BookHistsByPolarimeter(EPolarimeterId polId) o[shName] = hist; shName = "hBCVsFillTime_" + strDirName + "_" + sPolId; - hist = new TH2C(shName.c_str(), shName.c_str(), 1, fMinTime, fMaxTime, 1, -50, 0); + //Printf("fmintime: %ld fmaxtime: %ld", fMinTime, fMaxTime); + hist = new TH2C(shName.c_str(), shName.c_str(), 1, fMinTime, fMaxTime, 1, -25, 15); hist->SetTitle("; Time in Fill, hours; BiasCurrent, \\mu A;"); hist->SetOption("DUMMY GRIDX GRIDY"); //hist->GetXaxis()->SetTimeOffset(0, "local"); @@ -348,7 +349,9 @@ void MAsymSingleFillHists::PostFill(AnaFillResult &afr) TGraphErrors *gr = *it; gr->SetMarkerStyle(20); gr->SetMarkerColor(RunConfig::DetAsColor(det)); - gr->SetMarkerSize(0.3); + gr->SetMarkerSize(1); + //Printf("PostFill: %s color: %d", "hBCVsFillTime", RunConfig::DetAsColor(det)); + //gr->Print();//zchang debug hBCVsFillTime_->GetListOfFunctions()->Add(gr, "p"); det++; } @@ -363,11 +366,12 @@ void MAsymSingleFillHists::PostFill(AnaFillResult &afr) { MeasInfo *measInfo = *it; mark_gr->SetPoint(i, measInfo->fStartTime - afr.GetStartTime(), -0.1); + //Printf("PostFill: time =%ld", measInfo->fStartTime-afr.GetStartTime()); i++; } mark_gr->SetMarkerStyle(23); - mark_gr->SetMarkerSize(5); + mark_gr->SetMarkerSize(2); hBCVsFillTime_->GetListOfFunctions()->AddFirst(mark_gr, "p"); } } @@ -389,6 +393,12 @@ void MAsymSingleFillHists::PostFill(AnaFillResult &afr) TH1* hIntensVsFillTime_ = (TH1*) o["hIntensVsFillTime_" + strDirName + "_" + sRingId]; if (graphErrs && graphErrs->GetN() > 0) { + TF1 fitFunc("fitFunc", "exp([0]+[1]*x/3600)"); + //fitFunc.SetParameter(0, 100); + //fitFunc.SetParameter(1, 100); + fitFunc.SetParNames("const", "life"); + graphErrs->Fit(&fitFunc); + Info("PostFill", "Fitting intensity vs. time exp(%lg+x*(%lg))", fitFunc.GetParameter(0), fitFunc.GetParameter(1)); ((TAttMarker*) hIntensVsFillTime_)->Copy(*graphErrs); graphErrs->SetMarkerSize(0.8); hIntensVsFillTime_->GetListOfFunctions()->Add(graphErrs, "p"); diff --git a/src/MeasInfo.cxx b/src/MeasInfo.cxx index 250b423e..7cd17607 100644 --- a/src/MeasInfo.cxx +++ b/src/MeasInfo.cxx @@ -15,6 +15,9 @@ #include "MseMeasInfo.h" #include "RunPeriod.h" +#include "CachingLogReader.h" +#include "SshLogReader.h" + #include "revision-export.h" ClassImp(MeasInfo) @@ -442,9 +445,6 @@ void MeasInfo::Update(const MseMeasInfoX& run) while (sstr >> chId) { DisableChannel(chId); } - if (!sstr.eof()) { - Fatal("Update", "Could not parse run period's disabled_channels from \"%s\", it must be whitespace-delimetered list of numbers", run.disabled_channels.c_str()); - } // Check for horizontal targets and disable 90 degree detectors if (fTargetOrient == 'H') { @@ -473,12 +473,15 @@ void MeasInfo::Update(const MseMeasInfoX& run) } else if (RUNID >= 17000 && RUNID < 18000) { // Run 13 fRunId = 13; gCh2WfdMap = ch2WfdMap_run13; - } else if (RUNID >= 18000 && RUNID < 20000) { // Run 15 + } else if (RUNID >= 18000 && RUNID < 20000) { fRunId = 15; gCh2WfdMap = ch2WfdMap_run13; - } else if (RUNID >= 20000) { // Run 17 + } else if(RUNID >= 20000 && RUNID < 31000){ fRunId = 17; gCh2WfdMap = ch2WfdMap_run11; + } else if(RUNID >= 31000){ + fRunId = 22; + gCh2WfdMap = ch2WfdMap_run11; } else { // default Run value } @@ -612,6 +615,14 @@ Bool_t MeasInfo::IsSiliconChannel(UShort_t chId) return false; } +Bool_t MeasInfo::IsSpinTuneChannel(UShort_t chId) +{ + if (chId == 80) + return true; + + return false; +} + /** */ UShort_t MeasInfo::GetNumDisabledChannels() const @@ -777,11 +788,11 @@ vector MeasInfo::GetBiasCurrents() const } } - AnaInfo *anaInfo = gAsymAnaInfo ? (AnaInfo*)gAsymAnaInfo : (AnaInfo*)gMAsymAnaInfo; - - static opencdev::LocalLogReader log_reader(anaInfo->GetSlowControlLogDir()); - + //AnaInfo *anaInfo = gAsymAnaInfo ? (AnaInfo*)gAsymAnaInfo : (AnaInfo*)gMAsymAnaInfo; + //static opencdev::LocalLogReader log_reader(anaInfo->GetSlowControlLogDir()); + CachingLogReader log_reader; string logger_name = BiasCurrentUtil::GetBiasCurrentLoggerName((EPolarimeterId)fPolId); + Info("BiasCurrent", "logger: %s", logger_name.c_str()); opencdev::mean_result_t bias_mean_value; log_reader.query_timerange_mean(logger_name, startTime, endTime, &bias_mean_value); @@ -828,6 +839,7 @@ EPolarimeterId MeasInfo::ExtractPolarimeterId(std::string runName) * "New system" streamer with backward-compatibility to old files. * Implemented as suggested in https://root.cern.ch/root/SchemaEvolution.html */ +/* void MeasInfo::Streamer(TBuffer &R__b) { // Stream an object of class MeasInfo. @@ -841,9 +853,9 @@ void MeasInfo::Streamer(TBuffer &R__b) } TObject::Streamer(R__b); R__b >> fBeamEnergy; - fMachineParams.Streamer(R__b); + //fMachineParams.Streamer(R__b); R__b >> fHasMachineParamsInRawData; - fTargetParams.Streamer(R__b); + //fTargetParams.Streamer(R__b); R__b >> fExpectedGlobalTdcOffset; R__b >> fExpectedGlobalTimeOffset; { TString R__str; R__str.Streamer(R__b); fRunName = R__str.Data(); } @@ -956,4 +968,4 @@ void MeasInfo::Streamer(TBuffer &R__b) } else { MeasInfo::Class()->WriteBuffer(R__b, this); } -} +}*/ diff --git a/src/RawDataReader.cxx b/src/RawDataReader.cxx index bfeeb767..8d78c941 100644 --- a/src/RawDataReader.cxx +++ b/src/RawDataReader.cxx @@ -409,7 +409,8 @@ void RawDataReader::ReadDataPassTwo(MseMeasInfoX &mseMeasInfo) mseMeasInfo.nevents_processed = gMeasInfo->fNEventsProcessed; mseMeasInfo.nevents_silicon = gMeasInfo->fNEventsSilicon; - if (gAsymAnaInfo->HasAlphaBit()) + //if (gAsymAnaInfo->HasAlphaBit()) + if (gAsymAnaInfo->HasAlphaBit() || gAsymAnaInfo->HasPulserBit()) //zchang mseMeasInfo.beam_energy = 0; else mseMeasInfo.beam_energy = gMeasInfo->GetBeamEnergyReal(); @@ -628,22 +629,27 @@ static void ProcessRecordATPassOne(const char *mSeek, RecordHeaderStruct *mHeade if ( gAsymRoot->fChannelEvent->PassCutEmptyBunch() ) gAsymRoot->FillPassOne(kCUT_PASSONE_RAW_EB); } - - if ( gAsymRoot->fChannelEvent->PassCutPmtChannel() ) - { - gAsymRoot->FillPassOne(kCUT_PASSONE_PMT); - } - + //zchang + if(gAsymRoot->fChannelEvent->PassCutSpinTuneChannel()) + { + if(gAsymRoot->fSpinTuneMotor) gAsymRoot->FillSpinTuneMotor(); + } + // + if ( gAsymRoot->fChannelEvent->PassCutPmtChannel() ) + { + gAsymRoot->FillPassOne(kCUT_PASSONE_PMT); + } + if ( gAsymRoot->fChannelEvent->PassCutStepperChannel() ) - { - gAsymRoot->FillPassOne(kCUT_PASSONE_STEPPER); + { + gAsymRoot->FillPassOne(kCUT_PASSONE_STEPPER); } - + if ( gAsymAnaInfo->HasStudiesBit() && gAsymRoot->fChannelEvent->IsSpinFlipperMarkerChannel() ) { - gAsymRoot->AddSpinFlipperMarker(); + gAsymRoot->AddSpinFlipperMarker(); } - + gMeasInfo->fNEventsProcessed++; } } @@ -703,7 +709,6 @@ static void ProcessRecordATPassTwo(const char *mSeek, RecordHeaderStruct *mHeade } } } - if (gAsymAnaInfo->fSaveTrees.any()) { gAsymRoot->AddChannelEvent(); } // Fill target histograms @@ -711,16 +716,32 @@ static void ProcessRecordATPassTwo(const char *mSeek, RecordHeaderStruct *mHeade { gAsymRoot->fHists->d["targets"]->Fill(gAsymRoot->fChannelEvent); } + //zchang noise study + if (gAsymAnaInfo->HasNoiseBit() && ! gAsymAnaInfo->HasNormalBit() && + gAsymRoot->fChannelEvent->PassCutSiliconChannel() && + gAsymRoot->fChannelEvent->PassCutEnabledChannel() ) + { + gAsymRoot->Fill(kCUT_NOISE); + + //zchang noise study -- need to revert to carbon cut for normal analysis + if(gAsymRoot->fChannelEvent->PassCutNoiseLower()) + { + //gAsymRoot->Fill(kCUT_NOISE_LOWER); + //zchang noise cut test + gAsymRoot->Fill(kCUT_CARBON); + } + } if (gAsymAnaInfo->HasNormalBit() && gAsymRoot->fChannelEvent->PassCutSiliconChannel() && gAsymRoot->fChannelEvent->PassCutKinEnergyAEDepend() && gAsymRoot->fChannelEvent->PassCutEnabledChannel() ) { - gAsymRoot->Fill(kCUT_NOISE); + gAsymRoot->Fill(kCUT_NOISE); if (gAsymRoot->fChannelEvent->PassCutCarbonMass()) gAsymRoot->Fill(kCUT_CARBON); + } if ( gAsymRoot->fChannelEvent->PassCutSiliconChannel() ) @@ -880,14 +901,17 @@ void ProcessRecord(const recordMeasTypeStruct &rec) /** */ void ProcessRecord(const recordPolAdoStruct &rec, MseMeasInfoX &mseMeasInfo) { - if (!gAsymAnaInfo->HasAlphaBit()) DecodeTargetID( (polDataStruct &) rec.data, mseMeasInfo); + //if (!gAsymAnaInfo->HasAlphaBit()) + if (!gAsymAnaInfo->HasAlphaBit() && !gAsymAnaInfo->HasPulserBit()) //zchang + DecodeTargetID( (polDataStruct &) rec.data, mseMeasInfo); } /** */ void ProcessRecord(const recordpCTagAdoStruct &rec, MseMeasInfoX &mseMeasInfo) { - if (!gAsymAnaInfo->HasTargetBit() || gAsymAnaInfo->HasAlphaBit()) return; + //if (!gAsymAnaInfo->HasTargetBit() || gAsymAnaInfo->HasAlphaBit()) return; + if (!gAsymAnaInfo->HasTargetBit() || gAsymAnaInfo->HasAlphaBit() || gAsymAnaInfo->HasPulserBit()) return; //zchang gNDelimeters = (rec.header.len - sizeof(rec.header)) / sizeof(pCTargetStruct); diff --git a/src/RunConfig.cxx b/src/RunConfig.cxx index 286fd119..17d4d014 100644 --- a/src/RunConfig.cxx +++ b/src/RunConfig.cxx @@ -47,11 +47,11 @@ RunConfig::RunConfig() : TObject(), fPolarimeters(), fTargets(), fMeasTypes(), fRings.insert(kBLUE_RING); fRings.insert(kYELLOW_RING); - fBeamEnergies.insert(kINJECTION); - fBeamEnergies.insert(kBEAM_ENERGY_100); - fBeamEnergies.insert(kBEAM_ENERGY_250); - fBeamEnergies.insert(kBEAM_ENERGY_255); - fBeamEnergies.insert(kBEAM_ENERGY_104); + //fBeamEnergies.insert(kINJECTION); + //fBeamEnergies.insert(kBEAM_ENERGY_100); + //fBeamEnergies.insert(kBEAM_ENERGY_250); + //fBeamEnergies.insert(kBEAM_ENERGY_255); + //fBeamEnergies.insert(kBEAM_ENERGY_104); fSpinStates.insert(kSPIN_DOWN); fSpinStates.insert(kSPIN_NULL); @@ -176,6 +176,10 @@ string RunConfig::AsString(EBeamEnergy beamEnergy) return "250"; case kBEAM_ENERGY_255: return "255"; + case kBEAM_ENERGY_254: + return "254"; + case kBEAM_ENERGY_253: + return "253"; default: return "UNK"; } diff --git a/src/SshLogReader.cxx b/src/SshLogReader.cxx index 664ad1d0..30bb341f 100644 --- a/src/SshLogReader.cxx +++ b/src/SshLogReader.cxx @@ -23,7 +23,7 @@ string SshLogReader::GetSshCommand(const string &logger, const string &args) } snprintf(buf, sizeof(buf), - "ssh yellowpc \"" + "ssh yellpc \"" "setenv PATH /usr/controls/bin; setenv LD_LIBRARY_PATH /ride/release/X86/lib;" "exportLoggerData" " -logger '%s'" @@ -279,3 +279,35 @@ void SshLogReader::get_fill_events(int fill_id, const string &ev_name, vectorpush_back(time); } } +/*zchang*/ +/* +void SshLogReader::query_timerange_mean(const std::string &logger, opencdev::cdev_time_t starttime, opencdev::cdev_time_t endtime, opencdev::mean_result_t *mean_result) +{ + opencdev::result_t result; + query_timerange(logger, starttime, endtime, &result); + calculate_mean(result, mean_result); +} + +void SshLogReader::calculate_mean(const opencdev::result_t &result, opencdev::mean_result_t *mean_result) const +{ + for (opencdev::result_t::const_iterator it = result.begin(); it != result.end(); it++) + { + const std::string &key = it->first; + const std::map &m = it->second; + double mean = NAN; + + if (m.size() != 0) + { + mean = std::accumulate(m.begin(), m.end(), 0.0f, opencdev::val_add) / m.size(); + } + + (*mean_result)[key] = mean; + } +} +*/ +/*template +V SshLogReader::val_add(V sum, const std::pair &p) +{ + return sum + p.second; +}*/ + diff --git a/src/asym.cxx b/src/asym.cxx index 5c495c73..e3014b69 100644 --- a/src/asym.cxx +++ b/src/asym.cxx @@ -17,7 +17,10 @@ #include "MseMeasInfo.h" #include "RawDataReader.h" #include "RunPeriod.h" +//#include "SpinTuneMotor.h" +#include "CachingLogReader.h" +#include "SshLogReader.h" using namespace std; @@ -44,10 +47,14 @@ int main(int argc, char *argv[]) // Book root file gAsymRoot->CreateRootFile(gAsymAnaInfo->GetRootFileName()); - + //gAsymRoot->Finalize(); return 1; MseMeasInfoX *mseMeasInfoX = 0; MseMeasInfoX *mseMeasInfoXOrig = 0; - + //spin tune motor zchang + //if(gAsymAnaInfo->HasSTMBit()){ + //gAsymRoot->fSpinTuneMotor = new SpinTuneMotor; + //} + // // Check whether the measurement is already in database if (gAsymAnaInfo->fFlagUseDb) { mseMeasInfoX = gAsymDb->SelectRun(gMeasInfo->GetRunName()); @@ -56,7 +63,9 @@ int main(int argc, char *argv[]) if (mseMeasInfoX) { // If measurement found in database get its copy for later update with SQL mseMeasInfoXOrig = new MseMeasInfoX(gMeasInfo->GetRunName()); *mseMeasInfoXOrig = *mseMeasInfoX; + Info("MeasInfo", "found in DB"); } else { // If measurement not found in database create a new object + Info("MeasInfo", "not found in DB"); mseMeasInfoX = new MseMeasInfoX(gMeasInfo->GetRunName()); } @@ -100,7 +109,8 @@ int main(int argc, char *argv[]) endTime = startTime + 600; } - opencdev::LocalLogReader log_reader(gAsymAnaInfo->GetSlowControlLogDir()); + //opencdev::LocalLogReader log_reader(gAsymAnaInfo->GetSlowControlLogDir()); + CachingLogReader log_reader; log_reader.query_timerange_mean("RHIC/Rf/Voltage_Monitor_StripChart", startTime, endTime, &mean_value); log_reader.query_timerange_mean("RHIC/PowerSupplies/rot-ps", startTime, endTime, &mean_value); log_reader.query_timerange_mean("RHIC/PowerSupplies/snake-ps", startTime, endTime, &mean_value); @@ -145,9 +155,13 @@ int main(int argc, char *argv[]) // set preliminary cuts. rawDataReader.ReadDataPassOne(*mseMeasInfoX); // Fill primary histograms - gAsymRoot->FillDerivedPassOne(); // Fill other histograms from the primary ones + //zchang check noise cut + //if(gAsymRoot->fChannelEvent->PassCutNoiseLower()) gAsymRoot->FillDerivedPassOne(); + gAsymRoot->FillDerivedPassOne(); + // Fill other histograms from the primary ones if (gAsymAnaInfo->HasNormalBit()) { + Info("calibrate", "normal bit"); gAsymRoot->Calibrate(); } gAsymRoot->PostFillPassOne(); // Make decisions based on hist content/data @@ -155,12 +169,14 @@ int main(int argc, char *argv[]) // PassTwo gAsymRoot->PreFill(); rawDataReader.ReadDataPassTwo(*mseMeasInfoX); - if (gAsymAnaInfo->HasAlphaBit() ) { + if (gAsymAnaInfo->HasAlphaBit()) { gAsymRoot->Calibrate(); } gAsymRoot->FillDerived(); gAsymRoot->PostFill(); + //gAsymRoot->AfterBurner(); + if (gAsymAnaInfo->HasNormalBit()) { // Add info to database entry @@ -204,7 +220,6 @@ int main(int argc, char *argv[]) if (gAsymAnaInfo->HasGraphBit()) gAsymRoot->SaveAs("^.*$", gAsymAnaInfo->GetImageDir()); - // Close ROOT file gAsymRoot->Finalize(); diff --git a/src/malpha.cxx b/src/malpha.cxx index ef15c3b7..48d6dc85 100644 --- a/src/malpha.cxx +++ b/src/malpha.cxx @@ -342,7 +342,7 @@ void PlotCorrelation(DrawObjContainer *oc, const char *name, ResultMean &r1, Res ObjMap &o = oc->o; TString hname(name); - TH2F *h = new TH2F(hname, hname, 1, r1.min_value, r1.max_value, 1, r2.min_value, r2.max_value); + TH2F *h = new TH2F(hname, hname, 1, r1.min_value-1, r1.max_value+1, 1, r2.min_value, r2.max_value); h->SetOption("DUMMY"); for (int det = 0; det < N_DETECTORS; det++) @@ -374,7 +374,7 @@ void PlotCorrelation(DrawObjContainer *oc, const char *name, ResultMean &r1, Res TString hdetname(name); hdetname += (det + 1); - TH2F *hdet = new TH2F(hdetname, hdetname, 1, r1.min_value, r1.max_value, 1, r2.min_value, r2.max_value); + TH2F *hdet = new TH2F(hdetname, hdetname, 1, r1.min_value-1, r1.max_value+1, 1, r2.min_value, r2.max_value); hdet->SetOption("DUMMY"); hdet->SetXTitle(r1.YTitle.c_str()); hdet->SetYTitle(r2.YTitle.c_str()); diff --git a/src/masym.cxx b/src/masym.cxx index ec62e717..bb7e75af 100644 --- a/src/masym.cxx +++ b/src/masym.cxx @@ -52,13 +52,15 @@ int main(int argc, char *argv[]) gRunConfig.fBeamEnergies.clear(); gRunConfig.fBeamEnergies.insert(kINJECTION); - gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_255); - gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_104); + gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_254); + //gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_255); + //gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_253); + //gRunConfig.fBeamEnergies.insert(kBEAM_ENERGY_104); std::string filelist = mAsymAnaInfo.GetMListFullPath(); MAsymRoot mAsymRoot(mAsymAnaInfo); mAsymRoot.SetAnaGlobResult(&anaGlobResult); - Int_t runID; + Int_t runID = -1; Info("masym", "Starting first pass..."); // Container with measurements passed QA cuts. Used to save time on opening @@ -81,10 +83,10 @@ int main(int argc, char *argv[]) ssMeasId >> nFillId; - if ( nFillId >= 17064 && nFillId <= 17084 ) { + /*if ( nFillId >= 17064 && nFillId <= 17084 ) { Error("masym", "Encountered vetoed fillId: %d. Skipping...", nFillId); continue; - } + }*/ std::unique_ptr f(new TFile(fileName.c_str(), "READ")); @@ -118,7 +120,7 @@ int main(int argc, char *argv[]) UShort_t targetId = gMM->fMeasInfo->GetTargetId(); ETargetOrient targetOrient = gMM->fMeasInfo->GetTargetOrient(); Info("masym", "MeasId: %4.3f, targetOrient %i, targetId %i", runId, targetOrient, targetId ); - if(runID == 13 ||runID == 15 || runID == 17 ){ // years with target last good run lists + if(runID == 13 ||runID == 15 || runID == 17 || runId == 22){ // years with target last good run lists Int_t target_ok = anaGlobResult.GetTargetStatus(runId, targetOrient, targetId); if(target_ok != 1) { Warning("masym","Measurement %9.3f had a broken target", runId); @@ -136,22 +138,24 @@ int main(int argc, char *argv[]) polarization = fitResPolarPhi->Value(0) * 100; polarizationErr = fitResPolarPhi->FitResult::Error(0) * 100; } - + Info("pol", "%lg", polarization); Float_t profileRatio = gMM->fAnaMeasResult->fProfilePolarR.first; Float_t profileRatioErr = gMM->fAnaMeasResult->fProfilePolarR.second; // the cut on polarization value should be removed //if (polarization > 99 || polarizationErr > 30 || - if (polarization < 10 || polarization > 99 || polarizationErr > 30 || + if (polarization < 10 || polarization > 99 || + //polarizationErr > 30 || // gRunConfig.fBeamEnergies.find(beamEnergy) == gRunConfig.fBeamEnergies.end() || // this line needs to be uncommented for Run13 gMM->fMeasInfo->fMeasType != kMEASTYPE_SWEEP || - (TMath::Abs(profileRatio) > 5.000) || // exclude very large values - (TMath::Abs(profileRatio) > 1.000 && profileRatioErr < 0.05) || // exclude large values with small errors - (TMath::Abs(profileRatio) > 1.000 && profileRatioErr > 0.50) || // exclude large values with large errors + //(TMath::Abs(profileRatio) > 5.000) || // exclude very large values + //(TMath::Abs(profileRatio) > 1.000 && profileRatioErr < 0.05) || // exclude large values with small errors + //(TMath::Abs(profileRatio) > 1.000 && profileRatioErr > 0.50) || // exclude large values with large errors //(profileRatioErr/TMath::Abs(profileRatio) > 2.000 && TMath::Abs(profileRatio) > 1.0) || - profileRatioErr < 0.01 || profileRatioErr > 10 || // exclude too small and too big errors. probably from failed fits? + //profileRatioErr < 0.01 || profileRatioErr > 10 || // exclude too small and too big errors. probably from failed fits? //(TMath::Abs(profileRatio) < 0.001 && profileRatioErr < 0.01) - ( fillId >= 17064 && fillId <= 17084 ) + //( fillId >= 17064 && fillId <= 17084 )//zchang run22 + 0 ) { Warning("masym", "Measurement %9.3f did not pass basic QA check", runId); @@ -160,8 +164,8 @@ int main(int argc, char *argv[]) RunConfig::AsString(gMM->fMeasInfo->fMeasType).c_str(), profileRatio, profileRatioErr ); - f->Close(); - continue; + //f->Close(); + //continue; } mAsymRoot.UpdMinMax(*gMM); @@ -191,7 +195,7 @@ int main(int argc, char *argv[]) gH->d["fills"] = new MAsymFillHists(new TDirectoryFile("fills", "fills", "", &mAsymRoot)); gH->d["rate"] = new MAsymRateHists(new TDirectoryFile("rate", "rate", "", &mAsymRoot)); gH->d["runs"] = new MAsymRunHists (new TDirectoryFile("runs", "runs", "", &mAsymRoot)); - gH->d["pmt"] = new MAsymPmtHists (new TDirectoryFile("pmt", "pmt", "", &mAsymRoot)); + //gH->d["pmt"] = new MAsymPmtHists (new TDirectoryFile("pmt", "pmt", "", &mAsymRoot)); gH->d["bias"] = new MAsymBiasHists(new TDirectoryFile("bias", "bias", "", &mAsymRoot)); // Adjust min/max fill for histogram limits @@ -202,7 +206,7 @@ int main(int argc, char *argv[]) // Process run/fill results, i.e. calculate fill average, ... Info("masym", "Analyzing measurements..."); Info("masym", "RunId %i", runID); - anaGlobResult.AddHJMeasResult(runID); + anaGlobResult.AddHJMeasResult(runID); //not for run22 yet zchang anaGlobResult.Process(gH); Info("masym", "Starting second pass..."); diff --git a/webview/fills/index.php b/webview/fills/index.php index 89b0413a..730c959f 100644 --- a/webview/fills/index.php +++ b/webview/fills/index.php @@ -11,7 +11,9 @@ if ( isset($_GET['fillid']) && isset($_GET['rp']) ) { $gFillId = $_GET['fillid']; + $gFillId = strip_tags($gFillId); $gAnaName = "run".sprintf("%02d", $_GET['rp']); + $gAnaName = strip_tags($gAnaName); $gAnaResDir = DATA_DIR."/$gAnaName/"; // Check for correct and existing fillid diff --git a/webview/head.html b/webview/head.html index 4b354b38..d257c9b1 100644 --- a/webview/head.html +++ b/webview/head.html @@ -1,29 +1,29 @@
-Contact CNIPol, -Grant Webb +Contact CNIPol +

-Home +Home       -pC Measurements +pC Measurements       -Fill Results +Fill Results       -Summary Plots +Summary Plots       -Target History +Target History       diff --git a/webview/index.php b/webview/index.php index 7735ca98..dfa17560 100644 --- a/webview/index.php +++ b/webview/index.php @@ -29,16 +29,16 @@ - - -
Summary Plots +Summary Plots A collection of plots to monitor the performance of the RHIC polarimeters for different time periods
Fill Results +Fill Results Polarization of RHIC beams for the experiments. Currently only Run11 fills are listed but we plan to update the database with Run 12 and even Run 9 results
pC Measurements +pC Measurements

Detailed information on every polarization measurement carried by the RHIC p-Carbon polarimeters diff --git a/webview/rundb/FillResult.php b/webview/rundb/FillResult.php index f30ee25d..ae26f3b3 100644 --- a/webview/rundb/FillResult.php +++ b/webview/rundb/FillResult.php @@ -114,6 +114,8 @@ function AddMeas($row) else $this->fPCPolarSlopes[$polId] = new pair($row['polar_slope'], $row['polar_slope_err']); + //printf("%d %f %f %f \n",$this->fFillId, $row['polar'], $row['polar_p0'], $row['polar_slope']); + //$this->fPCProfRs[$polId] = new pair($row['prof_r'], $row['prof_r_err']); //print "
{$this->fFillId}
$polId: ".print_r($this->fPCPolars[$polId]); //} diff --git a/webview/rundb/FillSelector.php b/webview/rundb/FillSelector.php index 9c96484d..392e0448 100644 --- a/webview/rundb/FillSelector.php +++ b/webview/rundb/FillSelector.php @@ -8,7 +8,7 @@ class FillSelector { var $urlQuery; var $sqlWhere; var $sqlOrderBy = ""; - var $defaultRun = 17; + var $defaultRun = 22; static $queryVarNames = array("rp", "fn", "ft", "be", "mode", "srtn", "srtd"); @@ -42,7 +42,7 @@ function FillSelector() if ( isset($_GET['rp']) && array_key_exists($_GET['rp'], $RUN_PERIOD)) { $rp = $_GET['rp']; $this->sqlWhere .= " AND fill_polar.fill > '{$RUN_PERIOD_BY_FILL[$rp]['start']}' AND fill_polar.fill < '{$RUN_PERIOD_BY_FILL[$rp]['end']}'"; - } else if ( isset($_GET['rp']) && empty($_GET['rp'])) { + }else if ( isset($_GET['rp']) && empty($_GET['rp'])) { } else { $rp = $this->defaultRun; @@ -51,10 +51,10 @@ function FillSelector() } if (!empty($_GET['fn'])) - $this->sqlWhere .= " AND fill_polar.fill LIKE '{$_GET['fn']}'"; + $this->sqlWhere .= " AND fill_polar.fill LIKE '{$_GET['fn']}'"; if (isset($_GET['ft']) && array_key_exists($_GET['ft'], $FILLTYPE)) { - $this->sqlWhere .= " AND type = {$_GET['ft']}"; + $this->sqlWhere .= " AND type = {$_GET['ft']}"; } else if ( isset($_GET['ft']) && empty($_GET['ft'])) { } @@ -62,7 +62,8 @@ function FillSelector() if (!empty($_GET['be'])) $this->sqlWhere .= " AND ROUND(beam_energy) = {$_GET['be']}"; - $this->sqlWhere .= " AND (fill_polar.stop_time = '0000-00-00 00:00:00' OR (fill_polar.stop_time - fill_polar.start_time) > 400)"; + if($rp < 22) + $this->sqlWhere .= " AND (fill_polar.stop_time = '0000-00-00 00:00:00' OR (fill_polar.stop_time - fill_polar.start_time) > 400)"; //$this->sqlWhere .= " AND beam_energy >= {$BEAM_ENERGY_INJ}"; } //}}} diff --git a/webview/rundb/RunSelector.php b/webview/rundb/RunSelector.php index bbff9ca3..5a14b700 100644 --- a/webview/rundb/RunSelector.php +++ b/webview/rundb/RunSelector.php @@ -5,7 +5,7 @@ class RunSelector var $urlQuery; var $sqlWhere; var $sqlOrderBy = ""; - var $defaultRun = 17; + var $defaultRun = 22; static $queryVarNames = array("rp", "rn", "pi", "mt", "be", "to", "ti", "himg", "srtn", "srtd"); diff --git a/webview/rundb/RunSelector_test.php b/webview/rundb/RunSelector_test.php new file mode 100644 index 00000000..1b2280ae --- /dev/null +++ b/webview/rundb/RunSelector_test.php @@ -0,0 +1,187 @@ + "run_name", + "pi" => "polarimeter_id", + "po" => "polarization", + "mt" => "measurement_type", + "be" => "beam_energy", + "te" => "nevents_total", + "pr" => "profile_ratio", + "at" => "ana_start_time", + "av" => "asym_version", + "tgt", + "ph" => "phase", +); + + function RunSelector() + { + global $RUN_PERIOD_BY_DATE, $RUN_PERIOD, $POLARIMETER_ID, $RHIC_STREAM, $MEASTYPE, $TARGET_ORIENT, $TARGET_ID; + + $url = parse_url($_SERVER['REQUEST_URI']); + + if (isset($url['query'])) + parse_str($url['query'], $urlQuery); + + // Copy only valid variables + $urlQueryNew = array(); + + foreach (self::$queryVarNames as $varName) + { + if (isset($urlQuery[$varName])) + $urlQueryNew[$varName] = $urlQuery[$varName]; + } + + $this->urlQuery = http_build_query($urlQueryNew); + + $this->sqlWhere = "TRUE"; + + if ( isset($_GET['rp']) && array_key_exists($_GET['rp'], $RUN_PERIOD)) { + $rp = $_GET['rp']; + $this->sqlWhere .= " AND start_time > '{$RUN_PERIOD_BY_DATE[$rp]['start']}' AND start_time < '{$RUN_PERIOD_BY_DATE[$rp]['end']}'"; + } else if ( isset($_GET['rp']) && empty($_GET['rp'])) { + } else { + $rp = $this->defaultRun; + $_GET['rp'] = $rp; + $this->sqlWhere .= " AND start_time > '{$RUN_PERIOD_BY_DATE[$rp]['start']}' AND start_time < '{$RUN_PERIOD_BY_DATE[$rp]['end']}'"; + } + + if (!empty($_GET['rn'])) + $this->sqlWhere .= " AND run_name LIKE '{$_GET['rn']}'"; + + if (isset($_GET['pi']) && array_key_exists($_GET['pi'], $POLARIMETER_ID)) + $this->sqlWhere .= " AND polarimeter_id = {$_GET['pi']}"; + + if (isset($_GET['mt']) && array_key_exists($_GET['mt'], $MEASTYPE)) + $this->sqlWhere .= " AND measurement_type = {$_GET['mt']}"; + + if (!empty($_GET['be'])) + $this->sqlWhere .= " AND ROUND(beam_energy) = {$_GET['be']}"; + + if (isset($_GET['to']) && array_key_exists($_GET['to'], $TARGET_ORIENT)) + $this->sqlWhere .= " AND target_orient LIKE '{$_GET['to']}'"; + + if (isset($_GET['ti']) && array_key_exists($_GET['ti'], $TARGET_ID)) + $this->sqlWhere .= " AND target_id = {$_GET['ti']}"; + + + if (isset($_GET['srtn']) && array_key_exists($_GET['srtn'], self::$shortSortNames)) + { + $this->sqlOrderBy = " ".self::$shortSortNames[$_GET['srtn']]." "; + $this->sqlOrderBy .= ( isset($_GET['srtd']) && is_numeric($_GET['srtd']) && $_GET['srtd'] < 0 ) ? "DESC" : "ASC"; + $this->sqlOrderBy .= ", "; + } + } + + + function HtmlSortLinks($key=null) + { + // first check for a page variable in the query + $url = parse_url($_SERVER['REQUEST_URI']); + + $tmpQuery = null; + + if (isset($url['query'])) + parse_str($url['query'], $tmpQuery); + + $page = (isset($tmpQuery['page']) && is_numeric($tmpQuery['page'])) ? "page={$tmpQuery['page']}&" : "" ; + + // then remove unwanted sorting variables + parse_str($this->urlQuery, $urlVars); + + unset($urlVars['srtn']); + unset($urlVars['srtd']); + + $this->urlQuery = http_build_query($urlVars); + + $html = "urlQuery}&srtn=$key&srtd=-1\">▼ ". + "urlQuery}&srtn=$key&srtd=+1\">▲"; + + return $html; + } + + + function PrintForm() + { + global $RUN_PERIOD, $POLARIMETER_ID, $RHIC_STREAM, $MEASTYPE, + $BEAM_ENERGY, $TARGET_ORIENT, $TARGET_ID, $PLOT_IMAGES; + + // Create a table with the necessary header informations + echo "

\n"; + echo '
+ '; + + echo " + + + "; + echo " + +
Run period:\n"; + + $this->HtmlSelectField($RUN_PERIOD, "rp", $this->defaultRun); + + $runName = isset($_GET['rn']) ? $_GET['rn'] : ""; + + echo "
Run: + +     + Use \"%\" to match any number of characters, use \"_\" to match any single character in run id\n"; + + echo "
Graph:\n"; + + $this->HtmlSelectField($PLOT_IMAGES, "himg"); + + echo "
Polarimeter:\n"; + + $this->HtmlSelectField($POLARIMETER_ID, "pi"); + + echo " Type:\n"; + + $this->HtmlSelectField($MEASTYPE, "mt"); + + echo " Beam energy:\n"; + + $this->HtmlSelectField($BEAM_ENERGY, "be"); + + echo " Target:\n"; + + $this->HtmlSelectField($TARGET_ORIENT, "to"); + $this->HtmlSelectField($TARGET_ID, "ti"); + + echo "
+

+

+
+
\n"; + } + + + function HtmlSelectField($options, $v="", $default=null) + { + $html = "\n"; + + print $html; + } +} diff --git a/webview/rundb/SqlDbReader_test.php b/webview/rundb/SqlDbReader_test.php new file mode 100644 index 00000000..6abb8e79 --- /dev/null +++ b/webview/rundb/SqlDbReader_test.php @@ -0,0 +1,102 @@ +runSelector = $runSelector; + $this->urlQuery = $runSelector->urlQuery; + $this->sqlWhere = $runSelector->sqlWhere; + $this->sqlOrderBy = $runSelector->sqlOrderBy; + } + } + + /** */ + function SetSqlWhere($where="") + { + $this->sqlWhere = $where; + } + + /** */ + function CreateSqlWhere($runSelector=0) + { + if (!$runSelector) return; + } + + /** */ + function CountEntries() + { + $this->sqlQuery = "SELECT COUNT(run_name) FROM `run_info` WHERE {$this->sqlWhere}"; + + $result = mysql_query($this->sqlQuery); + $nrows = mysql_fetch_array($result); + $this->nResults = $nrows[0]; + return $this->nResults; + } + + /** */ + function ReadEntries($start=0, $limit=100) + { + $this->sqlQuery = "SELECT *\n" + . "FROM `run_info` WHERE {$this->sqlWhere}\n" + . "ORDER BY {$this->sqlOrderBy} `run_info`.`start_time` DESC\n" + . "LIMIT $start, $limit\n"; + + $this->result = mysql_query($this->sqlQuery); + return $this->result; + } + + + /** */ + function SortByTime() { + } + + + /** + * Create page links + */ + function HtmlPageIndex($nPages=1, $curPage=1) + { + $this->CountEntries(); + + $html = "
\n"; + + for ($i=1; $i<=$nPages; $i++) { + if ($i == $curPage) + $html .= "$i "; + else + $html .= "urlQuery}\">$i "; + } + + $html .= "
\n"; + + return $html; + } + + + /** */ + function PrintPageIndex($nPages=1, $curPage=1) + { + print $this->HtmlPageIndex($nPages, $curPage); + } +} + +?> diff --git a/webview/rundb/TargetSelector.php b/webview/rundb/TargetSelector.php index 29b733df..8f776859 100644 --- a/webview/rundb/TargetSelector.php +++ b/webview/rundb/TargetSelector.php @@ -8,7 +8,7 @@ class TargetSelector { var $urlQuery; var $sqlWhere; var $sqlOrderBy = ""; - var $defaultRun = 17; + var $defaultRun = 22; static $queryVarNames = array("rp", "rn", "pi", "mt", "be", "to", "ti", "srtn", "srtd"); diff --git a/webview/rundb/bottom.html b/webview/rundb/bottom.html index e8e016a5..995b7feb 100644 --- a/webview/rundb/bottom.html +++ b/webview/rundb/bottom.html @@ -1,9 +1,6 @@ -

 
+


-
- -
-Developed and maintained by Dmitri Smirnov -(RHIC Spin Group) +
+Developed by Dmitri Smirnov and maintained by RHIC Spin Group
diff --git a/webview/rundb/config.php b/webview/rundb/config.php index 227ab0ed..74ffae67 100644 --- a/webview/rundb/config.php +++ b/webview/rundb/config.php @@ -3,9 +3,9 @@ include_once("Pair.php"); -define("DATA_DIR", "/home/cnipol/root"); -define("LOG_DIR", "/home/cnipol/log"); -define("VIDEO_DIR", "/home/cnipol/video"); +define("DATA_DIR", "/gpfs/mnt/gpfs02/eic/eichome/cnipol/root"); +//define("LOG_DIR", "/home/cnipol/log"); +//define("VIDEO_DIR", "/home/cnipol/video"); // Approximate fill numbers $RUN_PERIOD_BY_FILL = array ( @@ -14,7 +14,8 @@ 12 => array( "start" => 16000, "end" => 16800 ), 13 => array( "start" => 17000, "end" => 18000 ), 15 => array( "start" => 18000, "end" => 20000 ), - 17 => array( "start" => 20000, "end" => 22000) + 17 => array( "start" => 20000, "end" => 22000), + 22 => array( "start" => 32000, "end" => 34000), ); // Approximate dates @@ -24,10 +25,11 @@ 12 => array( "start" => "2011-11-01 00:00:00", "end" => "2012-06-01 00:00:00" ), 13 => array( "start" => "2013-01-01 00:00:00", "end" => "2013-08-01 00:00:00" ), 15 => array( "start" => "2015-01-01 00:00:00", "end" => "2015-08-01 00:00:00" ), - 17 => array( "start" => "2017-01-01 00:00:00", "end" => "2017-08-01 00:00:00" ) + 17 => array( "start" => "2017-01-01 00:00:00", "end" => "2017-08-01 00:00:00" ), + 22 => array( "start" => "2021-11-01 00:00:00", "end" => "2022-05-01 00:00:00" ), ); -$RUN_PERIOD = array(9 => "Run 9", 11 => "Run 11", 12 => "Run 12", 13 => "Run 13", 15 => "Run 15", 17 => "Run 17"); +$RUN_PERIOD = array(9 => "Run 9", 11 => "Run 11", 12 => "Run 12", 13 => "Run 13", 15 => "Run 15", 17 => "Run 17", 22 => "Run 22"); $POLARIMETER_ID = array(0 => "B1U", 1 => "Y1D", 2 => "B2D", 3 => "Y2U"); $HJ_POLARIMETER_ID = 10; $AGS_POLARIMETER_ID = 11; @@ -37,6 +39,7 @@ $FILLTYPE = array(0x00 => "undef", 0x01 => "phys"); $BEAM_ENERGY = array("24" => "24", "100" => "100", "104" => "104","250" => "250", "255" => "255"); $BEAM_ENERGY_INJ = 24; +$BEAM_ENERGY_254 = 254; $TARGET_ORIENT = array("H" => "H", "V" => "V"); //$TARGET_ORIENT_ID = array(0 => "H", "V" => "V"); $TARGET_ID = array_combine(range(1, 6), range(1, 6)); @@ -185,6 +188,41 @@ $normHJPC[17][255]['Y2U']['H'][2] = new pair( 1.03245, 0.01997 ); $normHJPC[17][255]['Y2U']['H'][4] = new pair( 0.94707, 0.02233 ); $normHJPC[17][255]['Y2U']['V'][1] = new pair( 1.02009, 0.00902 ); +//run-22 set to 1 +$normHJPC[22][24]['B1U']['nomi'] = new pair( 1.0, -1.0); +$normHJPC[22][24]['Y1D']['nomi'] = new pair( 1.0, -1.0); +$normHJPC[22][24]['B2D']['nomi'] = new pair( 1.0, -1.0); +$normHJPC[22][24]['Y2U']['nomi'] = new pair( 1.0, -1.0); +$normHJPC[22][255]['B1U']['nomi'] = new pair( 0.93, 0.04); +$normHJPC[22][255]['Y1D']['nomi'] = new pair( 0.94, 0.03); +$normHJPC[22][255]['B2D']['nomi'] = new pair( 0.96, 0.04); +$normHJPC[22][255]['Y2U']['nomi'] = new pair( 1.00, 0.03); +$normHJPC[22][255]['B1U']['H'][2] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['H'][4] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['H'][6] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['V'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['V'][3] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['V'][4] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['V'][5] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B1U']['V'][6] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['H'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['H'][2] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['H'][3] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['H'][5] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][2] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][3] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][4] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][5] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y1D']['V'][6] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B2D']['H'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B2D']['H'][2] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B2D']['H'][4] = new pair( 1.0, -1 ); +$normHJPC[22][255]['B2D']['V'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y2U']['H'][1] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y2U']['H'][2] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y2U']['H'][4] = new pair( 1.0, -1 ); +$normHJPC[22][255]['Y2U']['V'][1] = new pair( 1.0, -1 ); // sigma = fill-to-fill uncorrelated errors // delta = fill-to-fill correlated errors diff --git a/webview/rundb/index.php b/webview/rundb/index.php index 193a70c5..623c5bc4 100644 --- a/webview/rundb/index.php +++ b/webview/rundb/index.php @@ -20,6 +20,7 @@ if (isset($_GET['runid']) && !isset($_GET['chanid'])) { $gRunId = $_GET['runid']; + $gRunId = strip_tags($gRunId); $gRunDir = DATA_DIR."/$gRunId"; // Check for correct and existing runid @@ -74,8 +75,12 @@ } else if ( isset($_GET['ach']) && !empty($_GET['ach']) ) // all channel histogram { include("runinfo_ach.html"); - } else + } else{ + if( $rc['fRunId'] == 22) { + include("runinfo_r22.html"); + }else include("runinfo.html"); + } } elseif ($rc['measurement_type'] == 1) { include("runinfo_calib.html"); @@ -85,8 +90,12 @@ //include("runinfo.html"); if ( isset($_GET['raw']) ) { include("runinfo_raw.html"); - } else - include("runinfo.html"); + } else { + if( $rc['fRunId'] == 22) { + include("runinfo_r22.html"); + }else + include("runinfo.html"); + } } exit; @@ -97,7 +106,9 @@ if (isset($_GET['runid']) && isset($_GET['chanid'])) { $gRunId = $_GET['runid']; + $gRunId = strip_tags($gRunId); $gChanId = $_GET['chanid']; + $gChanId = strip_tags($gChanId); $gRunDir = DATA_DIR."/$gRunId"; // Check for correct and existing runid @@ -148,6 +159,5 @@ // exit; //} -include("runinfo_index.html"); - +include("runinfo_index_test.html"); ?> diff --git a/webview/rundb/main.css.php b/webview/rundb/main.css.php deleted file mode 120000 index 78b7695f..00000000 --- a/webview/rundb/main.css.php +++ /dev/null @@ -1 +0,0 @@ -../main.css \ No newline at end of file diff --git a/webview/rundb/main.css.php b/webview/rundb/main.css.php new file mode 100644 index 00000000..b6a6d0a0 --- /dev/null +++ b/webview/rundb/main.css.php @@ -0,0 +1,369 @@ +span.red { + color: red; +} + +.orange { + color: orange; +} + +.bold { + font-weight: bold; +} + +.notbold { + font-weight: normal; +} + +.blue { + color: blue; +} + +.red { + color: red; +} + +.green { + color: green; +} + +.yellow3 { + color: #bbbb00; +} + +.blue3 { + color: #0000bb; +} + +.center { + text-align: center; +} + +.left { + text-align: left; +} + +.align_l { + text-align: left !important; +} + +.align_r { + text-align: right; +} + +.align_lb { + text-align: left; + vertical-align: bottom; +} + +.align_cm { + text-align: center !important; + vertical-align: middle !important; +} + +.align_ct { + text-align: center; + vertical-align: top; +} + +.left { + text-align: left; +} + +.strike { + text-decoration: line-through; +} + +.feature { + background-color: pink !important; +} + +span.feature { + background-color: pink; +} + +.nowrap { + white-space: nowrap; +} + +.bluPol { + background-color: #8bf !important; + padding: 0.2em; +} + +.yelPol { + background-color: #eea !important; + padding: 0.2em; +} + +.agsPol { + background-color: #f88 !important; + padding: 0.2em; +} + +.bkgGreen { + background-color: #0f0 !important; + padding: 0.2em; +} + +.bkgRed { + background-color: #f00 !important; + padding: 0.2em; +} + +.frgGreen { + color: #0f0 !important; +} + +.frgRed { + color: #f00 !important; +} + +.bkg1 { + background-color: #0000ff; +} + +.s50 {font-size: 50%;} +.s80 {font-size: 80%;} +.s120 {font-size: 120%;} +.s150 {font-size: 150%;} +.s200 {font-size: 200%;} + +.my-th { + font-weight: bold; + font-size: 150%; +} + +.my-h2 { + font-weight: bold; + font-size: 150%; +} + +dt.feature { + font-weight: bold; + margin-top: 2em; +} + +.boldred { + font-weight: bold; + color: red; +} + +.notbold { + font-weight: normal; +} + +BODY { + counter-reset: counterH1 counterFig counterTable; /* Create a chapter counter scope */ + margin: 1ex 3%; +} + +H1.count:before { + content: counter(counterH1) " "; + counter-increment: counterH1; /* Add 1 to chapter */ +} + +H1.count:after { + content: ""; +} + +H1.count { + counter-reset: counterH2; /* Set section to 0 */ + background-color: #ddddff; +} + +H2.count:before { + content: counter(counterH1) "." counter(counterH2) " "; + counter-increment: counterH2; +} + +H2.count { + counter-reset: counterH3; /* Set section to 0 */ + background-color: #dfdfff; +} + +H3.count:before { + content: counter(counterH1) "." counter(counterH2) "." counter(counterH3) " "; + counter-increment: counterH3; +} + +H3.count { + counter-reset: counterH4; /* Set section to 0 */ + background-color: #ededff; +} + +H4.count:before { + content: counter(counterH1) "." counter(counterH2) "." counter(counterH3) "." counter(counterH4) " "; + counter-increment: counterH4; +} + +H4.count { + counter-reset: counterH5; /* Set section to 0 */ + background-color: #efefff; +} + +H5.count:before { + content: counter(counterH1) "." counter(counterH2) "." counter(counterH3) "." counter(counterH4) "." counter(counterH5) " "; + counter-increment: counterH5; +} + +H5.count { + background-color: #efefff; +} + +OL.count { counter-reset: item } +LI.count { display: block } +LI.count:before { content: counters(item, ".") " "; counter-increment: item } + + +.figcount:before { + content: "Figure " counter(counterFig) ": "; + counter-increment: counterFig; + font-weight: bold; +} + +.figure { + display: inline; +} + +div.tablecount:before { + content: "Table " counter(counterTable) ": "; + counter-increment: counterTable; + font-weight: bold; +} + +.hidden { display: none; } +.unhidden { display: block; } + +div.divcenter { + width: 50%; + margin: 0px auto; +} + +div.section { + display: block; +} + +.padding0 td { + padding: 0em !important; +} + +.padding1 { + padding: 0.2em; +} + +.padding2 { + padding: 0.5em; +} + +table.generic { + border-collapse:collapse; +} + +table.generic th { + vertical-align:text-top; + text-align: left; + border: 1px solid black; + padding: 0.5em; +} + +table.generic td { + vertical-align:text-top; + border: 1px solid black; + padding: 0.5em; +} + +table.generic_dl_0 { + border-collapse:collapse; + border-style: none; +} + +table.generic_dl_0 th { + vertical-align:text-top; + text-align: left; + border-style: none; + padding: 0.5em; +} + +table.generic_dl_0 td { + vertical-align:text-top; + border-style: none; + padding: 0.5em; +} + + +table.simple0 td, th { + margin-left: auto; + margin-right: auto; + padding: 0; + border: 1px solid black; + border-collapse:collapse; +} + +table.simple00 { + margin-left: auto; + margin-right: auto; + padding: 0; + border: 0px none white; + table-layout: auto; + width: 1%; +} + +table.simple00 td, th { + text-align: center; + vertical-align: top; +} + +table.w80 { + width: 80% !important; +} + +table.w100 { + width: 100% !important; +} + + +table.simple { + margin-left: auto; + margin-right: auto; + padding: 0.3em; + border-spacing: 0px; + background-color: #ffffff; +} + +table.simple td, th { + border: 1px solid #aaa; + padding: 0.3em; + background-color: #fff; +} + +tr.toprow2 td { + width: 50%; +} + +tr.toprow3 td { + width: 33%; +} + +tr.toprow4 td { + width: 25%; +} + +tr.toprow5 td { + width: 20%; +} + +tr.toprow6 td { + width: 20%; +} + +tr.my_tr_highlight:hover td { + background-color: #E9E9E9; color: #000; +} + +tr.my_tr_highlight:hover .bluPol { + background-color: #6f9fdf !important; +} + +tr.my_tr_highlight:hover .yelPol { + background-color: #cfcf8f !important; +} diff --git a/webview/rundb/runinfo.html b/webview/rundb/runinfo.html index 9974394b..7ab31780 100644 --- a/webview/rundb/runinfo.html +++ b/webview/rundb/runinfo.html @@ -127,6 +127,21 @@

Summary

$asymVersion = "$asymVersion"; ?> + + + +

diff --git a/webview/rundb/runinfo_index_test.html b/webview/rundb/runinfo_index_test.html new file mode 100644 index 00000000..d68fc2f1 --- /dev/null +++ b/webview/rundb/runinfo_index_test.html @@ -0,0 +1,341 @@ + + + + + + + RHIC Polarimetry Results: p-Carbon Measurement Database + + + + + + + + + + + + + +

+ +

p-Carbon Measurements

+ +PrintForm(); + +$sqlDbReader = new SqlDbReader($runSelector); +$nRuns = $sqlDbReader->CountEntries(); + +?> + + + +

+Runs selected: nResults?> + +

+Export to CSV file: download + + $nPages || $page < 1) $page = 1; + +$sqlDbReader->PrintPageIndex($nPages, $page); + +$rslt = $sqlDbReader->ReadEntries(($page-1)*$nRunsPerPage, $nRunsPerPage); + +// Read file with online polarization values and return an array +//$onlinePolars = readOnlinePolar(LOG_DIR."/online_polar.dat"); + +//print "

\n";
+//print_r($row); 
+//print "
\n"; + +// Arrays for average values + +$polarizations = array(); +$phases = array(); +$profileRatios = array(); + + +?> + +

+

+ + + + + + +
Run + Date & Time + Polarimeter
HtmlSortLinks("pi");?> +
Polarization, %
HtmlSortLinks("po");?> +
Phase, degree
HtmlSortLinks("ph");?> + +
Prof. Ratio R + Type + Beam Energy, GeV + Target + Bunches
−/0/+ +
Total Events
HtmlSortLinks("te");?> + +
Offline analysis +
R + V + Ver
HtmlSortLinks("av");?> +
Date & Time
HtmlSortLinks("at");?> + + +PrintThis(); + + //print "
\n";
+   //print_r($e); 
+   //print "
\n"; + + $polId = $POLARIMETER_ID[$e['polarimeter_id']]; + $start_time = isset($e['start_time']) ? strtotime($e['start_time']) : 0; + $runPeriod = getRunPeriod($start_time); + + // return to normal flow + //$strOnlinePolar = " "; + //if (isset($onlinePolars[$e['run_name']])) { + // $onlinePolar = $onlinePolars[$e['run_name']]; + // $strOnlinePolar = " ".polarPairToString($onlinePolar).""; + // //$strOnlinePolar .= " p1"; + //} + + $measurementType = " "; + + if (isset($e['measurement_type']) && $e['measurement_type'] >= 0 ) { + //$values = preg_split("/[\s,]+/", $e['profile_ratio']); + //$profileRatio = sprintf("%5.2f ± %5.2f", $values[0], $values[1]); + $measurementType = $MEASTYPE[$e['measurement_type']]; + } + + $polarization = "—"; + $phase = "—"; + $profileRatio = "—"; + $beamEnergy = "—"; + $targetId = "—"; + $trTooltip = "Measurement {$e['run_name']}"; + $udCounts = array('-' => "—", '0' => "—", '+' => "—"); + + $measConfigFile = DATA_DIR."/{$e['run_name']}/runconfig.php"; + $runconfig_present = file_exists($measConfigFile); + + if ($measurementType != "undef" && $measurementType != "alpha") + { + // Apply normalization factor to polarization value + $norm2 = getHJPCNorm($runPeriod, intval($e['beam_energy']+0.5), $polId, $e['target_orient'], $e['target_id']); + $norm = $norm2->val; + + if ( isset($e['polarization']) ) { + $polarization = sprintf("%5.1f ± %5.1f", $e['polarization']*100*$norm, $e['polarization_error']*100*$norm); + $polarizations[] = new pair($e['polarization']*100*$norm, $e['polarization_error']*100*$norm); + } + //phase: angle in transverse plane + if ( isset($e['phase']) ) { + $phase = sprintf("%5.1f ± %5.1f", $e['phase']*180/3.14, $e['phase_error']*180/3.14); + $phases[] = new pair($e['phase']*180/3.14, $e['phase_error']*180/3.14); + } + + if ( isset($e['profile_ratio']) ) { + $profileRatio = sprintf("%5.2f ± %5.2f", $e['profile_ratio'], $e['profile_ratio_error']); + $profileRatios[] = new pair($e['profile_ratio'], $e['profile_ratio_error']); + } + + $beamEnergy = isset($e['beam_energy']) ? sprintf("%6.2f", $e['beam_energy']) : $beamEnergy; + + $targetId = ( isset($e['target_id']) && $e['target_id'] > 0 ) ? + "{$e['target_orient']}{$e['target_id']}" : $targetId; + + + // Get info from the file + if ( $runconfig_present ) + { + include($measConfigFile); + $trTooltip .= " "; + + $rce = $rc['fMachineParams']['fCavity197MHzVoltage'][0]; + $trTooltip .= isset($rce) ? "| 197Mhz V: $rce " : ""; + + $rce = $rc['fMachineParams']['fStarRotatorCurrents'][0]; + $trTooltip .= isset($rce) ? "| Rotator: ".sprintf("%.0f", $rce)." " : ""; + //$trTooltip .= isset($rce) && $rce>10 ? " Rotator: ON" : ""; + + $rce = $rc['fTargetParams']['fVelocity']; + $trTooltip .= isset($rce) ? "| Target speed: $rce " : ""; + + // Look at bunch counts + $measResult = new MeasResult(); + + $udCounts = $measResult->GetBunchUpDownCounts($rc['fBeamBunches']); + + unset($rc); + } + } + + // Set css class + $cssPol = ""; + + if ($polId[0] == 'B') $cssPol = "bluPol"; + if ($polId[0] == 'Y') $cssPol = "yelPol"; + + if ($polId[2] == 'U') $cssPol .= " bold"; + #if ($polId[2] == 'D') $cssPol .= ""; + + // Offline processed fraction + $processedFrac = "—"; + + if ( isset($e['nevents_total']) && isset($e['nevents_processed']) && $e['nevents_total'] != 0 ) + { + $processedFrac = $e['nevents_processed'] == $e['nevents_total'] ? "ф" : sprintf("%4.2f", $e['nevents_processed']/$e['nevents_total']); + + $processedFrac = "$processedFrac"; + } + + // video file + $videoFile = VIDEO_DIR."/{$e['run_name']}.avi"; + + if ( file_exists($videoFile) ) + $videoFile = "β"; + else + $videoFile = "—"; + + + // Deal with version now + $asymVersion = isset($e['asym_version']) ? $e['asym_version'] : "v0.0.0;"; + list($human_version, $git_hash) = explode(";", $asymVersion); + $asymVersion = ""; + if ($git_hash) + $asymVersion = ''; + $asymVersion .= $human_version; + if ($git_hash) + $asymVersion .= ''; + + // Set default directory for run images + $dir = "../runs/{$e['run_name']}/images$gSuffix/"; + $gP = new PlotHelper($dir); +?> + +
'; +echo $e['run_name']; +if ($runconfig_present) echo ''; +?> + + + + + + + + + + + + + + + + + + +
+ img($_GET['himg'], false, 1200)?> + + + + + +
 
  + +
Mean + +   +   + ToString("", "%5.2f") : " ")?> + ToString("", "%5.2f") : " ")?> + ToString("", "%5.2f") : " ")?> +   +   +   +   +   +   +   +   +   + +
+ +PrintPageIndex($nPages, $page); +?> + +

Normalization for p-Carbon Measurements

+ +For details on calculation of normalization factors go to https://wiki.bnl.gov/rhicspin/PCarbon_normalization. +Normalization kjet/crb applied to p-Carbon polarization for selected run period is: + + + + + + + + + + + + diff --git a/webview/rundb/runinfo_r22.html b/webview/rundb/runinfo_r22.html new file mode 100644 index 00000000..2dcb335d --- /dev/null +++ b/webview/rundb/runinfo_r22.html @@ -0,0 +1,959 @@ + + + + + + + p-Carbon Measurement <?=$gRunId?>: Analysis Results + + + + + + + + + + + + + + + +

pC Measurement

+ +
+ +
+ +
+ + + +

Summary

+ +
+ +default "; + +foreach ($rc['suffixes'] as $suffix) +{ + if (empty($suffix)) continue; + + if ($gSfx == $suffix) + $suffixes .= "$suffix "; + else + $suffixes .= "$suffix "; +} + +// Assign the variables +$polId = $POLARIMETER_ID[$rc['polarimeter_id']]; +$runPeriod = getRunPeriod($rc['start_time']); + +$cssPol = ""; + +if ($polId[0] == 'B') $cssPol = "bluPol"; +if ($polId[0] == 'Y') $cssPol = "yelPol"; + +if ($polId[2] == 'U') $cssPol .= " bold"; +#if ($polId[2] == 'D') $cssPol .= ""; + +$strPolId = "$polId"; + +if ( isset($rc['A_N'][1]) && $rc['A_N'][1] == 0) $rc['A_N'][1] = 1e-10; + +$anpower = $rc['A_N'][1]; + +$polarization = " "; + +$norm = getHJPCNorm($runPeriod, intval($rc['beam_energy']+0.5), $polId, $rc['target_orient'], $rc['target_id']); +$normVal = $norm->val; + +if (isset($rc['polarization'])) { + $polarization = sprintf("%5.1f ± %5.1f %%", + $rc['polarization']*100*$normVal, $rc['polarization_error']*100*$normVal); +} + +$polarization_X90 = isset($rc['fAsymX90']['phys']) && $rc['A_N'][1] > 1e-10 ? + sprintf("%5.1f ± %5.1f %%", $rc['fAsymX90']['phys'][0]*100*$normVal/$rc['A_N'][1], + $rc['fAsymX90']['phys'][1]*100*$normVal/$rc['A_N'][1]) : "—"; + +$polarization_X45 = isset($rc['fAsymX45']['phys']) && $rc['A_N'][1] > 1e-10 ? + sprintf("%5.1f ± %5.1f %%", $rc['fAsymX45']['phys'][0]*100*$normVal*M_SQRT2/$rc['A_N'][1], + $rc['fAsymX45']['phys'][1]*100*$normVal*M_SQRT2/$rc['A_N'][1]) : "—"; + +$polarization_X45T = isset($rc['fAsymX45T']['phys']) && $rc['A_N'][1] > 1e-10 ? + sprintf("%5.1f ± %5.1f %%", $rc['fAsymX45T']['phys'][0]*100*$normVal*M_SQRT2/$rc['A_N'][1], + $rc['fAsymX45T']['phys'][1]*100*$normVal*M_SQRT2/$rc['A_N'][1]) : "—"; + +$polarization_X45B = isset($rc['fAsymX45B']['phys']) && $rc['A_N'][1] > 1e-10 ? + sprintf("%5.1f ± %5.1f %%", $rc['fAsymX45B']['phys'][0]*100*$normVal*M_SQRT2/$rc['A_N'][1], + $rc['fAsymX45B']['phys'][1]*100*$normVal*M_SQRT2/$rc['A_N'][1]) : "—"; + +$polarization_Y45 = isset($rc['fAsymY45']['phys']) && $rc['A_N'][1] > 1e-10 ? + sprintf("%5.1f ± %5.1f %%", $rc['fAsymY45']['phys'][0]*100*$normVal*M_SQRT2/$rc['A_N'][1], + $rc['fAsymY45']['phys'][1]*100*$normVal*M_SQRT2/$rc['A_N'][1]) : "—"; + +$targetId = "—"; + +if (isset($rc['target_orient']) && isset($rc['target_id']) && $rc['target_id'] > 0) { + $targetId = "{$rc['target_orient']}{$rc['target_id']}"; +} + +$measurementType = "—"; + +if (isset($rc['measurement_type']) && $rc['measurement_type'] >= 0 ) { + $measurementType = $MEASTYPE[$rc['measurement_type']]; +} + +$profileRatio = sprintf("%5.2f ± %5.2f", $rc['profile_ratio'], $rc['profile_ratio_error']); + +// Deal with version now +$asymVersion = isset($rc['asym_version']) ? $rc['asym_version'] : "v0.0.0"; +$asymVersion = "$asymVersion"; +?> + + + + + +

+ + + + + + + + + $row1\n"; + $iCell++; + } +?> + + + +
+ Polarimeter: + + Polarization: + + Beam Energy:  GeV + + Target: + +
+ + + +
X90 + X45 + X45T + X45B + Y45 +
+ + + + +
+ +
+ Run Period: + + H-Jet norm (A_N Scale): err > 0 ? $norm->ToString("", "%5.3f") : sprintf("%5.3f", $norm->val);?> + + Analyzing power: +   + +
+ Run Start Time: + + Total Events: + + Profile Ratio: r = + + Run Type: + + +
+ + Processed Offline:   + ( s) + + Events Processed: + 1): ?>(every event) + + + Energy Calibration Run: + + Asym Version: + +
+ Channels: Total excluded channels: +
+ + + $chanId"; + + if ($chanId % 36 == 0) { + print "$row1\n"; + $row1 = ""; + } + } + ?> +
+ +GetBunchUpDownCounts($rc['fBeamBunches']); + + //$row1 = ""; + $row2 = ""; + $row3 = ""; + $iCell = 0; + $bkgCellColor = "#fff"; + + foreach ($rc['fBeamBunches'] as $bunchId => $bunch) + { + if ($iCell % 8 == 0) { + if ($bkgCellColor == "#fff") $bkgCellColor = "#ddd"; + else if ($bkgCellColor == "#ddd") $bkgCellColor = "#fff"; + } + + if ($bunch['fBunchSpin'] == -1) $bunchSpin = "−"; + else if ($bunch['fBunchSpin'] == +1) $bunchSpin = "+"; + else $bunchSpin = "0"; + //$bunchSpin = ($bunch['fBunchSpin'] == -1 ? "−" : "+"); + + //$row1 .= "
$bunchId"; + $row2 .= "{$bunch['fIsFilled']}"; + $row3 .= "$bunchSpin"; + + //print "
+ + + + + + + +
+ Bunch fill pattern: +
+ Bunch spin pattern: Total −/0/+: +
+ +
+   + +
+
Analysis tags (for experts):
+ +
+ +

+ + + + + + + + + + + + + +

Raw Data

+ +
+ +

+&raw>All channels at once + +

+ + + + + +
+img('run/wall_current_monitor')?> +
+Number of protons per bunch as reported by the wall current monitor (WCM) +
+ +
+img('raw/hBunchCounts')?> +
+Number of events per bunch +
+ +
+img('raw/hStripCounts')?> +
+Number of events per detector channel +
+ +
+img('raw/hWfdCounts')?> +
+Number of events per WFD +
+ + +
+img('raw/hAdcAmpltd')?> +

Distribution of the maximum signal amplitude (all channels combined) + +

+img('raw/hTdc')?> +

Distribution of the signal time (all channels combined) + + + +

+img('raw/hTvsA')?> +

TDC vs Amplitude (all channels combined) +
+By channel + +

+img('raw_eb/hTvsA')?> +

TDC vs Amplitude: empty bunches only (all channels combined) +
+By channel + + + +

+img('raw/hRevolutionId')?> +

Number of events per beam revolution + +

+ + +img('raw/hChIdVsBunchId')?> +
+Number of events registered by detector channel per bunch +
+ +
+img('raw/hIvsA')?> +
+Pulse integral vs (maximum) apmplitude +
+ +
+ + +

+ + + +

Beam Polarization and Asymmetry

+ +
+ +

+ + + + + + +
+img('asym/hNdetasym_lam')?> +
+Detector asymmetry vs azimuthal angle and the 3 parameter fit to the spin asymmetry (ε0), the spin tilt angle from vertical (φ0), and the luminosity up/down asymmetry (λ). +
+ +
+img('asym/hPolarVsPhi')?> +
+Polarization per channel as a function of the azimuthal channel angle +
+ +
+img('asym/hAsymVsPhi')?> +
+Asymmetry per channel as a function of the azimuthal channel angle +
+ +
img('asym/hAsymVsBunchId_X90')?> +
X90: Left-right asymmetry using only 90° detectors
+ +
img('asym/hAsymVsBunchId_X45')?> +
X45: Left-right asymmetry using only 45° detectors
+ +
img('asym/hAsymVsBunchId_Y45')?> +
Y45: Top-bottom (false) asymmetry using only 45° detectors
+ +
+
+Red points correspond to bunches with "up" spin +polarization. Green points correspond to bunches +with "down" spin polarization +
+ +
img('asym/hKinEnergyAChAsym')?> +
+Asymmetry as a function of the recoil carbon kinematic energy +
+ +
img('asym/hLongiChAsym')?> +
+Asymmetry as a function of the proton-Carbon interaction position (in seconds) +relative to the bunch center +
+ +
+   + +
+ + + +

+ + + +

Profile

+ +
+ +

+ + + + + + + +
+img("targets/hTargetVertRotary")?> +
+Nominal target position in motor steps vs time +
+ +
+img("profile/hIntensProfile")?> +
+Intensity profile: Number of events as a function of time +
+By channel +
+ + +
+img("profile/hIntensUniProfile")?> +
+If we assume a gaussian beam profile with the unit width the actuall +position of the target in the beam can be deduced from the intensity measured +at each target step. Note that the plot is symmetric around X = 0 by +construction +
+ +
+img("profile/hAsymUniProfile")?> +
+Beam asymmetry as a function of beam width in intesity sigma units +
+ +
+img("profile/hAsymVsIntensProfile")?> +
+Asymmetry vs intensity as measured every 0.1 second. The data is fitted with a +function P = P_max * (I/I_max)^r +
+ + +
+ + +img("profile/hPolarUniProfile")?> +
+Beam polarization as a function of beam width in intesity sigma units +
+ +
+img("profile/hPolarVsIntensProfile")?> +
+Polarization vs intensity as measured every 0.1 second. The data is fitted with +a function P = P_max * (I/I_max)^r +
+ +
+ + +img("profile/hPolarUniProfileBin")?> +
+The same as above but with a smaller number of bins for easier reading +
+ +
+img("profile/hPolarVsIntensProfileBin")?> +
+The same as above but with a smaller number of bins for easier reading +
+ + + +
+ + + + + + + +

Dead layer, t0 calibration

+ +
+ +

+ + + + + + + + + +
+img("calib/hDLVsChannel")?> +
+Effective dead layer for individual channels as extracted from the "banana" +fit. The dead layer is estimated from the undetected fraction of the initial +carbon energy +
+ +
+img("calib/hT0VsChannel")?> +
+ +
+ +
+img("calib/hLogChi2NdfVsChannel")?> + + +img("calib/hFitStatusVsChannel")?> +
+The channel is disabled if the channel status is not equal 1. The status codes +are:
+0: Not used in the fit, e.g. due to low statistics
+1: The channel is OK
+2: Fit did not converge
+3: Dead layer is too far from the average
+4: t0 is too far from the average
+5: chi^2/NDF is too high +
+ +
+img("preproc/hsTimeVsEnergyACumul")?> + + + + + + +
+ + +

Recoil Carbon Kinematics

+ +
+ +

+ + + + + + +
+img("kinema_premass/hPseudoMass")?> + +img("kinema/hPseudoMassClean")?> + +  + +
+img("kinema/hMassCleanFitChi2ByChannel")?> + +img("kinema/hMassCleanFitMeanByChannel")?> + +img("kinema/hMassCleanFitSigmaByChannel")?> + + +
+img("std/hLongiTimeDiff")?> + +img("std/hLongiTimeDiffVsEnergyA")?> + +img("std/hLongiTimeDiffVsEnergyA_pfx")?> + +
+ +

+ + + +

Channels

+ +
+ +

+ + +dir = "../runs/$gRunId/images$gSuffix/std/channel$chanId/"; + $gP->dir = "../runs/$gRunId/images$gSuffix/preproc/"; + + //$row1 .= "$row1\n$row2"; + print "\n"; + //$row1 = "";// $row2 = ""; + } + + $img = $gP->img("combo_ch$chanId", false, 250); + //$img = $gP->img("combo_ch$chanId"); + //$img = $gP->img("combo_ch$chanId", 150, "./?runid=$gRunId&chanid=$chanId&sfx=$gSfx"); + print "
$chanId"; + + if ( ($chanId-1) % 6 == 0 ) { + //print "
$img
\n"; + print "channel $chanId\n"; + +} +?> +
+ +

+ + + + +
+ + + + + + diff --git a/webview/rundb/test.php b/webview/rundb/test.php new file mode 100644 index 00000000..0dffea01 --- /dev/null +++ b/webview/rundb/test.php @@ -0,0 +1,164 @@ +\n"; + //print "Please wait for the data to be analyzed\n"; + exit; + } + + // Read information about this run from the config file + $rc = array(); + include("$gRunDir/runconfig$gSuffix.php"); + if (count($rc) == 0) { + print "No config file found for $gRunId\n"; + exit; + } + + // Check for all runconfig files + if ($handle = opendir($gRunDir)) { + //echo "Directory handle: $handle\n"; + //echo "Files:\n"; + + /* This is the correct way to loop over the directory. */ + $rc['suffixes'][] = array(); + + while (false !== ($file = readdir($handle))) { + //echo "$file\n"; + if (preg_match("/^runconfig(_?)(.*)\.php$/", $file, $matches)) $rc['suffixes'][] = $matches[2]; + } + + //print_r($rc['suffixes']); + + closedir($handle); + } else { + print "Could not find dir $gRunDir\n"; + exit; + } + + include_once("PlotHelper.php"); + + // Set default directory for run images + $dir = "../runs/$gRunId/images$gSuffix/"; + $gP = new PlotHelper($dir); + + if (ereg("[0-9]{3,}\.[0-9]{3}", $gRunId) && $rc['measurement_type'] != 1) { + + // Check if raw data display requested + if (isset($_GET['raw'])) + { + include("runinfo_raw.html"); + } else if ( isset($_GET['ach']) && !empty($_GET['ach']) ) // all channel histogram + { + include("runinfo_ach.html"); + } else{ + if( $rc['fRunId'] == 22) { + include("runinfo_r22.html"); + }else + include("runinfo.html"); + } + + } elseif ($rc['measurement_type'] == 1) { + include("runinfo_calib.html"); + } else { + //print "Problem displaying info for $gRunId\n"; + // XXX this is a temporary fix for notgt data files + //include("runinfo.html"); + if ( isset($_GET['raw']) ) { + include("runinfo_raw.html"); + } else { + if( $rc['fRunId'] == 22) { + include("runinfo_r22.html"); + }else + include("runinfo.html"); + } + } + + exit; +} + + +// Channel details view +if (isset($_GET['runid']) && isset($_GET['chanid'])) { + + $gRunId = $_GET['runid']; + $gRunId = strip_tags($gRunId); + $gChanId = $_GET['chanid']; + $gChanId = strip_tags($gChanId); + $gRunDir = DATA_DIR."/$gRunId"; + + // Check for correct and existing runid + if (!is_dir($gRunDir) || !file_exists("$gRunDir/runconfig$gSuffix.php")) + { + print "No results found for $gRunId\n"; + exit; + } + + // Check for correct and existing runid + if (!is_dir(DATA_DIR."/$gRunId") || !file_exists(DATA_DIR."/$gRunId/runconfig.php")) { + print "No results found for $gRunId\n"; + exit; + } + + // Read information about this run + $rc = array(); + include("$gRunDir/runconfig$gSuffix.php"); + if (count($rc) == 0) { + print "No config file found for $gRunDir\n"; + exit; + } + + include_once("PlotHelper.php"); + + $dir = "../runs/$gRunId/images$gSuffix/"; + $gP = new PlotHelper($dir); + + //if (ereg("[0-9]{3,}\.[0-9]{3}", $gRunId) && $rc['measurement_type'] != 1) + if ($rc['measurement_type'] != 1) + { + include("chaninfo.html"); + } elseif ($rc['measurement_type'] == 1) { + include("chaninfo_calib.html"); + } else { + print "Problem with $gRunId\n"; + } + + exit; +} + + +//if ( isset($_GET['himg']) && !empty($_GET['himg']) ) +//{ +// $gHistImg = $_GET['himg']; +// include("runinfo_index_image2.html"); +// +// exit; +//} + +include("runinfo_index_test.html"); + +?> diff --git a/webview/summary/index.php b/webview/summary/index.php index eb9c314c..641d6d57 100644 --- a/webview/summary/index.php +++ b/webview/summary/index.php @@ -10,6 +10,7 @@ if ( isset($_GET['ana']) ) { $gAnaId = $_GET['ana']; + $gAnaId = strip_tags($gAnaId); $gAnaDir = DATA_DIR."/$gAnaId"; // Check for correct and existing runid @@ -31,8 +32,58 @@ } include("summary.html"); -} elseif ( isset($_GET['alpha_list']) ) { +}elseif( isset($_GET['anar22']) ){ + $gAnaId = $_GET['anar22']; + $gAnaId = strip_tags($gAnaId); + $gAnaDir = DATA_DIR."/$gAnaId"; + + // Check for correct and existing runid + if (!is_dir($gAnaDir) || !file_exists("$gAnaDir/anainfo.php")) + { + print "No results found for $gAnaId
\n"; + exit; + } + + + // Read information about this run from the config file + $ai = array(); + include("$gAnaDir/anainfo.php"); + $ai = $rc; + + if (count($ai) == 0) { + print "No config file found for $gAnaId\n"; + exit; + } + + include("summary_r22.html"); +}elseif( isset($_GET['anar22b']) ){ + $gAnaId = $_GET['anar22b']; + $gAnaId = strip_tags($gAnaId); + $gAnaDir = DATA_DIR."/$gAnaId"; + + // Check for correct and existing runid + if (!is_dir($gAnaDir) || !file_exists("$gAnaDir/anainfo.php")) + { + print "No results found for $gAnaId
\n"; + exit; + } + + + // Read information about this run from the config file + $ai = array(); + include("$gAnaDir/anainfo.php"); + $ai = $rc; + + if (count($ai) == 0) { + print "No config file found for $gAnaId\n"; + exit; + } + + include("summary_r22_254.html"); +}elseif ( isset($_GET['alpha_list']) ) { include("summary_malpha.html"); +} elseif ( isset($_GET['bes_list']) ) { + include("summary_bes.html"); } else { include("summary_index.html"); } diff --git a/webview/summary/summary.html b/webview/summary/summary.html index b6c98cf5..d6700ffc 100644 --- a/webview/summary/summary.html +++ b/webview/summary/summary.html @@ -180,7 +180,7 @@

GeV

- +

H-Jet/p-Carbon Polarization Ratio

diff --git a/webview/summary/summary_bes.html b/webview/summary/summary_bes.html new file mode 100644 index 00000000..9521b5ee --- /dev/null +++ b/webview/summary/summary_bes.html @@ -0,0 +1,109 @@ + + + + RHIC Polarimetry Results: Beam Energy Scan Plots + + + + + + + + + + + + + + +

Beam energy scan plots

+ +
+ +
+ +
+ +

+ + + + +
Gamma 485 485.5 486 486.5 487 +
Brho [Tm] 846.65 847.52 848.39 849.27 850.14 +
pc [GeV] 253.82 254.08 254.34 254.60 254.87 +
+ + + + +

Summary plots from fill

+ +
+ +

+STAR ZDC polarimetry (scaler files) +

+STAR ZDC polarimetry (trigger files) + +

+ + + +
+ img("pol_$ff", false, 500)?> +
Polarization
+ +
+ img("phase_$ff", false, 500)?> +
Spin angle (phase)
+ +
+ +
+ +

+ + + + + + diff --git a/webview/summary/summary_index.html b/webview/summary/summary_index.html index 370fc592..ed53a70d 100644 --- a/webview/summary/summary_index.html +++ b/webview/summary/summary_index.html @@ -27,6 +27,22 @@

Summary Plots by Run Period

+

Run 22

+ + + + +

Studies

+ +

Run 17

diff --git a/webview/summary/summary_r22.html b/webview/summary/summary_r22.html new file mode 100644 index 00000000..c4ee9a3e --- /dev/null +++ b/webview/summary/summary_r22.html @@ -0,0 +1,1138 @@ + + + + + + + RHIC Polarimetry Results: Summary Plots + + + + + + + + + + + +CountEntries(); + +$dir = "../runs/{$_GET['anar22']}/images/"; +$gP = new PlotHelper($dir); + +//$flattopEnergy = sprintf("%03d", 24); +//$flattopEnergy = sprintf("%03d", 100); +//$ai['fBeamEnergies'] = $_GET['es']; +$flattopEnergy = sprintf("%03d", 255); + +?> + + + +

Summary Plots

+ +
+ +
+ +
+ + + + +

H-Jet Polarimeter

+ +
+ + + +

Beam Polarization

+ +
+ + + +

GeV

+ +

+ + + +
+ img("runs/BLU/hPolarHJVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hPolarHJVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
Beam polarization as measured by the H-Jet polarimeter
+ +
+ + + + +

+ + + + +

Analyzing power A_N

+ +
+ + + +

GeV

+ +

+ + + +
img("runs/BLU/hAsymHJVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hAsymHJVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
Analyzing power A_N as measured by the H-Jet polarimeter
+ +
+ + + + +

+ + +
+ + + + + +

p-Carbon Polarimeters

+ +
+ + + +

Unscaled Polarization

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarPCVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarPCVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarPCVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarPCVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Average polarization as measured by p-Carbon +polarimeters. The values are unscaled. The analyzing power (P = +ε/A_N) from 2004 is used. + +
+ + + +

+ + + + +

H-Jet/p-Carbon Polarization Ratio

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hNormJCVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hNormJCVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hNormJCVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hNormJCVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Ratio of H-Jet/p-Carbon polarizations
+ +
+ + + + +

+ + + + + +

H-jet/p-Carbon Polarization Ratio by Target Id

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hNormHJ2PCVsTargetId_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hNormHJ2PCVsTargetId_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hNormHJ2PCVsTargetId_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hNormHJ2PCVsTargetId_Y1D_$strEnergy", false, 800)?> +
Y1D
+ + +
+
+H-jet/p-Carbon polarization ratio by target. +
+ +
+ + + + + +

Scaled Polarization

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarPCScaledVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarPCScaledVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarPCScaledVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarPCScaledVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Fill polarization as measured by p-Carbon +polarimeters. The normalization to the H-jet results is applied
+ +
+ + + +

+ + + + +

H-Jet/p-Carbon Scaled Polarization Ratio

+ +
+ + + +

GeV

+ + +

+ + + + + +
img("runs/B1U/hPolarHJPCRatioVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarHJPCRatioVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarHJPCRatioVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarHJPCRatioVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Ratio of H-Jet/scaled p-Carbon polarization +
+ +
+ + + +

+ + + + +

Upstream/Downstream Scaled Polarization Ratio

+ + + + +
+ +

+ + + + +
img("runs/BLU/hPolarUDRatioVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hPolarUDRatioVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
+Ratio of upstream to downstream p-Carbon polarization values at flattop energy only +
+ +
+ + + + + + +

Injection Efficiency: RHIC Injection/AGS Polarization Ratio

+ + + +

Ratio plots

+ + + + + +
img("fills/hRhicAgsPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRhicAgsPolarRatio_YEL", false, 800)?> +
Yellow
+ +
+
+Ratio of RHIC polarization at injection (only first injection measurement per polarimeter is used) to polarization in AGS before injection. +
+ +
+ + +

Polarization in AGS

+ +
+Polarizations in AGS before injection into the RHIC: +
+ + + + + +
img("fills/hAgsPolarVsFillId", false, 800)?>
+ + + + + + +

Energy Ramp Efficiency: After/Before Polarization Ratio

+ + + + +

GeV

+ +

+ + + + + +
img("fills/hRampPCPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRampPCPolarRatio_YEL", false, 800)?> +
Yellow
+ +
img("fills/hRampPCPolarRatio_B1U", false, 400)?> +
B1U
+ +
img("fills/hRampPCPolarRatio_B2D", false, 400)?> +
B2D
+ +
img("fills/hRampPCPolarRatio_Y1D", false, 400)?> +
Y1D
+ +
img("fills/hRampPCPolarRatio_Y2U", false, 400)?> +
Y2U
+ +
+
+Ratio ("after"/"before") of polarization measured before and after the energy ramp +
+ +
+ + + + + + + +

Rotator Ramp Efficiency: After/Before Polarization Ratio

+ + + + +

GeV

+ +

+ + + + + +
img("fills/hRotatorPCPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRotatorPCPolarRatio_YEL", false, 800)?> +
Yellow
+ +
img("fills/hRotatorPCPolarRatio_B1U", false, 400)?> +
B1U
+ +
img("fills/hRotatorPCPolarRatio_B2D", false, 400)?> +
B2D
+ +
img("fills/hRotatorPCPolarRatio_Y1D", false, 400)?> +
Y1D
+ +
img("fills/hRotatorPCPolarRatio_Y2U", false, 400)?> +
Y2U
+ +
+
+Ratio ("after"/"before") of polarization measured before and after the rotator +ramp at flattop energy only +
+ +
+ + + + + + + +

Polarization Profile R

+ +
+ + + + +

GeV

+ +

+ + + + + + + + + +
img("runs/B1U/hRVsFill_B1U_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/Y2U/hRVsFill_Y2U_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/B1U/hRVsFill_V_B1U_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/B1U/hRVsFill_H_B1U_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+
img("runs/Y2U/hRVsFill_V_Y2U_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/Y2U/hRVsFill_H_Y2U_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+ +
+
B1U
+
+
Y2U
+ +
img("runs/B2D/hRVsFill_B2D_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/Y1D/hRVsFill_Y1D_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/B2D/hRVsFill_V_B2D_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/B2D/hRVsFill_H_B2D_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+
img("runs/Y1D/hRVsFill_V_Y1D_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/Y1D/hRVsFill_H_Y1D_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+ +
+
B2D
+
+
Y1D
+ +
+
+Fill average polarization profile values +
+ +
+ + + +

+ + + + +

Polarization Profile R Decay, dR/dt

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hRSlopeVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hRSlopeVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hRSlopeVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hRSlopeVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Polarization profile "decay" per hour +
+ +
+ + + +

+ + + + +

Polarization Decay, dP/dt

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarSlopeVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarSlopeVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarSlopeVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarSlopeVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Polarization decay in absolute % per hour +
+ +
+ + + +

+ + + + +

Polarization Decay (dP/dt) vs Profile R Slope (dR/dt)

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hRSlopeVsPolarSlope_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hRSlopeVsPolarSlope_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hRSlopeVsPolarSlope_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hRSlopeVsPolarSlope_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+dR/dt vs dP/dt +
+ +
+ + + +

+ + + + +

Polarization by p-Carbon

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Average polarization +
+ +
+ + + + +

+ +

Spin Angle (Radial Component) by p-Carbon

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hSpinAngleVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hSpinAngleVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hSpinAngleVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hSpinAngleVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Average spin angle (i.e. radial component) +
+ +
+ + + +

+ + + + + +

p-Carbon Calibration: t0 Time Offset

+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hT0VsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hT0VsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hT0VsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hT0VsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+t0 calibration parameter averaged over all channels and all measurements in a fill +
+ +
+ + + + + + +

p-Carbon Calibration: Effective Dead Layer

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hDLVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hDLVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hDLVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hDLVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Effective dead layer calibration parameter averaged over all channels and all +measurements in a fill +
+ +
+ + + + + + +

Target Usage

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hTargetVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hTargetVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hTargetVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hTargetVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ + +
+
+Target used in the fill +
+ +
+ + + + + + +

Bunch Asymmetry

+ + + +

GeV

+ +

+ + + + +
img("fills/hBunchAsymChi2_BLU", false, 800)?> +
Blue
+ +
img("fills/hBunchAsymChi2_YEL", false, 800)?> +
Yellow
+ +
+
+ +from the fits of the individual bunch asymmetries. Red +points correspond to fits of bunch asymmetries with only "up" spin polarization, +green points correspond to fits of bunch asymmetries +with only "down" spin polarization +
+ +
+ + + + + + +

Bunch Asymmetry Spread

+ + + +

GeV

+ +

+ + + + +
img("fills/hBunchAsymSigma_BLU", false, 800)?> +
Blue
+ +
img("fills/hBunchAsymSigma_YEL", false, 800)?> +
Yellow
+ +
+
+The spread of bunch asymmetries in the fill. Red +points correspond bunch asymmetries with only "up" spin polarization, +green points correspond bunch asymmetries +with only "down" spin polarization +
+ +
+ + + + +

+ + + + + +

Beam Intensity

+ +
+ + + + +

GeV

+ +

+ + + + +
img("runs/BLU/hIntensDecayVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hIntensDecayVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
+Beam intensity lifetime +
+ +
+ + + + +

+ + + +

Bias current

+ +
+ +
+Average detector bias currents during the measurements: +
+ + +

+

+ + + + + +
img("bias/hBiasCurrent_${pol}_det1", false, 200)?> +
Det1
+
img("bias/hBiasCurrent_${pol}_det2", false, 200)?> +
Det2
+
img("bias/hBiasCurrent_${pol}_det3", false, 200)?> +
Det3
+
img("bias/hBiasCurrent_${pol}_det4", false, 200)?> +
Det4
+
img("bias/hBiasCurrent_${pol}_det5", false, 200)?> +
Det5
+
img("bias/hBiasCurrent_${pol}_det6", false, 200)?> +
Det6
+
+ + + + +

+ + + + + + +
+ + + + + + + diff --git a/webview/summary/summary_r22_254.html b/webview/summary/summary_r22_254.html new file mode 100644 index 00000000..d070d01a --- /dev/null +++ b/webview/summary/summary_r22_254.html @@ -0,0 +1,1138 @@ + + + + + + + RHIC Polarimetry Results: Summary Plots + + + + + + + + + + + +CountEntries(); + +$dir = "../runs/{$_GET['anar22b']}/images/"; +$gP = new PlotHelper($dir); + +//$flattopEnergy = sprintf("%03d", 24); +//$flattopEnergy = sprintf("%03d", 100); +//$ai['fBeamEnergies'] = $_GET['es']; +$flattopEnergy = sprintf("%03d", 254); + +?> + + + +

Summary Plots

+ +
+ +
+ +
+ + + + +

H-Jet Polarimeter

+ +
+ + + +

Beam Polarization

+ +
+ + + +

GeV

+ +

+ + + +
+ img("runs/BLU/hPolarHJVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hPolarHJVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
Beam polarization as measured by the H-Jet polarimeter
+ +
+ + + + +

+ + + + +

Analyzing power A_N

+ +
+ + + +

GeV

+ +

+ + + +
img("runs/BLU/hAsymHJVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hAsymHJVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
Analyzing power A_N as measured by the H-Jet polarimeter
+ +
+ + + + +

+ + +
+ + + + + +

p-Carbon Polarimeters

+ +
+ + + +

Unscaled Polarization

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarPCVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarPCVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarPCVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarPCVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Average polarization as measured by p-Carbon +polarimeters. The values are unscaled. The analyzing power (P = +ε/A_N) from 2004 is used. + +
+ + + +

+ + + + +

H-Jet/p-Carbon Polarization Ratio

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hNormJCVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hNormJCVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hNormJCVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hNormJCVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Ratio of H-Jet/p-Carbon polarizations
+ +
+ + + + +

+ + + + + +

H-jet/p-Carbon Polarization Ratio by Target Id

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hNormHJ2PCVsTargetId_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hNormHJ2PCVsTargetId_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hNormHJ2PCVsTargetId_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hNormHJ2PCVsTargetId_Y1D_$strEnergy", false, 800)?> +
Y1D
+ + +
+
+H-jet/p-Carbon polarization ratio by target. +
+ +
+ + + + + +

Scaled Polarization

+ +
+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarPCScaledVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarPCScaledVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarPCScaledVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarPCScaledVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
Fill polarization as measured by p-Carbon +polarimeters. The normalization to the H-jet results is applied
+ +
+ + + +

+ + + + +

H-Jet/p-Carbon Scaled Polarization Ratio

+ +
+ + + +

GeV

+ + +

+ + + + + +
img("runs/B1U/hPolarHJPCRatioVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarHJPCRatioVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarHJPCRatioVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarHJPCRatioVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Ratio of H-Jet/scaled p-Carbon polarization +
+ +
+ + + +

+ + + + +

Upstream/Downstream Scaled Polarization Ratio

+ + + + +
+ +

+ + + + +
img("runs/BLU/hPolarUDRatioVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hPolarUDRatioVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
+Ratio of upstream to downstream p-Carbon polarization values at flattop energy only +
+ +
+ + + + + + +

Injection Efficiency: RHIC Injection/AGS Polarization Ratio

+ + + +

Ratio plots

+ + + + + +
img("fills/hRhicAgsPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRhicAgsPolarRatio_YEL", false, 800)?> +
Yellow
+ +
+
+Ratio of RHIC polarization at injection (only first injection measurement per polarimeter is used) to polarization in AGS before injection. +
+ +
+ + +

Polarization in AGS

+ +
+Polarizations in AGS before injection into the RHIC: +
+ + + + + +
img("fills/hAgsPolarVsFillId", false, 800)?>
+ + + + + + +

Energy Ramp Efficiency: After/Before Polarization Ratio

+ + + + +

GeV

+ +

+ + + + + +
img("fills/hRampPCPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRampPCPolarRatio_YEL", false, 800)?> +
Yellow
+ +
img("fills/hRampPCPolarRatio_B1U", false, 400)?> +
B1U
+ +
img("fills/hRampPCPolarRatio_B2D", false, 400)?> +
B2D
+ +
img("fills/hRampPCPolarRatio_Y1D", false, 400)?> +
Y1D
+ +
img("fills/hRampPCPolarRatio_Y2U", false, 400)?> +
Y2U
+ +
+
+Ratio ("after"/"before") of polarization measured before and after the energy ramp +
+ +
+ + + + + + + +

Rotator Ramp Efficiency: After/Before Polarization Ratio

+ + + + +

GeV

+ +

+ + + + + +
img("fills/hRotatorPCPolarRatio_BLU", false, 800)?> +
Blue
+ +
img("fills/hRotatorPCPolarRatio_YEL", false, 800)?> +
Yellow
+ +
img("fills/hRotatorPCPolarRatio_B1U", false, 400)?> +
B1U
+ +
img("fills/hRotatorPCPolarRatio_B2D", false, 400)?> +
B2D
+ +
img("fills/hRotatorPCPolarRatio_Y1D", false, 400)?> +
Y1D
+ +
img("fills/hRotatorPCPolarRatio_Y2U", false, 400)?> +
Y2U
+ +
+
+Ratio ("after"/"before") of polarization measured before and after the rotator +ramp at flattop energy only +
+ +
+ + + + + + + +

Polarization Profile R

+ +
+ + + + +

GeV

+ +

+ + + + + + + + + +
img("runs/B1U/hRVsFill_B1U_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/Y2U/hRVsFill_Y2U_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/B1U/hRVsFill_V_B1U_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/B1U/hRVsFill_H_B1U_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+
img("runs/Y2U/hRVsFill_V_Y2U_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/Y2U/hRVsFill_H_Y2U_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+ +
+
B1U
+
+
Y2U
+ +
img("runs/B2D/hRVsFill_B2D_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/Y1D/hRVsFill_Y1D_$strEnergy", false, 800)?> +
Horizontal and vertical profiles
+
img("runs/B2D/hRVsFill_V_B2D_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/B2D/hRVsFill_H_B2D_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+
img("runs/Y1D/hRVsFill_V_Y1D_$strEnergy", false, 400)?> +
Horizontal profile (Vertical targets)
+
img("runs/Y1D/hRVsFill_H_Y1D_$strEnergy", false, 400)?> +
Vertical profile (Horizontal targets)
+ +
+
B2D
+
+
Y1D
+ +
+
+Fill average polarization profile values +
+ +
+ + + +

+ + + + +

Polarization Profile R Decay, dR/dt

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hRSlopeVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hRSlopeVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hRSlopeVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hRSlopeVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Polarization profile "decay" per hour +
+ +
+ + + +

+ + + + +

Polarization Decay, dP/dt

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarSlopeVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarSlopeVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarSlopeVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarSlopeVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Polarization decay in absolute % per hour +
+ +
+ + + +

+ + + + +

Polarization Decay (dP/dt) vs Profile R Slope (dR/dt)

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hRSlopeVsPolarSlope_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hRSlopeVsPolarSlope_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hRSlopeVsPolarSlope_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hRSlopeVsPolarSlope_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+dR/dt vs dP/dt +
+ +
+ + + +

+ + + + +

Polarization by p-Carbon

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hPolarVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hPolarVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hPolarVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hPolarVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Average polarization +
+ +
+ + + + +

+ +

Spin Angle (Radial Component) by p-Carbon

+ +
+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hSpinAngleVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hSpinAngleVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hSpinAngleVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hSpinAngleVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Average spin angle (i.e. radial component) +
+ +
+ + + +

+ + + + + +

p-Carbon Calibration: t0 Time Offset

+ + + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hT0VsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hT0VsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hT0VsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hT0VsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+t0 calibration parameter averaged over all channels and all measurements in a fill +
+ +
+ + + + + + +

p-Carbon Calibration: Effective Dead Layer

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hDLVsFill_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hDLVsFill_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hDLVsFill_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hDLVsFill_Y1D_$strEnergy", false, 800)?> +
Y1D
+ +
+
+Effective dead layer calibration parameter averaged over all channels and all +measurements in a fill +
+ +
+ + + + + + +

Target Usage

+ + + +

GeV

+ +

+ + + + + +
img("runs/B1U/hTargetVsMeas_B1U_$strEnergy", false, 800)?> +
B1U
+ +
img("runs/Y2U/hTargetVsMeas_Y2U_$strEnergy", false, 800)?> +
Y2U
+ +
img("runs/B2D/hTargetVsMeas_B2D_$strEnergy", false, 800)?> +
B2D
+ +
img("runs/Y1D/hTargetVsMeas_Y1D_$strEnergy", false, 800)?> +
Y1D
+ + +
+
+Target used in the fill +
+ +
+ + + + + + +

Bunch Asymmetry

+ + + +

GeV

+ +

+ + + + +
img("fills/hBunchAsymChi2_BLU", false, 800)?> +
Blue
+ +
img("fills/hBunchAsymChi2_YEL", false, 800)?> +
Yellow
+ +
+
+ +from the fits of the individual bunch asymmetries. Red +points correspond to fits of bunch asymmetries with only "up" spin polarization, +green points correspond to fits of bunch asymmetries +with only "down" spin polarization +
+ +
+ + + + + + +

Bunch Asymmetry Spread

+ + + +

GeV

+ +

+ + + + +
img("fills/hBunchAsymSigma_BLU", false, 800)?> +
Blue
+ +
img("fills/hBunchAsymSigma_YEL", false, 800)?> +
Yellow
+ +
+
+The spread of bunch asymmetries in the fill. Red +points correspond bunch asymmetries with only "up" spin polarization, +green points correspond bunch asymmetries +with only "down" spin polarization +
+ +
+ + + + +

+ + + + + +

Beam Intensity

+ +
+ + + + +

GeV

+ +

+ + + + +
img("runs/BLU/hIntensDecayVsFill_BLU_$strEnergy", false, 800)?> +
Blue
+ +
img("runs/YEL/hIntensDecayVsFill_YEL_$strEnergy", false, 800)?> +
Yellow
+ +
+
+Beam intensity lifetime +
+ +
+ + + + +

+ + + +

Bias current

+ +
+ +
+Average detector bias currents during the measurements: +
+ + +

+

+ + + + + +
img("bias/hBiasCurrent_${pol}_det1", false, 200)?> +
Det1
+
img("bias/hBiasCurrent_${pol}_det2", false, 200)?> +
Det2
+
img("bias/hBiasCurrent_${pol}_det3", false, 200)?> +
Det3
+
img("bias/hBiasCurrent_${pol}_det4", false, 200)?> +
Det4
+
img("bias/hBiasCurrent_${pol}_det5", false, 200)?> +
Det5
+
img("bias/hBiasCurrent_${pol}_det6", false, 200)?> +
Det6
+
+ + + + +

+ + + + + + +
+ + + + + + +