LArSoft  v09_90_00
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

geo::GeometryCore const * fGeom
 
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 45 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 84 of file SCECorrection_module.cc.

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

85  : EDProducer{p}
86  , fGeom(lar::providerFrom<geo::Geometry>())
87  , fSCE(lar::providerFrom<spacecharge::SpaceChargeService>())
88  , fCorrectNoT0Tag(p.get<bool>("CorrectNoT0Tag"))
89  , fCorrectSCE(p.get<bool>("CorrectSCE"))
90  , fSCEXCorrFlip(p.get<bool>("SCEXCorrFlip"))
91  , fPFPLabel(p.get<std::string>("PFPLabel"))
92  , fTrackLabel(p.get<std::string>("TrackLabel"))
93  , fT0Labels(p.get<std::vector<std::string>>("T0Labels"))
94  , fT0LabelsCorrectT0(p.get<std::vector<bool>>("T0LabelsCorrectT0"))
95 {
96 
97  produces<std::vector<anab::T0>>();
98  produces<std::vector<recob::Slice>>();
99  produces<std::vector<recob::PFParticle>>();
100  produces<std::vector<recob::SpacePoint>>();
101  produces<std::vector<recob::Cluster>>();
102  produces<std::vector<recob::Vertex>>();
103  produces<std::vector<larpandoraobj::PFParticleMetadata>>();
104 
105  // produces<art::Assns<anab::T0, recob::Slice> >();
106  produces<art::Assns<anab::T0, recob::PFParticle>>();
107  produces<art::Assns<recob::Slice, recob::Hit>>();
108 
109  produces<art::Assns<recob::PFParticle, recob::Slice>>();
110  produces<art::Assns<recob::PFParticle, recob::SpacePoint>>();
111  produces<art::Assns<recob::PFParticle, recob::Vertex>>();
112  produces<art::Assns<recob::PFParticle, recob::Cluster>>();
113  produces<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>();
114  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
115  produces<art::Assns<recob::Cluster, recob::Hit>>();
116 }
geo::GeometryCore const * fGeom
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 385 of file SCECorrection_module.cc.

References util::abs(), geo::TPCGeo::DetectDriftDirection(), fGeom, and geo::GeometryCore::GetElement().

Referenced by produce().

387 {
388 
389  const geo::TPCGeo& tpcGeo = fGeom->GetElement(tpcId);
390  int driftDirection = tpcGeo.DetectDriftDirection();
391 
392  switch (std::abs(driftDirection)) {
393  case 1: return geo::Vector_t{t0Offset * driftDirection, 0, 0};
394  case 2: return geo::Vector_t{0, t0Offset * driftDirection, 0};
395  case 3: return geo::Vector_t{0, 0, t0Offset * driftDirection};
396  default:
397  throw cet::exception("SCECorrection")
398  << "Drift direction unknown: " << driftDirection << std::endl;
399  }
400 }
geo::GeometryCore const * fGeom
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
Geometry information for a single TPC.
Definition: TPCGeo.h:36
constexpr auto abs(T v)
Returns the absolute value of the argument.
CryostatGeo const & GetElement(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:465
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.cxx:149
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 448 of file SCECorrection_module.cc.

References util::abs(), and DEFINE_ART_MODULE.

Referenced by produce().

450 {
451 
452  if (!sliceT0CorrectMap.size()) { return std::pair<art::Ptr<anab::T0>, bool>(); }
453 
454  double minT0 = std::numeric_limits<double>::max();
455  std::pair<art::Ptr<anab::T0>, bool> sliceT0CorrectPair;
456  for (auto const& sliceT0CorrectIter : sliceT0CorrectMap) {
457  double t0Time = abs(sliceT0CorrectIter.first->Time());
458  if (t0Time < minT0) {
459  minT0 = t0Time;
460  sliceT0CorrectPair = sliceT0CorrectIter;
461  }
462  }
463  return sliceT0CorrectPair;
464 }
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 402 of file SCECorrection_module.cc.

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

Referenced by produce().

408 {
409 
410  std::map<art::Ptr<anab::T0>, bool> pfpT0CorrectMap;
411  // Loop over all of the PFPs in the slice
412  for (auto const& pfp : slicePFPs) {
413 
414  // Loop over all of the T0 labels
415  // We will take the first label to have a T0, so the order matters
416  for (unsigned int i = 0; i < fT0Labels.size(); i++) {
417  std::string t0Label = fT0Labels.at(i);
418 
419  // Get the T0
420  art::FindManyP<anab::T0> fmPFPT0(pfpHandle, evt, t0Label);
421  if (fmPFPT0.isValid()) {
422  std::vector<art::Ptr<anab::T0>> pfpT0s = fmPFPT0.at(pfp.key());
423  if (pfpT0s.size() == 1) {
424  pfpT0CorrectMap[pfpT0s.front()] = fT0LabelsCorrectT0.at(i);
425  break;
426  }
427  }
428  // If not, Check the track associated to the PFP
429  if (!fmPFPTrack.isValid()) continue;
430  std::vector<art::Ptr<recob::Track>> pfpTracks = fmPFPTrack.at(pfp.key());
431  if (pfpTracks.size() != 1) { continue; }
432  art::Ptr<recob::Track> pfpTrack = pfpTracks.front();
433 
434  // Check if the track has a T0
435  art::FindManyP<anab::T0> fmTrackT0(trackHandle, evt, t0Label);
436  if (fmTrackT0.isValid()) {
437  std::vector<art::Ptr<anab::T0>> trackT0s = fmTrackT0.at(pfpTrack.key());
438  if (trackT0s.size() == 1) {
439  pfpT0CorrectMap[trackT0s.front()] = fT0LabelsCorrectT0.at(i);
440  break;
441  }
442  }
443  } // fT0Labels
444  } // slicePFPs
445  return pfpT0CorrectMap;
446 }
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 118 of file SCECorrection_module.cc.

References applyT0Shift(), geo::TPCID::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().

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

Referenced by produce(), and SCECorrection().

const bool sce::SCECorrection::fCorrectSCE
private

Definition at line 65 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

geo::GeometryCore const* sce::SCECorrection::fGeom
private

Definition at line 62 of file SCECorrection_module.cc.

Referenced by applyT0Shift(), and SCECorrection().

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

Definition at line 67 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

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

Definition at line 63 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

const bool sce::SCECorrection::fSCEXCorrFlip
private

Definition at line 65 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().

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

Definition at line 68 of file SCECorrection_module.cc.

Referenced by getSliceT0s(), and SCECorrection().

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

Definition at line 69 of file SCECorrection_module.cc.

Referenced by getSliceT0s(), and SCECorrection().

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

Definition at line 67 of file SCECorrection_module.cc.

Referenced by produce(), and SCECorrection().


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