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

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

#include <PixelMapSimProducer.h>

Public Member Functions

 PixelMapSimProducer (unsigned int nWire, unsigned int nTdc, double tRes, double threshold=0.)
 
 PixelMapSimProducer ()
 
void SetUnwrapped (unsigned short unwrap)
 
void SetProtoDUNE ()
 
Boundary DefineBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const sim::SimChannel * > &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< sim::SimChannel > > &slice)
 
PixelMap CreateMap (detinfo::DetectorPropertiesData const &detProp, const std::vector< const sim::SimChannel * > &slice)
 
PixelMap CreateMapGivenBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const sim::SimChannel * > &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 PixelMapSimProducer.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file PixelMapSimProducer.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 int fTotHits
How many ROIs above threshold?
double fThreshold
charge threshold for each time tick, below which isn&#39;t added to pixel map
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
double fTRes
Timing resolution for pixel map.
unsigned int fNWire
Number of wires, length for pixel maps.
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
unsigned int fNTdc
Number of tdcs, width of pixel map.
unsigned short fUnwrapped
Use unwrapped pixel maps?
geo::GeometryCore const * fGeometry
cvn::PixelMapSimProducer::PixelMapSimProducer ( )

Definition at line 47 of file PixelMapSimProducer.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::PixelMapSimProducer::_cacheIntercepts ( )
private

Definition at line 165 of file PixelMapSimProducer.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
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.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
double _getIntercept(geo::WireID wireid) const
geo::GeometryCore const * fGeometry
std::vector< double > fVDPlane1
double cvn::PixelMapSimProducer::_getIntercept ( geo::WireID  wireid) const
private

Definition at line 152 of file PixelMapSimProducer.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
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
geo::GeometryCore const * fGeometry
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.
PixelMap cvn::PixelMapSimProducer::CreateMap ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< sim::SimChannel > > &  slice 
)

Definition at line 54 of file PixelMapSimProducer.cxx.

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

Definition at line 64 of file PixelMapSimProducer.cxx.

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

Definition at line 71 of file PixelMapSimProducer.cxx.

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

Get boundaries for pixel map representation of cluster.

