Public Member Functions | Private Member Functions | Private Attributes | List of all members
cvn::PixelMapWireProducer Class Reference

Producer algorithm for PixelMap, input to CVN neural net. More...

#include <PixelMapWireProducer.h>

Public Member Functions

 PixelMapWireProducer (unsigned int nWire, unsigned int nTdc, double tRes, double threshold=0.)
 
 PixelMapWireProducer ()
 
void SetUnwrapped (unsigned short unwrap)
 
void SetProtoDUNE ()
 
Boundary DefineBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster)
 Get boundaries for pixel map representation of cluster. More...
 
unsigned int NROI ()
 
void GetDUNEGlobalWire (unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
 Function to convert to a global unwrapped wire number. More...
 
void GetDUNEGlobalWireTDC (detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
 
void GetDUNE10ktGlobalWireTDC (detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
 
void GetProtoDUNEGlobalWire (unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
 
void GetProtoDUNEGlobalWireTDC (unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, double &globalTDC, unsigned int &globalPlane) const
 
void GetDUNEVertDrift3ViewGlobalWire (unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
 
unsigned int NWire () const
 
unsigned int NTdc () const
 
double TRes () const
 
PixelMap CreateMap (detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Wire > > &slice)
 
PixelMap CreateMap (detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &slice)
 
PixelMap CreateMapGivenBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster, const Boundary &bound)
 

Private Member Functions

double _getIntercept (geo::WireID wireid) const
 
void _cacheIntercepts ()
 

Private Attributes

unsigned int fNWire
 Number of wires, length for pixel maps. More...
 
unsigned int fNTdc
 Number of tdcs, width of pixel map. More...
 
double fTRes
 Timing resolution for pixel map. More...
 
double fThreshold
 charge threshold for each time tick, below which isn't added to pixel map More...
 
unsigned short fUnwrapped
 Use unwrapped pixel maps? More...
 
bool fProtoDUNE
 Do we want to use this for particle extraction from protoDUNE? More...
 
unsigned int fTotHits
 How many ROIs above threshold? More...
 
geo::GeometryCore const * fGeometry
 
std::vector< double > fVDPlane0
 
std::vector< double > fVDPlane1
 

Detailed Description

Producer algorithm for PixelMap, input to CVN neural net.

Definition at line 29 of file PixelMapWireProducer.h.

Constructor & Destructor Documentation

cvn::PixelMapWireProducer::PixelMapWireProducer ( unsigned int  nWire,
unsigned int  nTdc,
double  tRes,
double  threshold = 0. 
)

Definition at line 31 of file PixelMapWireProducer.cxx.

31  :
32  fNWire(nWire),
33  fNTdc(nTdc),
34  fTRes(tRes),
35  fThreshold(threshold),
36  fUnwrapped(2),
37  fProtoDUNE(false),
38  fTotHits(0)
39  {
40 
42  if (fGeometry->DetectorName().find("dunevd10kt_3view") != std::string::npos)
44 
45  }
unsigned short fUnwrapped
Use unwrapped pixel maps?
double fTRes
Timing resolution for pixel map.
double fThreshold
charge threshold for each time tick, below which isn&#39;t added to pixel map
unsigned int fNTdc
Number of tdcs, width of pixel map.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
unsigned int fTotHits
How many ROIs above threshold?
unsigned int fNWire
Number of wires, length for pixel maps.
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
geo::GeometryCore const * fGeometry
cvn::PixelMapWireProducer::PixelMapWireProducer ( )

Definition at line 47 of file PixelMapWireProducer.cxx.

48  {
50  if (fGeometry->DetectorName().find("dunevd10kt_3view") != std::string::npos)
52  }
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
geo::GeometryCore const * fGeometry

Member Function Documentation

void cvn::PixelMapWireProducer::_cacheIntercepts ( )
private

Definition at line 165 of file PixelMapWireProducer.cxx.

165  {
166 
167  // double spacing = 0.847;
168  for(int plane = 0; plane < 2; plane++){
169 
170  int nCRM_row = 6;
171  for(int diag_tpc = 0; diag_tpc < nCRM_row; diag_tpc++){
172 
173  unsigned int nWiresTPC = fGeometry->Nwires(plane, 0, 0);
174  int tpc_id = plane == 0 ? (nCRM_row+1)*diag_tpc : (nCRM_row-1)*(nCRM_row-diag_tpc);
175  geo::WireID start = geo::WireID(0, tpc_id, plane, 0);
176  geo::WireID end = geo::WireID(0, tpc_id, plane, nWiresTPC-1);
177 
178  double start_intercept = _getIntercept(start);
179  double end_intercept = _getIntercept(end);
180  if(plane == 0){
181  fVDPlane0.push_back(start_intercept);
182  fVDPlane0.push_back(end_intercept);
183  }
184  else{
185  fVDPlane1.push_back(_getIntercept(end));
186  fVDPlane1.push_back(_getIntercept(start));
187  }
188  }
189 
190  }
191  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::vector< double > fVDPlane0
std::vector< double > fVDPlane1
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
double _getIntercept(geo::WireID wireid) const
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
geo::GeometryCore const * fGeometry
double cvn::PixelMapWireProducer::_getIntercept ( geo::WireID  wireid) const
private

Definition at line 152 of file PixelMapWireProducer.cxx.

153  {
154  const geo::WireGeo* pwire = fGeometry->WirePtr(wireid);
156  double slope = 0.;
157  if(!pwire->isVertical()) slope = pwire->TanThetaZ();
158 
159  double intercept = center.Y() - slope*center.Z();
160  if(wireid.Plane == 2) intercept = 0.;
161 
162  return intercept;
163  }
bool isVertical() const
Returns if this wire is vertical (theta_z ~ pi/2)
Definition: WireGeo.h:276
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
geo::GeometryCore const * fGeometry
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
double TanThetaZ() const
Definition: WireGeo.h:266
def center(depos, point)
Definition: depos.py:117
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.
PixelMap cvn::PixelMapWireProducer::CreateMap ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< recob::Wire > > &  slice 
)

Definition at line 54 of file PixelMapWireProducer.cxx.

56  {
57  std::vector<const recob::Wire*> newCluster;
58  for(const art::Ptr<recob::Wire> hit : cluster){
59  newCluster.push_back(hit.get());
60  }
61  return CreateMap(detProp, newCluster);
62  }
PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Wire > > &slice)
Cluster finding and building.
Detector simulation of raw signals on wires.
PixelMap cvn::PixelMapWireProducer::CreateMap ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const recob::Wire * > &  slice 
)

Definition at line 64 of file PixelMapWireProducer.cxx.

66  {
67  Boundary bound = DefineBoundary(detProp, cluster);
68  return CreateMapGivenBoundary(detProp, cluster, bound);
69  }
Boundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster)
Get boundaries for pixel map representation of cluster.
Cluster finding and building.
PixelMap CreateMapGivenBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster, const Boundary &bound)
PixelMap cvn::PixelMapWireProducer::CreateMapGivenBoundary ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const recob::Wire * > &  cluster,
const Boundary bound 
)

