You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Absolutely, I would like to make some of the mcplextra tools from dgcode available in the mcpl release as well. It won't be part of the mcpltool executable itself though, as that one should not depend on C++ code, but likely in some other optional command line tool.
I would like to remind anyone interested in this that it is not difficult to write a simple C programme which does the same as ess_mcplextra_filterfile. Here is the example from https://mctools.github.io/mcpl/usage_c/ without comments, showing how to extract all neutrons with ekin below some threshold:
#include "mcpl.h"
#include <stdio.h>
int main(int argc,char**argv) {
if (argc!=3) {
printf("Please supply input and output filenames\n");
return 1;
}
mcpl_file_t fi = mcpl_open_file(argv[1]);
mcpl_outfile_t fo = mcpl_create_outfile(argv[2]);
mcpl_transfer_metadata(fi, fo);
mcpl_hdr_add_comment(fo,"Applied custom filter to select neutrons with ekin<0.1MeV");
const mcpl_particle_t* particle;
while ( ( particle = mcpl_read(fi) ) ) {
if ( particle->pdgcode == 2112 && particle->ekin < 0.1 )
mcpl_add_particle(fo,particle);
}
mcpl_close_outfile(fo);
mcpl_close_file(fi);
}
Having access to the nice "filtering grammar" from the DG code "ess_mcplextra_filterfile" in the general mcpltool (fat version) would be nice.
For now I have implemented a quick and dirty solution / example for McStas specific use, available through the instrument files
https://github.com/McStasMcXtrace/McCode/blob/master/mcstas-comps/examples/MCPL_filter_energy.instr and https://github.com/McStasMcXtrace/McCode/blob/master/mcstas-comps/examples/MCPL_filter_radius.instr
(which for the McStas savvy allows to do to similar filtering operations)
The text was updated successfully, but these errors were encountered: