Skip to content
Merged
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
17 changes: 9 additions & 8 deletions sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include "art/Framework/Services/System/TriggerNamesService.h"
#include "nurandom/RandomUtils/NuRandomService.h"
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesData.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larevt/SpaceCharge/SpaceCharge.h"
Expand Down Expand Up @@ -92,6 +92,7 @@
#include "lardataobj/RecoBase/PFParticle.h"
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/TrackHitMeta.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Shower.h"
#include "lardataobj/RecoBase/MCSFitResult.h"
Expand Down Expand Up @@ -1386,15 +1387,15 @@ void CAFMaker::produce(art::Event& evt) noexcept {
}

// Prep truth-to-reco-matching info
std::map<int, std::vector<std::pair<geo::WireID, const sim::IDE*>>> id_to_ide_map;
std::map<int, std::vector<sbn::ReadoutIDE>> id_to_ide_map;
std::map<int, std::vector<art::Ptr<recob::Hit>>> id_to_truehit_map;
std::map<int, caf::HitsEnergy> id_to_hit_energy_map;

if ( !isRealData ) {
art::ServiceHandle<cheat::BackTrackerService> bt_serv;

id_to_ide_map = PrepSimChannels(simchannels, wireReadout);
id_to_truehit_map = PrepTrueHits(hits, clock_data, *bt_serv);
id_to_ide_map = sbn::PrepSimChannels(simchannels, wireReadout);
id_to_truehit_map = sbn::PrepTrueHits(hits, clock_data, *bt_serv);
id_to_hit_energy_map = SetupIDHitEnergyMap(hits, clock_data, *bt_serv);
}

Expand Down Expand Up @@ -1984,8 +1985,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FindManyPStrict<recob::Vertex>(fmPFPart, evt,
fParams.PFParticleLabel() + slice_tag_suff);

art::FindManyP<recob::Hit> fmTrackHit =
FindManyPStrict<recob::Hit>(slcTracks, evt,
art::FindManyP<recob::Hit, recob::TrackHitMeta> fmTrackHit =
FindManyPDStrict<recob::Hit, recob::TrackHitMeta>(slcTracks, evt,
fParams.RecoTrackLabel() + slice_tag_suff);

art::FindManyP<recob::Hit> fmShowerHit =
Expand Down Expand Up @@ -2239,10 +2240,10 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FillTrackDazzle(fmTrackDazzle.at(iPart).front(), trk);
}
if (fmCalo.isValid()) {
FillTrackCalo(fmCalo.at(iPart), fmTrackHit.at(iPart),
FillTrackCalo(fmCalo.at(iPart), *thisTrack[0], fmTrackHit.at(iPart), fmTrackHit.data(iPart),
(fParams.FillHitsNeutrinoSlices() && NeutrinoSlice) || fParams.FillHitsAllSlices(),
fParams.TrackHitFillRRStartCut(), fParams.TrackHitFillRREndCut(),
dprop, trk);
dprop, *sce, trk);
}

if (fmCRTHitMatch.isValid() && fDet == kICARUS) {
Expand Down
2 changes: 2 additions & 0 deletions sbncode/CAFMaker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker
larcorealg::Geometry
larcore::Geometry_Geometry_service
larcorealg::GeoAlgo
lardataalg::headers
larsim::MCCheater_BackTrackerService_service
nusimdata::SimulationBase
larsim::MCCheater_ParticleInventoryService_service
Expand Down Expand Up @@ -65,6 +66,7 @@ cet_build_plugin ( CAFMaker art::module
hep_concurrency::hep_concurrency
lardataobj::RecoBase
nurandom::RandomUtils_NuRandomService_service
lardata::DetectorPropertiesService
lardata::DetectorClocksService
BASENAME_ONLY
)
Expand Down
41 changes: 39 additions & 2 deletions sbncode/CAFMaker/FillReco.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,30 @@ namespace caf
}
}

// Helper function: get the e field
double GetEfield(const detinfo::DetectorPropertiesData& dprop, spacecharge::SpaceCharge const& sce, const geo::Point_t& loc) {

double EField = dprop.Efield();
if (sce.EnableSimEfieldSCE()) {
// Gets fractional E field distortions w.r.t. the nominal field on x-axis
geo::Vector_t EFieldOffsets = sce.GetEfieldOffsets(loc);
// Add 1 in X direction as this is the direction of the drift field, not caring if it is +x or -x direction, since we only want |E|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make double sure: does the offset as returned by sce always assume the nominal electric field to have positive x direction?
That assumption is an essential ingredient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on how the SCE map is saved. For SBN SCE studies, it is assumed the nominal electric field has positive x direction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it depends on that... unfortunately I don't see that assumption documented.
However, I see many places where that assumption is made, and if you haven't noticed anything strange in testing, that will have to do.

EFieldOffsets += geo::Vector_t{1, 0, 0};
// Convert to Absolute E Field from relative
EFieldOffsets *= EField;
// We only care about the magnitude for recombination
EField = EFieldOffsets.r();
}
return EField;
}

