LDMX-Software / ldmx-sw

The Light Dark Matter eXperiment simulation and reconstruction framework.
https://ldmx-software.github.io
GNU General Public License v3.0
22 stars 20 forks source link

Move DetectorConstruction and ParallelWorld msgs under the logger system #1414

Closed tvami closed 2 months ago

tvami commented 2 months ago

Is your feature request related to a problem? Please describe.

Now that I'm debugging with setting the logging to very high numbers, I still see the "Adding .. to parallel world" msgs, etc.

Describe the solution you'd like

I'd like to move https://github.com/LDMX-Software/ldmx-sw/blob/trunk/SimCore/src/SimCore/ParallelWorld.cxx#L27 and https://github.com/LDMX-Software/ldmx-sw/blob/trunk/SimCore/src/SimCore/DetectorConstruction.cxx#L141 under the ldmx_log(debug)

tvami commented 2 months ago

Not as trivial as I thought:

``` In file included from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:22, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Conditions.h:21, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/EventProcessor.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/ConditionsInterface.h:12, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/Geo/Parser.h:11, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/DetectorConstruction.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:1: /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx: In lambda function: /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: 'this' was not captured for this lambda function 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: 'this' was not captured for this lambda function 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx: In instantiation of 'simcore::DetectorConstruction::ConstructSDandField():: [with auto:2 = std::shared_ptr]': /usr/include/c++/11/bits/stl_algo.h:3820:5: required from '_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = __gnu_cxx::__normal_iterator*, std::vector, std::allocator > > >; _Funct = simcore::DetectorConstruction::ConstructSDandField()::]' /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/Factory.h:284:18: required from 'void simcore::Factory::apply(UnaryFunction) const [with UnaryFunction = simcore::DetectorConstruction::ConstructSDandField()::; Prototype = simcore::XsecBiasingOperator; PrototypePtr = std::shared_ptr; PrototypeConstructorArgs = {std::__cxx11::basic_string, std::allocator >, const framework::config::Parameters&}]' /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:152:53: required from here /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: 'this' was not captured for this lambda function 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: invalid use of non-static data member 'simcore::DetectorConstruction::theLog_' 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ In file included from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Conditions.h:21, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/EventProcessor.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/ConditionsInterface.h:12, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/Geo/Parser.h:11, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/DetectorConstruction.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:1: /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:137:40: note: declared here 137 | mutable ::framework::logging::logger theLog_{ \ | ^~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:137:40: note: in definition of macro 'enableLogging' 137 | mutable ::framework::logging::logger theLog_{ \ | ^~~~~~~ In file included from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:22, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Conditions.h:21, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/EventProcessor.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/ConditionsInterface.h:12, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/Geo/Parser.h:11, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/DetectorConstruction.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:1: /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: 'this' was not captured for this lambda function 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:146:37: error: invalid use of non-static data member 'simcore::DetectorConstruction::theLog_' 146 | #define ldmx_log(lvl) BOOST_LOG_SEV(theLog_, ::framework::logging::level::lvl) | ^ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:176:9: note: in expansion of macro 'ldmx_log' 176 | ldmx_log(debug) | ^~~~~~~~ In file included from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Conditions.h:21, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/EventProcessor.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/ConditionsInterface.h:12, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/Geo/Parser.h:11, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/include/SimCore/DetectorConstruction.h:13, from /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/SimCore/src/SimCore/DetectorConstruction.cxx:1: /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:137:40: note: declared here 137 | mutable ::framework::logging::logger theLog_{ \ | ^~~~~~~ /sdf/home/t/tamasvami/BugFixes/temp/ldmx-sw/Framework/include/Framework/Logger.h:137:40: note: in definition of macro 'enableLogging' 137 | mutable ::framework::logging::logger theLog_{ \ | ^~~~~~~ ```
tomeichlersmith commented 2 months ago

The ldmx_log macro just assumes the the logger theLog_ is in-scope. enableLogging is a macro that defines theLog_ for a specific class as a member variable. You should put enableLogging within a class declaration and, if not possible, just make sure theLog_ is created in-scope somewhere.

Specifically, I'm guessing the "lambda stuff" you are seeing is from

https://github.com/LDMX-Software/ldmx-sw/blob/2e2dbd342a7ee9a350da12d247efb773ce3a9005/SimCore/src/SimCore/DetectorConstruction.cxx#L149-L152

where we are applying the same (lambda) function to each XsecBiasingOperator. You will need to update this lambda to capture the local variables ([] -> [&]) so that this is available to retrieve theLog_.

(copied from slack for posterity).