235 std::cout<<
"============================================"<<std::endl
236 <<
"Run = "<<
event.run()<<
", SubRun = "<<
event.subRun()<<
", Event = "<<
event.id().event()<<std::endl
237 <<
"============================================"<<std::endl;
245 art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
247 auto particleHandle =
event.getValidHandle<std::vector<simb::MCParticle>>(
fSimModuleLabel);
252 if( !pfParticleHandle.isValid() ){
259 art::FindManyP< recob::Track > pfPartToTrackAssoc(pfParticleHandle, event,
fTpcTrackModuleLabel);
270 std::map<int, simb::MCParticle> particles;
271 std::vector<simb::MCParticle> parts;
272 std::vector<int> nuParticleIds;
273 std::vector<int> lepParticleIds;
274 std::vector<int> dirtParticleIds;
275 std::vector<int> crParticleIds;
278 for (
auto const& particle: (*particleHandle)){
280 int partId = particle.TrackId();
281 particles[partId] = particle;
282 parts.push_back(particle);
284 art::Ptr<simb::MCTruth> truth = pi_serv->TrackIdToMCTruth_P(partId);
288 if(truth->Origin() == simb::kBeamNeutrino){
290 vtx.SetX(truth->GetNeutrino().Nu().Vx()); vtx.SetY(truth->GetNeutrino().Nu().Vy()); vtx.SetZ(truth->GetNeutrino().Nu().Vz());
293 dirtParticleIds.push_back(partId);
296 else if(pdg==13 && particle.Mother()==0){
297 lepParticleIds.push_back(partId);
301 nuParticleIds.push_back(partId);
308 crParticleIds.push_back(partId);
318 std::vector<double> fakeTpc0Flashes = fakeFlashes.first;
319 std::vector<double> fakeTpc1Flashes = fakeFlashes.second;
324 if(!tpc0BeamFlash && !tpc1BeamFlash)
return;
330 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
331 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
334 for (PFParticleIdMap::const_iterator it = pfParticleMap.begin(); it != pfParticleMap.end(); ++it){
336 const art::Ptr<recob::PFParticle> pParticle(it->second);
338 if (!pParticle->IsPrimary())
continue;
340 const int pdg(pParticle->PdgCode());
341 const bool isNeutrino(
std::abs(pdg) == pandora::NU_E ||
std::abs(pdg) == pandora::NU_MU ||
std::abs(pdg) == pandora::NU_TAU);
343 if(!isNeutrino)
continue;
346 std::vector<recob::Track> nuTracks;
349 for (
const size_t daughterId : pParticle->Daughters()){
352 art::Ptr<recob::PFParticle> pDaughter = pfParticleMap.at(daughterId);
353 const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pDaughter.key()));
354 if(associatedTracks.size() != 1)
continue;
358 nuTracks.push_back(tpcTrack);
361 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
364 if(std::find(lepParticleIds.begin(), lepParticleIds.end(), trueId) != lepParticleIds.end()){
368 else if(std::find(nuParticleIds.begin(), nuParticleIds.end(), trueId) != nuParticleIds.end()){
369 if(pfpType != 0) pfpType = 4;
371 else if(std::find(dirtParticleIds.begin(), dirtParticleIds.end(), trueId) != dirtParticleIds.end()){
373 if(pfpType != 0 && pfpType != 4) pfpType = 1;
375 else if(std::find(crParticleIds.begin(), crParticleIds.end(), trueId) != crParticleIds.end()){
377 if(pfpType != 0 && pfpType != 4 && pfpType != 1) pfpType = 2;
381 if(particles.find(trueId) != particles.end()){
383 if(
std::abs(particles[trueId].PdgCode()) == 13){
386 double momentum = particles[trueId].P();
388 double theta = (se.second-se.first).Theta();
389 double phi = (se.second-se.first).Phi();
391 for(
size_t j = 0; j <
nCuts; j++){
393 if(j == 0) plot =
true;
395 cosIdAlg.
SetCuts(
true,
false,
false,
false,
false,
false,
false,
false,
false);
396 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
399 cosIdAlg.
SetCuts(
false,
true,
false,
false,
false,
false,
false,
false,
false);
400 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
403 cosIdAlg.
SetCuts(
false,
false,
true,
false,
false,
false,
false,
false,
false);
404 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
408 cosIdAlg.
SetCuts(
false,
false,
false,
true,
false,
false,
false,
false,
false);
409 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
412 cosIdAlg.
SetCuts(
false,
false,
false,
false,
true,
false,
false,
false,
false);
413 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
416 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
true,
false,
false,
false);
417 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
420 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
true,
false,
false);
421 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
424 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
false,
true,
false);
425 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
428 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
false,
false,
true);
429 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
434 if(
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
436 if(j == 11 && !
cosIdAlg.
CosmicId(tpcTrack, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
439 hTrueMom[trackType][j]->Fill(momentum);
449 if(nuTracks.size() == 0)
continue;
452 std::sort(nuTracks.begin(), nuTracks.end(), [](
auto&
left,
auto&
right){
453 return left.Length() >
right.Length();});
458 double recoMuMomentum = 0.;
460 double length = nuTrack.Length();
461 double theta = nuTrack.Theta();
462 double phi = nuTrack.Phi();
471 for(
size_t j = 0; j <
nCuts; j++){
473 if(j == 0) plot =
true;
475 cosIdAlg.
SetCuts(
true,
false,
false,
false,
false,
false,
false,
false,
false);
481 cosIdAlg.
SetCuts(
false,
true,
false,
false,
false,
false,
false,
false,
false);
487 cosIdAlg.
SetCuts(
false,
false,
true,
false,
false,
false,
false,
false,
false);
493 cosIdAlg.
SetCuts(
false,
false,
false,
true,
false,
false,
false,
false,
false);
499 cosIdAlg.
SetCuts(
false,
false,
false,
false,
true,
false,
false,
false,
false);
505 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
true,
false,
false,
false);
511 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
true,
false,
false);
517 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
false,
true,
false);
523 cosIdAlg.
SetCuts(
false,
false,
false,
false,
false,
false,
false,
false,
true);
531 if(
cosIdAlg.
CosmicId(
detProp, *pParticle, pfParticleMap, event, fakeTpc0Flashes, fakeTpc1Flashes)) plot =
true;
533 if(j == 11 && !
cosIdAlg.
CosmicId(
detProp, *pParticle, pfParticleMap, event, fakeTpc0Flashes, fakeTpc1Flashes)){
538 hRecoMom[pfpType][j]->Fill(recoMuMomentum);
void GetPFParticleIdMap(const PFParticleHandle &pfParticleHandle, PFParticleIdMap &pfParticleMap)
trkf::TrajectoryMCSFitter fMcsFitter
art::InputTag fTpcTrackModuleLabel
name of TPC track producer
bool BeamFlash(std::vector< double > flashes, double beamTimeMin, double beamTimeMax)
bool CosmicId(recob::Track track, const art::Event &event, std::vector< double > t0Tpc0, std::vector< double > t0Tpc1)
TH1D * hRecoLength[5][12]
float bestMomentum() const
momentum for best direction fit
double TpcLength(const simb::MCParticle &particle)
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
TH1D * hTrueLength[4][12]
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
trkf::TrackMomentumCalculator fRangeFitter
art::InputTag fSimModuleLabel
name of detsim producer
Class storing the result of the Maximum Likelihood fit of Multiple Coulomb Scattering angles between ...
art::InputTag fPandoraLabel
art::Handle< std::vector< recob::PFParticle > > PFParticleHandle
std::pair< std::vector< double >, std::vector< double > > FakeTpcFlashes(std::vector< simb::MCParticle > particles)
bool fVerbose
print information about what's going on
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
BEGIN_PROLOG could also be cout
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
std::pair< TVector3, TVector3 > CrossingPoints(const simb::MCParticle &particle)
bool InFiducial(geo::Point_t point, double fiducial)
void SetCuts(bool FV, bool SP, bool Geo, bool CC, bool AC, bool CT, bool CH, bool PT, bool PN)