Public Member Functions | Private Attributes | List of all members
protoana::ProtoDUNEDPCRPGeo Class Reference

#include <ProtoDUNEDPCRPGeo.h>

Public Member Functions

 ProtoDUNEDPCRPGeo ()
 
 ~ProtoDUNEDPCRPGeo ()
 
crpgeoinfo GetCRPGeoInfo (geo::Point_t const &pnt) const
 
int GetLemsPerCRP () const
 

Private Attributes

int fLemsPerRow
 
float fLemWidth
 
geo::Geometry const * fGeom
 

Detailed Description

Definition at line 45 of file ProtoDUNEDPCRPGeo.h.

Constructor & Destructor Documentation

protoana::ProtoDUNEDPCRPGeo::ProtoDUNEDPCRPGeo ( )

Definition at line 16 of file ProtoDUNEDPCRPGeo.cxx.

17 {
18  fLemsPerRow = 6;
19  fLemWidth = 50.0; // in cm
20 
21  // geometry service
23 }
geo::Geometry const * fGeom
protoana::ProtoDUNEDPCRPGeo::~ProtoDUNEDPCRPGeo ( )

Definition at line 27 of file ProtoDUNEDPCRPGeo.cxx.

28 {;}

Member Function Documentation

crpgeoinfo protoana::ProtoDUNEDPCRPGeo::GetCRPGeoInfo ( geo::Point_t const &  pnt) const

Definition at line 32 of file ProtoDUNEDPCRPGeo.cxx.

33 {
34  const string myname = "protoana::ProtoDUNEDPCRPGeo::GetCRPGeoInfo: ";
35 
36  crpgeoinfo crp_geo_info;
37 
38  // find TPC volume
39  geo::TPCGeo const* tpc = nullptr;
40  try{
41  tpc = fGeom->PositionToTPCptr( pnt );
42  }
43  catch(cet::exception &e){
44  cout<<e;
45  }
46 
47  if( not tpc ) return crp_geo_info;
48  crp_geo_info.crpid = tpc->ID().TPC;
49 
50  // determine drift coordinate
51  int dcoord = std::abs(tpc->DetectDriftDirection())-1; //x:0, y:1, z:2
52  int tcoord1 = 0;
53  int tcoord2 = 0;
54  if(dcoord == 0)
55  {
56  tcoord1 = 1; // Y
57  tcoord2 = 2; // Z
58  }
59  else if(dcoord == 1)
60  {
61  tcoord1 = 0; // X
62  tcoord2 = 2; // Z
63  }
64  else // wrong CRP drift
65  {
66  cout<<myname<<"Bad drift direction "<<dcoord<<endl;
67  return crp_geo_info;
68  }
69 
70 
71  double xyz[3] = {pnt.X(), pnt.Y(), pnt.Z()};
72  crp_geo_info.danode = tpc->PlaneLocation(0)[dcoord] - xyz[dcoord];
73 
74  // point coordinate in the plane
75  float planeX = xyz[ tcoord2 ] - tpc->PlaneLocation(0)[ tcoord2 ];
76  float planeY = xyz[ tcoord1 ] - tpc->PlaneLocation(0)[ tcoord1 ];
77 
78  // cout<<"Input : "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<endl;
79  // cout<<"Plane : "
80  // <<tpc->PlaneLocation(0)[0]<<" "
81  // <<tpc->PlaneLocation(0)[1]<<" "
82  // <<tpc->PlaneLocation(0)[2]<<endl;
83  // cout<<"Danode : "<<crp_geo_info.danode<<endl;
84  // cout<<"Plane coord : "<<planeX<<" "<<planeY<<endl;
85 
86  // distance to the CRP edge
87  float activeHalfWidth = 0.5 * fLemsPerRow * fLemWidth;
88  crp_geo_info.dedge = std::min( (activeHalfWidth - std::abs(planeX)),
89  (activeHalfWidth - std::abs(planeY)) );
90  if( crp_geo_info.dedge < 0 || crp_geo_info.dedge > activeHalfWidth ){
91  cout<<myname<<"Bad distance to CRP edge "<<crp_geo_info.dedge<<endl;
92  return crp_geo_info;
93  }
94 
95  // 2d index of each LEM: CRP edges should be about -150.0 -> 150.0 cm
96  int LemsHalfRow = fLemsPerRow / 2;
97  int icol = int(planeX / fLemWidth); // column index along Z axis
98  if( planeX < 0 ) icol += (LemsHalfRow - 1);
99  else icol += (LemsHalfRow);
100 
101  int irow = int(planeY / fLemWidth); // row index in other coordinate
102  if( planeY < 0 ) irow += (LemsHalfRow - 1);
103  else irow += (LemsHalfRow);
104 
105  crp_geo_info.lemid = icol * fLemsPerRow + irow;
106  if( crp_geo_info.lemid >= fLemsPerRow * fLemsPerRow || crp_geo_info.lemid < 0 ){
107  // bad LEM index;
108  cout<<myname<<"Bad LEM index "<<crp_geo_info.lemid<<endl;
109  return crp_geo_info;
110  }
111 
112  // assumed center of each LEM
113  float lemX = (icol + 0.5) * fLemWidth - activeHalfWidth;
114  float lemY = (irow + 0.5) * fLemWidth - activeHalfWidth;
115 
116  // position wrt to LEM center
117  float inlemX = planeX - lemX;
118  float inlemY = planeY - lemY;
119  crp_geo_info.dlem = std::min( (0.5 * fLemWidth - std::abs(inlemX)),
120  (0.5 * fLemWidth - std::abs(inlemY)) );
121  // cout<<"LEM IDs : "<<icol<<" "<<irow<<" "<<crp_geo_info.lemid<<"\n";
122  // cout<<"LEM pos : "<<lemX<<" "<<lemY<<"\n";
123  // cout<<"In LEM pos : "<<inlemX<<" "<<inlemY<<"\n";
124  // cout<<"Distance to LEM border : "<<crp_geo_info.dlem<<endl;
125 
126  if( crp_geo_info.dlem < 0 || crp_geo_info.dlem > 0.5*fLemWidth ){
127  cout<<myname<<"Bad distance to LEM border "<<crp_geo_info.dlem<<endl;
128  return crp_geo_info;
129  }
130 
131  crp_geo_info.valid = true;
132 
133  return crp_geo_info;
134 }
Geometry information for a single TPC.
Definition: TPCGeo.h:38
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point) const
Returns the TPC at specified location.
T abs(T value)
const double e
geo::Geometry const * fGeom
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
int protoana::ProtoDUNEDPCRPGeo::GetLemsPerCRP ( ) const
inline

Definition at line 53 of file ProtoDUNEDPCRPGeo.h.

Member Data Documentation

geo::Geometry const* protoana::ProtoDUNEDPCRPGeo::fGeom
private

Definition at line 60 of file ProtoDUNEDPCRPGeo.h.

int protoana::ProtoDUNEDPCRPGeo::fLemsPerRow
private

Definition at line 58 of file ProtoDUNEDPCRPGeo.h.

float protoana::ProtoDUNEDPCRPGeo::fLemWidth
private

Definition at line 59 of file ProtoDUNEDPCRPGeo.h.


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