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(
"HCAL_TOWER_SIZE") != std::string::npos) {
359 if (command.find(
"HCAL_TOWER_NX") != std::string::npos) {
364 if (command.find(
"HCAL_TOWER_NY") != std::string::npos) {
369 if (command.find(
"PIX_OffsetX") != std::string::npos) {
374 if (command.find(
"PIX_OffsetY") != std::string::npos) {
379 if (command.find(
"PIX_SKIN") != std::string::npos) {
384 if (command.find(
"TOWER_TOLX") != std::string::npos) {
390 if (command.find(
"TOWER_TOLY") != std::string::npos) {
396 if (command.find(
"MIDDLE_TOWER_OFFSET") != std::string::npos) {
401 if (command.find(
"Tower_NX") != std::string::npos) {
406 if (command.find(
"Tower_NY") != std::string::npos) {
412 if (command.find(
"COMMAND") != std::string::npos) {
414 if (command.find(
"NUMBER_OF_PAD_LAYERS") != std::string::npos) {
415 npadlayers = std::stoi(tokens[1]);
416 LOG(
debug) <<
"Number of pad layers " << npadlayers;
419 if (command.find(
"NUMBER_OF_HCAL_LAYERS") != std::string::npos) {
429 if (command.find(
"NUMBER_OF_SEGMENTS") != std::string::npos) {
434 if (command.find(
"INSERT_PIX") != std::string::npos) {
435 sscanf(command.c_str(),
"COMMAND_INSERT_PIX_AT_L%d", &pixl[npixlayers]);
436 LOG(
debug) <<
"Number of pixel layer " << npixlayers <<
" : location " << pixl[npixlayers];
440 if (command.find(
"COMMAND_PIXEL_READOUT_ON") != std::string::npos) {
446 if (command.find(
"COMMAND_INSERT_FRONT_PAD_LAYERS") != std::string::npos) {
448 LOG(
debug) <<
"Insert two pad layers in front of ECAL for charged particle veto!";
451 if (command.find(
"COMMAND_INSERT_HCAL_READOUT") != std::string::npos) {
453 LOG(
debug) <<
"Insert Aluminium 1cm thick layer behind HCAL to simulate readout SiPM material !";
457 if (command.find(
"VIRTUAL") != std::string::npos) {
460 float padSize, sensitiveThickness, pixelTreshold;
462 if (command.find(
"N_SEGMENTS") != std::string::npos) {
467 if (command.find(
"SEGMENT_LAYOUT") != std::string::npos) {
469 maxLayer = std::stoi(tokens[2]);
470 padSize = std::stof(tokens[3]);
471 sensitiveThickness = std::stof(tokens[4]);
472 isPixel = std::stoi(tokens[5]);
473 pixelTreshold = std::stof(tokens[6]);
490 sscanf(command.c_str(),
"VIRTUAL_SEGMENT_LAYOUT_N%d", &
segment);
501 LOG(
debug) <<
"Segment number " <<
segment <<
" defined with (minLayer, maxLayer, padSize, isPixel): ("
502 <<
minlayer <<
", " << maxLayer <<
", " << padSize <<
", " << isPixel <<
")";
512 for (
int i = 0;
i < npixlayers;
i++) {
522 LOG(warning) <<
"You reached the segments limits! Setting Number of segments to: 100";
548 for (
auto& tmpComp : padCompDummy) {
549 LOG(
debug) <<
"Material(pad layer) " << tmpComp.material();
550 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
551 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
552 if (tmpComp.material().compare(
"SiPad")) {
553 mPadCompositionBase.emplace_back(tmpComp.material(), tmpComp.layer(), tmpComp.stack(), tmpComp.id(),
554 tmpComp.centerX(), tmpComp.centerY(), center_z,
583 center_z += tmpComp.getThickness();
592 for (
auto& tmpComp : pixelCompDummy) {
593 LOG(
debug) <<
"Material (pixel layer) " << tmpComp.material();
594 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
595 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
596 if (tmpComp.material().compare(
"SiPix")) {
604 pixX, pixY, center_z,
609 center_z += tmpComp.getThickness();
616 for (
auto& tmpComp : hCalCompDummy) {
617 LOG(
debug) <<
"Material (hcal) " << tmpComp.material();
618 LOG(
debug) <<
"layer / stack / id :: " << tmpComp.layer() <<
" / " << tmpComp.stack() <<
" / " << tmpComp.id();
619 LOG(
debug) <<
"center x,y,dz :: " << tmpComp.sizeX() <<
" / " << tmpComp.sizeY() <<
" / " << tmpComp.sizeZ();
620 mHCalCompositionBase.emplace_back(tmpComp.material(), tmpComp.layer(), tmpComp.stack(), tmpComp.id(),
621 tmpComp.centerX(), tmpComp.centerY(),
mNHCalLayers == 1 ? 0. : center_z,
622 tmpComp.sizeX(), tmpComp.sizeY(), tmpComp.sizeZ());
624 center_z = tmpComp.getThickness();
626 center_z += tmpComp.getThickness();
634 LOG(
debug) <<
" end of SetParameters ";
682 if (itowerx == 0 && itowery == 5) {
685 if (itowerx == 1 && itowery == 5) {
697 double hCALsizeX = nCols * padSize;
698 double hCALsizeY = nRows * padSize;
699 x = ix * padSize + 0.5 * padSize - 0.5 * hCALsizeX;
700 y = iy * padSize + 0.5 * padSize - 0.5 * hCALsizeY;
706 double beamPipeRadius = 3.6;
708 double minRadius = beamPipeRadius + towerHalfDiag;
711 y = iy * towerSize + 0.5 * towerSize - 0.5 * towerSize * nRows;
712 x = ix * towerSize + 0.5 * towerSize - 0.5 * towerSize * nCols;
713 if (y < minRadius && y > -minRadius) {
714 x =
int(
x) <= 0 ?
x - (minRadius - towerSize) :
x + (minRadius - towerSize);
721 // define beam pipe radius, calculate half of the tower diagonal in XY
722 // and remove every tower which center is closer than the sum of the two...
723 double beamPipeRadius = 3.6; // in cm TODO: check if this is OK
724 double towerHalfDiag = std::sqrt(2)*0.5*getTowerSizeX(); // tower half diagonal
725 double minRadius = beamPipeRadius+towerHalfDiag;
727 if((x*x+y*y) < (minRadius*minRadius)){ // comparing the tower center position with the minimum distance in second powers.
728 //mDisableTowers.push_back(Tower+1);