Public Member Functions | Private Member Functions | Private Attributes | List of all members
cluster::LineCluster Class Reference

Produces clusters by ClusterCrawler algorithm. More...

Inheritance diagram for cluster::LineCluster:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 LineCluster (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &evt) override
 

Private Attributes

ClusterCrawlerAlg fCCAlg
 
art::InputTag fHitFinderLabel
 label of module producing input hits More...
 
bool fDoWireAssns
 
bool fDoRawDigitAssns
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Produces clusters by ClusterCrawler algorithm.

Configuration parameters

Definition at line 37 of file LineCluster_module.cc.

Constructor & Destructor Documentation

cluster::LineCluster::LineCluster ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 80 of file LineCluster_module.cc.

81  : EDProducer{pset}, fCCAlg{pset.get<fhicl::ParameterSet>("ClusterCrawlerAlg")}
82  {
83  fHitFinderLabel = pset.get<art::InputTag>("HitFinderModuleLabel");
84  fDoWireAssns = pset.get<bool>("DoWireAssns", true);
85  fDoRawDigitAssns = pset.get<bool>("DoRawDigitAssns", false);
86 
87  // let HitCollectionAssociator declare that we are going to produce
88  // hits and associations with wires and raw digits
89  // (with no particular product label)
91  producesCollector(), "", fDoWireAssns, fDoRawDigitAssns);
92 
93  produces<std::vector<recob::Cluster>>();
94  produces<std::vector<recob::Vertex>>();
95  produces<std::vector<recob::EndPoint2D>>();
96  produces<art::Assns<recob::Cluster, recob::Hit>>();
97  produces<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
98  produces<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>>();
99  } // LineCluster::LineCluster()
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.cxx:248
art::InputTag fHitFinderLabel
label of module producing input hits
ClusterCrawlerAlg fCCAlg
ProducesCollector & producesCollector() noexcept

Member Function Documentation

void cluster::LineCluster::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 103 of file LineCluster_module.cc.

