120 if( !fBeamlineUtils.IsGoodBeamlineTrigger( e ) ){
121 MF_LOG_INFO(
"AbsCexSelection") <<
"Failed Beamline Trigger Check" <<
"\n";
128 if(beamParticles.size() == 0){
129 MF_LOG_INFO(
"AbsCexSelection") <<
"We found no beam particles for this event... moving on" <<
"\n";
140 if( !thisTrack && thisShower ){
141 MF_LOG_INFO(
"AbsCexSelection") <<
"Beam Particle Reconstructed as shower" <<
"\n";
144 else if( !thisShower && !thisTrack ){
145 MF_LOG_INFO(
"AbsCexSelection") <<
"Beam Particle Not Reconstructed" <<
"\n";
149 MF_LOG_INFO(
"AbsCexSelection") <<
"Beam Particle Reconstructed as track" <<
"\n";
157 auto recoTracks = e.getValidHandle<std::vector<recob::Track> >(
fTrackerTag);
158 art::FindManyP<recob::Hit> findHits(recoTracks,e,
fTrackerTag);
171 double dirX = 0., dirY = 0., dirZ = 1.;
186 dirX = -1. * endDir.X();
187 dirY = -1. * endDir.Y();
188 dirZ = -1. * endDir.Z();
197 std::cout << startZ <<
" " << endZ <<
std::endl;
198 std::cout << startY <<
" " << endY <<
std::endl;
199 std::cout << startX <<
" " << endX <<
std::endl;
200 std::cout << dirX <<
" " << dirY <<
" " << dirZ <<
std::endl;
202 if( e.isRealData() ){
203 auto beamEvent = fBeamlineUtils.GetBeamEvent(e);
204 std::cout << beamEvent.GetTOF() <<
std::endl;
206 const std::vector< recob::Track > & beamEventTracks = beamEvent.GetBeamTracks();
207 if( beamEventTracks.size() < 1 ){
208 MF_LOG_INFO(
"AbsCexSelection") <<
"No tracks associated to beam event" <<
"\n";
212 MF_LOG_INFO(
"AbsCexSelection") <<
"Too many tracks associated to beam event" <<
"\n";
216 auto beamEventTrack = beamEventTracks.at(0);
217 double deltaX = startX - beamEventTrack.End().X();
218 double deltaY = startY - beamEventTrack.End().Y();
219 double deltaZ = startZ - beamEventTrack.End().Z();
225 MF_LOG_INFO(
"AbsCexSelection") <<
"Beam track is outside of good start region" <<
"\n";
229 double beamDirX = beamEventTrack.EndDirection().X();
230 double beamDirY = beamEventTrack.EndDirection().Y();
231 double beamDirZ = beamEventTrack.EndDirection().Z();
233 double cos_theta = (beamDirX*dirX + beamDirY*dirY + beamDirZ*dirZ);
235 MF_LOG_INFO(
"AbsCexSelection") <<
"Bad track angle" <<
"\n";
243 auto mcTruths = e.getValidHandle<std::vector<simb::MCTruth>>(
fGeneratorTag);
245 if( !true_beam_particle ){
246 MF_LOG_INFO(
"AbsCexSelection") <<
"No true beam particle" <<
"\n";
250 double deltaX = startX - true_beam_particle->Position(0).X();
251 double deltaY = startY - true_beam_particle->Position(0).Y();
252 double deltaZ = startZ - true_beam_particle->Position(0).Z();
258 MF_LOG_INFO(
"AbsCexSelection") <<
"Beam track is outside of good start region" <<
"\n";
262 double beamDirX = true_beam_particle->Px() / true_beam_particle->P();
263 double beamDirY = true_beam_particle->Py() / true_beam_particle->P();
264 double beamDirZ = true_beam_particle->Pz() / true_beam_particle->P();
266 double cos_theta = (beamDirX*dirX + beamDirY*dirY + beamDirZ*dirZ);
268 MF_LOG_INFO(
"AbsCexSelection") <<
"Bad track angle" <<
"\n";
277 MF_LOG_INFO(
"AbsCexSelection") <<
"Failed End Z cut" <<
"\n";
285 for(
size_t i = 0; i < trackDaughters.size(); ++i ){
286 auto daughterTrack = trackDaughters.at(i);
289 auto daughterHits = findHits.at( daughterTrack->ID() );
292 double track_total = 0.;
293 for(
size_t h = 0;
h < daughterHits.size(); ++
h ){
294 std::array<float,4> cnn_out = hitResults->
getOutput( daughterHits[
h] );
295 track_total += cnn_out[ hitResults->
getIndex(
"track") ];
299 MF_LOG_INFO(
"AbsCexSelection") <<
"Found daughter track that looks like shower" <<
"\n";
308 std::vector<float> calo_range = daughter_calo[0].ResidualRange();
309 std::vector<float> calo_dEdX;
311 else calo_dEdX = daughter_calo[0].dEdx();
313 std::vector<double> daughter_range, daughter_dEdX;
314 for(
size_t j = 0; j < calo_range.size(); ++j ){
315 daughter_range.push_back( calo_range[i] );
316 daughter_dEdX.push_back( calo_dEdX[i] );
319 std::pair< double,int > chi2_pid_results = trackUtil.
Chi2PID( daughter_dEdX, daughter_range,
profile );
322 MF_LOG_INFO(
"AbsCexSelection") <<
"Found daughter with MIP-like Chi2 PID" <<
"\n";
std::string fGeneratorTag
std::pair< double, double > fTrackStartYCut
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
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.
bool InRange(double, double, double)
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.
int getIndex(const std::string &name) const
Index of column with given name, or -1 if name not found.
Vector_t StartDirection() const
Access to track direction at different points.
std::pair< double, double > fTrackStartXCut
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::string fCalorimetryTag
std::pair< double, double > fTrackStartZCut
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...
#define MF_LOG_INFO(category)
std::pair< double, int > Chi2PID(const std::vector< double > &track_dedx, const std::vector< double > &range, TProfile *profile)
Hierarchical representation of particle flow.
Vector_t EndDirection() const
Point_t const & End() const
Returns the position of the last valid point of the trajectory [cm].
std::string fPFParticleTag
fhicl::ParameterSet beamlineUtil
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
std::array< float, N > getOutput(size_t key) const
Get copy of the MVA output vector at index "key".
fhicl::ParameterSet fCalorimetryParameters
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.
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)
std::vector< float > CalibrateCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, const fhicl::ParameterSet &ps)
Calibrate a Calorimetry object for a given plane from a given track.