18 #include "art_root_io/TFileService.h" 69 std::vector<recob::Hit>
const& hitlist,
70 std::vector<hit_origin_t>& hitOrigins,
71 std::vector<sim::MCHitCollection>
const& mchitCollectionVector,
72 std::map<int, const simb::MCTruth*>
const& trackIDToTruthMap);
77 std::vector<size_t>
const& track_indices_this_hit,
78 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_cluster,
79 std::vector<bool>& hitsAccounted_per_tag,
80 std::vector<bool>& hitsAllTags);
85 std::vector<size_t>
const& cluster_indices_this_hit,
86 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_cluster,
87 std::vector<bool>& hitsAccounted_per_tag,
88 std::vector<bool>& hitsAllTags);
188 tEventTree = (TTree*)tfs->make<TTree>(
"CosmicEventTree",
"CosmicEventTree");
193 "runNumber/I:eventNumber/I:nHitsTotal_Unknown/I:nHitsTotal_Cosmic/I:nHitsTotal_NonCosmic/" 194 "I:qTotal_Unknown/F:qTotal_Cosmic/F:qTotal_NonCosmic/F:nHitsTrack/I:nHitsTrack_Cosmic/" 195 "I:nHitsTrack_NonCosmic/I:qTrack/F:qTrack_Cosmic/F:qTrack_NonCosmic/F:nHitsCluster/" 196 "I:nHitsCluster_Cosmic/I:nHitsCluster_NonCosmic/I:qCluster/F:qCluster_Cosmic/" 197 "F:qCluster_NonCosmic/F:TotalTaggedCharge_Cosmic/F:TotalTaggedCharge_NonCosmic/" 198 "F:TotalTaggedHits_Cosmic/I:TotalTaggedHits_NonCosmic/I");
219 std::vector<recob::Hit>
const& hitVector(*hitListHandle);
221 std::vector<hit_origin_t> hitOrigins(hitVector.size());
226 std::vector<sim::MCHitCollection>
const& mchitcolVector(*mchitListHandle);
231 std::vector<simb::MCParticle>
const& mcParticleVector(*mcParticleHandle);
237 std::vector<const simb::MCTruth*> particle_to_truth =
241 std::map<int, const simb::MCTruth*> trackIDToTruthMap;
242 for (
size_t p_iter = 0; p_iter < mcParticleVector.size(); p_iter++)
243 trackIDToTruthMap[mcParticleVector[p_iter].TrackId()] = particle_to_truth[p_iter];
245 FillMCInfo(evt, hitVector, hitOrigins, mchitcolVector, trackIDToTruthMap);
249 std::vector<recob::Track>
const& trackVector(*trackListHandle);
253 std::vector<recob::Cluster>
const& clusterVector(*clusterListHandle);
257 std::vector<std::vector<size_t>> track_indices_per_hit =
262 std::vector<std::vector<size_t>> cluster_indices_per_hit =
265 std::vector<art::Handle<std::vector<anab::CosmicTag>>> cosmicTagHandlesVector(
267 std::vector<art::Handle<art::Assns<recob::Track, anab::CosmicTag>>> assnTrackTagHandlesVector(
269 std::vector<std::vector<const anab::CosmicTag*>> tags_per_track(
271 std::vector<art::Handle<art::Assns<recob::Cluster, anab::CosmicTag>>> assnClusterTagHandlesVector(
273 std::vector<std::vector<const anab::CosmicTag*>> tags_per_cluster(
285 for (
auto const& pair : *assnTrackTagHandlesVector[label_i])
286 tags_per_track.at(pair.first.key())[label_i] = &(*(pair.second));
292 for (
auto const& pair : *assnClusterTagHandlesVector[label_i])
293 tags_per_cluster.at(pair.first.key())[label_i] = &(*(pair.second));
299 std::vector<std::vector<bool>> hitsAccounted(
301 std::vector<bool> hitsAllTags(hitVector.size(),
false);
303 for (
size_t hit_iter = 0; hit_iter < hitVector.size(); hit_iter++) {
305 float charge = hitVector[hit_iter].Integral();
308 if (track_indices_per_hit[hit_iter].
size() != 0)
312 track_indices_per_hit[hit_iter],
314 hitsAccounted[hit_iter],
317 if (cluster_indices_per_hit[hit_iter].
size() != 0)
321 cluster_indices_per_hit[hit_iter],
323 hitsAccounted[hit_iter],
326 if (hitsAllTags[hit_iter])
FillAllTagsInfo(hitVector[hit_iter], origin);
383 std::vector<recob::Hit>
const& hitlist,
384 std::vector<hit_origin_t>& hitOrigins,
385 std::vector<sim::MCHitCollection>
const& mchitCollectionVector,
386 std::map<int, const simb::MCTruth*>
const& trackIdToTruthMap)
388 auto const clock_data =
391 for (
size_t itr = 0; itr < hitlist.size(); itr++) {
395 std::vector<int> trackIDs;
396 std::vector<double>
energy;
398 for (
auto const& mchit : mchitCollectionVector[this_hit.
Channel()]) {
399 if (
std::abs(clock_data.TPCTDC2Tick(mchit.PeakTime()) - this_hit.
PeakTime()) <
401 trackIDs.push_back(mchit.PartTrackId());
402 energy.push_back(mchit.PartEnergy());
406 if (trackIDs.size() == 0) {
413 float cosmic_energy = 0;
414 float non_cosmic_energy = 0;
416 for (
size_t iter = 0; iter < trackIDs.size(); iter++) {
417 auto map_element = trackIdToTruthMap.find(
std::abs(trackIDs[iter]));
418 if (map_element == trackIdToTruthMap.end())
continue;
419 int origin = map_element->second->Origin();
421 non_cosmic_energy += energy[iter];
423 cosmic_energy += energy[iter];
426 if (non_cosmic_energy > cosmic_energy) {
443 size_t const& hit_iter,
446 std::vector<size_t>
const& track_indices_this_hit,
447 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_track,
448 std::vector<bool>& hitsAccounted_per_tag,
449 std::vector<bool>& hitsAllTags)
453 cEventVals.
qTrack += charge;
466 if (hitsAccounted_per_tag[nCT])
continue;
468 for (
auto const& track_index : track_indices_this_hit) {
469 if (!tags_per_track[track_index][nCT])
continue;
473 hitsAccounted_per_tag[nCT] =
true;
474 hitsAllTags[hit_iter] =
true;
492 size_t const& hit_iter,
495 std::vector<size_t>
const& cluster_indices_this_hit,
496 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_cluster,
497 std::vector<bool>& hitsAccounted_per_tag,
498 std::vector<bool>& hitsAllTags)
515 if (hitsAccounted_per_tag[nCT])
continue;
517 for (
auto const& cluster_index : cluster_indices_this_hit) {
518 if (!tags_per_cluster[cluster_index][nCT])
continue;
519 const anab::CosmicTag* currentTag(tags_per_cluster[cluster_index][nCT]);
522 hitsAccounted_per_tag[nCT] =
true;
523 hitsAllTags[hit_iter] =
true;
void analyze(const art::Event &evt)
read access to event
CosmicRemovalAna(fhicl::ParameterSet const &pset)
EventNumber_t event() const
std::string fMCHitsModuleLabel
int TotalTaggedHits_NonCosmic
void FillAllTagsInfo(recob::Hit const &hit, hit_origin_t const &origin)
void FillTrackInfo(size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &track_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * >> const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
cEventProperties_t cEventVals
float TotalTaggedCharge_NonCosmic
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
EDAnalyzer(fhicl::ParameterSet const &pset)
std::string fTrackModuleLabel
std::vector< float > cTaggedCharge_NonCosmic
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::string fHitsModuleLabel
#define DEFINE_ART_MODULE(klass)
void FillMCInfo(art::Event const &e, std::vector< recob::Hit > const &hitlist, std::vector< hit_origin_t > &hitOrigins, std::vector< sim::MCHitCollection > const &mchitCollectionVector, std::map< int, const simb::MCTruth * > const &trackIDToTruthMap)
std::vector< int > cTaggedHits_Cosmic
std::string fClusterModuleLabel
void InitEventTree(int run_number, int event_number)
int TotalTaggedHits_Cosmic
std::vector< int > cTaggedHits_NonCosmic
std::vector< float > fCosmicScoreThresholds
Detector simulation of raw signals on wires.
float PeakTime() const
Time of the signal peak, in tick units.
Declaration of signal hit object.
std::string fMCModuleLabel
float TotalTaggedCharge_Cosmic
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
Provides recob::Track data product.
std::vector< float > cTaggedCharge_Cosmic
2D representation of charge deposited in the TDC/wire plane
auto const & get(AssnsNode< L, R, D > const &r)
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
int nHitsCluster_NonCosmic
constexpr Point origin()
Returns a origin position with a point of the specified type.
void FillClusterInfo(size_t const &hit_iter, hit_origin_t const &origin, float const &charge, std::vector< size_t > const &cluster_indices_this_hit, std::vector< std::vector< const anab::CosmicTag * >> const &tags_per_cluster, std::vector< bool > &hitsAccounted_per_tag, std::vector< bool > &hitsAllTags)
std::vector< std::string > fCosmicTagAssocLabel