WeightSharedHitsAlg.cxx
Go to the documentation of this file.
4 
6 
9 #include "GeometryObjects/Geo.h"
10 #include "Utilities/func/MathUtil.h"
11 
12 #include "TGeoManager.h"
13 #include "TGeoNode.h"
14 #include "TMatrixD.h"
15 
16 #include <string.h>
17 
18 namespace fuzz{
19 
21  {
22  }
23 
25  {
26 
27  }
28 
29 
30  void WeightSharedHitsAlg::GetWeights( std::vector<rb::WeightedProng>& prongs )
31  {
32  const int nPro = prongs.size();
33 
34  // This map holds info about the cells that are shared by
35  // multiple prongs. The key is the channel, and the value
36  // is another map. In the inner map, the key is the index
37  // of the prong and the value is the index of the cell in
38  // that prong. Therefore, proIdx[chan][prgIdx] = [cellIdx]
39  std::map< uint32_t , std::map< int, int > > proIdx ;
40 
41  for( int iPro = 0; iPro < nPro; ++iPro){
42 
43  // loop over cells in ith prong
44  for( unsigned int iCell = 0; iCell < prongs[iPro].NCell(); ++iCell ){
45  const art::Ptr<rb::CellHit>& ihit = prongs[iPro].Cell(iCell);
46 
47  // In the following loop, we will find which other
48  // prongs the ihits[iCell] belongs to.
49 
50  for( int jPro = iPro+1; jPro < nPro; ++jPro){
51 
52  // loop over cells in jth prong
53  for( unsigned int jCell = 0 ; jCell < prongs[jPro].NCell(); ++jCell){
54  const art::Ptr<rb::CellHit>& jhit = prongs[jPro].Cell(jCell);
55 
56  if( *jhit == *ihit){
57  proIdx[ ihit->Channel() ][ iPro ] = iCell;
58  proIdx[ ihit->Channel() ][ jPro ] = jCell;
59  }
60 
61  }// end loop over jprong cells
62  }// end j loop over prongs
63  }// end loop over iprong cells
64  }// end i loop over prongs
65 
66  // We now have all the info we need to set weights:
67  // 1/N weights
68  // loop over channels
69  for( auto & cmap : proIdx){
70  // for each channel, get number of prongs that share that channel
71  int nsharedprongs = cmap.second.size();
72  // loop over the shared prongs for that channel
73  for( auto & pmap : cmap.second){
74  // doing the really naive thing which is weighting by 1/Nprongs
75  prongs[pmap.first].SetWeight(pmap.second, 1./nsharedprongs);
76  }
77  }// end loop over proIdx
78 
79  return;
80 
81  }// end of GetWeights
82 
83 }//end fuzz namespace
WeightSharedHitsAlg(const WeightSharedHitsParams &params)
Collect Geo headers and supply basic geometry functions.
Fuzzy k-Means prong-finding algorithm.
uint32_t Channel() const
Definition: RawDigit.h:84
cmap::CMap class source code
Definition: CMap.cxx:17
void GetWeights(std::vector< rb::WeightedProng > &prong)