Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BEGIN_PROLOG

ICARUS_Calibration_GlobalTags: {
@table::TPC_CalibrationTags_Jan2025
@table::TPC_CalibrationTags_Jul2025
@table::PMT_CalibrationTags_Run3_Feb2025
@table::CRT_CalibrationTags_Oct2023
}
Expand Down
11 changes: 11 additions & 0 deletions fcl/configurations/calibration_database_TPC_TagSets_icarus.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ TPC_CalibrationTags_Jan2025: {

}

## TPC_CalibrationTags_Jul2024
# Update to 2D deconv tags. Change TPC equalization to be per-plane
TPC_CalibrationTags_Jul2025: {

tpc_channelstatus_data: "v3r4"
tpc_elifetime_data: "v3r0"
tpc_dqdxcalibration_allplanes_data: "v1r0"
tpc_yz_correction_allplanes_data: "v2r0"

}

END_PROLOG
24 changes: 24 additions & 0 deletions fcl/reco/Definitions/stage1_icarus_defs.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,28 @@ icarus_stage1_producers.SBNShowerGausCryoW.UseAllParticles:
icarus_stage1_producers.SBNShowerGausCryoE.PFParticleLabel: "pandoraGausCryoE"
icarus_stage1_producers.SBNShowerGausCryoE.UseAllParticles: true

applyNorm: true

icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[7].CalorimetryAlg: @local::icarus_calorimetryalgdata
icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[7].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[7].NormTools: @local::icarus_calonormtools
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[7].CalorimetryAlg: @local::icarus_calorimetryalgdata
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[7].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[7].NormTools: @local::icarus_calonormtools

icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[5].CalorimetryAlg: @local::icarus_calorimetryalgdata
icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[5].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[5].NormTools: @local::icarus_calonormtools
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[5].CalorimetryAlg: @local::icarus_calorimetryalgdata
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[5].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[5].NormTools: @local::icarus_calonormtools

icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[3].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoE.ShowerFinderTools[3].NormTools: @local::icarus_calonormtools
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[3].ApplyCorrectionsInNorm: @local::applyNorm
icarus_stage1_producers.SBNShowerGausCryoW.ShowerFinderTools[3].NormTools: @local::icarus_calonormtools

# Set supera input fcl files
icarus_stage1_analyzers.superaMC.supera_params: "supera_icarus_MC_all_cryo_PMT_CRT_v10.fcl"

END_PROLOG
33 changes: 33 additions & 0 deletions fcl/reco/Stage1/mc/stage1_run2_icarus_MC.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,39 @@ physics.producers.mcreco.MCParticleDroppedLabel: "largeant:droppedMCParticles"
physics.producers.mcreco.MCRecoPart.SavePathPDGList: [13,-13,211,-211,111,311,310,130,321,-321,2212,2112,2224,2214,2114,1114,3122,1000010020,1000010030,1000020030,1000020040]
physics.producers.mcreco.MCRecoPart.TrackIDOffsets: [0,10000000,20000000] #Account for track ID offsets in labeling primaries

runPeriod: 2

physics.producers.SBNShowerGausCryoE.ShowerFinderTools[7].CalorimetryAlg: @local::icarus_calorimetryalgmc
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[7].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[7].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[7].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[7].NormTools[1].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[7].CalorimetryAlg: @local::icarus_calorimetryalgmc
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[7].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[7].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[7].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[7].NormTools[1].MC: @local::runPeriod

physics.producers.SBNShowerGausCryoE.ShowerFinderTools[5].CalorimetryAlg: @local::icarus_calorimetryalgmc
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[5].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[5].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[5].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[5].NormTools[1].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[5].CalorimetryAlg: @local::icarus_calorimetryalgmc
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[5].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[5].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[5].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[5].NormTools[1].MC: @local::runPeriod

physics.producers.SBNShowerGausCryoE.ShowerFinderTools[3].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[3].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[3].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoE.ShowerFinderTools[3].NormTools[1].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[3].ApplyCorrectionsInNorm: true
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[3].NormTools: @local::icarus_calonormtoolsMC
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[3].NormTools[0].MC: @local::runPeriod
physics.producers.SBNShowerGausCryoW.ShowerFinderTools[3].NormTools[1].MC: @local::runPeriod

