17 #include "art/Framework/Core/EDProducer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "art/Framework/Principal/Handle.h"
21 #include "fhiclcpp/ParameterSet.h"
50 void produce(art::Event &
e)
override;
69 fAlg(
p.get<fhicl::ParameterSet>(
"BeamFlashTrackMatchAlgParams")),
70 fTrackModuleLabel(
p.get<std::string>(
"TrackModuleLabel")),
71 fFlashModuleLabel(
p.get<std::string>(
"FlashModuleLabel")),
72 fHitTagAssnsAlg(
p.get<fhicl::ParameterSet>(
"HitTagAssociatorAlgParams")),
73 fMakeHitTagAssns(
p.get<
bool>(
"MakeHitTagAssns",
false)),
74 fHitModuleLabel(
p.get<std::string>(
"HitModuleLabel",
"dummy_hit"))
76 produces< std::vector<anab::CosmicTag> >();
77 produces< art::Assns<recob::Track, anab::CosmicTag> >();
78 if(fMakeHitTagAssns) produces< art::Assns<recob::Hit, anab::CosmicTag> >();
89 art::ServiceHandle<phot::PhotonVisibilityService const> pvsHandle;
91 art::ServiceHandle<opdet::OpDigiProperties const> opdigipHandle;
95 art::Handle< std::vector<recob::OpFlash> > flashHandle;
96 evt.getByLabel(fFlashModuleLabel, flashHandle);
97 std::vector<recob::OpFlash>
const& flashVector(*flashHandle);
100 art::Handle< std::vector<recob::Track> > trackHandle;
101 evt.getByLabel(fTrackModuleLabel, trackHandle);
102 std::vector<recob::Track>
const& trackVector(*trackHandle);
105 std::unique_ptr< std::vector<anab::CosmicTag> > cosmicTagPtr (
new std::vector<anab::CosmicTag>);
106 std::vector<anab::CosmicTag> & cosmicTagVector(*cosmicTagPtr);
110 std::vector<size_t> assnTrackTagVector;
111 std::unique_ptr< art::Assns<recob::Track,anab::CosmicTag> > assnTrackTag(
new art::Assns<recob::Track,anab::CosmicTag>);
114 fAlg.RunCompatibilityCheck(flashVector, trackVector,
115 cosmicTagVector, assnTrackTagVector,
116 providers, pvs, opdigip);
120 for(
size_t track_iter=0; track_iter<assnTrackTagVector.size(); track_iter++){
121 if(assnTrackTagVector[track_iter]==std::numeric_limits<size_t>::max())
continue;
122 art::Ptr<recob::Track> trk_ptr(trackHandle,track_iter);
123 util::CreateAssn(*
this, evt, cosmicTagVector, trk_ptr, *assnTrackTag, assnTrackTagVector[track_iter]);
127 if(fMakeHitTagAssns){
130 art::Handle< std::vector<recob::Hit> > hitHandle;
131 evt.getByLabel(fHitModuleLabel, hitHandle);
134 art::Handle< art::Assns<recob::Hit,recob::Track> > assnHitTrackHandle;
135 evt.getByLabel(fTrackModuleLabel,assnHitTrackHandle);
136 std::vector< std::vector<size_t> >
140 std::vector< std::vector<size_t> > assnHitTagVector;
141 std::unique_ptr< art::Assns<recob::Hit,anab::CosmicTag> > assnHitTag(
new art::Assns<recob::Hit,anab::CosmicTag>);
143 fHitTagAssnsAlg.MakeHitTagAssociations(track_indices_per_hit,
148 for(
size_t hit_iter=0; hit_iter<assnHitTagVector.size(); hit_iter++){
149 art::Ptr<recob::Hit> hit_ptr(hitHandle,hit_iter);
150 for(
size_t tag_iter=0; tag_iter<assnHitTagVector[hit_iter].size(); tag_iter++)
151 util::CreateAssn(*
this, evt, cosmicTagVector, hit_ptr, *assnHitTag, assnHitTagVector[hit_iter][tag_iter]);
154 evt.put( std::move(assnHitTag));
158 evt.put(std::move(cosmicTagPtr));
159 evt.put(std::move(assnTrackTag));
Utilities to manage ProviderPack objects with art.
ProviderPackFromServices< Services...> extractProviders()
Returns a provider pack with providers from specified services.
Declaration of signal hit object.
BeamFlashTrackMatchTaggerAlg fAlg
HitTagAssociatorAlg fHitTagAssnsAlg
The geometry of one entire detector, as served by art.
BeamFlashTrackMatchTagger(fhicl::ParameterSet const &p)
BeamFlashTrackMatchTagger & operator=(BeamFlashTrackMatchTagger const &)=delete
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
void produce(art::Event &e) override
std::string fTrackModuleLabel
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
std::string fHitModuleLabel
std::string fFlashModuleLabel
art framework interface to geometry description