63 #include <TDirectory.h>
66 #include <TMusrRunHeader.h>
110 static TObjArray
Slist(0);
114 #define HISTOGRAM_WRITE_PERIOD 300 // write histograms every 300s to file
115 #define UPDATE_INFO_PERIOD 5 // update info structure with eloss and B-field every 5sec
116 #define UPDATE_INFO_PERIOD_IPMI 300 // update lemXX ipmi log info structure every 300s
160 {
"TDC0", TID_DWORD},
163 {
"POSI", TID_STRUCT,
sizeof(
posi_bank), (
char **)posi_bank_str },
169 {
"SCL0", TID_DWORD},
172 {
"SSUM", TID_DOUBLE},
173 {
"RATE", TID_STRUCT,
sizeof(
rate_bank), (
char **)rate_bank_str },
174 {
"SRAT", TID_STRUCT,
sizeof(
srat_bank), (
char **)srat_bank_str },
180 {
"DBEA", TID_FLOAT},
181 {
"MBEA", TID_FLOAT},
182 {
"MVAC", TID_FLOAT},
183 {
"MMOD", TID_FLOAT},
184 {
"MSAM", TID_FLOAT},
185 {
"M900", TID_FLOAT},
186 {
"MHVT", TID_FLOAT},
187 {
"MHVD", TID_FLOAT},
188 {
"MWAV", TID_DOUBLE},
266 char fname[256], exp_name[32];
267 char lazy_fname[128];
272 BOOL flag_Bpar,flag_spinrot;
274 RUNINFO_STR(runinfo_str);
287 cm_get_experiment_database(&hDB, NULL);
289 db_create_record(hDB, 0,
"/Runinfo", strcomb(runinfo_str));
290 db_find_key(hDB, 0,
"/Runinfo", &hKey);
291 if (db_open_record(hDB, hKey, &
runinfo,
sizeof(
runinfo), MODE_READ, NULL, NULL) != DB_SUCCESS) {
292 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Runinfo\" tree in ODB");
296 db_create_record(hDB, 0,
"/Experiment/Run Parameters", strcomb(exp_param_str));
297 db_find_key(hDB, 0,
"/Experiment/Run Parameters", &hKey);
298 if (db_open_record(hDB, hKey, &exp_param,
sizeof(exp_param), MODE_READ, NULL, NULL) != DB_SUCCESS) {
299 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Experiment/Run Parameters\" tree in ODB");
303 sprintf(str,
"/Experiment/Name");
304 size =
sizeof(exp_name);
305 if (db_get_value(hDB, 0, str, exp_name, &size, TID_STRING, TRUE) != DB_SUCCESS ) {
306 sprintf(exp_name,
"nemu");
309 db_create_record(hDB, 0,
"/Experiment/Edit on start", strcomb(exp_edit_str));
310 db_find_key(hDB, 0,
"/Equipment/Trigger/Settings", &hKey);
311 if (db_open_record(hDB, hKey, &trigger_settings,
sizeof(trigger_settings), MODE_READ,
312 NULL, NULL) != DB_SUCCESS) {
313 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/Trigger/Settings\" tree in ODB");
317 db_create_record(hDB, 0,
"/Equipment/Scaler/Settings", strcomb(scaler_settings_str));
318 db_find_key(hDB, 0,
"/Equipment/Scaler/Settings", &hKey);
319 if (db_open_record(hDB, hKey, &scaler_settings,
sizeof(scaler_settings), MODE_READ,
320 NULL, NULL) != DB_SUCCESS) {
321 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/Scaler/Settings\" tree in ODB");
325 if (db_find_key(hDB, 0,
"/Equipment/Trigger/Vme_Statistics", &hKey))
326 db_open_record(hDB, hKey, &vme_stats,
sizeof(vme_stats), MODE_READ, NULL, NULL);
331 db_create_record(hDB, 0, str, strcomb(t0shift_param_str));
332 db_find_key(hDB, 0, str, &hKey);
333 if (db_open_record(hDB, hKey, &t0shift_param,
sizeof(t0shift_param),
334 MODE_READ, NULL, NULL) != DB_SUCCESS) {
335 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"%s\" tree in ODB", str);
341 db_create_record(hDB, 0, str, strcomb(tdsampletof_param_str));
342 db_find_key(hDB, 0, str, &hKey);
343 if (db_open_record(hDB, hKey, &tdsampletof_param,
sizeof(tdsampletof_param),
344 MODE_READ, NULL, NULL) != DB_SUCCESS) {
345 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"%s\" tree in ODB", str);
350 db_create_record(hDB, 0,
"/Info", strcomb(info_str));
351 db_find_key(hDB, 0,
"/Info", &hKey);
352 if (db_open_record(hDB, hKey, &info,
sizeof(info), MODE_READ, NULL, NULL) != DB_SUCCESS) {
353 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Info\" tree in ODB");
357 db_find_key(hDB, 0,
"/Info/LEM_Setup_Parameter/Bpar", &hKey);
358 if (db_open_record(hDB, hKey, &flag_Bpar,
sizeof(BOOL), MODE_READ, &
update_t0shift, NULL) != DB_SUCCESS) {
359 cm_msg(MERROR,
"analyzer_init",
"Cannot open /Info/LEM_Setup_Parameter/Bpar tree in ODB");
364 db_find_key(hDB, 0,
"/Info/SpinRot_Parameter/RotationAngle", &hKey);
366 cm_msg(MERROR,
"analyzer_init",
"Cannot open /Info/SpinRot_Parameter/RotationAngle tree in ODB");
371 db_find_key(hDB, 0,
"/Equipment/HV/Variables", &hKey);
372 if (db_open_record(hDB, hKey, &hv_event,
sizeof(hv_event), MODE_READ, NULL, NULL) != DB_SUCCESS) {
373 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/HV/Variables\" tree in ODB");
392 db_find_key(hDB, 0,
"/Equipment/SCS2001M/Variables", &hKey);
393 if (db_open_record(hDB, hKey, &scs2001m_event,
sizeof(scs2001m_event),
394 MODE_READ, NULL, NULL) != DB_SUCCESS) {
395 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/SCS2001M/Variables\" tree in ODB");
399 db_create_record(hDB, 0,
"/Equipment/SlowControl/Variables/MEAN", strcomb(mean_bank_str));
400 db_find_key(hDB, 0,
"/Equipment/SlowControl/Variables/MEAN", &hKey);
401 if (db_open_record(hDB, hKey, &mean,
sizeof(mean), MODE_READ, NULL, NULL) != DB_SUCCESS) {
402 cm_msg(MERROR,
"analyzer_init",
"Cannot open \"/Equipment/SlowControl/Variables/MEAN\" tree in ODB");
410 if ( db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SRAT", &hKey) == DB_SUCCESS ) {
411 memset(&srat_bank, 0,
sizeof(srat_bank));
412 db_set_record(hDB, hKey, &srat_bank,
sizeof(srat_bank), 0);
433 if (
runinfo.online_mode == 1) {
435 tms = localtime(&now);
438 size =
sizeof(fname);
440 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
441 sprintf(fname,
"lem%02d_%%04d.asc", tms->tm_year%100);
442 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
445 sprintf(str,
"/%s/Output/Histo Dump Filename",
analyzer_name);
446 size =
sizeof(fname);
449 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
451 sprintf(fname,
"../his/%04d/lem%02d_%%04d.hsn", tms->tm_year+1900, tms->tm_year%100);
452 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
455 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE) == DB_SUCCESS ) {
456 sprintf(fname,
"../his/%04d/lem%02d_his_%%04d.root", tms->tm_year+1900, tms->tm_year%100);
457 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
463 sprintf(str,
"/Logger/Data dir");
464 size =
sizeof(fname);
465 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
466 sprintf(fname,
"/data/%s/dlog", exp_name);
467 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
470 sprintf(str,
"/Logger/ODB Dump File");
471 size =
sizeof(fname);
472 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
473 sprintf(fname,
"/data/%s/odb/%04d/lem%02d_%%04d.odb", exp_name, tms->tm_year+1900, tms->tm_year%100);
474 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
477 sprintf(str,
"/Logger/Channels/0/Settings/Filename");
478 size =
sizeof(fname);
479 if ( db_get_value(hDB, 0, str, fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
480 sprintf(fname,
"lem%02d_%%04d", tms->tm_year%100);
481 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
484 sprintf(str,
"/Logger/History Dir");
485 sprintf(fname,
"/data/%s/history", exp_name);
486 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
488 sprintf(str,
"/Logger/History Path");
490 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
492 sprintf(str,
"/Logger/Elog Dir");
494 sprintf(fname,
"/home/nemu/elog/LEM_Experiment");
495 db_set_value(hDB, 0, str, &fname,
sizeof(fname), 1, TID_STRING);
498 sprintf(str,
"/Lazy/FTP/Settings/Filename format");
499 size =
sizeof(lazy_fname);
500 if ( db_get_value(hDB, 0, str, lazy_fname, &size, TID_STRING, FALSE) == DB_SUCCESS ) {
501 sprintf(lazy_fname,
"lem%02d_%%04d.root", tms->tm_year%100);
502 db_set_value(hDB, 0, str, &lazy_fname, size, 1, TID_STRING);
535 size =
sizeof(fname);
536 db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE);
541 sprintf(timestr,
"%s", ctime(&now));
543 db_set_value(hDB, 0,
"/Info/Scaler Update time", ×tr,
sizeof(timestr), 1, TID_STRING);
549 gRunHeader = gROOT->GetRootFolder()->AddFolder(
"RunHeader",
"LEM Run Header Info");
550 gROOT->GetListOfBrowsables()->Add(
gRunHeader,
"RunHeader");
551 header =
new TMusrRunHeader(
true);
554 Slist.SetName(
"RunSummary");
562 status = db_find_key(hDB, 0,
"/Analyzer/Forced Write Data Flag", &hKey);
563 if (status != DB_SUCCESS) {
564 status = db_create_key(hDB, 0,
"/Analyzer/Forced Write Data Flag", TID_BOOL);
583 cm_get_experiment_database(&hDB, NULL);
589 if ( db_find_key(hDB, 0,
"/Equipment/Scaler/Variables/SRAT", &hkey) == DB_SUCCESS ) {
590 memset(&srat_bank, 0,
sizeof(srat_bank));
591 db_set_record(hDB, hkey, &srat_bank,
sizeof(srat_bank), 0);
595 if (
runinfo.online_mode == 1) {
622 al_trigger_alarm(
"ana_begin_of_run",
"Beam Shutters KV61/62 still closed at begin-of-run!",
623 "Warning",
"BeamLine Shutters KV61/62 still closed at BOR!", AT_INTERNAL);
634 char str[256], logdir[256], cmd[256], file_name[256];
636 INT size, len, status;
641 cm_get_experiment_database(&hDB, NULL);
645 db_get_value(hDB, 0,
"/Logger/Write data", &flag, &size, TID_BOOL, FALSE);
646 if (flag &&
runinfo.online_mode == 1) {
652 db_get_value(hDB, 0,
"/Logger/Data Dir", str, &size, TID_STRING, FALSE);
654 if (str[strlen(str)-1] != DIR_SEPARATOR)
655 strcat(str, DIR_SEPARATOR_STR);
657 strcat(str,
"runlog.txt");
658 strcpy(file_name, str);
659 f = fopen(file_name,
"a");
662 strcpy(str, ctime(&now));
670 fprintf(f,
"%5d\t%s %s",
runinfo.run_number, str, year);
672 strcpy(str,
runinfo.start_time);
674 fprintf(f,
"::%s --- ", str+11);
676 strcpy(str, ctime(&now));
678 fprintf(f,
"%s\t", str+11);
681 db_get_value(hDB, 0,
"/Equipment/Trigger/Statistics/Events sent", &n, &size, TID_DOUBLE, FALSE);
683 fprintf(f,
"%6.1lfk\t", n/1000);
684 fprintf(f,
"%s --- ", exp_param.
comment);
691 runinfo.stop_time_binary = now;
692 strcpy(
runinfo.stop_time, ctime(&now));
695 len = strlen(
runinfo.stop_time);
696 if (
runinfo.stop_time[len-1] ==
'\n' )
707 db_set_value(hDB, 0,
"/Runinfo/State", &
runinfo.state,
sizeof(
runinfo.state), 1, TID_INT);
708 db_set_value(hDB, 0,
"/Runinfo/Stop time", &
runinfo.stop_time,
709 sizeof(
runinfo.stop_time), 1, TID_STRING);
710 db_set_value(hDB, 0,
"/Runinfo/Stop time binary", &
runinfo.stop_time_binary,
711 sizeof(
runinfo.stop_time_binary), 1, TID_DWORD);
714 ss_printf(0,50,
"Rates at EOR are a v e r a g e d rates !");
739 cm_get_experiment_database(&hDB, NULL);
743 al_trigger_alarm(
"ana_begin_of_run",
"Beam Shutters KV61/62 still closed at run resume!",
744 "Warning",
"BeamLine Shutters KV61/62 still closed at run resume!", AT_INTERNAL);
755 DWORD nowtime, difftime;
764 last_update_info_write = nowtime;
767 cm_get_experiment_database(&hDB, NULL);
769 if (
runinfo.state == STATE_PAUSED )
return CM_SUCCESS;
771 if (
runinfo.state == STATE_RUNNING ) {
774 status = db_find_key(hDB, 0,
"/Analyzer/Forced Write Data Flag", &hKey);
775 if (status == DB_SUCCESS) {
776 size =
sizeof(forced_write);
777 status = db_get_data(hDB, hKey, &forced_write, &size, TID_BOOL);
778 if (status != DB_SUCCESS)
779 forced_write = FALSE;
781 forced_write = FALSE;
789 forced_write = FALSE;
790 status = db_set_data(hDB, hKey, &forced_write,
sizeof(forced_write), 1, TID_BOOL);
792 last_histogram_write = nowtime;
820 char fname[256], str[256], file_name[256], save_file_name[256], cmd[256];
823 cm_get_experiment_database(&hDB, NULL);
824 sprintf(str,
"/%s/Output/Histo Dump Filename",
analyzer_name);
825 size =
sizeof(fname);
826 db_get_value(hDB, 0, str, fname, &size, TID_STRING, TRUE);
828 if (strchr(fname,
'%') != NULL)
829 sprintf(file_name, fname,
runinfo.run_number);
831 strcpy(file_name, fname);
833 db_find_key(hDB, 0,
"/Logger/Data dir", &hkey);
836 db_get_data(hDB, hkey, str, &size, TID_STRING);
837 if (str[strlen(str) - 1] != DIR_SEPARATOR)
838 strcat(str, DIR_SEPARATOR_STR);
839 strcat(str, file_name);
840 strcpy(file_name, str);
843 strcpy(save_file_name, file_name);
851 strcat(file_name, str);
856 TDirectory *savedir = gDirectory;
857 TFile *outf =
new TFile(file_name,
"RECREATE",
"Midas Analyzer Histograms");
859 cm_msg(MERROR,
"SaveRootHistograms",
"Cannot create output file %s", file_name);
867 cm_msg(MERROR,
"write_histogram_file",
"analyzer error: couldn't fill the run header information!");
876 status = gSystem->CopyFile(file_name, save_file_name, kTRUE);
879 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (file open failure of %s)", file_name);
880 }
else if (status == -2) {
881 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (write protection error of %s)", save_file_name);
882 }
else if (status == -3) {
883 cm_msg(MINFO,
"analyzer",
"**WARNING** cp in write histogram file failed. (error during copying (%s->%s))", file_name, save_file_name);
902 char dir[256], filebody[256];
907 if ( getenv(
"MIDAS_DATA") ) {
908 strcpy(dir, getenv(
"MIDAS_DATA"));
909 strcat(dir, DIR_SEPARATOR_STR);
911 strcat(dir, DIR_SEPARATOR_STR);
913 #if defined (OS_UNIX)
914 strcpy(dir, getenv(
"HOME"));
915 #elif defined (OS_WINNT)
916 strcpy(dir, getenv(
"HOMEPATH"));
918 strcat(dir, DIR_SEPARATOR_STR);
919 cm_msg(MINFO,
"get_sum_filename",
920 "MIDAS_DATA path not defined, use home directory %s instead\n", dir);
924 tms = localtime(&now);
926 strcpy(filename, dir);
927 sprintf(filebody,
"%04d/lem%02d_%04d.summ", tms->tm_year+1900, tms->tm_year%100,
runinfo.run_number);
928 strcat(filename, filebody);
938 char fileName[256],
line[256], enumline[256];
944 FILE *fp = fopen(fileName,
"r");
946 printf(
"File %s does not exist!\n", fileName);
950 while (fgets(line,256,fp)) {
951 sprintf(enumline,
"%04d ", i);
952 strcat(enumline, line);
953 s =
new TObjString(enumline);
974 float deltaE, x, p0, p1, p2, p3;
976 if ( moderator_hv > 20.1 ) {
984 deltaE = p0 + p1*x + p2*x*x + p3*x*x*x;
1000 float Bfield, x, p0, p1;
1013 Bfield = p0 + p1*current;
1025 INT i, size, result;
1026 float eloss, impEnergy, modHV, sampleHV, current, Bfield;
1027 char lem_setup[
STR_SIZE], lem_cryostat[NAME_LENGTH], old_lem_cryostat[NAME_LENGTH], hostname[64];
1029 BOOL flag, cryo_not_found;
1035 cm_get_experiment_database(&hDB, NULL);
1041 impEnergy = modHV - eloss - sampleHV;
1042 db_set_value(hDB, 0,
"/Info/Energy Loss (C-foil)", &eloss,
sizeof(eloss), 1, TID_FLOAT);
1043 db_set_value(hDB, 0,
"/Info/Implantation Energy (keV)", &impEnergy,
sizeof(impEnergy), 1, TID_FLOAT);
1050 current = current/10. * 500.;
1052 size =
sizeof(float);
1053 db_get_value(hDB, 0,
"/Equipment/Bruker/Variables/Input[3]", ¤t, &size, TID_FLOAT, FALSE);
1057 db_set_value(hDB, 0,
"/Info/Magnetic Field (G)", &Bfield,
sizeof(Bfield), 1, TID_FLOAT);
1064 result = gethostname(hostname,
sizeof(hostname));
1066 if (strstr(hostname,
"lem00")) {
1070 db_find_key(hDB, 0,
"/Info/Lem00IPMILog", &hKey);
1071 db_set_record(hDB, hKey, &info00,
sizeof(info00), 0);
1074 if (strstr(hostname,
"lem03")) {
1078 db_find_key(hDB, 0,
"/Info/Lem03IPMILog", &hKey);
1079 db_set_record(hDB, hKey, &info03,
sizeof(info03), 0);
1100 std::vector<int> ivec;
1101 char lem_setup[
STR_SIZE+NAME_LENGTH];
1102 char str[256], str1[256], str2[256], *p_str;
1103 double ip_sum, scaler_clock_sum, tdc_clock_sum, n_events, dval;
1104 double td_sum, td_clean_sum, td_good_sum, pos_sum[
N_DECAY_HISTS];
1108 cm_get_experiment_database(&hDB, NULL);
1110 sprintf(lem_setup,
"%s, ", info.
lem_setup);
1119 header->Set(
"RunInfo/Generic Validator URL",
"http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
1120 header->Set(
"RunInfo/Specific Validator URL",
"http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRootLEM.xsd");
1121 header->Set(
"RunInfo/Generator",
"nemu_analyzer");
1130 db_find_key(hDB, 0,
"/Analyzer/Output/Histo Dump Filename", &hKey);
1131 db_get_data(hDB, hKey, &str, &size, TID_STRING);
1139 }
while (str[i] !=
'\0');
1141 cm_msg(MERROR,
"update_run_header",
"Couldn't obtain run file name template! ODB corrupted?");
1146 strcpy(str1, p_str);
1147 p_str = strstr(str1,
"%");
1149 cm_msg(MERROR,
"update_run_header",
"Wrong run file name template! ODB corrupted?");
1153 sprintf(str,
"%04d.root",
runinfo.run_number);
1155 header->Set(
"RunInfo/File Name", str1);
1161 time_bin = (long)
runinfo.start_time_binary;
1162 struct tm *tm = localtime((time_t*)&time_bin);
1163 strftime(str,
sizeof(str),
"%F %T", tm);
1164 header->Set(
"RunInfo/Run Start Time", str);
1165 time_bin = (long)
runinfo.stop_time_binary;
1166 tm = localtime((time_t*)&time_bin);
1167 strftime(str,
sizeof(str),
"%F %T", tm);
1168 header->Set(
"RunInfo/Run Stop Time", str);
1172 ival = (int)
runinfo.stop_time_binary - (
int)
runinfo.start_time_binary;
1174 TMusrRunPhysicalQuantity prop;
1175 prop.Set(
"Run Duration", ival,
"sec");
1176 header->Set(
"RunInfo/Run Duration", prop);
1178 header->Set(
"RunInfo/Laboratory",
"PSI");
1179 header->Set(
"RunInfo/Instrument",
"LEM");
1181 prop.Set(
"Muon Beam Momentum", 28.1,
"MeV/c");
1182 header->Set(
"RunInfo/Muon Beam Momentum", prop);
1184 header->Set(
"RunInfo/Muon Species",
"positive muon");
1185 header->Set(
"RunInfo/Muon Source",
"Target E - Low Energy Muons");
1186 header->Set(
"RunInfo/Setup", lem_setup);
1187 header->Set(
"RunInfo/Comment",
"n/a");
1191 header->Set(
"RunInfo/Sample Temperature", prop);
1193 header->Set(
"RunInfo/Sample Magnetic Field", prop);
1197 prop.Set(
"Time Resolution", 0.1953125,
"ns",
"TDC CAEN V1190");
1198 header->Set(
"RunInfo/Time Resolution", prop);
1204 header->Set(
"RunInfo/RedGreen Offsets", ivec);
1210 header->Set(
"RunInfo/Moderator HV", prop);
1212 header->Set(
"RunInfo/Sample HV", prop);
1214 header->Set(
"RunInfo/Implantation Energy", prop);
1216 header->Set(
"RunInfo/Muon Spin Angle", prop);
1217 header->Set(
"RunInfo/Cuts",
"none");
1228 sprintf(str,
"DetectorInfo/Detector%03d", i+1);
1229 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1233 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1236 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1239 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1243 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1244 ival = (int) ceil(dval);
1247 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1255 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1259 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1262 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1265 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1269 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1270 ival = (int) ceil(dval);
1273 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1281 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1285 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1288 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1291 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1295 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1296 ival = (int) ceil(dval);
1299 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1307 snprintf(str1,
sizeof(str1),
"%s/Name", str);
1311 snprintf(str1,
sizeof(str1),
"%s/Histo Number", str);
1314 snprintf(str1,
sizeof(str1),
"%s/Histo Length", str);
1317 snprintf(str1,
sizeof(str1),
"%s/Time Zero Bin", str);
1321 snprintf(str1,
sizeof(str1),
"%s/First Good Bin", str);
1322 ival = (int) ceil(dval);
1325 snprintf(str1,
sizeof(str1),
"%s/Last Good Bin", str);
1349 header->Set(
"MagneticFieldEnvironmentInfo/Magnet Name", info.
lem_setup);
1361 header->Set(
"BeamlineInfo/Name",
"muE4");
1371 size =
sizeof(double);
1372 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[0]", &ip_sum, &size, TID_DOUBLE, FALSE);
1373 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[1]", &scaler_clock_sum, &size, TID_DOUBLE, FALSE);
1374 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[4]", &td_sum, &size, TID_DOUBLE, FALSE);
1375 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[40]", &pos_sum[0], &size, TID_DOUBLE, FALSE);
1376 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[41]", &pos_sum[1], &size, TID_DOUBLE, FALSE);
1377 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[42]", &pos_sum[2], &size, TID_DOUBLE, FALSE);
1378 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[43]", &pos_sum[3], &size, TID_DOUBLE, FALSE);
1379 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[44]", &pos_sum[4], &size, TID_DOUBLE, FALSE);
1380 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[45]", &pos_sum[5], &size, TID_DOUBLE, FALSE);
1381 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[46]", &pos_sum[6], &size, TID_DOUBLE, FALSE);
1382 db_get_value(hDB, 0,
"/Equipment/Scaler/Variables/SSUM[47]", &pos_sum[7], &size, TID_DOUBLE, FALSE);
1383 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/TD clean", &td_clean_sum, &size, TID_DOUBLE, FALSE);
1384 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/TD good" , &td_good_sum, &size, TID_DOUBLE, FALSE);
1385 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/channelCounts[1]" , &tdc_clock_sum, &size, TID_DOUBLE, FALSE);
1386 db_get_value(hDB, 0,
"/Equipment/Trigger/VME_Statistics/SlowMuonEvents" , &n_events, &size, TID_DOUBLE, FALSE);
1388 header->Set(
"ScalerInfo/Sum Ip", ip_sum);
1389 header->Set(
"ScalerInfo/Sum Clock (Scaler)", scaler_clock_sum);
1390 header->Set(
"ScalerInfo/Sum Clock (TDC)", tdc_clock_sum);
1391 header->Set(
"ScalerInfo/Sum Slow Muon Events", n_events);
1392 header->Set(
"ScalerInfo/Sum TD", td_sum);
1393 header->Set(
"ScalerInfo/Sum TD_Clean", td_clean_sum);
1394 header->Set(
"ScalerInfo/Sum TD_Good", td_good_sum);
1396 TIntVector posSumVec;
1397 for (
unsigned int i=0; i<8; i++)
1398 posSumVec.push_back((
int)pos_sum[i]);
1399 header->Set(
"ScalerInfo/Sum Positrons", posSumVec);
1424 float moderator_hv, energy_after_TD_XXkV;
1425 float tofXXkV, muon_mass, c_light, l_eff, scale;
1429 if (moderator_hv < 5.0)
1432 energy_after_TD_XXkV = moderator_hv -
energy_loss(moderator_hv);
1434 muon_mass = 105658.370;
1435 c_light = 299.792458;
1444 scale = l_eff/c_light*sqrt(muon_mass/2.);
1446 tofXXkV = scale/sqrt(energy_after_TD_XXkV);
1448 tofXXkV = tofXXkV/0.1953125;
1453 cm_get_experiment_database(&hDB, NULL);
1454 db_find_key(hDB, 0,
"/Info/t0_parameter/t0", &hKey);
1455 db_set_record(hDB, hKey, &t0,
sizeof(t0), 0);
1526 float moderatorHV, energyAfterTD;
1527 float tofXXkV, muonMass, cLight;
1528 float dTotal, dFree, dL3, dRA;
1529 float tofFree, tofL3, tofRA;
1530 float scaleL3, scaleRA;
1535 if (moderatorHV < 5.0)
1538 energyAfterTD = moderatorHV -
energy_loss(moderatorHV);
1539 muonMass = 105658.37;
1540 cLight = 299.792458;
1549 dTotal = tdsampletof_param.
dtotalp0 + tdsampletof_param.
dtotalp1*moderatorHV;
1550 dL3 = tdsampletof_param.
dl3;
1551 dRA = tdsampletof_param.
dra;
1552 dFree = dTotal - dL3 - dRA;
1555 UL3 = scaleL3 * UL3;
1556 URA = scaleRA * URA;
1558 if ( UL3 == 0. ) UL3 = 0.0001;
1559 if ( URA == 0. ) URA = 0.0001;
1562 tofFree = dFree/sqrt(2.*energyAfterTD/muonMass)/cLight;
1563 if (UL3 <= energyAfterTD)
1564 tofL3 = dL3/UL3/cLight * sqrt(2.*muonMass*energyAfterTD) * (1. - sqrt(1.-UL3/energyAfterTD));
1566 tofL3 = dL3/UL3/cLight * sqrt(2.*muonMass*energyAfterTD);
1567 if (URA <= energyAfterTD)
1568 tofRA = dRA/URA/cLight * sqrt(2.*muonMass*energyAfterTD) * (1. - sqrt(1.-URA/energyAfterTD));
1570 tofRA = dRA/URA/cLight * sqrt(2.*muonMass*energyAfterTD);
1572 tofXXkV = tofFree + tofL3 + tofRA;
1573 tofXXkV = tofXXkV/0.1953125;
1578 cm_get_experiment_database(&hDB, NULL);
1579 db_find_key(hDB, 0,
"/Info/t0_parameter/t0", &hKey);
1580 db_set_record(hDB, hKey, &t0,
sizeof(t0), 0);
1654 char filename_mws[] =
"/data/nemu/test.txt";
1656 static const long max_len = 200;
1657 char buff[max_len + 1];
1660 if ((fd = fopen(filename_mws,
"rb")) != NULL) {
1662 fseek(fd, -max_len, SEEK_END);
1663 fread(buff, max_len-1, 1, fd);
1666 buff[max_len-1] =
'\0';
1667 char *last_newline = strrchr(buff,
'\n');
1668 char *last_line = last_newline+1;
1670 printf(
"last line: %s\n", last_line);
1672 if (strstr(last_line,
",") != NULL){
1673 sscanf(last_line,
"%lf,%lf,%lf",
1680 cm_msg(MINFO,
"read_microwave_log",
"read_microwave_log: cannot find file %s.", filename_mws);
1736 char line[128], *str_p;
1740 static DWORD last = 0;
1765 info->
vtt = -9999.0;
1772 info->
p1_1v = -9999.0;
1773 info->
p1_5v = -9999.0;
1774 info->
p3_3v = -9999.0;
1776 info->
p5v = -9999.0;
1777 info->
p5vsb = -9999.0;
1778 info->
p12v = -9999.0;
1779 info->
vbat = -9999.0;
1784 fp = fopen(
"/var/log/lem00.psi.ch_ipmi.log",
"r");
1786 printf(
"\nCouldn't open log file.\n");
1791 fgets(line,
sizeof(line), fp);
1794 if (strstr(line,
"CPU1 Temp")) {
1795 str_p = strstr(line,
"|");
1796 if (str_p == NULL) {
1800 status = sscanf(str_p+1,
"%f", &fval);
1806 }
else if (strstr(line,
"CPU2 Temp")) {
1807 str_p = strstr(line,
"|");
1808 if (str_p == NULL) {
1812 status = sscanf(str_p+1,
"%f", &fval);
1818 }
else if (strstr(line,
"System Temp")) {
1819 str_p = strstr(line,
"|");
1820 if (str_p == NULL) {
1824 status = sscanf(str_p+1,
"%f", &fval);
1830 }
else if (strstr(line,
"Peripheral Temp")) {
1831 str_p = strstr(line,
"|");
1832 if (str_p == NULL) {
1836 status = sscanf(str_p+1,
"%f", &fval);
1842 }
else if (strstr(line,
"PCH Temp")) {
1843 str_p = strstr(line,
"|");
1844 if (str_p == NULL) {
1848 status = sscanf(str_p+1,
"%f", &fval);
1854 }
else if (strstr(line,
"P1-DIMMA1 TEMP")) {
1855 str_p = strstr(line,
"|");
1856 if (str_p == NULL) {
1860 status = sscanf(str_p+1,
"%f", &fval);
1866 }
else if (strstr(line,
"P1-DIMMB1 TEMP")) {
1867 str_p = strstr(line,
"|");
1868 if (str_p == NULL) {
1872 status = sscanf(str_p+1,
"%f", &fval);
1878 }
else if (strstr(line,
"P2-DIMME1 TEMP")) {
1879 str_p = strstr(line,
"|");
1880 if (str_p == NULL) {
1884 status = sscanf(str_p+1,
"%f", &fval);
1890 }
else if (strstr(line,
"P2-DIMMF1 TEMP")) {
1891 str_p = strstr(line,
"|");
1892 if (str_p == NULL) {
1896 status = sscanf(str_p+1,
"%f", &fval);
1902 }
else if (strstr(line,
"FAN1")) {
1903 str_p = strstr(line,
"|");
1904 if (str_p == NULL) {
1908 status = sscanf(str_p+1,
"%d", &ival);
1914 }
else if (strstr(line,
"FAN2")) {
1915 str_p = strstr(line,
"|");
1916 if (str_p == NULL) {
1920 status = sscanf(str_p+1,
"%d", &ival);
1926 }
else if (strstr(line,
"FAN3")) {
1927 str_p = strstr(line,
"|");
1928 if (str_p == NULL) {
1932 status = sscanf(str_p+1,
"%d", &ival);
1938 }
else if (strstr(line,
"FAN5")) {
1939 str_p = strstr(line,
"|");
1940 if (str_p == NULL) {
1944 status = sscanf(str_p+1,
"%d", &ival);
1950 }
else if (strstr(line,
"FAN6")) {
1951 str_p = strstr(line,
"|");
1952 if (str_p == NULL) {
1956 status = sscanf(str_p+1,
"%d", &ival);
1962 }
else if (strstr(line,
"VTT")) {
1963 str_p = strstr(line,
"|");
1964 if (str_p == NULL) {
1968 status = sscanf(str_p+1,
"%f", &fval);
1974 }
else if (strstr(line,
"CPU1 Vcore")) {
1975 str_p = strstr(line,
"|");
1976 if (str_p == NULL) {
1980 status = sscanf(str_p+1,
"%f", &fval);
1986 }
else if (strstr(line,
"CPU2 Vcore")) {
1987 str_p = strstr(line,
"|");
1988 if (str_p == NULL) {
1992 status = sscanf(str_p+1,
"%f", &fval);
1998 }
else if (strstr(line,
"VDIMM AB")) {
1999 str_p = strstr(line,
"|");
2000 if (str_p == NULL) {
2004 status = sscanf(str_p+1,
"%f", &fval);
2010 }
else if (strstr(line,
"VDIMM CD")) {
2011 str_p = strstr(line,
"|");
2012 if (str_p == NULL) {
2016 status = sscanf(str_p+1,
"%f", &fval);
2022 }
else if (strstr(line,
"VDIMM EF")) {
2023 str_p = strstr(line,
"|");
2024 if (str_p == NULL) {
2028 status = sscanf(str_p+1,
"%f", &fval);
2034 }
else if (strstr(line,
"VDIMM GH")) {
2035 str_p = strstr(line,
"|");
2036 if (str_p == NULL) {
2040 status = sscanf(str_p+1,
"%f", &fval);
2046 }
else if (strstr(line,
"+1.1 V")) {
2047 str_p = strstr(line,
"|");
2048 if (str_p == NULL) {
2052 status = sscanf(str_p+1,
"%f", &fval);
2058 }
else if (strstr(line,
"+1.5 V")) {
2059 str_p = strstr(line,
"|");
2060 if (str_p == NULL) {
2064 status = sscanf(str_p+1,
"%f", &fval);
2070 }
else if (strstr(line,
"3.3V ")) {
2071 str_p = strstr(line,
"|");
2072 if (str_p == NULL) {
2076 status = sscanf(str_p+1,
"%f", &fval);
2082 }
else if (strstr(line,
"+3.3VSB")) {
2083 str_p = strstr(line,
"|");
2084 if (str_p == NULL) {
2088 status = sscanf(str_p+1,
"%f", &fval);
2094 }
else if (strstr(line,
"5V ")) {
2095 str_p = strstr(line,
"|");
2096 if (str_p == NULL) {
2100 status = sscanf(str_p+1,
"%f", &fval);
2106 }
else if (strstr(line,
"+5VSB")) {
2107 str_p = strstr(line,
"|");
2108 if (str_p == NULL) {
2112 status = sscanf(str_p+1,
"%f", &fval);
2118 }
else if (strstr(line,
"12V")) {
2119 str_p = strstr(line,
"|");
2120 if (str_p == NULL) {
2124 status = sscanf(str_p+1,
"%f", &fval);
2130 }
else if (strstr(line,
"VBAT")) {
2131 str_p = strstr(line,
"|");
2132 if (str_p == NULL) {
2136 status = sscanf(str_p+1,
"%f", &fval);
2142 }
else if (strstr(line,
"Chassis Intru")) {
2143 str_p = strstr(line,
"|");
2144 if (str_p == NULL) {
2148 status = sscanf(str_p+1,
"%d", &ival);
2154 }
else if (strstr(line,
"PS1 Status")) {
2155 str_p = strstr(line,
"|");
2156 if (str_p == NULL) {
2160 status = sscanf(str_p+1,
"%x", &ival);
2166 }
else if (strstr(line,
"PS2 Status")) {
2167 str_p = strstr(line,
"|");
2168 if (str_p == NULL) {
2172 status = sscanf(str_p+1,
"%x", &ival);
2198 char line[128], *str_p;
2202 static DWORD last = 0;
2233 info->
p12v = -9999.0;
2234 info->
p5vcc = -9999.0;
2237 info->
vcpu1 = -9999.0;
2238 info->
vcpu2 = -9999.0;
2243 info->
p5vsb = -9999.0;
2254 fp = fopen(
"/var/log/lem03.psi.ch_ipmi.log",
"r");
2256 printf(
"\nCouldn't open log file.\n");
2261 fgets(line,
sizeof(line), fp);
2264 if (strstr(line,
"CPU1 Temp")) {
2265 str_p = strstr(line,
"|");
2266 if (str_p == NULL) {
2270 status = sscanf(str_p+1,
"%f", &fval);
2276 }
else if (strstr(line,
"CPU2 Temp")) {
2277 str_p = strstr(line,
"|");
2278 if (str_p == NULL) {
2282 status = sscanf(str_p+1,
"%f", &fval);
2288 }
else if (strstr(line,
"PCH Temp")) {
2289 str_p = strstr(line,
"|");
2290 if (str_p == NULL) {
2294 status = sscanf(str_p+1,
"%f", &fval);
2300 }
else if (strstr(line,
"System Temp")) {
2301 str_p = strstr(line,
"|");
2302 if (str_p == NULL) {
2306 status = sscanf(str_p+1,
"%f", &fval);
2312 }
else if (strstr(line,
"Peripheral Temp")) {
2313 str_p = strstr(line,
"|");
2314 if (str_p == NULL) {
2318 status = sscanf(str_p+1,
"%f", &fval);
2324 }
else if (strstr(line,
"VRMCpu1 Temp")) {
2325 str_p = strstr(line,
"|");
2326 if (str_p == NULL) {
2330 status = sscanf(str_p+1,
"%f", &fval);
2336 }
else if (strstr(line,
"VRMCpu2 Temp")) {
2337 str_p = strstr(line,
"|");
2338 if (str_p == NULL) {
2342 status = sscanf(str_p+1,
"%f", &fval);
2348 }
else if (strstr(line,
"VRMP1ABC Temp")) {
2349 str_p = strstr(line,
"|");
2350 if (str_p == NULL) {
2354 status = sscanf(str_p+1,
"%f", &fval);
2360 }
else if (strstr(line,
"VRMP1DEF Temp")) {
2361 str_p = strstr(line,
"|");
2362 if (str_p == NULL) {
2366 status = sscanf(str_p+1,
"%f", &fval);
2372 }
else if (strstr(line,
"VRMP2ABC Temp")) {
2373 str_p = strstr(line,
"|");
2374 if (str_p == NULL) {
2378 status = sscanf(str_p+1,
"%f", &fval);
2384 }
else if (strstr(line,
"VRMP2DEF Temp")) {
2385 str_p = strstr(line,
"|");
2386 if (str_p == NULL) {
2390 status = sscanf(str_p+1,
"%f", &fval);
2396 }
else if (strstr(line,
"P1-DIMMA1 Temp")) {
2397 str_p = strstr(line,
"|");
2398 if (str_p == NULL) {
2402 status = sscanf(str_p+1,
"%f", &fval);
2408 }
else if (strstr(line,
"P1-DIMMD1 Temp")) {
2409 str_p = strstr(line,
"|");
2410 if (str_p == NULL) {
2414 status = sscanf(str_p+1,
"%f", &fval);
2420 }
else if (strstr(line,
"P2-DIMMA1 Temp")) {
2421 str_p = strstr(line,
"|");
2422 if (str_p == NULL) {
2426 status = sscanf(str_p+1,
"%f", &fval);
2432 }
else if (strstr(line,
"P2-DIMMD1 Temp")) {
2433 str_p = strstr(line,
"|");
2434 if (str_p == NULL) {
2438 status = sscanf(str_p+1,
"%f", &fval);
2444 }
else if (strstr(line,
"FAN1")) {
2445 str_p = strstr(line,
"|");
2446 if (str_p == NULL) {
2450 status = sscanf(str_p+1,
"%d", &ival);
2456 }
else if (strstr(line,
"FAN2")) {
2457 str_p = strstr(line,
"|");
2458 if (str_p == NULL) {
2462 status = sscanf(str_p+1,
"%d", &ival);
2468 }
else if (strstr(line,
"FAN3")) {
2469 str_p = strstr(line,
"|");
2470 if (str_p == NULL) {
2474 status = sscanf(str_p+1,
"%d", &ival);
2480 }
else if (strstr(line,
"FAN5")) {
2481 str_p = strstr(line,
"|");
2482 if (str_p == NULL) {
2486 status = sscanf(str_p+1,
"%d", &ival);
2492 }
else if (strstr(line,
"FAN6")) {
2493 str_p = strstr(line,
"|");
2494 if (str_p == NULL) {
2498 status = sscanf(str_p+1,
"%d", &ival);
2504 }
else if (strstr(line,
"12V")) {
2505 str_p = strstr(line,
"|");
2506 if (str_p == NULL) {
2510 status = sscanf(str_p+1,
"%f", &fval);
2516 }
else if (strstr(line,
"5VCC")) {
2517 str_p = strstr(line,
"|");
2518 if (str_p == NULL) {
2522 status = sscanf(str_p+1,
"%f", &fval);
2528 }
else if (strstr(line,
"3.3VCC")) {
2529 str_p = strstr(line,
"|");
2530 if (str_p == NULL) {
2534 status = sscanf(str_p+1,
"%f", &fval);
2540 }
else if (strstr(line,
"VBAT")) {
2541 str_p = strstr(line,
"|");
2542 if (str_p == NULL) {
2546 status = sscanf(str_p+1,
"%x", &ival);
2552 }
else if (strstr(line,
"Vcpu1")) {
2553 str_p = strstr(line,
"|");
2554 if (str_p == NULL) {
2558 status = sscanf(str_p+1,
"%f", &fval);
2564 }
else if (strstr(line,
"Vcpu2")) {
2565 str_p = strstr(line,
"|");
2566 if (str_p == NULL) {
2570 status = sscanf(str_p+1,
"%f", &fval);
2576 }
else if (strstr(line,
"VDimmP1ABC")) {
2577 str_p = strstr(line,
"|");
2578 if (str_p == NULL) {
2582 status = sscanf(str_p+1,
"%f", &fval);
2588 }
else if (strstr(line,
"VDimmP1DEF")) {
2589 str_p = strstr(line,
"|");
2590 if (str_p == NULL) {
2594 status = sscanf(str_p+1,
"%f", &fval);
2600 }
else if (strstr(line,
"VDimmP2ABC")) {
2601 str_p = strstr(line,
"|");
2602 if (str_p == NULL) {
2606 status = sscanf(str_p+1,
"%f", &fval);
2612 }
else if (strstr(line,
"VDimmP2DEF")) {
2613 str_p = strstr(line,
"|");
2614 if (str_p == NULL) {
2618 status = sscanf(str_p+1,
"%f", &fval);
2624 }
else if (strstr(line,
"5VSB")) {
2625 str_p = strstr(line,
"|");
2626 if (str_p == NULL) {
2630 status = sscanf(str_p+1,
"%f", &fval);
2636 }
else if (strstr(line,
"3.3VSB")) {
2637 str_p = strstr(line,
"|");
2638 if (str_p == NULL) {
2642 status = sscanf(str_p+1,
"%f", &fval);
2648 }
else if (strstr(line,
"1.8V PCH")) {
2649 str_p = strstr(line,
"|");
2650 if (str_p == NULL) {
2654 status = sscanf(str_p+1,
"%f", &fval);
2660 }
else if (strstr(line,
"PVNN PCH")) {
2661 str_p = strstr(line,
"|");
2662 if (str_p == NULL) {
2666 status = sscanf(str_p+1,
"%f", &fval);
2672 }
else if (strstr(line,
"1.05V PCH")) {
2673 str_p = strstr(line,
"|");
2674 if (str_p == NULL) {
2678 status = sscanf(str_p+1,
"%f", &fval);
2684 }
else if (strstr(line,
"Chassis Intru")) {
2685 str_p = strstr(line,
"|");
2686 if (str_p == NULL) {
2690 status = sscanf(str_p+1,
"%x", &ival);
2696 }
else if (strstr(line,
"PS1 Status")) {
2697 str_p = strstr(line,
"|");
2698 if (str_p == NULL) {
2702 status = sscanf(str_p+1,
"%x", &ival);
2708 }
else if (strstr(line,
"PS2 Status")) {
2709 str_p = strstr(line,
"|");
2710 if (str_p == NULL) {
2714 status = sscanf(str_p+1,
"%x", &ival);
2720 }
else if (strstr(line,
"AOC_SAS Temp")) {
2721 str_p = strstr(line,
"|");
2722 if (str_p == NULL) {
2726 status = sscanf(str_p+1,
"%f", &fval);
2732 }
else if (strstr(line,
"HDD Temp")) {
2733 str_p = strstr(line,
"|");
2734 if (str_p == NULL) {
2738 status = sscanf(str_p+1,
"%f", &fval);
2744 }
else if (strstr(line,
"HDD Status")) {
2745 str_p = strstr(line,
"|");
2746 if (str_p == NULL) {
2750 status = sscanf(str_p+1,
"%x", &ival);
2776 INT i, indexKV61, indexKV62, size;
2777 HNDLE hkey, hsubkey;
2779 char magnetNames[100*32];
2780 float measuredKV61, measuredKV62;
2782 measuredKV61 = measuredKV62 = 0.;
2783 indexKV61 = indexKV62 = 0;
2786 if (db_find_key(hDB, 0,
"/Equipment/Beamline/Settings/Names", &hkey) != DB_SUCCESS) {
2787 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get Names array for beam shutter status.");
2791 db_get_key(hDB, hkey, &key);
2792 size = key.num_values*32;
2793 db_get_data(hDB, hkey, magnetNames, &size, TID_STRING);
2795 for (i=0; i<key.num_values; i++) {
2796 if (strstr(magnetNames+NAME_LENGTH*i,
"KV61 (1=open)") != NULL) indexKV61 = i;
2797 if (strstr(magnetNames+NAME_LENGTH*i,
"KV62 (1=open)") != NULL) indexKV62 = i;
2801 if (db_find_key(hDB, 0,
"/Equipment/Beamline/Variables/Measured", &hkey) != DB_SUCCESS) {
2802 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't determine status of beam shutters.");
2806 size =
sizeof(float);
2808 if (db_get_data_index(hDB, hkey, &measuredKV61, &size, indexKV61, TID_FLOAT) != DB_SUCCESS) {
2809 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get measured value of KV61.");
2812 if (db_get_data_index(hDB, hkey, &measuredKV62, &size, indexKV62, TID_FLOAT) != DB_SUCCESS) {
2813 cm_msg(MERROR,
"beam_shutter_open",
"Warning: can't get measured value of KV62.");
2817 if (measuredKV61 == 1. && measuredKV62 == 1.)
2840 cm_get_experiment_database(&hDB, NULL);
2844 db_get_value(hDB, 0,
"/Info/LEM_Setup_Parameter/Bpar", &info.
lem_setup_parameter.
bpar, &size, TID_BOOL, FALSE);
2847 cm_msg(MINFO,
"update_t0shift",
"Changed t0 shifts of decay histograms for magnet Bpar...");
2853 cm_msg(MINFO,
"update_t0shift",
"Changed t0 shifts of decay histograms for magnet WEW...");
2857 db_find_key(hDB, 0, str, &hKey);
2858 db_set_record(hDB, hKey, &t0shift_param,
sizeof(t0shift_param), 0);
2876 float sr_current, right_plate, left_plate, right_rod, left_rod;
2877 float moderator_hv, a[4];
2882 cm_msg(MINFO,
"set_spin_rot_angle",
"Spin rotator called with %i enable/disable and angle of %f degrees", flag_spinrot,
rotation_angle);
2888 if ((moderator_hv <= 1.0) || (moderator_hv >= 21.0)) {
2889 al_trigger_alarm(
"ana_Spin_rotator",
"Moderator HV should be between 1 and 20kV for spin rotation!",
2890 "Warning",
"Moderator HV should be between 1 and 20kV for spin rotation!", AT_INTERNAL);
2896 al_trigger_alarm(
"ana_Spin_rotator",
"Rotation angle is out of range, +/- 90 degrees!",
2897 "Warning",
"Rotation angle is out of range, +/- 90 degrees!", AT_INTERNAL);
2909 right_plate=(sr_current*sqrt(moderator_hv))/(a[2]+pow(fabs(sr_current/sqrt(moderator_hv)+a[3]),a[4]));
2910 left_plate=-1.0*right_plate;
2911 right_rod=0.5*right_plate;
2912 left_rod=0.5*left_plate;
2917 if (db_find_key(hDB, 0,
"/Equipment/Danfysik_Spin_Rot/Variables/Output", &hKey) == DB_SUCCESS ) {
2918 db_set_data_index(hDB, hKey, &sr_current,
sizeof(sr_current), 2, TID_FLOAT); }
2919 if (db_find_key(hDB, 0,
"/Equipment/HV/Variables/Demand", &hKey) == DB_SUCCESS ) {
2921 db_set_data_index(hDB, hKey, &right_plate,
sizeof(right_plate), 3, TID_FLOAT);
2923 db_set_data_index(hDB, hKey, &left_plate,
sizeof(left_plate), 2, TID_FLOAT);
2925 db_set_data_index(hDB, hKey, &left_rod,
sizeof(left_rod), 1, TID_FLOAT);
2927 db_set_data_index(hDB, hKey, &right_rod,
sizeof(right_rod), 0, TID_FLOAT);}
2930 cm_msg(MINFO,
"set_spin_rot_angle",
"Changed spin rotation angle to %f degrees",
rotation_angle);
2931 cm_msg(MINFO,
"set_spin_rot_angle",
"SR current %f and potential %f", sr_current, right_plate);
2934 cm_msg(MINFO,
"set_spin_rot_angle",
"Spin rotator disabled, angle not changed.");
#define UPDATE_INFO_PERIOD_IPMI
struct INFO::@293 lem_setup_parameter
double keysight_u8481a_timestamp
float implantation_energy
#define UPDATE_INFO_PERIOD
INT beam_shutter_open(HNDLE hDB)
void get_sum_filename(char *filename)
INT32 sample_zeroflux_channel
VME_STATS vme_stats
Required ODB structures.
SCALER_SETTINGS scaler_settings
#define T0SHIFT_PARAM_STR(_name)
double channelCounts[N_TDC_CHANNELS]
ANA_MODULE tof_ana_module
void set_spin_rot_angle(INT hDB, INT hKey, void *dummy)
void update_t0shift(INT dummy1, INT dummy2, void *dummy3)
struct DECAYANAMODULE_PARAM::@1::@3 decaybin
#define EXP_EDIT_STR(_name)
ANA_MODULE * trigger_module[]
DECAYANAMODULE_PARAM decay_ana_param
double tektronix_set_power
BANK_LIST scaler_bank_list[]
const char * analyzer_name
RATE_BANK_STR(rate_bank_str)
double tektronix_timestamp
#define N_OFFSET_PPC_HISTOGRAMS
ID offset of postpileup-rejected histograms.
ANA_MODULE mcp1_ana_module
#define HISTOGRAM_WRITE_PERIOD
struct DECAYANAMODULE_PARAM::@0 histotitles
ANA_MODULE pileup_ana_module
INT read_lem03_ipmi_log(LEM03_IPMI_LOG *info)
double keysight_u2002a_timestamp
double ana_pico_timestamp
struct DECAYANAMODULE_PARAM::@1 histobinning
struct DECAYANAMODULE_PARAM::@0::@2 decaytitles
double keysight_u2002a_measured_power
SCANAMODULE_PARAM sc_ana_param
struct INFO::@294 t0_parameter
INT ana_resume_run(INT run_number, char *error)
void extract_summary_data()
ANA_MODULE * scaler_module[]
TRIGGER_SETTINGS trigger_settings
INT read_lem00_ipmi_log(LEM00_IPMI_LOG *info)
static DWORD last_histogram_write
#define TDSAMPLETOF_PARAM_STR(_name)
static TMusrRunHeader * header
struct INFO::@300 file_header_info
INT read_microwave_log(MICROWAVE_LOG *microwave_info)
static float rotation_angle
double tektronix_set_frequency
ANALYZE_REQUEST analyze_request[]
char beamline_settings[132]
BANK_LIST trigger_bank_list[]
char sample_cryo[NAME_LENGTH]
SRAT_BANK_STR(srat_bank_str)
TFolder * gManaHistosFolder
INT write_histogram_file()
struct INFO::@292 magnet_parameter
static TFolder * gRunHeader
TDSAMPLETOF_PARAM tdsampletof_param
SCS2001M_EVENT scs2001m_event
#define SCALER_SETTINGS_STR(_name)
ANA_MODULE scaler_rate_sum
#define MEAN_BANK_STR(_name)
#define N_SCALER
total number of scaler channels
float energy_loss(float moderator_hv)
#define EXP_PARAM_STR(_name)
INT ana_end_of_run(INT run_number, char *error)
struct INFO::@295 spinrot_parameter
static DWORD last_update_info_write
INT ana_pause_run(INT run_number, char *error)
#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 TObjArray Slist(0)
double ana_pico_set_frequency
T0SHIFT_PARAM t0shift_param
POSI_BANK_STR(posi_bank_str)
ANA_MODULE decay_ana_module
double ana_pico_set_power
int t0Hist[N_DECAY_HISTS]
float get_magnetic_field(float current)
double keysight_u8481a_measured_power
INT ana_begin_of_run(INT run_number, char *error)
struct INFO::@291 energy_loss_parameter