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

Public Member Functions

 ShowerFinder (fhicl::ParameterSet const &)
 
- 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 produce (art::Event &evt)
 

Private Attributes

std::string fVertexModuleLabel
 label of module finding 2D endpoint More...
 
std::string fClusterModuleLabel
 label of module finding clusters More...
 
std::string fHoughLineModuleLabel
 label of module finding hough line More...
 
std::string fVertexStrengthModuleLabel
 label of module finding 2D endpoint More...
 
double fRcone
 radious of cone for method More...
 
double fLcone
 length of the cone More...
 

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 42 of file ShowerFinder_module.cc.

Constructor & Destructor Documentation

shwf::ShowerFinder::ShowerFinder ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 63 of file ShowerFinder_module.cc.

63  :
64  EDProducer{pset}
65  {
66  fVertexModuleLabel = pset.get<std::string > ("VertexModuleLabel");
67  fClusterModuleLabel = pset.get<std::string > ("ClusterModuleLabel");
68  fHoughLineModuleLabel = pset.get<std::string > ("HoughLineModuleLabel");
69  fVertexStrengthModuleLabel= pset.get<std::string > ("VertexStrengthModuleLabel");
70  fRcone = pset.get<double > ("Rcone");
71  fLcone = pset.get<double > ("Lcone");
72 
73  produces< std::vector<recob::Shower> >();
74  produces< art::Assns<recob::Shower, recob::Cluster> >();
75  produces< art::Assns<recob::Shower, recob::Hit> >();
76  }
std::string fHoughLineModuleLabel
label of module finding hough line
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fVertexModuleLabel
label of module finding 2D endpoint
std::string fClusterModuleLabel
label of module finding clusters
std::string fVertexStrengthModuleLabel
label of module finding 2D endpoint
double fRcone
radious of cone for method
double fLcone
length of the cone

Member Function Documentation

void shwf::ShowerFinder::produce ( art::Event evt)
privatevirtual
Todo:

This method appears to produce a recob::Cluster really as it is

a collection of 2D clusters from single planes

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Todo:
NEED TO TAKE OUT THE HOUGH LINES FROM THE PROTOSHOWERS!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Todo:
really need to determine the values of the arguments of the recob::Shower ctor

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Todo:
check if protoshower from further vertex is also contained in vertex nearer...

Implements art::EDProducer.

Definition at line 83 of file ShowerFinder_module.cc.

