Low-Energy Muon (LEM) Experiment  0.5.2
analyzer.cxx File Reference
#include <vector>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <unistd.h>
#include "midas.h"
#include "experim.h"
#include "nemu_experim.h"
#include <TROOT.h>
#include <TSystem.h>
#include <TMath.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TTree.h>
#include <TDirectory.h>
#include <TFile.h>
#include <TMusrRunHeader.h>
Include dependency graph for analyzer.cxx:

Go to the source code of this file.

Macros

#define HISTOGRAM_WRITE_PERIOD   300
 
#define UPDATE_INFO_PERIOD   5
 
#define UPDATE_INFO_PERIOD_IPMI   300
 

Functions

 RATE_BANK_STR (rate_bank_str)
 
 SRAT_BANK_STR (srat_bank_str)
 
 POSI_BANK_STR (posi_bank_str)
 
static TObjArray Slist (0)
 
INT write_histogram_file ()
 
void get_sum_filename (char *filename)
 
void extract_summary_data ()
 
void update_info ()
 
void update_run_header ()
 
INT beam_shutter_open (HNDLE hDB)
 
float energy_loss (float moderator_hv)
 
float get_magnetic_field (float current)
 
void get_t0 ()
 
void get_t0L3RA ()
 
INT read_lem00_ipmi_log (LEM00_IPMI_LOG *info)
 
INT read_lem03_ipmi_log (LEM03_IPMI_LOG *info)
 
INT read_microwave_log (MICROWAVE_LOG *microwave_info)
 
void update_t0shift (INT dummy1, INT dummy2, void *dummy3)
 
void set_spin_rot_angle (INT hDB, INT hKey, void *dummy)
 
void disp_scaler (INT n)
 
INT analyzer_init ()
 
INT analyzer_exit ()
 
INT ana_begin_of_run (INT run_number, char *error)
 
INT ana_end_of_run (INT run_number, char *error)
 
INT ana_pause_run (INT run_number, char *error)
 
INT ana_resume_run (INT run_number, char *error)
 
INT analyzer_loop ()
 

Variables

const char * analyzer_name = "Analyzer"
 
INT analyzer_loop_period = 1000
 
INT odb_size = DEFAULT_ODB_SIZE
 
char runname [256]
 
INT versionCounter
 
VME_STATS vme_stats
 Required ODB structures. More...
 
RUNINFO runinfo
 
EXP_EDIT exp_edit
 
EXP_PARAM exp_param
 
SCALER_SETTINGS scaler_settings
 
RATE_BANK rate_bank
 
SRAT_BANK srat_bank
 
POSI_BANK posi_bank
 
TRIGGER_SETTINGS trigger_settings
 
INFO info
 
HV_EVENT hv_event
 
SCS2001M_EVENT scs2001m_event
 
T0SHIFT_PARAM t0shift_param
 
TDSAMPLETOF_PARAM tdsampletof_param
 
MEAN_BANK mean
 
DECAYANAMODULE_PARAM decay_ana_param
 
SCANAMODULE_PARAM sc_ana_param
 
TFolder * gManaHistosFolder
 
static TFolder * gRunHeader = NULL
 
static TMusrRunHeader * header = NULL
 
static DWORD last_histogram_write
 
static DWORD last_update_info_write
 
static INT write_flag
 
static INT sum_count
 
static float rotation_angle
 
ANA_MODULE decay_ana_module
 
ANA_MODULE tof_ana_module
 
ANA_MODULE pileup_ana_module
 
ANA_MODULE mcp1_ana_module
 
ANA_MODULE scaler_rate_sum
 
ANA_MODULE sc_ana_module
 
ANA_MODULE * trigger_module []
 
ANA_MODULE * scaler_module []
 
ANA_MODULE * sc_module []
 
BANK_LIST trigger_bank_list []
 
BANK_LIST scaler_bank_list []
 
BANK_LIST sc_bank_list []
 
ANALYZE_REQUEST analyze_request []
 

Macro Definition Documentation

#define HISTOGRAM_WRITE_PERIOD   300

Definition at line 114 of file analyzer.cxx.

Referenced by analyzer_loop().

#define UPDATE_INFO_PERIOD   5

Definition at line 115 of file analyzer.cxx.

Referenced by analyzer_loop().

#define UPDATE_INFO_PERIOD_IPMI   300

Definition at line 116 of file analyzer.cxx.

Referenced by read_lem00_ipmi_log(), and read_lem03_ipmi_log().

Function Documentation

INT ana_begin_of_run ( INT  run_number,
char *  error 
)
INT ana_end_of_run ( INT  run_number,
char *  error 
)
INT ana_pause_run ( INT  run_number,
char *  error 
)

Definition at line 726 of file analyzer.cxx.

References disp_scaler(), N_SCALER, and runinfo.

