LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
sce::SCECorrection Class Reference
Inheritance diagram for sce::SCECorrection:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 SCECorrection (fhicl::ParameterSet const &p)
 
 SCECorrection (SCECorrection const &)=delete
 
 SCECorrection (SCECorrection &&)=delete
 
SCECorrectionoperator= (SCECorrection const &)=delete
 
SCECorrectionoperator= (SCECorrection &&)=delete
 
void produce (art::Event &evt) override
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

geo::Vector_t applyT0Shift (const double &t0, const geo::TPCID &tpcId) const
 
std::map< art::Ptr< anab::T0 >, bool > getSliceT0s (const art::Event &evt, const std::vector< art::Ptr< recob::PFParticle >> &slicePFPs, const art::Handle< std::vector< recob::PFParticle >> &pfpHandle, const art::Handle< std::vector< recob::Track >> &trackHandle, const art::FindManyP< recob::Track > &fmPFPTrack) const
 
std::pair< art::Ptr< anab::T0 >, bool > getSliceBestT0 (const std::map< art::Ptr< anab::T0 >, bool > &sliceT0CorrectMap) const
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeom
 
spacecharge::SpaceCharge const * fSCE
 
const bool fCorrectNoT0Tag
 
const bool fCorrectSCE
 
const bool fSCEXCorrFlip
 
const std::string fPFPLabel
 
const std::string fTrackLabel
 
const std::vector< std::string > fT0Labels
 
const std::vector< bool > fT0LabelsCorrectT0
 

Detailed Description

Definition at line 44 of file SCECorrection_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

sce::SCECorrection::SCECorrection ( fhicl::ParameterSet const &  p)
explicit

Definition at line 83 of file SCECorrection_module.cc.

References fCorrectNoT0Tag, fCorrectSCE, fPFPLabel, fSCE, fSCEXCorrFlip, fT0Labels, fT0LabelsCorrectT0, and fTrackLabel.