void FillTrackPlaneCalo(const anab::Calorimetry &calo,
const recob::Track& track,
const std::vector<art::Ptr<recob::Hit>> &hits,
const std::vector<const recob::TrackHitMeta*>& thms,
bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend,
const detinfo::DetectorPropertiesData &dprop,
const spacecharge::SpaceCharge &sce,
caf::SRTrackCalo &srcalo) {

// Collect info from Calorimetry
Expand Down Expand Up @@ -832,7 +852,8 @@ namespace caf

// lookup the wire -- the Calorimery object makes this
// __way__ harder than it should be
for (const art::Ptr<recob::Hit> &h: hits) {
for (unsigned i_hit = 0; i_hit < hits.size(); i_hit++) {
const art::Ptr<recob::Hit> &h = hits[i_hit];
if (h.key() == tps[i]) {
p.wire = h->WireID().Wire;
p.tpc = h->WireID().TPC;
Expand All @@ -844,6 +865,19 @@ namespace caf
p.mult = h->Multiplicity();
p.start = h->StartTick();
p.end = h->EndTick();


// Get the trajectory point index from this hit. Again -- this is too hard.
//
// Use this to get the (SCE corrected) efield and the angle to the drift direction
unsigned traj_point_index = thms.at(i_hit)->Index();
if (track.HasValidPoint(traj_point_index)) {
float costh_drift = track.DirectionAtPoint(traj_point_index).X();
float phi = acos(abs(costh_drift));
float efield = GetEfield(dprop, sce, track.LocationAtPoint(traj_point_index));
p.efield = efield;
p.phi = phi;
}
}
}

Expand Down Expand Up @@ -897,9 +931,12 @@ namespace caf
}

void FillTrackCalo(const std::vector<art::Ptr<anab::Calorimetry>> &calos,
const recob::Track& track,
const std::vector<art::Ptr<recob::Hit>> &hits,
const std::vector<const recob::TrackHitMeta*>& thms,
bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend,
const detinfo::DetectorPropertiesData &dprop,
const spacecharge::SpaceCharge &sce,
caf::SRTrack& srtrack,
bool allowEmpty)
{
Expand All @@ -912,7 +949,7 @@ namespace caf
if (calo.PlaneID()) {
unsigned plane_id = calo.PlaneID().Plane;
assert(plane_id < 3);
FillTrackPlaneCalo(calo, hits, fill_calo_points, fillhit_rrstart, fillhit_rrend, dprop, srtrack.calo[plane_id]);
FillTrackPlaneCalo(calo, track, hits, thms, fill_calo_points, fillhit_rrstart, fillhit_rrend, dprop, sce, srtrack.calo[plane_id]);
}
}

Expand Down
11 changes: 10 additions & 1 deletion sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "larsim/MCCheater/ParticleInventoryService.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesData.h"

// LArSoft includes
#include "larcorealg/Geometry/fwd.h"

#include "larevt/SpaceCharge/SpaceCharge.h"

#include "lardataobj/RecoBase/PFParticle.h"
#include "lardataobj/RecoBase/Shower.h"
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/TrackHitMeta.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/SpacePoint.h"
Expand Down Expand Up @@ -204,9 +207,12 @@ namespace caf
bool allowEmpty = false);

void FillTrackPlaneCalo(const anab::Calorimetry &calo,
const recob::Track& track,
const std::vector<art::Ptr<recob::Hit>> &hits,
const std::vector<const recob::TrackHitMeta*>& thms,
bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend,
const detinfo::DetectorPropertiesData &dprop,
spacecharge::SpaceCharge const& sce,
caf::SRTrackCalo &srcalo);

void FillTrackScatterClosestApproach(const art::Ptr<sbn::ScatterClosestApproach> closestapproach,
Expand All @@ -222,9 +228,12 @@ namespace caf
bool allowEmpty = false);

void FillTrackCalo(const std::vector<art::Ptr<anab::Calorimetry>> &calos,
const recob::Track& track,
const std::vector<art::Ptr<recob::Hit>> &hits,
const std::vector<const recob::TrackHitMeta*>& thms,
bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend,
const detinfo::DetectorPropertiesData &dprop,
spacecharge::SpaceCharge const& sce,
caf::SRTrack& srtrack,
bool allowEmpty = false);

Expand Down
Loading