10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Services/Registry/ServiceHandle.h"
15 #include "art_root_io/TFileService.h"
16 #include "canvas/Persistency/Common/Ptr.h"
17 #include "canvas/Persistency/Common/PtrVector.h"
18 #include "fhiclcpp/ParameterSet.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
45 explicit DBcluster(fhicl::ParameterSet
const& pset);
66 : EDProducer{pset}, fDBScan(pset.get<fhicl::ParameterSet>(
"DBScanAlg"))
68 fhitsModuleLabel = pset.get<std::string>(
"HitsModuleLabel");
70 produces<std::vector<recob::Cluster>>();
71 produces<art::Assns<recob::Cluster, recob::Hit>>();
79 art::ServiceHandle<art::TFileService const>
tfs;
81 fhitwidth = tfs->make<TH1F>(
" fhitwidth",
"width of hits in cm", 50000, 0, 5);
82 fhitwidth_ind_test = tfs->make<TH1F>(
"fhitwidth_ind_test",
"width of hits in cm", 50000, 0, 5);
84 tfs->make<TH1F>(
"fhitwidth_coll_test",
"width of hits in cm", 50000, 0, 5);
93 std::unique_ptr<std::vector<recob::Cluster>> ccol(
new std::vector<recob::Cluster>);
94 std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> assn(
95 new art::Assns<recob::Cluster, recob::Hit>);
102 art::ServiceHandle<geo::Geometry const> geom;
104 art::Handle<std::vector<recob::Hit>> hitcol;
108 std::vector<art::Ptr<recob::Hit>> allhits;
112 art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
117 std::map<geo::PlaneID, std::vector<art::Ptr<recob::Hit>>> planeIDToHits;
118 for (
size_t i = 0; i < hitcol->size(); ++i)
119 planeIDToHits[hitcol->at(i).WireID().planeID()].push_back(art::Ptr<recob::Hit>(hitcol, i));
121 auto const clock_data =
122 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
123 auto const det_prop =
124 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
126 for (
auto& itr : planeIDToHits) {
129 allhits.resize(itr.second.size());
130 allhits.swap(itr.second);
135 for (
unsigned int j = 0; j <
fDBScan.
fps.size(); ++j) {
137 if (allhits.size() !=
fDBScan.
fps.size())
break;
149 art::PtrVector<recob::Hit> clusterHits;
154 clusterHits.push_back(allhits[j]);
155 totalQ += clusterHits.back()->Integral();
159 if (clusterHits.empty())
continue;
163 unsigned int sw = wireID.
Wire;
164 unsigned int ew = clusterHits.back()->WireID().Wire;
167 ClusterParamAlgo.
ImportHits(gser, clusterHits);
174 clusterHits.front()->PeakTime(),
175 clusterHits.front()->SigmaPeakTime(),
178 clusterHits.back()->PeakTime(),
179 clusterHits.back()->SigmaPeakTime(),
181 clusterHits.front()->View(),
186 ccol->emplace_back(
cluster.move());
196 mf::LogVerbatim(
"Summary") << std::setfill(
'-') << std::setw(175) <<
"-" << std::setfill(
' ');
197 mf::LogVerbatim(
"Summary") <<
"DBcluster Summary:";
198 for (
unsigned int i = 0; i < ccol->size(); ++i)
199 mf::LogVerbatim(
"Summary") << ccol->at(i);
201 evt.put(std::move(ccol));
202 evt.put(std::move(assn));
211 DEFINE_ART_MODULE(DBcluster)
Class managing the creation of a new recob::Cluster object.
std::set< raw::ChannelID_t > ChannelSet_t
Type of set of channel IDs.
Declaration of signal hit object.
WireID_t Wire
Index of the wire within its plane.
std::vector< std::vector< double > > fps
the collection of points we are working on
virtual ChannelSet_t BadChannels() const =0
Returns a copy of set of bad channel IDs for the current run.
static const SentryArgument_t Sentry
An instance of the sentry object.
DBScanAlg fDBScan
object that implements the DB scan algorithm
void ImportHits(util::GeometryUtilities const &gser, Iter begin, Iter end)
Calls SetHits() with the hits in the sequence.
std::vector< unsigned int > fpointId_to_clusterId
mapping point_id -> clusterId
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
Helper functions to create a cluster.
Wrapper for ClusterParamsAlgBase objects to accept diverse input.
Wrapper for ClusterParamsAlgBase objects to accept arbitrary input.
Class providing information about the quality of channels.
Declaration of cluster object.
TH1F * fhitwidth_ind_test
TH1F * fhitwidth_coll_test
std::string fhitsModuleLabel
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 InitScan(const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &allhits, std::set< uint32_t > badChannels, const std::vector< geo::WireID > &wireids=std::vector< geo::WireID >())
void produce(art::Event &evt)
std::vector< std::vector< unsigned int > > fclusters
collection of something
Interface for experiment-specific channel quality info provider.
constexpr WireID()=default
Default constructor: an invalid TPC ID.
DBcluster(fhicl::ParameterSet const &pset)
art::ServiceHandle< art::TFileService > tfs
constexpr PlaneID const & planeID() const
Interface to class computing cluster parameters.
Interface for experiment-specific service for channel quality info.
art framework interface to geometry description
Signal from collection planes.