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

Public Member Functions

 SmallClusterFinder (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 beginJob () override
 
void produce (art::Event &evt) override
 
int GetPlaneAndTPC (art::Ptr< recob::Hit > a, unsigned int &p, unsigned int &cs, unsigned int &t, unsigned int &w)
 

Private Attributes

art::ServiceHandle< geo::Geometry const > geom
 
std::string fHitFinderModuleLabel
 
bool verbose
 
SmallClusterFinderAlg fSmallClusterFinderAlg
 
unsigned int fNPlanes
 

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

Definition at line 62 of file SmallClusterFinder_module.cc.

Constructor & Destructor Documentation

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

Definition at line 94 of file SmallClusterFinder_module.cc.

95  : EDProducer{pset}, fSmallClusterFinderAlg(pset.get<fhicl::ParameterSet>("smallClustAlg"))
96  {
97  fHitFinderModuleLabel = pset.get<std::string>("HitFinderModuleLabel");
98  verbose = pset.get<bool>("Verbose");
99 
100  produces<std::vector<recob::Cluster>>(); //This code makes clusters
101  produces<art::Assns<recob::Cluster, recob::Hit>>(); //Matches clusters with hits
102  }
std::string string
Definition: nybbler.cc:12
SmallClusterFinderAlg fSmallClusterFinderAlg
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20

Member Function Documentation

void cluster::SmallClusterFinder::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 106 of file SmallClusterFinder_module.cc.

107  {
108  // this will not change on a run per run basis.
109  fNPlanes = geom->Nplanes(); //get the number of planes in the TPC
110  }
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
art::ServiceHandle< geo::Geometry const > geom
int cluster::SmallClusterFinder::GetPlaneAndTPC ( art::Ptr< recob::Hit a,
unsigned int &  p,
unsigned int &  cs,
unsigned int &  t,
unsigned int &  w 
)
private
void cluster::SmallClusterFinder::produce ( art::Event evt)
overrideprivatevirtual

Get Clusters

Implements art::EDProducer.

Definition at line 115 of file SmallClusterFinder_module.cc.

116  {
117  /**Get Clusters*/
118 
119  //Get the hits for this event:
121  evt.getByLabel(fHitFinderModuleLabel, HitListHandle);
122 
123  //A vector to hold hits, not yet filled:
124  std::vector<art::Ptr<recob::Hit>> hitlist;
125 
126  //How many hits in this event? Tell user:
127  if (verbose)
128  std::cout << " ++++ Hitsreceived received " << HitListHandle->size() << " +++++ "
129  << std::endl;
130  //Catch the case were there are no hits in the event:
131  if (HitListHandle->size() == 0) {
132  if (verbose) std::cout << "No hits received! Exiting." << std::endl;
133  return;
134  }
135  hitlist.resize(HitListHandle->size());
136 
137  //wrap the hits in art::Ptrs to pass to the Alg
138  for (unsigned int iHit = 0; iHit < hitlist.size(); iHit++) {
139  hitlist[iHit] = art::Ptr<recob::Hit>(HitListHandle, iHit);
140  }
141 
142  //std::cout << "Passing " << hitlist.size() << " hits to the alg." << std::endl;
143 
144  // Now run the alg to find the gammas:
145  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
146  auto const detProp =
148  util::GeometryUtilities const gser{*geom, clockData, detProp};
149  fSmallClusterFinderAlg.FindSmallClusters(gser, clockData, detProp, hitlist);
150 
151  // make an art::PtrVector of the clusters
152  auto SmallClusterFinder = std::make_unique<std::vector<recob::Cluster>>();
153  auto assn = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
154 
155  // prepare the algorithm to compute the cluster characteristics;
156  // we use the "standard" one here; configuration would happen here,
157  // but we are using the default configuration for that algorithm
158  ClusterParamsImportWrapper<StandardClusterParamsAlg> ClusterParamAlgo;
159 
160  for (unsigned int iplane = 0; iplane < fNPlanes; iplane++) {
161 
162  auto const leftoverHits = fSmallClusterFinderAlg.GetLeftoversByPlane(iplane);
163 
164  //write the leftover hits as a cluster:
165  if (leftoverHits.size() != 0) {
166  // pick some information from the first hit
167  geo::PlaneID planeID = leftoverHits.front()->WireID().planeID();
168  if (verbose)
169  std::cout << "Writing leftover hits to cluster ID: " << iplane * 100 << std::endl;
170 
171  ClusterParamAlgo.ImportHits(gser, leftoverHits);
172 
173  // create the recob::Cluster directly in the vector
174  ClusterCreator leftover(gser,
175  ClusterParamAlgo, // algo
176  0., // start_wire
177  0., // sigma_start_wire
178  0., // start_tick
179  0., // sigma_start_tick
180  0., // end_wire
181  0., // sigma_end_wire,
182  0., // end_tick
183  0., // sigma_end_tick
184  iplane * 100, // ID
185  geom->Plane(iplane, planeID.TPC, planeID.Cryostat).View(),
186  planeID, // plane
187  recob::Cluster::Sentry // sentry
188  );
189 
190  SmallClusterFinder->emplace_back(leftover.move());
191 
192  util::CreateAssn(evt, *SmallClusterFinder, leftoverHits, *assn);
193  } //leftovers are written for this plane, if they exist.
194 
195  auto const smallClusters = fSmallClusterFinderAlg.GetSmallClustersByPlane(iplane);
196  for (unsigned int i = 0; i < smallClusters.size(); i++) {
197  // pick some information from the first hit
198  geo::PlaneID planeID; // invalid by default
199  if (!smallClusters.empty()) planeID = smallClusters[i].front()->WireID().planeID();
200 
201  ClusterParamAlgo.ImportHits(gser, smallClusters[i]);
202 
203  // create the recob::Cluster directly in the vector
204  ClusterCreator clust(gser,
205  ClusterParamAlgo, // algo
206  0., // start_wire
207  0., // sigma_start_wire
208  0., // start_tick
209  0., // sigma_start_tick
210  0., // end_wire
211  0., // sigma_end_wire,
212  0., // end_tick
213  0., // sigma_end_tick
214  iplane * 100 + i + 1, // ID
215  geom->Plane(iplane, planeID.TPC, planeID.Cryostat).View(),
216  planeID, // plane
217  recob::Cluster::Sentry // sentry
218  );
219 
220  SmallClusterFinder->emplace_back(clust.move());
221  // associate the hits to this cluster
222  util::CreateAssn(evt, *SmallClusterFinder, smallClusters[i], *assn);
223  }
224  }
225 
227  evt.put(std::move(assn));
228  } //end produce
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
SmallClusterFinderAlg fSmallClusterFinderAlg
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
SmallClusterFinder(fhicl::ParameterSet const &pset)
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
void FindSmallClusters(util::GeometryUtilities const &gser, detinfo::DetectorClocksData const &dataClocks, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> allHits)
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:184
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
def move(depos, offset)
Definition: depos.py:107
std::vector< art::Ptr< recob::Hit > > GetLeftoversByPlane(unsigned int iPlane)
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.
std::vector< std::vector< art::Ptr< recob::Hit > > > GetSmallClustersByPlane(unsigned int iPlane)
art::ServiceHandle< geo::Geometry const > geom
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::string cluster::SmallClusterFinder::fHitFinderModuleLabel
private

Definition at line 74 of file SmallClusterFinder_module.cc.

unsigned int cluster::SmallClusterFinder::fNPlanes
private

Definition at line 82 of file SmallClusterFinder_module.cc.

SmallClusterFinderAlg cluster::SmallClusterFinder::fSmallClusterFinderAlg
private

Definition at line 80 of file SmallClusterFinder_module.cc.

art::ServiceHandle<geo::Geometry const> cluster::SmallClusterFinder::geom
private

Routine that finds the cluster and sets the dTdW of the 2D shower

Definition at line 71 of file SmallClusterFinder_module.cc.

bool cluster::SmallClusterFinder::verbose
private

Definition at line 75 of file SmallClusterFinder_module.cc.


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