Definition at line 71 of file PixelMapWireProducer.cxx.

74  {
75 
76  PixelMap pm(fNWire, fNTdc, bound);
77 
78  for(size_t iHit = 0; iHit < cluster.size(); ++iHit)
79  {
80 
81  const recob::Wire* reco_wire = cluster[iHit];
82  auto ROIs = reco_wire->SignalROI();
83  if(!(ROIs.get_ranges().size())) continue;
84 
85  std::vector<geo::WireID> wireids = fGeometry->ChannelToWire(reco_wire->Channel());
86  if(!wireids.size()) continue;
87  geo::WireID wireid = wireids[0];
88 
89  if(wireids.size() > 1){
90  for(auto iwire : wireids)
91  if(iwire.Plane == reco_wire->View()) wireid = iwire;
92  }
93  unsigned int tempWire = wireid.Wire;
94  unsigned int tempPlane = wireid.Plane;
95 
96  if(!fProtoDUNE){
97  if(fUnwrapped == 1){
98  if (fGeometry->DetectorName().find("dunevd10kt_3view") != std::string::npos){
99  GetDUNEVertDrift3ViewGlobalWire(wireid.Wire, wireid.Plane,wireid.TPC,tempWire,tempPlane);
100  }
101  }
102  else if(fUnwrapped == 2){
103  // Old method that has problems with the APA crossers, kept for old times' sake
104  GetDUNEGlobalWire(wireid.Wire,wireid.Plane,wireid.TPC,tempWire,tempPlane);
105  }
106  }
107  else{
108  GetProtoDUNEGlobalWire(wireid.Wire,wireid.Plane,wireid.TPC,tempWire,tempPlane);
109  }
110 
111  for(auto iROI = ROIs.begin_range(); iROI != ROIs.end_range(); ++iROI){
112  auto& ROI = *iROI;
113  for(int tick = ROI.begin_index(); tick < (int)ROI.end_index(); tick++){
114 
115  double temptdc = (double)tick;
116  if(!(ROI[tick] > fThreshold)) continue;
117  // Leigh: Simple modification to unwrap the collection view wire plane
118  if(!fProtoDUNE){
119  if(fUnwrapped == 1){
120  // Jeremy: Autodetect geometry for DUNE 10kt module. Is this a bad idea??
121  if (fGeometry->DetectorName() == "dune10kt_v1") {
122  if (wireid.TPC%6 == 0 or wireid.TPC%6 == 5) continue; // Skip dummy TPCs in 10kt module
123  GetDUNE10ktGlobalWireTDC(detProp, wireid.Wire,(double)tick,
124  wireid.Plane,wireid.TPC,tempWire,tempPlane,temptdc);
125  }
126  else if (fGeometry->DetectorName().find("dunevd10kt_3view") == std::string::npos){
127  GetDUNEGlobalWireTDC(detProp, wireid.Wire,(double)tick,
128  wireid.Plane,wireid.TPC,tempWire,tempPlane,temptdc);
129  }
130  }
131  }
132  const double pe = ROI[tick];
133  const unsigned int wire = tempWire;
134  const unsigned int wirePlane = tempPlane;
135  const double tdc = temptdc;
136  pm.Add(wire, tdc, wirePlane, pe);
137  }
138  }
139 
140  }
141  pm.SetTotHits(fTotHits);
142  return pm;
143  }
void GetDUNE10ktGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
unsigned short fUnwrapped
Use unwrapped pixel maps?
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
double fThreshold
charge threshold for each time tick, below which isn&#39;t added to pixel map
void GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
void GetProtoDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
unsigned int fNTdc
Number of tdcs, width of pixel map.
geo::View_t View() const
Returns the view the channel belongs to.
Definition: Wire.h:230
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
void GetDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
Function to convert to a global unwrapped wire number.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:231
unsigned int fTotHits
How many ROIs above threshold?
unsigned int fNWire
Number of wires, length for pixel maps.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
geo::GeometryCore const * fGeometry
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
void GetDUNEGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
Boundary cvn::PixelMapWireProducer::DefineBoundary ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const recob::Wire * > &  cluster 
)

