[mcstas-users] TOFRes_sample

Ryoichi Kajimoto ryoichi.kajimoto at j-parc.jp
Mon Oct 23 13:29:19 CEST 2023


Hi,

I'm simulating a resolution function of a direct-geometry TOF spectrometer. I use TOFRes_sample() for the sample and Res_monitor() for the monitor.

My code worked with McStas 3.1, but it cannot be compiled with McStas 3.4.
I would appreciate if you could provide any solution.

Converting the .instr file to .c with mcstas command worked fine without an error, but compiling it with gcc -O3 -lm stops with an error message attached below.

I found that Res_monitor.comp and Res_sample.comp were greatly updated in McStas 3.4 but TOFRes_sample.comp was unchanged. I suspect that TOFRes_sample.comp is not compatible with Res_monitor.comp...

Thank you in advance,

Ryoichi Kajimoto


==================================

SIKIResSim.c: In function ‘Table_Read_Handle’:
SIKIResSim.c:7518:60: warning: format ‘%i’ expects argument of type ‘int’, but argument 5 has type ‘long int’ [-Wformat=]
 7518 |       fprintf(stderr,"Warning: Read_Table :%s %s Data has %i invalid lines (*****). Ignored.\n",
      |                                                           ~^
      |                                                            |
      |                                                            int
      |                                                           %li
......
 7521 |         count_invalid);
      |         ~~~~~~~~~~~~~
      |         |
      |         long int
SIKIResSim.c: In function ‘_resmonitor_setpos’:
SIKIResSim.c:13221:6: error: ‘RSsample’ undeclared (first use in this function)
13221 |   if(RSsample && strlen(RSsample))
      |      ^~~~~~~~
SIKIResSim.c:13221:6: note: each undeclared identifier is reported only once for each function it appears in
SIKIResSim.c: In function ‘class_Res_monitor_init’:
SIKIResSim.c:663:33: warning: format not a string literal and no format arguments [-Wformat-security]
  663 | #define NAME_CURRENT_COMP (_comp->_name)
      |                           ~~~~~~^~~~~~~~
SIKIResSim.c:13781:48: note: in expansion of macro ‘NAME_CURRENT_COMP’
13781 |   if (!strcmp(filename,"\0")) sprintf(filename,NAME_CURRENT_COMP);
      |                                                ^~~~~~~~~~~~~~~~~
SIKIResSim.c:641:10: error: ‘_class_Res_sample_parameters’ undeclared (first use in this function); did you mean ‘_class_TOFRes_sample_parameters’?
  641 |     &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )
      |          ^~~~~~~
SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’
13835 |   int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);
      |                  ^~~~~~~~~~~~
SIKIResSim.c:641:41: error: expected expression before ‘)’ token
  641 |     &( ((_class_ ## type ##_parameters *) _getvar_parameters(compname))->par )
      |                                         ^
SIKIResSim.c:13835:18: note: in expansion of macro ‘COMP_GETPAR3’
13835 |   int *index_ptr=COMP_GETPAR3(Res_sample, res_sample_comp, compindex);
      |                  ^~~~~~~~~~~~

==================================

This is how I use TOFRes_sample() and Res_monitor():

==================================

SPLIT COMPONENT RSsample = TOFRes_sample(
  thickness = sample_r-0.0001,
  radius = sample_r,
  yheight = sample_h,
  focus_xw = Wdx+0.001,
  focus_yh = Wdy+0.001,
  target_x = sample_det_x,
  target_y = sample_det_y,
  target_z = sample_det_z,
  time_bin = (ts+tsd+toffset)*1e6,
  time_width = Dtsd*1e6
) AT (0,0,L1) RELATIVE mod

COMPONENT det_pos = Arm()
  AT (sample_det_x,sample_det_y,sample_det_z) RELATIVE RSsample
  ROTATED (0,atan(sample_det_x/sample_det_z)*RAD2DEG,0) RELATIVE RSsample

COMPONENT resmonitor = Res_monitor(
  res_sample_comp = RSsample,
  options = "cylinder",
  xwidth = Wdx, yheight = Wdy,
  filename = "resmonitor.dat"
) AT (0,0,0) RELATIVE det_pos


More information about the mcstas-users mailing list