Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dumpwires.cc
Go to the documentation of this file.
1 // Author: David Lawrence Dec. 20, 2013
2 //
3 //
4 // hd_ana.cc
5 //
6 
7 #include <fstream>
8 
9 #include <DANA/DApplication.h>
10 #include <HDGEOMETRY/DGeometry.h>
11 using namespace std;
12 
13 void Usage(JApplication &app);
14 
15 
16 //-----------
17 // main
18 //-----------
19 int main(int narg, char *argv[])
20 {
21  // Instantiate an DApplication object
22  DApplication app(narg, argv);
23 
24  //if(narg<=1)Usage(app);
25 
26  app.Init();
27  DGeometry *dgeom = app.GetDGeometry(1);
28  if(!dgeom){
29  jerr << "Couldn't get DGeometry pointer!!" << endl;
30  return -1;
31  }
32 
33  // Get CDC wires
34  vector<vector<DCDCWire *> > cdcwires;
35  dgeom->GetCDCWires(cdcwires);
36 
37  // Get FDC wires
38  vector<vector<DFDCWire *> > fdcwires;
39  dgeom->GetFDCWires(fdcwires);
40 
41  cout << endl;
42  cout << "Writing GlueX wire definitions to gluex_wires.txt ... " << endl;
43 
44  ofstream ofs("gluex_wires.txt");
45  ofs << "#" << endl;
46  ofs << "# CDC wires" <<endl;
47  ofs << "# id length pos_x pos_y pos_z dir_x dir_y dir_z" << endl;
48  ofs << "#" << endl;
49 
50  ofs << "# ----- CDC ------" << endl;
51  int Ncdc = 0;
52  for(unsigned int i=0; i<cdcwires.size(); i++){
53  vector<DCDCWire *> &wires = cdcwires[i];
54  for(unsigned int j=0; j<wires.size(); j++){
55 
56  DCDCWire *w = wires[j];
57 
58  int id = 100000 + (i+1)*1000 + j;
59  ofs << id << " " << w->L << " ";
60 
61  ofs << w->origin.X() << " ";
62  ofs << w->origin.Y() << " ";
63  ofs << w->origin.Z() << " ";
64 
65  ofs << w->udir.X() << " ";
66  ofs << w->udir.Y() << " ";
67  ofs << w->udir.Z() << " ";
68  ofs << endl;
69  Ncdc++;
70  }
71  }
72 
73  ofs << "#" << endl;
74  ofs << "# ----- FDC ------" << endl;
75  int Nfdc = 0;
76  for(unsigned int i=0; i<fdcwires.size(); i++){
77  vector<DFDCWire *> &wires = fdcwires[i];
78  for(unsigned int j=0; j<wires.size(); j++){
79 
80  DFDCWire *w = wires[j];
81 
82  int id = 200000 + (i+1)*1000 + j;
83  ofs << id << " " << w->L << " ";
84 
85  ofs << w->origin.X() << " ";
86  ofs << w->origin.Y() << " ";
87  ofs << w->origin.Z() << " ";
88 
89  ofs << w->udir.X() << " ";
90  ofs << w->udir.Y() << " ";
91  ofs << w->udir.Z() << " ";
92  ofs << endl;
93  Nfdc++;
94  }
95  }
96 
97  ofs.close();
98 
99  cout << "Done." << endl;
100  cout << "Num. CDC wires: " << Ncdc << endl;
101  cout << "Num. FDC wires: " << Nfdc << endl;
102 
103 
104  return 0;
105 }
106 
107 //-----------
108 // Usage
109 //-----------
110 void Usage(JApplication &app)
111 {
112  cout<<endl;
113  cout<<"Usage:"<<endl;
114  cout<<" hd_ana [options] source1 source2 source3 ..."<<endl;
115  cout<<endl;
116  app.Usage();
117  cout<<endl;
118 
119  exit(0);
120 }
121 
static vector< vector< DFDCWire * > > fdcwires
bool GetCDCWires(vector< vector< DCDCWire * > > &cdcwires) const
Definition: DGeometry.cc:773
DGeometry * GetDGeometry(unsigned int run_number)
jerror_t Init(void)
bool GetFDCWires(vector< vector< DFDCWire * > > &fdcwires) const
Definition: DGeometry.cc:1078
void Usage(JApplication &app)
Definition: hd_ana.cc:33
int main(int argc, char *argv[])
Definition: gendoc.cc:6