Definition at line 193 of file PixelMapSimProducer.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 sim::SimChannel* reco_wire = cluster[iHit];
211  auto& ROIs = reco_wire->TDCIDEMap();
212  if(!(ROIs.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  for(auto iROI = ROIs.begin(); iROI != ROIs.end(); ++iROI){
241  auto& ROI = *iROI;
242  auto tick = ROI.first;
243  // for(int tick = ROI.begin_index(); tick < (int)ROI.end_index(); tick++){
244 
245  double globalTime = (double)tick;
246  double charge = 0.005*reco_wire->Charge(tick);
247  if(!(charge > fThreshold)) continue;
248  // Leigh: Simple modification to unwrap the collection view wire plane
249  if(!fProtoDUNE){
250  if(fUnwrapped == 1){
251  // Jeremy: Autodetect geometry for DUNE 10kt module. Is this a bad idea??
252  if (fGeometry->DetectorName() == "dune10kt_v1") {
253  if (wireid.TPC%6 == 0 or wireid.TPC%6 == 5) continue; // Skip dummy TPCs in 10kt module
254  GetDUNE10ktGlobalWireTDC(detProp, wireid.Wire,(double)tick,
255  wireid.Plane,wireid.TPC,globalWire,globalPlane,globalTime);
256  }
257  else if (fGeometry->DetectorName().find("dunevd10kt_3view") == std::string::npos){
258  GetDUNEGlobalWireTDC(detProp, wireid.Wire,(double)tick,
259  wireid.Plane,wireid.TPC,globalWire,globalPlane,globalTime);
260  }
261  }
262  }
263 
264  if(globalPlane==0){
265  tsum_0 += globalTime;
266  total_t0++;
267  wire_0.push_back(globalWire);
268  twire_0.push_back((double)tick);
269  }
270  if(globalPlane==1){
271  tsum_1 += globalTime;
272  total_t1++;
273  wire_1.push_back(globalWire);
274  twire_1.push_back((double)tick);
275  }
276  if(globalPlane==2){
277  tsum_2 += globalTime;
278  total_t2++;
279  wire_2.push_back(globalWire);
280  twire_2.push_back((double)tick);
281  }
282 
283  // }
284  }
285 
286  // if(!none_threshold){
287  // if(globalPlane==0){
288  // wire_0.push_back(globalWire);
289  // twire_0.push_back((double)min_tick);
290  // }
291  // if(globalPlane==1){
292  // wire_1.push_back(globalWire);
293  // twire_1.push_back((double)min_tick);
294  // }
295  // if(globalPlane==2){
296  // wire_2.push_back(globalWire);
297  // twire_2.push_back((double)min_tick);
298  // }
299  // }
300 
301  }
302  double tmean_0 = tsum_0/total_t0;
303  double tmean_1 = tsum_1/total_t1;
304  double tmean_2 = tsum_2/total_t2;
305 
306 
307  //auto maxwireelement_0= std::max_element(wire_0.begin(), wire_0.end());
308  //std::cout<<"maxwire 0: "<<*maxwireelement_0<<std::endl;
309  //auto maxwireelement_1= std::max_element(wire_1.begin(), wire_1.end());
310  //std::cout<<"maxwire 1: "<<*maxwireelement_1<<std::endl;
311  //auto maxwireelement_2= std::max_element(wire_2.begin(), wire_2.end());
312  //std::cout<<"maxwire 2: "<<*maxwireelement_2<<std::endl;
313 
314 
315  std::vector<int> bwire_0;
316  std::vector<int> bwire_1;
317  std::vector<int> bwire_2;
318  for(int i = 0; i < (int)wire_0.size(); i++){
319  double t = twire_0[i];
320  if(std::abs(t-tmean_0) < (double)fTRes)
321  bwire_0.push_back(wire_0[i]);
322  }
323  for(int i = 0; i < (int)wire_1.size(); i++){
324  double t = twire_1[i];
325  if(std::abs(t-tmean_1) < (double)fTRes)
326  bwire_1.push_back(wire_1[i]);
327  }
328  for(int i = 0; i < (int)wire_2.size(); i++){
329  double t = twire_2[i];
330  if(std::abs(t-tmean_2) < (double)fTRes)
331  bwire_2.push_back(wire_2[i]);
332  }
333 
334  std::cout << "Boundary wire vector sizes: " << bwire_0.size() << ", " << bwire_1.size() << ", " << bwire_2.size() << std::endl;
335 
336  int minwire_0 = 0;
337  int minwire_1 = 0;
338  int minwire_2 = 0;
339  auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
340  auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
341  auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
342 
343  if(bwire_0.size() > 0) { minwire_0 = *minwireelement_0-1; std::cout<<"minwire 0: "<<(*minwireelement_0) <<std::endl;}
344  if(bwire_1.size() > 0) { minwire_1 = *minwireelement_1-1; std::cout<<"minwire 1: "<<(*minwireelement_1) <<std::endl;}
345  if(bwire_2.size() > 0) { minwire_2 = *minwireelement_2-1; std::cout<<"minwire 2: "<<(*minwireelement_2) <<std::endl;}
346 
347  fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
348 
349  Boundary bound(fNWire,fTRes,minwire_0,minwire_1,minwire_2,tmean_0,tmean_1,tmean_2);
350 
351  return bound;
352  }
unsigned int fTotHits
How many ROIs above threshold?
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:140
double fThreshold
charge threshold for each time tick, below which isn&#39;t added to pixel map
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
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
double globalTime
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
void GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
T abs(T value)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
Definition: SimChannel.cxx:134
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
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
double fTRes
Timing resolution for pixel map.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:329
unsigned int fNWire
Number of wires, length for pixel maps.
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
unsigned short fUnwrapped
Use unwrapped pixel maps?
TDCIDEs_t const & TDCIDEMap() const
Returns all the deposited energy information as stored.
Definition: SimChannel.h:328
void GetProtoDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
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.
geo::GeometryCore const * fGeometry
QTextStream & endl(QTextStream &s)
void cvn::PixelMapSimProducer::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 456 of file PixelMapSimProducer.cxx.

