BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_geom_bmnzdc.C
Go to the documentation of this file.
1/*************************************************************************************
2 * Author: Elena Litvinenko (EL)
3 * Project: BMN (mpd.jinr.ru/trac/browser/bmnroot; git.jinr.ru/nica/bmnroot)
4 * Created: 28-Oct-2015
5 * Last update: 05-11-2015
6 ************************************************************************************/
7
8#include "mpdshape.class.C"
9
11{
12 public:
14 {
15 id = chan = front_chan = size = x = y = -1;
16 used = 0;
17 };
18 void set(unsigned long v1,
19 unsigned char v2,
20 unsigned char v3,
21 unsigned char v4,
22 unsigned char v5,
23 unsigned char v6,
24 unsigned char v7,
25 float v8,
26 float v9)
27 {
28 id = v1;
29 chan = v2;
30 front_chan = v3;
31 size = v4;
32 ix = v5;
33 iy = v6;
34 used = v7;
35 x = v8;
36 y = v9;
37 };
38 unsigned long id;
39 unsigned char chan;
40 unsigned char front_chan;
41 unsigned char size;
42 unsigned char ix;
43 unsigned char iy;
44 unsigned char used;
45 float x;
46 float y;
47};
48
49int n_rec = 0;
51
53{
54 n_rec = 0;
55 TString dummy;
56 ifstream in;
57
58 TString dir = getenv("VMCWORKDIR");
59 TString path = dir + "/input/";
60 in.open((path + mappingFile).Data());
61 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy;
62 while (!in.eof()) {
63 int id, chan, front_chan, size, ix, iy, used;
64 float x, y;
65 in >> std::hex >> id >> std::dec >> chan >> front_chan >> size >> ix >> iy >> x >> y >> used;
66 if (!in.good())
67 break;
68 zdc_map_element[n_rec].id = id;
69 zdc_map_element[n_rec].chan = chan;
70 zdc_map_element[n_rec].front_chan = front_chan;
71 zdc_map_element[n_rec].size = size;
72 zdc_map_element[n_rec].ix = ix;
73 zdc_map_element[n_rec].iy = iy;
76 zdc_map_element[n_rec].used = used;
77 if (size <= 2)
78 n_rec++;
79 }
80 in.close();
81}
82
83void fix_rect_width_zcenter(std::ostringstream& points, Double_t xyhalfwidth, Double_t zfullwidth)
84{
85 points.str("");
86 points << setprecision(4);
87 points << xyhalfwidth << " " << -xyhalfwidth << " " << (-zfullwidth / 2) << endl;
88 points << xyhalfwidth << " " << xyhalfwidth << " " << (-zfullwidth / 2) << endl;
89 points << -xyhalfwidth << " " << xyhalfwidth << " " << (-zfullwidth / 2) << endl;
90 points << -xyhalfwidth << " " << -xyhalfwidth << " " << (-zfullwidth / 2) << endl;
91 points << xyhalfwidth << " " << -xyhalfwidth << " " << zfullwidth / 2 << endl;
92 points << xyhalfwidth << " " << xyhalfwidth << " " << zfullwidth / 2 << endl;
93 points << -xyhalfwidth << " " << xyhalfwidth << " " << zfullwidth / 2 << endl;
94 points << -xyhalfwidth << " " << -xyhalfwidth << " " << zfullwidth / 2 << endl;
95}
96
97void fix_rect_xy_width_zcenter(std::ostringstream& points,
98 Double_t xhalfwidth,
99 Double_t yhalfwidth,
100 Double_t zfullwidth)
101{
102 points.str("");
103 points << setprecision(4);
104 points << xhalfwidth << " " << -yhalfwidth << " " << (-zfullwidth / 2) << endl;
105 points << xhalfwidth << " " << yhalfwidth << " " << (-zfullwidth / 2) << endl;
106 points << -xhalfwidth << " " << yhalfwidth << " " << (-zfullwidth / 2) << endl;
107 points << -xhalfwidth << " " << -yhalfwidth << " " << (-zfullwidth / 2) << endl;
108 points << xhalfwidth << " " << -yhalfwidth << " " << zfullwidth / 2 << endl;
109 points << xhalfwidth << " " << yhalfwidth << " " << zfullwidth / 2 << endl;
110 points << -xhalfwidth << " " << yhalfwidth << " " << zfullwidth / 2 << endl;
111 points << -xhalfwidth << " " << -yhalfwidth << " " << zfullwidth / 2 << endl;
112}
113
114void addnum(char* name)
115{
116 if (name) {
117 int len = strlen(name);
118 if (len) {
119 name[len] = '#';
120 name[len + 1] = '1';
121 name[len + 2] = '\0';
122 }
123 }
124}
125
126void create_geom_bmnzdc(const char* filename = "", const char* detector_name = "zdc", int version = 1)
127{
128 TString mappingFile = "ZDC_map_Mar08.txt";
129
130 local_BmnZDCRaw2Digit(mappingFile);
131
132 Double_t initDist = 9500., // Distance between interacting point and left point of detector (along the beam), mm
133 x_fullwidth_mother = 1650., // x size of external box of the detector
134 y_fullwidth_mother = 1056., // y size of external box of the detector
135 z_fullwidth_mother = 1450., // z size of external box of the detector
136
137 z_fullwidth_box = 1190., // end of WLS
138 thickness_box = 2, // size suggested by EL
139 thickness_WLS = 0.4, // size suggested by EL
140
141 xy_fullwidth_big_box = 150., // XY size for small module box (for 36 small central modules)
142 xy_fullwidth_small_box = 75., // XY size for small module box (for 36 small central modules)
143
144 x_fullwidth_big_plate =
145 xy_fullwidth_big_box - 2 * thickness_box, // =146: x size of scintillator plate for big modules
146 y_fullwidth_big_plate = x_fullwidth_big_plate - 4, // =142: y size of scintillator plate for big modules
147 x_fullwidth_small_plate =
148 xy_fullwidth_small_box - 2 * thickness_box, // =71: x size of scintillator plate for small modules
149 y_fullwidth_small_plate = x_fullwidth_small_plate - 4, // =67: y size of scintillator plate for small modules
150
151 zWidthS = 5.0, // z - FULL-size of scintillator layer (scintillator plate), mm
152 zWidthA = 10.0; // z - FULL-size of absorber layer, mm
153
154 Double_t moduleWidth = 75;
155
156 Int_t number_of_layers_along_Z = 64; // for HCAL - 80 scintillator/lead layers
157
158 Int_t nlayers = number_of_layers_along_Z; // number of Absorber-Scintillator layers
159
160 // Int_t
161 // number_of_small_modules_in_XY_plane = 36, // 6x6
162 // number_of_big_modules_in_XY_plane = 68; // (7x4+2x3)x2
163
164 ofstream* f;
165 if (!strlen(filename)) {
166 char filename1[200];
167 sprintf(filename1, "%s_%dmodules_%dlayers_v%d\.geo", detector_name, n_rec, number_of_layers_along_Z, version);
168 f = new ofstream(filename1, ios::out | ios::trunc);
169 cout << "filename: " << filename1 << endl;
170 } else {
171 f = new ofstream(filename, ios::out | ios::trunc);
172 cout << "filename: " << filename << endl;
173 }
174
175 // helper streams
176 std::ostringstream points, position, rotation;
177 points.setf(ios::showpoint);
178 position.setf(ios::showpoint);
179 position.setf(ios::fixed);
180 position << setprecision(6);
181 rotation.setf(ios::showpoint);
182 rotation.setf(ios::fixed);
183 rotation << setprecision(6);
184
185 // detector mother volume:
186
187 char mothername[30] = Form("%s01", detector_name); //" zdc"
188
189 *f << "//*****************************************************" << endl;
190 *f << "// ZDC detector for BMN project," << endl;
191 *f << "// geometry version 1" << endl;
192 *f << "// created 19-11-2015 by E.I.Litvinenko" << endl;
193 *f << "//*****************************************************" << endl;
194
195 // fix_rect_xy_width_z0 (points, x_fullwidth_mother/2+5,y_fullwidth_mother/2+5, z_fullwidth_mother+5);
196 fix_rect_xy_width_zcenter(points, x_fullwidth_mother / 2 + 1, y_fullwidth_mother / 2 + 1, z_fullwidth_mother + 2);
197 Mpdshape* detmother = new Mpdshape(f, mothername, "cave", "BOX", "air", points.str(), position.str());
198
199 detmother->SetSegment(1);
200 // detmother->SetPosition(0., 0., initDist);
201 detmother->SetPosition(0., 0., initDist + z_fullwidth_mother / 2);
202 detmother->SetRotation(" 1. 0. 0. 0. 1. 0. 0. 0. 1.");
203 detmother->DumpWithIncrement();
204
205 addnum(mothername); // "zdc#1"
206
207 // one module small box:
208
209 char boxnames[30] = Form("%s01boxs", detector_name); // "zdc01boxs"
210
211 position.str("");
212 rotation.str("");
213 fix_rect_width_zcenter(points, xy_fullwidth_small_box / 2, z_fullwidth_box + thickness_box * 2);
214 Mpdshape* detmoduleboxs = new Mpdshape(f, boxnames, mothername, "BOX", "steel", points.str(), position.str());
215 detmoduleboxs->SetSegment(1);
216
217 addnum(boxnames); // "zdc01boxs#1"
218
219 // one module big box:
220
221 char boxnameb[30] = Form("%s01boxb", detector_name); // "zdc01boxb"
222
223 position.str("");
224 rotation.str("");
225 fix_rect_width_zcenter(points, xy_fullwidth_big_box / 2, z_fullwidth_box + thickness_box * 2);
226 Mpdshape* detmoduleboxb = new Mpdshape(f, boxnameb, mothername, "BOX", "steel", points.str(), position.str());
227 detmoduleboxb->SetSegment(1);
228
229 addnum(boxnameb); // "zdc01boxb#1"
230
231 // one small module:
232
233 char modulenames[30] = Form("%s01ms", detector_name); // "zdc01ms"
234
235 position.str("");
236 rotation.str("");
237 fix_rect_width_zcenter(points, xy_fullwidth_small_box / 2 - thickness_box, z_fullwidth_box);
238 Mpdshape* detmodules = new Mpdshape(f, modulenames, boxnames, "BOX", "air", points.str(), position.str());
239 detmodules->SetSegment(1);
240 detmodules->SetPosition(0, 0, 0);
241
242 addnum(modulenames); // "zdc01ms#1"
243
244 // one big module:
245
246 char modulenameb[30] = Form("%s01mb", detector_name); // "zdc01mb"
247
248 position.str("");
249 rotation.str("");
250 fix_rect_width_zcenter(points, xy_fullwidth_big_box / 2 - thickness_box, z_fullwidth_box);
251 Mpdshape* detmoduleb = new Mpdshape(f, modulenameb, boxnameb, "BOX", "air", points.str(), position.str());
252 detmoduleb->SetSegment(1);
253 detmoduleb->SetPosition(0, 0, 0);
254
255 addnum(modulenameb); // "zdc01mb#1"
256
257 // layers
258
259 char absorber_names[30] = Form("%s01as", detector_name); // "zdc01as"
260 char scintillator_names[30] = Form("%s01ss", detector_name); // "zdc01ss"
261 char absorber_nameb[30] = Form("%s01ab", detector_name); // "zdc01ab"
262 char scintillator_nameb[30] = Form("%s01sb", detector_name); // "zdc01sb"
263
264 Mpdshape *detlayer_abss = 0, *detlayer_scis = 0;
265 Mpdshape *detlayer_absb = 0, *detlayer_scib = 0;
266
267 Double_t xm, ym; // coordinates of center of the module
268 Int_t imodule, jmodule; // xy-index and z-index of the module
269
270 char module_rotation[30] = "1. 0. 0. 0. 1. 0. 0. 0. 1.";
271
272 Bool_t first_small = 1, first_large = 1;
273
274 for (imodule = 0; imodule < n_rec; imodule++) {
275
276 xm = zdc_map_element[imodule].x;
277 ym = zdc_map_element[imodule].y;
278 if (zdc_map_element[imodule].size == 1) {
279 detmoduleboxs->SetPosition(xm, ym, (z_fullwidth_box - z_fullwidth_mother - 2) / 2);
280 detmoduleboxs->DumpWithIncrement();
281 if (first_small) {
282 detmodules->DumpWithIncrement();
283 for (int ilayer = 0; ilayer < nlayers; ilayer++) {
284 if (!ilayer) {
285 position.str("");
286 fix_rect_xy_width_zcenter(points, x_fullwidth_small_plate / 2, y_fullwidth_small_plate / 2,
287 zWidthA);
288 detlayer_abss =
289 new Mpdshape(f, absorber_names, modulenames, "BOX", "lead", points.str(), position.str());
290 detlayer_abss->SetSegment(1);
291
292 position.str("");
293 fix_rect_xy_width_zcenter(points, x_fullwidth_small_plate / 2, y_fullwidth_small_plate / 2,
294 zWidthS);
295 detlayer_scis = new Mpdshape(f, scintillator_names, modulenames, "BOX", "polystyrene",
296 points.str(), position.str());
297 detlayer_scis->SetSegment(1);
298 }
299
300 detlayer_abss->SetPosition(0., 0.,
301 -z_fullwidth_box / 2 + zWidthA * 0.5 + (zWidthA + zWidthS) * ilayer);
302 detlayer_abss->SetRotation(" 1. 0. 0. 0. 1. 0. 0. 0. 1.");
303 detlayer_abss->DumpWithIncrement();
304 detlayer_scis->SetPosition(
305 0., 0., -z_fullwidth_box / 2 + zWidthA + zWidthS * 0.5 + (zWidthA + zWidthS) * ilayer);
306 detlayer_scis->SetRotation(" 1. 0. 0. 0. 1. 0. 0. 0. 1.");
307 detlayer_scis->DumpWithIncrement();
308 }
309 first_small = 0;
310 }
311 } else {
312 detmoduleboxb->SetPosition(xm, ym, (z_fullwidth_box - z_fullwidth_mother - 2) / 2);
313 detmoduleboxb->DumpWithIncrement();
314 if (first_large) {
315 detmoduleb->DumpWithIncrement();
316 for (int ilayer = 0; ilayer < nlayers; ilayer++) {
317 if (!ilayer) {
318 position.str("");
319 fix_rect_xy_width_zcenter(points, x_fullwidth_big_plate / 2, y_fullwidth_big_plate / 2,
320 zWidthA);
321 detlayer_absb =
322 new Mpdshape(f, absorber_nameb, modulenameb, "BOX", "lead", points.str(), position.str());
323 detlayer_absb->SetSegment(1);
324
325 position.str("");
326 fix_rect_xy_width_zcenter(points, x_fullwidth_big_plate / 2, y_fullwidth_big_plate / 2,
327 zWidthS);
328 detlayer_scib = new Mpdshape(f, scintillator_nameb, modulenameb, "BOX", "polystyrene",
329 points.str(), position.str());
330 detlayer_scib->SetSegment(1);
331 }
332
333 detlayer_absb->SetPosition(0., 0.,
334 -z_fullwidth_box / 2 + zWidthA * 0.5 + (zWidthA + zWidthS) * ilayer);
335 detlayer_absb->SetRotation(" 1. 0. 0. 0. 1. 0. 0. 0. 1.");
336 detlayer_absb->DumpWithIncrement();
337 detlayer_scib->SetPosition(
338 0., 0., -z_fullwidth_box / 2 + zWidthA + zWidthS * 0.5 + (zWidthA + zWidthS) * ilayer);
339 detlayer_scib->SetRotation(" 1. 0. 0. 0. 1. 0. 0. 0. 1.");
340 detlayer_scib->DumpWithIncrement();
341 }
342 first_large = 0;
343 }
344 }
345 cout << " imodule: " << imodule << " " << xm << " " << ym << endl;
346 }
347 cout << " layers: " << nlayers << endl;
348 cout << " modules: " << imodule << endl;
349
350 // close geometry file
351 f->close();
352}
bool Bool_t
int Int_t
double Double_t
char * Form(const char *fmt,...)
void set(unsigned long v1, unsigned char v2, unsigned char v3, unsigned char v4, unsigned char v5, unsigned char v6, unsigned char v7, float v8, float v9)
void SetPosition(std::string position)
void SetSegment(Int_t segment)
void SetRotation(std::string rotation)
void DumpWithIncrement()
int n_rec
Bmn_ZDC_map_element zdc_map_element[256]
void local_BmnZDCRaw2Digit(TString mappingFile)
void addnum(char *name)
void fix_rect_width_zcenter(std::ostringstream &points, Double_t xyhalfwidth, Double_t zfullwidth)
void create_geom_bmnzdc(const char *filename="", const char *detector_name="zdc", int version=1)
void fix_rect_xy_width_zcenter(std::ostringstream &points, Double_t xhalfwidth, Double_t yhalfwidth, Double_t zfullwidth)