Skip to content

Commit 7efe1eb

Browse files
committed
interface SPEArea DB with ophit recalibrator
1 parent a4b8813 commit 7efe1eb

9 files changed

Lines changed: 41 additions & 43 deletions

fcl/reco/Definitions/stage0_icarus_defs.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "timing_icarus.fcl"
1313
#include "timing_beam.fcl"
1414
#include "icarus_ophitfinder.fcl"
15-
#include "ophit-recalibrator.fcl"
15+
#include "ophit_recalibrator_icarus.fcl"
1616
#include "icarus_flashfinder.fcl"
1717
#include "trigger_emulation_icarus.fcl"
1818
#include "crt_decoderdefs_icarus.fcl"

fcl/reco/Stage0/partial/stage0_run2_opdetonly_icarus_data_reprocessing.fcl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ physics.path: [
2727

2828
# recalibrate optical hits
2929
physics.producers.ophit.InputLabel: "ophit::stage0" # start from hits in previous stage0 execution
30-
physics.producers.ophit.RecalibratePE: true # recalibrate PE values
31-
physics.producers.ophit.UseGainDatabase: false # not ready yet
32-
physics.producers.ophit.SPEArea: @local::SPERun2.Area # use fixed value for all channels
33-
physics.producers.ophit.RecalibrateTime: false # not needed for Run2
30+
physics.producers.ophit.RecalibratePE: true # recalibrate PE values
31+
physics.producers.ophit.UseGainDatabase: true # speArea db
32+
physics.producers.ophit.RecalibrateTime: false # not needed for Run2
3433

3534
# make sure flashes are using the new ophits
3635
# as well as the correct (non)calibration

fcl/reco/Stage0/partial/stage0_run3_opdetonly_icarus_data_reprocessing.fcl

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#include "stage0_run2_opdetonly_icarus_data_reprocessing.fcl"
22

3-
# recalibrate optical hits
4-
physics.producers.ophit.RecalibratePE: true # recalibrate PE values
5-
physics.producers.ophit.UseGainDatabase: false # not ready yet
6-
physics.producers.ophit.SPEArea: @local::SPERun4.Area # use fixed value for all channels
7-
83
physics.producers.ophit.RecalibrateTime: true # also needed for Run4
94
# these were the tags used in the initial data processing (v10_06_00_01p05)
105
physics.producers.ophit.OldTimingDBTags.CablesTag: @local::PMT_CalibrationTags_Run3_Feb2025.pmt_cables_delays_data
116
physics.producers.ophit.OldTimingDBTags.LaserTag: @local::PMT_CalibrationTags_Run3_Feb2025.pmt_laser_timing_data
12-
physics.producers.ophit.OldTimingDBTags.CosmicsTag: @local::PMT_CalibrationTags_Run3_Feb2025.pmt_cosmics_timing_data
7+
physics.producers.ophit.OldTimingDBTags.CosmicsTag: @local::PMT_CalibrationTags_Run3_Feb2025.pmt_cosmics_timing_data

icaruscode/PMT/Calibration/ICARUSPhotonCalibratorServiceFromDB.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ namespace calib {
5656

5757
ICARUSPhotonCalibratorServiceFromDB(Parameters const& params, art::ActivityRegistry& reg);
5858

59+
virtual std::string getAreaDatabaseTag() const = 0;
60+
5961
private:
6062
provider_type const* provider() const override { return &fProvider; }
6163

icaruscode/PMT/Calibration/OpHitRecalibrator_module.cc

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "icaruscode/Timing/PMTTimingCorrections.h"
1010
#include "icaruscode/Timing/IPMTTimingCorrectionService.h"
1111
#include "icaruscode/Timing/PMTTimingCorrectionsProvider.h"
12+
#include "icaruscode/PMT/Calibration/ICARUSPhotonCalibratorServiceFromDB.h"
1213

1314
// framework libraries
1415
#include "canvas/Utilities/InputTag.h"
@@ -45,25 +46,25 @@ namespace icarus
4546
* gain and/or timing calibrations, and applies new ones.
4647
* A new collection of hits is produced containing a re-calibrated copy of all the
4748
* hits from the input collections.
48-
*
49-
* The PE recalibration is simple: for each optical hit, its `PE` value is recomputed
49+
*
50+
* The PE recalibration is simple: for each optical hit, its `PE` value is recomputed
5051
* from its `Area` [ADC x tick] based on a newly determined single-PE area.
5152
* If `UseGainDatabase` is set, the module calls retrieves the SPE area by channel and run number
52-
* using the gain calibration service. If that option is disabled, a single SPE area value
53+
* using the gain calibration service. If that option is disabled, a single SPE area value
5354
* is used for all channels and run numbers. This value is read from the `SPEArea` paramater
5455
* set in the configuration.
55-
*
56-
* The timing recalibration requires removing previously-applied timing corrections and
57-
* adding the new ones. Unfortunately, however, it's not possible to easily determine
56+
*
57+
* The timing recalibration requires removing previously-applied timing corrections and
58+
* adding the new ones. Unfortunately, however, it's not possible to easily determine
5859
* which timing corrections were previsouly applied to the optical hits.
5960
* The old corrections -- that need to be removed -- are therefore obtained by locally
60-
* definining an instance of `icarusDB::PMTTimingCorrectionsProvider` and manually setting
61+
* definining an instance of `icarusDB::PMTTimingCorrectionsProvider` and manually setting
6162
* in the configuration the database tags that were used originally (`OldTimingDBTags`).
6263
* These need to be deduced by the `icaruscode` version that was used and the corresponding
6364
* settings in `calibration_database_GlobalTags_icarus.fcl`
6465
* On the other hand, the new corrections are obtained from the current timing correction
6566
* service `icarusDB::PMTTimingCorrections` as defined in `timing_icarus.fcl`.
66-
*
67+
*
6768
* Input
6869
* ------
6970
* * `std::vector<recob::OpHit>` data products (as for `InputLabels`)
@@ -83,9 +84,9 @@ namespace icarus
8384
* * `SPEArea` (double, default: -1): if not using the gain database, single-photoelectron
8485
* area in ADC x tick to be used in the PE calibration.
8586
* * `RecalibrateTime` (flag, mandatory): if set, recalibrate hit times.
86-
* * `OldTimingDBTags` (fhicl::ParameterSet, mandatory): configuration for the previously-applied timing corrections
87+
* * `OldTimingDBTags` (fhicl::ParameterSet, mandatory): configuration for the previously-applied timing corrections
8788
* that need to be removed/replace by the now ones. It should match what is tipically passed to
88-
* `icarusDB::PMTTimingCorrectionsProvider`, specifying the database tags that were used.
89+
* `icarusDB::PMTTimingCorrectionsProvider`, specifying the database tags that were used.
8990
* * `Verbose` (flag, default: `false`): verbose printing
9091
*
9192
*/
@@ -108,10 +109,11 @@ class icarus::OpHitRecalibrator : public art::SharedProducer
108109
bool const fRecalibrateTime;
109110
bool const fUseGainDatabase;
110111
double const fSPEArea;
111-
bool const fVerbose;
112+
bool const fVerbose;
112113

113-
/// Pointer to the online pmt corrections service
114+
/// Pointers to the online corrections services
114115
icarusDB::PMTTimingCorrections const &fPMTTimingCorrectionsService;
116+
icarusDB::PhotonCalibratorFromDB const &fPhotonCalibratorService;
115117

116118
/// Pointer to the provider for the old pmt corrections
117119
std::unique_ptr<icarusDB::PMTTimingCorrectionsProvider> fOldTimingProvider;
@@ -127,6 +129,7 @@ icarus::OpHitRecalibrator::OpHitRecalibrator(fhicl::ParameterSet const &config,
127129
fSPEArea{config.get<double>("SPEArea", -1.)},
128130
fVerbose{config.get<bool>("Verbose", false)},
129131
fPMTTimingCorrectionsService{*(lar::providerFrom<icarusDB::IPMTTimingCorrectionService const>())},
132+
fPhotonCalibratorService{*(lar::providerFrom<icarusDB::ICARUSPhotonCalibratorServiceFromDB const>())},
130133
fOldTimingProvider{std::make_unique<icarusDB::PMTTimingCorrectionsProvider>(config.get<fhicl::ParameterSet>("OldTimingDBTags"))}
131134
{
132135
async<art::InEvent>();
@@ -141,7 +144,7 @@ icarus::OpHitRecalibrator::OpHitRecalibrator(fhicl::ParameterSet const &config,
141144
if (!fRecalibratePE && !fRecalibrateTime)
142145
{
143146
throw art::Exception{art::errors::Configuration}
144-
<< "No re-calibration selected. Why are you running meeee!?!?! :/\n";
147+
<< "No re-calibration selected. Why are you even running meeee,!?!?! :/\n";
145148
}
146149

147150
if (fRecalibratePE && !fUseGainDatabase && (fSPEArea < 0))
@@ -161,11 +164,10 @@ icarus::OpHitRecalibrator::OpHitRecalibrator(fhicl::ParameterSet const &config,
161164
<< " -> new " << fPMTTimingCorrectionsService.getCosmicsDatabaseTag();
162165
}
163166

164-
// FIXME: temporary since no gain db exists yet...
165-
if (fUseGainDatabase)
167+
if (fRecalibratePE && fUseGainDatabase)
166168
{
167-
throw art::Exception{art::errors::Configuration}
168-
<< "Gain database interface doesn't exist yet. Try again later.\n";
169+
mf::LogInfo("OpHitRecalibrator") << "Re-calibration of PE (gain) enabled:\n"
170+
<< "AreaTag: " << fPhotonCalibratorService.getAreaDatabaseTag();
169171
}
170172

171173
// Consumes
@@ -218,9 +220,16 @@ void icarus::OpHitRecalibrator::produce(art::Event &event, art::ProcessingFrame
218220

219221
if (fUseGainDatabase)
220222
{
221-
// soon...
222-
// newSPEArea = get_from_db(opHit.OpChannel())
223+
// service directly returns PE from area and channel
224+
// compute SPE area back for logging purposes
225+
hitPE = fPhotonCalibratorService.PE(opHit.Area(), opHit.OpChannel());
226+
newSPEArea = opHit.Area() / hitPE;
223227
}
228+
else
229+
{
230+
// simple re-computation
231+
hitPE = opHit.Area() / newSPEArea;
232+
}
224233

225234
if (log)
226235
{
@@ -230,9 +239,7 @@ void icarus::OpHitRecalibrator::produce(art::Event &event, art::ProcessingFrame
230239
<< " (old SPEArea: " << oldSPEArea
231240
<< ") --> new PE " << opHit.Area() / newSPEArea
232241
<< " (new SPEArea: " << newSPEArea << ")\n";
233-
}
234-
235-
hitPE = opHit.Area() / newSPEArea;
242+
}
236243
}
237244

238245
// Second, recalibrate PMT times (if enabled)

icaruscode/PMT/Calibration/PhotonCalibratorFromDB.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ icarusDB::PhotonCalibratorFromDB::PhotonCalibratorFromDB(const Config& config)
3737
: fCalibDefaults( config.Defaults() )
3838
, fVerbose ( config.Verbose() )
3939
, fLogCategory ( config.LogCategory() )
40+
, fAreaTag ( config.AreaTag() )
4041
, fDB ( config.DBname(), "", "", config.AreaTag(), true, false)
4142
{
4243
mf::LogInfo(fLogCategory)

icaruscode/PMT/Calibration/PhotonCalibratorFromDB.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace icarusDB::details {
3030

3131
/// Area [positive, ADC count sum] of response to single photoelectron.
3232
double speArea = -1.0;
33-
3433
double speAreaErr = -1.0; /// Uncertainty on `speArea` [ADC count sum]
3534
double speFitWidth = -1.0;
3635
double speFitWidthErr = -1.0;
@@ -149,13 +148,17 @@ class icarusDB::PhotonCalibratorFromDB: public calib::IPhotonCalibrator {
149148
*/
150149
std::uint64_t RunToDatabaseTimestamp( unsigned int run ) const;
151150

151+
/// Get current area database tag
152+
std::string getAreaDatabaseTag() const override { return fAreaTag; }
153+
152154
private:
153155

154156
using PhotonCalibratorInfo = details::PhotonCalibratorInfo;
155157

156158
PhotonCalibratorInfo const fCalibDefaults; ///< Default calibration values.
157159
bool const fVerbose;
158160
std::string const fLogCategory;
161+
std::string const fAreaTag;
159162

160163
lariov::DBFolder fDB; ///< Cached database interface.
161164

@@ -168,7 +171,6 @@ class icarusDB::PhotonCalibratorFromDB: public calib::IPhotonCalibrator {
168171
return (it == fDatabaseSPECalibrations.end())? fCalibDefaults: it->second;
169172
}
170173

171-
172174
}; // class icarusDB::PhotonCalibratorFromDB
173175

174176

icaruscode/PMT/Calibration/fcl/ophit-recalibrator.fcl renamed to icaruscode/PMT/Calibration/fcl/ophit_recalibrator_icarus.fcl

File renamed without changes.

0 commit comments

Comments
 (0)