57 #define VISUAL_CPLUSPLUS
75 #include <TDirectory.h>
78 #include <TMusrRunHeader.h>
122 static TObjArray
Slist(0);
126 #define HISTOGRAM_WRITE_PERIOD 300 // write histograms every 300s to file
127 #define UPDATE_INFO_PERIOD 10 // update info structure with eloss and B-field every 10sec
128 #define UPDATE_INFO_PERIOD_INTEL 300 // update lem00 intel log info structure every 300s
172 {
"TDC0", TID_DWORD},
175 {
"POSI", TID_STRUCT,
sizeof(
posi_bank), (
char **)posi_bank_str },
181 {
"SCL0", TID_DWORD},
184 {
"SSUM", TID_DOUBLE},
185 {
"RATE", TID_STRUCT,
sizeof(
rate_bank), (
char **)rate_bank_str },
186 {
"SRAT", TID_STRUCT,
sizeof(
srat_bank), (
char **)srat_bank_str },
192 {
"DBEA", TID_FLOAT},
193 {
"MBEA", TID_FLOAT},
194 {
"MVAC", TID_FLOAT},
195 {
"MMOD", TID_FLOAT},
196 {
"MSAM", TID_FLOAT},
197 {
"M900", TID_FLOAT},
198 {
"MHVT", TID_FLOAT},
199 {
"MHVD", TID_FLOAT},
277 char fname[256], exp_name[32];
278 char lazy_fname[128];
283 BOOL flag_Bpar,flag_spinrot;
285 RUNINFO_STR(runinfo_str);
298 cm_get_experiment_database(&hDB, NULL);
300 db_create_record(hDB, 0,
"/Runinfo", strcomb(runinfo_str));
301 db_find_key(hDB, 0,
"/Runinfo", &hKey);
302 if (db_open_record(hDB, hKey, &
runinfo,
sizeof(
runinfo), MODE_READ, NULL, NULL) != DB_SUCCESS) {
303 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Runinfo\" tree in ODB");
307 db_create_record(hDB, 0,
"/Experiment/Run Parameters", strcomb(exp_param_str));
308 db_find_key(hDB, 0,
"/Experiment/Run Parameters", &hKey);
309 if (db_open_record(hDB, hKey, &
exp_param,
sizeof(
exp_param), MODE_READ, NULL, NULL) != DB_SUCCESS) {
310 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Experiment/Run Parameters\" tree in ODB");
314 sprintf(str,
"/Experiment/Name");
315 size =
sizeof(exp_name);
316 if (db_get_value(hDB, 0, str, exp_name, &size, TID_STRING, TRUE) != DB_SUCCESS ) {
317 sprintf(exp_name,
"nemu");
320 db_create_record(hDB, 0,
"/Experiment/Edit on start", strcomb(exp_edit_str));
321 db_find_key(hDB, 0,
"/Equipment/Trigger/Settings", &hKey);
323 NULL, NULL) != DB_SUCCESS) {
324 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/Trigger/Settings\" tree in ODB");
328 db_create_record(hDB, 0,
"/Equipment/Scaler/Settings", strcomb(scaler_settings_str));
329 db_find_key(hDB, 0,
"/Equipment/Scaler/Settings", &hKey);
331 NULL, NULL) != DB_SUCCESS) {
332 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/Scaler/Settings\" tree in ODB");
337 db_create_record(hDB, 0, str, strcomb(t0shift_param_str));
338 db_find_key(hDB, 0, str, &hKey);
340 MODE_READ, NULL, NULL) != DB_SUCCESS) {
341 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"%s\" tree in ODB", str);
347 db_create_record(hDB, 0, str, strcomb(tdsampletof_param_str));
348 db_find_key(hDB, 0, str, &hKey);
350 MODE_READ, NULL, NULL) != DB_SUCCESS) {
351 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"%s\" tree in ODB", str);
356 db_create_record(hDB, 0,
"/Info", strcomb(info_str));
357 db_find_key(hDB, 0,
"/Info", &hKey);
358 if (db_open_record(hDB, hKey, &
info,
sizeof(
info), MODE_READ, NULL, NULL) != DB_SUCCESS) {
359 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Info\" tree in ODB");
363 db_find_key(hDB, 0,
"/Info/LEM_Setup_Parameter/Bpar", &hKey);
364 if (db_open_record(hDB, hKey, &flag_Bpar,
sizeof(BOOL), MODE_READ, &
update_t0shift, NULL) != DB_SUCCESS) {
365 cm_msg(MERROR,
"analyzer_init",
"Cannot open /Info/LEM_Setup_Parameter/Bpar tree in ODB");
370 db_find_key(hDB, 0,
"/Info/SpinRot_Parameter/RotationAngle", &hKey);
372 cm_msg(MERROR,
"analyzer_init",
"Cannot open /Info/SpinRot_Parameter/RotationAngle tree in ODB");
377 db_find_key(hDB, 0,
"/Equipment/HV/Variables", &hKey);
378 if (db_open_record(hDB, hKey, &
hv_event,
sizeof(
hv_event), MODE_READ, NULL, NULL) != DB_SUCCESS) {
379 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/HV/Variables\" tree in ODB");
398 db_find_key(hDB, 0,
"/Equipment/SCS2001M/Variables", &hKey);
400 MODE_READ, NULL, NULL) != DB_SUCCESS) {
401 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/SCS2001M/Variables\" tree in ODB");
405 db_create_record(hDB, 0,
"/Equipment/SlowControl/Variables/MEAN", strcomb(mean_bank_str));
406 db_find_key(hDB, 0,
"/Equipment/SlowControl/Variables/MEAN", &hKey);
407 if (db_open_record(hDB, hKey, &
mean,
sizeof(
mean), MODE_READ, NULL, NULL) != DB_SUCCESS) {
408 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/SlowControl/Variables/MEAN\" tree in ODB");
416 if ( db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SRAT", &hKey) == DB_SUCCESS ) {
439 if (
runinfo.online_mode == 1) {
441 tms = localtime(&now);
444 size =
sizeof(fname);
446 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
447 sprintf(fname,
"lem%02d_%%04d.asc", tms->tm_year%100);
448 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
451 sprintf(str,
"/%s/Output/Histo Dump Filename",
analyzer_name);
452 size =
sizeof(fname);
455 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
457 sprintf(fname,
"../his/%04d/lem%02d_%%04d.hsn", tms->tm_year+1900, tms->tm_year%100);
458 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
461 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
462 sprintf(fname,
"../his/%04d/lem%02d_his_%%04d.root", tms->tm_year+1900, tms->tm_year%100);
463 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
469 sprintf(str,
"/Logger/Data dir");
470 size =
sizeof(fname);
471 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
472 sprintf(fname,
"/data/%s/dlog", exp_name);
473 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
476 sprintf(str,
"/Logger/Message file");
477 size =
sizeof(fname);
478 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
479 sprintf(fname,
"/data/%s/midas.log", exp_name);
480 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
483 sprintf(str,
"/Logger/ODB Dump File");
484 size =
sizeof(fname);
485 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
486 sprintf(fname,
"/data/%s/odb/%04d/lem%02d_%%04d.odb", exp_name, tms->tm_year+1900, tms->tm_year%100);
487 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
490 sprintf(str,
"/Logger/Channels/0/Settings/Filename");
491 size =
sizeof(fname);
492 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
493 sprintf(fname,
"lem%02d_%%04d.root", tms->tm_year%100);
494 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
497 sprintf(str,
"/Logger/History Dir");
498 sprintf(fname,
"/data/%s/history", exp_name);
499 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
501 sprintf(str,
"/Logger/History Path");
503 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
505 sprintf(str,
"/Logger/Elog Dir");
507 sprintf(fname,
"/home/nemu/elog/LEM_Experiment");
508 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
511 sprintf(str,
"/Lazy/FTP/Settings/Filename format");
512 size =
sizeof(lazy_fname);
513 if ( db_get_value(hDB, 0, str, lazy_fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
514 sprintf(lazy_fname,
"lem%02d_%%04d.root", tms->tm_year%100);
515 db_set_value(hDB, 0, str, &lazy_fname, size, 1, TID_STRING);
548 size =
sizeof(fname);
549 db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE);
554 sprintf(timestr,
"%s", ctime(&now));
556 db_set_value(hDB, 0,
"/Info/Scaler Update time", ×tr,
sizeof(timestr), 1, TID_STRING);
562 gRunHeader = gROOT->GetRootFolder()->AddFolder(
"RunHeader",
"LEM Run Header Info");
563 gROOT->GetListOfBrowsables()->Add(
gRunHeader,
"RunHeader");
565 header =
new TMusrRunHeader(
true);
569 Slist.SetName(
"RunSummary");
593 cm_get_experiment_database(&hDB, NULL);
599 if ( db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SRAT", &hkey) == DB_SUCCESS ) {
605 if (
runinfo.online_mode == 1) {
632 al_trigger_alarm(
"ana_begin_of_run",
"Beam Shutters KV61/62 still closed at begin-of-run!",
633 "Warning",
"BeamLine Shutters KV61/62 still closed at BOR!", AT_INTERNAL);
644 char str[256], logdir[256], cmd[256], file_name[256];
646 INT size, len, status;
651 cm_get_experiment_database(&hDB, NULL);
655 db_get_value(hDB, 0,
"/Logger/Write data", &flag, &size, TID_BOOL, FALSE);
656 if (flag &&
runinfo.online_mode == 1) {
662 db_get_value(hDB, 0,
"/Logger/Data Dir", str, &size, TID_STRING, FALSE);
664 if (str[strlen(str)-1] != DIR_SEPARATOR)
665 strcat(str, DIR_SEPARATOR_STR);
667 strcat(str,
"runlog.txt");
668 strcpy(file_name, str);
669 f = fopen(file_name,
"a");
672 strcpy(str, ctime(&now));
680 fprintf(f,
"%5d\t%s %s",
runinfo.run_number, str, year);
682 strcpy(str,
runinfo.start_time);
684 fprintf(f,
"::%s --- ", str+11);
686 strcpy(str, ctime(&now));
688 fprintf(f,
"%s\t", str+11);
691 db_get_value(hDB, 0,
"/Equipment/Trigger/Statistics/Events sent", &n, &size, TID_DOUBLE, FALSE);
693 fprintf(f,
"%6.1lfk\t", n/1000);
701 runinfo.stop_time_binary = now;
702 strcpy(
runinfo.stop_time, ctime(&now));
705 len = strlen(
runinfo.stop_time);
706 if (
runinfo.stop_time[len-1] ==
'\n' )
717 db_set_value(hDB, 0,
"/Runinfo/State", &
runinfo.state,
sizeof(
runinfo.state), 1, TID_INT);
718 db_set_value(hDB, 0,
"/Runinfo/Stop time", &
runinfo.stop_time,
719 sizeof(
runinfo.stop_time), 1, TID_STRING);
720 db_set_value(hDB, 0,
"/Runinfo/Stop time binary", &
runinfo.stop_time_binary,
721 sizeof(
runinfo.stop_time_binary), 1, TID_DWORD);
724 ss_printf(0,50,
"Rates at EOR are a v e r a g e d rates !");
749 cm_get_experiment_database(&hDB, NULL);
753 al_trigger_alarm(
"ana_begin_of_run",
"Beam Shutters KV61/62 still closed at run resume!",
754 "Warning",
"BeamLine Shutters KV61/62 still closed at run resume!", AT_INTERNAL);
765 DWORD nowtime, difftime;
771 last_update_info_write = nowtime;
774 if (
runinfo.state == STATE_PAUSED )
return CM_SUCCESS;
776 if (
runinfo.state == STATE_RUNNING ) {
782 last_histogram_write = nowtime;
809 char fname[256], str[256], file_name[256], save_file_name[256], cmd[256];
812 cm_get_experiment_database(&hDB, NULL);
813 sprintf(str,
"/%s/Output/Histo Dump Filename",
analyzer_name);
814 size =
sizeof(fname);
815 db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE);
817 if (strchr(fname,
'%') != NULL)
818 sprintf(file_name, fname,
runinfo.run_number);
820 strcpy(file_name, fname);
822 db_find_key(hDB, 0,
"/Logger/Data dir", &hkey);
825 db_get_data(hDB, hkey, str, &size, TID_STRING);
826 if (str[strlen(str) - 1] != DIR_SEPARATOR)
827 strcat(str, DIR_SEPARATOR_STR);
828 strcat(str, file_name);
829 strcpy(file_name, str);
832 strcpy(save_file_name, file_name);
840 strcat(file_name, str);
845 TDirectory *savedir = gDirectory;
846 TFile *outf =
new TFile(file_name,
"RECREATE",
"Midas Analyzer Histograms");
848 cm_msg(MERROR,
"SaveRootHistograms",
"Cannot create output file %s", file_name);
856 cm_msg(MERROR,
"write_histogram_file",
"analyzer error: couldn't fill the run header information!");
865 status = gSystem->CopyFile(file_name, save_file_name, kTRUE);
868 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (file open failure of %s)", file_name);
869 }
else if (status == -2) {
870 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (write protection error of %s)", save_file_name);
871 }
else if (status == -3) {
872 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (error during copying (%s->%s))", file_name, save_file_name);
891 char dir[256], filebody[256];
896 if ( getenv(
"MIDAS_DATA") ) {
897 strcpy(dir, getenv(
"MIDAS_DATA"));
898 strcat(dir, DIR_SEPARATOR_STR);
900 strcat(dir, DIR_SEPARATOR_STR);
902 #if defined (OS_UNIX)
903 strcpy(dir, getenv(
"HOME"));
904 #elif defined (OS_WINNT)
905 strcpy(dir, getenv(
"HOMEPATH"));
907 strcat(dir, DIR_SEPARATOR_STR);
908 cm_msg(MINFO,
"get_sum_filename",
909 "MIDAS_DATA path not defined, use home directory %s instead\n", dir);
913 tms = localtime(&now);
915 strcpy(filename, dir);
916 sprintf(filebody,
"%04d/lem%02d_%04d.summ", tms->tm_year+1900, tms->tm_year%100,
runinfo.run_number);
917 strcat(filename, filebody);
927 char fileName[256],
line[256], enumline[256];
933 FILE *fp = fopen(fileName,
"r");
935 printf(
"File %s does not exist!\n", fileName);
939 while (fgets(line,256,fp)) {
940 sprintf(enumline,
"%04d ", i);
941 strcat(enumline, line);
942 s =
new TObjString(enumline);
963 float deltaE, x, p0, p1, p2, p3;
965 if ( moderator_hv > 20.1 ) {
973 deltaE = p0 + p1*x + p2*x*x + p3*x*x*x;
989 float Bfield, x, p0, p1;
1005 Bfield = p0 + p1*current;
1017 INT i, size, result;
1018 float eloss, impEnergy, modHV, sampleHV, current, Bfield;
1019 char lem_setup[
STR_SIZE], lem_cryostat[NAME_LENGTH], old_lem_cryostat[NAME_LENGTH];
1021 BOOL flag, cryo_not_found;
1025 cm_get_experiment_database(&hDB, NULL);
1031 impEnergy = modHV - eloss - sampleHV;
1032 db_set_value(hDB, 0,
"/Info/Energy Loss (C-foil)", &eloss,
sizeof(eloss), 1, TID_FLOAT);
1033 db_set_value(hDB, 0,
"/Info/Implantation Energy (keV)", &impEnergy,
sizeof(impEnergy), 1, TID_FLOAT);
1040 current = current/10. * 500.;
1042 size =
sizeof(float);
1043 db_get_value(hDB, 0,
"/Equipment/Bruker/Variables/Input[3]", ¤t, &size, TID_FLOAT, FALSE);
1047 db_set_value(hDB, 0,
"/Info/Magnetic Field (G)", &Bfield,
sizeof(Bfield), 1, TID_FLOAT);
1057 db_find_key(hDB, 0,
"/Info/Lem00IPMILog", &hKey);
1058 db_set_record(hDB, hKey, &info,
sizeof(info), 0);
1079 char lem_setup[
STR_SIZE+NAME_LENGTH];
1080 char str[256], str1[256], str2[256], *p_str;
1081 double ip_sum, scaler_clock_sum, tdc_clock_sum, n_events, dval;
1082 double td_sum, td_clean_sum, td_good_sum, pos_sum[
N_DECAY_HISTS];
1086 cm_get_experiment_database(&hDB, NULL);
1097 header->Set(
"RunInfo/Generic Validator URL",
"http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
1098 header->Set(
"RunInfo/Specific Validator URL",
"http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRootLEM.xsd");
1099 header->Set(
"RunInfo/Generator",
"nemu_analyzer");
1107 db_find_key(hDB, 0,
"/Analyzer/Output/Histo Dump Filename", &hKey);
1108 db_get_data(hDB, hKey, &str, &size, TID_STRING);
1116 }
while (str[i] !=
'\0');
1118 cm_msg(MERROR,
"update_run_header",
"Couldn't obtain run file name template! ODB corrupted?");
1123 strcpy(str1, p_str);
1124 p_str = strstr(str1,
"%");
1126 cm_msg(MERROR,
"update_run_header",
"Wrong run file name template! ODB corrupted?");
1130 sprintf(str,
"%04d.root",
runinfo.run_number);
1132 header->Set(
"RunInfo/File Name", str1);
1138 time_bin = (long)
runinfo.start_time_binary;
1139 struct tm *tm = localtime((time_t*)&time_bin);
1140 strftime(str,
sizeof(str),
"%F %T", tm);
1141 header->Set(
"RunInfo/Run Start Time", str);
1142 time_bin = (long)
runinfo.stop_time_binary;
1143 tm = localtime((time_t*)&time_bin);
1144 strftime(str,
sizeof(str),
"%F %T", tm);
1145 header->Set(
"RunInfo/Run Stop Time", str);
1149 ival = (int)
runinfo.stop_time_binary - (
int)
runinfo.start_time_binary;
1151 TMusrRunPhysicalQuantity prop;
1152 prop.Set(
"Run Duration", ival,
"sec");
1153 header->Set(
"RunInfo/Run Duration", prop);
1155 header->Set(
"RunInfo/Laboratory",
"PSI");
1156 header->Set(
"RunInfo/Instrument",
"LEM");
1158 prop.Set(
"Muon Beam Momentum", 28.1,
"MeV/c");
1159 header->Set(
"RunInfo/Muon Beam Momentum", prop);
1161 header->Set(
"RunInfo/Muon Species",
"positive muon");
1162 header->Set(
"RunInfo/Muon Source",
"Target E - Low Energy Muons");
1163 header->Set(
"RunInfo/Setup", lem_setup);
1164 header->Set(
"RunInfo/Comment",
"n/a");
1168 header->Set(
"RunInfo/Sample Temperature", prop);
1170 header->Set(
"RunInfo/Sample Magnetic Field", prop);
1174 prop.Set(
"Time Resolution", 0.1953125,
"ns",
"TDC CAEN V1190");
1175 header->Set(
"RunInfo/Time Resolution", prop);
1181 header->Set(
"RunInfo/RedGreen Offsets", ivec);
1187 header->Set(
"RunInfo/Moderator HV", prop);
1189 header->Set(
"RunInfo/Sample HV", prop);
1191 header->Set(
"RunInfo/Implantation Energy", prop);
1193 header->Set(
"RunInfo/Muon Spin Angle", prop);
1194 header->Set(
"RunInfo/Cuts",
"none");
1205 sprintf(str,
"DetectorInfo/Detector%03d", i+1);
1206 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1210 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1213 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1216 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1220 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1221 ival = (int) ceil(dval);
1224 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1232 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1236 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1239 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1242 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1246 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1247 ival = (int) ceil(dval);
1250 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1258 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1262 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1265 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1268 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1272 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1273 ival = (int) ceil(dval);
1276 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1284 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1288 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1291 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1294 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1298 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1299 ival = (int) ceil(dval);
1302 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1338 header->Set(
"BeamlineInfo/Name",
"muE4");
1348 size =
sizeof(double);
1349 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[0]", &ip_sum, &size, TID_DOUBLE, FALSE);
1350 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[1]", &scaler_clock_sum, &size, TID_DOUBLE, FALSE);
1351 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[4]", &td_sum, &size, TID_DOUBLE, FALSE);
1352 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[40]", &pos_sum[0], &size, TID_DOUBLE, FALSE);
1353 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[41]", &pos_sum[1], &size, TID_DOUBLE, FALSE);
1354 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[42]", &pos_sum[2], &size, TID_DOUBLE, FALSE);
1355 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[43]", &pos_sum[3], &size, TID_DOUBLE, FALSE);
1356 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[44]", &pos_sum[4], &size, TID_DOUBLE, FALSE);
1357 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[45]", &pos_sum[5], &size, TID_DOUBLE, FALSE);
1358 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[46]", &pos_sum[6], &size, TID_DOUBLE, FALSE);
1359 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[47]", &pos_sum[7], &size, TID_DOUBLE, FALSE);
1360 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/TD clean", &td_clean_sum, &size, TID_DOUBLE, FALSE);
1361 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/TD good" , &td_good_sum, &size, TID_DOUBLE, FALSE);
1362 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/channelCounts[1]" , &tdc_clock_sum, &size, TID_DOUBLE, FALSE);
1363 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/SlowMuonEvents" , &n_events, &size, TID_DOUBLE, FALSE);
1365 header->Set(
"ScalerInfo/Sum Ip", ip_sum);
1366 header->Set(
"ScalerInfo/Sum Clock (Scaler)", scaler_clock_sum);
1367 header->Set(
"ScalerInfo/Sum Clock (TDC)", tdc_clock_sum);
1368 header->Set(
"ScalerInfo/Sum Slow Muon Events", n_events);
1369 header->Set(
"ScalerInfo/Sum TD", td_sum);
1370 header->Set(
"ScalerInfo/Sum TD_Clean", td_clean_sum);
1371 header->Set(
"ScalerInfo/Sum TD_Good", td_good_sum);
1373 TIntVector posSumVec;
1374 for (
unsigned int i=0; i<8; i++)
1375 posSumVec.push_back((
int)pos_sum[i]);
1376 header->Set(
"ScalerInfo/Sum Positrons", posSumVec);
1401 float moderator_hv, energy_after_TD_XXkV;
1402 float tofXXkV, muon_mass, c_light, l_eff, scale;
1406 if (moderator_hv < 5.0)
1409 energy_after_TD_XXkV = moderator_hv -
energy_loss(moderator_hv);
1411 muon_mass = 105658.370;
1412 c_light = 299.792458;
1421 scale = l_eff/c_light*sqrt(muon_mass/2.);
1423 tofXXkV = scale/sqrt(energy_after_TD_XXkV);
1425 tofXXkV = tofXXkV/0.1953125;
1430 cm_get_experiment_database(&hDB, NULL);
1431 db_find_key(hDB, 0,
"/Info/t0_parameter/t0", &hKey);
1432 db_set_record(hDB, hKey, &t0,
sizeof(t0), 0);
1503 float moderatorHV, energyAfterTD;
1504 float tofXXkV, muonMass, cLight;
1505 float dTotal, dFree, dL3, dRA;
1506 float tofFree, tofL3, tofRA;
1507 float scaleL3, scaleRA;
1512 if (moderatorHV < 5.0)
1515 energyAfterTD = moderatorHV -
energy_loss(moderatorHV);
1516 muonMass = 105658.37;
1517 cLight = 299.792458;
1529 dFree = dTotal - dL3 - dRA;
1532 UL3 = scaleL3 * UL3;
1533 URA = scaleRA * URA;
1535 if ( UL3 == 0. ) UL3 = 0.0001;
1536 if ( URA == 0. ) URA = 0.0001;
1539 tofFree = dFree/sqrt(2.*energyAfterTD/muonMass)/cLight;
1540 if (UL3 <= energyAfterTD)
1541 tofL3 = dL3/UL3/cLight * sqrt(2.*muonMass*energyAfterTD) * (1. - sqrt(1.-UL3/energyAfterTD));
1543 tofL3 = dL3/UL3/cLight * sqrt(2.*muonMass*energyAfterTD);
1544 if (URA <= energyAfterTD)
1545 tofRA = dRA/URA/cLight * sqrt(2.*muonMass*energyAfterTD) * (1. - sqrt(1.-URA/energyAfterTD));
1547 tofRA = dRA/URA/cLight * sqrt(2.*muonMass*energyAfterTD);
1549 tofXXkV = tofFree + tofL3 + tofRA;
1550 tofXXkV = tofXXkV/0.1953125;
1555 cm_get_experiment_database(&hDB, NULL);
1556 db_find_key(hDB, 0,
"/Info/t0_parameter/t0", &hKey);
1557 db_set_record(hDB, hKey, &t0,
sizeof(t0), 0);
1631 char line[128], *str_p;
1635 static DWORD last = 0;
1660 info->
vtt = -9999.0;
1667 info->
p1_1v = -9999.0;
1668 info->
p1_5v = -9999.0;
1669 info->
p3_3v = -9999.0;
1671 info->
p5v = -9999.0;
1672 info->
p5vsb = -9999.0;
1673 info->
p12v = -9999.0;
1674 info->
vbat = -9999.0;
1679 fp = fopen(
"/var/log/lem00.psi.ch_ipmi.log",
"r");
1681 printf(
"\nCouldn't open log file.\n");
1686 fgets(line,
sizeof(line), fp);
1689 if (strstr(line,
"CPU1 Temp")) {
1690 str_p = strstr(line,
"|");
1691 if (str_p == NULL) {
1695 status = sscanf(str_p+1,
"%f", &fval);
1701 }
else if (strstr(line,
"CPU2 Temp")) {
1702 str_p = strstr(line,
"|");
1703 if (str_p == NULL) {
1707 status = sscanf(str_p+1,
"%f", &fval);
1713 }
else if (strstr(line,
"System Temp")) {
1714 str_p = strstr(line,
"|");
1715 if (str_p == NULL) {
1719 status = sscanf(str_p+1,
"%f", &fval);
1725 }
else if (strstr(line,
"Peripheral Temp")) {
1726 str_p = strstr(line,
"|");
1727 if (str_p == NULL) {
1731 status = sscanf(str_p+1,
"%f", &fval);
1737 }
else if (strstr(line,
"PCH Temp")) {
1738 str_p = strstr(line,
"|");
1739 if (str_p == NULL) {
1743 status = sscanf(str_p+1,
"%f", &fval);
1749 }
else if (strstr(line,
"P1-DIMMA1 TEMP")) {
1750 str_p = strstr(line,
"|");
1751 if (str_p == NULL) {
1755 status = sscanf(str_p+1,
"%f", &fval);
1761 }
else if (strstr(line,
"P1-DIMMB1 TEMP")) {
1762 str_p = strstr(line,
"|");
1763 if (str_p == NULL) {
1767 status = sscanf(str_p+1,
"%f", &fval);
1773 }
else if (strstr(line,
"P2-DIMME1 TEMP")) {
1774 str_p = strstr(line,
"|");
1775 if (str_p == NULL) {
1779 status = sscanf(str_p+1,
"%f", &fval);
1785 }
else if (strstr(line,
"P2-DIMMF1 TEMP")) {
1786 str_p = strstr(line,
"|");
1787 if (str_p == NULL) {
1791 status = sscanf(str_p+1,
"%f", &fval);
1797 }
else if (strstr(line,
"FAN1")) {
1798 str_p = strstr(line,
"|");
1799 if (str_p == NULL) {
1803 status = sscanf(str_p+1,
"%d", &ival);
1809 }
else if (strstr(line,
"FAN2")) {
1810 str_p = strstr(line,
"|");
1811 if (str_p == NULL) {
1815 status = sscanf(str_p+1,
"%d", &ival);
1821 }
else if (strstr(line,
"FAN3")) {
1822 str_p = strstr(line,
"|");
1823 if (str_p == NULL) {
1827 status = sscanf(str_p+1,
"%d", &ival);
1833 }
else if (strstr(line,
"FAN5")) {
1834 str_p = strstr(line,
"|");
1835 if (str_p == NULL) {
1839 status = sscanf(str_p+1,
"%d", &ival);
1845 }
else if (strstr(line,
"FAN6")) {
1846 str_p = strstr(line,
"|");
1847 if (str_p == NULL) {
1851 status = sscanf(str_p+1,
"%d", &ival);
1857 }
else if (strstr(line,
"VTT")) {
1858 str_p = strstr(line,
"|");
1859 if (str_p == NULL) {
1863 status = sscanf(str_p+1,
"%f", &fval);
1869 }
else if (strstr(line,
"CPU1 Vcore")) {
1870 str_p = strstr(line,
"|");
1871 if (str_p == NULL) {
1875 status = sscanf(str_p+1,
"%f", &fval);
1881 }
else if (strstr(line,
"CPU2 Vcore")) {
1882 str_p = strstr(line,
"|");
1883 if (str_p == NULL) {
1887 status = sscanf(str_p+1,
"%f", &fval);
1893 }
else if (strstr(line,
"VDIMM AB")) {
1894 str_p = strstr(line,
"|");
1895 if (str_p == NULL) {
1899 status = sscanf(str_p+1,
"%f", &fval);
1905 }
else if (strstr(line,
"VDIMM CD")) {
1906 str_p = strstr(line,
"|");
1907 if (str_p == NULL) {
1911 status = sscanf(str_p+1,
"%f", &fval);
1917 }
else if (strstr(line,
"VDIMM EF")) {
1918 str_p = strstr(line,
"|");
1919 if (str_p == NULL) {
1923 status = sscanf(str_p+1,
"%f", &fval);
1929 }
else if (strstr(line,
"VDIMM GH")) {
1930 str_p = strstr(line,
"|");
1931 if (str_p == NULL) {
1935 status = sscanf(str_p+1,
"%f", &fval);
1941 }
else if (strstr(line,
"+1.1 V")) {
1942 str_p = strstr(line,
"|");
1943 if (str_p == NULL) {
1947 status = sscanf(str_p+1,
"%f", &fval);
1953 }
else if (strstr(line,
"+1.5 V")) {
1954 str_p = strstr(line,
"|");
1955 if (str_p == NULL) {
1959 status = sscanf(str_p+1,
"%f", &fval);
1965 }
else if (strstr(line,
"3.3V ")) {
1966 str_p = strstr(line,
"|");
1967 if (str_p == NULL) {
1971 status = sscanf(str_p+1,
"%f", &fval);
1977 }
else if (strstr(line,
"+3.3VSB")) {
1978 str_p = strstr(line,
"|");
1979 if (str_p == NULL) {
1983 status = sscanf(str_p+1,
"%f", &fval);
1989 }
else if (strstr(line,
"5V ")) {
1990 str_p = strstr(line,
"|");
1991 if (str_p == NULL) {
1995 status = sscanf(str_p+1,
"%f", &fval);
2001 }
else if (strstr(line,
"+5VSB")) {
2002 str_p = strstr(line,
"|");
2003 if (str_p == NULL) {
2007 status = sscanf(str_p+1,
"%f", &fval);
2013 }
else if (strstr(line,
"12V")) {
2014 str_p = strstr(line,
"|");
2015 if (str_p == NULL) {
2019 status = sscanf(str_p+1,
"%f", &fval);
2025 }
else if (strstr(line,
"VBAT")) {
2026 str_p = strstr(line,
"|");
2027 if (str_p == NULL) {
2031 status = sscanf(str_p+1,
"%f", &fval);
2037 }
else if (strstr(line,
"Chassis Intru")) {
2038 str_p = strstr(line,
"|");
2039 if (str_p == NULL) {
2043 status = sscanf(str_p+1,
"%d", &ival);
2049 }
else if (strstr(line,
"PS1 Status")) {
2050 str_p = strstr(line,
"|");
2051 if (str_p == NULL) {
2055 status = sscanf(str_p+1,
"%x", &ival);
2061 }
else if (strstr(line,
"PS2 Status")) {
2062 str_p = strstr(line,
"|");
2063 if (str_p == NULL) {
2067 status = sscanf(str_p+1,
"%x", &ival);
2093 char line[128], *str_p, ok_string[32];
2094 int status, ival[4];
2097 static DWORD last = 0;
2107 fp = fopen(
"/var/Intel/logs/lem01_ipmi.log",
"r");
2109 printf(
"\nCouldn't open log file.\n");
2114 fgets(line,
sizeof(line), fp);
2115 if (line[0] ==
'0') {
2118 str_p = strstr(line,
"=");
2119 if (str_p == NULL) {
2123 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2126 if (!strcmp(ok_string,
"OK")) {
2133 str_p = strstr(line,
"=");
2134 if (str_p == NULL) {
2138 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2141 if (!strcmp(ok_string,
"OK")) {
2148 str_p = strstr(line,
"=");
2149 if (str_p == NULL) {
2153 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2156 if (!strcmp(ok_string,
"OK")) {
2163 str_p = strstr(line,
"=");
2164 if (str_p == NULL) {
2168 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2171 if (!strcmp(ok_string,
"OK")) {
2178 str_p = strstr(line,
"=");
2179 if (str_p == NULL) {
2183 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2186 if (!strcmp(ok_string,
"OK")) {
2193 str_p = strstr(line,
"=");
2194 if (str_p == NULL) {
2198 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2201 if (!strcmp(ok_string,
"OK")) {
2208 str_p = strstr(line,
"=");
2209 if (str_p == NULL) {
2213 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2216 if (!strcmp(ok_string,
"OK")) {
2223 str_p = strstr(line,
"=");
2224 if (str_p == NULL) {
2228 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2231 if (!strcmp(ok_string,
"OK")) {
2238 str_p = strstr(line,
"=");
2239 if (str_p == NULL) {
2243 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2246 if (!strcmp(ok_string,
"OK")) {
2253 str_p = strstr(line,
"OK");
2254 if (str_p == NULL) {
2258 status = sscanf(str_p+2,
"%f Volts", &fval);
2264 str_p = strstr(line,
"OK");
2265 if (str_p == NULL) {
2269 status = sscanf(str_p+2,
"%f Volts", &fval);
2275 str_p = strstr(line,
"OK");
2276 if (str_p == NULL) {
2280 status = sscanf(str_p+2,
"%f Volts", &fval);
2286 str_p = strstr(line,
"OK");
2287 if (str_p == NULL) {
2291 status = sscanf(str_p+2,
"%f Volts", &fval);
2297 str_p = strstr(line,
"OK");
2298 if (str_p == NULL) {
2302 status = sscanf(str_p+2,
"%f Volts", &fval);
2308 str_p = strstr(line,
"OK");
2309 if (str_p == NULL) {
2313 status = sscanf(str_p+2,
"%f Volts", &fval);
2319 str_p = strstr(line,
"OK");
2320 if (str_p == NULL) {
2324 status = sscanf(str_p+2,
"%f Volts", &fval);
2330 str_p = strstr(line,
"OK");
2331 if (str_p == NULL) {
2335 status = sscanf(str_p+2,
"%f Volts", &fval);
2341 str_p = strstr(line,
"OK");
2342 if (str_p == NULL) {
2346 status = sscanf(str_p+2,
"%f Volts", &fval);
2352 str_p = strstr(line,
"OK");
2353 if (str_p == NULL) {
2357 status = sscanf(str_p+2,
"%f Volts", &fval);
2363 str_p = strstr(line,
"OK");
2364 if (str_p == NULL) {
2368 status = sscanf(str_p+2,
"%f Volts", &fval);
2374 str_p = strstr(line,
"=");
2375 if (str_p == NULL) {
2379 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2382 if (!strcmp(ok_string,
"OK")) {
2389 str_p = strstr(line,
"=");
2390 if (str_p == NULL) {
2394 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2397 if (!strcmp(ok_string,
"OK")) {
2404 str_p = strstr(line,
"OK");
2405 if (str_p == NULL) {
2409 status = sscanf(str_p+2,
"%f degrees C", &fval);
2415 str_p = strstr(line,
"OK");
2416 if (str_p == NULL) {
2420 status = sscanf(str_p+2,
"%f degrees C", &fval);
2426 str_p = strstr(line,
"OK");
2427 if (str_p == NULL) {
2431 status = sscanf(str_p+2,
"%f degrees C", &fval);
2437 str_p = strstr(line,
"OK");
2438 if (str_p == NULL) {
2442 status = sscanf(str_p+2,
"%f RPM", &fval);
2448 str_p = strstr(line,
"OK");
2449 if (str_p == NULL) {
2453 status = sscanf(str_p+2,
"%f RPM", &fval);
2459 str_p = strstr(line,
"OK");
2460 if (str_p == NULL) {
2464 status = sscanf(str_p+2,
"%f RPM", &fval);
2470 str_p = strstr(line,
"OK");
2471 if (str_p == NULL) {
2475 status = sscanf(str_p+2,
"%f RPM", &fval);
2481 str_p = strstr(line,
"=");
2482 if (str_p == NULL) {
2486 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2489 if (!strcmp(ok_string,
"OK")) {
2496 str_p = strstr(line,
"=");
2497 if (str_p == NULL) {
2501 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2504 if (!strcmp(ok_string,
"OK")) {
2511 str_p = strstr(line,
"=");
2512 if (str_p == NULL) {
2516 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2519 if (!strcmp(ok_string,
"OK")) {
2526 str_p = strstr(line,
"=");
2527 if (str_p == NULL) {
2531 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2534 if (!strcmp(ok_string,
"OK")) {
2541 str_p = strstr(line,
"=");
2542 if (str_p == NULL) {
2546 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2549 if (!strcmp(ok_string,
"OK")) {
2556 str_p = strstr(line,
"=");
2557 if (str_p == NULL) {
2561 status = sscanf(str_p+1,
"%x %x %x %x %s", &ival[0], &ival[1], &ival[2], &ival[3], ok_string);
2564 if (!strcmp(ok_string,
"OK")) {
2571 str_p = strstr(line,
"=");
2572 if (str_p == NULL) {
2576 status = sscanf(str_p+1,
"%x %s", &ival[0], ok_string);
2579 if (!strcmp(ok_string,
"OK")) {
2586 str_p = strstr(line,
"=");
2587 if (str_p == NULL) {
2591 status = sscanf(str_p+1,
"%x %s", &ival[0], ok_string);
2594 if (!strcmp(ok_string,
"OK")) {
2601 str_p = strstr(line,
"OK");
2602 if (str_p == NULL) {
2606 status = sscanf(str_p+2,
"%f degrees C", &fval);
2635 INT i, indexKV61, indexKV62, size;
2636 HNDLE hkey, hsubkey;
2638 char magnetNames[100*32];
2639 float measuredKV61, measuredKV62;
2641 measuredKV61 = measuredKV62 = 0.;
2642 indexKV61 = indexKV62 = 0;
2645 if (db_find_key(hDB, 0,
"/Equipment/Beamline/Settings/Names", &hkey) != DB_SUCCESS) {
2646 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get Names array for beam shutter status.");
2650 db_get_key(hDB, hkey, &key);
2651 size = key.num_values*32;
2652 db_get_data(hDB, hkey, magnetNames, &size, TID_STRING);
2654 for (i=0; i<key.num_values; i++) {
2655 if (strstr(magnetNames+NAME_LENGTH*i,
"KV61 (1=open)") != NULL) indexKV61 = i;
2656 if (strstr(magnetNames+NAME_LENGTH*i,
"KV62 (1=open)") != NULL) indexKV62 = i;
2660 if (db_find_key(hDB, 0,
"/Equipment/Beamline/Variables/Measured", &hkey) != DB_SUCCESS) {
2661 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't determine status of beam shutters.");
2665 size =
sizeof(float);
2667 if (db_get_data_index(hDB, hkey, &measuredKV61, &size, indexKV61, TID_FLOAT) != DB_SUCCESS) {
2668 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get measured value of KV61.");
2671 if (db_get_data_index(hDB, hkey, &measuredKV62, &size, indexKV62, TID_FLOAT) != DB_SUCCESS) {
2672 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get measured value of KV62.");
2676 if (measuredKV61 == 1. && measuredKV62 == 1.)
2699 cm_get_experiment_database(&hDB, NULL);
2706 cm_msg(MINFO,
"update_t0shift",
"Changed t0 shifts of decay histograms for magnet Bpar...");
2712 cm_msg(MINFO,
"update_t0shift",
"Changed t0 shifts of decay histograms for magnet WEW...");
2716 db_find_key(hDB, 0, str, &hKey);
2735 float sr_current, right_plate, left_plate, right_rod, left_rod;
2736 float moderator_hv, a[4];
2741 cm_msg(MINFO,
"set_spin_rot_angle",
"Spin rotator called with %i enable/disable and angle of %f degrees", flag_spinrot,
rotation_angle);
2747 if ((moderator_hv <= 1.0) || (moderator_hv >= 21.0)) {
2748 al_trigger_alarm(
"ana_Spin_rotator",
"Moderator HV should be between 1 and 20kV for spin rotation!",
2749 "Warning",
"Moderator HV should be between 1 and 20kV for spin rotation!", AT_INTERNAL);
2755 al_trigger_alarm(
"ana_Spin_rotator",
"Rotation angle is out of range, +/- 90 degrees!",
2756 "Warning",
"Rotation angle is out of range, +/- 90 degrees!", AT_INTERNAL);
2768 right_plate=(sr_current*sqrt(moderator_hv))/(a[2]+pow(fabs(sr_current/sqrt(moderator_hv)+a[3]),a[4]));
2769 left_plate=-1.0*right_plate;
2770 right_rod=0.5*right_plate;
2771 left_rod=0.5*left_plate;
2776 if (db_find_key(hDB, 0,
"/Equipment/Danfysik_Spin_Rot/Variables/Output", &hKey) == DB_SUCCESS ) {
2777 db_set_data_index(hDB, hKey, &sr_current,
sizeof(sr_current), 2, TID_FLOAT); }
2778 if (db_find_key(hDB, 0,
"/Equipment/HV/Variables/Demand", &hKey) == DB_SUCCESS ) {
2780 db_set_data_index(hDB, hKey, &right_plate,
sizeof(right_plate), 3, TID_FLOAT);
2782 db_set_data_index(hDB, hKey, &left_plate,
sizeof(left_plate), 2, TID_FLOAT);
2784 db_set_data_index(hDB, hKey, &left_rod,
sizeof(left_rod), 1, TID_FLOAT);
2786 db_set_data_index(hDB, hKey, &right_rod,
sizeof(right_rod), 0, TID_FLOAT);}
2789 cm_msg(MINFO,
"set_spin_rot_angle",
"Changed spin rotation angle to %f degrees",
rotation_angle);
2790 cm_msg(MINFO,
"set_spin_rot_angle",
"SR current %f and potential %f", sr_current, right_plate);
2793 cm_msg(MINFO,
"set_spin_rot_angle",
"Spin rotator disabled, angle not changed.");
void set_spin_rot_angle(INT hDB, INT hKey, void *dummy)
ANA_MODULE mcp1_ana_module
BANK_LIST trigger_bank_list[]
float implantation_energy
static TObjArray Slist(0)
INT beam_shutter_open(HNDLE hDB)
float energy_loss(float moderator_hv)
#define UPDATE_INFO_PERIOD_INTEL
#define T0SHIFT_PARAM_STR(_name)
struct DECAYANAMODULE_PARAM::@1::@3 decaybin
ANA_MODULE * trigger_module[]
#define EXP_EDIT_STR(_name)
INT read_intel_log(INTEL_LOG *info)
POSI_BANK_STR(posi_bank_str)
SRAT_BANK_STR(srat_bank_str)
#define N_OFFSET_PPC_HISTOGRAMS
ID offset of postpileup-rejected histograms.
ANA_MODULE scaler_rate_sum
DECAYANAMODULE_PARAM decay_ana_param
struct DECAYANAMODULE_PARAM::@0 histotitles
T0SHIFT_PARAM t0shift_param
SCALER_SETTINGS scaler_settings
#define HISTOGRAM_WRITE_PERIOD
INT ana_begin_of_run(INT run_number, char *error)
BANK_LIST scaler_bank_list[]
INT ana_end_of_run(INT run_number, char *error)
struct DECAYANAMODULE_PARAM::@1 histobinning
static TFolder * gRunHeader
RUNINFO runinfo
/Runinfo ODB key, defined in from midas.h
struct DECAYANAMODULE_PARAM::@0::@2 decaytitles
void extract_summary_data()
RATE_BANK_STR(rate_bank_str)
INT write_histogram_file()
static float rotation_angle
const char * analyzer_name
ANA_MODULE tof_ana_module
INT ana_resume_run(INT run_number, char *error)
struct INFO::@284 t0_parameter
#define TDSAMPLETOF_PARAM_STR(_name)
struct INFO::@282 magnet_parameter
void get_sum_filename(char *filename)
void update_t0shift(INT dummy1, INT dummy2, void *dummy3)
struct INFO::@283 lem_setup_parameter
ANALYZE_REQUEST analyze_request[]
char beamline_settings[132]
#define UPDATE_INFO_PERIOD
char sample_cryo[NAME_LENGTH]
struct INFO::@285 spinrot_parameter
static DWORD last_histogram_write
INT ana_pause_run(INT run_number, char *error)
ANA_MODULE decay_ana_module
INT sample_zeroflux_channel
TRIGGER_SETTINGS trigger_settings
/Equipment/Trigger/Settings
TDSAMPLETOF_PARAM tdsampletof_param
ANA_MODULE * scaler_module[]
#define SCALER_SETTINGS_STR(_name)
#define MEAN_BANK_STR(_name)
#define N_SCALER
total number of scaler channels
INT read_ipmi_log(IPMI_LOG *info)
INT t0Hist[N_DECAY_HISTS]
#define EXP_PARAM_STR(_name)
#define N_OFFSET_ONOFF_HISTOGRAMS
ID offset for "on/off", "red/green" histograms: no offset means "off".
#define N_DECAY_HISTS
number of LE-uSR npp decay histograms
static DWORD last_update_info_write
SCS2001M_EVENT scs2001m_event
struct INFO::@290 file_header_info
ANA_MODULE pileup_ana_module
static TMusrRunHeader * header
float get_magnetic_field(float current)
struct INFO::@281 energy_loss_parameter
SCANAMODULE_PARAM sc_ana_param
TFolder * gManaHistosFolder