services.message.destinations :
{
STDCOUT:
Expand Down
2 changes: 2 additions & 0 deletions icaruscode/TPC/Calorimetry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ cet_build_plugin(NormalizeDriftSQLite art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeDrift art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeTPCSQL art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeTPC art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeTPCPerPlaneSQL art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeTPCPerPlane art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeTPCLocal art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeWire art::tool LIBRARIES ${TOOL_LIBRARIES})
cet_build_plugin(NormalizeYZSQL art::tool LIBRARIES ${TOOL_LIBRARIES})
Expand Down
147 changes: 147 additions & 0 deletions icaruscode/TPC/Calorimetry/NormalizeTPCPerPlaneSQL_tool.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// Framework Includes
#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/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>

namespace icarus {
namespace calo {

class NormalizeTPCPerPlaneSQL : public INormalizeCharge
{
public:
NormalizeTPCPerPlaneSQL(fhicl::ParameterSet const &pset);

void configure(const fhicl::ParameterSet& pset) override;
double Normalize(double dQdx, const art::Event &e, const recob::Hit &h, const geo::Point_t &location, const geo::Vector_t &direction, double t0) override;

private:
// Configuration
std::string fDBFileName;
std::string fDBTag;
bool fVerbose;
int fMC;

lariov::DBFolder fDB;

// Class to hold data from DB
class ScaleInfo {
public:
std::map<unsigned, double> scale;
};

// Helpers
ScaleInfo GetScaleInfo(uint64_t run);

// Cache run requests
std::map<uint64_t, ScaleInfo> fScaleInfos;
};

DEFINE_ART_CLASS_TOOL(NormalizeTPCPerPlaneSQL)

} // end namespace calo
} // end namespace icarus


icarus::calo::NormalizeTPCPerPlaneSQL::NormalizeTPCPerPlaneSQL(fhicl::ParameterSet const &pset):
fDBFileName(pset.get<std::string>("DBFileName")),
fDBTag(pset.get<std::string>("DBTag")),
fVerbose(pset.get<bool>("Verbose", false)),
fMC(pset.get<int>("MC")),
fDB(fDBFileName, "", "", fDBTag, true, false) {}

void icarus::calo::NormalizeTPCPerPlaneSQL::configure(const fhicl::ParameterSet& pset) {}

icarus::calo::NormalizeTPCPerPlaneSQL::ScaleInfo icarus::calo::NormalizeTPCPerPlaneSQL::GetScaleInfo(uint64_t run) {

// check the cache
if (fScaleInfos.count(run)) {
return fScaleInfos.at(run);
}

// Look up the run
//
// Translate the run into a fake "timestamp"
fDB.UpdateData((run+1000000000)*1000000000);

// Collect the run info
ScaleInfo thisscale;

// Iterate over the rows
for (unsigned ch = 0; ch < 12; ch++) {
double scale;
fDB.GetNamedChannelData(ch, "scale", scale);

thisscale.scale[ch] = scale;
}
// Set the cache
fScaleInfos[run] = thisscale;

return thisscale;
}

double icarus::calo::NormalizeTPCPerPlaneSQL::Normalize(double dQdx, const art::Event &e,
const recob::Hit &hit, const geo::Point_t &location, const geo::Vector_t &direction, double t0) {

// Get the info
uint64_t runID = -1;
switch (fMC) {
case 1:
runID = 8460;
break;
case 2:
runID = 9301;
break;
case 3:
runID = 11806;
break;
case 4:
runID = 12960;
break;
case 5:
runID = 14079;
break;
default:
runID = e.id().runID().run();
break;
}

ScaleInfo const& i = GetScaleInfo(runID);

// Lookup the TPC, cryo
unsigned tpc = hit.WireID().TPC;
unsigned cryo = hit.WireID().Cryostat;
unsigned plane = hit.WireID().Plane;

// Get the TPC-Plane index
unsigned itpc_plane = 2*cryo + tpc/2 + plane*4;

double scale = 1;

// TODO: what to do if no scale is found? throw an exception??
if (i.scale.count(itpc_plane)) scale = i.scale.at(itpc_plane);

if (fVerbose) std::cout << "NormalizeTPCPerPlaneSQL Tool -- Data at Cryo: " << cryo << " TPC: " << tpc << " Plane: " << plane << " itpc_plane: " << itpc_plane << " scale: " << scale << std::endl;

return dQdx * scale;
}

Loading