3 #include "dune/DuneObj/ProtoDUNEBeamEvent.h" 8 std::vector< fhicl::ParameterSet > DataCuts_sets = pset.
get< std::vector< fhicl::ParameterSet > >
10 std::vector< fhicl::ParameterSet > MCCuts_sets = pset.
get< std::vector< fhicl::ParameterSet > >
14 for(
size_t i = 0; i < DataCuts_sets.size(); ++i ){
22 std::cerr <<
"Error: Attempting to duplicate a cut parameter set" <<
std::endl;
32 for(
size_t i = 0; i < MCCuts_sets.size(); ++i ){
41 std::cerr <<
"Error: Attempting to duplicate a cut parameter set" <<
std::endl;
55 std::cerr <<
"Error. Momentum provided not in range" <<
std::endl;
62 if( !theBeamVals.
Valid ){
76 double trackDirX = 0.;
77 double trackDirY = 0.;
78 double trackDirZ = 0.;
86 trackDirX = -1. * endDir.X();
87 trackDirY = -1. * endDir.Y();
88 trackDirZ = -1. * endDir.Z();
91 trackDirX = startDir.X();
92 trackDirY = startDir.Y();
93 trackDirZ = startDir.Z();
96 double deltaX = startX - theBeamVals.
X;
97 double deltaY = startY - theBeamVals.
Y;
99 double costheta = theBeamVals.
DirX*trackDirX + theBeamVals.
DirY*trackDirY + theBeamVals.
DirZ*trackDirZ;
101 std::pair< double, double > startX_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartXCut");
102 std::pair< double, double > startY_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartYCut");
103 std::pair< double, double > startZ_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartZCut");
104 double costheta_cut = BeamPars.
get<
double >(
"TrackDirCut");
106 static bool first =
true;
115 if( deltaX < startX_cut.first || deltaX > startX_cut.second )
117 if( deltaY < startY_cut.first || deltaY > startY_cut.second )
119 if( startZ < startZ_cut.first || startZ > startZ_cut.second )
121 if( costheta < costheta_cut )
132 std::cerr <<
"Error. Momentum provided not in range" <<
std::endl;
139 if( !theBeamVals.
Valid ){
150 double flip = ( startDir.Z() < 0. ? -1. : 1. );
152 double showerDirX = flip * startDir.X();
153 double showerDirY = flip * startDir.Y();
154 double showerDirZ = flip * startDir.Z();
156 double deltaX = startX - theBeamVals.
X;
157 double deltaY = startY - theBeamVals.
Y;
159 double costheta = theBeamVals.
DirX*showerDirX + theBeamVals.
DirY*showerDirY + theBeamVals.
DirZ*showerDirZ;
160 std::pair< double, double > startX_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartXCut");
161 std::pair< double, double > startY_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartYCut");
162 std::pair< double, double > startZ_cut = BeamPars.
get< std::pair< double, double > >(
"TrackStartZCut");
163 double costheta_cut = BeamPars.
get<
double >(
"TrackDirCut");
165 if( deltaX < startX_cut.first || deltaX > startX_cut.second )
167 if( deltaY < startY_cut.first || deltaY > startY_cut.second )
169 if( startZ < startZ_cut.first || startZ > startZ_cut.second )
171 if( costheta < costheta_cut )
184 auto mcTruths = evt.
getValidHandle< std::vector< simb::MCTruth > >(
"generator");
188 result.
Valid =
false;
190 if( !true_beam_particle ){
191 std::cout <<
"No true beam particle" <<
std::endl;
196 result.
DirX = true_beam_particle->Px() / true_beam_particle->P();
197 result.
DirY = true_beam_particle->Py() / true_beam_particle->P();
198 result.
DirZ = true_beam_particle->Pz() / true_beam_particle->P();
201 result.
X = true_beam_particle->Position(0).X() + (-1.*true_beam_particle->Position(0).Z())*(result.
DirX / result.
DirZ);
202 result.
Y = true_beam_particle->Position(0).Y() + (-1.*true_beam_particle->Position(0).Z())*(result.
DirY / result.
DirZ);
207 std::vector<art::Ptr<beam::ProtoDUNEBeamEvent>> beamVec;
208 auto beamHandle = evt.
getValidHandle< std::vector< beam::ProtoDUNEBeamEvent > >(
"beamevent");
211 result.Valid =
false;
213 if( beamHandle.isValid()){
219 const std::vector< recob::Track > & beamTracks = beamEvent.
GetBeamTracks();
220 if( beamTracks.size() == 0 ){
221 std::cout <<
"Warning: no tracks associated to beam data" <<
std::endl;
224 else if( beamTracks.size() > 1 ){
225 std::cout <<
"Warning: mutiple tracks associated to beam data" <<
std::endl;
230 result.X = beamTracks.at(0).Trajectory().End().X();
231 result.Y = beamTracks.at(0).Trajectory().End().Y();
233 result.DirX = beamTracks.at(0).EndDirection().X();
234 result.DirY = beamTracks.at(0).EndDirection().Y();
235 result.DirZ = beamTracks.at(0).EndDirection().Z();
BeamVals GetDataBeam(const art::Event &)
const TVector3 & ShowerStart() const
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
std::vector< std::string > valid_momenta
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
bool IsBeamlike(const recob::Track &, const art::Event &, std::string)
Vector_t StartDirection() const
Access to track direction at different points.
T get(std::string const &key) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
const TVector3 & Direction() const
std::map< std::string, fhicl::ParameterSet > DataCuts
Vector_t EndDirection() const
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
std::map< std::string, fhicl::ParameterSet > MCCuts
const std::vector< recob::Track > & GetBeamTracks() const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
def momentum(x1, x2, x3, scale=1.)
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
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)
BeamVals GetMCBeam(const art::Event &)