Get boundaries for pixel map representation of cluster.

Definition at line 193 of file PixelMapWireProducer.cxx.

195  {
196 
197  std::vector<int> wire_0;
198  std::vector<int> wire_1;
199  std::vector<int> wire_2;
200 
201  std::vector<double> twire_0;
202  std::vector<double> twire_1;
203  std::vector<double> twire_2;
204 
205  double tsum_0 = 0., tsum_1 = 0., tsum_2 = 0.;
206  int total_t0 = 0, total_t1 = 0, total_t2 = 0;
207 
208  for(size_t iHit = 0; iHit < cluster.size(); ++iHit)
209  {
210  const recob::Wire* reco_wire = cluster[iHit];
211  auto ROIs = reco_wire->SignalROI();
212  if(!(ROIs.get_ranges().size())) continue;
213 
214  std::vector<geo::WireID> wireids = fGeometry->ChannelToWire(reco_wire->Channel());
215  if(!wireids.size()) continue;
216  geo::WireID wireid = wireids[0];
217 
218  if(wireids.size() > 1){
219  for(auto iwire : wireids)
220  if(iwire.Plane == reco_wire->View()) wireid = iwire;
221  }
222  unsigned int globalWire = wireid.Wire;
223  unsigned int globalPlane = wireid.Plane;
224 
225  if(!fProtoDUNE){
226  if(fUnwrapped == 1){
227  if (fGeometry->DetectorName().find("dunevd10kt_3view") != std::string::npos){
228  GetDUNEVertDrift3ViewGlobalWire(wireid.Wire, wireid.Plane,wireid.TPC,globalWire,globalPlane);
229  }
230  }
231  else if(fUnwrapped == 2){
232  // Old method that has problems with the APA crossers, kept for old times' sake
233  GetDUNEGlobalWire(wireid.Wire,wireid.Plane,wireid.TPC,globalWire,globalPlane);
234  }
235  }
236  else{
237  GetProtoDUNEGlobalWire(wireid.Wire,wireid.Plane,wireid.TPC,globalWire,globalPlane);
238  }
239 
240  // bool none_threshold = true;
241  // int min_tick = 20000;
242  for(auto iROI = ROIs.begin_range(); iROI != ROIs.end_range(); ++iROI){
243  auto& ROI = *iROI;
244  bool none_threshold = true;
245  int min_tick = 20000;
246  for(int tick = ROI.begin_index(); tick < (int)ROI.end_index(); tick++){
247 
248  double globalTime = (double)tick;
249  none_threshold = none_threshold && !(ROI[tick] > fThreshold);
250  if(!(ROI[tick] > fThreshold)) continue;
251  if(tick < min_tick) min_tick = tick;
252  // Leigh: Simple modification to unwrap the collection view wire plane
253  if(!fProtoDUNE){
254  if(fUnwrapped == 1){
255  // Jeremy: Autodetect geometry for DUNE 10kt module. Is this a bad idea??
256  if (fGeometry->DetectorName() == "dune10kt_v1") {
257  if (wireid.TPC%6 == 0 or wireid.TPC%6 == 5) continue; // Skip dummy TPCs in 10kt module
258  GetDUNE10ktGlobalWireTDC(detProp, wireid.Wire,(double)tick,
259  wireid.Plane,wireid.TPC,globalWire,globalPlane,globalTime);
260  }
261  else if (fGeometry->DetectorName().find("dunevd10kt_3view") == std::string::npos){
262  GetDUNEGlobalWireTDC(detProp, wireid.Wire,(double)tick,
263  wireid.Plane,wireid.TPC,globalWire,globalPlane,globalTime);
264  }
265  }
266  }
267 
268  if(globalPlane==0){
269  tsum_0 += globalTime;
270  total_t0++;
271  }
272  if(globalPlane==1){
273  tsum_1 += globalTime;
274  total_t1++;
275  }
276  if(globalPlane==2){
277  tsum_2 += globalTime;
278  total_t2++;
279  }
280  }
281  if(!none_threshold){
282  if(globalPlane==0){
283  wire_0.push_back(globalWire);
284  twire_0.push_back((double)min_tick);
285  }
286  if(globalPlane==1){
287  wire_1.push_back(globalWire);
288  twire_1.push_back((double)min_tick);
289  }
290  if(globalPlane==2){
291  wire_2.push_back(globalWire);
292  twire_2.push_back((double)min_tick);
293  }
294  }
295  }
296 
297  // if(!none_threshold){
298  // if(globalPlane==0){
299  // wire_0.push_back(globalWire);
300  // twire_0.push_back((double)min_tick);
301  // }
302  // if(globalPlane==1){
303  // wire_1.push_back(globalWire);
304  // twire_1.push_back((double)min_tick);
305  // }
306  // if(globalPlane==2){
307  // wire_2.push_back(globalWire);
308  // twire_2.push_back((double)min_tick);
309  // }
310  // }
311 
312  }
313  double tmean_0 = tsum_0/total_t0;
314  double tmean_1 = tsum_1/total_t1;
315  double tmean_2 = tsum_2/total_t2;
316 
317 
318  //auto maxwireelement_0= std::max_element(wire_0.begin(), wire_0.end());
319  //std::cout<<"maxwire 0: "<<*maxwireelement_0<<std::endl;
320  //auto maxwireelement_1= std::max_element(wire_1.begin(), wire_1.end());
321  //std::cout<<"maxwire 1: "<<*maxwireelement_1<<std::endl;
322  //auto maxwireelement_2= std::max_element(wire_2.begin(), wire_2.end());
323  //std::cout<<"maxwire 2: "<<*maxwireelement_2<<std::endl;
324 
325 
326  std::vector<int> bwire_0;
327  std::vector<int> bwire_1;
328  std::vector<int> bwire_2;
329  for(int i = 0; i < (int)wire_0.size(); i++){
330  double t = twire_0[i];
331  if(std::abs(t-tmean_0) < (double)fTRes)
332  bwire_0.push_back(wire_0[i]);
333  }
334  for(int i = 0; i < (int)wire_1.size(); i++){
335  double t = twire_1[i];
336  if(std::abs(t-tmean_1) < (double)fTRes)
337  bwire_1.push_back(wire_1[i]);
338  }
339  for(int i = 0; i < (int)wire_2.size(); i++){
340  double t = twire_2[i];
341  if(std::abs(t-tmean_2) < (double)fTRes)
342  bwire_2.push_back(wire_2[i]);
343  }
344 
345  std::cout << "Boundary wire vector sizes: " << bwire_0.size() << ", " << bwire_1.size() << ", " << bwire_2.size() << std::endl;
346 
347  int minwire_0 = 0;
348  int minwire_1 = 0;
349  int minwire_2 = 0;
350  auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
351  auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
352  auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
353 
354  if(bwire_0.size() > 0) { minwire_0 = *minwireelement_0-1; std::cout<<"minwire 0: "<<(*minwireelement_0) <<std::endl;}
355  if(bwire_1.size() > 0) { minwire_1 = *minwireelement_1-1; std::cout<<"minwire 1: "<<(*minwireelement_1) <<std::endl;}
356  if(bwire_2.size() > 0) { minwire_2 = *minwireelement_2-1; std::cout<<"minwire 2: "<<(*minwireelement_2) <<std::endl;}
357 
358  fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
359 
360  Boundary bound(fNWire,fTRes,minwire_0,minwire_1,minwire_2,tmean_0,tmean_1,tmean_2);
361 
362  return bound;
363  }
void GetDUNE10ktGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
unsigned short fUnwrapped
Use unwrapped pixel maps?
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
double globalTime
double fTRes
Timing resolution for pixel map.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
double fThreshold
charge threshold for each time tick, below which isn&#39;t added to pixel map
void GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
void GetProtoDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
geo::View_t View() const
Returns the view the channel belongs to.
Definition: Wire.h:230
T abs(T value)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
void GetDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
Function to convert to a global unwrapped wire number.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:231
unsigned int fTotHits
How many ROIs above threshold?
unsigned int fNWire
Number of wires, length for pixel maps.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
geo::GeometryCore const * fGeometry
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
void GetDUNEGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
QTextStream & endl(QTextStream &s)
void cvn::PixelMapWireProducer::GetDUNE10ktGlobalWireTDC ( detinfo::DetectorPropertiesData const &  detProp,
unsigned int  localWire,
double  localTDC,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane,
double &  globalTDC 
) const

