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

Public Member Functions

 ROIFromDecoder (const fhicl::ParameterSet &pset)
 
 ~ROIFromDecoder ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void initializeHistograms (art::TFileDirectory &) override
 
void FindROIs (const art::Event &, const ArrayFloat &, const std::vector< raw::ChannelID_t > &, const geo::PlaneID &, ArrayFloat &, ArrayBool &) override
 
- Public Member Functions inherited from icarus_tool::IROILocator
virtual ~IROILocator () noexcept=default
 

Private Types

using TPCIDToLabelMap = std::map< geo::TPCID, std::string >
 

Private Attributes

TPCIDToLabelMap fTPCIDToLabelMap
 Translate from TPCID to a substring. More...
 
std::vector< art::InputTag > fROILabelVec
 List of input files to search. More...
 
const geo::GeometryCorefGeometry = lar::providerFrom<geo::Geometry>()
 

Additional Inherited Members

- Public Types inherited from icarus_tool::IROILocator
using VectorBool = std::vector< bool >
 
using VectorFloat = std::vector< float >
 
using ArrayBool = std::vector< VectorBool >
 
using ArrayFloat = std::vector< VectorFloat >
 
using PlaneIDVec = std::vector< geo::PlaneID >
 

Detailed Description

Definition at line 27 of file ROIFromDecoder_tool.cc.

Member Typedef Documentation

using icarus_tool::ROIFromDecoder::TPCIDToLabelMap = std::map<geo::TPCID,std::string>
private

Definition at line 41 of file ROIFromDecoder_tool.cc.

Constructor & Destructor Documentation

icarus_tool::ROIFromDecoder::ROIFromDecoder ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 53 of file ROIFromDecoder_tool.cc.

54 {
55  std::cout << "*** In ROIFromDecoder constructor ***" << std::endl;
56  configure(pset);
57 }
void configure(const fhicl::ParameterSet &pset) override
BEGIN_PROLOG could also be cout
icarus_tool::ROIFromDecoder::~ROIFromDecoder ( )

Definition at line 59 of file ROIFromDecoder_tool.cc.

60 {
61 }

Member Function Documentation

void icarus_tool::ROIFromDecoder::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Implements icarus_tool::IROILocator.

Definition at line 63 of file ROIFromDecoder_tool.cc.

64 {
65  // Start by recovering the parameters
66  fROILabelVec = pset.get<std::vector<art::InputTag>>("ROILabelVec", {""});
67 
68  // Build our map
69  fTPCIDToLabelMap[geo::TPCID(0,0)] = "EE";
70  fTPCIDToLabelMap[geo::TPCID(0,1)] = "EE";
71  fTPCIDToLabelMap[geo::TPCID(0,2)] = "EW";
72  fTPCIDToLabelMap[geo::TPCID(0,3)] = "EW";
73  fTPCIDToLabelMap[geo::TPCID(1,0)] = "WE";
74  fTPCIDToLabelMap[geo::TPCID(1,1)] = "WE";
75  fTPCIDToLabelMap[geo::TPCID(1,2)] = "WW";
76  fTPCIDToLabelMap[geo::TPCID(1,3)] = "WW";
77 
78  return;
79 }
std::vector< art::InputTag > fROILabelVec
List of input files to search.
TPCIDToLabelMap fTPCIDToLabelMap
Translate from TPCID to a substring.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void icarus_tool::ROIFromDecoder::FindROIs ( const art::Event &  event,
const ArrayFloat inputImage,
const std::vector< raw::ChannelID_t > &  channelVec,
const geo::PlaneID planeID,
ArrayFloat output,
ArrayBool outputROIs 
)
overridevirtual

Implements icarus_tool::IROILocator.

Definition at line 81 of file ROIFromDecoder_tool.cc.