84  : EDProducer{p}
85  , fSCE(lar::providerFrom<spacecharge::SpaceChargeService>())
86  , fCorrectNoT0Tag(p.get<bool>("CorrectNoT0Tag"))
87  , fCorrectSCE(p.get<bool>("CorrectSCE"))
88  , fSCEXCorrFlip(p.get<bool>("SCEXCorrFlip"))
89  , fPFPLabel(p.get<std::string>("PFPLabel"))
90  , fTrackLabel(p.get<std::string>("TrackLabel"))
91  , fT0Labels(p.get<std::vector<std::string>>("T0Labels"))
92  , fT0LabelsCorrectT0(p.get<std::vector<bool>>("T0LabelsCorrectT0"))
93 {
94  produces<std::vector<anab::T0>>();
95  produces<std::vector<recob::Slice>>();
96  produces<std::vector<recob::PFParticle>>();
97  produces<std::vector<recob::SpacePoint>>();
98  produces<std::vector<recob::Cluster>>();
99  produces<std::vector<recob::Vertex>>();
100  produces<std::vector<larpandoraobj::PFParticleMetadata>>();
101 
102  produces<art::Assns<anab::T0, recob::PFParticle>>();
103  produces<art::Assns<recob::Slice, recob::Hit>>();
104 
105  produces<art::Assns<recob::PFParticle, recob::Slice>>();
106  produces<art::Assns<recob::PFParticle, recob::SpacePoint>>();
107  produces<art::Assns<recob::PFParticle, recob::Vertex>>();
108  produces<art::Assns<recob::PFParticle, recob::Cluster>>();
109  produces<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>();
110  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
111  produces<art::Assns<recob::Cluster, recob::Hit>>();
112 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
spacecharge::SpaceCharge const * fSCE
const std::string fPFPLabel
const std::vector< bool > fT0LabelsCorrectT0
const std::string fTrackLabel
const std::vector< std::string > fT0Labels
sce::SCECorrection::SCECorrection ( SCECorrection const &  )
delete
sce::SCECorrection::SCECorrection ( SCECorrection &&  )
delete

Member Function Documentation

geo::Vector_t sce::SCECorrection::applyT0Shift ( const double &  t0,
const geo::TPCID tpcId 
) const
private

Definition at line 374 of file SCECorrection_module.cc.

References geo::TPCGeo::DriftAxisWithSign(), fGeom, pmtana::sign(), geo::to_int(), geo::GeometryCore::TPC(), geo::X, geo::Y, and geo::Z.

Referenced by produce().

376 {
377  auto const [axis, sign] = fGeom->TPC(tpcId).DriftAxisWithSign();
378  switch (axis) {
379  case geo::Coordinate::X: return geo::Vector_t{t0Offset * to_int(sign), 0, 0};
380  case geo::Coordinate::Y: return geo::Vector_t{0, t0Offset * to_int(sign), 0};
381  case geo::Coordinate::Z: return geo::Vector_t{0, 0, t0Offset * to_int(sign)};
382  }
383  return {}; // unreachable
384 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
DriftAxis DriftAxisWithSign() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.h:78
constexpr int to_int(Coordinate const coord) noexcept
Enumerate the possible plane projections.
Definition: geo_types.h:124
int sign(double val)
Definition: UtilFunc.cxx:104
art::ServiceHandle< geo::Geometry > fGeom
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::pair< art::Ptr< anab::T0 >, bool > sce::SCECorrection::getSliceBestT0 ( const std::map< art::Ptr< anab::T0 >, bool > &  sliceT0CorrectMap) const
private

Definition at line 432 of file SCECorrection_module.cc.

References util::abs(), and DEFINE_ART_MODULE.

Referenced by produce().

434 {
435 
436  if (!sliceT0CorrectMap.size()) { return std::pair<art::Ptr<anab::T0>, bool>(); }
437 
438  double minT0 = std::numeric_limits<double>::max();
439  std::pair<art::Ptr<anab::T0>, bool> sliceT0CorrectPair;
440  for (auto const& sliceT0CorrectIter : sliceT0CorrectMap) {
441  double t0Time = abs(sliceT0CorrectIter.first->Time());
442  if (t0Time < minT0) {
443  minT0 = t0Time;
444  sliceT0CorrectPair = sliceT0CorrectIter;
445  }
446  }
447  return sliceT0CorrectPair;
448 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::map< art::Ptr< anab::T0 >, bool > sce::SCECorrection::getSliceT0s ( const art::Event evt,
const std::vector< art::Ptr< recob::PFParticle >> &  slicePFPs,
const art::Handle< std::vector< recob::PFParticle >> &  pfpHandle,
const art::Handle< std::vector< recob::Track >> &  trackHandle,
const art::FindManyP< recob::Track > &  fmPFPTrack 
) const
private

Definition at line 386 of file SCECorrection_module.cc.

References fT0Labels, fT0LabelsCorrectT0, and art::Ptr< T >::key().

Referenced by produce().

392 {
393 
394  std::map<art::Ptr<anab::T0>, bool> pfpT0CorrectMap;
395  // Loop over all of the PFPs in the slice
396  for (auto const& pfp : slicePFPs) {
397 
398  // Loop over all of the T0 labels
399  // We will take the first label to have a T0, so the order matters
400  for (unsigned int i = 0; i < fT0Labels.size(); i++) {
401  std::string t0Label = fT0Labels.at(i);
402 
403  // Get the T0
404  art::FindManyP<anab::T0> fmPFPT0(pfpHandle, evt, t0Label);
405  if (fmPFPT0.isValid()) {
406  std::vector<art::Ptr<anab::T0>> pfpT0s = fmPFPT0.at(pfp.key());
407  if (pfpT0s.size() == 1) {
408  pfpT0CorrectMap[pfpT0s.front()] = fT0LabelsCorrectT0.at(i);
409  break;
410  }
411  }
412  // If not, Check the track associated to the PFP
413  if (!fmPFPTrack.isValid()) continue;
414  std::vector<art::Ptr<recob::Track>> pfpTracks = fmPFPTrack.at(pfp.key());
415  if (pfpTracks.size() != 1) { continue; }
416  art::Ptr<recob::Track> pfpTrack = pfpTracks.front();
417 
418  // Check if the track has a T0
419  art::FindManyP<anab::T0> fmTrackT0(trackHandle, evt, t0Label);
420  if (fmTrackT0.isValid()) {
421  std::vector<art::Ptr<anab::T0>> trackT0s = fmTrackT0.at(pfpTrack.key());
422  if (trackT0s.size() == 1) {
423  pfpT0CorrectMap[trackT0s.front()] = fT0LabelsCorrectT0.at(i);
424  break;
425  }
426  }
427  } // fT0Labels
428  } // slicePFPs
429  return pfpT0CorrectMap;
430 }
const std::vector< bool > fT0LabelsCorrectT0
key_type key() const noexcept
Definition: Ptr.h:166
const std::vector< std::string > fT0Labels
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
SCECorrection& sce::SCECorrection::operator= ( SCECorrection const &  )
delete
SCECorrection& sce::SCECorrection::operator= ( SCECorrection &&  )
delete
void sce::SCECorrection::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 114 of file SCECorrection_module.cc.

References applyT0Shift(), geo::PlaneID::asTPCID(), spacecharge::SpaceCharge::EnableCalSpatialSCE(), fCorrectNoT0Tag, fCorrectSCE, art::fill_ptr_vector(), fPFPLabel, fSCE, fSCEXCorrFlip, fTrackLabel, art::ProductRetriever::getByLabel(), spacecharge::SpaceCharge::GetCalPosOffsets(), getSliceBestT0(), getSliceT0s(), art::Ptr< T >::isNull(), art::Ptr< T >::key(), art::Event::put(), geo::TPCID::TPC, and recob::Hit::WireID().

115 {
116  // Implementation of required member function here.
117  auto t0Collection = std::make_unique<std::vector<anab::T0>>();
118  auto pfpCollection = std::make_unique<std::vector<recob::PFParticle>>();
119  auto clusterCollection = std::make_unique<std::vector<recob::Cluster>>();
120  auto spCollection = std::make_unique<std::vector<recob::SpacePoint>>();
121  auto vtxCollection = std::make_unique<std::vector<recob::Vertex>>();
122  auto sliceCollection = std::make_unique<std::vector<recob::Slice>>();
123  auto pfpMetaCollection = std::make_unique<std::vector<larpandoraobj::PFParticleMetadata>>();
124 
125  auto t0PFPAssn = std::make_unique<art::Assns<anab::T0, recob::PFParticle>>();
126  auto sliceHitAssn = std::make_unique<art::Assns<recob::Slice, recob::Hit>>();
127  auto pfpSliceAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Slice>>();
128  auto pfpVtxAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Vertex>>();
129  auto pfpSPAssn = std::make_unique<art::Assns<recob::PFParticle, recob::SpacePoint>>();
130  auto pfpClusterAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Cluster>>();
131  auto pfpMetaAssn =
132  std::make_unique<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>();
133  auto spHitAssn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
134  auto clusterHitAssn = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
135 
136  art::PtrMaker<anab::T0> t0PtrMaker{evt};
137  art::PtrMaker<recob::PFParticle> pfpPtrMaker{evt};
138  art::PtrMaker<recob::Cluster> clusterPtrMaker{evt};
139  art::PtrMaker<recob::Vertex> vtxPtrMaker{evt};
140  art::PtrMaker<recob::Slice> slicePtrMaker{evt};
141  art::PtrMaker<recob::SpacePoint> spPtrMaker{evt};
143 
144  // Get all the slices in the event
146  std::vector<art::Ptr<recob::Slice>> allSlices;
147  if (evt.getByLabel(fPFPLabel, sliceHandle)) art::fill_ptr_vector(allSlices, sliceHandle);
148 
149  // Get all the Clusters in the event
151  std::vector<art::Ptr<recob::Cluster>> allClusters;
152  if (evt.getByLabel(fPFPLabel, clusterHandle)) art::fill_ptr_vector(allClusters, clusterHandle);
153 
154  // Get all the SpacePoints in the event
156  std::vector<art::Ptr<recob::SpacePoint>> allSpacePoints;
157  if (evt.getByLabel(fPFPLabel, spHandle)) art::fill_ptr_vector(allSpacePoints, spHandle);
158 
159  // Get all the PFParticles in the event
161  std::vector<art::Ptr<recob::PFParticle>> allPFParticles;
162  if (evt.getByLabel(fPFPLabel, pfpHandle)) art::fill_ptr_vector(allPFParticles, pfpHandle);
163 
164  // Get all the Tracks in the event
166  std::vector<art::Ptr<recob::Track>> allTracks;
167  if (evt.getByLabel(fTrackLabel, trackHandle)) art::fill_ptr_vector(allTracks, trackHandle);
168 
169  art::FindManyP<recob::PFParticle> fmSlicePFP(sliceHandle, evt, fPFPLabel);
170  art::FindManyP<recob::Track> fmPFPTrack(pfpHandle, evt, fTrackLabel);
171  art::FindManyP<recob::SpacePoint> fmPFPSP(pfpHandle, evt, fPFPLabel);
172  art::FindManyP<recob::Cluster> fmPFPCluster(pfpHandle, evt, fPFPLabel);
173  art::FindManyP<recob::Vertex> fmPFPVertex(pfpHandle, evt, fPFPLabel);
174  art::FindManyP<recob::Hit> fmClusterHit(clusterHandle, evt, fPFPLabel);
175  art::FindManyP<recob::Hit> fmSPHit(spHandle, evt, fPFPLabel);
176  art::FindManyP<recob::Hit> fmSliceHit(sliceHandle, evt, fPFPLabel);
178 
179  // Check the assns that are necessary, others are optional and will be checked
180  // when they are used to create the new assns
181  if (!fmSlicePFP.isValid()) {
182  throw cet::exception("SCECorrection") << "FindMany Slice-PFP is not Valid" << std::endl;
183  }
184  if (!fmPFPSP.isValid()) {
185  throw cet::exception("SCECorrection") << "FindMany PFP-SpacePoint is not Valid" << std::endl;
186  }
187  if (!fmSPHit.isValid()) {
188  throw cet::exception("SCECorrection") << "FindMany SpacePoint-Hit is not Valid" << std::endl;
189  }
190 
191  // For each slice, get all the PFPs and tracks and check for T0 tags
192  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
193  auto const detProp =
195 
196  for (auto const& slice : allSlices) {
197 
198  //Cretae a new slice
199  recob::Slice newSlice(*slice);
200  sliceCollection->push_back(newSlice);
201  art::Ptr<recob::Slice> newSlicePtr = slicePtrMaker(sliceCollection->size() - 1);
202 
203  // Get the pfps and hits associated to the slice
204  const std::vector<art::Ptr<recob::PFParticle>> slicePFPs = fmSlicePFP.at(slice.key());
205 
206  const std::map<art::Ptr<anab::T0>, bool> sliceT0CorrectMap =
207  getSliceT0s(evt, slicePFPs, pfpHandle, trackHandle, fmPFPTrack);
208 
209  const std::pair<art::Ptr<anab::T0>, bool> sliceT0CorrectPair =
210  getSliceBestT0(sliceT0CorrectMap);
211 
212  if (sliceT0CorrectPair.first.isNull() && !fCorrectNoT0Tag) { continue; }
213 
214  art::Ptr<anab::T0> newT0Ptr;
215  double t0Offset(0);
216  if (!sliceT0CorrectPair.first.isNull()) {
217  // Calculate the shift we need to apply for the t0
218  t0Offset = detProp.DriftVelocity() * sliceT0CorrectPair.first->Time() / 1e3;
219  // Create a new T0
220  t0Collection->push_back(*sliceT0CorrectPair.first);
221  newT0Ptr = t0PtrMaker(t0Collection->size() - 1);
222  }
223 
224  // Make an association with the new slice and the old hits
225  if (fmSliceHit.isValid()) {
226  const std::vector<art::Ptr<recob::Hit>> sliceHits = fmSliceHit.at(slice.key());
227  for (const art::Ptr<recob::Hit>& hitPtr : sliceHits) {
228  sliceHitAssn->addSingle(newSlicePtr, hitPtr);
229  }
230  }
231 
232  // Correct all PFPs in the slice
233  for (auto const& pfp : slicePFPs) {
234 
235  // Create new PFPs and associate them to the slice
236  recob::PFParticle newPFP(*pfp);
237  pfpCollection->push_back(newPFP);
238  art::Ptr<recob::PFParticle> newPFPPtr = pfpPtrMaker(pfpCollection->size() - 1);
239  pfpSliceAssn->addSingle(newPFPPtr, newSlicePtr);
240 
241  if (!newT0Ptr.isNull()) { t0PFPAssn->addSingle(newT0Ptr, newPFPPtr); }
242 
243  std::vector<art::Ptr<recob::SpacePoint>> pfpSPs = fmPFPSP.at(pfp.key());
244  // Get the vertex associated to the PFP
245  if (fmPFPVertex.isValid()) {
246  std::vector<art::Ptr<recob::Vertex>> pfpVertices = fmPFPVertex.at(pfp.key());
247  for (auto const& pfpVertex : pfpVertices) {
248 
249  geo::Point_t vtxPos(pfpVertex->position());
250  //Find the closest SP to the vertex
251  // If the PFP has no space points, look in the whole event
252  std::vector<art::Ptr<recob::SpacePoint>> vtxSPs = pfpSPs.size() ? pfpSPs : allSpacePoints;
253 
254  double minVtxSPDist = std::numeric_limits<double>::max();
256  for (auto const& sp : vtxSPs) {
257  geo::Point_t spPos(sp->XYZ()[0], sp->XYZ()[1], sp->XYZ()[2]);
258  geo::Vector_t vtxSPDiff = vtxPos - spPos;
259  if (vtxSPDiff.Mag2() < minVtxSPDist) {
260  spPtr = sp;
261  minVtxSPDist = vtxSPDiff.Mag2();
262  }
263  }
264 
265  if (spPtr.isNull()) continue;
266 
267  // Get the hit and TPC Id associated to closest SP
268  art::Ptr<recob::Hit> spHitPtr = fmSPHit.at(spPtr.key()).front();
269  geo::TPCID tpcId = spHitPtr->WireID().asTPCID();
270 
271  if (!sliceT0CorrectPair.first.isNull() && sliceT0CorrectPair.second) {
272  geo::Vector_t posOffset = applyT0Shift(t0Offset, tpcId);
273  vtxPos += posOffset;
274  }
275 
277  geo::Vector_t posOffset = fSCE->GetCalPosOffsets(vtxPos, tpcId.TPC);
278  if (fSCEXCorrFlip) { posOffset.SetX(-posOffset.X()); }
279  vtxPos += posOffset;
280  }
281 
282  // Create a new vertex and associate it to the PFP
283  recob::Vertex newVtx(
284  vtxPos, pfpVertex->covariance(), pfpVertex->chi2(), pfpVertex->ndof(), pfpVertex->ID());
285  vtxCollection->push_back(newVtx);
286  art::Ptr<recob::Vertex> newVtxPtr = vtxPtrMaker(vtxCollection->size() - 1);
287  pfpVtxAssn->addSingle(newPFPPtr, newVtxPtr);
288  }
289  }
290 
291  for (auto const& sp : pfpSPs) {
292 
293  //Get the spacepoint position in a nicer form
294  geo::Point_t spPos(sp->XYZ()[0], sp->XYZ()[1], sp->XYZ()[2]);
295 
296  // Get the hit so we know what TPC the sp was in
297  // N.B. We can't use SP position to infer the TPC as it could be
298  // shifted into another TPC
299  art::Ptr<recob::Hit> spHitPtr = fmSPHit.at(sp.key()).front();
300  geo::TPCID tpcId = spHitPtr->WireID().asTPCID();
301 
302  if (!sliceT0CorrectPair.first.isNull() && sliceT0CorrectPair.second) {
303  geo::Vector_t posOffset = applyT0Shift(t0Offset, tpcId);
304  spPos += posOffset;
305  }
306 
308  geo::Vector_t posOffset = fSCE->GetCalPosOffsets(spPos, tpcId.TPC);
309  if (fSCEXCorrFlip) { posOffset.SetX(-posOffset.X()); }
310  spPos += posOffset;
311  }
312 
313  // Create new spacepoint and associate it to the pfp and hit
314  Double32_t spXYZ[3] = {spPos.X(), spPos.Y(), spPos.Z()};
315  recob::SpacePoint correctedSP(spXYZ, sp->ErrXYZ(), sp->Chisq(), sp->ID());
316 
317  spCollection->push_back(correctedSP);
318  art::Ptr<recob::SpacePoint> spPtr = spPtrMaker(spCollection->size() - 1);
319  pfpSPAssn->addSingle(newPFPPtr, spPtr);
320  spHitAssn->addSingle(spPtr, spHitPtr);
321  } // pspSPs
322 
323  // Create new clusters and associations
324  if (fmPFPCluster.isValid() && fmClusterHit.isValid()) {
325  std::vector<art::Ptr<recob::Cluster>> pfpClusters = fmPFPCluster.at(pfp.key());
326  for (auto const& pfpCluster : pfpClusters) {
327  recob::Cluster newCluster(*pfpCluster);
328  clusterCollection->push_back(newCluster);
329  art::Ptr<recob::Cluster> newClusterPtr = clusterPtrMaker(clusterCollection->size() - 1);
330 
331  std::vector<art::Ptr<recob::Hit>> clusterHits = fmClusterHit.at(pfpCluster.key());
332  pfpClusterAssn->addSingle(newPFPPtr, newClusterPtr);
333  for (auto const& clusterHit : clusterHits) {
334  clusterHitAssn->addSingle(newClusterPtr, clusterHit);
335  }
336  }
337  }
338 
339  // Create new PFParticle Metadata objects and associations
340  if (fmPFPMeta.isValid()) {
341  const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> pfpMetas =
342  fmPFPMeta.at(pfp.key());
343  for (const art::Ptr<larpandoraobj::PFParticleMetadata>& pfpMeta : pfpMetas) {
344  larpandoraobj::PFParticleMetadata newPFPMeta(*pfpMeta);
345  pfpMetaCollection->push_back(newPFPMeta);
347  pfpMetaPtrMaker(pfpMetaCollection->size() - 1);
348  pfpMetaAssn->addSingle(newPFPPtr, newPFPMetaPtr);
349  }
350  }
351  } // slicePFPs
352  } // slice
353 
354  // Put all the things we just produced into the event
355  evt.put(std::move(t0Collection));
356  evt.put(std::move(sliceCollection));
357  evt.put(std::move(clusterCollection));
358  evt.put(std::move(pfpCollection));
359  evt.put(std::move(spCollection));
360  evt.put(std::move(vtxCollection));
361  evt.put(std::move(pfpMetaCollection));
362 
363  evt.put(std::move(t0PFPAssn));
364  evt.put(std::move(sliceHitAssn));
365  evt.put(std::move(pfpSPAssn));
366  evt.put(std::move(spHitAssn));
367  evt.put(std::move(pfpVtxAssn));
368  evt.put(std::move(pfpSliceAssn));
369  evt.put(std::move(pfpClusterAssn));
370  evt.put(std::move(clusterHitAssn));
371  evt.put(std::move(pfpMetaAssn));
372 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
virtual geo::Vector_t GetCalPosOffsets(geo::Point_t const &point, int const &TPCid) const =0
geo::Vector_t applyT0Shift(const double &t0, const geo::TPCID &tpcId) const
Set of hits with a 2D structure.
Definition: Cluster.h:69
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:290
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
spacecharge::SpaceCharge const * fSCE
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
std::map< art::Ptr< anab::T0 >, bool > getSliceT0s(const art::Event &evt, const std::vector< art::Ptr< recob::PFParticle >> &slicePFPs, const art::Handle< std::vector< recob::PFParticle >> &pfpHandle, const art::Handle< std::vector< recob::Track >> &trackHandle, const art::FindManyP< recob::Track > &fmPFPTrack) const
Metadata associated to PFParticles.
const std::string fPFPLabel
key_type key() const noexcept
Definition: Ptr.h:166
bool isNull() const noexcept
Definition: Ptr.h:211
std::pair< art::Ptr< anab::T0 >, bool > getSliceBestT0(const std::map< art::Ptr< anab::T0 >, bool > &sliceT0CorrectMap) const
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
const std::string fTrackLabel
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
virtual bool EnableCalSpatialSCE() const =0
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:315
Definition: fwd.h:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
constexpr TPCID const & asTPCID() const
Conversion to PlaneID (for convenience of notation).
Definition: geo_types.h:409
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

const bool sce::SCECorrection::fCorrectNoT0Tag
private

Definition at line 64 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

const bool sce::SCECorrection::fCorrectSCE
private

Definition at line 64 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

art::ServiceHandle<geo::Geometry> sce::SCECorrection::fGeom
private

Definition at line 61 of file SCECorrection_module.cc.

Referenced by applyT0Shift().

const std::string sce::SCECorrection::fPFPLabel
private

Definition at line 66 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

spacecharge::SpaceCharge const* sce::SCECorrection::fSCE
private

Definition at line 62 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

const bool sce::SCECorrection::fSCEXCorrFlip
private

Definition at line 64 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

const std::vector<std::string> sce::SCECorrection::fT0Labels
private

Definition at line 67 of file SCECorrection_module.cc.

Referenced by getSliceT0s(), and SCECorrection().

const std::vector<bool> sce::SCECorrection::fT0LabelsCorrectT0
private

Definition at line 68 of file SCECorrection_module.cc.

Referenced by getSliceT0s(), and SCECorrection().

const std::string sce::SCECorrection::fTrackLabel
private

Definition at line 66 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().


The documentation for this class was generated from the following file: