Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dt::View Class Reference

Representation of the channels in one view. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-21/DiscreteTracker/View.h"

Public Types

typedef std::map< int, std::vector< Chunk > > ChunkMap
 

Public Member Functions

 View (art::PtrVector< rb::CellHit > chits, bool considerBadChans)
 
geo::View_t GeoView () const
 
ChunkMap MakeChunks () const
 
std::set< unsigned intGetPlanes () const
 
int PrevPlane (unsigned int plane) const
 
int NextPlane (unsigned int plane) const
 
int AdjacentPlane (unsigned int plane, Direction dir) const
 
dt::Channel Channel (int plane, int cell) const
 
dt::ChannelChannel (int plane, int cell)
 

Protected Member Functions

std::vector< ChunkMakeChunkCombos (int plane, int begin, int end) const
 
bool Outside (int plane, int cell) const
 

Protected Attributes

geo::View_t fGeoView
 
unsigned int fMinCell
 
std::vector< std::vector< dt::Channel > > fChans
 Should access this via Channel function. More...
 
std::set< unsigned intfPlanes
 

Detailed Description

Representation of the channels in one view.

Definition at line 22 of file View.h.

Member Typedef Documentation

typedef std::map<int, std::vector<Chunk> > dt::View::ChunkMap

Definition at line 27 of file View.h.

Constructor & Destructor Documentation

dt::View::View ( art::PtrVector< rb::CellHit chits,
bool  considerBadChans 
)

Definition at line 19 of file View.cxx.

References ana::assert(), getBrightness::cell, rb::CellHit::Cell(), febshutoff_auto::chan, art::PtrVector< T >::empty(), fChans, fGeoView, fMinCell, fPlanes, geom(), geo::GeometryBase::GetPlanesByView(), chaninfo::BadChanList::IsBad(), chaninfo::BadChanList::IsLowEfficiency(), it, dt::Channel::kDead, std::max(), makeBrightnessMap::maxCell, rb::Cluster::MaxCell(), makeBrightnessMap::maxPlane, rb::Cluster::MaxPlane(), std::min(), rb::Cluster::MinCell(), rb::Cluster::MinPlane(), getGoodRuns4SAM::n, geo::PlaneGeo::Ncells(), geo::GeometryBase::NPlanes(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), NDAPDHVSetting::plane, dt::Channel::SetDead(), dt::Channel::SetHit(), art::PtrVector< T >::size(), dt::Channel::Type(), and submit_hadd::u.

