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);
187 tEventTree = (TTree*)tfs->make<TTree>(
"CosmicEventTree",
"CosmicEventTree");
192 "runNumber/I:eventNumber/I:nHitsTotal_Unknown/I:nHitsTotal_Cosmic/I:nHitsTotal_NonCosmic/" 193 "I:qTotal_Unknown/F:qTotal_Cosmic/F:qTotal_NonCosmic/F:nHitsTrack/I:nHitsTrack_Cosmic/" 194 "I:nHitsTrack_NonCosmic/I:qTrack/F:qTrack_Cosmic/F:qTrack_NonCosmic/F:nHitsCluster/" 195 "I:nHitsCluster_Cosmic/I:nHitsCluster_NonCosmic/I:qCluster/F:qCluster_Cosmic/" 196 "F:qCluster_NonCosmic/F:TotalTaggedCharge_Cosmic/F:TotalTaggedCharge_NonCosmic/" 197 "F:TotalTaggedHits_Cosmic/I:TotalTaggedHits_NonCosmic/I");
217 std::vector<recob::Hit>
const& hitVector(*hitListHandle);
219 std::vector<hit_origin_t> hitOrigins(hitVector.size());
224 std::vector<sim::MCHitCollection>
const& mchitcolVector(*mchitListHandle);
229 std::vector<simb::MCParticle>
const& mcParticleVector(*mcParticleHandle);
235 std::vector<const simb::MCTruth*> particle_to_truth =
239 std::map<int, const simb::MCTruth*> trackIDToTruthMap;
240 for (
size_t p_iter = 0; p_iter < mcParticleVector.size(); p_iter++)
241 trackIDToTruthMap[mcParticleVector[p_iter].TrackId()] = particle_to_truth[p_iter];
243 FillMCInfo(evt, hitVector, hitOrigins, mchitcolVector, trackIDToTruthMap);
247 std::vector<recob::Track>
const& trackVector(*trackListHandle);
251 std::vector<recob::Cluster>
const& clusterVector(*clusterListHandle);
255 std::vector<std::vector<size_t>> track_indices_per_hit =
260 std::vector<std::vector<size_t>> cluster_indices_per_hit =
263 std::vector<art::Handle<std::vector<anab::CosmicTag>>> cosmicTagHandlesVector(
265 std::vector<art::Handle<art::Assns<recob::Track, anab::CosmicTag>>> assnTrackTagHandlesVector(
267 std::vector<std::vector<const anab::CosmicTag*>> tags_per_track(
269 std::vector<art::Handle<art::Assns<recob::Cluster, anab::CosmicTag>>> assnClusterTagHandlesVector(
271 std::vector<std::vector<const anab::CosmicTag*>> tags_per_cluster(
283 for (
auto const& pair : *assnTrackTagHandlesVector[label_i])
284 tags_per_track.at(pair.first.key())[label_i] = &(*(pair.second));
290 for (
auto const& pair : *assnClusterTagHandlesVector[label_i])
291 tags_per_cluster.at(pair.first.key())[label_i] = &(*(pair.second));
297 std::vector<std::vector<bool>> hitsAccounted(
299 std::vector<bool> hitsAllTags(hitVector.size(),
false);
301 for (
size_t hit_iter = 0; hit_iter < hitVector.size(); hit_iter++) {
303 float charge = hitVector[hit_iter].Integral();
306 if (track_indices_per_hit[hit_iter].
size() != 0)
310 track_indices_per_hit[hit_iter],
312 hitsAccounted[hit_iter],
315 if (cluster_indices_per_hit[hit_iter].
size() != 0)
319 cluster_indices_per_hit[hit_iter],
321 hitsAccounted[hit_iter],
324 if (hitsAllTags[hit_iter])
FillAllTagsInfo(hitVector[hit_iter], origin);
379 std::vector<recob::Hit>
const& hitlist,
380 std::vector<hit_origin_t>& hitOrigins,
381 std::vector<sim::MCHitCollection>
const& mchitCollectionVector,
382 std::map<int, const simb::MCTruth*>
const& trackIdToTruthMap)
386 for (
size_t itr = 0; itr < hitlist.size(); itr++) {
390 std::vector<int> trackIDs;
391 std::vector<double>
energy;
393 for (
auto const& mchit : mchitCollectionVector[this_hit.
Channel()]) {
394 if (
std::abs(clock_data.TPCTDC2Tick(mchit.PeakTime()) - this_hit.
PeakTime()) <
396 trackIDs.push_back(mchit.PartTrackId());
397 energy.push_back(mchit.PartEnergy());
401 if (trackIDs.size() == 0) {
408 float cosmic_energy = 0;
409 float non_cosmic_energy = 0;
411 for (
size_t iter = 0; iter < trackIDs.size(); iter++) {
412 auto map_element = trackIdToTruthMap.find(
std::abs(trackIDs[iter]));
413 if (map_element == trackIdToTruthMap.end())
continue;
414 int origin = map_element->second->Origin();
416 non_cosmic_energy += energy[iter];
418 cosmic_energy += energy[iter];
421 if (non_cosmic_energy > cosmic_energy) {
437 size_t const& hit_iter,
440 std::vector<size_t>
const& track_indices_this_hit,
441 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_track,
442 std::vector<bool>& hitsAccounted_per_tag,
443 std::vector<bool>& hitsAllTags)
447 cEventVals.
qTrack += charge;
460 if (hitsAccounted_per_tag[nCT])
continue;
462 for (
auto const& track_index : track_indices_this_hit) {
463 if (!tags_per_track[track_index][nCT])
continue;
467 hitsAccounted_per_tag[nCT] =
true;
468 hitsAllTags[hit_iter] =
true;
485 size_t const& hit_iter,
488 std::vector<size_t>
const& cluster_indices_this_hit,
489 std::vector<std::vector<const anab::CosmicTag*>>
const& tags_per_cluster,
490 std::vector<bool>& hitsAccounted_per_tag,
491 std::vector<bool>& hitsAllTags)
508 if (hitsAccounted_per_tag[nCT])
continue;
510 for (
auto const& cluster_index : cluster_indices_this_hit) {
511 if (!tags_per_cluster[cluster_index][nCT])
continue;
512 const anab::CosmicTag* currentTag(tags_per_cluster[cluster_index][nCT]);
515 hitsAccounted_per_tag[nCT] =
true;
516 hitsAllTags[hit_iter] =
true;
void analyze(const art::Event &evt)
read access to event
CosmicRemovalAna(fhicl::ParameterSet const &pset)
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)
Declaration of signal hit object.
cEventProperties_t cEventVals
constexpr auto abs(T v)
Returns the absolute value of the argument.
float TotalTaggedCharge_NonCosmic
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
std::vector< const U * > GetAssociatedVectorOneP(art::Handle< art::Assns< T, U >> h, art::Handle< std::vector< T >> index_p)
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.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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
Provides recob::Track data product.
EventNumber_t event() const
Declaration of cluster object.
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.
std::string fMCModuleLabel
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
float TotalTaggedCharge_Cosmic
std::vector< float > cTaggedCharge_Cosmic
2D representation of charge deposited in the TDC/wire plane
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U >> h, art::Handle< std::vector< T >> index_p)
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