|
23 | 23 | #include "larcorealg/Geometry/GeometryCore.h" |
24 | 24 | #include "lardata/DetectorInfoServices/DetectorPropertiesService.h" |
25 | 25 |
|
| 26 | +// For beam trigger information |
| 27 | +#include "lardataobj/RawData/RDTimeStamp.h" |
| 28 | + |
26 | 29 | // DeepLearning includes |
27 | 30 | #include "dune/Protodune/DeepLearning/Tools/ImageInformation.h" |
28 | 31 |
|
@@ -360,10 +363,10 @@ namespace ProtoDuneDL |
360 | 363 | } |
361 | 364 |
|
362 | 365 | auto origin = particleInventory->TrackIdToMCTruth_P(bestTrackId)->Origin(); |
363 | | - if((origin == simb::kSingleParticle) && (particleInventory->TrackIdToParticle_P(bestTrackId)->Process() == "primary")) |
364 | | - { |
365 | | - hitOrigin = ProtoDuneDL::Labels::Beam; |
366 | | - } |
| 366 | + if((origin == simb::kSingleParticle) && (particleInventory->TrackIdToParticle_P(bestTrackId)->Process() == "primary")) |
| 367 | + { |
| 368 | + hitOrigin = ProtoDuneDL::Labels::Beam; |
| 369 | + } |
367 | 370 | else |
368 | 371 | { |
369 | 372 | hitOrigin = ProtoDuneDL::Labels::NotBeam; |
@@ -409,12 +412,27 @@ namespace ProtoDuneDL |
409 | 412 | pAllHitsStruct->push_back(tempAllHits); |
410 | 413 | } |
411 | 414 |
|
412 | | - // Keep the hit only if it can be matched to the primary |
413 | | - bool keepHit = true; |
| 415 | + // Keep the hit only if it can be matched to the primary in MC or event has beam trigger |
| 416 | + bool keepHit = false; |
414 | 417 | if(isMC) |
415 | 418 | { |
416 | 419 | keepHit = (mapPrimaryToHits.find(bestTrackId) != mapPrimaryToHits.end()) && (mapPrimaryToHits[bestTrackId] == hitOrigin); |
417 | 420 | } |
| 421 | + else |
| 422 | + { |
| 423 | + // Require beam trigger |
| 424 | + art::Handle<std::vector<raw::RDTimeStamp>> timeStamps; |
| 425 | + event.getByLabel("timingrawdecoder:daq", timeStamps); |
| 426 | + |
| 427 | + // Require time stamp and one RDTimeStamp |
| 428 | + if(timeStamps.isValid() && timeStamps->size() == 1) |
| 429 | + { |
| 430 | + // Access the trigger information. Beam trigger flag = 0xc |
| 431 | + const raw::RDTimeStamp& timeStamp = timeStamps->at(0); |
| 432 | + keepHit = (timeStamp.GetFlags() == 0xc); |
| 433 | + } |
| 434 | + } |
| 435 | + |
418 | 436 | if(keepHit) |
419 | 437 | { |
420 | 438 | ProtoDuneDL::HitsStruct tempHits; |
|
0 commit comments