169 event =
e.id().event();
174 auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
179 std::vector < art::Ptr < recob::Slice > > sliceList;
180 auto sliceListHandle =
e.getHandle < std::vector < recob::Slice > >(
"pandora");
181 if (sliceListHandle) {
187 std::vector < art::Ptr < recob::PFParticle > > pfpList;
188 auto pfpListHandle =
e.getHandle < std::vector < recob::PFParticle > >(
"pandora");
194 std::vector < art::Ptr < recob::Cluster > > cluList;
195 auto cluListHandle =
e.getHandle < std::vector < recob::Cluster > >(
"pandora");
201 std::vector < art::Ptr < recob::Track > > trkList;
202 auto trkListHandle =
e.getHandle < std::vector < recob::Track > >(
"pandoraTrack");
208 std::vector < art::Ptr < recob::Hit > > hitList;
209 auto hitListHandle =
e.getHandle < std::vector < recob::Hit > >(
"hitpdune");
215 art::FindManyP<recob::Cluster> fmcpfp(pfpListHandle,
e,
"pandora");
218 art::FindManyP<recob::Vertex> fmvpfp(pfpListHandle,
e,
"pandora");
221 art::FindManyP<recob::Hit> fmhc(cluListHandle,
e,
"pandora");
223 art::FindManyP <recob::Hit> hitsFromSlice(sliceListHandle,
e,
"pandora");
226 art::FindManyP<recob::Hit, recob::TrackHitMeta> fmthm(trkListHandle,
e,
"pandoraTrack");
229 art::FindManyP<recob::Hit> thass(trkListHandle,
e,
"pandoraTrack");
235 const unsigned int beamSlice{pfpUtil.
GetBeamSlice(
e,
"pandora")};
237 const std::map<unsigned int,std::vector<const recob::PFParticle*>> sliceToPFParticleMap = pfpUtil.
GetPFParticleSliceMap(
e,
"pandora");
238 std::vector<unsigned int> tracksToUse;
239 for (
auto const & element : sliceToPFParticleMap)
241 if (element.first == beamSlice)
248 if (track ==
nullptr)
252 if (track->Length() < 100.)
256 if (track->Start<TVector3>().Z() < 50.0 || track->End<TVector3>().
Z() < 50.0)
260 if (track->VertexDirection<TVector3>().Y() < TMath::Cos(165. * TMath::Pi() / 180.))
264 tracksToUse.push_back(track->ID());
273 std::vector<int> wirekeys;
274 for(
unsigned int t = 0;
t < tracksToUse.size(); ++
t){
281 trackid = thisTrack->
ID();
307 if (fmthm.isValid()){
309 auto vhit=fmthm.at(trackid);
310 auto vmeta=fmthm.data(trackid);
311 for (
size_t ii = 0; ii<vhit.size(); ++ii){
312 bool fBadhit =
false;
318 throw cet::exception(
"Calorimetry_module.cc") <<
"Requested track trajectory index "<<vmeta[ii]->Index()<<
" exceeds the total number of trajectory points "<<thisTrack->
NumberTrajectoryPoints()<<
" for track index "<<trackid<<
". Something is wrong with the track reconstruction. Please contact tjyang@fnal.gov!!";
325 if (fBadhit)
continue;
326 if (
loc.Z()<-100)
continue;
327 if(vhit[ii]->
WireID().Plane==2){
328 wirekeys.push_back(vhit[ii].
key());
341 auto const &hits = thass.at(trackid);
342 for (
auto &
hit : hits){
343 std::array<float,4> cnn_out = hitResults.getOutput(
hit);
344 if (
hit->WireID().Plane == 2){
346 tpc.push_back(
hit->WireID().TPC);
347 plane.push_back(
hit->WireID().Plane);
348 wire.push_back(
hit->WireID().Wire);
351 score_em.push_back(cnn_out[hitResults.getIndex(
"em")]);
352 score_trk.push_back(cnn_out[hitResults.getIndex(
"track")]);
353 score_mic.push_back(cnn_out[hitResults.getIndex(
"michel")]);
359 unsigned int nCollectionHits = 0;
360 for(
unsigned int h = 0;
h <
plane.size(); ++
h){
369 if(nCollectionHits > 0){
377 std::cout <<
"Filling output tree" <<
std::endl;
std::vector< double > score_trk
Point_t const & LocationAtPoint(size_t i) const
bool isValid
Whether this ID points to a valid element.
bool HasValidPoint(size_t i) const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
std::vector< double > score_mic
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
unsigned short GetBeamSlice(art::Event const &evt, const std::string particleLabel) const
Try to get the slice tagged as beam. Returns 9999 if no beam slice was found.
std::vector< double > peakt
const recob::Track * GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the track associated to this particle. Returns a null pointer if not found.
Point_t const & Vertex() const
const std::map< unsigned int, std::vector< const recob::PFParticle * > > GetPFParticleSliceMap(art::Event const &evt, const std::string particleLabel) const
Get a map of slice index to the primary PFParticles within it.
static int max(int a, int b)
Detector simulation of raw signals on wires.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Hierarchical representation of particle flow.
Point_t const & End() const
std::vector< short > plane
std::vector< double > charge
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< short > wire
std::vector< short > channel
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::vector< double > score_em
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)