Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
slicer::MMSlicer Class Reference
Inheritance diagram for slicer::MMSlicer:
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

 MMSlicer (fhicl::ParameterSet const &pset)
 
virtual ~MMSlicer ()
 
void produce (art::Event &evt)
 
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

void WindowSlice (std::vector< art::Ptr< rb::CellHit > > hitlist, std::unique_ptr< std::vector< rb::Cluster > > &clustercol)
 
float HitTime (art::Ptr< rb::CellHit > hit)
 
std::vector< std::vector< art::Ptr< rb::CellHit > > > WindowSliceZ (std::vector< art::Ptr< rb::CellHit > > &hits) const
 
CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fCellHitInput
 Read CellHits from Cal/[fCellHitFolderIn]. More...
 
unsigned int fMinHits
 The minimum number of hits needed to create a slice (this is in any view) More...
 
double fTimeWindow
 
double fZGapAllowed
 
int fADCmin
 
int fADCmax
 

Detailed Description

Definition at line 25 of file MMSlicer_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

slicer::MMSlicer::MMSlicer ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 59 of file MMSlicer_module.cc.

59  :
60  fCellHitInput (pset.get< std::string >("CellHitInput") ),
61  fMinHits (pset.get< int >("MinHits") ),
62  fTimeWindow (pset.get< double >("TimeWindow") ),
63  fZGapAllowed (pset.get< int >("ZGapAllowed") ),
64  fADCmin (pset.get< int >("ADCmin") ),
65  fADCmax (pset.get< int >("ADCmax") )
66  {
67  produces< std::vector<rb::Cluster> >();
68  }
std::string fCellHitInput
Read CellHits from Cal/[fCellHitFolderIn].
unsigned int fMinHits
The minimum number of hits needed to create a slice (this is in any view)
enum BeamMode string
slicer::MMSlicer::~MMSlicer ( )
virtual

Definition at line 71 of file MMSlicer_module.cc.

72  {
73  }

Member Function Documentation

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
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  }
float slicer::MMSlicer::HitTime ( art::Ptr< rb::CellHit hit)
inlineprotected

Definition at line 36 of file MMSlicer_module.cc.

References hits(), rb::CellHit::TNS(), and WindowSliceZ().

Referenced by WindowSlice().

36 { return hit->TNS(); }
float TNS() const
Definition: CellHit.h:46
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
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void slicer::MMSlicer::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 76 of file MMSlicer_module.cc.

References rawdata::RawDigit::ADC(), fADCmax, fADCmin, fCellHitInput, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, art::Event::put(), and WindowSlice().

77  {
78  // Load hit list (CellHits)
80  evt.getByLabel(fCellHitInput, hitcol);
81 
82  std::vector<art::Ptr<rb::CellHit > > hitlist;
83  for(unsigned int i = 0; i < hitcol->size(); ++i){
84  art::Ptr<rb::CellHit> hit(hitcol, i);
85  if (hit->ADC() > fADCmin && hit->ADC() < fADCmax)
86  hitlist.push_back(hit);
87  }
88 
89  std::unique_ptr< std::vector<rb::Cluster> > clustercol(new std::vector<rb::Cluster>);
90  WindowSlice(hitlist, clustercol);
91  evt.put(std::move(clustercol));
92  }
std::string fCellHitInput
Read CellHits from Cal/[fCellHitFolderIn].
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
void WindowSlice(std::vector< art::Ptr< rb::CellHit > > hitlist, std::unique_ptr< std::vector< rb::Cluster > > &clustercol)
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
void slicer::MMSlicer::WindowSlice ( std::vector< art::Ptr< rb::CellHit > >  hitlist,
std::unique_ptr< std::vector< rb::Cluster > > &  clustercol 
)
protected

Definition at line 97 of file MMSlicer_module.cc.

References rb::Cluster::Add(), fMinHits, fTimeWindow, make_syst_table_plots::h, hits(), HitTime(), getGoodRuns4SAM::n, rb::Cluster::NXCell(), rb::Cluster::NYCell(), rb::SortByTime(), and WindowSliceZ().

Referenced by produce().

