215 std::ifstream fin(geometryfile);
217 LOG(error) <<
"No geometry file for FoCAL. Use default ones";
221 LOG(info) <<
"Using geometry file " << geometryfile;
224 std::vector<Composition> padCompDummy(10);
225 std::vector<Composition> hCalCompDummy(10);
226 std::vector<Composition> pixelCompDummy(10);
227 std::vector<Composition> frontMatterCompDummy(10);
231 int nFrontMatter = 0;
239 LOG(info) <<
"Loading FOCAL geometry file ";
240 while (getline(fin, input)) {
241 LOG(
debug) <<
"Read string :: " << input.c_str();
242 const char* p = std::strpbrk(
"#", input.c_str());
248 std::vector<std::string> tokens;
249 std::stringstream
str(input);
251 while (getline(
str, tmpStr,
' ')) {
252 if (tmpStr.empty()) {
255 tokens.push_back(tmpStr);
258 std::string command = tokens[0];
259 LOG(
debug) <<
"command: " << command;
261 if (command.find(
"COMPOSITION") != std::string::npos)
263 std::string material = tokens[1];
264 float cx = std::stof(tokens[2]);
265 float cy = std::stof(tokens[3]);
266 float dx = std::stof(tokens[4]);
267 float dy = std::stof(tokens[5]);
268 float dz = std::stof(tokens[6]);
271 LOG(
debug) <<
"Material :: " << material;
272 LOG(
debug) <<
"cx/cy/dx/dy/dz :: " << cx <<
" / " << cy <<
" / " << dx <<
" / " << dy <<
" / " << dz;
275 if (command.find(
"PAD") != std::string::npos) {
276 sscanf(command.c_str(),
"COMPOSITION_PAD_S%d", &
stack);
277 padCompDummy.emplace_back(material,
stack,
stack, 0, cx, cy, cz, dx, dy, dz);
281 if (command.find(
"HCAL") != std::string::npos) {
282 sscanf(command.c_str(),
"COMPOSITION_HCAL_S%d", &
stack);
283 hCalCompDummy.emplace_back(material,
stack,
stack, 0, cx, cy, cz, dx, dy, dz);
287 if (command.find(
"PIX") != std::string::npos) {
288 sscanf(command.c_str(),
"COMPOSITION_PIX_S%d", &
stack);
289 pixelCompDummy.emplace_back(material,
stack,
stack, 0, cx, cy, cz, dx, dy, dz);
295 if (command.find(
"FM") != std::string::npos) {
296 sscanf(command.c_str(),
"COMPOSITION_FM_S%d", &
stack);
297 frontMatterCompDummy.emplace_back(material,
stack,
stack, 0, cx, cy, cz, dx, dy, dz);
302 if (command.find(
"GLOBAL") != std::string::npos) {
304 if (command.find(
"PAD_SIZE") != std::string::npos) {
309 if (command.find(
"PAD_NX") != std::string::npos) {
314 if (command.find(
"PAD_NY") != std::string::npos) {
319 if (command.find(
"PAD_SUPERMODULE_X") != std::string::npos) {
324 if (command.find(
"PAD_SUPERMODULE_Y") != std::string::npos) {
329 if (command.find(
"PIX_NX") != std::string::npos) {
334 if (command.find(
"PIX_NY") != std::string::npos) {
339 if (command.find(
"PAD_PPTOL") != std::string::npos) {
344 if (command.find(
"PAD_SKIN") != std::string::npos) {
349 if (command.find(
"FOCAL_Z") != std::string::npos) {
354 if (command.find(
"DetectorOpen_Right") != std::string::npos) {
359 if (command.find(
"DetectorOpen_Left") != std::string::npos) {
364 if (command.find(
"HCAL_TOWER_SIZE") != std::string::npos) {
369 if (command.find(
"HCAL_PITCH_SIZE") != std::string::npos) {
374 if (command.find(
"HCAL_TOWER_NX") != std::string::npos) {
379 if (command.find(
"HCAL_TOWER_NY") != std::string::npos) {
384 if (command.find(
"HCAL_BEAMPIPE") != std::string::npos) {
389 if (command.find(
"PIX_OffsetX") != std::string::npos) {
394 if (command.find(
"PIX_OffsetY") != std::string::npos) {
399 if (command.find(
"PIX_SKIN") != std::string::npos) {
404 if (command.find(
"TOWER_TOLX") != std::string::npos) {
410 if (command.find(
"TOWER_TOLY") != std::string::npos) {
416 if (command.find(
"MIDDLE_TOWER_OFFSET") != std::string::npos) {
421 if (command.find(
"Tower_NX") != std::string::npos) {
426 if (command.find(
"Tower_NY") != std::string::npos) {
432 if (command.find(
"COMMAND") != std::string::npos) {
434 if (command.find(
"NUMBER_OF_PAD_LAYERS") != std::string::npos) {
435 npadlayers = std::stoi(tokens[1]);
436 LOG(
debug) <<
"Number of pad layers " << npadlayers;
439 if (command.find(
"NUMBER_OF_HCAL_LAYERS") != std::string::npos) {
444 if (command.find(
"NUMBER_OF_SEGMENTS") != std::string::npos) {
449 if (command.find(
"INSERT_PIX") != std::string::npos) {
450 sscanf(command.c_str(),
"COMMAND_INSERT_PIX_AT_L%d", &pixl[npixlayers]);
451 LOG(
debug) <<
"Number of pixel layer " << npixlayers <<
" : location " << pixl[npixlayers];
455 if (command.find(
"COMMAND_PIXEL_READOUT_ON") != std::string::npos) {
461 if (command.find(
"COMMAND_INSERT_FRONT_PAD_LAYERS") != std::string::npos) {
463 LOG(
debug) <<
"Insert two pad layers in front of ECAL for charged particle veto!";
466 if (command.find(
"COMMAND_INSERT_HCAL_READOUT") != std::string::npos) {
468 LOG(
debug) <<
"Insert Aluminium 1cm thick layer behind HCAL to simulate readout SiPM material !";
472 if (command.find(
"VIRTUAL") != std::string::npos) {
475 float padSize, sensitiveThickness, pixelTreshold;
477 if (command.find(
"N_SEGMENTS") != std::string::npos) {
482 if (command.find(
"SEGMENT_LAYOUT") != std::string::npos) {
484 maxLayer = std::stoi(tokens[2]);
485 padSize = std::stof(tokens[3]);
486 sensitiveThickness = std::stof(tokens[4]);
487 isPixel = std::stoi(tokens[5]);
488 pixelTreshold = std::stof(tokens[6]);
505 sscanf(command.c_str(),
"VIRTUAL_SEGMENT_LAYOUT_N%d", &
segment);
516 LOG(
debug) <<
"Segment number " <<
segment <<
" defined with (minLayer, maxLayer, padSize, isPixel): ("
517 <<
minlayer <<
", " << maxLayer <<
", " << padSize <<
", " << isPixel <<
")";
527 for (
int i = 0;
i < npixlayers;
i++) {
537 LOG(warning) <<
"You reached the segments limits! Setting Number of segments to: 100";
563 for (
auto& tmpComp : padCompDummy) {
564 LOG(
debug) <<
"Material(pad layer) " << tmpComp.material();
565 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
566 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
567 if (tmpComp.material().compare(
"SiPad")) {
568 mPadCompositionBase.emplace_back(tmpComp.material(), tmpComp.layer(), tmpComp.stack(), tmpComp.id(),
569 tmpComp.centerX(), tmpComp.centerY(), center_z,
598 center_z += tmpComp.getThickness();
607 for (
auto& tmpComp : pixelCompDummy) {
608 LOG(
debug) <<
"Material (pixel layer) " << tmpComp.material();
609 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
610 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
611 if (tmpComp.material().compare(
"SiPix")) {
619 pixX, pixY, center_z,
624 center_z += tmpComp.getThickness();
631 for (
auto& tmpComp : hCalCompDummy) {
632 LOG(
debug) <<
"Material (hcal) " << tmpComp.material();
633 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
634 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
635 mHCalCompositionBase.emplace_back(tmpComp.material(), tmpComp.layer(), tmpComp.stack(), tmpComp.id(),
636 tmpComp.centerX(), tmpComp.centerY(),
mNHCalLayers == 1 ? 0. : center_z,
637 tmpComp.sizeX(), tmpComp.sizeY(), tmpComp.sizeZ());
639 center_z = tmpComp.getThickness();
641 center_z += tmpComp.getThickness();
657 LOG(
debug) <<
" end of SetParameters ";
705 if (itowerx == 0 && itowery == 5) {
708 if (itowerx == 1 && itowery == 5) {
721 double hCALsizeX = nCols * padSize;
722 double hCALsizeY = nRows * padSize;
724 x = ix * padSize + 0.5 * padSize - 0.5 * hCALsizeX;
725 y = iy * padSize + 0.5 * padSize - 0.5 * hCALsizeY;
730 y = iy * towerSize + 0.5 * towerSize - 0.5 * towerSize * nRows;
731 x = ix * towerSize + 0.5 * towerSize - 0.5 * towerSize * nCols;
737 double hCALsizeX = comp1.
sizeX() * 2;
751 // define beam pipe radius, calculate half of the tower diagonal in XY
752 // and remove every tower which center is closer than the sum of the two...
753 double beamPipeRadius = 3.6; // in cm TODO: check if this is OK
754 double towerHalfDiag = std::sqrt(2)*0.5*getTowerSizeX(); // tower half diagonal
755 double minRadius = beamPipeRadius+towerHalfDiag;
757 if((x*x+y*y) < (minRadius*minRadius)){ // comparing the tower center position with the minimum distance in second powers.
758 //mDisableTowers.push_back(Tower+1);