104  {
105  // fetch the wires needed by CCHitFinder
106 
107  // make this accessible to ClusterCrawler_module
108  auto hitVecHandle = evt.getValidHandle<std::vector<recob::Hit>>(fHitFinderLabel);
109 
110  // look for clusters in all planes
111  auto const clock_data =
113  auto const det_prop =
115  fCCAlg.RunCrawler(clock_data, det_prop, *hitVecHandle);
116 
117  auto FinalHits = std::make_unique<std::vector<recob::Hit>>(std::move(fCCAlg.YieldHits()));
118 
119  // shcol contains the hit collection
120  // and its associations to wires and raw digits;
121  // we get the association to raw digits through wire associations
123  std::vector<recob::Cluster> sccol;
124  std::vector<recob::Vertex> sv3col;
125  std::vector<recob::EndPoint2D> sv2col;
126 
127  std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> hc_assn(
129  std::unique_ptr<art::Assns<recob::Cluster, recob::Vertex, unsigned short>> cv_assn(
131  std::unique_ptr<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>> cep_assn(
133 
134  std::vector<ClusterCrawlerAlg::ClusterStore> const& Clusters = fCCAlg.GetClusters();
135 
136  // Consistency check
137  /*
138  std::vector<short> const& inClus = fCCAlg.GetinClus();
139  for(unsigned int icl = 0; icl < Clusters.size(); ++icl) {
140  ClusterCrawlerAlg::ClusterStore const& clstr = Clusters[icl];
141  if(clstr.ID < 0) continue;
142  geo::PlaneID planeID = ClusterCrawlerAlg::DecodeCTP(clstr.CTP);
143  unsigned short plane = planeID.Plane;
144  for(unsigned short ii = 0; ii < clstr.tclhits.size(); ++ii) {
145  unsigned int iht = clstr.tclhits[ii];
146  recob::Hit const& theHit = FinalHits->at(iht);
147  if(theHit.WireID().Plane != plane) {
148  mf::LogError("LineCluster")<<"Cluster-hit plane mis-match "<<theHit.WireID().Plane<<" "<<plane
149  <<" in cluster "<<clstr.ID<<" WT "<<clstr.BeginWir<<":"<<(int)clstr.BeginTim<<" cluster CTP "<<clstr.CTP;
150  return;
151  }
152  if(inClus[iht] != clstr.ID) {
153  mf::LogError("LineCluster") << "InClus mis-match " << inClus[iht]
154  << " ID " << clstr.ID << " in cluster ID " << clstr.ID<<" cluster ProcCode "<<clstr.ProcCode;;
155  return;
156  }
157  } // ii
158  } // icl
159 */
160  // make EndPoints (aka 2D vertices)
161  std::vector<ClusterCrawlerAlg::VtxStore> const& EndPts = fCCAlg.GetEndPoints();
162  std::vector<unsigned int> indxToIndx(EndPts.size());
164  unsigned short vtxID = 0, end, wire, ivx;
165  for (ivx = 0; ivx < EndPts.size(); ++ivx) {
166  if (EndPts[ivx].NClusters == 0) continue;
167  indxToIndx[ivx] = vtxID;
168  ++vtxID;
169  // std::cout<<"EndPt "<<ivx<<" vtxID "<<vtxID<<"\n";
170  wire = (0.5 + EndPts[ivx].Wire);
171  geo::PlaneID plID = ClusterCrawlerAlg::DecodeCTP(EndPts[ivx].CTP);
172  geo::WireID wID = geo::WireID(plID.Cryostat, plID.TPC, plID.Plane, wire);
173  geo::View_t view = geom->View(wID);
174  sv2col.emplace_back((double)EndPts[ivx].Time, // Time
175  wID, // WireID
176  0, // strength - not relevant
177  vtxID, // ID
178  view, // View
179  0); // total charge - not relevant
180  } // iv
181  // convert 2D Vertex vector to unique_ptrs
182  std::unique_ptr<std::vector<recob::EndPoint2D>> v2col(
183  new std::vector<recob::EndPoint2D>(std::move(sv2col)));
184 
185  // make 3D vertices
186  std::vector<ClusterCrawlerAlg::Vtx3Store> const& Vertices = fCCAlg.GetVertices();
187  double xyz[3] = {0, 0, 0};
188  vtxID = 0;
189  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
190  // ignore incomplete vertices
191  if (vtx3.Ptr2D[0] < 0) continue;
192  if (vtx3.Ptr2D[1] < 0) continue;
193  if (vtx3.Ptr2D[2] < 0) continue;
194  ++vtxID;
195  xyz[0] = vtx3.X;
196  xyz[1] = vtx3.Y;
197  xyz[2] = vtx3.Z;
198  sv3col.emplace_back(xyz, vtxID);
199  } // 3D vertices
200  // convert Vertex vector to unique_ptrs
201  std::unique_ptr<std::vector<recob::Vertex>> v3col(
202  new std::vector<recob::Vertex>(std::move(sv3col)));
203 
204  // make the clusters and associations
205  float sumChg, sumADC;
206  unsigned int clsID = 0, nclhits;
207  for (unsigned int icl = 0; icl < Clusters.size(); ++icl) {
208  ClusterCrawlerAlg::ClusterStore const& clstr = Clusters[icl];
209  if (clstr.ID < 0) continue;
210  ++clsID;
211  sumChg = 0;
212  sumADC = 0;
213  geo::PlaneID planeID = ClusterCrawlerAlg::DecodeCTP(clstr.CTP);
214  unsigned short plane = planeID.Plane;
215  nclhits = clstr.tclhits.size();
216  std::vector<unsigned int> clsHitIndices;
217  // correct the hit indices to refer to the valid hits that were just added
218  for (unsigned int itt = 0; itt < nclhits; ++itt) {
219  unsigned int iht = clstr.tclhits[itt];
220  recob::Hit const& hit = FinalHits->at(iht);
221  sumChg += hit.Integral();
222  sumADC += hit.SummedADC();
223  } // itt
224  // get the wire, plane from a hit
225  unsigned int iht = clstr.tclhits[0];
226 
227  geo::View_t view = FinalHits->at(iht).View();
228  sccol.emplace_back((float)clstr.BeginWir, // Start wire
229  0, // sigma start wire
230  clstr.BeginTim, // start tick
231  0, // sigma start tick
232  clstr.BeginChg, // start charge
233  clstr.BeginAng, // start angle
234  0, // start opening angle (0 for line-like clusters)
235  (float)clstr.EndWir, // end wire
236  0, // sigma end wire
237  clstr.EndTim, // end tick
238  0, // sigma end tick
239  clstr.EndChg, // end charge
240  clstr.EndAng, // end angle
241  0, // end opening angle (0 for line-like clusters)
242  sumChg, // integral
243  0, // sigma integral
244  sumADC, // summed ADC
245  0, // sigma summed ADC
246  nclhits, // n hits
247  0, // wires over hits
248  0, // width (0 for line-like clusters)
249  clsID, // ID
250  view, // view
251  planeID, // plane
252  recob::Cluster::Sentry // sentry
253  );
254  // make the cluster - hit association
255  if (!util::CreateAssn(
256  *this, evt, *hc_assn, sccol.size() - 1, clstr.tclhits.begin(), clstr.tclhits.end())) {
258  << "Failed to associate hit " << iht << " with cluster " << icl;
259  } // exception
260  // make the cluster - EndPoint2D and Vertex associations
261  if (clstr.BeginVtx >= 0) {
262  end = 0;
263  // std::cout<<clstr.ID<<" clsID "<<clsID<<" Begin vtx "<<clstr.BeginVtx<<" vtxID "<<indxToIndx[clstr.BeginVtx]<<"\n";
264  if (!util::CreateAssnD(*this, evt, *cep_assn, clsID - 1, indxToIndx[clstr.BeginVtx], end)) {
266  << "Failed to associate cluster " << clsID << " with EndPoint2D " << clstr.BeginVtx;
267  } // exception
268  // See if this endpoint is associated with a 3D vertex
269  unsigned short vtxIndex = 0;
270  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
271  // ignore incomplete vertices
272  if (vtx3.Ptr2D[0] < 0) continue;
273  if (vtx3.Ptr2D[1] < 0) continue;
274  if (vtx3.Ptr2D[2] < 0) continue;
275  if (vtx3.Ptr2D[plane] == clstr.BeginVtx) {
276  if (!util::CreateAssnD(*this, evt, *cv_assn, clsID - 1, vtxIndex, end)) {
278  << "Failed to associate cluster " << icl << " with vertex";
279  } // exception
280  break;
281  } // vertex match
282  ++vtxIndex;
283  } // 3D vertices
284  } // clstr.BeginVtx >= 0
285  if (clstr.EndVtx >= 0) {
286  end = 1;
287  // std::cout<<clstr.ID<<" clsID "<<clsID<<" End vtx "<<clstr.EndVtx<<" vtxID "<<indxToIndx[clstr.EndVtx]<<"\n";
288  if (!util::CreateAssnD(*this, evt, *cep_assn, clsID - 1, indxToIndx[clstr.EndVtx], end)) {
290  << "Failed to associate cluster " << clsID << " with EndPoint2D " << clstr.BeginVtx;
291  } // exception
292  // See if this endpoint is associated with a 3D vertex
293  unsigned short vtxIndex = 0;
294  for (ClusterCrawlerAlg::Vtx3Store const& vtx3 : Vertices) {
295  // ignore incomplete vertices
296  if (vtx3.Ptr2D[0] < 0) continue;
297  if (vtx3.Ptr2D[1] < 0) continue;
298  if (vtx3.Ptr2D[2] < 0) continue;
299  if (vtx3.Ptr2D[plane] == clstr.EndVtx) {
300  if (!util::CreateAssnD(*this, evt, *cv_assn, clsID - 1, vtxIndex, end)) {
302  << "Failed to associate cluster " << icl << " with endpoint";
303  } // exception
304  break;
305  } // vertex match
306  ++vtxIndex;
307  } // 3D vertices
308  } // clstr.BeginVtx >= 0
309  } // icl
310 
311  // convert cluster vector to unique_ptrs
312  std::unique_ptr<std::vector<recob::Cluster>> ccol(
313  new std::vector<recob::Cluster>(std::move(sccol)));
314 
315  shcol.use_hits(std::move(FinalHits));
316 
317  // clean up
319 
320  // move the hit collection and the associations into the event:
321  shcol.put_into(evt);
322  evt.put(std::move(ccol));
323  evt.put(std::move(hc_assn));
324  evt.put(std::move(v2col));
325  evt.put(std::move(v3col));
326  evt.put(std::move(cv_assn));
327  evt.put(std::move(cep_assn));
328 
329  } // LineCluster::produce()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< ClusterStore > const & GetClusters() const
Returns a constant reference to the clusters found.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
static geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
std::vector< VtxStore > const & GetEndPoints() const
Returns a constant reference to the 2D end points found.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
bool CreateAssnD(PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
Creates a single one-to-one association with associated data.
def move(depos, offset)
Definition: depos.py:107
art::InputTag fHitFinderLabel
label of module producing input hits
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
A class handling a collection of hits and its associations.
Definition: HitCreator.h:842
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
ClusterCrawlerAlg fCCAlg
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< Vtx3Store > const & GetVertices() const
Returns a constant reference to the 3D vertices found.
void RunCrawler(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, std::vector< recob::Hit > const &srchits)
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406

Member Data Documentation

ClusterCrawlerAlg cluster::LineCluster::fCCAlg
private

Definition at line 45 of file LineCluster_module.cc.

bool cluster::LineCluster::fDoRawDigitAssns
private

Definition at line 50 of file LineCluster_module.cc.

bool cluster::LineCluster::fDoWireAssns
private

Definition at line 49 of file LineCluster_module.cc.

art::InputTag cluster::LineCluster::fHitFinderLabel
private

label of module producing input hits

Definition at line 47 of file LineCluster_module.cc.


The documentation for this class was generated from the following file: