8 #include "art/Framework/Core/EDProducer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Principal/Handle.h"
12 #include "art_root_io/TFileService.h"
13 #include "fhiclcpp/ParameterSet.h"
22 class TrackContainmentTagger;
38 void produce(art::Event &
e)
override;
53 art::ServiceHandle<art::TFileService const>
tfs;
54 fAlg.SetupOutputTree(tfs->make<TTree>(
"myanatree",
"MyAnalysis Tree"));
56 fAlg.Configure(
p.get<fhicl::ParameterSet>(
"TrackContainmentAlg"));
57 fTrackModuleLabels =
p.get< std::vector<std::string> >(
"TrackModuleLabels");
58 fApplyTags =
p.get< std::vector<bool> >(
"ApplyTags",std::vector<bool>(fTrackModuleLabels.size(),
true));
60 if(fApplyTags.size()!=fTrackModuleLabels.size())
61 throw cet::exception(
"TrackContainmentTagger::TrackContainmentTagger")
62 <<
"ApplyTags not same size as TrackModuleLabels. ABORT!!!";
64 fAlg.setMakeCosmicTags();
66 produces< std::vector<anab::CosmicTag> >();
67 produces< art::Assns<recob::Track, anab::CosmicTag> >();
73 std::unique_ptr< std::vector< anab::CosmicTag > > cosmicTagTrackVector(
new std::vector<anab::CosmicTag> );
74 std::unique_ptr< art::Assns<recob::Track, anab::CosmicTag > > assnOutCosmicTagTrack(
new art::Assns<recob::Track, anab::CosmicTag>);
76 fAlg.SetRunEvent(e.run(),e.event());
78 std::vector< std::vector<recob::Track> > trackVectors;
79 std::vector< art::Handle< std::vector<recob::Track> > > trackHandles;
80 for(
size_t i_l=0; i_l<fTrackModuleLabels.size(); ++i_l){
81 art::Handle< std::vector<recob::Track> > trackHandle;
82 e.getByLabel(fTrackModuleLabels[i_l],trackHandle);
83 trackVectors.push_back(*trackHandle);
84 trackHandles.push_back(trackHandle);
87 art::ServiceHandle<geo::Geometry const> geoHandle;
88 fAlg.ProcessTracks(trackVectors,*geoHandle);
90 auto const& cosmicTags = fAlg.GetTrackCosmicTags();
92 for(
size_t i_tc=0; i_tc<cosmicTags.size(); ++i_tc){
93 if(!fApplyTags[i_tc])
continue;
94 for(
size_t i_t=0; i_t<fAlg.GetTrackCosmicTags()[i_tc].size(); ++i_t){
95 cosmicTagTrackVector->emplace_back(fAlg.GetTrackCosmicTags()[i_tc][i_t]);
96 util::CreateAssn(*
this, e, *cosmicTagTrackVector, art::Ptr<recob::Track>(trackHandles[i_tc],i_t), *assnOutCosmicTagTrack );
100 e.put(std::move(cosmicTagTrackVector));
101 e.put(std::move(assnOutCosmicTagTrack));
std::vector< std::string > fTrackModuleLabels
void produce(art::Event &e) override
std::vector< bool > fApplyTags
TrackContainmentTagger(fhicl::ParameterSet const &p)
TrackContainmentTagger & operator=(TrackContainmentTagger 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.
trk::TrackContainmentAlg fAlg
art::ServiceHandle< art::TFileService > tfs
art framework interface to geometry description