20  {
21  assert(!chits.empty());
22 
23  fGeoView = chits[0]->View();
24 
27 
28  fChans.resize(geom->NPlanes());
29 
30  fPlanes = geom->GetPlanesByView(fGeoView);
31 
32  rb::Cluster clust(chits); // Just to get the extents
33  // Clumsy technique to remove all the planes outside the hit range
34  const unsigned int minPlane = clust.MinPlane();
35  for(unsigned int p = 0; p < minPlane; ++p) fPlanes.erase(p);
36  const unsigned int maxPlane = clust.MaxPlane();
37  for(unsigned int p = maxPlane+1; p < geom->NPlanes(); ++p)
38  fPlanes.erase(p);
39 
40  // Have the box we save be one bigger than the extent of the hit cells (but
41  // not larger than the detector).
42  const unsigned int minCell = std::max(clust.MinCell(fGeoView), 1u)-1;
43  fMinCell = minCell;
44  const unsigned int maxCell = std::min(clust.MaxCell(fGeoView)+1, geom->Plane(minPlane)->Ncells()-1);
45 
46  for(std::set<unsigned int>::iterator it = fPlanes.begin();
47  it != fPlanes.end(); ++it){
48  const unsigned int plane = *it;
49 
50  // Are you running with a geometry inconsistent with what you generated
51  // with?
52  assert(plane < geom->NPlanes());
53 
54  fChans[plane].reserve(maxCell-minCell+1);
55 
56  for(unsigned int cell = minCell; cell <= maxCell; ++cell){
57  dt::Channel chan(plane, cell);
58  if(considerBadChans &&
59  (bcl->IsBad(plane, cell) || bcl->IsLowEfficiency(plane, cell))){
60  chan.SetDead();
61  }
62 
63  fChans[plane].push_back(chan);
64  }
65  } // end for it (plane)
66 
67  for(unsigned int n = 0; n < chits.size(); ++n){
68  const art::Ptr<rb::CellHit> chit = chits[n];
69  const int plane = chit->Plane();
70  const int cell = chit->Cell();
71  dt::Channel& chan = fChans[plane][cell-minCell];
72  // Behave correctly in the face of eg weird CalHit configuration, and of
73  // channels that have bad efficiency but somehow worked this one time.
74  if(chan.Type() != Channel::kDead ||
75  (considerBadChans && bcl->IsLowEfficiency(plane, cell))){
76  chan.SetHit(chit);
77  }
78  }
79 
80  // Don't consider any planes that are completely dead
81  std::vector<unsigned int> deadPlanes;
82  for(std::set<unsigned int>::iterator it = fPlanes.begin();
83  it != fPlanes.end(); ++it){
84  const unsigned int plane = *it;
85 
86  bool alldead = true;
87  for(unsigned int cell = 0; cell < fChans[plane].size(); ++cell){
88  if(fChans[plane][cell].Type() != Channel::kDead){
89  alldead = false;
90  break;
91  }
92  } // end for cell
93  if(alldead) deadPlanes.push_back(plane);
94  } // end for it (plane)
95 
96  for(unsigned int n = 0; n < deadPlanes.size(); ++n)
97  fPlanes.erase(deadPlanes[n]);
98  }
T max(const caf::Proxy< T > &a, T b)
set< int >::iterator it
unsigned short Plane() const
Definition: CellHit.h:39
const char * p
Definition: xmltok.h:285
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
Type_t Type() const
Definition: Channel.cxx:45
A collection of associated CellHits.
Definition: Cluster.h:47
std::set< unsigned int > fPlanes
Definition: View.h:49
const PlaneGeo * Plane(unsigned int i) const
unsigned int fMinCell
Definition: View.h:45
Representation of the state of a single detector channel.
Definition: Channel.h:19
unsigned short Cell() const
Definition: CellHit.h:40
geo::View_t fGeoView
Definition: View.h:43
void SetHit(art::Ptr< rb::CellHit > chit)
Definition: Channel.cxx:25
bool empty() const
Definition: PtrVector.h:336
size_type size() const
Definition: PtrVector.h:308
const std::set< unsigned int > & GetPlanesByView(View_t v=kXorY) const
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
unsigned int NPlanes() const
T min(const caf::Proxy< T > &a, T b)
bool IsBad(int plane, int cell)
std::vector< std::vector< dt::Channel > > fChans
Should access this via Channel function.
Definition: View.h:47
bool IsLowEfficiency(int plane, int cell)

Member Function Documentation

int dt::View::AdjacentPlane ( unsigned int  plane,
Direction  dir 
) const

Definition at line 121 of file View.cxx.

References dt::kUpstream, NextPlane(), and PrevPlane().

Referenced by GetPlanes(), and dt::DiscreteTracker::PossibleNextSegs().

122  {
123  if(dir == kUpstream) return PrevPlane(plane);
124  return NextPlane(plane);
125  }
int NextPlane(unsigned int plane) const
Definition: View.cxx:111
int PrevPlane(unsigned int plane) const
Definition: View.cxx:101
TDirectory * dir
Definition: macro.C:5
dt::Channel dt::View::Channel ( int  plane,
int  cell 
) const

Definition at line 128 of file View.cxx.

References fChans, fMinCell, Outside(), NDAPDHVSetting::plane, and dt::Channel::SetDead().

Referenced by GetPlanes(), MakeChunkCombos(), MakeChunks(), and dt::DiscreteTracker::RecoDiscrete().

129  {
130  if(Outside(plane, cell)){
131  dt::Channel outside(plane, cell);
132  outside.SetDead();
133  return outside;
134  }
135 
136  return fChans[plane][cell-fMinCell];
137  }
bool Outside(int plane, int cell) const
Definition: View.cxx:261
unsigned int fMinCell
Definition: View.h:45
Representation of the state of a single detector channel.
Definition: Channel.h:19
std::vector< std::vector< dt::Channel > > fChans
Should access this via Channel function.
Definition: View.h:47
dt::Channel & dt::View::Channel ( int  plane,
int  cell 
)

Definition at line 140 of file View.cxx.

References ana::assert(), fChans, fMinCell, Outside(), and NDAPDHVSetting::plane.

141  {
142  assert(!Outside(plane, cell));
143 
144  return fChans[plane][cell-fMinCell];
145  }
bool Outside(int plane, int cell) const
Definition: View.cxx:261
unsigned int fMinCell
Definition: View.h:45
assert(nhit_max >=nhit_nbins)
std::vector< std::vector< dt::Channel > > fChans
Should access this via Channel function.
Definition: View.h:47
geo::View_t dt::View::GeoView ( ) const
inline

Definition at line 26 of file View.h.

