194 std::cout<<
"============================================"<<std::endl
195 <<
"Run = "<<
event.run()<<
", SubRun = "<<
event.subRun()<<
", Event = "<<
event.id().event()<<std::endl
196 <<
"============================================"<<std::endl;
204 art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
205 auto particleHandle =
event.getValidHandle<std::vector<simb::MCParticle>>(
fSimModuleLabel);
208 art::Handle< std::vector<sbn::crt::CRTHit>> crtHitHandle;
209 std::vector<art::Ptr<sbn::crt::CRTHit> > crtHitList;
211 art::fill_ptr_vector(crtHitList, crtHitHandle);
214 std::vector<sbn::crt::CRTHit> crtHits;
215 std::map<int, int> numHitMap;
217 for(
auto const&
hit : (crtHitList)){
218 crtHits.push_back(*
hit);
221 double hitTime =
hit->ts1_ns * 1
e-3;
222 if(hitTime > 0 && hitTime < 4)
continue;
223 numHitMap[hitTrueID]++;
227 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
228 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
233 if( !pfParticleHandle.isValid() ){
240 art::FindManyP< recob::Track > pfPartToTrackAssoc(pfParticleHandle, event,
fTPCTrackLabel);
246 std::map<int, simb::MCParticle> particles;
247 std::vector<int> nuParticleIds;
248 std::vector<int> lepParticleIds;
249 std::vector<int> dirtParticleIds;
250 std::vector<int> crParticleIds;
252 for (
auto const& particle: (*particleHandle)){
255 int partID = particle.TrackId();
256 particles[partID] = particle;
259 art::Ptr<simb::MCTruth> truth = pi_serv->TrackIdToMCTruth_P(partID);
263 if(truth->Origin() == simb::kBeamNeutrino){
265 vtx.SetX(truth->GetNeutrino().Nu().Vx()); vtx.SetY(truth->GetNeutrino().Nu().Vy()); vtx.SetZ(truth->GetNeutrino().Nu().Vz());
268 dirtParticleIds.push_back(partID);
271 else if(pdg==13 && particle.Mother()==0){
272 lepParticleIds.push_back(partID);
276 nuParticleIds.push_back(partID);
282 crParticleIds.push_back(partID);
290 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
291 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
294 for (
auto const& tpcTrack : (*tpcTrackHandle)){
296 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
298 std::string
type =
"none";
299 if(std::find(lepParticleIds.begin(), lepParticleIds.end(), trackTrueID) != lepParticleIds.end()) type =
"NuMuTrack";
300 if(std::find(nuParticleIds.begin(), nuParticleIds.end(), trackTrueID) != nuParticleIds.end()) type =
"NuTrack";
301 if(std::find(crParticleIds.begin(), crParticleIds.end(), trackTrueID) != crParticleIds.end()) type =
"CrTrack";
302 if(std::find(dirtParticleIds.begin(), dirtParticleIds.end(), trackTrueID) != dirtParticleIds.end()) type =
"DirtTrack";
303 if(type ==
"none")
continue;
308 if(closest.second != -99999){
310 if(hitTrueID == trackTrueID && hitTrueID != -99999){
318 if(numHitMap.find(trackTrueID) != numHitMap.end()){
325 int nbins =
hDCATotal.begin()->second->GetNbinsX();
326 for(
int i = 0; i < nbins; i++){
327 double DCAcut =
hDCATotal.begin()->second->GetBinCenter(i);
332 if(closest.second < DCAcut && closest.second != -99999){
333 double hitTime = closest.first.ts1_ns * 1
e-3;
334 if(hitTime > 0 && hitTime < 4)
continue;
347 for (PFParticleIdMap::const_iterator it = pfParticleMap.begin(); it != pfParticleMap.end(); ++it){
349 const art::Ptr<recob::PFParticle> pParticle(it->second);
351 if (!pParticle->IsPrimary())
continue;
353 const int pdg(pParticle->PdgCode());
354 const bool isNeutrino(
std::abs(pdg) == pandora::NU_E ||
std::abs(pdg) == pandora::NU_MU ||
std::abs(pdg) == pandora::NU_TAU);
356 if(!isNeutrino)
continue;
358 std::string type =
"none";
359 std::vector<recob::Track> nuTracks;
362 for (
const size_t daughterId : pParticle->Daughters()){
365 art::Ptr<recob::PFParticle> pDaughter = pfParticleMap.at(daughterId);
366 const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pDaughter.key()));
367 if(associatedTracks.size() != 1)
continue;
371 nuTracks.push_back(tpcTrack);
374 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
376 if(std::find(lepParticleIds.begin(), lepParticleIds.end(), trueId) != lepParticleIds.end()){
379 else if(std::find(nuParticleIds.begin(), nuParticleIds.end(), trueId) != nuParticleIds.end()){
380 if(type !=
"NuMuPfp") type =
"NuPfp";
382 else if(std::find(dirtParticleIds.begin(), dirtParticleIds.end(), trueId) != dirtParticleIds.end()){
383 if(type !=
"NuMuPfp" && type !=
"NuPfp") type =
"DirtPfp";
385 else if(std::find(crParticleIds.begin(), crParticleIds.end(), trueId) != crParticleIds.end()){
386 if(type !=
"NuMuPfp" && type !=
"NuPfp" && type !=
"DirtPfp") type =
"CrPfp";
390 if(nuTracks.size() == 0)
continue;
392 std::sort(nuTracks.begin(), nuTracks.end(), [](
auto&
left,
auto&
right){
393 return left.Length() >
right.Length();});
396 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
399 if(numHitMap.find(trackTrueID) != numHitMap.end()){
409 if(closest.second != -99999){
411 if(hitTrueID == trackTrueID && hitTrueID != -99999){
420 int nbins =
hDCATotal.begin()->second->GetNbinsX();
421 for(
int i = 0; i < nbins; i++){
422 double DCAcut =
hDCATotal.begin()->second->GetBinCenter(i);
427 if(closest.second < DCAcut && closest.second != -99999){
428 double hitTime = closest.first.ts1_ns * 1
e-3;
429 if(hitTime > 0 && hitTime < 4)
continue;
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
art::InputTag fCRTHitLabel
name of CRT producer
bool fVerbose
print information about what's going on
void GetPFParticleIdMap(const PFParticleHandle &pfParticleHandle, PFParticleIdMap &pfParticleMap)
int TrueIdFromTotalEnergy(const art::Event &event, const sbnd::crt::CRTData &data)
int TrueIdFromHitId(const art::Event &event, int hit_i)
std::map< std::string, TH1D * > hDCATotal
std::map< std::string, TH1D * > hNoMatchDCA
void Initialize(const art::Event &event)
std::pair< sbn::crt::CRTHit, double > ClosestCRTHit(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::pair< double, double > t0MinMax, std::vector< sbn::crt::CRTHit > crtHits, int driftDirection)
std::map< std::string, TH1D * > hLengthTotal
art::InputTag fTPCTrackLabel
name of CRT producer
std::map< std::string, TH1D * > hNumTrueMatches
std::map< std::string, TH1D * > hDCATag
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
bool CrtHitCosmicId(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< sbn::crt::CRTHit > crtHits, const art::Event &event)
std::map< std::string, TH1D * > hMatchDCA
art::InputTag fPandoraLabel
CRTBackTracker fCrtBackTrack
art::Handle< std::vector< recob::PFParticle > > PFParticleHandle
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)
art::InputTag fSimModuleLabel
name of detsim producer
std::map< std::string, TH1D * > hLengthTag