CheckDPhaseGeometry_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: CheckDPhaseGeometry
3 // Module Type: analyzer
4 // File: CheckDPhaseGeometry_module.cc
5 //
6 // Generated at Fri Jan 15 14:32:57 2016 by Vyacheslav Galymov using artmod
7 // from cetpkgsupport v1_10_01.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
21 
22 #include "TFile.h"
23 #include "TCanvas.h"
24 #include "TBox.h"
25 #include "TH2F.h"
26 #include "TLine.h"
27 
28 #include <iostream>
29 #include <iomanip>
30 
32 
34 public:
35  explicit CheckDPhaseGeometry(fhicl::ParameterSet const & p);
36  // The destructor generated by the compiler is fine for classes
37  // without bare pointers or other resource use.
38 
39  // Plugins should not be copied or assigned.
40  CheckDPhaseGeometry(CheckDPhaseGeometry const &) = delete;
44 
45  // Required functions.
46  void analyze(art::Event const & e) override;
47 
48 
49 private:
50 
51  // Declare member data here.
52  //const double dpwpitch = 0.3125; //cm
53 
54 };
55 
56 
58  :
59  EDAnalyzer(p) // ,
60  // More initializers here.
61 {;}
62 
64 {
65  std::vector<TBox*> TPCBox;
66  std::vector<TLine*> Wires;
67 
68  double minx = 1e9;
69  double maxx = -1e9;
70  double miny = 1e9;
71  double maxy = -1e9;
72  double minz = 1e9;
73  double maxz = -1e9;
74 
75  int nwires = 0;
76 
77  // get geometry
79  /*
80  // check channel map
81  for( unsigned ch = 0; ch < geo->Nchannels(); ++ch ){
82  auto wids = geo->ChannelToWire(ch);
83  //std::cout<<ch<<" -> wids "<<wids.size()<<std::endl;
84  std::cout<<"Channel to TPC "<< ch <<" "<<wids[0].TPC<<" "<<wids[0].Plane<<" "<<wids[0].Wire<<std::endl;
85  }
86  //return;
87  */
88  std::cout<<"Total number of TPC "<<geo->NTPC()<<std::endl;
89 
90  for (geo::TPCID const& tpcid: geo->IterateTPCIDs()) {
91  size_t const t = tpcid.TPC;
92  //if (t%2==0) continue;
93  double local[3] = {0.,0.,0.};
94  double world[3] = {0.,0.,0.};
95  const geo::TPCGeo &tpc = geo->TPC(t);
96  tpc.LocalToWorld(local,world);
97  if (minx>world[0]-tpc.ActiveHalfWidth())
98  minx = world[0]-tpc.ActiveHalfWidth();
99  if (maxx<world[0]+tpc.ActiveHalfWidth())
100  maxx = world[0]+tpc.ActiveHalfWidth();
101  if (miny>world[1]-tpc.ActiveHalfHeight())
102  miny = world[1]-tpc.ActiveHalfHeight();
103  if (maxy<world[1]+tpc.ActiveHalfHeight())
104  maxy = world[1]+tpc.ActiveHalfHeight();
105  if (minz>world[2]-tpc.ActiveLength()/2.)
106  minz = world[2]-tpc.ActiveLength()/2.;
107  if (maxz<world[2]+tpc.ActiveLength()/2.)
108  maxz = world[2]+tpc.ActiveLength()/2.;
109 
110 
111  TPCBox.push_back(new TBox(world[2]-tpc.ActiveLength()/2.,
112  world[1]-tpc.ActiveHalfHeight(),
113  world[2]+tpc.ActiveLength()/2.,
114  world[1]+tpc.ActiveHalfHeight()));
115  TPCBox.back()->SetFillStyle(0);
116  TPCBox.back()->SetLineStyle(2);
117  TPCBox.back()->SetLineWidth(2);
118  TPCBox.back()->SetLineColor(16);
119 
120  // std::cout<<"TPC "<<t<<" has found "<<geo->Nplanes(t)<<" planes"<<std::endl;
121  // std::cout<<"TPC coordinates : "<<world[0]<<" "<<world[1]<<" "<<world[2]<<std::endl;
122  // std::cout<<"Drift direction : ";
123  // if(tpc.DriftDirection() == geo::kPosX) std::cout<<"geo::kPosX"<<std::endl;
124  // else if(tpc.DriftDirection() == geo::kNegX) std::cout<<"geo::kNegX"<<std::endl;
125  // else std::cout<<" Uknown drift direction"<<std::endl;
126  // std::cout<<"Drift distance : "<<tpc.DriftDistance()<<std::endl;
127  std::cout<<tpc.TPCInfo(" ", 4)<<std::endl;
128  std::cout<<std::endl;
129  // scan the planes
130  for (size_t p = 0; p<geo->Nplanes(t);++p)
131  {
132  geo::PlaneID planeID(tpcid, p);
133  const geo::PlaneGeo &vPlane = tpc.Plane( planeID );
134  auto view = vPlane.View();
135  if( view == geo::kU )
136  std::cout<<" View type geo::kU"<<std::endl;
137  else if( view == geo::kV )
138  std::cout<<" View type geo::kV"<<std::endl;
139  else if( view == geo::kX )
140  std::cout<<" View type geo::kX"<<std::endl;
141  else if( view == geo::kY )
142  std::cout<<" View type geo::kY"<<std::endl;
143  else if( view == geo::kZ )
144  std::cout<<" View type geo::kZ"<<std::endl;
145  else
146  std::cout<<" View "<<view<<" uknown"<<std::endl;
147 
148  if( geo->SignalType(planeID) == geo::kCollection )
149  std::cout<<" View is geo::kCollection"<<std::endl;
150  else if( geo->SignalType(planeID) == geo::kInduction )
151  std::cout<<" View is geo::kInduction"<<std::endl;
152  else
153  std::cout<<" View signal type is unknown"<<std::endl;
154 
155  std::cout<<" Number of wires : "<<vPlane.Nwires()<<std::endl;
156  std::cout<<" Wire pitch : "<<vPlane.WirePitch()<<std::endl;
157  std::cout<<" Theta Z : "<<vPlane.ThetaZ()<<std::endl;
158 
159  double prval = 0;
160  double refpitch = 0;
161  for (size_t w = 0; w<geo->Nwires(p,t); ++w){
162  ++nwires;
163  //++nwires_tpc[t];
164  double xyz0[3];
165  double xyz1[3];
166  unsigned int c = 0;
167 
168  if(true)
169  {
170  geo->WireEndPoints(c,t,p,w,xyz0,xyz1);
171  Wires.push_back(new TLine(xyz0[2],xyz0[1],xyz1[2],xyz1[1]));
172 
173  double pitch = 0;
174  //if( p == 0) {pitch = xyz0[1] - prval; prval = xyz0[1];}
175  //else if( p == 1) {pitch = xyz0[2] - prval; prval = xyz0[2];}
176  if( view == geo::kX ) {pitch = xyz0[0] - prval; prval = xyz0[0];}
177  else if(view == geo::kY){pitch = xyz0[1] - prval; prval = xyz0[1];}
178  else if(view == geo::kZ){pitch = xyz0[2] - prval; prval = xyz0[2];}
179  else {
180  continue;
181  //std::cerr<<"cannot determine the view\n"; break;
182  }
183  if( w == 1 ){ refpitch = pitch; }
184  if(w > 0 && fabs(pitch - refpitch) > 0.00001)
185  {
186  std::cerr<<" Bad pitch : "<<t<<" "<<p<<" "<<w<<" "<<w-1<<" "<<pitch<<" "<<refpitch<<std::endl;
187  //<<std::setprecision(15)<<xyz0[0]<<" "<<xyz0[1]<<" "<<xyz0[2]<<std::endl;
188  }
189  }
190  //std::cout<<t<<" "<<p<<" "<<w<<" "<<xyz0[0]<<" "<<xyz0[1]<<" "<<xyz0[2]<<std::endl;
191  }
192  std::cout<<std::endl;
193  }
194  //break;
195  }
196  /*
197  TCanvas *can = new TCanvas("c1","c1");
198  can->cd();
199  TH2F *frame = new TH2F("frame",";z (cm);y (cm)",3000,minz,maxz,3000,miny,maxy);
200  frame->SetStats(0);
201  frame->Draw();
202  for (auto box: TPCBox) box->Draw();
203  for (auto wire: Wires) wire->Draw();
204  can->Print("wires.pdf");
205  can->Print("wires.C");
206  std::cout<<"N wires = "<<nwires<<std::endl;
207  std::cout<<"Total number of channel wires = "<<nwires<<std::endl;
208  //for (int i = 0; i<8; ++i)
209  //{
210  //std::cout<<"TPC "<<i<<" has "<<nwires_tpc[i]<<" wires"<<std::endl;
211  //}
212  */
213 }
214 
CheckDPhaseGeometry(fhicl::ParameterSet const &p)
double ActiveHalfHeight() const
Half height (associated with y coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:99
Planes which measure V.
Definition: geo_types.h:130
CheckDPhaseGeometry & operator=(CheckDPhaseGeometry const &)=delete
Planes which measure X direction.
Definition: geo_types.h:134
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Planes which measure Z direction.
Definition: geo_types.h:132
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
IteratorBox< TPC_id_iterator,&GeometryCore::begin_TPC_id,&GeometryCore::end_TPC_id > IterateTPCIDs() const
Enables ranged-for loops on all TPC IDs of the detector.
Planes which measure Y direction.
Definition: geo_types.h:133
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.
art framework interface to geometry description
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:726
Planes which measure U.
Definition: geo_types.h:129
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:184
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
Signal from induction planes.
Definition: geo_types.h:145
void analyze(art::Event const &e) override
double ActiveHalfWidth() const
Half width (associated with x coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:95
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
p
Definition: test.py:223
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
double ActiveLength() const
Length (associated with z coordinate) of active TPC volume [cm].
Definition: TPCGeo.h:103
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
std::string TPCInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with information about this TPC.
Definition: TPCGeo.cxx:244
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:269
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
Definition: TPCGeo.h:563
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146