Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
sn::SNSlicer Class Reference
Inheritance diagram for sn::SNSlicer:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 SNSlicer (fhicl::ParameterSet const &p)
 
 SNSlicer (SNSlicer const &)=delete
 
 SNSlicer (SNSlicer &&)=delete
 
SNSliceroperator= (SNSlicer const &)=delete
 
SNSliceroperator= (SNSlicer &&)=delete
 
rb::Cluster FinalizeCluster (rb::Cluster cluster)
 
bool ClusterIsGood (rb::Cluster *cluster)
 
void produce (art::Event &e) override
 
std::string workerType () const
 
void doBeginJob ()
 
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)
 
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< TconsumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< TmayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (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< TmayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeom
 
std::string fCellHitInput
 
unsigned int fADCThreshold
 CellHit product label. More...
 
unsigned int fPromptTimeThreshold
 ADC threshold. More...
 
unsigned int fDelayedTimeThreshold
 Min time separation. More...
 
unsigned int fCellThreshold
 Min time separation. More...
 
unsigned int fPlaneThreshold
 Min cell separation. More...
 
unsigned int fMinNumberHits
 Min plane separation. More...
 
unsigned int fMaxNumberHits
 Min number of hits for cluster to be acceptable. More...
 
bool fGroupPromptClusters
 Max number of hits for cluster to be acceptable. More...
 

Detailed Description

Definition at line 39 of file SNSlicer_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 25 of file Producer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 18 of file EDProducer.h.

Constructor & Destructor Documentation

sn::SNSlicer::SNSlicer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 70 of file SNSlicer_module.cc.

70  :
71  EDProducer(p),
72  fCellHitInput(p.get<std::string>("CellHitInput")),
73  fADCThreshold(p.get<int>("ADCThreshold")),
74  fPromptTimeThreshold(p.get<int>("PromptTimeSeparationThreshold")),
75  fDelayedTimeThreshold(p.get<int>("DelayedTimeSeparationThreshold")),
76  fCellThreshold(p.get<int>("CellSeparationThreshold")),
77  fPlaneThreshold(p.get<int>("PlaneSeparationThreshold")),
78  fMinNumberHits(p.get<unsigned int>("MinNumberHits")),
79  fMaxNumberHits(p.get<unsigned int>("MaxNumberHits")),
80  fGroupPromptClusters(p.get<bool>("GroupPromptClusters"))
81 {
82  produces<std::vector<rb::Cluster>>();
83 }
unsigned int fMaxNumberHits
Min number of hits for cluster to be acceptable.
unsigned int fDelayedTimeThreshold
Min time separation.
const char * p
Definition: xmltok.h:285
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fCellHitInput
unsigned int fMinNumberHits
Min plane separation.
unsigned int fPlaneThreshold
Min cell separation.
unsigned int fADCThreshold
CellHit product label.
unsigned int fCellThreshold
Min time separation.
bool fGroupPromptClusters
Max number of hits for cluster to be acceptable.
unsigned int fPromptTimeThreshold
ADC threshold.
enum BeamMode string
sn::SNSlicer::SNSlicer ( SNSlicer const &  )
delete
sn::SNSlicer::SNSlicer ( SNSlicer &&  )
delete

Member Function Documentation

bool sn::SNSlicer::ClusterIsGood ( rb::Cluster cluster)

Definition at line 85 of file SNSlicer_module.cc.

References rb::Cluster::ExtentCell(), rb::Cluster::ExtentPlane(), rb::Cluster::ExtentTNS(), fADCThreshold, fCellThreshold, fMaxNumberHits, fPlaneThreshold, fPromptTimeThreshold, geo::kX, geo::kY, rb::Cluster::NCell(), rb::Cluster::NXCell(), rb::Cluster::NYCell(), and rb::Cluster::TotalADC().

Referenced by produce().

86 {
87  bool kNumberHitsOutOfRange = (cluster->NCell() > fMaxNumberHits);
88  bool kMaxPlaneExtentExceeded = (cluster->ExtentPlane() > fPlaneThreshold);
89  bool kMaxXCellExtentExceeded = (cluster->NXCell()>0) ? (cluster->ExtentCell(geo::kX) > fCellThreshold) : false;
90  bool kMaxYCellExtentExceeded = (cluster->NYCell()>0) ? (cluster->ExtentCell(geo::kY) > fCellThreshold) : false;
91  bool kMaxTnsExtentExceeded = (cluster->ExtentTNS() > fPromptTimeThreshold);
92  bool kMaxTotalAdcExceeded = (cluster->TotalADC() > fADCThreshold);
93  // bool kClusterIs2D = (cluster->NXCell()==0 || cluster->NYCell()==0);
94 
95  bool kClusterIsBad = kNumberHitsOutOfRange || kMaxPlaneExtentExceeded ||
96  kMaxXCellExtentExceeded || kMaxYCellExtentExceeded ||
97  kMaxTnsExtentExceeded || kMaxTotalAdcExceeded;
98 
99  return (!kClusterIsBad);
100 }
unsigned int fMaxNumberHits
Min number of hits for cluster to be acceptable.
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
Vertical planes which measure X.
Definition: PlaneGeo.h:28
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
unsigned int ExtentCell(geo::View_t view) const
Definition: Cluster.cxx:570
double TotalADC() const
Sum of the ADC of all the contained hits.
Definition: Cluster.cxx:360
unsigned int fPlaneThreshold
Min cell separation.
unsigned int fADCThreshold
CellHit product label.
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
unsigned int ExtentPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.h:250
unsigned int fCellThreshold
Min time separation.
double ExtentTNS() const
Definition: Cluster.h:252
unsigned int fPromptTimeThreshold
ADC threshold.
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 55 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumes(), T, and getGoodRuns4SAM::tag.

56  {
57  return collector_.consumes<T, BT>(tag);
58  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ProductToken< T > consumes(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ConsumesCollector& art::ModuleBase::consumesCollector ( )
protectedinherited
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 69 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesMany(), and T.

70  {
71  collector_.consumesMany<T, BT>();
72  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 62 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesView(), T, and getGoodRuns4SAM::tag.

63  {
64  return collector_.consumesView<T, BT>(tag);
65  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > consumesView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
void art::detail::Producer::doBeginJob ( )
inherited
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
void art::detail::Producer::doEndJob ( )
inherited
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Producer::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 
)
inherited
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited
rb::Cluster sn::SNSlicer::FinalizeCluster ( rb::Cluster  cluster)

Definition at line 102 of file SNSlicer_module.cc.

References rb::Cluster::AllCells(), rb::Cluster::ID(), geo::kX, geo::kY, rb::Cluster::NXCell(), and rb::Cluster::NYCell().

Referenced by produce().

103 {
104  // Determine the view
105  unsigned int nCellX = cluster.NXCell();
106  unsigned int nCellY = cluster.NYCell();
107 
108  rb::Cluster cFinal;
109 
110  if (nCellX>0 && nCellY==0) {
111  cFinal = rb::Cluster(geo::kX, cluster.AllCells(), cluster.ID());
112  } else if (nCellX==0 && nCellY>0) {
113  cFinal = rb::Cluster(geo::kY, cluster.AllCells(), cluster.ID());
114  } else {
115  cFinal = rb::Cluster(cluster.AllCells(), cluster.ID());
116  }
117 
118  return cFinal;
119 }
Vertical planes which measure X.
Definition: PlaneGeo.h:28
A collection of associated CellHits.
Definition: Cluster.h:47
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
const int ID() const
Definition: Cluster.h:75
std::array<std::vector<ProductInfo>, NumBranchTypes> const& art::ModuleBase::getConsumables ( ) const
inherited
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 76 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsume(), T, and getGoodRuns4SAM::tag.

77  {
78  return collector_.mayConsume<T, BT>(tag);
79  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 90 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeMany(), and T.

91  {
93  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 83 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeView(), T, and getGoodRuns4SAM::tag.

84  {
85  return collector_.mayConsumeView<T, BT>(tag);
86  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > mayConsumeView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ModuleDescription const& art::ModuleBase::moduleDescription ( ) const
inherited
SNSlicer& sn::SNSlicer::operator= ( SNSlicer const &  )
delete
SNSlicer& sn::SNSlicer::operator= ( SNSlicer &&  )
delete
void sn::SNSlicer::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 122 of file SNSlicer_module.cc.

References std::abs(), rb::Cluster::Add(), ClusterIsGood(), om::cout, DEFINE_ART_MODULE(), febshutoff_auto::end, allTimeWatchdog::endl, fCellHitInput, fCellThreshold, fDelayedTimeThreshold, fGroupPromptClusters, FinalizeCluster(), fMinNumberHits, fPlaneThreshold, fPromptTimeThreshold, art::DataViewImpl::getByLabel(), hits(), MECModelEnuComparisons::i, compare_h5_caf::idx, calib::j, geo::kX, geo::kXorY, geo::kY, makeBrightnessMap::maxCell, makeBrightnessMap::maxPlane, rb::Cluster::NCell(), rb::Cluster::NXCell(), rb::Cluster::NYCell(), art::DataViewImpl::put(), rb::Cluster::RemoveHit(), rb::Cluster::SetID(), rb::SortByTime(), and string.

123 {
124  // Clusters will be stored here (already-used hits are tracked as well)
125  std::vector<rb::Cluster> promptClusters;
126  std::unique_ptr<std::vector<rb::Cluster>> clusters(new std::vector<rb::Cluster>);
127 
128  // Get the cell hits
130  e.getByLabel(fCellHitInput, hitsHandle);
131 
132  // Put the hits into a vector so we can alter them
133  std::vector<art::Ptr<rb::CellHit>> hits;
134  hits.reserve(hitsHandle->size());
135  for (unsigned int idx = 0; idx < hitsHandle->size(); ++idx){
136  art::Ptr<rb::CellHit> hit(hitsHandle, idx);
137  hits.push_back(hit);
138  }
139 
140  // Sort hits by time.
141  // NOTE: The rest of the code depends on this.
142  rb::SortByTime(hits);
143 
144  bool hitConsumed[hits.size() + 1] = { false };
145 
146  /* OUTER LOOP (HITS) */
147  size_t idxCluster = 0;
148  for (unsigned int i=0; i<hits.size(); ++i) {
149  if (hitConsumed[i]) continue;
150  ++idxCluster;
151 
152  // We add this hit to the cluster, but only if it has not yet been added
153  // to any other clusters.
154  rb::Cluster* aCluster = new rb::Cluster();
155  aCluster->SetID(idxCluster);
156 
157  if (!hitConsumed[i]) {
158  aCluster->Add(hits[i]);
159  hitConsumed[i] = true;
160  }
161  else {
162  continue;
163  }
164 
165  /*
166  The inner loop continues on until a hit fails a time condition, but we want
167  to come back to the hits we missed due to a failed plane or cell condition.
168  The "latch" variable is used to perform this book-keeping.
169 
170  At the first instance a plane or cell condition fails, the latch is set to
171  the index of that hit iff the latch is currently set to zero. The latch
172  therefore does not get re-assigned on subsequent plane or cell failures,
173  only the first.
174 
175  Once the time condition fails, the hit index i is set based on the latch
176  point if it is non-zero, otherwise it is set based on j.
177 
178  The latch get reset during each iteration of the outer loop.
179 
180  Here are some simple examples. Each box represents a hit that we are looping
181  over.
182  [*] = hit passed all conditions and is added to the cluster.
183  [x] = hit failed time condition and the inner loop will terminate here.
184  [ ] = hit failed plane or cell condition
185  [L] = latch point set here
186  ^ = carat indicates where the loop will start next time
187 
188  SCENARIO 1: Several hits pass all conditions, but some intermediate hits
189  fail cell or plane condition. Time condition fails at hit 6.
190  0 1 2 3 4 5 6
191  [*] [*] [L] [ ] [*] [*] [x]
192  ^ ---> latch point at hit 2. Next outer loop will start here.
193 
194  SCENARIO 2: All hits 0-5 pass all conditions. Hit 6 fails time condition.
195  No latch point is set, so the next iteration of the outer loop will start
196  at the failure point (Hit 6).
197  0 1 2 3 4 5 6
198  [*] [*] [*] [*] [*] [*] [x]
199  ^ ---> Next outer loop will start here.
200  */
201  unsigned int latch = 0;
202 
203  /* INNER LOOP (HITS) */
204  // std::cout << std::endl;
205  for (unsigned int j=i+1; j<hits.size(); ++j) {
206  // std::cout << "Checking hit (j) " << j+1 << "/" << hits.size();
207  bool kHitsFailTimeThreshold = hits[j]->TNS() - hits[i]->TNS() > fPromptTimeThreshold;
208  bool kHitsFailPlaneThreshold = std::abs(hits[j]->Plane() - hits[i]->Plane()) > fPlaneThreshold;
209  bool kHitsFailCellThreshold = std::abs(hits[j]->Cell() - hits[i]->Cell()) > fCellThreshold;
210  bool kHitsInSameView = hits[j]->View() == hits[i]->View();
211 
212  // This hit is too far away in time from the first, and all subsequent
213  // hits willalso be so. We terminate the inner loop and set the outer loop
214  // index depending on either the latch point or the current inner loop
215  // index.
216  if (kHitsFailTimeThreshold) {
217  // std::cout << " -- SEED FOR NEXT CLUSTER" << std::endl;
218  // std::cout << "--Break--" << std::endl;
219  i = (latch==0) ? j-1 : latch-1;
220  break;
221  }
222 
223  // This hit is too far away in Planes from the first. If the latch point
224  // has not yet been set, we set it here. We move to the next iteration
225  // of the inner loop.
226  if (kHitsFailPlaneThreshold) {
227  // std::cout << " -- FAIL PLANE CONDITION." << std::endl;
228  if (latch==0) latch = j;
229  continue;
230  }
231 
232  // This hit is too far away in Cells from the first. This can only happen
233  // if both hits are in the same view. If the latch point has not yet been
234  // set, we set it here. We move to the next iteration of the inner loop.
235  if (kHitsInSameView && kHitsFailCellThreshold) {
236  // std::cout << " -- FAIL CELL CONDITION." << std::endl;
237  if (latch==0) latch = j;
238  continue;
239  }
240 
241  // If we've made it this far, this hit belongs in a cluster, but only if
242  // it hasn't been added to any other clusters yet.
243  if (!hitConsumed[j]) {
244  aCluster->Add(hits[j]);
245  if (this->ClusterIsGood(aCluster)) {
246  hitConsumed[j] = true;
247  } else {
248  aCluster->RemoveHit(hits[j]);
249  }
250  // std::cout << " -- ADDED TO CLUSTER #" << idxCluster << std::endl;
251  }
252  }
253 
254  if (this->ClusterIsGood(aCluster) && aCluster->NXCell()>0 && aCluster->NYCell()>0 && aCluster->NCell() >= fMinNumberHits) {
255  rb::Cluster fCluster = this->FinalizeCluster(*aCluster);
256 
257  promptClusters.push_back(fCluster);
258  clusters->push_back(fCluster);
259  } else {
260  hitConsumed[i] = false;
261  aCluster->RemoveHit(hits[i]);
262  }
263  delete aCluster;
264  // std::cout << std::endl;
265  }
266 
267 
268  /* Connect disparate prompt clusters */
269  // NOTE: This section never worked completely and hasn't been touched in ages.
270  // do not use without testing it first.
271  if (fGroupPromptClusters) {
272  bool clusterConsumed[promptClusters.size() + 1] = { false };
273 
274  /* OUTER LOOP (CLUSTERS) */
275  idxCluster = 0;
276  for (size_t i=0; i<promptClusters.size(); ++i) {
277  ++idxCluster;
278  std::cout << "Checking cluster (i) " << i+1 << "/" << promptClusters.size();
279  rb::Cluster* aCluster = new rb::Cluster();
280 
281  if (!clusterConsumed[i]) {
282  aCluster->Add(promptClusters[i].AllCells());
283  clusterConsumed[i] = true;
284  std::cout << " -- ADDED TO CLUSTER #" << idxCluster;
285  }
286 
287  unsigned int latch = 0;
288 
289  /* INNER LOOP (CLUSTERS) */
290  std::cout << std::endl;
291  for (size_t j=i+1; j<promptClusters.size(); ++j) {
292  std::cout << "Checking cluster (j) " << j+1 << "/" << promptClusters.size();
293 
294  // Check time
295  bool kClustersFailTimeThreshold = promptClusters[j].MeanTNS() - promptClusters[i].MeanTNS() > fDelayedTimeThreshold;
296 
297  // Check planes
298  unsigned int clusterPlanes[] = {promptClusters[i].MinPlane(), promptClusters[i].MaxPlane(), promptClusters[j].MinPlane(), promptClusters[j].MaxPlane()};
299  unsigned int* minPlane = std::min_element(std::begin(clusterPlanes), std::end(clusterPlanes));
300  unsigned int* maxPlane = std::max_element(std::begin(clusterPlanes), std::end(clusterPlanes));
301  bool kClustersFailPlaneThreshold = (*maxPlane)-(*minPlane) > fPlaneThreshold;
302 
303  // Check Cells
304  unsigned int iClusterNX = promptClusters[i].NXCell();
305  unsigned int iClusterNY = promptClusters[i].NYCell();
306  unsigned int jClusterNX = promptClusters[j].NXCell();
307  unsigned int jClusterNY = promptClusters[j].NYCell();
308 
309  geo::View_t iClusterView;
310  geo::View_t jClusterView;
311 
312  if (iClusterNX>0 && iClusterNY==0) iClusterView = geo::kX;
313  else if (iClusterNY>0 && iClusterNX==0) iClusterView = geo::kY;
314  else iClusterView = geo::kXorY;
315 
316  if (jClusterNX>0 && jClusterNY==0) jClusterView = geo::kX;
317  else if (jClusterNY>0 && jClusterNX==0) jClusterView = geo::kY;
318  else jClusterView = geo::kXorY;
319 
320  bool kBothClustersSpanBothViews = ((iClusterView == geo::kXorY) && (jClusterView == geo::kXorY));
321  bool kOneClusterSpanBothViews = ((iClusterView != geo::kXorY) != (jClusterView != geo::kXorY));
322  bool kBothClustersSpanOneView = ((iClusterView != geo::kXorY) && (jClusterView != geo::kXorY));
323  bool kClustersFailCellThreshold = false;
324 
325  // Case 1: Both clusters span both views
326  if (kBothClustersSpanBothViews) {
327  // Check X-view
328  unsigned int clusterXCells[] = {promptClusters[i].MinCell(geo::kX), promptClusters[i].MaxCell(geo::kX), promptClusters[j].MinCell(geo::kX), promptClusters[j].MaxCell(geo::kX)};
329  unsigned int* minCell = std::min_element(std::begin(clusterXCells), std::end(clusterXCells));
330  unsigned int* maxCell = std::max_element(std::begin(clusterXCells), std::end(clusterXCells));
331  bool kClustersFailXCellThreshold = (*maxCell)-(*minCell) > fCellThreshold;
332  // Check Y-view
333  unsigned int clusterYCells[] = {promptClusters[i].MinCell(geo::kY), promptClusters[i].MaxCell(geo::kY), promptClusters[j].MinCell(geo::kY), promptClusters[j].MaxCell(geo::kY)};
334  minCell = std::min_element(std::begin(clusterYCells), std::end(clusterYCells));
335  maxCell = std::max_element(std::begin(clusterYCells), std::end(clusterYCells));
336  bool kClustersFailYCellThreshold = (*maxCell)-(*minCell) > fCellThreshold;
337  kClustersFailCellThreshold = kClustersFailXCellThreshold && kClustersFailYCellThreshold;
338  }
339  // Case 2: Only one cluster spans both views
340  else if (kOneClusterSpanBothViews) {
341  geo::View_t commonView = (iClusterView == geo::kXorY) ? jClusterView : iClusterView;
342  unsigned int clusterCells[] = {promptClusters[i].MinCell(commonView), promptClusters[i].MaxCell(commonView), promptClusters[j].MinCell(commonView), promptClusters[j].MaxCell(commonView)};
343  unsigned int* minCell = std::min_element(std::begin(clusterCells), std::end(clusterCells));
344  unsigned int* maxCell = std::max_element(std::begin(clusterCells), std::end(clusterCells));
345  kClustersFailCellThreshold = (*maxCell)-(*minCell) > fCellThreshold;
346  }
347  // Case 3: Both clusters only span one view
348  else if (kBothClustersSpanOneView) {
349  // Check their cell distance if they're in the same view
350  if (iClusterView == jClusterView) {
351  unsigned int clusterCells[] = {promptClusters[i].MinCell(iClusterView), promptClusters[i].MaxCell(iClusterView), promptClusters[j].MinCell(jClusterView), promptClusters[j].MaxCell(jClusterView)};
352  unsigned int* minCell = std::min_element(std::begin(clusterCells), std::end(clusterCells));
353  unsigned int* maxCell = std::max_element(std::begin(clusterCells), std::end(clusterCells));
354  kClustersFailCellThreshold = (*maxCell)-(*minCell) > fCellThreshold;
355  }
356  }
357  // Default: We should never get here.
358  else {
359  std::cout << "I am confused about the views for clusters (i,j) = (" << iClusterView << "," << jClusterView << ")." << std::endl;
360  }
361 
362  // This cluster is too far away in time from the first, and all subsequent
363  // clusters willalso be so. We terminate the inner loop and set the outer loop
364  // index depending on either the latch point or the current inner loop
365  // index.
366  if (kClustersFailTimeThreshold) {
367  std::cout << " -- SEED FOR NEXT CLUSTER" << std::endl;
368  std::cout << "--Break--" << std::endl;
369  i = (latch==0) ? j-1 : latch-1;
370  break;
371  }
372 
373  // This cluster is too far away in Planes from the first. If the latch point
374  // has not yet been set, we set it here. We move to the next iteration
375  // of the inner loop.
376  if (kClustersFailPlaneThreshold) {
377  std::cout << " -- FAIL PLANE CONDITION." << std::endl;
378  if (latch==0) latch = j;
379  continue;
380  }
381 
382  // This cluster is too far away in Cells from the first. This can only happen
383  // if both hits are in the same view. If the latch point has not yet been
384  // set, we set it here. We move to the next iteration of the inner loop.
385  if (kClustersFailCellThreshold) {
386  std::string cellFailure;
387  if (kBothClustersSpanBothViews) cellFailure = "Both Span Both Views";
388  else if (kOneClusterSpanBothViews) cellFailure = "One Spans Both Views";
389  else if (kBothClustersSpanOneView) cellFailure = "Both Span One View";
390  std::cout << " -- FAIL CELL CONDITION (" << cellFailure << ")" << std::endl;
391  if (latch==0) latch = j;
392  continue;
393  }
394 
395  // If we've made it this far, this hit belongs in a cluster, but only if
396  // it hasn't been added to any other clusters yet.
397  if (!clusterConsumed[j]) {
398  aCluster->Add(promptClusters[j].AllCells());
399  clusterConsumed[j] = true;
400  std::cout << " -- ADDED TO CLUSTER #" << idxCluster << std::endl;
401  }
402  else std::cout << std::endl;
403  }
404  if (ClusterIsGood(aCluster) && aCluster->NXCell() > 0 && aCluster->NYCell() > 0) clusters->push_back(*aCluster);
405  std::cout << std::endl;
406  }
407  }
408 
409  // Put the clusters into the event
410  e.put(std::move(clusters));
411 }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
rb::Cluster FinalizeCluster(rb::Cluster cluster)
unsigned int fDelayedTimeThreshold
Min time separation.
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Vertical planes which measure X.
Definition: PlaneGeo.h:28
A collection of associated CellHits.
Definition: Cluster.h:47
std::string fCellHitInput
void RemoveHit(const art::Ptr< rb::CellHit > hit)
Remove hit from current cluster.
Definition: Cluster.cxx:290
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
Definition: CellHit.cxx:134
float abs(float number)
Definition: d0nt_math.hpp:39
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
void hits()
Definition: readHits.C:15
unsigned int fMinNumberHits
Min plane separation.
unsigned int fPlaneThreshold
Min cell separation.
bool ClusterIsGood(rb::Cluster *cluster)
const double j
Definition: BetheBloch.cxx:29
void SetID(int id)
Definition: Cluster.h:74
OStream cout
Definition: OStream.cxx:6
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
Definition: structs.h:12
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
unsigned int fCellThreshold
Min time separation.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
bool fGroupPromptClusters
Max number of hits for cluster to be acceptable.
unsigned int fPromptTimeThreshold
ADC threshold.
enum BeamMode string
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  )
inherited
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited
std::string art::EDProducer::workerType ( ) const
inherited

Member Data Documentation

unsigned int sn::SNSlicer::fADCThreshold
private

CellHit product label.

Definition at line 59 of file SNSlicer_module.cc.

Referenced by ClusterIsGood().

std::string sn::SNSlicer::fCellHitInput
private

Definition at line 58 of file SNSlicer_module.cc.

Referenced by produce().

unsigned int sn::SNSlicer::fCellThreshold
private

Min time separation.

Definition at line 62 of file SNSlicer_module.cc.

Referenced by ClusterIsGood(), and produce().

unsigned int sn::SNSlicer::fDelayedTimeThreshold
private

Min time separation.

Definition at line 61 of file SNSlicer_module.cc.

Referenced by produce().

art::ServiceHandle<geo::Geometry> sn::SNSlicer::fGeom
private

Definition at line 56 of file SNSlicer_module.cc.

bool sn::SNSlicer::fGroupPromptClusters
private

Max number of hits for cluster to be acceptable.

Definition at line 66 of file SNSlicer_module.cc.

Referenced by produce().

unsigned int sn::SNSlicer::fMaxNumberHits
private

Min number of hits for cluster to be acceptable.

Definition at line 65 of file SNSlicer_module.cc.

Referenced by ClusterIsGood().

unsigned int sn::SNSlicer::fMinNumberHits
private

Min plane separation.

Definition at line 64 of file SNSlicer_module.cc.

Referenced by produce().

unsigned int sn::SNSlicer::fPlaneThreshold
private

Min cell separation.

Definition at line 63 of file SNSlicer_module.cc.

Referenced by ClusterIsGood(), and produce().

unsigned int sn::SNSlicer::fPromptTimeThreshold
private

ADC threshold.

Definition at line 60 of file SNSlicer_module.cc.

Referenced by ClusterIsGood(), and produce().


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