Skip to content

Commit

Permalink
spin tune moter and noise study by zchang (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zlchang authored Apr 2, 2024
1 parent 506b267 commit f429aa4
Show file tree
Hide file tree
Showing 94 changed files with 6,652 additions and 307 deletions.
9 changes: 4 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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 = [email protected]: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
23 changes: 14 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}\"")

Expand All @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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+;
Expand All @@ -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+;
Expand All @@ -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+;
Expand Down
152 changes: 152 additions & 0 deletions contrib/RunPeriod.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
2 changes: 1 addition & 1 deletion contrib/opencdev
Submodule opencdev updated 1 files
+0 −1 CMakeLists.txt
2 changes: 1 addition & 1 deletion contrib/polarim-online
2 changes: 1 addition & 1 deletion contrib/root-helper
24 changes: 24 additions & 0 deletions inc/AfterBurner.h
Original file line number Diff line number Diff line change
@@ -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 <iostream>
#include <fstream>

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<double,double> asym_err(double lambda, double nup, double ndn);
void fit1asym(double nup[] , double ndn[] , double par[], double epar[] , double &chi2, int fixpar = 0);
}
1 change: 1 addition & 0 deletions inc/AnaFillExternResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AnaFillExternResult : public TObject

TGraphErrors* MakeGraph(const std::map<opencdev::cdev_time_t, double> &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:
Expand Down
10 changes: 10 additions & 0 deletions inc/AnaFillResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
};
Expand Down
4 changes: 2 additions & 2 deletions inc/AnaInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <sys/stat.h>

#include "TObject.h"
#include "TSystem.h"

#include "UserGroup.h"
#include "AsymCommon.h"


Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions inc/AnaMeasResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion inc/AsymAnaInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit f429aa4

Please sign in to comment.