All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cluster::SmallClusterFinder Class Reference
Inheritance diagram for cluster::SmallClusterFinder:

Public Member Functions

 SmallClusterFinder (fhicl::ParameterSet const &pset)
 

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
 

Detailed Description

Definition at line 63 of file SmallClusterFinder_module.cc.

Constructor & Destructor Documentation

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

Definition at line 95 of file SmallClusterFinder_module.cc.

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

Member Function Documentation

void cluster::SmallClusterFinder::beginJob ( )
overrideprivate

Definition at line 107 of file SmallClusterFinder_module.cc.

108  {
109  // this will not change on a run per run basis.
110  fNPlanes = geom->Nplanes(); //get the number of planes in the TPC
111  }
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)
overrideprivate

Get Clusters

Definition at line 116 of file SmallClusterFinder_module.cc.

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

Member Data Documentation

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

Definition at line 75 of file SmallClusterFinder_module.cc.

unsigned int cluster::SmallClusterFinder::fNPlanes
private

Definition at line 83 of file SmallClusterFinder_module.cc.

SmallClusterFinderAlg cluster::SmallClusterFinder::fSmallClusterFinderAlg
private

Definition at line 81 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 72 of file SmallClusterFinder_module.cc.

bool cluster::SmallClusterFinder::verbose
private

Definition at line 76 of file SmallClusterFinder_module.cc.


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