459  {
460  unsigned int nWiresTPC = 400;
461  unsigned int wireGap = 4;
462  double driftLen = fGeometry->TPC(tpc).DriftDistance();
463  double apaLen = fGeometry->TPC(tpc).Width() - fGeometry->TPC(tpc).ActiveWidth();
464  double driftVel = detProp.DriftVelocity();
465  unsigned int drift_size = (driftLen / driftVel) * 2; // Time in ticks to cross a TPC
466  unsigned int apa_size = 4*(apaLen / driftVel) * 2; // Width of the whole APA in TDC
467 
468 
469  globalWire = 0;
470  globalPlane = 0;
471 
472  // Collection plane has more wires
473  if(plane == 2){
474  nWiresTPC = 480;
475  wireGap = 5;
476  globalPlane = 2;
477  }
478 
479  bool includeZGap = true;
480  if(includeZGap) nWiresTPC += wireGap;
481 
482  // 10kt has four real TPCs and two dummies in each slice
483  //
484  // |--|-----|-----|-----|-----|--| / /
485  // y ^ |11| 10 | 9 | 8 | 7 | 6|/ /
486  // | -| z |--|-----|-----|-----|-----|--| /
487  // | / | 5| 4 | 3 | 2 | 1 | 0| /
488  // x <---|/ |--|-----|-----|-----|-----|--|/
489  // ^ wires ^ ^ wires ^
490  //
491  // We already filtered out the dummies, so we can assume 0->3 as follows:
492  //
493  // |-----|-----|-----|-----| / /
494  // y ^ | 7 | 6 | 5 | 4 |/ /
495  // | -| z |-----|-----|-----|-----| /
496  // | / | 3 | 2 | 1 | 0 | /
497  // x <---|/ |-----|-----|-----|-----|/
498  // ^ wires ^ ^ wires ^
499  //
500 
501  size_t tpc_x = (tpc%6) - 1; // x coordinate in 0->4 range
502  size_t tpc_xy = (tpc%12) - 1; // xy coordinate as 0->3 & 6->9 (converted from 1->4, 7->10)
503  if (tpc_xy > 3) tpc_xy -= 2; // now subtract 2 so it's in the 0->7 range
504 
505  // Induction views depend on the drift direction
506  if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
507  else globalPlane = plane;
508 
509  int offset = 752; // Offset between upper and lower modules in induction views, from Robert & Dorota's code
510  // Second induction plane gets offset from the back of the TPC
511  if (globalPlane != 1) globalWire += (tpc/12)*nWiresTPC;
512  else globalWire += ((300-tpc)/12)*nWiresTPC;
513  // Reverse wires and add offset for upper modules in induction views
514  if (tpc_xy > 3 and globalPlane < 2) globalWire += fGeometry->Nwires(globalPlane, tpc, 0) + offset - localWire;
515  else globalWire += localWire;
516 
517  if (tpc_x % 2 == 0) globalTDC = localTDC;
518  else globalTDC = (2*drift_size) - localTDC;
519  if (tpc_x > 1) globalTDC += 2 * (drift_size + apa_size);
520 
521  } // function PixelMapSimProducer::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.
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.
geo::GeometryCore const * fGeometry
void cvn::PixelMapSimProducer::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 354 of file PixelMapSimProducer.cxx.

355  {
356  unsigned int nWiresTPC = 400;
357 
358  globalWire = localWire;
359  globalPlane = 0;
360 
361  // Collection plane has more wires
362  if(plane == 2){
363  nWiresTPC=480;
364  globalPlane = 2;
365  }
366 
367  // Workspace geometry has two drift regions
368  // |-----|-----| / /
369  // y ^ | 3 | 2 |/ /
370  // | -| z |-----|-----| /
371  // | / | 1 | 0 | /
372  // x <---|/ |-----|-----|/
373  //
374 
375  int tpcMod4 = tpc%4;
376 
377  // Induction views depend on the drift direction
378  if(plane < 2){
379  // For drift in negative x direction keep U and V as defined.
380  if(tpcMod4 == 0 || tpcMod4 == 3){
381  globalPlane = plane;
382  }
383  // For drift in positive x direction, swap U and V.
384  else{
385  if(plane == 0) globalPlane = 1;
386  else globalPlane = 0;
387  }
388  }
389 
390  if(globalPlane != 1){
391  globalWire += (tpc/4)*nWiresTPC;
392  }
393  else{
394  globalWire += ((23-tpc)/4)*nWiresTPC;
395  }
396 
397  }
void cvn::PixelMapSimProducer::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 400 of file PixelMapSimProducer.cxx.