Definition at line 467 of file PixelMapWireProducer.cxx.

470  {
471  unsigned int nWiresTPC = 400;
472  unsigned int wireGap = 4;
473  double driftLen = fGeometry->TPC(tpc).DriftDistance();
474  double apaLen = fGeometry->TPC(tpc).Width() - fGeometry->TPC(tpc).ActiveWidth();
475  double driftVel = detProp.DriftVelocity();
476  unsigned int drift_size = (driftLen / driftVel) * 2; // Time in ticks to cross a TPC
477  unsigned int apa_size = 4*(apaLen / driftVel) * 2; // Width of the whole APA in TDC
478 
479 
480  globalWire = 0;
481  globalPlane = 0;
482 
483  // Collection plane has more wires
484  if(plane == 2){
485  nWiresTPC = 480;
486  wireGap = 5;
487  globalPlane = 2;
488  }
489 
490  bool includeZGap = true;
491  if(includeZGap) nWiresTPC += wireGap;
492 
493  // 10kt has four real TPCs and two dummies in each slice
494  //
495  // |--|-----|-----|-----|-----|--| / /
496  // y ^ |11| 10 | 9 | 8 | 7 | 6|/ /
497  // | -| z |--|-----|-----|-----|-----|--| /
498  // | / | 5| 4 | 3 | 2 | 1 | 0| /
499  // x <---|/ |--|-----|-----|-----|-----|--|/
500  // ^ wires ^ ^ wires ^
501  //
502  // We already filtered out the dummies, so we can assume 0->3 as follows:
503  //
504  // |-----|-----|-----|-----| / /
505  // y ^ | 7 | 6 | 5 | 4 |/ /
506  // | -| z |-----|-----|-----|-----| /
507  // | / | 3 | 2 | 1 | 0 | /
508  // x <---|/ |-----|-----|-----|-----|/
509  // ^ wires ^ ^ wires ^
510  //
511 
512  size_t tpc_x = (tpc%6) - 1; // x coordinate in 0->4 range
513  size_t tpc_xy = (tpc%12) - 1; // xy coordinate as 0->3 & 6->9 (converted from 1->4, 7->10)
514  if (tpc_xy > 3) tpc_xy -= 2; // now subtract 2 so it's in the 0->7 range
515 
516  // Induction views depend on the drift direction
517  if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
518  else globalPlane = plane;
519 
520  int offset = 752; // Offset between upper and lower modules in induction views, from Robert & Dorota's code
521  // Second induction plane gets offset from the back of the TPC
522  if (globalPlane != 1) globalWire += (tpc/12)*nWiresTPC;
523  else globalWire += ((300-tpc)/12)*nWiresTPC;
524  // Reverse wires and add offset for upper modules in induction views
525  if (tpc_xy > 3 and globalPlane < 2) globalWire += fGeometry->Nwires(globalPlane, tpc, 0) + offset - localWire;
526  else globalWire += localWire;
527 
528  if (tpc_x % 2 == 0) globalTDC = localTDC;
529  else globalTDC = (2*drift_size) - localTDC;
530  if (tpc_x > 1) globalTDC += 2 * (drift_size + apa_size);
531 
532  } // function PixelMapWireProducer::GetDUNE10ktGlobalWireTDC
double Width() const
Width is associated with x coordinate [cm].
Definition: TPCGeo.h:109
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
geo::GeometryCore const * fGeometry
double DriftDistance() const
Definition: TPCGeo.h:155
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:97
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void cvn::PixelMapWireProducer::GetDUNEGlobalWire ( unsigned int  localWire,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const

Function to convert to a global unwrapped wire number.

Definition at line 365 of file PixelMapWireProducer.cxx.

366  {
367  unsigned int nWiresTPC = 400;
368 
369  globalWire = localWire;
370  globalPlane = 0;
371 
372  // Collection plane has more wires
373  if(plane == 2){
374  nWiresTPC=480;
375  globalPlane = 2;
376  }
377 
378  // Workspace geometry has two drift regions
379  // |-----|-----| / /
380  // y ^ | 3 | 2 |/ /
381  // | -| z |-----|-----| /
382  // | / | 1 | 0 | /
383  // x <---|/ |-----|-----|/
384  //
385 
386  int tpcMod4 = tpc%4;
387 
388  // Induction views depend on the drift direction
389  if(plane < 2){
390  // For drift in negative x direction keep U and V as defined.
391  if(tpcMod4 == 0 || tpcMod4 == 3){
392  globalPlane = plane;
393  }
394  // For drift in positive x direction, swap U and V.
395  else{
396  if(plane == 0) globalPlane = 1;
397  else globalPlane = 0;
398  }
399  }
400 
401  if(globalPlane != 1){
402  globalWire += (tpc/4)*nWiresTPC;
403  }
404  else{
405  globalWire += ((23-tpc)/4)*nWiresTPC;
406  }
407 
408  }
void cvn::PixelMapWireProducer::GetDUNEGlobalWireTDC ( detinfo::DetectorPropertiesData const &  detProp,
unsigned int  localWire,
double  localTDC,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane,
double &  globalTDC 
) const

Definition at line 411 of file PixelMapWireProducer.cxx.

414  {
415 
416  unsigned int nWiresTPC = 400;
417  unsigned int wireGap = 4;
418  double driftLen = fGeometry->TPC(tpc,0).DriftDistance();
419  double apaLen = fGeometry->TPC(tpc,0).Width() - fGeometry->TPC(tpc,0).ActiveWidth();
420  double driftVel = detProp.DriftVelocity();
421  unsigned int drift_size = (driftLen / driftVel) * 2; // Time in ticks to cross a TPC
422  unsigned int apa_size = 4*(apaLen / driftVel) * 2; // Width of the whole APA in TDC
423 
424  globalWire = 0;
425  globalPlane = 0;
426 // int dir = fGeometry->TPC(tpc,0).DetectDriftDirection();
427 
428  // Collection plane has more wires
429  if(plane == 2){
430  nWiresTPC = 480;
431  wireGap = 5;
432  globalPlane = 2;
433  }
434 
435  bool includeZGap = true;
436  if(includeZGap) nWiresTPC += wireGap;
437 
438  // Workspace geometry has two drift regions
439  // |-----|-----| / /
440  // y ^ | 3 | 2 |/ /
441  // | -| z |-----|-----| /
442  // | / | 1 | 0 | /
443  // x <---|/ |-----|-----|/
444  //
445  int tpcMod4 = tpc%4;
446  // Induction views depend on the drift direction
447  if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
448  else globalPlane = plane;
449 
450  int offset = 752; // Offset between upper and lower modules in induction views, from Robert & Dorota's code
451  // Second induction plane gets offset from the back of the TPC
452  if (globalPlane != 1) globalWire += (tpc/4)*nWiresTPC;
453  else globalWire += ((23-tpc)/4)*nWiresTPC;
454  // Reverse wires and add offset for upper modules in induction views
455  // Nitish : what's the difference between Nwires here and nWiresTPC?
456  if (tpcMod4 > 1 and globalPlane < 2) globalWire += fGeometry->Nwires(globalPlane, tpc, 0) + offset - localWire;
457  else globalWire += localWire;
458 
459  if(tpcMod4 == 0 || tpcMod4 == 2){
460  globalTDC = drift_size - localTDC;
461  }
462  else{
463  globalTDC = localTDC + drift_size + apa_size;
464  }
465  }
double Width() const
Width is associated with x coordinate [cm].
Definition: TPCGeo.h:109
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
geo::GeometryCore const * fGeometry
double DriftDistance() const
Definition: TPCGeo.h:155
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:97
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void cvn::PixelMapWireProducer::GetDUNEVertDrift3ViewGlobalWire ( unsigned int  localWire,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const

Definition at line 594 of file PixelMapWireProducer.cxx.

595  {
596  // Preliminary function for VD Geometries (3 View for now)
597  // 1x6x6 -- single drift volume should make things significantly simpler
598 
599  int nCRM_row = 6;
600  // spacing between y-intercepts of parallel wires in a given plane.
601  double spacing = 0.847;
602 
603  globalPlane = plane;
604  unsigned int nWiresTPC = fGeometry->Nwires(globalPlane, tpc, 0);
605 
606  if(globalPlane < 2){
607 
608  geo::WireID wire_id = geo::WireID(0, tpc, globalPlane, localWire);
609  double wire_intercept = _getIntercept(wire_id);
610  double low_bound, upper_bound;
611  int start, end, diag_tpc;
612  // get wires on diagonal CRMs and their intercepts which bound the current wire's intercept
613  if(globalPlane == 0){
614  start = std::lower_bound(fVDPlane0.begin(), fVDPlane0.end(), wire_intercept) - fVDPlane0.begin() - 1;
615  end = std::upper_bound(fVDPlane0.begin(), fVDPlane0.end(), wire_intercept) - fVDPlane0.begin();
616  low_bound = fVDPlane0[start];
617  upper_bound = fVDPlane0[end];
618  diag_tpc = (start/2);
619  }
620  else{
621  end = std::lower_bound(fVDPlane1.begin(), fVDPlane1.end(), wire_intercept) - fVDPlane1.begin() - 1;
622  start = std::upper_bound(fVDPlane1.begin(), fVDPlane1.end(), wire_intercept) - fVDPlane1.begin();
623  low_bound = fVDPlane1[end];
624  upper_bound = fVDPlane1[start];
625  diag_tpc = (nCRM_row-(end/2) - 1);
626  }
627  // if the intercept of the wire is in between two diagonal CRMs, assign it to the diagonal CRM its closest to
628  if((start % 2)^globalPlane){
629 
630  int diag_idx = diag_tpc + !globalPlane;
631  globalWire = (wire_intercept > (low_bound+upper_bound)*0.5) ? (nWiresTPC-1)*diag_idx + !globalPlane : (nWiresTPC-1)*diag_idx + globalPlane;
632  }
633  // otherwise assign it to the closest wire within the same CRM
634  else{
635  int diag_idx = diag_tpc;
636  int offset = globalPlane ? std::round((upper_bound - wire_intercept)/spacing) : std::round((wire_intercept-low_bound)/spacing);
637  globalWire = (nWiresTPC-1)*diag_idx + offset + 1;
638 
639  }
640  }
641  else{
642  int tpc_z = tpc/6;
643  globalWire = localWire + tpc_z*nWiresTPC;
644  }
645 
646  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::vector< double > fVDPlane0
STL namespace.
std::vector< double > fVDPlane1
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
double _getIntercept(geo::WireID wireid) const
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
geo::GeometryCore const * fGeometry
void cvn::PixelMapWireProducer::GetProtoDUNEGlobalWire ( unsigned int  localWire,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const

Definition at line 536 of file PixelMapWireProducer.cxx.

537  {
538  unsigned int nWiresTPC = 400;
539 
540  globalWire = localWire;
541  globalPlane = 0;
542 
543  // Collection plane has more wires
544  if(plane == 2){
545  nWiresTPC=480;
546  globalPlane = 2;
547  }
548 
549  // ProtoDUNE has a central CPA so times are fine
550  // It (annoyingly) has two dummy TPCs on the sides
551  //
552  // y ^ |-|-----|-----|-| /
553  // | -| z | | | | | /
554  // | / |3| 2 | 1 |0| /
555  // x <---|/ |-|-----|-----|-|/
556  //
557 
558  int tpcMod4 = tpc%4;
559  // tpcMod4: 1 for -ve drift, 2 for +ve drift
560  // Induction views depend on the drift direction
561  if(plane < 2){
562  // For drift in negative x direction keep U and V as defined.
563  if(tpcMod4 == 1){
564  globalPlane = plane;
565  }
566  // For drift in positive x direction, swap U and V.
567  else{
568  if(plane == 0) globalPlane = 1;
569  else globalPlane = 0;
570  }
571  }
572 
573  if(globalPlane != 1){
574  globalWire += (tpc/4)*nWiresTPC;
575  }
576  else{
577  globalWire += ((12-tpc)/4)*nWiresTPC;
578  }
579 
580  } // function PixelMapWireProducer::GetProtoDUNEGlobalWire
void cvn::PixelMapWireProducer::GetProtoDUNEGlobalWireTDC ( unsigned int  localWire,
double  localTDC,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
double &  globalTDC,
unsigned int &  globalPlane 
) const

Definition at line 584 of file PixelMapWireProducer.cxx.

586  {
587  // We can just use the existing function to get the global wire & plane
588  // GetProtoDUNEGlobalWire(localWire, plane, tpc, globalWire, globalPlane);
589  GetDUNEGlobalWire(localWire, plane, tpc, globalWire, globalPlane);
590  // Implement additional mirroring here?
591 
592  } // function GetProtoDUNEGlobalWireTDC
void GetDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
Function to convert to a global unwrapped wire number.
unsigned int cvn::PixelMapWireProducer::NROI ( )
inline

Definition at line 42 of file PixelMapWireProducer.h.

42 {return fTotHits;};
unsigned int fTotHits
How many ROIs above threshold?
unsigned int cvn::PixelMapWireProducer::NTdc ( ) const
inline

Definition at line 62 of file PixelMapWireProducer.h.

62 {return fNTdc;};
unsigned int fNTdc
Number of tdcs, width of pixel map.
unsigned int cvn::PixelMapWireProducer::NWire ( ) const
inline

Definition at line 61 of file PixelMapWireProducer.h.

61 {return fNWire;};
unsigned int fNWire
Number of wires, length for pixel maps.
void cvn::PixelMapWireProducer::SetProtoDUNE ( )
inline

Definition at line 36 of file PixelMapWireProducer.h.

36 {fProtoDUNE = true;};
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
void cvn::PixelMapWireProducer::SetUnwrapped ( unsigned short  unwrap)
inline

Definition at line 35 of file PixelMapWireProducer.h.

35 {fUnwrapped = unwrap;};
unsigned short fUnwrapped
Use unwrapped pixel maps?
double cvn::PixelMapWireProducer::TRes ( ) const
inline

Definition at line 63 of file PixelMapWireProducer.h.

63 {return fTRes;};
double fTRes
Timing resolution for pixel map.

Member Data Documentation

geo::GeometryCore const* cvn::PixelMapWireProducer::fGeometry
private

Definition at line 84 of file PixelMapWireProducer.h.

unsigned int cvn::PixelMapWireProducer::fNTdc
private

Number of tdcs, width of pixel map.

Definition at line 76 of file PixelMapWireProducer.h.

unsigned int cvn::PixelMapWireProducer::fNWire
private

Number of wires, length for pixel maps.

Definition at line 75 of file PixelMapWireProducer.h.

bool cvn::PixelMapWireProducer::fProtoDUNE
private

Do we want to use this for particle extraction from protoDUNE?

Definition at line 80 of file PixelMapWireProducer.h.

double cvn::PixelMapWireProducer::fThreshold
private

charge threshold for each time tick, below which isn't added to pixel map

Definition at line 78 of file PixelMapWireProducer.h.

unsigned int cvn::PixelMapWireProducer::fTotHits
private

How many ROIs above threshold?

Definition at line 82 of file PixelMapWireProducer.h.

double cvn::PixelMapWireProducer::fTRes
private

Timing resolution for pixel map.

Definition at line 77 of file PixelMapWireProducer.h.

unsigned short cvn::PixelMapWireProducer::fUnwrapped
private

Use unwrapped pixel maps?

Definition at line 79 of file PixelMapWireProducer.h.

std::vector<double> cvn::PixelMapWireProducer::fVDPlane0
private

Definition at line 85 of file PixelMapWireProducer.h.

std::vector<double> cvn::PixelMapWireProducer::fVDPlane1
private

Definition at line 86 of file PixelMapWireProducer.h.


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