INT ana_resume_run ( INT  run_number,
char *  error 
)

Definition at line 735 of file analyzer.cxx.

References beam_shutter_open(), disp_scaler(), hDB, N_SCALER, and runinfo.

INT analyzer_exit ( )

Definition at line 572 of file analyzer.cxx.

INT beam_shutter_open ( HNDLE  hDB)

check, if beam shutters KV61/KV62 are open at begin-of-run

return:

  • 1, if beam shutters are open
  • 0, if beam shutters are closed
Parameters
hDBhandle to the ODB.

Definition at line 2774 of file analyzer.cxx.

Referenced by ana_begin_of_run(), and ana_resume_run().

void disp_scaler ( INT  n)
float energy_loss ( float  moderator_hv)

calculate energy loss in C-foil; measured E-loss data were fitted by a 3rd order polynom. Above 20kV, assume constant energy loss (polynom gives wrong results). Also, below 7.5kV data to be verified.

return: deltaE

Parameters
moderator_hvmoderator high voltage

Definition at line 972 of file analyzer.cxx.

References INFO::energy_loss_parameter, INFO::p0, INFO::p1, INFO::p2, and INFO::p3.

Referenced by get_t0(), get_t0L3RA(), and update_info().

void extract_summary_data ( )

Definition at line 935 of file analyzer.cxx.

References get_sum_filename(), line, and Slist().

Referenced by analyzer_loop().

float get_magnetic_field ( float  current)

Calculate magnetic field from zero flux current

return: B-field of either WEW or Bpar magnet

Parameters
currentrunning through the magnet

Definition at line 998 of file analyzer.cxx.

References INFO::bpar, INFO::lem_setup_parameter, INFO::magnet_parameter, and INFO::wew.

Referenced by sc_ana(), and update_info().

void get_sum_filename ( char *  filename)

Create filename for run summary files of the Nemu experiment.

Parameters
filenamepointer to the file name

Definition at line 898 of file analyzer.cxx.

References runinfo.

Referenced by extract_summary_data().

void get_t0 ( )

Calculates t0's for LE-uSR decay histograms and write them to /Info/t0_Parameter/t0.

t0's of decay histograms are saved in /Info/t0_Parameter/t0Hist array. The t0s for energies XX are then calculated:

t0 = t0Hist + tof_XXkV

t0Hist = t_(e+ prompt peak) - (13.5ns+550mm/299.79mm/ns)/0.1953125 = 2062 - 79 = 1983

tof_XXkV is calculated using the "effective length" of the transport system from TD to sample:

tof_XXkV = l_eff/c*sqrt(mc**2/2)*1/sqrt(E), see http://lem00:8000/LEM_Experiment/1849.

Currently two effective lengths are given in ODB:

leff_RAon and leff_RAoff for "RA-On" and "RA-Off" settings.

Definition at line 1419 of file analyzer.cxx.

References HV_EVENT::demand, energy_loss(), hDB, hKey, INFO::leff_RAoff, INFO::leff_RAon, INFO::lem_setup, INFO::magnetic_field, SCANAMODULE_PARAM::mod_hv_channel, N_DECAY_HISTS, INFO::t0_parameter, and INFO::t0Hist.

void get_t0L3RA ( )

Calculates t0's for LE-uSR decay histograms and write them to /Info/t0_Parameter/t0.

t0's of decay histograms are saved in /Info/t0_Parameter/t0Hist array. The t0s for moderator HV XX are then calculated:

t0 = t0Hist + tofXXkV

t0Hist = t_(e+ prompt peak) - (13.5ns+550mm/299.79mm/ns)/0.1953125 = 2062 - 79 = 1983

tofXXkV is calculated as a function of L3 and RA potential:

tofXXkV = dFree/sqrt(2E/m)/c + tof(L3) + tof(RA)

dFree = dTotal - dL3 -dRA, where dTotal = (544 + 0.4*ModHV)mm; the effective drift between TD and sample dL3 = 231 mm; effective drift length through L3, determined from a fit to measured TOF data dRA = 221 mm; effective drift length through RA, determined from a fit to measured TOF data dFree is the effective drift section without electric field

Assuming the following potential shape in the electrostatic elements:

U ^ | /\ | / \ | / \ ----—/ -----—> z

one can use

d = 0.5at**2 + vt ==> t = -v/a - sqrt[(v/a)**2 + 2d/a] with a = -e/m*U/d, where U = scalingFactor*LensPotential ("Lens" is either L3 or RA)

Using units keV and kV for m and U one gets

tof(Lens) = dLens/(scaleLens*ULens*c)*sqrt(2mE)*[1-sqrt(1-scaleLens*ULens/E)]

Experimentally, I found out that

scaleL3 = 0.71 + 0.004*ModHV scaleRA = 1.10

Use ODB paramters in /Analyzer/Parameters/TDSampleTOF:

