Public Member Functions | Private Member Functions | Private Attributes | List of all members
sce::SCECorrection Class Reference
Inheritance diagram for sce::SCECorrection:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

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
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

geo::Vector_t applyT0Shift (const double &t0, const geo::TPCID &tpcId) const
 
std::map< art::Ptr< anab::T0 >, boolgetSliceT0s (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 >, boolgetSliceBestT0 (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::stringfT0Labels
 
const std::vector< boolfT0LabelsCorrectT0
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

Definition at line 44 of file SCECorrection_module.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file SCECorrection_module.cc.

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

394 {
395 
396  const geo::TPCGeo& tpcGeo = fGeom->GetElement(tpcId);
397  int driftDirection = tpcGeo.DetectDriftDirection();
398 
399  switch (std::abs(driftDirection)) {
400  case 1:
401  return geo::Vector_t { t0Offset * driftDirection, 0, 0 };
402  case 2:
403  return geo::Vector_t { 0, t0Offset * driftDirection, 0 };
404  case 3:
405  return geo::Vector_t { 0, 0, t0Offset * driftDirection };
406  default:
407  throw cet::exception("SCECorrection") << "Drift direction unknown: " << driftDirection
408  << std::endl;
409  }
410 }
geo::GeometryCore const * fGeom
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
Geometry information for a single TPC.
Definition: TPCGeo.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
T abs(T value)
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.cxx:157
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::pair< art::Ptr< anab::T0 >, bool > sce::SCECorrection::getSliceBestT0 ( const std::map< art::Ptr< anab::T0 >, bool > &  sliceT0CorrectMap) const
private

Definition at line 461 of file SCECorrection_module.cc.

463 {
464 
465  if (!sliceT0CorrectMap.size()) {
466  return std::pair<art::Ptr<anab::T0>, bool>();
467  }
468 
469  double minT0 = std::numeric_limits<double>::max();
470  std::pair<art::Ptr<anab::T0>, bool> sliceT0CorrectPair;
471  for (auto const& sliceT0CorrectIter : sliceT0CorrectMap) {
472  double t0Time = abs(sliceT0CorrectIter.first->Time());
473  if (t0Time < minT0) {
474  minT0 = t0Time;
475  sliceT0CorrectPair = sliceT0CorrectIter;
476  }
477  }
478  return sliceT0CorrectPair;
479 }
T abs(T value)
static int max(int a, int b)
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 412 of file SCECorrection_module.cc.

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

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

Member Data Documentation

const bool sce::SCECorrection::fCorrectNoT0Tag
private

Definition at line 64 of file SCECorrection_module.cc.

const bool sce::SCECorrection::fCorrectSCE
private

Definition at line 64 of file SCECorrection_module.cc.

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

Definition at line 61 of file SCECorrection_module.cc.

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

Definition at line 66 of file SCECorrection_module.cc.

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

Definition at line 62 of file SCECorrection_module.cc.

const bool sce::SCECorrection::fSCEXCorrFlip
private

Definition at line 64 of file SCECorrection_module.cc.

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

Definition at line 67 of file SCECorrection_module.cc.

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

Definition at line 68 of file SCECorrection_module.cc.

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

Definition at line 66 of file SCECorrection_module.cc.


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