197 std::cout<<
"============================================"<<std::endl
198 <<
"Run = "<<
event.run()<<
", SubRun = "<<
event.subRun()<<
", Event = "<<
event.id().event()<<std::endl
199 <<
"============================================"<<std::endl;
207 art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
208 auto particleHandle =
event.getValidHandle<std::vector<simb::MCParticle>>(
fSimModuleLabel);
211 art::Handle< std::vector<sbn::crt::CRTTrack>> crtTrackHandle;
212 std::vector<art::Ptr<sbn::crt::CRTTrack> > crtTrackList;
214 art::fill_ptr_vector(crtTrackList, crtTrackHandle);
217 std::vector<sbn::crt::CRTTrack> crtTracks;
218 std::map<int, int> numCrtTrackMap;
220 for(
auto const&
track : (crtTrackList)){
221 crtTracks.push_back(*
track);
224 double trackTime =
track->ts1_ns * 1
e-3;
225 if(trackTime > 0 && trackTime < 4)
continue;
226 numCrtTrackMap[trackTrueID]++;
230 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
231 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
236 if( !pfParticleHandle.isValid() ){
243 art::FindManyP< recob::Track > pfPartToTrackAssoc(pfParticleHandle, event,
fTPCTrackLabel);
249 std::map<int, simb::MCParticle> particles;
250 std::vector<int> nuParticleIds;
251 std::vector<int> lepParticleIds;
252 std::vector<int> dirtParticleIds;
253 std::vector<int> crParticleIds;
255 for (
auto const& particle: (*particleHandle)){
258 int partID = particle.TrackId();
259 particles[partID] = particle;
262 art::Ptr<simb::MCTruth> truth = pi_serv->TrackIdToMCTruth_P(partID);
266 if(truth->Origin() == simb::kBeamNeutrino){
268 vtx.SetX(truth->GetNeutrino().Nu().Vx()); vtx.SetY(truth->GetNeutrino().Nu().Vy()); vtx.SetZ(truth->GetNeutrino().Nu().Vz());
271 dirtParticleIds.push_back(partID);
274 else if(pdg==13 && particle.Mother()==0){
275 lepParticleIds.push_back(partID);
279 nuParticleIds.push_back(partID);
285 crParticleIds.push_back(partID);
293 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
294 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
297 for (
auto const& tpcTrack : (*tpcTrackHandle)){
299 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
301 std::string
type =
"none";
302 if(std::find(lepParticleIds.begin(), lepParticleIds.end(), trackTrueID) != lepParticleIds.end()) type =
"NuMuTrack";
303 if(std::find(nuParticleIds.begin(), nuParticleIds.end(), trackTrueID) != nuParticleIds.end()) type =
"NuTrack";
304 if(std::find(crParticleIds.begin(), crParticleIds.end(), trackTrueID) != crParticleIds.end()) type =
"CrTrack";
305 if(std::find(dirtParticleIds.begin(), dirtParticleIds.end(), trackTrueID) != dirtParticleIds.end()) type =
"DirtTrack";
306 if(type ==
"none")
continue;
308 if(numCrtTrackMap.find(trackTrueID) != numCrtTrackMap.end()){
319 if(closestAngle.second != -99999){
321 if(crtTrackTrueID == trackTrueID && crtTrackTrueID != -99999){
329 if(closestDCA.second != -99999){
331 if(crtTrackTrueID == trackTrueID && crtTrackTrueID != -99999){
340 int nbins =
hDCATotal.begin()->second->GetNbinsX();
341 for(
int i = 0; i < nbins; i++){
342 double DCAcut =
hDCATotal.begin()->second->GetBinCenter(i);
347 if(closestDCA.second < DCAcut && closestDCA.second != -99999){
348 double trackTime = closestDCA.first.ts1_ns * 1
e-3;
349 if(trackTime > 0 && trackTime < 4)
continue;
363 for (PFParticleIdMap::const_iterator it = pfParticleMap.begin(); it != pfParticleMap.end(); ++it){
365 const art::Ptr<recob::PFParticle> pParticle(it->second);
367 if (!pParticle->IsPrimary())
continue;
369 const int pdg(pParticle->PdgCode());
370 const bool isNeutrino(
std::abs(pdg) == pandora::NU_E ||
std::abs(pdg) == pandora::NU_MU ||
std::abs(pdg) == pandora::NU_TAU);
372 if(!isNeutrino)
continue;
374 std::string type =
"none";
375 std::vector<recob::Track> nuTracks;
378 for (
const size_t daughterId : pParticle->Daughters()){
381 art::Ptr<recob::PFParticle> pDaughter = pfParticleMap.at(daughterId);
382 const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pDaughter.key()));
383 if(associatedTracks.size() != 1)
continue;
387 nuTracks.push_back(tpcTrack);
390 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
392 if(std::find(lepParticleIds.begin(), lepParticleIds.end(), trueId) != lepParticleIds.end()){
395 else if(std::find(nuParticleIds.begin(), nuParticleIds.end(), trueId) != nuParticleIds.end()){
396 if(type !=
"NuMuPfp") type =
"NuPfp";
398 else if(std::find(dirtParticleIds.begin(), dirtParticleIds.end(), trueId) != dirtParticleIds.end()){
399 if(type !=
"NuMuPfp" && type !=
"NuPfp") type =
"DirtPfp";
401 else if(std::find(crParticleIds.begin(), crParticleIds.end(), trueId) != crParticleIds.end()){
402 if(type !=
"NuMuPfp" && type !=
"NuPfp" && type !=
"DirtPfp") type =
"CrPfp";
406 if(nuTracks.size() == 0)
continue;
408 std::sort(nuTracks.begin(), nuTracks.end(), [](
auto&
left,
auto&
right){
409 return left.Length() >
right.Length();});
412 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
415 if(numCrtTrackMap.find(trackTrueID) != numCrtTrackMap.end()){
425 if(closestAngle.second != -99999){
427 if(crtTrackTrueID == trackTrueID && crtTrackTrueID != -99999){
435 if(closestDCA.second != -99999){
437 if(crtTrackTrueID == trackTrueID && crtTrackTrueID != -99999){
446 int nbins =
hDCATotal.begin()->second->GetNbinsX();
447 for(
int i = 0; i < nbins; i++){
448 double DCAcut =
hDCATotal.begin()->second->GetBinCenter(i);
453 if(closestDCA.second < DCAcut && closestDCA.second != -99999){
454 double trackTime = closestDCA.first.ts1_ns * 1
e-3;
455 if(trackTime > 0 && trackTime < 4)
continue;
int TrueIdFromTrackId(const art::Event &event, int track_i)
art::Handle< std::vector< recob::PFParticle > > PFParticleHandle
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
art::InputTag fCRTTrackLabel
name of CRT producer
bool fVerbose
print information about what's going on
void GetPFParticleIdMap(const PFParticleHandle &pfParticleHandle, PFParticleIdMap &pfParticleMap)
process_name use argoneut_mc_hitfinder track
int TrueIdFromTotalEnergy(const art::Event &event, const sbnd::crt::CRTData &data)
std::map< std::string, TH1D * > hDCATag
std::map< std::string, TH1D * > hDCATotal
CrtTrackCosmicIdAlg ctTag
CRTBackTracker fCrtBackTrack
void Initialize(const art::Event &event)
art::InputTag fSimModuleLabel
name of detsim producer
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByDCA(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event, double minAngle=0.)
bool CrtTrackCosmicId(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
std::map< std::string, TH1D * > hNumTrueMatches
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
std::map< std::string, TH1D * > hNoMatchDCA
art::InputTag fPandoraLabel
std::map< std::string, TH1D * > hLengthTag
std::map< std::string, TH1D * > hMatchAngle
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByAngle(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event, double minDCA=0.)
CRTTrackMatchAlg trackAlg
std::map< std::string, TH1D * > hMatchDCA
art::InputTag fTPCTrackLabel
name of CRT producer
std::map< std::string, TH1D * > hLengthTotal
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:
bool InFiducial(geo::Point_t point, double fiducial)
std::map< std::string, TH1D * > hNoMatchAngle