403  {
404 
405  unsigned int nWiresTPC = 400;
406  unsigned int wireGap = 4;
407  double driftLen = fGeometry->TPC(tpc,0).DriftDistance();
408  double apaLen = fGeometry->TPC(tpc,0).Width() - fGeometry->TPC(tpc,0).ActiveWidth();
409  double driftVel = detProp.DriftVelocity();
410  unsigned int drift_size = (driftLen / driftVel) * 2; // Time in ticks to cross a TPC
411  unsigned int apa_size = 4*(apaLen / driftVel) * 2; // Width of the whole APA in TDC
412 
413  globalWire = 0;
414  globalPlane = 0;
415 // int dir = fGeometry->TPC(tpc,0).DetectDriftDirection();
416 
417  // Collection plane has more wires
418  if(plane == 2){
419  nWiresTPC = 480;
420  wireGap = 5;
421  globalPlane = 2;
422  }
423 
424  bool includeZGap = true;
425  if(includeZGap) nWiresTPC += wireGap;
426 
427  // Workspace geometry has two drift regions
428  // |-----|-----| / /
429  // y ^ | 3 | 2 |/ /
430  // | -| z |-----|-----| /
431  // | / | 1 | 0 | /
432  // x <---|/ |-----|-----|/
433  //
434  int tpcMod4 = tpc%4;
435  // Induction views depend on the drift direction
436  if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
437  else globalPlane = plane;
438 
439  int offset = 752; // Offset between upper and lower modules in induction views, from Robert & Dorota's code
440  // Second induction plane gets offset from the back of the TPC
441  if (globalPlane != 1) globalWire += (tpc/4)*nWiresTPC;
442  else globalWire += ((23-tpc)/4)*nWiresTPC;
443  // Reverse wires and add offset for upper modules in induction views
444  // Nitish : what's the difference between Nwires here and nWiresTPC?
445  if (tpcMod4 > 1 and globalPlane < 2) globalWire += fGeometry->Nwires(globalPlane, tpc, 0) + offset - localWire;
446  else globalWire += localWire;
447 
448  if(tpcMod4 == 0 || tpcMod4 == 2){
449  globalTDC = drift_size - localTDC;
450  }
451  else{
452  globalTDC = localTDC + drift_size + apa_size;
453  }
454  }
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.
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.
geo::GeometryCore const * fGeometry
void cvn::PixelMapSimProducer::GetDUNEVertDrift3ViewGlobalWire ( unsigned int  localWire,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const

Definition at line 583 of file PixelMapSimProducer.cxx.

584  {
585  // Preliminary function for VD Geometries (3 View for now)
586  // 1x6x6 -- single drift volume should make things significantly simpler
587 
588  int nCRM_row = 6;
589  // spacing between y-intercepts of parallel wires in a given plane.
590  double spacing = 0.847;
591 
592  globalPlane = plane;
593  unsigned int nWiresTPC = fGeometry->Nwires(globalPlane, tpc, 0);
594 
595  if(globalPlane < 2){
596 
597  geo::WireID wire_id = geo::WireID(0, tpc, globalPlane, localWire);
598  double wire_intercept = _getIntercept(wire_id);
599  double low_bound, upper_bound;
600  int start, end, diag_tpc;
601  // get wires on diagonal CRMs and their intercepts which bound the current wire's intercept
602  if(globalPlane == 0){
603  start = std::lower_bound(fVDPlane0.begin(), fVDPlane0.end(), wire_intercept) - fVDPlane0.begin() - 1;
604  end = std::upper_bound(fVDPlane0.begin(), fVDPlane0.end(), wire_intercept) - fVDPlane0.begin();
605  low_bound = fVDPlane0[start];
606  upper_bound = fVDPlane0[end];
607  diag_tpc = (start/2);
608  }
609  else{
610  end = std::lower_bound(fVDPlane1.begin(), fVDPlane1.end(), wire_intercept) - fVDPlane1.begin() - 1;
611  start = std::upper_bound(fVDPlane1.begin(), fVDPlane1.end(), wire_intercept) - fVDPlane1.begin();
612  low_bound = fVDPlane1[end];
613  upper_bound = fVDPlane1[start];
614  diag_tpc = (nCRM_row-(end/2) - 1);
615  }
616  // if the intercept of the wire is in between two diagonal CRMs, assign it to the diagonal CRM its closest to
617  if((start % 2)^globalPlane){
618 
619  int diag_idx = diag_tpc + !globalPlane;
620  globalWire = (wire_intercept > (low_bound+upper_bound)*0.5) ? (nWiresTPC-1)*diag_idx + !globalPlane : (nWiresTPC-1)*diag_idx + globalPlane;
621  }
622  // otherwise assign it to the closest wire within the same CRM
623  else{
624  int diag_idx = diag_tpc;
625  int offset = globalPlane ? std::round((upper_bound - wire_intercept)/spacing) : std::round((wire_intercept-low_bound)/spacing);
626  globalWire = (nWiresTPC-1)*diag_idx + offset + 1;
627 
628  }
629  }
630  else{
631  int tpc_z = tpc/6;
632  globalWire = localWire + tpc_z*nWiresTPC;
633  }
634 
635  }
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.
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.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
double _getIntercept(geo::WireID wireid) const
geo::GeometryCore const * fGeometry
std::vector< double > fVDPlane1
void cvn::PixelMapSimProducer::GetProtoDUNEGlobalWire ( unsigned int  localWire,
unsigned int  plane,
unsigned int  tpc,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const

Definition at line 525 of file PixelMapSimProducer.cxx.

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

Definition at line 573 of file PixelMapSimProducer.cxx.

575  {
576  // We can just use the existing function to get the global wire & plane
577  // GetProtoDUNEGlobalWire(localWire, plane, tpc, globalWire, globalPlane);
578  GetDUNEGlobalWire(localWire, plane, tpc, globalWire, globalPlane);
579  // Implement additional mirroring here?
580 
581  } // 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::PixelMapSimProducer::NROI ( )
inline

Definition at line 42 of file PixelMapSimProducer.h.

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

Definition at line 62 of file PixelMapSimProducer.h.

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

Definition at line 61 of file PixelMapSimProducer.h.

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

Definition at line 36 of file PixelMapSimProducer.h.

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

Definition at line 35 of file PixelMapSimProducer.h.

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

Definition at line 63 of file PixelMapSimProducer.h.

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

Member Data Documentation

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

Definition at line 84 of file PixelMapSimProducer.h.

unsigned int cvn::PixelMapSimProducer::fNTdc
private

Number of tdcs, width of pixel map.

Definition at line 76 of file PixelMapSimProducer.h.

unsigned int cvn::PixelMapSimProducer::fNWire
private

Number of wires, length for pixel maps.

Definition at line 75 of file PixelMapSimProducer.h.

bool cvn::PixelMapSimProducer::fProtoDUNE
private

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

Definition at line 80 of file PixelMapSimProducer.h.

double cvn::PixelMapSimProducer::fThreshold
private

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

Definition at line 78 of file PixelMapSimProducer.h.

unsigned int cvn::PixelMapSimProducer::fTotHits
private

How many ROIs above threshold?

Definition at line 82 of file PixelMapSimProducer.h.

double cvn::PixelMapSimProducer::fTRes
private

Timing resolution for pixel map.

Definition at line 77 of file PixelMapSimProducer.h.

unsigned short cvn::PixelMapSimProducer::fUnwrapped
private

Use unwrapped pixel maps?

Definition at line 79 of file PixelMapSimProducer.h.

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

Definition at line 85 of file PixelMapSimProducer.h.

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

Definition at line 86 of file PixelMapSimProducer.h.


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