84  {
85 
86  std::unique_ptr<std::vector<recob::Shower> > showercol(new std::vector<recob::Shower>);
87  std::unique_ptr< art::Assns<recob::Shower, recob::Cluster> > cassn(new art::Assns<recob::Shower, recob::Cluster>);
88  std::unique_ptr< art::Assns<recob::Shower, recob::Hit> > hassn(new art::Assns<recob::Shower, recob::Hit>);
89 
90  // Read in the vertex List object(s).
92  evt.getByLabel(fVertexModuleLabel,vertexListHandle);
93 
94  // Read in the hough line List object(s).
96  evt.getByLabel(fHoughLineModuleLabel,houghListHandle);
97 
98  // Read in the cluster List object(s).
99  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
100  evt.getByLabel(fClusterModuleLabel,clusterListHandle);
101 
102  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
103 
104  // Read in the vertex Strength List object(s).
105  art::Handle< std::vector<recob::EndPoint2D> > vertexStrengthListHandle;
106  evt.getByLabel(fVertexStrengthModuleLabel,vertexStrengthListHandle);
107 
108  std::vector<size_t> protoShowers; //vector of indices of clusters associated to a cone
109 
110  std::vector< art::Ptr<recob::Hit> > clusterhits; //hits in the cluster
111 
113 
114  //This vector will contain all strong and strongest vertices
116 
117  //This loop is going over all the vertices in the event
118  //and is interested in ONLY strong and strongest vertices.
119  mf::LogInfo("ShowerFinder") << "Vertex STRENGTH list size = " << vertexStrengthListHandle->size()
120  << " AND vertices:" << vertexListHandle->size()
121  << "\nCLUSTER list size = " << clusterListHandle->size()
122  << " AND Hough: :" << houghListHandle->size();
123 
124  for(size_t iv = 0; iv < vertexListHandle->size(); ++iv){
125  art::Ptr<recob::EndPoint2D> vertex(vertexListHandle, iv);
126  //std::cout << "Vertex " << iv << " : str = " << vertex->ID() << std::endl;
127  //if(vertex->Strength() == 4 || vertex->Strength() == 3){
128  if(vertex->ID() == 1 || vertex->Strength() == 3){ //only use Strongest and strong
129  vertSel.push_back(vertex);
130  }
131  else continue;
132  }
133 
134  //Definition of the geometry of the cone (which is basically a triangle)
135  double scan_angle = 0; //angle of the scan steps
136  double xa_cone = 0; // x coordinate of the cone's apex (wire number)
137  double ya_cone = 0; // y coordinate of the cone's apex (drift time)
138  double x1_cone = 0; // x coordinate of the cone's top right point (wire number)
139  double y1_cone = 0; // y coordinate of the cone's top right point (drift time)
140  double x2_cone = 0; // x coordinate of the cone's top left point (wire number)
141  double y2_cone = 0; // y coordinate of the cone's top left point (drift time)
142 
143  //The length of the side of the cone
144  double fScone = std::sqrt( (fRcone*fRcone) + (fLcone*fLcone));
145 
146  // Opening angle of the cone (defined from input parameters)
147  double cone_angle = (TMath::ATan(fRcone / fLcone)) / 2.0;
148  mf::LogInfo("ShowerFinder") << "Cone Opening Angle: " << (180.0*cone_angle)/TMath::Pi();
149  double compl_angle = 0;
150 
151  unsigned int n_scan =1 + (int)(TMath::Pi() / (2.0*cone_angle));
152  mf::LogInfo("ShowerFinder") << "N scan: " << n_scan;
153 
154  double x_hit = 0; //x coordinate of hit
155  double y_hit = 0; //y coordinate of hit
156 
157  int hits_cluster_counter = 0; //count the number of hits in a cluster that is inside a cone
158  //int hits_cluster_Total = 0; //The total number of hits in a cluster
159 
160  // For EVERY vertex, the algorithm is going to scan the plane to find clusters
161  // contained in the scanning cones
162 
163  for(size_t ivert = 0; ivert < vertSel.size(); ++ivert){
164 
165  mf::LogInfo("ShowerFinder") << "Number of STRONG vertices = " << vertSel.size();
166 
167  //get the coordinates of the vertex for the summit of the cone
168  xa_cone = vertSel[ivert]->WireID().Wire; //for update to EndPoint2D ... WK 4/22/13
169  ya_cone = vertSel[ivert]->DriftTime();
170 
171  mf::LogInfo("ShowerFinder") << "Vertex at: (" << xa_cone << ", " << ya_cone << ")";
172 
173  //Beginning of the scan!
174  for(unsigned int iscan = 0; iscan < n_scan; ++iscan){
175 
176  mf::LogInfo("ShowerFinder") << ">>>> Start SCAN: " << iscan;
177 
178  //define the scan anlge
179  scan_angle = (TMath::Pi()/2.0) - (iscan*(2.0*cone_angle));
180 
181  mf::LogInfo("ShowerFinder") << "Scan Angle: " << (180.*scan_angle)/TMath::Pi();
182 
183  //get the complementary angle for geometry puurposes
184  compl_angle = scan_angle - cone_angle;
185 
186  //Calculate the coordinates of the top right corner of the cone
187  x1_cone = xa_cone + fScone*(std::cos(compl_angle));
188  y1_cone = ya_cone + fScone*(std::sin(compl_angle));
189 
190  //Calculate the coordinates of the top left corner of the cone
191  x2_cone = xa_cone + fScone*(std::cos(scan_angle + cone_angle));
192  y2_cone = ya_cone + fScone*(std::sin(scan_angle + cone_angle));
193 
194  //Looking if a cluster is in this cone (loop over all hits of all clusters)
195  protoShowers.clear();
196  for(size_t iclust = 0; iclust < clusterListHandle->size(); ++iclust){
197 
198  // art::Ptr<recob::Cluster> clust(clusterListHandle, iclust);
199  recob::Cluster const& clust = clusterListHandle->at(iclust);
200 
201  //Get the hits vector from the cluster
202  clusterhits = fmh.at(iclust);
203  if(clusterhits.size() == 0) continue;
204 
205  //Loop over ALL hits in the cluster. Looking if the cluster's
206  // hit is comprised in the cone
207  for(size_t ihits = 0; ihits < clusterhits.size(); ++ihits){
208 
209 
210  x_hit = clusterhits[ihits]->WireID().Wire; //for update to EndPoint2D ... WK 4/22/13
211  y_hit = clusterhits[ihits]->PeakTime();
212 
213  // Check in hits is INSIDE cone
214 
215  //define the 2 line equations:
216  if(y_hit <= ((y2_cone - ya_cone)/(x2_cone - xa_cone))*x_hit + ya_cone &&
217  y_hit >= ((y1_cone - ya_cone)/(x1_cone - xa_cone))*x_hit + ya_cone){
218  hits_cluster_counter++;
219  }
220 
221  }//end hits loop
222 
223  //If there is more than 50% if the cluster INSIDE the cone, this is a protoshower
224  if(clusterhits.size() == 0) continue;
225  if(((double)hits_cluster_counter / (double)clusterhits.size()) >= 0.5){
226  mf::LogInfo("ShowerFinder") << "GOT A SHOWER!!! in scan " << iscan
227  << " cluster: " << iclust << " : " << clust.ID();
228 
229  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
230  /// \todo NEED TO TAKE OUT THE HOUGH LINES FROM THE PROTOSHOWERS!!!!!
231  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
232 
233  protoShowers.push_back(iclust);
234  }
235  clusterhits.clear();
236  hits_cluster_counter = 0;
237 
238  } //end cluster loop
239 
240  if(protoShowers.empty()) continue;
241 
242  // loop over hits in the protoShowers to determine the total charge of the shower
243  double totalCharge = 0.;
244 
245  for(size_t p = 0; p < protoShowers.size(); ++p){
246  const size_t psIndex = protoShowers[p];
247  for (art::Ptr<recob::Hit> const& hit: fmh.at(psIndex))
248  if(hit->SignalType() == geo::kCollection) totalCharge += hit->Integral();
249  }
250 
251  /// \todo really need to determine the values of the arguments of the recob::Shower ctor
252  // fill with bogus values for now
253  //double dcosVtx[3] = { util::kBogusD };
254  //double dcosVtxErr[3] = { util::kBogusD };
255  //double maxTransWidth[2] = { util::kBogusD };
256  //double distMaxWidth = util::kBogusD;
257 
258  //showercol->push_back( recob::Shower(dcosVtx, dcosVtxErr, maxTransWidth, totalCharge, distMaxWidth) );
259  showercol->push_back(recob::Shower());
260 
261  // associate the shower with its clusters
262  util::CreateAssn(*this, evt, *cassn,
263  showercol->size() - 1, protoShowers.begin(), protoShowers.end());
264 
265  // get the hits associated with each cluster and associate those with the shower
266  for(size_t p = 0; p < protoShowers.size(); ++p){
267  const size_t psIndex = protoShowers[p];
268  std::vector< art::Ptr<recob::Hit> > hits = fmh.at(psIndex);
269  util::CreateAssn(*this, evt, *showercol, hits, *hassn);
270  }
271 
272  } //end scan loop
273  } //end vertices loop
274 
275  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
276  //NEED TO SEPARATE THE SHOWERS FROM THE DIFFERENT VERTEX!!!!
277  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
278 
279 
280  mf::LogInfo("ShowerFinder") << "---> Recorded shower = "<< showercol->size();
281  /// \todo check if protoshower from further vertex is also contained in vertex nearer...
282  //if the shower is stand alone ok, else, erase the next one
283  //shower.SetID(is);
284  //shower.SetVertexCoord(xa_cone, ya_cone);
285 
286  vertSel.clear();
287 
288  evt.put(std::move(showercol));
289  evt.put(std::move(cassn));
290  evt.put(std::move(hassn));
291 
292  return;
293  } // end of produce
std::string fHoughLineModuleLabel
label of module finding hough line
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fVertexModuleLabel
label of module finding 2D endpoint
Set of hits with a 2D structure.
Definition: Cluster.h:71
std::string fClusterModuleLabel
label of module finding clusters
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
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.
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
std::string fVertexStrengthModuleLabel
label of module finding 2D endpoint
double fRcone
radious of cone for method
ID_t ID() const
Identifier of this cluster.
Definition: Cluster.h:738
double fLcone
length of the cone
void clear()
Definition: PtrVector.h:533
Definition: fwd.h:31
Signal from collection planes.
Definition: geo_types.h:146
vertex reconstruction

Member Data Documentation

std::string shwf::ShowerFinder::fClusterModuleLabel
private

label of module finding clusters

Definition at line 50 of file ShowerFinder_module.cc.

std::string shwf::ShowerFinder::fHoughLineModuleLabel
private

label of module finding hough line

Definition at line 51 of file ShowerFinder_module.cc.

double shwf::ShowerFinder::fLcone
private

length of the cone

Definition at line 54 of file ShowerFinder_module.cc.

double shwf::ShowerFinder::fRcone
private

radious of cone for method

Definition at line 53 of file ShowerFinder_module.cc.

std::string shwf::ShowerFinder::fVertexModuleLabel
private

label of module finding 2D endpoint

Definition at line 49 of file ShowerFinder_module.cc.

std::string shwf::ShowerFinder::fVertexStrengthModuleLabel
private

label of module finding 2D endpoint

Definition at line 52 of file ShowerFinder_module.cc.


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