20 #include "art_root_io/TFileService.h" 40 #include "dune/DuneObj/ProtoDUNEBeamEvent.h" 43 #include "dune/CalibServices/XYZCalibServiceProtoDUNE.h" 45 #include "canvas/Persistency/Common/FindManyP.h" 50 #include "dune/Protodune/singlephase/DataUtils/ProtoDUNEDataUtils.h" 58 #include "TTimeStamp.h" 75 class ProtoDUNEelectronAnaTree;
90 virtual void endJob()
override;
268 fPandoraBeam = tfs->make<TTree>(
"PandoraBeam",
"Beam events reconstructed with Pandora");
396 for(
int k=0;
k < 6;
k++)
400 for(
int k=0;
k < 6;
k++)
404 bool beamTriggerEvent =
false;
412 if(geantGoodParticle != 0x0){
413 beamTriggerEvent =
true;
429 for(
size_t i=0; i<geantGoodParticle->NumberTrajectoryPoints() && i<1000; ++i){
440 if(
abs(geantGoodParticle->PdgCode()) != 11 )
return;
445 if( !beamTriggerEvent )
return;
447 std::vector< art::Ptr<beam::ProtoDUNEBeamEvent> > beaminfo;
458 if(beaminfo[0]->GetTOFChan() != -1){
459 ftof = beaminfo[0]->GetTOF();
468 auto &
tracks = beaminfo[0]->GetBeamTracks();
480 auto & beammom = beaminfo[0]->GetRecoBeamMomenta();
488 if( !recoParticleHandle )
return;
510 for(
const int didx : particle->Daughters() ){
551 if(thisTrack != 0x0){
590 for(
size_t k = 0;
k < calovector.size() &&
k<3;
k++){
591 int plane = calovector[
k].PlaneID().Plane;
592 if(plane !=2 )
continue;
596 for(
size_t l=0;
l<calovector[
k].dEdx().size() &&
l<
MAXHits; ++
l){
600 const auto &
pos=(calovector[
k].XYZ())[
l];
608 else if(thisShower != 0x0){
628 art::FindManyP<recob::SpacePoint> spFromMCPartHits(hitsFromMCPart,evt,
fPFParticleTag);
630 if( hitsFromMCPart.size()){
632 for(
size_t i=0; i<hitsFromMCPart.size(); ++i){
633 if( hitsFromMCPart[i]->
WireID().Plane != 2 )
continue;
635 TVector3 xyzWire = pwire->
GetCenter<TVector3>();
636 tot_ch += hitsFromMCPart[i]->Integral();
642 std::vector<art::Ptr<recob::SpacePoint>> sp = spFromMCPartHits.at(i);
668 art::FindManyP<recob::SpacePoint> spFromShowerHits(sh_hits,evt,
fPFParticleTag);
672 art::FindManyP<recob::Hit> findHitsFromShowers(recoShowers,evt,
fShowerTag);
676 std::vector< art::Ptr< recob::Hit > > tmp_sh_hits = findHitsFromShowers.at( thisShower->
ID() );
680 for(
size_t j=0; j<sh_hits.size() && j<
MAXHits; ++j){
681 if( sh_hits[j]->
WireID().Plane != 2 )
continue;
682 art::FindManyP<recob::Wire> wFromHits(sh_hits,evt,
"hitpdune");
683 std::vector<art::Ptr<recob::Wire>> wires = wFromHits.at(j);
685 TVector3 xyzWire = pwire->
GetCenter<TVector3>();
686 std::array<float,4> cnn_out = hitResults.
getOutput( tmp_sh_hits[j] );
687 double p_trk_or_sh = cnn_out[ hitResults.
getIndex(
"track") ]+ cnn_out[ hitResults.
getIndex(
"em") ];
688 double cnn_score = cnn_out[ hitResults.
getIndex(
"em") ]/p_trk_or_sh;
697 std::vector<art::Ptr<recob::SpacePoint>> sp = spFromShowerHits.at(j);
710 if(calovector.size() != 3 &&
fVerbose > 0)
711 std::cerr <<
"WARNING::Calorimetry vector size for primary is = " << calovector.size() <<
std::endl;
713 for(
size_t k = 0;
k < calovector.size() &&
k<3;
k++){
714 int plane = calovector[
k].PlaneID().Plane;
715 if(plane !=2 )
continue;
719 for(
size_t l=0;
l<calovector[
k].dEdx().size() &&
l<
MAXHits; ++
l){
723 const auto &
pos=(calovector[
k].XYZ())[
l];
741 if(daughterTrack != 0x0){
761 else if(daughterShower != 0x0){
779 if(!pfdaughterT0vec.empty())
793 for(
int k=0;
k < 5;
k++)
796 for(
int k=0;
k < 3;
k++){
810 for(
int l=0;
l<1000;
l ++) {
854 for(
int k=0;
k < 2;
k++){
896 for(
int l=0;
l < 3;
l++){
double E(const int i=0) const
ProtoDUNEelectronAnaTree(fhicl::ParameterSet const &p)
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
int fdaughterIsshower[NMAXDAUGTHERS]
double fprimaryShower_hit_cnn[MAXHits]
const TVector3 & ShowerStart() const
double fdaughterEndPosition[NMAXDAUGTHERS][3]
const std::vector< const recob::Hit * > GetRecoShowerHits(const recob::Shower &shower, art::Event const &evt, const std::string showerModule) const
Get the hits from a given reco shower.
double EndMomentum() const
int fprimaryShower_hit_ch[MAXHits]
constexpr std::uint32_t timeLow() const
double fprimaryShower_hit_X[MAXHits]
double GetDepEnergyMC(const art::Event &evt, geo::GeometryCore const *fGeom, int trackid, int whichview) const
geo::GeometryCore const * fGeometry
double fdaughterStartDirection[NMAXDAUGTHERS][3]
std::vector< anab::T0 > GetPFParticleT0(const recob::PFParticle &particle, art::Event const &evt, std::string particleLabel) const
Get the T0(s) from a given PFParticle.
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
std::string fParticleIDTag
double fbeamtrackEndPos[3]
double fprimary_calX[MAXHits]
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.
double fbeamtrackMom_at[1000][4]
Handle< PROD > getHandle(SelectorBase const &) const
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
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.
std::vector< anab::Calorimetry > GetRecoShowerCalorimetry(const recob::Shower &shower, art::Event const &evt, const std::string showerModule, const std::string caloModule) const
Get shower calo info.
double fprimaryKineticEnergy[3]
constexpr std::uint32_t timeHigh() const
double fprimaryEndMomentum
const std::vector< const recob::Hit * > GetPFParticleHits(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Get the hits associated to the PFParticle.
double fdaughterTheta[NMAXDAUGTHERS]
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.
double fprimaryTruthShower_hit_q[MAXHits]
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
int fprimaryShowerBestPlane
virtual void endJob() override
protoana::ProtoDUNETrackUtils trackUtil
double fprimaryShower_hit_Y[MAXHits]
double fprimaryStartPosition[3]
EDAnalyzer(fhicl::ParameterSet const &pset)
double fdaughterStartPosition[NMAXDAUGTHERS][3]
double fprimaryTruth_vtx[3]
int fdaughterIstrack[NMAXDAUGTHERS]
double fprimaryOpeningAngle
int fprimaryTruthShower_hit_w[MAXHits]
void FillPrimaryPFParticle(art::Event const &evt, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const recob::PFParticle *particle)
art framework interface to geometry description
std::string fShowerCaloTag
std::string fPFParticleTag
trkf::TrackMomentumCalculator trmom
std::string fCalorimetryTag
std::vector< const recob::Hit * > GetMCParticleHits(detinfo::DetectorClocksData const &clockData, const simb::MCParticle &mcpart, const art::Event &evt, std::string hitModule, bool use_eve=true) const
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double fcerenkovPressure[2]
void analyze(art::Event const &evt) override
double fprimaryEndDirection[3]
protoana::ProtoDUNEPFParticleUtils pfpUtil
double Length(size_t p=0) const
Access to various track properties.
double fprimary_calZ[MAXHits]
double fdaughterLength[NMAXDAUGTHERS]
double fprimaryShowerCharge
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
double GetPurity(detinfo::DetectorClocksData const &clockData, const recob::PFParticle &pfpart, const art::Event &evt, std::string pfparticleModule) const
const art::InputTag fBeamModuleLabel
double Theta() const
Access to spherical or geographical angles at vertex or at any point.
double fprimarydEdx[MAXHits]
double fdaughterEndDirection[NMAXDAUGTHERS][3]
double fbeamtrackMomentum
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.
double fprimaryTruthShower_hit_Z[MAXHits]
double fprimaryTruth_purity
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
protoana::ProtoDUNETruthUtils truthUtil
SubRunNumber_t subRun() const
double fprimaryShower_hit_pitch[MAXHits]
const simb::MCParticle * GetMCParticleFromRecoTrack(detinfo::DetectorClocksData const &clockData, const recob::Track &track, art::Event const &evt, std::string trackModule) const
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
int fdaughterID[NMAXDAUGTHERS]
double fprimaryMomentumByRangeMuon
Description of geometry of one entire detector.
int fprimaryIsBeamparticle
double fdaughterPhi[NMAXDAUGTHERS]
double ConvertTicksToX(double ticks, int p, int t, int c) const
Vector_t EndDirection() const
Returns the direction of the trajectory at the last point.
double fdaughterVertex[3]
double Vx(const int i=0) const
virtual void beginJob() override
double fdaughterOpeningAngle[NMAXDAUGTHERS]
Declaration of signal hit object.
double fprimaryResidualRange[MAXHits]
protoana::ProtoDUNEBeamlineUtils beamlineUtil
double StartMomentum() const
Hierarchical representation of particle flow.
double fprimaryTruth_Edepo
double fprimaryShowerEnergy
Contains all timing reference information for the detector.
double fprimaryMomentumByRangeProton
double fprimaryTruthShower_hit_Y[MAXHits]
int GetNActiveFembsForAPA(art::Event const &evt, int apa) const
Get number of active fembs in an APA.
double fprimaryShower_hit_Z[MAXHits]
std::vector< std::string > fbeamtrackEndProcess
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
double fprimary_calY[MAXHits]
Provides recob::Track data product.
int fdaughterShowerBestPlane[NMAXDAUGTHERS]
double fprimary_cal_pitch[MAXHits]
double fprimaryShower_hit_q[MAXHits]
int fdaughterNHits[NMAXDAUGTHERS]
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.
EventNumber_t event() const
double fbeamtrackPos_at[1000][3]
Declaration of basic channel signal object.
double fdaughterT0[NMAXDAUGTHERS]
double fprimaryShower_hit_t[MAXHits]
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
void FillPrimaryDaughterPFParticle(art::Event const &evt, const recob::PFParticle *daughterParticle, int daughterID)
std::string fGeneratorTag
const simb::MCParticle * GetMCParticleFromRecoShower(detinfo::DetectorClocksData const &clockData, const recob::Shower &shower, art::Event const &evt, std::string showerModule) const
double fprimaryShowerMIPEnergy
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
double fprimaryStartDirection[3]
int fprimaryShower_hit_w[MAXHits]
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
recob::tracking::Plane Plane
protoana::ProtoDUNEShowerUtils showerUtil
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
double fprimarydQdx[MAXHits]
ProtoDUNEelectronAnaTree & operator=(ProtoDUNEelectronAnaTree const &)=delete
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
float GetBeamCosmicScore(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel) const
Access the BDT output used to decide if a slice is beam-like or cosmic-like.
double fprimaryTruthShower_hit_t[MAXHits]
protoana::ProtoDUNEDataUtils dataUtil
double Vy(const int i=0) const
double fprimaryEndPosition[3]
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
double GetTrackMomentum(double trkrange, int pdg) const
QTextStream & endl(QTextStream &s)
bool IsBeamTrigger(art::Event const &evt) const
double fprimaryTruthShower_hit_X[MAXHits]
double fprimaryShowerTruth_Charge
int fprimaryTruthShower_nHits
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.