Low-Energy Muon (LEM) Experiment  0.5.1
analyzer.c File Reference
#include <vector>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.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.c:

Go to the source code of this file.

Macros

#define HISTOGRAM_WRITE_PERIOD   300
 
#define UPDATE_INFO_PERIOD   10
 
#define UPDATE_INFO_PERIOD_INTEL   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_intel_log (INTEL_LOG *info)
 
INT read_ipmi_log (IPMI_LOG *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
 
RUNINFO runinfo
 Required ODB structures. More...
 
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
 /Equipment/Trigger/Settings More...
 
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 126 of file analyzer.c.

Referenced by analyzer_loop().

#define UPDATE_INFO_PERIOD   10

Definition at line 127 of file analyzer.c.

Referenced by analyzer_loop().

#define UPDATE_INFO_PERIOD_INTEL   300

Definition at line 128 of file analyzer.c.

Referenced by read_intel_log(), and read_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 736 of file analyzer.c.

References disp_scaler(), N_SCALER, and runinfo.

INT ana_resume_run ( INT  run_number,
char *  error 
)

Definition at line 745 of file analyzer.c.

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

INT analyzer_exit ( )

Definition at line 582 of file analyzer.c.

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 2633 of file analyzer.c.

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 961 of file analyzer.c.

References INFO::energy_loss_parameter, info, 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 924 of file analyzer.c.

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 987 of file analyzer.c.

References INFO::bpar, INFO::helmholtz, info, 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 887 of file analyzer.c.

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 1396 of file analyzer.c.

References HV_EVENT::demand, energy_loss(), hDB, hKey, hv_event, info, INFO::leff_RAoff, INFO::leff_RAon, INFO::lem_setup, INFO::magnetic_field, SCANAMODULE_PARAM::mod_hv_channel, N_DECAY_HISTS, sc_ana_param, 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 1498 of file analyzer.c.

References HV_EVENT::demand, TDSAMPLETOF_PARAM::dl3, TDSAMPLETOF_PARAM::dra, TDSAMPLETOF_PARAM::dtotalp0, TDSAMPLETOF_PARAM::dtotalp1, energy_loss(), hDB, hKey, hv_event, info, 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, INFO::t0Hist, and tdsampletof_param.

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 2730 of file analyzer.c.

References INFO::a0, INFO::a1, INFO::a2, INFO::a3, INFO::a4, HV_EVENT::demand, hv_event, info, SCANAMODULE_PARAM::mod_hv_channel, rotation_angle, sc_ana_param, 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 2693 of file analyzer.c.

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

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 806 of file analyzer.c.

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

Referenced by analyzer_loop().

Variable Documentation

ANALYZE_REQUEST analyze_request[]

Definition at line 206 of file analyzer.c.

INT analyzer_loop_period = 1000

Definition at line 87 of file analyzer.c.

const char* analyzer_name = "Analyzer"

Definition at line 84 of file analyzer.c.

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.c.

DECAYANAMODULE_PARAM decay_ana_param

Definition at line 44 of file decay_ana_module.c.

Referenced by update_run_header().

EXP_EDIT exp_edit

Definition at line 96 of file analyzer.c.

EXP_PARAM exp_param

Definition at line 97 of file analyzer.c.

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

TFolder* gManaHistosFolder

Referenced by sc_eor(), and write_histogram_file().

TFolder* gRunHeader = NULL
static

Definition at line 119 of file analyzer.c.

Referenced by analyzer_init(), and write_histogram_file().

TMusrRunHeader* header = NULL
static

Definition at line 121 of file analyzer.c.

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

HV_EVENT hv_event

Definition at line 107 of file analyzer.c.

INFO info

Definition at line 106 of file analyzer.c.

DWORD last_histogram_write
static

Definition at line 124 of file analyzer.c.

Referenced by analyzer_init(), and analyzer_loop().

DWORD last_update_info_write
static

Definition at line 125 of file analyzer.c.

Referenced by analyzer_init(), and analyzer_loop().

ANA_MODULE mcp1_ana_module

Definition at line 51 of file mcp1_ana_module.c.

MEAN_BANK mean

Definition at line 52 of file sc_ana_module.c.

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

INT odb_size = DEFAULT_ODB_SIZE

Definition at line 90 of file analyzer.c.

ANA_MODULE pileup_ana_module

Definition at line 50 of file pileup_ana_module.c.

POSI_BANK posi_bank

Definition at line 103 of file analyzer.c.

RATE_BANK rate_bank

Definition at line 99 of file analyzer.c.

float rotation_angle
static

Definition at line 132 of file analyzer.c.

Referenced by analyzer_init(), and set_spin_rot_angle().

RUNINFO runinfo

Required ODB structures.

/Runinfo ODB key, defined in from midas.h

Definition at line 95 of file analyzer.c.

char runname[256]
ANA_MODULE sc_ana_module

Definition at line 64 of file sc_ana_module.c.

SCANAMODULE_PARAM sc_ana_param

Definition at line 53 of file sc_ana_module.c.

Referenced by get_t0(), sc_ana(), sc_eor(), set_spin_rot_angle(), and update_info().

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},
{ "" },
}

Definition at line 191 of file analyzer.c.

ANA_MODULE* sc_module[]
Initial value:
= {
NULL
}
ANA_MODULE sc_ana_module
Definition: sc_ana_module.c:64

Definition at line 158 of file analyzer.c.

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.c:99
SRAT_BANK srat_bank
Definition: analyzer.c:101

Definition at line 179 of file analyzer.c.

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

Definition at line 153 of file analyzer.c.

ANA_MODULE scaler_rate_sum

Definition at line 41 of file scaler_rate_sum.c.

SCALER_SETTINGS scaler_settings

/Equipment/Scaler/Settings/

Definition at line 98 of file analyzer.c.

SCS2001M_EVENT scs2001m_event

Definition at line 109 of file analyzer.c.

SRAT_BANK srat_bank

Definition at line 101 of file analyzer.c.

Referenced by ana_begin_of_run(), and analyzer_init().

INT sum_count
static

Definition at line 130 of file analyzer.c.

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

T0SHIFT_PARAM t0shift_param

Definition at line 111 of file analyzer.c.

Referenced by analyzer_init(), and update_t0shift().

TDSAMPLETOF_PARAM tdsampletof_param

Definition at line 112 of file analyzer.c.

Referenced by analyzer_init(), and get_t0L3RA().

ANA_MODULE tof_ana_module

Definition at line 54 of file tof_ana_module.c.

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.c:103

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 170 of file analyzer.c.

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

Definition at line 145 of file analyzer.c.

TRIGGER_SETTINGS trigger_settings

/Equipment/Trigger/Settings

The following structures are defined in experim.h that is created by entering 'make' in ODBedit.

ODB record values can be easily accessed by db_open_record which creates a hot-link to the structure; structure_name.keyvalue

Definition at line 105 of file analyzer.c.

INT versionCounter

Definition at line 93 of file analyzer.c.

Referenced by ana_begin_of_run(), and write_histogram_file().

INT write_flag
static

Definition at line 129 of file analyzer.c.

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