99  {
100  // A timeslice is at most fTimeWindow long, and must contain at least
101  // fMinHits hits. Any fTimeWindow-sized subwindow drawn within it
102  // will also contain at least fMinHits hits.
103 
104  slices->clear();
105  if(hits.size() < fMinHits ) return;
106 
107  std::vector<std::vector<art::Ptr<rb::CellHit> > > tSlices;
108 
110 
111  typedef std::vector<art::Ptr<rb::CellHit> >::iterator it_t;
112  // The inclusive->exclusive range we're considering for the current slice
113  it_t itStart = hits.begin();
114  it_t itEnd = hits.begin();
115 
116  // We use this point to test if we can expand the slice
117  it_t itTest = hits.begin();
118 
119  while(true){
120  // Grow the slice by moving the end until it's fTimeWindow in size
121  while(HitTime(*itEnd) - HitTime(*itStart) < fTimeWindow){
122  ++itEnd;
123  if(itEnd == hits.end()) break; //out of hits
124  }
125  if(itEnd == hits.end()) break; // Break all the way out of the loop
126 
127  // The window doesn't have enough hits, drop first hit and try again
128  if(itEnd - itStart < fMinHits){
129  ++itStart;
130  // assert(itStart <= itEnd);
131  continue;
132  }
133 
134  // The window is long enough and has enough charge
135  // Catch itTest up until it defines the start of a fTimeWindow-sized
136  // window ending on itEnd
137  while (HitTime(*itEnd) - HitTime(*itTest) > fTimeWindow) ++itTest;
138 
139  // If growing the window more would cause the itTest-itEnd window
140  // not to have enough hits, then write out what we have.
141  if(itEnd+1 - itTest < fMinHits){
142  std::vector<art::Ptr<rb::CellHit> > slice(itStart, itEnd);
143  tSlices.push_back(slice);
144  itStart = itEnd;
145  continue;
146  }
147 
148  // We can still legally grow the window. Do that and try again
149  ++itEnd;
150  if(itEnd == hits.end()) break;
151  }
152 
153  // If there are enough hits in the final slice, make it one too
154  if(itEnd - itStart > fMinHits){
155  std::vector<art::Ptr<rb::CellHit> > slice(itStart, itEnd);
156  tSlices.push_back(slice);
157  }
158 
159  // std::cout<<"the number of time slices: "<<tSlices.size()<<std::endl;
160 
161  // Split every time slice up based on z if it has gaps in
162  for(unsigned int s = 0; s != tSlices.size(); ++s){
163  std::vector<std::vector<art::Ptr<rb::CellHit> > > zSlices =
164  WindowSliceZ(tSlices[s]);
165 
166  for(unsigned int n = 0; n != zSlices.size(); ++n){
167  rb::Cluster clust;
168  //Start adding hits:
169  for(unsigned int h = 0; h != zSlices[n].size(); ++h){
170  clust.Add(zSlices[n][h]);
171  }
172  if (clust.NXCell()>=3 && clust.NYCell()>=3)
173  slices->push_back(clust);
174  }
175  }
176  }
A collection of associated CellHits.
Definition: Cluster.h:47
void SortByTime(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in time order (earliest to latest).
Definition: CellHit.cxx:134
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
unsigned int fMinHits
The minimum number of hits needed to create a slice (this is in any view)
const XML_Char * s
Definition: expat.h:262
void hits()
Definition: readHits.C:15
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
float HitTime(art::Ptr< rb::CellHit > hit)
std::vector< std::vector< art::Ptr< rb::CellHit > > > WindowSliceZ(std::vector< art::Ptr< rb::CellHit > > &hits) const
std::vector< std::vector< art::Ptr< rb::CellHit > > > slicer::MMSlicer::WindowSliceZ ( std::vector< art::Ptr< rb::CellHit > > &  hits) const
protected

Definition at line 180 of file MMSlicer_module.cc.

References DEFINE_ART_MODULE(), fMinHits, fZGapAllowed, hits(), and rb::SortByPlane().

Referenced by HitTime(), and WindowSlice().

181  {
182  std::vector<std::vector<art::Ptr<rb::CellHit> > > zSlices;
183 
185 
186  // std::cout<<"total number hits in the time slice: "<<hits.size()<<std::endl;
187 
188  if (hits.size()<fMinHits+1) return zSlices;
189 
190  // The extremes, inclusive and exclusive of our candidate slice
191  typedef std::vector<art::Ptr<rb::CellHit> >::iterator it_t;
192  it_t itBegin = hits.begin();
193  it_t itEnd = hits.begin();
194 
195  while(itEnd != hits.end()-1){
196  const int endPlane = (*itEnd)->Plane();
197  ++itEnd;
198  const int nextPlane = (*itEnd)->Plane();
199 
200 
201  if(nextPlane - endPlane > fZGapAllowed){
202  std::vector<art::Ptr<rb::CellHit> > slice(itBegin, itEnd);
203  if (itEnd-itBegin > fMinHits) zSlices.push_back(slice);
204 
205  // if(slice.size() > fMinHits) zSlices.push_back(slice);
206  // Start a new slice
207  itBegin = itEnd;
208  }
209  } // end while
210 
211 
212  // Whatever hits are left, give them their own slice
213  // std::cout<<"remaing hits number: "<<itEnd-itBegin<<std::endl;
214  std::vector<art::Ptr<rb::CellHit> > slice(itBegin, itEnd);
215 
216  if (slice.size() > fMinHits) zSlices.push_back(slice);
217 
218  return zSlices;
219  }
unsigned int fMinHits
The minimum number of hits needed to create a slice (this is in any view)
void hits()
Definition: readHits.C:15
void SortByPlane(std::vector< art::Ptr< rb::CellHit > > &c)
Sort c in plane order (low to high).
Definition: CellHit.cxx:124

Member Data Documentation

int slicer::MMSlicer::fADCmax
protected

Definition at line 50 of file MMSlicer_module.cc.

Referenced by produce().

int slicer::MMSlicer::fADCmin
protected

Definition at line 50 of file MMSlicer_module.cc.

Referenced by produce().

std::string slicer::MMSlicer::fCellHitInput
protected

Read CellHits from Cal/[fCellHitFolderIn].

Definition at line 44 of file MMSlicer_module.cc.

Referenced by produce().

unsigned int slicer::MMSlicer::fMinHits
protected

The minimum number of hits needed to create a slice (this is in any view)

Definition at line 45 of file MMSlicer_module.cc.

Referenced by WindowSlice(), and WindowSliceZ().

double slicer::MMSlicer::fTimeWindow
protected

Definition at line 48 of file MMSlicer_module.cc.

Referenced by WindowSlice().

double slicer::MMSlicer::fZGapAllowed
protected

Definition at line 49 of file MMSlicer_module.cc.

Referenced by WindowSliceZ().


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