275 auto beamHandle =
evt.getValidHandle<std::vector<beam::ProtoDUNEBeamEvent>>(
"beamevent");
276 std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
277 if( beamHandle.isValid()){
289 std::cout <<
"Failed beam quality check!\n" <<
std::endl;
299 if (
evt.isRealData()) {
307 int nMomenta = momenta.size();
308 std::cout <<
"Number of reconstructed momenta: " << nMomenta <<
std::endl;
318 const std::vector< double > & the_tofs = beamEvent.
GetTOFs();
319 const std::vector< int > & the_chans = beamEvent.
GetTOFChans();
322 std::cout <<
"Number of measured TOF: " << the_tofs.size() <<
std::endl;
326 std::cout <<
"All (TOF, Channels): " <<
std::endl;
327 for(
size_t i = 0; i < the_tofs.size(); ++i ){
328 std::cout <<
"\t(" << the_tofs[i] <<
", " << the_chans[i] <<
")" <<
std::endl;
336 std::cout <<
"Cerenkov status, pressure:" <<
std::endl;
366 std::cout<<
"Selected nominal beam momentum is: "<<nom_beam_mon<<
" GeV/c"<<
std::endl;
376 std::cout <<
"muon " << candidates.muon <<
std::endl;
377 std::cout <<
"pion " << candidates.pion <<
std::endl;
378 std::cout <<
"kaon " << candidates.kaon <<
std::endl;
379 std::cout <<
"proton " << candidates.proton <<
std::endl;
399 std::vector<art::Ptr<recob::Track> > tracklist;
404 art::FindManyP<recob::PFParticle> pfp_trk_assn(trackListHandle,
evt,
"pandoraTrack");
405 auto allHits =
evt.getValidHandle<std::vector<recob::Hit> >(
fHitTag);
413 auto trackListHandle2 =
evt.getHandle< std::vector<recob::Track> >(
"pandoraTrack");
416 std::vector<art::Ptr<recob::PFParticle> > pfplist;
417 auto PFPListHandle =
evt.getHandle< std::vector<recob::PFParticle> > (
"pandora");
426 std::vector<art::Ptr<recob::Cluster>> clusterlist;
427 auto clusterListHandle =
evt.getHandle< std::vector<recob::Cluster> > (
"pandora");
430 art::FindManyP<recob::Cluster> fmcp(PFPListHandle,
evt,
"pandora");
431 art::FindManyP<recob::Track> pftrack(PFPListHandle,
evt,
"pandoraTrack");
432 std::cout<<
"number of pfp_particles "<<pfplist.size()<<
std::endl;
461 evttime = ts2.AsDouble();
465 if(!
evt.isRealData()){
466 for(
int ik=0; ik<6; ik++)
470 for(
int ik=0; ik<6; ik++)
475 if (beamVec.size()&&candidates.proton==1) {
481 for(
size_t ii = 0; ii < the_tofs.size(); ++ii ){
482 tofs.push_back(the_tofs[ii]);
483 ch_tofs.push_back(the_chans[ii]);
491 for (
size_t i = 0; i<
tracks.size(); ++i){
501 std::cout<<
"beamDirx/beamDiry/beamDirz:"<<
tracks[i].StartDirection().X()<<
"/"<<
tracks[i].StartDirection().Y()<<
"/"<<
tracks[i].StartDirection().Z()<<
std::endl;
509 std::cout<<
"beam mom size:"<<momenta.size()<<
std::endl;
510 for (
size_t i = 0; i<momenta.size(); ++i){
512 std::cout<<
"beam mom["<<i<<
"]:"<<momenta[i]<<
" [GeV]"<<
std::endl;
533 std::cout<<
"\n*******************************************************"<<
std::endl;
534 std::cout<<
"Moving on to the PFParticle section..."<<
std::endl;
543 auto recoParticles =
evt.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleTag);
558 if(beamParticles.size() == 0){
559 std::cout <<
"We found no beam particles for this event... moving on" <<
std::endl;
568 std::cout<<
"we have "<<beamParticles.size()<<
" beam particle(s)"<<
std::endl;
577 if(thisTrack != 0x0) {
578 std::cout <<
"Beam particle is track-like" <<
std::endl;
587 for (
auto &
calo : calovector){
588 if (
calo.PlaneID().Plane == 2){
597 for (
size_t ihit = 0; ihit <
calo.dQdx().size(); ++ihit){
609 const auto &primtrk_pos=(
calo.XYZ())[ihit];
646 std::cout<<
"vtx_X:"<<vtx.X()<<
" ; vtx_Y:"<<vtx.Y()<<
" ; vtx_Z:"<<vtx.Z()<<
std::endl;
651 std::cout<<
"vtx_end_X:"<<vtx_end.X()<<
" ; vtx_end_Y:"<<vtx_end.Y()<<
" ; vtx_end_Z:"<<vtx_end.Z()<<
std::endl;
653 if (vtx.Z()==vtx_end.Z()) {
654 std::cout<<
"WARNING!! StartZ and EndZ are the same!!"<<
std::endl;
659 std::vector<float> Stw, Endw, Stt, Endt, Stwires, Endwires, Stticks, Endticks, TPCb, TPCcl;
660 Stw.clear(); Endw.clear(); Stt.clear(); Endt.clear(); Stwires.clear(); Endwires.clear(); Stticks.clear(); Endticks.clear(); TPCb.clear(); TPCcl.clear();
662 float numw, numt,wire_no,ticks_no;
664 for(
size_t p1=0;p1<pfplist.size();p1++){
665 std::vector<art::Ptr<recob::Track>>
trk=pftrack.at(p1);
666 std::vector<art::Ptr<recob::Cluster>> allClusters=fmcp.at(p1);
668 for(
size_t c1=0;
c1<allClusters.size();
c1++){
670 if(trk.size() &&
int(trk[0].
key())==(
int)(thisTrack->
ID())){
671 Stw.push_back(allClusters[
c1]->StartWire());
672 Endw.push_back(allClusters[
c1]->EndWire());
673 Stt.push_back(allClusters[
c1]->StartTick());
674 Endt.push_back(allClusters[
c1]->EndTick());
679 Stwires.push_back(allClusters[
c1]->StartWire());
680 Endwires.push_back(allClusters[
c1]->EndWire());
681 Stticks.push_back(allClusters[
c1]->StartTick());
682 Endticks.push_back(allClusters[
c1]->EndTick());
683 TPCcl.push_back(allClusters[
c1]->
Plane().
TPC);
688 for(
size_t clt=0;clt<Stw.size();clt++){
689 for(
size_t cl1=0;cl1<Stwires.size();cl1++){
690 if(TPCcl[cl1]!=TPCb[clt])
continue;
692 den=(Stw[clt]-Endw[clt])*(Stticks[cl1]-Endticks[cl1])-(Stt[clt]-Endt[clt])*(Stwires[cl1]-Endwires[cl1]);
694 numw=(Stw[clt]*Endt[clt]-Stt[clt]*Endw[clt])*(Stwires[cl1]-Endwires[cl1])-(Stw[clt]-Endw[clt])*(Stwires[cl1]*Endticks[cl1]-Stticks[cl1]*Endwires[cl1]);
695 numt=(Stw[clt]*Endt[clt]-Stt[clt]*Endw[clt])*(Stticks[cl1]-Endticks[cl1])-(Stt[clt]-Endt[clt])*(Stwires[cl1]*Endticks[cl1]-Stticks[cl1]*Endwires[cl1]);
699 if(((Stw[clt]<wire_no && Endw[clt]>wire_no)||(Stw[clt]>wire_no && Endw[clt]<wire_no))&&((Stt[clt]<ticks_no && Endt[clt]>ticks_no)||(Stt[clt]>ticks_no && Endt[clt]<ticks_no)) && ((Stwires[cl1]<wire_no && Endwires[cl1]>wire_no)||(Stwires[cl1]>wire_no && Endwires[cl1]<wire_no)) && ((Stticks[cl1]<ticks_no && Endticks[cl1]>ticks_no)||(Stticks[cl1]>ticks_no && Endticks[cl1]<ticks_no))) {
700 std::cout<<
"intersection wire and ticks are "<<std::round(wire_no)<<
" "<<ticks_no<<
" Stw Endw StT EndT "<<Stwires[cl1]<<
" "<<Endwires[cl1]<<
" "<<Stticks[cl1]<<
" "<<Endticks[cl1]<<
std::endl;
703 unsigned int wireno=std::round(wire_no);
707 std::cout<<
"Z position of intersection = "<<xyzStart[2]<<
" "<<xyzEnd[2]<<
" "<<wireno<<
std::endl;
716 if(thisShower != 0x0) {
717 std::cout <<
"Beam particle is shower-like" <<
std::endl;
726 pdg_code.push_back(particle->PdgCode());
727 n_daughter.push_back(particle->NumDaughters());
728 isPrimary.push_back(particle->IsPrimary());
729 pfp_self.push_back(particle->Self());
732 std::cout<<
"pdg code:"<<particle->PdgCode()<<
std::endl;
733 std::cout<<
"IsPrimary:"<<particle->IsPrimary()<<
std::endl;
734 std::cout<<
"NumDaughters:"<<particle->NumDaughters()<<
std::endl;
735 std::cout<<
"Self:"<<particle->Self()<<
std::endl;
736 std::cout<<
"Parent:"<<particle->Parent()<<
std::endl;
738 if ((particle->NumDaughters())>0) {
739 for (
int ii=0; ii<(particle->NumDaughters());++ii) {
740 std::cout<<
"Daughter["<<ii<<
"]:"<<particle->Daughter(ii)<<
std::endl;
759 std::cout<<
"trkDirx/trkDiry/trkDirz:"<<trackdir.X()<<
"/"<<trackdir.Y()<<
"/"<<trackdir.Z()<<
std::endl;
767 std::cout<<
"trk ID: "<<thisTrack->
ID()<<
""<<
std::endl;
787 for(
const int daughterID : particle->Daughters()){
790 std::cout <<
"Daughter " << daughterID <<
" has " << daughterParticle->
NumDaughters() <<
" daughters" <<
std::endl;
797 std::cout <<
"Beam particle has " << trackDaughters.size() <<
" track-like daughters and " << showerDaughters.size() <<
" shower-like daughters." <<
std::endl;
799 std::cout<<
"# total Tracks:"<<nTrack<<
std::endl;
800 std::cout<<
"# total Showers:"<<nShower<<
std::endl;
805 std::cout<<
"*******************************************************"<<
std::endl;
std::vector< double > primtrk_hitx
std::vector< double > beamMomentum
PossibleParticleCands GetPIDCandidates(beam::ProtoDUNEBeamEvent const &beamevt, double nominal_momentum)
std::vector< int > primtrk_ch
fhicl::ParameterSet fBeamPars
constexpr std::uint32_t timeLow() const
const int & GetTimingTrigger() const
int NumDaughters() const
Returns the number of daughter particles flowing from this one.
const std::vector< double > & GetTOFs() const
std::vector< int > beam_inst_TOF_Chan
std::vector< double > primtrk_Dirz
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.
geo::WireID WireID() const
const double & GetCKov0Pressure() const
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
bool reco_reconstructable_beam_event
std::vector< anab::Calorimetry > GetRecoTrackCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule) const
Get the Calorimetry(s) from a given reco track.
constexpr std::uint32_t timeHigh() const
const short & GetCKov1Status() const
const TVector3 GetPFParticleVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the interaction vertex of a primary PFParticle.
std::vector< int > n_beamparticle
Plane(const Point_t &planePos, const Vector_t &planeDir)
Constructor from reference position on the plane and direction orthogonal to the plane.
std::vector< int > primtrk_wid
std::vector< int > primtrk_trktag
WireID_t Wire
Index of the wire within its plane.
std::vector< double > primtrk_hitz
std::vector< double > primtrk_endy
bool IsEmptyEvent(const art::Event &evt) const
std::vector< double > primtrk_startx
std::vector< double > beamPosx
std::vector< int > pfp_self
std::vector< double > Xintersection
std::vector< double > beamDiry
std::vector< double > primtrk_endx
double cosine_beam_primtrk
Vector_t StartDirection() const
Access to track direction at different points.
protoana::ProtoDUNEBeamlineUtils fBeamlineUtils
double Length(size_t p=0) const
Access to various track properties.
std::vector< double > primtrk_endz
std::vector< size_t > primtrk_calo_hit_index
std::vector< double > primtrk_hity
std::vector< int > beam_inst_PDG_candidates
std::vector< double > primtrk_dedx
const std::vector< double > & GetRecoBeamMomenta() const
std::vector< double > primtrk_resrange
std::vector< double > Zintersection
const double & GetTOF() const
T get(std::string const &key) const
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.
std::vector< double > primtrk_Diry
std::vector< int > n_daughter
std::vector< int > isPrimary
std::vector< double > timeintersection
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...
protoana::ProtoDUNEEmptyEventFinder fEmptyEventFinder
std::vector< double > primtrklen
bool IsGoodBeamlineTrigger(art::Event const &evt) const
std::vector< double > primtrk_startz
std::vector< double > Yintersection
const art::InputTag fTrackModuleLabel
std::vector< double > beamPosz
std::vector< double > primtrkID
std::vector< double > beamDirx
float PeakTime() const
Time of the signal peak, in tick units.
std::vector< int > GetPID(beam::ProtoDUNEBeamEvent const &beamevt, double nominal_momentum)
Hierarchical representation of particle flow.
const std::vector< int > & GetTOFChans() const
std::vector< int > pfp_daughter
short low_pressure_status
std::vector< double > primtrk_starty
int GetNActiveFembsForAPA(art::Event const &evt, int apa) const
Get number of active fembs in an APA.
short high_pressure_status
const std::vector< const recob::Shower * > GetPFParticleDaughterShowers(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the daughter showers from the PFParticle.
std::vector< int > pdg_code
std::string fPFParticleTag
geo::GeometryCore const * fGeometry
std::vector< double > primtrk_pt
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
std::vector< double > primtrk_ke
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
std::vector< double > primtrk_range
std::vector< int > ch_tofs
const TVector3 GetPFParticleSecondaryVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the secondary interaction vertex of a primary PFParticle.
std::vector< double > primtrk_pitch
const std::vector< recob::Track > & GetBeamTracks() const
const short & GetCKov0Status() const
std::vector< double > beam_inst_TOF
2D representation of charge deposited in the TDC/wire plane
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< double > tofs
recob::tracking::Plane Plane
std::string fCalorimetryTag
const bool & CheckIsMatched() const
std::vector< double > beamPosy
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
const int & GetTOFChan() const
const std::vector< const recob::Track * > GetPFParticleDaughterTracks(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the daughter tracks from the PFParticle.
std::vector< double > primtrk_dqdx
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
QTextStream & endl(QTextStream &s)
protoana::ProtoDUNEDataUtils dataUtil
std::vector< double > primtrk_Dirx
std::vector< double > beamDirz
const double & GetCKov1Pressure() const