Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
sn::SNSlicer Class Reference
Inheritance diagram for sn::SNSlicer:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::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
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

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

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

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

Definition at line 35 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 fCellHitInput(p.get<std::string>("CellHitInput")),
72 fADCThreshold(p.get<int>("ADCThreshold")),
73 fPromptTimeThreshold(p.get<int>("PromptTimeSeparationThreshold")),
74 fDelayedTimeThreshold(p.get<int>("DelayedTimeSeparationThreshold")),
75 fCellThreshold(p.get<int>("CellSeparationThreshold")),
76 fPlaneThreshold(p.get<int>("PlaneSeparationThreshold")),
77 fMinNumberHits(p.get<unsigned int>("MinNumberHits")),
78 fMaxNumberHits(p.get<unsigned int>("MaxNumberHits")),
79 fGroupPromptClusters(p.get<bool>("GroupPromptClusters"))
80 {
81  produces<std::vector<rb::Cluster>>();
82 }
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
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 84 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().

85 {
86  bool kNumberHitsOutOfRange = (cluster->NCell() > fMaxNumberHits);
87  bool kMaxPlaneExtentExceeded = (cluster->ExtentPlane() > fPlaneThreshold);
88  bool kMaxXCellExtentExceeded = (cluster->NXCell()>0) ? (cluster->ExtentCell(geo::kX) > fCellThreshold) : false;
89  bool kMaxYCellExtentExceeded = (cluster->NYCell()>0) ? (cluster->ExtentCell(geo::kY) > fCellThreshold) : false;
90  bool kMaxTnsExtentExceeded = (cluster->ExtentTNS() > fPromptTimeThreshold);
91  bool kMaxTotalAdcExceeded = (cluster->TotalADC() > fADCThreshold);
92  // bool kClusterIs2D = (cluster->NXCell()==0 || cluster->NYCell()==0);
93 
94  bool kClusterIsBad = kNumberHitsOutOfRange || kMaxPlaneExtentExceeded ||
95  kMaxXCellExtentExceeded || kMaxYCellExtentExceeded ||
96  kMaxTnsExtentExceeded || kMaxTotalAdcExceeded;
97 
98  return (!kClusterIsBad);
99 }
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 = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
rb::Cluster sn::SNSlicer::FinalizeCluster ( rb::Cluster  cluster)

Definition at line 101 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().

102 {
103  // Determine the view
104  unsigned int nCellX = cluster.NXCell();
105  unsigned int nCellY = cluster.NYCell();
106 
107  rb::Cluster cFinal;
108 
109  if (nCellX>0 && nCellY==0) {
110  cFinal = rb::Cluster(geo::kX, cluster.AllCells(), cluster.ID());
111  } else if (nCellX==0 && nCellY>0) {
112  cFinal = rb::Cluster(geo::kY, cluster.AllCells(), cluster.ID());
113  } else {
114  cFinal = rb::Cluster(cluster.AllCells(), cluster.ID());
115  }
116 
117  return cFinal;
118 }
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
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
SNSlicer& sn::SNSlicer::operator= ( SNSlicer const &  )
delete
SNSlicer& sn::SNSlicer::operator= ( SNSlicer &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void sn::SNSlicer::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 121 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::Event::put(), rb::Cluster::RemoveHit(), rb::Cluster::SetID(), rb::SortByTime(), and string.

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

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

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: