15 #include "art_root_io/TFileService.h" 77 TCanvas *can =
new TCanvas(
"c1",
"c1");
79 std::vector<TBox*> TPCBox;
80 std::vector<TLine*> Wires;
90 std::vector<int> nwires_tpc(geo->
NTPC());
91 for (
size_t i = 0; i<geo->
NTPC(); ++i) nwires_tpc[i] = 0;
92 for (
size_t t = 0;
t<geo->
NTPC(); ++
t){
94 double local[3] = {0.,0.,0.};
95 double world[3] = {0.,0.,0.};
117 TPCBox.push_back(
new TBox(world[2]-tpc.
ActiveLength()/2.,
121 TPCBox.back()->SetFillStyle(0);
122 TPCBox.back()->SetLineStyle(2);
123 TPCBox.back()->SetLineWidth(2);
124 TPCBox.back()->SetLineColor(16);
137 if ((
t==2||
t==6||
t==10)&&
p==0&&
w%10==0){
139 Wires.push_back(
new TLine(xyz0[2],xyz0[1],xyz1[2],xyz1[1]));
146 TH2F *frame =
new TH2F(
"frame",
";z (cm);y (cm)",100,minz,maxz,100,miny,maxy);
149 for (
auto box: TPCBox) box->Draw();
150 for (
auto wire: Wires) wire->Draw();
151 can->Print(
"wires.pdf");
152 std::cout<<
"N wires = "<<nwires<<
std::endl;
153 for (
size_t i = 0; i<geo->
NTPC(); ++i){
154 std::cout<<
"TPC "<<i<<
" has "<<nwires_tpc[i]<<
" wires"<<
std::endl;
158 std::vector<TBox*> CRTBox0;
159 std::vector<TBox*> CRTBox1;
160 std::vector<std::vector<TBox*>> CRTStrips(2);
161 std::vector<int> modules0;
162 std::vector<int> modules1;
163 std::vector<TText *> text0;
164 std::vector<TText *> text1;
165 std::vector<double> module_x(32);
166 std::vector<double> module_y(32);
167 std::vector<double> module_z(32);
168 std::vector<double> pixel_x(32);
169 std::vector<double> pixel_y(32);
170 std::vector<double> pixel_z(32);
171 for (
unsigned int i = 0; i < geo->
NAuxDets(); ++i){
172 auto& auxdet = geo->
AuxDet(i);
176 double auxdet0[3] = {-auxdet.HalfWidth1(), auxdet.HalfHeight(), -auxdet.Length()/2};
178 auxdet.LocalToWorld(auxdet0, world0);
179 double auxdet1[3] = {auxdet.HalfWidth1(), auxdet.HalfHeight(), auxdet.Length()/2};
181 auxdet.LocalToWorld(auxdet1, world1);
182 module_x[i] = (world0[0]+world1[0])/2;
183 module_y[i] = (world0[1]+world1[1])/2;
184 module_z[i] = (world0[2]+world1[2])/2;
185 std::cout<<
"CRT module "<<i<<
" x = "<<module_x[i]<<
" y = "<<module_y[i]<<
" z = "<<module_z[i]<<
std::endl;
187 CRTBox0.push_back(
new TBox(world0[0],world0[1],world1[0],world1[1]));
188 CRTBox0.back()->SetFillStyle(0);
190 CRTBox0.back()->SetLineColor(i%8+1);
192 CRTBox0.back()->SetLineColor(kOrange);
194 CRTBox0.back()->SetLineWidth(2);
195 modules0.push_back(i);
196 text0.push_back(
new TText((world0[0]+world1[0])/2,(world0[1]+world1[1])/2,Form(
"%d",i)));
197 text0.back()->SetTextColor(i%8+1);
199 text0.back()->SetTextColor(kOrange);
204 CRTBox1.push_back(
new TBox(world0[0],world0[1],world1[0],world1[1]));
205 CRTBox1.back()->SetFillStyle(0);
207 CRTBox1.back()->SetLineColor(i%8+1);
209 CRTBox1.back()->SetLineColor(kOrange);
211 CRTBox1.back()->SetLineWidth(2);
212 modules1.push_back(i);
213 text1.push_back(
new TText((world0[0]+world1[0])/2,(world0[1]+world1[1])/2,Form(
"%d",i)));
214 text1.back()->SetTextColor(i%8+1);
216 text1.back()->SetTextColor(kOrange);
225 std::vector< std::pair <int,int> > vect;
226 vect.push_back( std::make_pair(1,2));
227 vect.push_back( std::make_pair(0,2));
228 vect.push_back( std::make_pair(15,13));
229 vect.push_back( std::make_pair(14,13));
230 vect.push_back( std::make_pair(14,12));
231 vect.push_back( std::make_pair(9,11));
232 vect.push_back( std::make_pair(9,10));
233 vect.push_back( std::make_pair(8,10));
234 vect.push_back( std::make_pair(7,5));
235 vect.push_back( std::make_pair(6,5));
236 vect.push_back( std::make_pair(6,4));
237 vect.push_back( std::make_pair(1,3));
238 vect.push_back( std::make_pair(0,3));
239 vect.push_back( std::make_pair(15,12));
240 vect.push_back( std::make_pair(8,11));
241 vect.push_back( std::make_pair(7,4));
242 vect.push_back( std::make_pair(17,18));
243 vect.push_back( std::make_pair(16,18));
244 vect.push_back( std::make_pair(31,29));
245 vect.push_back( std::make_pair(30,29));
246 vect.push_back( std::make_pair(30,28));
247 vect.push_back( std::make_pair(25,27));
248 vect.push_back( std::make_pair(25,26));
249 vect.push_back( std::make_pair(24,26));
250 vect.push_back( std::make_pair(23,21));
251 vect.push_back( std::make_pair(22,21));
252 vect.push_back( std::make_pair(22,20));
253 vect.push_back( std::make_pair(17,19));
254 vect.push_back( std::make_pair(16,19));
255 vect.push_back( std::make_pair(31,28));
256 vect.push_back( std::make_pair(24,27));
257 vect.push_back( std::make_pair(23,20));
259 std::vector<size_t> fChannelMap;
260 fChannelMap.push_back(24);
261 fChannelMap.push_back(25);
262 fChannelMap.push_back(30);
263 fChannelMap.push_back(18);
264 fChannelMap.push_back(15);
265 fChannelMap.push_back(7);
266 fChannelMap.push_back(13);
267 fChannelMap.push_back(12);
268 fChannelMap.push_back(11);
269 fChannelMap.push_back(10);
270 fChannelMap.push_back(6);
271 fChannelMap.push_back(14);
272 fChannelMap.push_back(19);
273 fChannelMap.push_back(31);
274 fChannelMap.push_back(26);
275 fChannelMap.push_back(27);
276 fChannelMap.push_back(22);
277 fChannelMap.push_back(23);
278 fChannelMap.push_back(29);
279 fChannelMap.push_back(17);
280 fChannelMap.push_back(8);
281 fChannelMap.push_back(0);
282 fChannelMap.push_back(3);
283 fChannelMap.push_back(2);
284 fChannelMap.push_back(5);
285 fChannelMap.push_back(4);
286 fChannelMap.push_back(1);
287 fChannelMap.push_back(9);
288 fChannelMap.push_back(16);
289 fChannelMap.push_back(28);
290 fChannelMap.push_back(20);
291 fChannelMap.push_back(21);
293 for (
size_t i = 0; i<32; ++i){
302 module[0] = fChannelMap[vect[i].first];
303 module[1] = fChannelMap[vect[i].second];
304 for (
size_t j = 0; j<2; ++j){
305 auto& auxdet = geo->
AuxDet(module[j]);
311 double auxdet0[3] = {-auxdet.HalfWidth1(), auxdet.HalfHeight(), -auxdet.Length()/2};
313 auxdet.LocalToWorld(auxdet0, world0);
314 double auxdet1[3] = {auxdet.HalfWidth1(), auxdet.HalfHeight(), auxdet.Length()/2};
316 auxdet.LocalToWorld(auxdet1, world1);
330 pixel_z[i] = (z[0]+z[1])/2;
334 tex.SetTextSize(0.02);
336 TH2F *frcrt0 =
new TH2F(
"frcrt0",
"Upstream;x(cm);y(cm)",100,-300, 600, 100, -100, 650);
337 TH2F *frcrt1 =
new TH2F(
"frcrt1",
"Downstream;x(cm);y(cm)",100,-400, 450, 100, -200, 600);
340 TCanvas *cancrt =
new TCanvas(
"cancrt",
"cancrt",1600,800);
344 TLegend *leg0 =
new TLegend(0.7,0.1,0.9,0.9);
345 leg0->SetFillStyle(0);
346 for (
size_t i = 0; i< CRTBox0.size(); ++i){
349 leg0->AddEntry(CRTBox0[i], Form(
"Module %d",modules0[i]),
"l");
352 for (
int i = 0; i<16; ++i){
356 tt.SetTextSize(0.02);
357 for (
unsigned int i = 0; i < geo->
NAuxDets(); ++i){
358 auto& auxdet = geo->
AuxDet(i);
362 if (auxdet.HalfWidth1()>auxdet.HalfHeight()){
363 for (
int j = 0; j<1; ++j){
364 auto& auxdetsen = auxdet.SensitiveVolume(j);
366 double auxdetsen0[3] = {0,0,auxdetsen.Length()/2-20};
368 auxdetsen.LocalToWorld(auxdetsen0,world0);
370 tt.SetTextColor(i%8+1);
371 tt.DrawLatex(world0[0], world0[1], Form(
"%d",j));
379 TLegend *leg1 =
new TLegend(0.7,0.1,0.9,0.9);
380 leg1->SetFillStyle(0);
381 for (
size_t i = 0; i< CRTBox1.size(); ++i){
384 leg1->AddEntry(CRTBox1[i], Form(
"Module %d",modules1[i]),
"l");
387 for (
int i = 16; i<32; ++i){
391 for (
unsigned int i = 0; i < geo->
NAuxDets(); ++i){
392 auto& auxdet = geo->
AuxDet(i);
396 for (
int j = 0; j<1; ++j){
397 auto& auxdetsen = auxdet.SensitiveVolume(j);
399 double auxdetsen0[3] = {0,0,auxdetsen.Length()/2-20};
401 auxdetsen.LocalToWorld(auxdetsen0,world0);
403 tt.SetTextColor(i%8+1);
404 tt.DrawLatex(world0[0], world0[1], Form(
"%d",j));
410 for (
int i = 0; i<2; ++i){
411 auto& auxdet = geo->
AuxDet(i*2);
412 for (
size_t j = 0; j<auxdet.NSensitiveVolume(); ++j){
414 double world0[3] = {0};
415 double world1[3] = {0};
417 -auxdetsen.HalfHeight(),
419 double auxdet1[3] = {auxdetsen.HalfWidth1(),
420 auxdetsen.HalfHeight(),
422 auxdetsen.LocalToWorld(auxdet0, world0);
423 auxdetsen.LocalToWorld(auxdet1, world1);
427 CRTStrips[i].push_back(
new TBox(world0[1], world0[2], world1[1], world1[2]));
430 CRTStrips[i].push_back(
new TBox(world0[0], world0[2], world1[0], world1[2]));
432 CRTStrips[i].back()->SetFillStyle(0);
433 CRTStrips[i].back()->SetLineWidth(2);
439 for (
int i = 0; i<2; ++i){
440 cstp[i] =
new TCanvas(Form(
"cstp_%d",i), Form(
"cstp_%d",i), 1000,500);
445 for (
size_t j = 0; j<CRTStrips[i].size(); ++j){
446 if (minx>CRTStrips[i][j]->GetX1()) minx = CRTStrips[i][j]->GetX1();
447 if (minx>CRTStrips[i][j]->GetX2()) minx = CRTStrips[i][j]->GetX2();
448 if (maxx<CRTStrips[i][j]->GetX1()) maxx = CRTStrips[i][j]->GetX1();
449 if (maxx<CRTStrips[i][j]->GetX2()) maxx = CRTStrips[i][j]->GetX2();
450 if (miny>CRTStrips[i][j]->GetY1()) miny = CRTStrips[i][j]->GetY1();
451 if (miny>CRTStrips[i][j]->GetY2()) miny = CRTStrips[i][j]->GetY2();
452 if (maxy<CRTStrips[i][j]->GetY1()) maxy = CRTStrips[i][j]->GetY1();
453 if (maxy<CRTStrips[i][j]->GetY2()) maxy = CRTStrips[i][j]->GetY2();
455 frstp[i] =
new TH2D(Form(
"frstp_%d",i),Form(
"frstp_%d",i),100,minx-10,maxx+10,100,miny-1,maxy+1);
456 frstp[i]->SetStats(0);
457 if (i==0) frstp[i]->SetTitle(
"Horizontal module (offline module 0);y(cm);z(cm)");
458 else frstp[i]->SetTitle(
"Vertical module (offline module 2);x(cm);z(cm)");
460 for (
size_t j = 0; j<CRTStrips[i].size(); ++j){
461 CRTStrips[i][j]->Draw();
463 auto& auxdet = geo->
AuxDet(i*2);
464 for (
size_t j = 0; j<auxdet.NSensitiveVolume(); ++j){
468 if (i==0) tt.DrawLatex(xyz[1]-0.5, xyz[2], Form(
"%d",
int(j)));
469 else tt.DrawLatex(xyz[0]-0.5, xyz[2], Form(
"%d",
int(j)));
471 cstp[i]->Print(Form(
"cstp_%d.png",i));
473 std::ofstream
outfile(
"pixel.txt");
474 for (
int i = 0; i<32; ++i){
475 outfile<<pixel_x[i]<<
" "<<pixel_y[i]<<
" "<<pixel_z[i]<<
std::endl;
479 cancrt->Print(
"crt.pdf");
480 cancrt->Print(
"crt.png");
484 outfile.open(
"channelmap.txt");
485 for (
size_t i = 0; i<geo->
Nchannels(); ++i){
487 outfile<<i<<
" "<<wire.TPC<<
" "<<wire.Plane<<
" "<<wire.Wire<<
std::endl;
CheckGeometry & operator=(CheckGeometry const &)=delete
double ActiveHalfHeight() const
Half height (associated with y coordinate) of active TPC volume [cm].
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Geometry information for a single TPC.
CheckGeometry(fhicl::ParameterSet const &p)
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
EDAnalyzer(fhicl::ParameterSet const &pset)
double HalfWidth1() const
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
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
void analyze(art::Event const &e) override
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
#define DEFINE_ART_MODULE(klass)
double ActiveHalfWidth() const
Half width (associated with x coordinate) of active TPC volume [cm].
void reconfigure(fhicl::ParameterSet const &p)
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
double ActiveLength() const
Length (associated with z coordinate) of active TPC volume [cm].
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
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.
LArSoft geometry interface.
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.
QTextStream & endl(QTextStream &s)
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
void GetCenter(double *xyz, double localz=0.0) const
Return the center position of an AuxDet.