130 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::Track> thass(hitListHandle,
e,
"pandoraTrack");
233 if (!
e.isRealData()){
238 auto mcTruths =
e.getValidHandle<std::vector<simb::MCTruth>>(
fGeneratorTag);
242 if(geantGoodParticle != 0x0){
253 beampdg = geantGoodParticle->PdgCode();
258 auto beamHandle =
e.getValidHandle<std::vector<beam::ProtoDUNEBeamEvent>>(
"beamevent");
260 std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
261 if( beamHandle.isValid()){
265 if (beamVec.empty())
return;
276 std::cout <<
"Failed quality check" <<
std::endl;
287 if (pids.empty())
return;
300 if(beamParticles.size() == 0){
301 std::cerr <<
"We found no beam particles for this event... moving on" <<
std::endl;
309 double endpeakt = -1;
310 std::vector<int> wirekeys;
318 trackid = thisTrack->
ID();
326 if (SCE->EnableCalSpatialSCE()){
337 offset = {0., 0., 0.};
338 if (SCE->EnableCalSpatialSCE()){
350 if (fmthm.isValid()){
352 auto vhit=fmthm.at(trackid);
353 auto vmeta=fmthm.data(trackid);
354 for (
size_t ii = 0; ii<vhit.size(); ++ii){
355 bool fBadhit =
false;
361 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!!";
368 if (fBadhit)
continue;
369 if (
loc.Z()<-100)
continue;
370 if(vhit[ii]->
WireID().Plane==2){
371 wirekeys.push_back(vhit[ii].
key());
375 endwire=vhit[ii]->WireID().Wire;
376 endpeakt=vhit[ii]->PeakTime();
377 endtpc=vhit[ii]->WireID().TPC;
393 if (SCE->EnableCalSpatialSCE()){
401 offset = {0., 0., 0.};
402 if (SCE->EnableCalSpatialSCE()){
419 if (fmcpfp.isValid()){
421 auto const& clusters = fmcpfp.at(beamParticles[0]->Self());
422 for (
auto const &
cluster : clusters){
425 auto const& hits = fmhc.at(
cluster.key());
428 for (
auto &
hit : hits){
429 std::array<float,4> cnn_out = hitResults.getOutput(
hit);
430 if (
hit->WireID().Plane == 2){
432 tpc.push_back(
hit->WireID().TPC);
433 plane.push_back(
hit->WireID().Plane);
434 wire.push_back(
hit->WireID().Wire);
437 score_em.push_back(cnn_out[hitResults.getIndex(
"em")]);
438 score_trk.push_back(cnn_out[hitResults.getIndex(
"track")]);
439 score_mic.push_back(cnn_out[hitResults.getIndex(
"michel")]);
441 int this_origin = -1;
443 if (!
e.isRealData()){
445 std::map<int,double> trkide;
447 for(
size_t e = 0;
e < TrackIDs.size(); ++
e){
448 trkide[TrackIDs[
e].trackID] += TrackIDs[
e].energy;
456 if ((ii->second)>maxe){
464 this_pdg = particle->
PdgCode();
465 this_process = particle->
Process();
469 pdg.push_back(this_pdg);
470 origin.push_back(this_origin);
471 process.push_back(this_process);
479 unsigned int nCollectionHits = 0;
480 for(
unsigned int h = 0;
h <
plane.size(); ++
h){
488 if(nCollectionHits > 0){
497 for(
size_t hitl=0;hitl<hitList.size();hitl++){
498 std::array<float,4> cnn_out=hitResults.getOutput(hitList[hitl]);
499 auto &
tracks = thass.at(hitList[hitl].
key());
501 if (std::find(wirekeys.begin(), wirekeys.end(), hitl) != wirekeys.end())
continue;
504 int planeid=hitList[hitl]->WireID().Plane;
505 if (planeid!=2)
continue;
506 int tpcid=hitList[hitl]->WireID().TPC;
507 if (tpcid!=endtpc)
continue;
508 float peakth1=hitList[hitl]->PeakTime();
509 int wireh1=hitList[hitl]->WireID().Wire;
510 if(
std::abs(wireh1-endwire)<15 &&
std::abs(peakth1-endpeakt)<100 && tpcid==endtpc){
std::vector< double > daughter_score_trk
std::vector< int > origin
const TVector3 & ShowerStart() const
const int & GetTimingTrigger() const
std::vector< double > daughter_score_em
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
std::vector< short > wire
const recob::Shower * GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the shower associated to this particle. Returns a null pointer if not found.
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
Point_t const & LocationAtPoint(size_t i) const
simb::Origin_t Origin() 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.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Cluster finding and building.
std::string Process() const
std::vector< short > daughter_plane
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
std::vector< double > daughter_charge
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
std::vector< double > score_em
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
protoana::ProtoDUNEBeamlineUtils fBeamlineUtils
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
double average_daughter_score_mic
const std::vector< const recob::PFParticle * > GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const
Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice w...
const TVector3 & Direction() const
bool IsGoodBeamlineTrigger(art::Event const &evt) const
static int max(int a, int b)
std::string fGeneratorTag
Detector simulation of raw signals on wires.
std::vector< double > score_mic
std::vector< short > plane
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::vector< short > channel
std::vector< int > GetPID(beam::ProtoDUNEBeamEvent const &beamevt, double nominal_momentum)
Hierarchical representation of particle flow.
std::vector< short > daughter_wire
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
Point_t const & End() const
std::vector< double > daughter_peakt
std::vector< double > daughter_score_mic
std::vector< short > daughter_channel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
recob::tracking::Plane Plane
std::vector< double > score_trk
const bool & CheckIsMatched() const
std::vector< double > charge
std::vector< std::string > process
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
std::vector< short > daughter_tpc