From 2569b6809a11454aa25fe5235d9a2e774b60541c Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 9 Feb 2022 11:13:52 +0100 Subject: [PATCH 1/7] CMakeLists. Adding mcpl headers --- CMakeLists.txt | 5 +++++ src/TRestAxionMCPLOptics.cxx | 1 + 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22b497c1..7f4ce542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,11 @@ endif (${REST_SOLAXFLUX} MATCHES "ON") set( external_libs ${external_libs} -lmpfr ) +file(GLOB_RECURSE addon_src + "mcpl.c" ) + +set(addon_inc ${CMAKE_CURRENT_SOURCE_DIR}/external/mcpl) + COMPILELIB("") INSTALL(DIRECTORY ./data/ diff --git a/src/TRestAxionMCPLOptics.cxx b/src/TRestAxionMCPLOptics.cxx index 594cdf6e..e20c8d6f 100644 --- a/src/TRestAxionMCPLOptics.cxx +++ b/src/TRestAxionMCPLOptics.cxx @@ -63,6 +63,7 @@ /// #include "TRestAxionMCPLOptics.h" +#include "mcpl.h" using namespace std; From 1467c7e2bd65006c1d9e16180617427c3c45533a Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 9 Feb 2022 12:46:20 +0100 Subject: [PATCH 2/7] Updating README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index be1655a3..3cc4f3ee 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,10 @@ cd framework/build cmake -DRESTLIB_AXION=ON ../ make -j4 install ``` + +### Publications + +This repository makes use of the following published codes: +- K. Altenmuller et al, REST-for-Physics, a ROOT-based framework for event oriented data analysis and combined Monte Carlo response, [Computer Physics Communications 273, April 2022, 108281](https://doi.org/10.1016/j.cpc.2021.108281). +- S.Hoof, J.Jaeckel, T.J.Lennert, Quantifying uncertainties in the solar axion flux and their impact on determining axion model parameters, [JCAP09(2021)006](https://doi.org/10.1088/1475-7516/2021/09/006). +- T.Kittelmann, E.Klinkby, E.B.Knudsen, P.Willendrup, X.X.Cai, K.Kanaki, Monte Carlo Particle Lists: MCPL, Computer Physics Communications 218 (2017) 17–42](http://dx.doi.org/10.17632/cby92vsv5g.1). From 7159d9ecd15b6e25dbb8821b8b2fdd555a054c76 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 9 Feb 2022 12:48:10 +0100 Subject: [PATCH 3/7] README.md minor fixes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3cc4f3ee..ca33a831 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,6 @@ make -j4 install ### Publications This repository makes use of the following published codes: -- K. Altenmuller et al, REST-for-Physics, a ROOT-based framework for event oriented data analysis and combined Monte Carlo response, [Computer Physics Communications 273, April 2022, 108281](https://doi.org/10.1016/j.cpc.2021.108281). -- S.Hoof, J.Jaeckel, T.J.Lennert, Quantifying uncertainties in the solar axion flux and their impact on determining axion model parameters, [JCAP09(2021)006](https://doi.org/10.1088/1475-7516/2021/09/006). -- T.Kittelmann, E.Klinkby, E.B.Knudsen, P.Willendrup, X.X.Cai, K.Kanaki, Monte Carlo Particle Lists: MCPL, Computer Physics Communications 218 (2017) 17–42](http://dx.doi.org/10.17632/cby92vsv5g.1). +- K. Altenmuller et al, *REST-for-Physics, a ROOT-based framework for event oriented data analysis and combined Monte Carlo response*, [Computer Physics Communications 273, April 2022, 108281](https://doi.org/10.1016/j.cpc.2021.108281). +- S.Hoof, J.Jaeckel, T.J.Lennert, *Quantifying uncertainties in the solar axion flux and their impact on determining axion model parameters*, [JCAP09(2021)006](https://doi.org/10.1088/1475-7516/2021/09/006). +- T.Kittelmann, E.Klinkby, E.B.Knudsen, P.Willendrup, X.X.Cai, K.Kanaki, *Monte Carlo Particle Lists: MCPL*, [Computer Physics Communications 218 (2017) 17–42](http://dx.doi.org/10.17632/cby92vsv5g.1). From 2013b548f740655684ca2e751a1520699201cdee Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 9 Feb 2022 12:49:46 +0100 Subject: [PATCH 4/7] README.md updating DOI --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca33a831..117cf858 100644 --- a/README.md +++ b/README.md @@ -65,4 +65,4 @@ make -j4 install This repository makes use of the following published codes: - K. Altenmuller et al, *REST-for-Physics, a ROOT-based framework for event oriented data analysis and combined Monte Carlo response*, [Computer Physics Communications 273, April 2022, 108281](https://doi.org/10.1016/j.cpc.2021.108281). - S.Hoof, J.Jaeckel, T.J.Lennert, *Quantifying uncertainties in the solar axion flux and their impact on determining axion model parameters*, [JCAP09(2021)006](https://doi.org/10.1088/1475-7516/2021/09/006). -- T.Kittelmann, E.Klinkby, E.B.Knudsen, P.Willendrup, X.X.Cai, K.Kanaki, *Monte Carlo Particle Lists: MCPL*, [Computer Physics Communications 218 (2017) 17–42](http://dx.doi.org/10.17632/cby92vsv5g.1). +- T.Kittelmann, E.Klinkby, E.B.Knudsen, P.Willendrup, X.X.Cai, K.Kanaki, *Monte Carlo Particle Lists: MCPL*, [Computer Physics Communications 218 (2017) 17–42](https://doi.org/10.1016/j.cpc.2017.04.012). From e72bcf87c391cad39772d0339d432d4351450f97 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 10 Feb 2022 09:08:53 +0100 Subject: [PATCH 5/7] TRestAxionMCPLOptics. Integrating MCPL files loading (WIP) --- inc/TRestAxionMCPLOptics.h | 2 ++ src/TRestAxionMCPLOptics.cxx | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/inc/TRestAxionMCPLOptics.h b/inc/TRestAxionMCPLOptics.h index d225367c..a1f9ce49 100644 --- a/inc/TRestAxionMCPLOptics.h +++ b/inc/TRestAxionMCPLOptics.h @@ -38,6 +38,8 @@ class TRestAxionMCPLOptics : public TRestAxionOptics { std::string fOutputMCPLFilename; public: + Int_t LoadMCPLFiles(); + void PrintMetadata(); void InitFromConfigFile(); diff --git a/src/TRestAxionMCPLOptics.cxx b/src/TRestAxionMCPLOptics.cxx index e20c8d6f..8154a54e 100644 --- a/src/TRestAxionMCPLOptics.cxx +++ b/src/TRestAxionMCPLOptics.cxx @@ -115,6 +115,54 @@ void TRestAxionMCPLOptics::Initialize() { SetSectionName(this->ClassName()); SetLibraryVersion(LIBRARY_VERSION); + + if (fInputMCPLFilename != "" && fOutputMCPLFilename != "") LoadMCPLFiles(); +} + +/////////////////////////////////////////////// +/// \brief Method to load inside the class the MCPL files +/// +Int_t TRestAxionMCPLOptics::LoadMCPLFiles() { + string fname = fInputMCPLFilename; + if (fname.find("https") == 0) fname = TRestTools::DownloadRemoteFile(fname); + mcpl_file_t f = mcpl_open_file(fname.c_str()); + + string fname2 = fOutputMCPLFilename; + if (fname2.find("https") == 0) fname2 = TRestTools::DownloadRemoteFile(fname2); + mcpl_file_t g = mcpl_open_file(fname2.c_str()); + + const mcpl_particle_t *p, *q; + while ((p = mcpl_read(f))) { + q = mcpl_read(g); + + cout << "Input MCPL file (detector_plane)" << endl; + cout << "--------------------------------" << endl; + cout << "X: " << p->position[0] << " Y: " << p->position[1] << " Z: " << p->position[2] << endl; + cout << "pX: " << p->direction[0] << " pY: " << p->direction[1] << " pZ: " << p->direction[2] << endl; + cout << "polX: " << p->polarisation[0] << " polY: " << p->polarisation[1] + << " polZ: " << p->polarisation[2] << endl; + cout << "Ekin = " << p->ekin << endl; + cout << "Time = " << p->time << endl; + cout << "Weight = " << p->weight << endl; + cout << "User flags = " << p->userflags << endl; + cout << endl; + cout << "Output MCPL file (post_optics)" << endl; + cout << "--------------------------------" << endl; + cout << "X: " << q->position[0] << " Y: " << q->position[1] << " Z: " << q->position[2] << endl; + cout << "pX: " << q->direction[0] << " pY: " << q->direction[1] << " pZ: " << q->direction[2] << endl; + cout << "polX: " << q->polarisation[0] << " polY: " << q->polarisation[1] + << " polZ: " << q->polarisation[2] << endl; + cout << "Ekin = " << q->ekin << endl; + cout << "Time = " << q->time << endl; + cout << "Weight = " << q->weight << endl; + cout << "User flags = " << q->userflags << endl; + cout << endl; + + getchar(); + } + mcpl_close_file(f); + + return 0; } /////////////////////////////////////////////// From f006e1e4fa18b304df7dba2be8bff859d7456b51 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 10 Feb 2022 09:57:15 +0100 Subject: [PATCH 6/7] pipeline/optics. Updating setup.rml --- pipeline/optics/setups.rml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pipeline/optics/setups.rml b/pipeline/optics/setups.rml index f7bae717..103ae166 100644 --- a/pipeline/optics/setups.rml +++ b/pipeline/optics/setups.rml @@ -1,5 +1,5 @@ - + @@ -8,9 +8,9 @@ - - + + From bfeab775a2427cc17c8f8c8eb6f9d8eefef3652c Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 10 Feb 2022 09:58:27 +0100 Subject: [PATCH 7/7] Applying clang-format --- external/mcpl/mcpl.h | 355 +++++++++++++++-------------- inc/TRestAxionGeneratorProcess.h | 2 +- inc/TRestAxionLikelihood.h | 8 +- inc/mpreal.h | 7 +- src/TRestAxionGeneratorProcess.cxx | 3 +- src/TRestAxionMagneticField.cxx | 6 +- src/TRestAxionSolarModel.cxx | 6 +- 7 files changed, 195 insertions(+), 192 deletions(-) diff --git a/external/mcpl/mcpl.h b/external/mcpl/mcpl.h index 0028bfd9..443abd0e 100644 --- a/external/mcpl/mcpl.h +++ b/external/mcpl/mcpl.h @@ -22,7 +22,7 @@ #define MCPL_VERSION_MAJOR 1 #define MCPL_VERSION_MINOR 3 #define MCPL_VERSION_PATCH 2 -#define MCPL_VERSION 10302 /* (10000*MAJOR+100*MINOR+PATCH) */ +#define MCPL_VERSION 10302 /* (10000*MAJOR+100*MINOR+PATCH) */ #define MCPL_VERSION_STR "1.3.2" #define MCPL_FORMATVERSION 3 /* Format version of written files */ @@ -30,190 +30,193 @@ extern "C" { #endif - /*********/ - /* Types */ - /*********/ +/*********/ +/* Types */ +/*********/ -#pragma pack (push, 1) +#pragma pack(push, 1) - /* The data structure representing a particle (note that persistification of */ - /* polarisation and userflags must be explicitly enabled when writing .mcpl */ - /* files, or they will simply contain zeroes when the file is read): */ +/* The data structure representing a particle (note that persistification of */ +/* polarisation and userflags must be explicitly enabled when writing .mcpl */ +/* files, or they will simply contain zeroes when the file is read): */ - typedef struct { +typedef struct { double ekin; /* kinetic energy [MeV] */ double polarisation[3]; /* polarisation vector */ double position[3]; /* position [cm] */ double direction[3]; /* momentum direction (unit vector) */ double time; /* time-stamp [millisecond] */ double weight; /* weight or intensity */ - int32_t pdgcode; /* MC particle number from the Particle Data Group (2112=neutron, 22=gamma, ...) */ - uint32_t userflags; /* User flags (if used, the file header should probably contain information about how). */ - } mcpl_particle_t; - -#pragma pack (pop) - - typedef struct { void * internal; } mcpl_file_t; /* file-object used while reading .mcpl */ - typedef struct { void * internal; } mcpl_outfile_t; /* file-object used while writing .mcpl */ - - /****************************/ - /* Creating new .mcpl files */ - /****************************/ - - /* Instantiate new file object (will also open and override specified file) */ - mcpl_outfile_t mcpl_create_outfile(const char * filename); - - const char * mcpl_outfile_filename(mcpl_outfile_t);/* filename being written to (might have had .mcpl appended) */ - - /* Optionally set global options or add info to the header: */ - void mcpl_hdr_set_srcname(mcpl_outfile_t, const char *);/* Name of the generating application */ - void mcpl_hdr_add_comment(mcpl_outfile_t, const char *);/* Add one or more human-readable comments */ - void mcpl_hdr_add_data(mcpl_outfile_t, const char * key, - uint32_t ldata, const char * data);/* add binary blobs by key */ - void mcpl_enable_userflags(mcpl_outfile_t);/* to write the "userflags" info */ - void mcpl_enable_polarisation(mcpl_outfile_t);/* to write the "polarisation" info */ - void mcpl_enable_doubleprec(mcpl_outfile_t);/* use double precision FP numbers in storage */ - void mcpl_enable_universal_pdgcode(mcpl_outfile_t, int32_t pdgcode);/* All particles are of the same type */ - void mcpl_enable_universal_weight(mcpl_outfile_t, double w);/* All particles have the same weight */ - - /* Optionally (but rarely skipped) add particles, by updating the info in */ - /* and then passing in a pointer to an mcpl_particle_t instance: */ - void mcpl_add_particle(mcpl_outfile_t,const mcpl_particle_t*); - - /* Finally, always remember to close the file: */ - void mcpl_close_outfile(mcpl_outfile_t); - - /* Alternatively close with (will call mcpl_gzip_file after close). */ - /* Returns non-zero if gzipping was succesful: */ - int mcpl_closeandgzip_outfile(mcpl_outfile_t); - - /* Convenience function which returns a pointer to a nulled-out particle - struct which can be used to edit and pass to mcpl_add_particle. It can be - reused and will be automatically free'd when the file is closed: */ - mcpl_particle_t* mcpl_get_empty_particle(mcpl_outfile_t); - - /***********************/ - /* Reading .mcpl files */ - /***********************/ - - /* Open file and load header information into memory, skip to the first (if */ - /* any) particle in the list: */ - mcpl_file_t mcpl_open_file(const char * filename); - - /* Access header data: */ - unsigned mcpl_hdr_version(mcpl_file_t);/* file format version (not the same as MCPL_VERSION) */ - uint64_t mcpl_hdr_nparticles(mcpl_file_t);/* number of particles stored in file */ - const char* mcpl_hdr_srcname(mcpl_file_t);/* Name of the generating application */ - unsigned mcpl_hdr_ncomments(mcpl_file_t);/* number of comments stored in file */ - const char * mcpl_hdr_comment(mcpl_file_t, unsigned icomment);/* access i'th comment */ - int mcpl_hdr_nblobs(mcpl_file_t); - const char** mcpl_hdr_blobkeys(mcpl_file_t);/* returns 0 if there are no keys */ - int mcpl_hdr_blob(mcpl_file_t, const char* key, - uint32_t* ldata, const char ** data);/* access data (returns 0 if key doesn't exist) */ - int mcpl_hdr_has_userflags(mcpl_file_t); - int mcpl_hdr_has_polarisation(mcpl_file_t); - int mcpl_hdr_has_doubleprec(mcpl_file_t); - uint64_t mcpl_hdr_header_size(mcpl_file_t);/* bytes consumed by header (uncompressed) */ - int mcpl_hdr_particle_size(mcpl_file_t);/* bytes per particle (uncompressed) */ - int32_t mcpl_hdr_universal_pdgcode(mcpl_file_t);/* returns 0 in case of per-particle pdgcode */ - double mcpl_hdr_universal_weight(mcpl_file_t);/* returns 0.0 in case of per-particle weights */ - int mcpl_hdr_little_endian(mcpl_file_t); - - /* Request pointer to particle at current location and skip forward to the next */ - /* particle. Return value will be null in case there was no particle at the */ - /* current location (normally due to end-of-file): */ - const mcpl_particle_t* mcpl_read(mcpl_file_t); - - /* Seek and skip in particles (returns 0 when there is no particle at the new position): */ - int mcpl_skipforward(mcpl_file_t,uint64_t n); - int mcpl_rewind(mcpl_file_t); - int mcpl_seek(mcpl_file_t,uint64_t ipos); - uint64_t mcpl_currentposition(mcpl_file_t); - - /* Deallocate memory and release file-handle with: */ - void mcpl_close_file(mcpl_file_t); - - /***********************************/ - /* Other operations on .mcpl files */ - /***********************************/ - - /* Dump information about the file to std-output: */ - /* parts : 0 -> header+particle list, 1 -> just header, 2 -> just particle list. */ - /* nlimit: maximum number of particles to list (0 for unlimited) */ - /* nskip : index of first particle in the file to list. */ - void mcpl_dump(const char * file, int parts, uint64_t nskip, uint64_t nlimit); - - /* Merge contents of a list of files by concatenating all particle contents into a */ - /* new file, file_output. This results in an error unless all meta-data and settings */ - /* in the files are identical. Also fails if file_output already exists. Note that */ - /* the return value is a handle to the output file which has not yet been closed: */ - mcpl_outfile_t mcpl_merge_files( const char* file_output, - unsigned nfiles, const char ** files); - - /* Test if files could be merged by mcpl_merge_files: */ - int mcpl_can_merge(const char * file1, const char* file2); - - /* Similar to mcpl_merge_files, but merges two files by appending all particles in */ - /* file2 to the list in file1 (thus file1 grows while file2 stays untouched). */ - /* Note that this requires similar version of the MCPL format of the two files, in */ - /* addition to the other checks in mcpl_can_merge(). */ - /* Careful usage of this function can be more efficient than mcpl_merge_files. */ - void mcpl_merge_inplace(const char * file1, const char* file2); - - /* Attempt to merge incompatible files, by throwing away meta-data and otherwise */ - /* selecting a configuration which is suitable to contain the data of all files. */ - /* Userflags will be discarded unless keep_userflags=1. */ - /* If called with compatible files, the code will fall back to calling the usual */ - /* mcpl_merge_files function instead. */ - mcpl_outfile_t mcpl_forcemerge_files( const char* file_output, - unsigned nfiles, const char ** files, - int keep_userflags ); - - - /* Attempt to fix number of particles in the header of a file which was never */ - /* properly closed: */ - void mcpl_repair(const char * file1); - - /* For easily creating a standard mcpl-tool cmdline application: */ - int mcpl_tool(int argc, char** argv); - - /* Attempt to run gzip on a file (does not require MCPL_HASZLIB on unix) */ - /* Returns non-zero if gzipping was succesful. */ - int mcpl_gzip_file(const char * filename); - - /* Convenience function which transfers all settings, blobs and comments to */ - /* target. Intended to make it easy to filter files via custom C code. */ - void mcpl_transfer_metadata(mcpl_file_t source, mcpl_outfile_t target); - - /* Function which can be used when transferring particles from one MCPL file */ - /* to another. A particle must have been already read from the source file */ - /* with a call to mcpl_read(..). This function will transfer the packed par- */ - /* ticle data exactly when possible (using mcpl_add_particle can in principle */ - /* introduce tiny numerical uncertainties due to the internal unpacking and */ - /* repacking of direction vectors involved): */ - void mcpl_transfer_last_read_particle(mcpl_file_t source, mcpl_outfile_t target); - - /******************/ - /* Error handling */ - /******************/ - - /* Override the error handler which will get called with the error */ - /* description. If no handler is set, errors will get printed to stdout and the */ - /* process terminated. An error handler should not return to the calling code. */ - void mcpl_set_error_handler(void (*handler)(const char *)); - - /**********************/ - /* Obsolete functions */ - /**********************/ - - /* Functions kept for backwards compatibility. They keep working for now, but */ - /* usage will result in a warning printed to stdout, notifying users to update */ - /* their code. */ - - void mcpl_merge(const char *, const char*);/* Obsolete name for mcpl_merge_inplace */ - int mcpl_gzip_file_rc(const char * filename);/* Obsolete name for mcpl_gzip_file */ - int mcpl_closeandgzip_outfile_rc(mcpl_outfile_t);/* Obsolete name for mcpl_closeandgzip_outfile_rc */ - int32_t mcpl_hdr_universel_pdgcode(mcpl_file_t);/* Obsolete name for mcpl_hdr_universal_pdgcode */ + int32_t pdgcode; /* MC particle number from the Particle Data Group (2112=neutron, 22=gamma, ...) */ + uint32_t + userflags; /* User flags (if used, the file header should probably contain information about how). */ +} mcpl_particle_t; + +#pragma pack(pop) + +typedef struct { + void* internal; +} mcpl_file_t; /* file-object used while reading .mcpl */ +typedef struct { + void* internal; +} mcpl_outfile_t; /* file-object used while writing .mcpl */ + +/****************************/ +/* Creating new .mcpl files */ +/****************************/ + +/* Instantiate new file object (will also open and override specified file) */ +mcpl_outfile_t mcpl_create_outfile(const char* filename); + +const char* mcpl_outfile_filename( + mcpl_outfile_t); /* filename being written to (might have had .mcpl appended) */ + +/* Optionally set global options or add info to the header: */ +void mcpl_hdr_set_srcname(mcpl_outfile_t, const char*); /* Name of the generating application */ +void mcpl_hdr_add_comment(mcpl_outfile_t, const char*); /* Add one or more human-readable comments */ +void mcpl_hdr_add_data(mcpl_outfile_t, const char* key, uint32_t ldata, + const char* data); /* add binary blobs by key */ +void mcpl_enable_userflags(mcpl_outfile_t); /* to write the "userflags" info */ +void mcpl_enable_polarisation(mcpl_outfile_t); /* to write the "polarisation" info */ +void mcpl_enable_doubleprec(mcpl_outfile_t); /* use double precision FP numbers in storage */ +void mcpl_enable_universal_pdgcode(mcpl_outfile_t, int32_t pdgcode); /* All particles are of the same type */ +void mcpl_enable_universal_weight(mcpl_outfile_t, double w); /* All particles have the same weight */ + +/* Optionally (but rarely skipped) add particles, by updating the info in */ +/* and then passing in a pointer to an mcpl_particle_t instance: */ +void mcpl_add_particle(mcpl_outfile_t, const mcpl_particle_t*); + +/* Finally, always remember to close the file: */ +void mcpl_close_outfile(mcpl_outfile_t); + +/* Alternatively close with (will call mcpl_gzip_file after close). */ +/* Returns non-zero if gzipping was succesful: */ +int mcpl_closeandgzip_outfile(mcpl_outfile_t); + +/* Convenience function which returns a pointer to a nulled-out particle + struct which can be used to edit and pass to mcpl_add_particle. It can be + reused and will be automatically free'd when the file is closed: */ +mcpl_particle_t* mcpl_get_empty_particle(mcpl_outfile_t); + +/***********************/ +/* Reading .mcpl files */ +/***********************/ + +/* Open file and load header information into memory, skip to the first (if */ +/* any) particle in the list: */ +mcpl_file_t mcpl_open_file(const char* filename); + +/* Access header data: */ +unsigned mcpl_hdr_version(mcpl_file_t); /* file format version (not the same as MCPL_VERSION) */ +uint64_t mcpl_hdr_nparticles(mcpl_file_t); /* number of particles stored in file */ +const char* mcpl_hdr_srcname(mcpl_file_t); /* Name of the generating application */ +unsigned mcpl_hdr_ncomments(mcpl_file_t); /* number of comments stored in file */ +const char* mcpl_hdr_comment(mcpl_file_t, unsigned icomment); /* access i'th comment */ +int mcpl_hdr_nblobs(mcpl_file_t); +const char** mcpl_hdr_blobkeys(mcpl_file_t); /* returns 0 if there are no keys */ +int mcpl_hdr_blob(mcpl_file_t, const char* key, uint32_t* ldata, + const char** data); /* access data (returns 0 if key doesn't exist) */ +int mcpl_hdr_has_userflags(mcpl_file_t); +int mcpl_hdr_has_polarisation(mcpl_file_t); +int mcpl_hdr_has_doubleprec(mcpl_file_t); +uint64_t mcpl_hdr_header_size(mcpl_file_t); /* bytes consumed by header (uncompressed) */ +int mcpl_hdr_particle_size(mcpl_file_t); /* bytes per particle (uncompressed) */ +int32_t mcpl_hdr_universal_pdgcode(mcpl_file_t); /* returns 0 in case of per-particle pdgcode */ +double mcpl_hdr_universal_weight(mcpl_file_t); /* returns 0.0 in case of per-particle weights */ +int mcpl_hdr_little_endian(mcpl_file_t); + +/* Request pointer to particle at current location and skip forward to the next */ +/* particle. Return value will be null in case there was no particle at the */ +/* current location (normally due to end-of-file): */ +const mcpl_particle_t* mcpl_read(mcpl_file_t); + +/* Seek and skip in particles (returns 0 when there is no particle at the new position): */ +int mcpl_skipforward(mcpl_file_t, uint64_t n); +int mcpl_rewind(mcpl_file_t); +int mcpl_seek(mcpl_file_t, uint64_t ipos); +uint64_t mcpl_currentposition(mcpl_file_t); + +/* Deallocate memory and release file-handle with: */ +void mcpl_close_file(mcpl_file_t); + +/***********************************/ +/* Other operations on .mcpl files */ +/***********************************/ + +/* Dump information about the file to std-output: */ +/* parts : 0 -> header+particle list, 1 -> just header, 2 -> just particle list. */ +/* nlimit: maximum number of particles to list (0 for unlimited) */ +/* nskip : index of first particle in the file to list. */ +void mcpl_dump(const char* file, int parts, uint64_t nskip, uint64_t nlimit); + +/* Merge contents of a list of files by concatenating all particle contents into a */ +/* new file, file_output. This results in an error unless all meta-data and settings */ +/* in the files are identical. Also fails if file_output already exists. Note that */ +/* the return value is a handle to the output file which has not yet been closed: */ +mcpl_outfile_t mcpl_merge_files(const char* file_output, unsigned nfiles, const char** files); + +/* Test if files could be merged by mcpl_merge_files: */ +int mcpl_can_merge(const char* file1, const char* file2); + +/* Similar to mcpl_merge_files, but merges two files by appending all particles in */ +/* file2 to the list in file1 (thus file1 grows while file2 stays untouched). */ +/* Note that this requires similar version of the MCPL format of the two files, in */ +/* addition to the other checks in mcpl_can_merge(). */ +/* Careful usage of this function can be more efficient than mcpl_merge_files. */ +void mcpl_merge_inplace(const char* file1, const char* file2); + +/* Attempt to merge incompatible files, by throwing away meta-data and otherwise */ +/* selecting a configuration which is suitable to contain the data of all files. */ +/* Userflags will be discarded unless keep_userflags=1. */ +/* If called with compatible files, the code will fall back to calling the usual */ +/* mcpl_merge_files function instead. */ +mcpl_outfile_t mcpl_forcemerge_files(const char* file_output, unsigned nfiles, const char** files, + int keep_userflags); + +/* Attempt to fix number of particles in the header of a file which was never */ +/* properly closed: */ +void mcpl_repair(const char* file1); + +/* For easily creating a standard mcpl-tool cmdline application: */ +int mcpl_tool(int argc, char** argv); + +/* Attempt to run gzip on a file (does not require MCPL_HASZLIB on unix) */ +/* Returns non-zero if gzipping was succesful. */ +int mcpl_gzip_file(const char* filename); + +/* Convenience function which transfers all settings, blobs and comments to */ +/* target. Intended to make it easy to filter files via custom C code. */ +void mcpl_transfer_metadata(mcpl_file_t source, mcpl_outfile_t target); + +/* Function which can be used when transferring particles from one MCPL file */ +/* to another. A particle must have been already read from the source file */ +/* with a call to mcpl_read(..). This function will transfer the packed par- */ +/* ticle data exactly when possible (using mcpl_add_particle can in principle */ +/* introduce tiny numerical uncertainties due to the internal unpacking and */ +/* repacking of direction vectors involved): */ +void mcpl_transfer_last_read_particle(mcpl_file_t source, mcpl_outfile_t target); + +/******************/ +/* Error handling */ +/******************/ + +/* Override the error handler which will get called with the error */ +/* description. If no handler is set, errors will get printed to stdout and the */ +/* process terminated. An error handler should not return to the calling code. */ +void mcpl_set_error_handler(void (*handler)(const char*)); + +/**********************/ +/* Obsolete functions */ +/**********************/ + +/* Functions kept for backwards compatibility. They keep working for now, but */ +/* usage will result in a warning printed to stdout, notifying users to update */ +/* their code. */ + +void mcpl_merge(const char*, const char*); /* Obsolete name for mcpl_merge_inplace */ +int mcpl_gzip_file_rc(const char* filename); /* Obsolete name for mcpl_gzip_file */ +int mcpl_closeandgzip_outfile_rc(mcpl_outfile_t); /* Obsolete name for mcpl_closeandgzip_outfile_rc */ +int32_t mcpl_hdr_universel_pdgcode(mcpl_file_t); /* Obsolete name for mcpl_hdr_universal_pdgcode */ #ifdef __cplusplus } diff --git a/inc/TRestAxionGeneratorProcess.h b/inc/TRestAxionGeneratorProcess.h index 8ee70714..1a8a9630 100644 --- a/inc/TRestAxionGeneratorProcess.h +++ b/inc/TRestAxionGeneratorProcess.h @@ -40,7 +40,7 @@ class TRestAxionGeneratorProcess : public TRestEventProcess { Int_t fCounter = 0; //! /// A pointer to the axion model stored in TRestRun - TRestAxionSpectrum *fAxionSpectrum; //! + TRestAxionSpectrum* fAxionSpectrum; //! /// Random number generator TRandom3* fRandom; //! diff --git a/inc/TRestAxionLikelihood.h b/inc/TRestAxionLikelihood.h index 9a2e51a3..31f7e383 100644 --- a/inc/TRestAxionLikelihood.h +++ b/inc/TRestAxionLikelihood.h @@ -25,10 +25,10 @@ #include -#include "TRestAxionSpectrum.h" #include "TRestAxionBufferGas.h" #include "TRestAxionPhotonConversion.h" #include "TRestAxionSolarModel.h" +#include "TRestAxionSpectrum.h" #include "TRandom3.h" @@ -63,9 +63,9 @@ class TRestAxionLikelihood : public TRestMetadata { Double_t fLastStepDensity = 0.; //-> - TRestAxionPhotonConversion *fPhotonConversion; //! - TRestAxionBufferGas *fBufferGas; //! - TRestAxionSpectrum *fAxionSpectrum; //! + TRestAxionPhotonConversion* fPhotonConversion; //! + TRestAxionBufferGas* fBufferGas; //! + TRestAxionSpectrum* fAxionSpectrum; //! /// Random number generator TRandom3* fRandom; //! diff --git a/inc/mpreal.h b/inc/mpreal.h index 24e286be..45c3bfce 100644 --- a/inc/mpreal.h +++ b/inc/mpreal.h @@ -125,9 +125,10 @@ #endif // Less important options -#define MPREAL_DOUBLE_BITS_OVERFLOW -1 // Triggers overflow exception during conversion to double if mpreal - // cannot fit in MPREAL_DOUBLE_BITS_OVERFLOW bits - // = -1 disables overflow checks (default) +#define MPREAL_DOUBLE_BITS_OVERFLOW \ + -1 // Triggers overflow exception during conversion to double if mpreal + // cannot fit in MPREAL_DOUBLE_BITS_OVERFLOW bits + // = -1 disables overflow checks (default) // Fast replacement for mpfr_set_zero(x, +1): // (a) uses low-level data members, might not be compatible with new versions of MPFR diff --git a/src/TRestAxionGeneratorProcess.cxx b/src/TRestAxionGeneratorProcess.cxx index ffd1dc2c..a3596fc7 100644 --- a/src/TRestAxionGeneratorProcess.cxx +++ b/src/TRestAxionGeneratorProcess.cxx @@ -126,8 +126,7 @@ void TRestAxionGeneratorProcess::InitProcess() { /// Double_t TRestAxionGeneratorProcess::GenerateEnergy() { debug << "Entering TRestAxionGeneratorProcess::GenerateEnergy() ..." << endl; - Double_t solarFlux = - fAxionSpectrum->GetSolarAxionFlux(fEnergyRange.X(), fEnergyRange.Y(), fEnergyStep); + Double_t solarFlux = fAxionSpectrum->GetSolarAxionFlux(fEnergyRange.X(), fEnergyRange.Y(), fEnergyStep); Double_t random = solarFlux * fRandom->Uniform(0, 1.0); diff --git a/src/TRestAxionMagneticField.cxx b/src/TRestAxionMagneticField.cxx index 2252a0db..2d0c4832 100644 --- a/src/TRestAxionMagneticField.cxx +++ b/src/TRestAxionMagneticField.cxx @@ -1080,9 +1080,9 @@ TVector3 TRestAxionMagneticField::GetFieldAverageTransverseVector(TVector3 from, if ((length > 0) && (numberofpoints > 0)) { Bavg = Bavg * (1.0 / numberofpoints); // calculates the average magnetic field vector - BTavg = Bavg - - (Bavg * direction) * - direction; // calculates the transverse component of the average magnetic field vector + BTavg = + Bavg - (Bavg * direction) * + direction; // calculates the transverse component of the average magnetic field vector debug << "B average vector = (" << Bavg.x() << ", " << Bavg.y() << ", " << Bavg.z() << ")" << endl; debug << "Transverse B average vector = (" << BTavg.x() << ", " << BTavg.y() << ", " << BTavg.z() << ")" << endl; diff --git a/src/TRestAxionSolarModel.cxx b/src/TRestAxionSolarModel.cxx index f51d1ef3..a286fa7d 100644 --- a/src/TRestAxionSolarModel.cxx +++ b/src/TRestAxionSolarModel.cxx @@ -20,7 +20,7 @@ * For the list of contributors see $REST_PATH/CREDITS. * *************************************************************************/ -/***************** DOXYGEN DOCUMENTATION ******************************** +////////////////////////////////////////////////////////////////////////// /// TRestAxionSolarModel is a class used to calculate all axion interaction /// rates in the Sun based on a solar model and opacity code. The main /// purpose of the class is to return the two types of solar axion spectra, @@ -49,11 +49,11 @@ /// Sebastian Hoof /// /// \class TRestAxionSolarModel -/// \author Javier Galan, Sebastian Hoof +/// \author Javier Galan +/// \author Sebastian Hoof /// ///
/// - *************************************************************************/ #include "TRestAxionSolarModel.h"