dTotalP0 = 544 dTotalP1 = 0.400, so that dTotal = dTotalP0 + dTotalP1*ModHV dL3 = 231 dRA = 221 scaleL3P0 = 0.71 scaleL3P1 = 0.004, so that scaleL3 = scaleL3P0 + scaleL3P1*ModHV scaleRAP0 = 1.1 scaleRAP1 = 0. modHVchannel = 4 L3-channel = 10 RA-Lchannel = 11 RA-Rchannel = 12 RA-Tchannel = 13 RA-Bchannel = 14

Definition at line 1521 of file analyzer.cxx.

References HV_EVENT::demand, TDSAMPLETOF_PARAM::dl3, TDSAMPLETOF_PARAM::dra, TDSAMPLETOF_PARAM::dtotalp0, TDSAMPLETOF_PARAM::dtotalp1, energy_loss(), hDB, hKey, TDSAMPLETOF_PARAM::l3_channel, TDSAMPLETOF_PARAM::moderator_channel, N_DECAY_HISTS, TDSAMPLETOF_PARAM::rab_channel, TDSAMPLETOF_PARAM::ral_channel, TDSAMPLETOF_PARAM::rar_channel, TDSAMPLETOF_PARAM::rat_channel, TDSAMPLETOF_PARAM::scalel3p0, TDSAMPLETOF_PARAM::scalel3p1, TDSAMPLETOF_PARAM::scalerap0, TDSAMPLETOF_PARAM::scalerap1, INFO::t0_parameter, and INFO::t0Hist.

Referenced by update_info().

POSI_BANK_STR ( posi_bank_str  )

Referenced by tof_init().

RATE_BANK_STR ( rate_bank_str  )
void set_spin_rot_angle ( INT  hDB,
INT  hKey,
void *  dummy 
)

set values for LEM spin rotator depending on angle and moderator energy.

Definition at line 2871 of file analyzer.cxx.

References INFO::a0, INFO::a1, INFO::a2, INFO::a3, INFO::a4, HV_EVENT::demand, SCANAMODULE_PARAM::mod_hv_channel, rotation_angle, INFO::spinrot_parameter, and INFO::SRenable.

Referenced by analyzer_init().

static TObjArray Slist ( )
static
SRAT_BANK_STR ( srat_bank_str  )
void update_t0shift ( INT  dummy1,
INT  dummy2,
void *  dummy3 
)

update t0Shifts for LEM decay histograms when changing from Bpar to WEW setup.

Parameters
dummy1unused dispatcher parameter
dummy2unused dispatcher parameter
dummy3unused dispatcher parameter

Definition at line 2834 of file analyzer.cxx.

References analyzer_name, INFO::bpar, T0SHIFT_PARAM::delta_t0, hDB, hKey, INFO::lem_setup_parameter, N_DECAY_HISTS, and T0SHIFT_PARAM::shift_delta_t0.

Referenced by analyzer_init().

INT write_histogram_file ( )

display scaler in analyzer window if running online; function defined in module scaler_rate_sum.c

Definition at line 817 of file analyzer.cxx.

References analyzer_name, gManaHistosFolder, gRunHeader, hDB, header, runinfo, and versionCounter.

Referenced by analyzer_loop().

Variable Documentation

ANALYZE_REQUEST analyze_request[]

Definition at line 195 of file analyzer.cxx.

INT analyzer_loop_period = 1000

Definition at line 74 of file analyzer.cxx.

const char* analyzer_name = "Analyzer"

Definition at line 71 of file analyzer.cxx.

Referenced by analyzer_init(), update_t0shift(), and write_histogram_file().

ANA_MODULE decay_ana_module

Define analyser modules which are from external source code. ana_module tof_ana_module = tof_ana_module.c ana_module scaler_rate_sum = scaler_rate_sum.c

Definition at line 53 of file decay_ana_module.cxx.

DECAYANAMODULE_PARAM decay_ana_param

Definition at line 44 of file decay_ana_module.cxx.

EXP_EDIT exp_edit

Definition at line 84 of file analyzer.cxx.

EXP_PARAM exp_param

Definition at line 85 of file analyzer.cxx.

TFolder* gManaHistosFolder

Referenced by sc_eor(), and write_histogram_file().

TFolder* gRunHeader = NULL
static

Definition at line 107 of file analyzer.cxx.

Referenced by analyzer_init(), and write_histogram_file().

TMusrRunHeader* header = NULL
static

Definition at line 109 of file analyzer.cxx.

Referenced by analyzer_init(), update_run_header(), and write_histogram_file().

HV_EVENT hv_event

Definition at line 95 of file analyzer.cxx.

DWORD last_histogram_write
static

Definition at line 112 of file analyzer.cxx.

Referenced by analyzer_init(), and analyzer_loop().

