PixelMapWireProducer.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file PixelMapWireProducer.h
3 /// \brief PixelMapWireProducer for CVN
4 /// \author Alexander Radovic - a.radovic@gmail.com
5 //
6 // Modifications to allow unwrapped collection view
7 // - Leigh Whitehead - leigh.howard.whitehead@cern.ch
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include <iostream>
11 #include <ostream>
12 #include <list>
13 #include <algorithm>
14 
17 #include "TVector2.h"
18 #include "TH2D.h"
19 // #include "lardataobj/RecoBase/Wire.h"
21 
27 
28 namespace cvn
29 {
30 
31  PixelMapWireProducer::PixelMapWireProducer(unsigned int nWire, unsigned int nTdc, double tRes, double threshold):
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  }
46 
48  {
50  if (fGeometry->DetectorName().find("dunevd10kt_3view") != std::string::npos)
52  }
53 
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  }
63 
65  const std::vector<const recob::Wire* >& cluster)
66  {
67  Boundary bound = DefineBoundary(detProp, cluster);
68  return CreateMapGivenBoundary(detProp, cluster, bound);
69  }
70 
72  const std::vector<const recob::Wire*>& cluster,
73  const Boundary& bound)
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  }
144 
145  std::ostream& operator<<(std::ostream& os, const PixelMapWireProducer& p)
146  {
147  os << "PixelMapWireProducer: "
148  << p.NTdc() <<" tdcs X " << p.NWire() << " wires";
149  return os;
150  }
151 
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  }
164 
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  }
192 
194  const std::vector< const recob::Wire*>& cluster)
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  }
364 
365  void PixelMapWireProducer::GetDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int& globalWire, unsigned int& globalPlane) const
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  }
409 
410  // Based on Robert's code in adcutils
412  unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc,
413  unsigned int& globalWire, unsigned int& globalPlane, double& globalTDC) const
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  }
466 
468  unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc,
469  unsigned int& globalWire, unsigned int& globalPlane, double& globalTDC) const
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
533 
534  // Special case for ProtoDUNE where we want to extract single particles to mimic CCQE interactions. The output pixel maps should be the same as the workspace
535  // but we need different treatment of the wire numbering
536  void PixelMapWireProducer::GetProtoDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int& globalWire, unsigned int& globalPlane) const
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
581 
582  // Special case for ProtoDUNE where we want to extract single particles to mimic CCQE interactions. The output pixel maps should be the same as the workspace
583  // but we need different treatment of the wire numbering
584  void PixelMapWireProducer::GetProtoDUNEGlobalWireTDC(unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc,
585  unsigned int& globalWire, double& globalTDC, unsigned int& globalPlane) const
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
593 
594  void PixelMapWireProducer::GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int& globalWire, unsigned int& globalPlane) const
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  }
647 
648 } // namespace cvn
bool isVertical() const
Returns if this wire is vertical (theta_z ~ pi/2)
Definition: WireGeo.h:276
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
PixelMapWireProducer for CVN.
Boundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster)
Get boundaries for pixel map representation of cluster.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
std::vector< double > fVDPlane0
PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Wire > > &slice)
std::ostream & operator<<(std::ostream &os, const PixelMapProducer &p)
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?
struct vector vector
void GetProtoDUNEGlobalWireTDC(unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, double &globalTDC, unsigned int &globalPlane) const
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.
Producer algorithm for PixelMap, input to CVN neural net.
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
Cluster finding and building.
void GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
Utility class for truth labels.
std::vector< double > fVDPlane1
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.
void SetTotHits(unsigned int tothits)
Definition: PixelMap.h:67
art framework interface to geometry description
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
double _getIntercept(geo::WireID wireid) const
T abs(T value)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
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?
void Add(const unsigned int &wire, const double &tdc, const unsigned int &view, const double &pe)
Definition: PixelMap.cxx:46
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?
p
Definition: test.py:223
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Definition: Wire.h:228
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
geo::GeometryCore const * fGeometry
Detector simulation of raw signals on wires.
unsigned int NTdc() const
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
double DriftDistance() const
Definition: TPCGeo.h:155
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:97
PixelMap, basic input to CVN neural net.
Definition: PixelMap.h:22
def center(depos, point)
Definition: depos.py:117
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
unsigned int NWire() const
Access the description of detector geometry.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
PixelMap CreateMapGivenBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Wire * > &cluster, const Boundary &bound)
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
QTextStream & endl(QTextStream &s)
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.