References fGeoView.

Referenced by dt::DiscreteTracker::BestSeed().

26 {return fGeoView;}
geo::View_t fGeoView
Definition: View.h:43
std::set<unsigned int> dt::View::GetPlanes ( ) const
inline

Definition at line 29 of file View.h.

References AdjacentPlane(), getBrightness::cell, Channel(), dir, febshutoff_auto::end, fPlanes, MakeChunkCombos(), NextPlane(), Outside(), NDAPDHVSetting::plane, and PrevPlane().

29 {return fPlanes;}
std::set< unsigned int > fPlanes
Definition: View.h:49
std::vector< Chunk > dt::View::MakeChunkCombos ( int  plane,
int  begin,
int  end 
) const
protected

Definition at line 184 of file View.cxx.

References ana::assert(), Channel(), make_associated_cosmic_defs::chunk, febshutoff_auto::end, hits(), MECModelEnuComparisons::i, calib::j, dt::Channel::kDead, dt::Channel::kHit, make_pair(), art::PtrVector< T >::push_back(), runNovaSAM::ret, moon_position_table_new3::second, and dt::Channel::Type().

Referenced by GetPlanes(), and MakeChunks().

186  {
187  std::vector<Chunk> ret;
188 
189  assert(begin < end);
190 
191  // Pairs of hit cell and extremal neighbouring dead cell, ordered low to high
192  std::vector<std::pair<int, int> > lows, highs;
193 
194  // Every hit cell that has a boundary below, and every one with a boundary above
195  for(int k = begin; k < end; ++k){
196  const Channel::Type_t here = Channel(plane, k).Type();
197  const Channel::Type_t below = Channel(plane, k-1).Type();
198  const Channel::Type_t above = Channel(plane, k+1).Type();
199 
200  if(here == Channel::kHit && (k == begin || below == Channel::kDead)){
201  int lower = k;
202  // Run the dead cell along until we find the end of the dead region
203  while(Channel(plane, lower-1).Type() == Channel::kDead && lower-1 >= begin) --lower;
204  lows.push_back(std::make_pair(lower, k));
205  }
206 
207  if(here == Channel::kHit && (k == end-1 || above == Channel::kDead)){
208  int higher = k;
209  while(Channel(plane, higher+1).Type() == Channel::kDead && higher+1 < end) ++higher;
210  highs.push_back(std::make_pair(k, higher));
211  }
212  } // end for k
213 
214 
215  // Every combination of those starting and stopping points
216  for(unsigned int i = 0; i < lows.size(); ++i){
217  for(unsigned int j = 0; j < highs.size(); ++j){
218  if(lows[i].second > highs[j].first) continue;
219 
221  for(int k = lows[i].second; k <= highs[j].first; ++k){
222  if(Channel(plane, k).Type() == Channel::kHit)
223  hits.push_back(Channel(plane, k).GetHit());
224  }
225 
226  for(bool up: {false, true}){
227  Chunk chunk;
228  if(up) chunk = Chunk(plane, lows[i].first, lows[i].second, highs[j].first, highs[j].second, up, hits);
229  else chunk = Chunk(plane, highs[j].first, highs[j].second, lows[i].first, lows[i].second, up, hits);
230 
231  ret.push_back(chunk);
232  } // end for up
233  } // end for i
234  } // end for j
235 
236 
237  // Also, make a chunk for every contiguous block of dead channels. A track
238  // can go through these without needing to hit the live cells
239  // adjacent. Hopefully the scoring system weighting real hits higher means
240  // this won't cause problems.
241  for(int i = begin; i < end; ++i){
242  if(Channel(plane, i).Type() != Channel::kDead) continue;
243  const int from = i;
244  for(; i < end; ++i){
245  if(Channel(plane, i).Type() != Channel::kDead) break;
246  }
247  const int to = i-1;
248 
249  for(bool up: {false, true}){
250  const Chunk chunk(plane, from, to, from, to, up,
252  ret.push_back(chunk);
253  }
254  }
255 
256  assert(!ret.empty());
257  return ret;
258  }
dt::Channel Channel(int plane, int cell) const
Definition: View.cxx:128
Type_t Type() const
Definition: Channel.cxx:45
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
void hits()
Definition: readHits.C:15
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
const double j
Definition: BetheBloch.cxx:29
assert(nhit_max >=nhit_nbins)
View::ChunkMap dt::View::MakeChunks ( ) const

Definition at line 148 of file View.cxx.

References getBrightness::cell, cellMax, Channel(), make_goodruns_defs::chunks, fChans, fMinCell, fPlanes, it, dt::Channel::kDead, dt::Channel::kHit, MakeChunkCombos(), NDAPDHVSetting::plane, and dt::Channel::Type().

Referenced by dt::DiscreteTracker::BestSeed(), and dt::DiscreteTracker::RecoDiscrete().

149  {
150  ChunkMap chunks_map;
151 
152  for(std::set<unsigned int>::iterator it = fPlanes.begin();
153  it != fPlanes.end(); ++it){
154  const int plane = *it;
155 
156  bool inside = false;
157  int begin = -1;
158 
159  const unsigned int cellMax = fMinCell+fChans[plane].size();
160  for(unsigned int cell = fMinCell; cell < cellMax; ++cell){
161  const Channel::Type_t type = Channel(plane, cell).Type();
162  if(!inside && (type == Channel::kHit || type == Channel::kDead)){
163  inside = true;
164  begin = cell;
165  }
166  if(inside && (type != Channel::kHit && type != Channel::kDead)){
167  inside = false;
168  std::vector<Chunk> chunks = MakeChunkCombos(plane, begin, cell);
169  chunks_map[plane].insert(chunks_map[plane].begin(),
170  chunks.begin(), chunks.end());
171  }
172  } // end for cell
173  if(inside){
174  std::vector<Chunk> chunks = MakeChunkCombos(plane, begin, cellMax);
175  chunks_map[plane].insert(chunks_map[plane].begin(),
176  chunks.begin(), chunks.end());
177  }
178  } // end for it (plane)
179 
180  return chunks_map;
181  }
set< int >::iterator it
dt::Channel Channel(int plane, int cell) const
Definition: View.cxx:128
Type_t Type() const
Definition: Channel.cxx:45
std::vector< Chunk > MakeChunkCombos(int plane, int begin, int end) const
Definition: View.cxx:184
std::map< int, std::vector< Chunk > > ChunkMap
Definition: View.h:27
std::set< unsigned int > fPlanes
Definition: View.h:49
unsigned int fMinCell
Definition: View.h:45
const int cellMax
std::vector< std::vector< dt::Channel > > fChans
Should access this via Channel function.
Definition: View.h:47
int dt::View::NextPlane ( unsigned int  plane) const

Definition at line 111 of file View.cxx.

References fPlanes, and it.

Referenced by AdjacentPlane(), dt::DiscreteTracker::BestSeed(), and GetPlanes().

112  {
113  std::set<unsigned int>::iterator it = fPlanes.find(plane);
114  if(it == fPlanes.end()) return -1;
115  ++it;
116  if(it == fPlanes.end()) return -1;
117  return *it;
118  }
set< int >::iterator it
std::set< unsigned int > fPlanes
Definition: View.h:49
bool dt::View::Outside ( int  plane,
int  cell 
) const
protected

Definition at line 261 of file View.cxx.

References fChans, fMinCell, makeTrainCVSamples::int, and gen_hdf5record::size.

Referenced by Channel(), and GetPlanes().

262  {
263  return (plane < 0 || cell < int(fMinCell) ||
264  plane >= int(fChans.size()) ||
265  cell-int(fMinCell) >= int(fChans[plane].size()));
266  }
unsigned int fMinCell
Definition: View.h:45
std::vector< std::vector< dt::Channel > > fChans
Should access this via Channel function.
Definition: View.h:47
int dt::View::PrevPlane ( unsigned int  plane) const

Definition at line 101 of file View.cxx.

References fPlanes, and it.

Referenced by AdjacentPlane(), and GetPlanes().

102  {
103  std::set<unsigned int>::iterator it = fPlanes.find(plane);
104  if(it == fPlanes.end()) return -1;
105  if(it == fPlanes.begin()) return -1;
106  --it;
107  return *it;
108  }
set< int >::iterator it
std::set< unsigned int > fPlanes
Definition: View.h:49

Member Data Documentation

std::vector<std::vector<dt::Channel> > dt::View::fChans
protected

Should access this via Channel function.

Definition at line 47 of file View.h.

Referenced by Channel(), MakeChunks(), Outside(), and View().

geo::View_t dt::View::fGeoView
protected

Definition at line 43 of file View.h.

Referenced by GeoView(), and View().

unsigned int dt::View::fMinCell
protected

Definition at line 45 of file View.h.

Referenced by Channel(), MakeChunks(), Outside(), and View().

std::set<unsigned int> dt::View::fPlanes
protected

Definition at line 49 of file View.h.

Referenced by GetPlanes(), MakeChunks(), NextPlane(), PrevPlane(), and View().


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