DWORD last_update_info_write
static

Definition at line 113 of file analyzer.cxx.

Referenced by analyzer_init(), and analyzer_loop().

ANA_MODULE mcp1_ana_module

Definition at line 49 of file mcp1_ana_module.cxx.

MEAN_BANK mean

Definition at line 51 of file sc_ana_module.cxx.

INT odb_size = DEFAULT_ODB_SIZE

Definition at line 77 of file analyzer.cxx.

ANA_MODULE pileup_ana_module

Definition at line 48 of file pileup_ana_module.cxx.

POSI_BANK posi_bank

Definition at line 91 of file analyzer.cxx.

RATE_BANK rate_bank

Definition at line 87 of file analyzer.cxx.

float rotation_angle
static

Definition at line 120 of file analyzer.cxx.

Referenced by analyzer_init(), and set_spin_rot_angle().

char runname[256]
ANA_MODULE sc_ana_module

Definition at line 63 of file sc_ana_module.cxx.

SCANAMODULE_PARAM sc_ana_param

Definition at line 52 of file sc_ana_module.cxx.

BANK_LIST sc_bank_list[]
Initial value:
= {
{ "DBEA", TID_FLOAT},
{ "MBEA", TID_FLOAT},
{ "MVAC", TID_FLOAT},
{ "MMOD", TID_FLOAT},
{ "MSAM", TID_FLOAT},
{ "M900", TID_FLOAT},
{ "MHVT", TID_FLOAT},
{ "MHVD", TID_FLOAT},
{ "MWAV", TID_DOUBLE},
{ "" },
}

Definition at line 179 of file analyzer.cxx.

ANA_MODULE* sc_module[]
Initial value:
= {
NULL
}
ANA_MODULE sc_ana_module

Definition at line 146 of file analyzer.cxx.

BANK_LIST scaler_bank_list[]
Initial value:
= {
{ "SCL0", TID_DWORD},
{ "SSUM", TID_DOUBLE},
{ "RATE", TID_STRUCT, sizeof(rate_bank), (char **)rate_bank_str },
{ "SRAT", TID_STRUCT, sizeof(srat_bank), (char **)srat_bank_str },
{ "RAAV", TID_INT},
{ "" },
}
RATE_BANK rate_bank
Definition: analyzer.cxx:87
SRAT_BANK srat_bank
Definition: analyzer.cxx:89

Definition at line 167 of file analyzer.cxx.

ANA_MODULE* scaler_module[]
Initial value:
= {
NULL
}
ANA_MODULE scaler_rate_sum

Definition at line 141 of file analyzer.cxx.

ANA_MODULE scaler_rate_sum

Definition at line 41 of file scaler_rate_sum.cxx.

SCALER_SETTINGS scaler_settings

Definition at line 86 of file analyzer.cxx.

Referenced by scaler_mode().

SCS2001M_EVENT scs2001m_event

Definition at line 97 of file analyzer.cxx.

SRAT_BANK srat_bank

Definition at line 89 of file analyzer.cxx.

INT sum_count
static

Definition at line 118 of file analyzer.cxx.

Referenced by ana_begin_of_run(), analyzer_init(), and analyzer_loop().

T0SHIFT_PARAM t0shift_param

Definition at line 99 of file analyzer.cxx.

TDSAMPLETOF_PARAM tdsampletof_param

Definition at line 100 of file analyzer.cxx.

ANA_MODULE tof_ana_module

Definition at line 57 of file tof_ana_module.cxx.

BANK_LIST trigger_bank_list[]
Initial value:
= {
{ "TDC0", TID_DWORD},
{ "POSI", TID_STRUCT, sizeof(posi_bank), (char **)posi_bank_str },
{ "" },
}
POSI_BANK posi_bank
Definition: analyzer.cxx:91

Define the list of MIDAS banks to be used. The analyser can either read MIDAS banks sent by other MIDAS clients (from the frontends, for example), or create new BANKS which can be used for subsequent analysis steps.

Definition at line 158 of file analyzer.cxx.

ANA_MODULE* trigger_module[]
Initial value:
= {
NULL
}
ANA_MODULE tof_ana_module
ANA_MODULE mcp1_ana_module
ANA_MODULE pileup_ana_module
ANA_MODULE decay_ana_module

Definition at line 133 of file analyzer.cxx.

TRIGGER_SETTINGS trigger_settings

Definition at line 93 of file analyzer.cxx.

INT versionCounter

Definition at line 80 of file analyzer.cxx.

Referenced by ana_begin_of_run(), and write_histogram_file().

VME_STATS vme_stats

Required ODB structures.

Definition at line 82 of file analyzer.cxx.

INT write_flag
static

Definition at line 117 of file analyzer.cxx.

Referenced by ana_begin_of_run(), analyzer_init(), and analyzer_loop().