109{
111
112 string detectorFile;
113 int moduleID;
115
116 try {
117
118 JParser<> zap(
"Auxiliary program to draw a given module in 3D.");
119
123
124 zap(argc, argv);
125 }
126 catch(const exception &error) {
127 FATAL(error.what() << endl);
128 }
129
130
132
133
135
136 try {
138 }
141 }
142
144 FATAL(
"Empty detector.");
145 }
146
147
149
150 if (moduleID == -1) {
151
152 module = detector.front();
153
154 } else {
155
157
158 if (!router.hasModule(moduleID)) {
159 FATAL(
"Missing module " << moduleID << endl);
160 } else {
161 module = router.getModule(moduleID);
162 }
163 }
164
165 module -= module.getPosition();
166
167
170
171
172 TApplication* app = new TApplication("user", NULL, NULL);
173
174 c1 =
new TCanvas(
"module", detectorFile.c_str(), 600, 600);
175 p1 =
new TPaveText(0.7, 0.9, 1.0, 1.0,
"NB");
176
178
180 p1->SetBorderSize(0);
181 p1->SetTextSize(0.03);
182
183 TGeoManager* gGeoManager = new TGeoManager("geometry", "");
184
185 TGeoMaterial* mat = new TGeoMaterial("vacuum", 0, 0, 0);
186 TGeoMedium* med = new TGeoMedium ("vacuum", 1, mat);
187 TGeoVolume* top = gGeoManager->MakeBox("top", med, 30.0, 30.0, 30.0);
188
189
190
191
192
193
194
195
196
197
198
199 const double dz = 3.0;
200 const double R1 = 2.0;
201 const double R2 = 4.0;
202
203
204 const Int_t color[] = { kRed, kOrange, kYellow, kGreen, kBlue, kMagenta };
205
206 for (unsigned int tdc = 0; tdc != module.size(); ++tdc) {
207
209 const int index = address.
ring -
'A';
210
211 ostringstream os[2];
212
213 os[0] <<
"PMT " << setw(1) << address.
ring << setw(1) << address.
position;
214 os[1] << "TDC " << setw(2) << tdc;
215
216 TGeoVolumeAssembly* pPMT = new TGeoVolumeAssembly("PMT");
217
220
221 for (int i = 0; i != sizeof(os)/sizeof(os[0]); ++i) {
224 }
225
226 pTube->SetLineColor(color[index]);
227 pCone->SetLineColor(color[index]);
228
229 pPMT->AddNode(pTube, 0, new TGeoTranslation(0.0, 0.0, -dz));
230 pPMT->AddNode(pCone, 1, new TGeoTranslation(0.0, 0.0, 0.0));
231
232 const JPMT& pmt =
module.getPMT(tdc);
233
234 const Double_t
x = pmt.
getX() * 100;
235 const Double_t
y = pmt.
getY() * 100;
236 const Double_t z = pmt.
getZ() * 100;
237
238 const Double_t theta = pmt.
getTheta() * 180.0 / PI;
239 const Double_t phi = pmt.
getPhi() * 180.0 / PI;
240
242 << setw(1) << address.
ring
243 << setw(1) << address.
position <<
" "
244 << setw(8) << pmt.
getID() <<
" "
245 << " TDC "
246 << setw(2) << tdc << " "
247 <<
FIXED(3,0) << x <<
" [cm] "
248 <<
FIXED(3,0) << y <<
" [cm] "
249 <<
FIXED(3,0) << z <<
" [cm] "
250 <<
FIXED(4,0) << theta <<
" [deg] "
251 <<
FIXED(4,0) << phi <<
" [deg] "
252 << endl);
253
254 TGeoRotation* rot = new TGeoRotation();
255
256 rot->RotateY(theta);
257 rot->RotateZ(phi);
258
259 top->AddNode(pPMT, tdc, new TGeoCombiTrans(x,y,z,rot));
260 }
261
262 gGeoManager->SetTopVolume(top);
263 gGeoManager->CloseGeometry();
264
265 top->Draw();
266
267 c1->GetView()->ShowAxis();
269
270 app->Run();
271}
TCanvas * c1
Global variables to handle mouse events.
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
Lookup table for PMT addresses in optical module.
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
char ring
ring number ['A','F']
int position
position within ring [1,6]
Data structure for PMT geometry, calibration and status.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
double getTheta() const
Get theta angle.
double getPhi() const
Get phi angle.
void AddText(const std::string &text)
Add text to buffer.
int getID() const
Get identifier.
Utility class to parse command line options.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Data structure to translate PMT physical to readout address.