16 #include "art_root_io/TFileService.h" 18 #include "canvas/Persistency/Common/FindManyP.h" 42 class EMCNNCheckCosmics;
86 std::vector<short>
tpc;
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);
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;
386 ftree = fileServiceHandle->make<TTree>(
"ftree",
"hit info");
387 ftree->Branch(
"run", &
run,
"run/I");
std::vector< double > daughter_score_trk
std::vector< int > origin
std::vector< double > daughter_score_mic
std::vector< double > score_trk
Handle< PROD > getHandle(SelectorBase const &) const
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.
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
std::vector< short > daughter_wire
std::vector< double > score_mic
EDAnalyzer(fhicl::ParameterSet const &pset)
std::vector< double > daughter_score_em
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
std::vector< double > daughter_peakt
void analyze(art::Event const &e) override
#define DEFINE_ART_MODULE(klass)
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
double average_daughter_score_mic
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
std::vector< short > daughter_plane
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.
SubRunNumber_t subRun() const
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.
std::vector< short > daughter_tpc
Hierarchical representation of particle flow.
std::vector< short > daughter_channel
EMCNNCheckCosmics & operator=(EMCNNCheckCosmics const &)=delete
EMCNNCheckCosmics(fhicl::ParameterSet const &p)
EventNumber_t event() const
Point_t const & End() const
std::vector< std::string > process
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
std::vector< double > daughter_charge
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
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)
Event finding and building.
std::string fGeneratorTag