82 {
83  // First thing is find the correct data product to recover ROIs
84  TPCIDToLabelMap::const_iterator tpcItr = fTPCIDToLabelMap.find(planeID.asTPCID());
85 
86  if (tpcItr == fTPCIDToLabelMap.end())
87  {
88  std::cout << "Can't happen? for planeID: " << planeID << std::endl;
89  return;
90  }
91 
92  art::InputTag roiLabel("");
93 
94  for(const auto& tag : fROILabelVec)
95  {
96  if (tag.instance().find(tpcItr->second) != std::string::npos)
97  {
98  roiLabel = tag;
99  break;
100  }
101  }
102 
103  if (roiLabel != "")
104  {
105  // do stuff here
106 
107  // Read in the collection of full length deconvolved waveforms
108  // Note we assume this list is sorted in increasing channel number!
109  art::Handle< std::vector<recob::Wire>> wireVecHandle;
110 
111  event.getByLabel(roiLabel, wireVecHandle);
112 
113  // The first task is to build a mapping between channel and ROIs from the input data product.
114  // The input data product will contain information for every plane in a physical TPC... unfortunately, we only want a single plane within
115  // a logical TPC... so we need to loop through to find what we want
116  std::unordered_map<raw::ChannelID_t,const recob::Wire*> channelToWireMap;
117 
118  for(const auto& wireData : *wireVecHandle)
119  {
120  std::vector<geo::WireID> wireIDVec = fGeometry->ChannelToWire(wireData.Channel());
121 
122  for(const auto& wireID : wireIDVec)
123  {
124  if (wireID.asPlaneID() != planeID) continue;
125 
126  if (wireID.Wire > outputROIs.size())
127  {
128  std::cout << "#################################### Wire out of bounds! Wire: " << wireID.Wire << ", max: " << outputROIs.size() << " #################" << std::endl;
129  continue;
130  }
131 
132  channelToWireMap[wireData.Channel()] = &wireData;
133  }
134  }
135 
136  // Now we loop through the input image channels and make the new ROIs
137  for(size_t channelIdx = 0; channelIdx < channelVec.size(); channelIdx++)
138  {
139  raw::ChannelID_t channel = channelVec[channelIdx];
140 
141  std::unordered_map<raw::ChannelID_t,const recob::Wire*>::const_iterator wireItr = channelToWireMap.find(channel);
142 
143  if (wireItr != channelToWireMap.end())
144  {
145  const recob::Wire& wireData = *(wireItr->second);
146 
147  // Get the WireIDs (again)
148  std::vector<geo::WireID> wireIDVec = fGeometry->ChannelToWire(channel);
149 
150  for(const auto& wireID : wireIDVec)
151  {
152  if (wireID.asPlaneID() != planeID) continue;
153 
154  // Recover this wire's output vector
155  VectorBool& channelData = outputROIs[wireID.Wire];
156 
157  // What we need to do is find the ROIs in the input wire data and then translate to the output
158  const recob::Wire::RegionsOfInterest_t signalROIs = wireData.SignalROI();
159 
160  for(const auto& range : signalROIs.get_ranges())
161  {
162  size_t startTick = range.begin_index();
163  size_t roiLen = range.data().size();
164  size_t stopTick = startTick + roiLen;
165 
166  if (startTick > channelData.size())
167  {
168  std::cout << "*** ROI decoder has start tick larger than output array, start: " << startTick << ", array size: " << channelData.size() << std::endl;
169  continue;
170  }
171 
172  if (stopTick > channelData.size())
173  {
174  std::cout << "*** ROI decoder has ROI length larger than output array, start: " << startTick << ", end: " << stopTick << ", array size: " << channelData.size() << std::endl;
175  continue;
176  }
177 
178  std::fill(channelData.begin() + startTick, channelData.begin() + stopTick, true);
179  }
180 
181  if (planeID.Cryostat == 0 && planeID.TPC == 0 && planeID.Plane == 0) std::cout << std::endl;
182  }
183  }
184  else
185  {
186  std::cout << "*** Not finding ROI information for channel: " << channel << std::endl;
187  }
188  }
189  }
190 
191  return;
192 }
std::vector< bool > VectorBool
Definition: IROILocator.h:34
size_type size() const
Returns the size of the vector.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
std::vector< art::InputTag > fROILabelVec
List of input files to search.
TPCIDToLabelMap fTPCIDToLabelMap
Translate from TPCID to a substring.
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:446
const geo::GeometryCore * fGeometry
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
BEGIN_PROLOG could also be cout
void icarus_tool::ROIFromDecoder::initializeHistograms ( art::TFileDirectory &  )
inlineoverridevirtual

Implements icarus_tool::IROILocator.

Definition at line 35 of file ROIFromDecoder_tool.cc.

35 {return;}

Member Data Documentation

const geo::GeometryCore* icarus_tool::ROIFromDecoder::fGeometry = lar::providerFrom<geo::Geometry>()
private

Definition at line 48 of file ROIFromDecoder_tool.cc.

std::vector<art::InputTag> icarus_tool::ROIFromDecoder::fROILabelVec
private

List of input files to search.

Definition at line 46 of file ROIFromDecoder_tool.cc.

TPCIDToLabelMap icarus_tool::ROIFromDecoder::fTPCIDToLabelMap
private

Translate from TPCID to a substring.

Definition at line 43 of file ROIFromDecoder_tool.cc.


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