# FunctorFactory: Fix DisableJIT behaviour and better feedback

- Propagate the owner requesting a functor to FunctorFactory and print it in error messages and debug logs.
- Write a .log file next to each .cpp with functors. It contains the same lines plus the list algorithms that registered each functor. This is a separate file to avoid unnecessary ccache misses.
- The control flow for the functor cache creation case
(
`DisableJIT=True`

+`DisableCache=True`

) is simplified. -
`DisableJIT=True`

will also prevent using an alredy existing .so that was made in a previous run with JIT enabled. In practice, disabling JIT means that all functors must be found in the cache. - If JIT is disabled and not all functors are in the cache, the start transition will fail and ERROR messages will be printed with complete details of the missing functors.
- Add
`JitKeepTemp`

property to control whether cpp (and log) files are kept when functors are JIT compiled. This replaces controlling that behaviour with OutputLevel.

Example extract of error messages:

```
FunctorFactory FATAL DisableJIT (THOR_DISABLE_JIT env var) is true but the following functors are not in the functor cache.
FunctorFactory ERROR missing functor 0x1fd64325dcb8a2 registered by TwoBodyCombiner/Femtoscopy_DpOmega_43de0d93
Python repr: ( ( SUM(Functor=( RHO_COORDINATE @ THREEMOMENTUM )) > 1000.0 ) & ( MASS < 4118.901795256401 ) & MAXDOCACUT(thresh=1.0) )
CPP code: Functors::all_of( operator>( ::Functors::Adapters::Accumulate( /* The functor to accumulate the return value of. */ Functors::chain( ::Functors::Common::Rho_Coordinate{}, :>
FunctorFactory ERROR missing functor 0x1fd64325dcb8a2 registered by TwoBodyCombiner/Femtoscopy_DpOmega_b3e38646
Python repr: ( ( SUM(Functor=( RHO_COORDINATE @ THREEMOMENTUM )) > 1000.0 ) & ( MASS < 4118.901795256401 ) & MAXDOCACUT(thresh=1.0) )
CPP code: Functors::all_of( operator>( ::Functors::Adapters::Accumulate( /* The functor to accumulate the return value of. */ Functors::chain( ::Functors::Common::Rho_Coordinate{}, :>
FunctorFactory ERROR missing functor 0x2881e26d342a5c registered by TwoBodyCombiner/TwoBodyCombiner_4ad808aa
Python repr: ( MAXDOCACUT(thresh=0.1) & ( ( CHILD(Index=1, Functor=( RHO_COORDINATE @ THREEMOMENTUM )) * CHILD(Index=2, Functor=( RHO_COORDINATE @ THREEMOMENTUM )) ) > 1000000.0 >
CPP code: Functors::all_of( ::Functors::Combination::MaxDistanceOfClosestApproachCut( /* Threshold for cut */ 0.1f ), operator>( operator*( ::Functors::Adapters::Child( /* The index >
```

Example extract of .log file:

`Moore/build.x86_64_v2-el9-gcc12-dbg/MooreCache/Moore_FunctorCache_Hlt2_options_sprucing_spruce_production_2023_1_srcs/FUNCTORS_FunctorFactory_0011.log`

```
===================================================
// ( ( MASS < 5280.0 ) & ( DOCACHI2(Child1=1, Child2=2) < 25 ) )
std::unique_ptr<Functors::AnyFunctor> factory_0x6a723bff69a74bee(){
return std::unique_ptr<Functors::AnyFunctor>{new Functors::Functor<bool (LHCb::ParticleCombination<LHCb::Particle,LHCb::Particle> const&)>(Functors::all_of( operator<( ::Functors::Composi>
}
::Gaudi::PluginService::DeclareFactory<Functors::AnyFunctor, ::Gaudi::PluginService::Factory<Functors::AnyFunctor*()>>
functor_0x6a723bff69a74bee{
std::string{"0x6a723bff69a74bee"},
factory_0x6a723bff69a74bee
};
requested from:ThreeBodyCombiner/bandq_BdToJpsiKpPim_JpsiToMuMu_fbdde878
===================================================
// ( ::Functors::math::in_range( 5100.0, MASS, 5700.0 ) & ( ( VALUE_OR(Value=nan) @ _CHI2DOF ) < 7 ) & ( _BPVIPCHI2.bind( _TES(DataHandles=[DataHandle('/Event/RecV1ToPVConverter_5d099e8f/Ou>
std::unique_ptr<Functors::AnyFunctor> factory_0x6acbf4f93172c9fb(){
return std::unique_ptr<Functors::AnyFunctor>{new Functors::Functor<bool (LHCb::Particle const&)>(Functors::all_of( ::Functors::math::in_range( 5100.0f, ::Functors::Composite::Mass{}, 5700>
}
::Gaudi::PluginService::DeclareFactory<Functors::AnyFunctor, ::Gaudi::PluginService::Factory<Functors::AnyFunctor*()>>
functor_0x6acbf4f93172c9fb{
std::string{"0x6acbf4f93172c9fb"},
factory_0x6acbf4f93172c9fb
};
requested from:FourBodyCombiner/B2OCB2DHHHCombiner_da6fc2c3
requested from:FourBodyCombiner/B2OCB2DHHHCombiner_817ef1e7
===================================================
```

Edited by Rosen Matev