Feature/blip energy drift correction - #941
Conversation
|
This PR is part of a set of 4 in sbndcode, sbnobj, sbncode, and sbnanaobj to make this new blip data entry, and share it to CAF level. |
|
Initial checks on MC looked good. The values of energy were very mildly shifted with temporary debug print outs like Unfortunately the detector properties service used to get the electron lifetime initially applies a fixed lifetime. We will need to connect to some kind of calibration database service to get better results on data. |
…ol easier to import
|
This PR is more complicated. This PR does not interrupt PANDORA's use of the NormalizeDriftSQLite_tool and allows blips to use NormalizeDriftSQLite_class. If we have an example of implementation of the art_tool version (that doesn't result in the code duplication seen in sbndcode/sbndcode/Calorimetry/LightCaloProducer_module.cc Lines 821 to 848 in 27d88f5 |
|
Oh oops let me get rid of the print statements I used to check the implementation. |
|
I have verified this code imports the correct lifetime values and adds additional variables to the blip larsoft output (reco2) and SRBlip output (CAF). |
|
I need to include normalizeDrift settings in the blipconfig.fcl (never pushed those changes) |
…n' into feature/BlipEnergyDriftCorrection
PetrilloAtWork
left a comment
There was a problem hiding this comment.
Left a few comments. I am particularly confused by the pattern of the tool source code.
However, I bear no authority on sbndcode, so mine should be taken just as suggestions.
| fCylinderRadius = pset.get<float> ("CylinderRadius", 15); | ||
|
|
||
| fCaloAlg = new calo::CalorimetryAlg( pset.get<fhicl::ParameterSet>("CaloAlg") ); | ||
| ElifetimeTool = new sbnd::calo::NormalizeDriftSQLite( pset.get<fhicl::ParameterSet>("NormalizeDrift")); |
There was a problem hiding this comment.
I recommend the use of std::unique_ptr here ([CF-051]). In shared SBN code, we forbid the use of new/delete, but this is not SBN code so it's up to you (I would change also the calo algorithm, rather than abiding to its questionable example).
Actually, I would go directly with an object in the class: I currently don't see a reason to allocate it dynamically; but that has also to do with a plan of future extension to other implementations.
| fESTAR_p0 = pset.get<float> ("ESTAR_p0", 0.01730); | ||
| fESTAR_p1 = pset.get<float> ("ESTAR_p1", 0.00003479); | ||
| fLifetimeCorr = pset.get<bool> ("LifetimeCorrection", false); | ||
| fLifetimeCorr = pset.get<bool> ("LifetimeCorrection", true); |
There was a problem hiding this comment.
Make sure the change of default is well advertised (also in release notes, if SBND maintains any).
| float Efield = kNominalEfield; | ||
|
|
||
| float recomb = ModBoxRecomb(fCalodEdx,Efield); | ||
| blip.EnergyNoDriftCorrection = depEl * (1./recomb) * kWion; |
There was a problem hiding this comment.
Why not just
| blip.EnergyNoDriftCorrection = depEl * (1./recomb) * kWion; | |
| blip.EnergyNoDriftCorrection = depEl / recomb * kWion; |
?
No big deal, but it feels strange.
| float energy_estar = Q_to_E_ESTAR(depEl); | ||
| float energy_pstar = Q_to_E_PSTAR(depEl); | ||
| blip.EnergyESTARNoDriftCorrection = energy_estar; | ||
| blip.EnergyPSTARNoDriftCorrection = energy_pstar; |
There was a problem hiding this comment.
It does not look like you really need that temporary parking spot any more:
| float energy_estar = Q_to_E_ESTAR(depEl); | |
| float energy_pstar = Q_to_E_PSTAR(depEl); | |
| blip.EnergyESTARNoDriftCorrection = energy_estar; | |
| blip.EnergyPSTARNoDriftCorrection = energy_pstar; | |
| blip.EnergyESTARNoDriftCorrection = Q_to_E_ESTAR(depEl); | |
| blip.EnergyPSTARNoDriftCorrection = Q_to_E_PSTAR(depEl)r; |
| energy_estar = Q_to_E_ESTAR(depEl); | ||
| energy_pstar = Q_to_E_PSTAR(depEl); //reaculate after drift correction | ||
| blip.EnergyESTAR = energy_estar; | ||
| blip.EnergyPSTAR = energy_pstar; |
There was a problem hiding this comment.
| energy_estar = Q_to_E_ESTAR(depEl); | |
| energy_pstar = Q_to_E_PSTAR(depEl); //reaculate after drift correction | |
| blip.EnergyESTAR = energy_estar; | |
| blip.EnergyPSTAR = energy_pstar; | |
| blip.EnergyESTAR = Q_to_E_ESTAR(depEl); | |
| blip.EnergyPSTAR = Q_to_E_PSTAR(depEl); //recalculate after drift correction |
| //#include "art/Framework/Core/EDProducer.h" | ||
| #include "art/Framework/Principal/Event.h" | ||
| #include "art/Framework/Principal/Handle.h" | ||
| #include "art/Framework/Services/Registry/ServiceHandle.h" | ||
| #include "art/Persistency/Common/PtrMaker.h" | ||
| #include "art/Utilities/ToolMacros.h" | ||
| #include "cetlib_except/exception.h" | ||
| #include "cetlib/cpu_timer.h" | ||
| #include "fhiclcpp/ParameterSet.h" | ||
| #include "messagefacility/MessageLogger/MessageLogger.h" | ||
|
|
||
| #include "larevt/CalibrationDBI/Providers/DBFolder.h" | ||
|
|
||
| // Tool include | ||
| #include "larreco/Calorimetry/INormalizeCharge.h" | ||
|
|
||
| // Services | ||
| #include "lardata/DetectorInfoServices/DetectorClocksService.h" | ||
|
|
||
| // Lab helpers | ||
| //#include "wda.h" | ||
|
|
||
| // C++ | ||
| #include <string> | ||
| #include <optional> | ||
| #include <cassert> |
There was a problem hiding this comment.
These headers should be sorted out... many of these are not used in the header, so they should live in the .cc file.
| //#include "art/Framework/Core/EDProducer.h" | |
| #include "art/Framework/Principal/Event.h" | |
| #include "art/Framework/Principal/Handle.h" | |
| #include "art/Framework/Services/Registry/ServiceHandle.h" | |
| #include "art/Persistency/Common/PtrMaker.h" | |
| #include "art/Utilities/ToolMacros.h" | |
| #include "cetlib_except/exception.h" | |
| #include "cetlib/cpu_timer.h" | |
| #include "fhiclcpp/ParameterSet.h" | |
| #include "messagefacility/MessageLogger/MessageLogger.h" | |
| #include "larevt/CalibrationDBI/Providers/DBFolder.h" | |
| // Tool include | |
| #include "larreco/Calorimetry/INormalizeCharge.h" | |
| // Services | |
| #include "lardata/DetectorInfoServices/DetectorClocksService.h" | |
| // Lab helpers | |
| //#include "wda.h" | |
| // C++ | |
| #include <string> | |
| #include <optional> | |
| #include <cassert> | |
| #include "art/Framework/Principal/Event.h" | |
| #include "fhiclcpp/ParameterSet.h" | |
| #include "larevt/CalibrationDBI/Providers/DBFolder.h" | |
| // Tool include | |
| #include "larreco/Calorimetry/INormalizeCharge.h" | |
| // Services | |
| #include "lardata/DetectorInfoServices/DetectorClocksService.h" | |
| // C++ | |
| #include <string> | |
| #include <optional> | |
| #include <cassert> |
#include "art/Utilities/ToolMacros.h" should be moved to the _tool.h header (which is where the tool macros are used).
Headers are needed for recob::Hit (lardataobj/RecoBase/Hit.h), geo::Point_t (larcoreobj/SimpleTypesAndConstants/geo_vectors.h), std::map (map) and uint32_t (cstdint?).
| cet_build_plugin(NormalizeDriftSQLite art::tool LIBRARIES ${TOOL_LIBRARIES}) | ||
| cet_build_plugin(NormalizeYZ art::tool LIBRARIES ${TOOL_LIBRARIES}) | ||
|
|
||
| cet_make_library(LIBRARY_NAME sbndcode_GIMME_LIFETIMES |
There was a problem hiding this comment.
While GIMME_LIFETIMES is indeed pretty straightforward and self-describing, it may complicate users' lifetime. At a certain point, from other code or from the documentation, I find out that I need the class sbnd::calo::NormalizeDriftSQLite, and I need to add its library. Normally what I would do is to look for sbndcode::NormalizeDriftSQLite or sbndcode::Calibration/TPCCalorimetry or sbndcode::Calibration/TPCCalorimetry/NormalizeDriftSQLite, but I will never guess GIMME_LIFETIMES.
There was a problem hiding this comment.
I am confused by this pattern: what is the reason for a _Definitions.h and a _class.h to coexist? what about _Implementation.cc and _class.cc?
| #################################### | ||
| product version qual flags <table_format=2> | ||
| sbncode v10_21_00 - | ||
| sbncode v10_21_02 - |
There was a problem hiding this comment.
Usually version bumps are not added to the PR, especially for merge in develop.
The reason: imagine that now a picky, annoying reviewer (ah-rum) starts giving you hard time for petty reasons. It takes one month to convince him to move forward. At that point, develop is using sbncode v10_23_00: this PR will create a conflict and will need to be fixed. Better to leave this type of updates to the release managers if needed (usually they are not).
| sbncode v10_21_02 - | |
| sbncode v10_21_00 - |
Adding additional blip energy variables so analyzers have access to a drift corrected energy, as well as an explicitly not drift corrected one.
All drift corrections are anchored to the event timestamp, so the beam blips will come out with the right energy. Any out-of-time blip activity will be mis-corrected, so the noDriftCorrection variables are saved as new variables.