91 if (iStation < 0 || iStation >=
fNStations) Fatal(
"SetNRegions",
"iStation is out of range.");
93 fRadii[iStation].resize(nRegions);
94 fSecLx[iStation].resize(nRegions);
95 fSecLy[iStation].resize(nRegions);
96 fNCols[iStation].resize(nRegions);
97 fNRows[iStation].resize(nRegions);
99 if (
fDebug) { printf(
"Station %i has %i regions\n", iStation + 1, nRegions); }
103 Int_t nChans =
Int_t(TMath::Power(2, n) + 1e-2);
104 if (nChans !=
fNChannels[iStation]) Fatal(
"Init",
"Number of channels should be equal to two with integer power.");
105 Int_t nPower = n / 2;
106 for (
Int_t iRegion = 0; iRegion <
fNRegions[iStation]; ++iRegion) {
107 fNCols[iStation].at(iRegion) = (
Int_t) TMath::Power(2, nPower);
108 fNRows[iStation].at(iRegion) = n % 2 != 0 ? (
Int_t) TMath::Power(2, nPower + 1) :
fNCols[iStation].at(iRegion);
111 printf(
"Region %i has %i columns and %i rows per sector\n", iRegion + 1,
fNCols[iStation].at(iRegion),
112 fNRows[iStation].at(iRegion));
145 if (iStation < 0 || iStation >=
fNStations) Fatal(
"SetSigma",
"iStation is out of range.");
146 if (iRegion < 0 || iRegion >=
fNRegions[iStation]) Fatal(
"SetSigma",
"iRegion is out of range.");
148 Double_t secLx =
fSecLx[iStation].at(iRegion) =
fNCols[iStation].at(iRegion) * TMath::Sqrt(12.) * sigmaX;
149 Double_t secLy =
fSecLy[iStation].at(iRegion) =
fNRows[iStation].at(iRegion) * TMath::Sqrt(12.) * sigmaY;
150 if (TMath::Abs(secLy - secLx) < 1e-5)
return;
151 if (TMath::Abs(secLy / secLx - 2) > 1e-5) {
152 if (secLy > 2 * secLx) {
153 fNCols[iStation].at(iRegion) *= 2;
154 fNRows[iStation].at(iRegion) /= 2;
157 fNCols[iStation].at(iRegion) /= 2;
158 fNRows[iStation].at(iRegion) *= 2;
160 SetSigma(iStation, iRegion, sigmaX, sigmaY);
168 if (iStation < 0 || iStation >=
fNStations) Fatal(
"SetPadSize",
"iStation is out of range.");
169 if (iRegion < 0 || iRegion >=
fNRegions[iStation]) Fatal(
"SetPadSize",
"iRegion is out of range.");
171 Double_t secLx =
fSecLx[iStation].at(iRegion) =
fNCols[iStation].at(iRegion) * padLx;
172 Double_t secLy =
fSecLy[iStation].at(iRegion) =
fNRows[iStation].at(iRegion) * padLy;
173 if (TMath::Abs(secLy - secLx) < 1e-5)
return;
174 if (TMath::Abs(secLy / secLx - 2) > 1e-5) {
175 if (secLy > 2 * secLx) {
176 fNCols[iStation].at(iRegion) *= 2;
177 fNRows[iStation].at(iRegion) /= 2;
180 fNCols[iStation].at(iRegion) /= 2;
181 fNRows[iStation].at(iRegion) *= 2;
286 Int_t detectorId =
module->GetDetectorId();
294 TVector3
size =
module->GetSize();
295 Double_t modLx =
size.X();
296 Double_t modLy =
size.Y();
297 Double_t modLz =
size.Z();
298 TVector3 position =
module->GetPosition();
299 Double_t modX = position.X();
300 Double_t modY = position.Y();
301 Double_t modZ = position.Z();
305 Int_t nX = modX < 0 ? -1 : 1;
306 Int_t nY = modY < 0 ? -1 : 1;
309 TVector3 secSize, secPosition;
311 for (
Int_t iCol = 0; iCol < nCols; ++iCol) {
312 secX = useModuleDesign ? modX + nX * ((iCol + 0.5) * secMaxLx - modLx / 2.)
313 : secMaxLx * nCols / 2. - (0.5 + iCol) * secMaxLx;
314 for (
Int_t iRow = 0; iRow < nRows; ++iRow) {
315 secY = useModuleDesign ? modY + nY * ((iRow + 0.5) * secMaxLy - modLy / 2.)
316 : secMaxLy * nRows / 2. - (0.5 + iRow) * secMaxLy;
317 iSector =
module->GetNSectors();
318 secSize.SetXYZ(secMaxLx, secMaxLy, modLz);
319 secPosition.SetXYZ(secX, secY, modZ);
321 fNCols[iStation].at(iRegion),
fNRows[iStation].at(iRegion)));
326 Int_t nPadRows, nPadCols;
327 Int_t n = useModuleDesign ? 1 : 2;
328 Double_t ly = useModuleDesign ? modLy - secMaxLy * nRows : (modLy - secMaxLy * nRows) / 2.;
330 nPadRows =
Int_t(ly / padMaxLy);
331 for (
Int_t i = 0; i < n; ++i) {
332 secY = useModuleDesign ? modY + nY * (modLy / 2. - ly / 2.) : TMath::Power(-1, i) * (modLy / 2. - ly / 2.);
333 for (
Int_t iCol = 0; iCol < nCols; ++iCol) {
334 secX = useModuleDesign ? modX + nX * ((iCol + 0.5) * secMaxLx - modLx / 2.)
335 : secMaxLx * nCols / 2. - (0.5 + iCol) * secMaxLx;
336 iSector =
module->GetNSectors();
337 secSize.SetXYZ(secMaxLx, ly, modLz);
338 secPosition.SetXYZ(secX, secY, modZ);
340 fNCols[iStation].at(iRegion), nPadRows));
345 Double_t lx = useModuleDesign ? modLx - secMaxLx * nCols : (modLx - secMaxLx * nCols) / 2.;
347 nPadCols = (
Int_t)(lx / padMaxLx);
348 for (
Int_t i = 0; i < n; ++i) {
349 secX = useModuleDesign ? modX + nX * (modLx / 2. - lx / 2.) : TMath::Power(-1, i) * (modLx / 2. - lx / 2.);
350 for (
Int_t iRow = 0; iRow < nRows; ++iRow) {
351 secY = useModuleDesign ? modY + nY * ((iRow + 0.5) * secMaxLy - modLy / 2.)
352 : secMaxLy * nRows / 2. - (0.5 + iRow) * secMaxLy;
353 iSector =
module->GetNSectors();
354 secSize.SetXYZ(lx, secMaxLy, modLz);
355 secPosition.SetXYZ(secX, secY, modZ);
357 fNRows[iStation].at(iRegion)));
362 if (lx > padMaxLx && ly > padMaxLy) {
363 nPadCols = (
Int_t)(lx / padMaxLx);
364 nPadRows = (
Int_t)(ly / padMaxLy);
365 secX = modX + nX * (modLx / 2. - lx / 2.);
366 secY = modY + nY * (modLy / 2. - ly / 2.);
367 iSector =
module->GetNSectors();
368 secSize.SetXYZ(lx, ly, modLz);
369 secPosition.SetXYZ(secX, secY, modZ);
378 TVector3 secSize = sector->
GetSize();
380 Int_t detectorId =
module->GetDetectorId();
382 Int_t iSector =
module->GetNSectors();
383 Double_t secLx = secSize.X();
384 Double_t secLy = secSize.Y();
385 Double_t secLz = secSize.Z();
386 Double_t padLx = sector->
GetPadDx();
387 Double_t padLy = sector->
GetPadDy();
388 Double_t secX = secPosition.X();
389 Double_t secY = secPosition.Y();
390 Double_t secZ = secPosition.Z();
394 Int_t nX = secX < 0 ? -1 : 1;
395 Int_t nY = secY < 0 ? -1 : 1;
401 if (!resultX && !resultY) {
405 Double_t rMax = station->
GetRmax();
407 nCols = isIncomplete ? nCols :
fNCols[iStation].at(iRegion);
408 nRows = isIncomplete ? nRows :
fNRows[iStation].at(iRegion);
409 module->AddSector(new CbmMuchSectorRectangular(detectorId, iSector, secPosition, secSize, nCols, nRows));
417 Double_t pLx = nC == 0 ? padLx : nC *
GetPadMaxSize(module,
"Width");
418 Double_t pLy = nR == 0 ? padLy : nR *
GetPadMaxSize(module,
"Length");
419 Double_t sLx = nC == 0 ? secLx : nC *
GetSectorMaxSize(module,
"Width", iReg);
420 Double_t sLy = nR == 0 ? secLy : nR *
GetSectorMaxSize(module,
"Length", iReg);
421 nCols =
Int_t(sLx / pLx);
422 nRows =
Int_t(sLy / pLy);
425 TVector3 position,
size;
426 Double_t newSecLx = 0., newSecLy = 0., newSecX = 0., newSecY = 0.;
427 for (
Int_t i = 0; i < 2; ++i) {
428 newSecLx = resultX ? i * (secLx - newSecLx) + (1 - i) * pLx / 2. * nCols : secLx;
429 newSecLy = resultY ? i * (secLy - newSecLy) + (1 - i) * pLy / 2. * nRows : secLy;
430 newSecX = resultX ? secX - TMath::Power(-1, i) * nX * (secLx / 2. - newSecLx / 2.) : secX;
431 newSecY = resultY ? secY - TMath::Power(-1, i) * nY * (secLy / 2. - newSecLy / 2.) : secY;
433 Double_t newPadLx = resultX ? pLx / 2. : padLx;
434 Double_t newPadLy = resultY ? pLy / 2. : padLy;
435 nCols =
Int_t(newSecLx / newPadLx);
436 nRows =
Int_t(newSecLy / newPadLy);
438 position.SetXYZ(newSecX, newSecY, secZ);
439 size.SetXYZ(newSecLx, newSecLy, secLz);
440 iSector =
module->GetNSectors();
449 if (radius < 0)
return 0;
451 Int_t intersects = 0;
453 Double_t modLx =
module->GetSize()[0];
454 Double_t modLy =
module->GetSize()[1];
455 Double_t modX =
module->GetPosition()[0];
456 Double_t modY =
module->GetPosition()[1];
458 Double_t ulR = TMath::Sqrt((modX - modLx / 2.) * (modX - modLx / 2.) + (modY + modLy / 2.) * (modY + modLy / 2.));
459 Double_t urR = TMath::Sqrt((modX + modLx / 2.) * (modX + modLx / 2.) + (modY + modLy / 2.) * (modY + modLy / 2.));
460 Double_t blR = TMath::Sqrt((modX - modLx / 2.) * (modX - modLx / 2.) + (modY - modLy / 2.) * (modY - modLy / 2.));
461 Double_t brR = TMath::Sqrt((modX + modLx / 2.) * (modX + modLx / 2.) + (modY - modLy / 2.) * (modY - modLy / 2.));
463 if (ulR < radius) intersects++;
464 if (urR < radius) intersects++;
465 if (blR < radius) intersects++;
466 if (brR < radius) intersects++;
468 if (intersects == 4)
return 2;
469 if (intersects)
return 1;
478 if (radius < 0)
return 0;
480 Int_t intersects = 0;
482 Double_t secLx = sector->
GetSize()[0];
483 Double_t secLy = sector->
GetSize()[1];
487 Double_t ulR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
488 Double_t urR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY + secLy / 2.) * (secY + secLy / 2.));
489 Double_t blR = TMath::Sqrt((secX - secLx / 2.) * (secX - secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
490 Double_t brR = TMath::Sqrt((secX + secLx / 2.) * (secX + secLx / 2.) + (secY - secLy / 2.) * (secY - secLy / 2.));
492 if (ulR < radius) intersects++;
493 if (urR < radius) intersects++;
494 if (blR < radius) intersects++;
495 if (brR < radius) intersects++;
497 if (intersects == 4)
return 2;
498 if (intersects)
return 1;
609 Int_t nTotSectors = 0;
610 Int_t nTotChannels = 0;
612 Int_t nTotStraws = 0;
613 printf(
"====================================================================="
614 "============================\n");
615 for (
Int_t iStation = 0; iStation <
fStations->GetEntriesFast(); ++iStation) {
621 Double_t padMaxLx = std::numeric_limits<Double_t>::min();
622 Double_t padMinLx = std::numeric_limits<Double_t>::max();
623 Double_t padMaxLy = std::numeric_limits<Double_t>::min();
624 Double_t padMinLy = std::numeric_limits<Double_t>::max();
625 Double_t secMaxLx = std::numeric_limits<Double_t>::min();
626 Double_t secMinLx = std::numeric_limits<Double_t>::max();
627 Double_t secMaxLy = std::numeric_limits<Double_t>::min();
628 Double_t secMinLy = std::numeric_limits<Double_t>::max();
629 if (!station)
continue;
632 if (!layer)
continue;
633 for (
Int_t iSide = 0; iSide < 2; ++iSide) {
642 if (!module)
continue;
644 nSectors +=
module->GetNSectors();
647 if (!sector)
continue;
648 Double_t padLx = sector->
GetPadDx();
649 Double_t padLy = sector->
GetPadDy();
650 if (padLx > padMaxLx) {
652 secMaxLx = sector->
GetPadNx() * padLx;
654 if (padLx < padMinLx) {
656 secMinLx = sector->
GetPadNx() * padLx;
658 if (padLy > padMaxLy) {
660 secMaxLy = sector->
GetPadNy() * padLy;
662 if (padLy < padMinLy) {
664 secMinLy = sector->
GetPadNy() * padLy;
677 printf(
"Station %i:\n", iStation + 1);
678 printf(
" GEM modules: %i\n", nGems);
680 printf(
" Sectors: %i, Min.Sector size:%3.2fx%3.2f, Max.Sector "
681 "size:%3.2fx%3.2f\n",
682 nSectors, secMinLx, secMinLy, secMaxLx, secMaxLy);
684 printf(
"Region %i: size %fx%f\n", iReg,
fSecLx.at(iStation).at(iReg),
fSecLy.at(iStation).at(iReg));
686 printf(
" Pads: %i, Min.Pad size:%3.2fx%3.2f, Max.Pad size:%3.2fx%3.2f\n", nChannels, padMinLx, padMinLy,
689 printf(
" Straw modules: %i\n", nStraws);
690 nTotSectors += nSectors;
691 nTotChannels += nChannels;
693 nTotStraws += nStraws;
695 printf(
"---------------------------------------------------------------------"
696 "----------------------------\n");
697 printf(
" Summary: \n GEM modules: %i\n Sectors: %i, Pads: %i\n "
698 "Straw modules: %i\n",
699 nTotGems, nTotSectors, nTotChannels, nTotStraws);
700 printf(
"====================================================================="
701 "============================\n");
710 for (iChar = length - 1; iChar >= 0; --iChar) {
714 txtfile[iChar + 1] =
'\0';
715 strcat(txtfile,
"txt");
718 outfile = fopen(txtfile,
"w");
727 for (
Int_t iStation = 0; iStation <
fStations->GetEntriesFast(); ++iStation) {
728 fprintf(outfile,
"=================================================================="
730 fprintf(outfile,
"Station %i\n", iStation + 1);
731 fprintf(outfile,
"Sector size, cm Sector position, cm Number of pads Side "
733 fprintf(outfile,
"------------------------------------------------------------------"
735 TCanvas* c1 =
new TCanvas(Form(
"station%i", iStation + 1), Form(
"station%i", iStation + 1), 800, 800);
737 c1->Range(-250, -250, 250, 250);
740 for (
Int_t iSide = 1; iSide >= 0; iSide--) {
746 module->InitModule();
750 Double_t secLx = sector->
GetSize()[0];
751 Double_t secLy = sector->
GetSize()[1];
763 const char* side = iSide ?
"Back" :
"Front";
764 fprintf(outfile,
"%-4.2fx%-10.2f %-6.2fx%-12.2f %-14i %-5s ", secLx, secLy, sector->
GetPosition()[0],
766 fprintf(outfile,
"%-4.2fx%-4.2f\n", sector->
GetPadDx(), sector->
GetPadDy());
772 TArc* holeArc =
new TArc(0., 0., station->
GetRmin());
775 for (
Int_t iRegion = 0; iRegion <
fNRegions[iStation]; ++iRegion) {
776 TArc* arc =
new TArc(0., 0.,
fRadii[iStation].at(iRegion));
777 arc->SetLineColor(kBlack);
778 arc->SetLineWidth(2);
779 arc->SetFillStyle(0);
783 c1->Print(Form(
"%s/station%i.eps", gSystem->DirName(
fDigiFileName), iStation + 1));
784 c1->Print(Form(
"%s/station%i.png", gSystem->DirName(
fDigiFileName), iStation + 1));
793 if (!infile) { Fatal(
"ReadInputFile",
"Error: Cannot open the input file."); }
801 strs =
Split(str,
' ');
802 index = strs.size() - 1;
804 StrToNum(strs.at(index), nStations);
806 printf(
"Number of stations: \t%i",
fNStations);
810 strs =
Split(str,
' ');
811 printf(
"\nNumber of channels: ");
815 StrToNum(strs.at(index), nChannels);
822 strs =
Split(str,
' ');
823 printf(
"\nNumber of regions: ");
838 strs =
Split(str,
' ');
839 printf(
"\nStation %i", iStation + 1);
840 printf(
"\n Region radii [cm]: ");
841 for (
Int_t iRegion = 0; iRegion <
fNRegions[iStation]; ++iRegion) {
842 index = strs.size() -
fNRegions[iStation] + iRegion;
846 printf(
"\t%4.2f",
fRadii[iStation].at(iRegion));
851 strs =
Split(str,
' ');
852 printf(
"\n Pad width [cm]: ");
853 for (
Int_t iRegion = 0; iRegion <
fNRegions[iStation]; ++iRegion) {
854 index = strs.size() -
fNRegions[iStation] + iRegion;
855 StrToNum(strs.at(index), padWidth.at(iRegion));
856 printf(
"\t%4.2f", padWidth.at(iRegion));
861 strs =
Split(str,
' ');
862 printf(
"\n Pad length [cm]: ");
863 for (
Int_t iRegion = 0; iRegion <
fNRegions[iStation]; ++iRegion) {
864 index = strs.size() -
fNRegions[iStation] + iRegion;
865 StrToNum(strs.at(index), padLength.at(iRegion));
866 printf(
"\t%4.2f", padLength.at(iRegion));
870 SetPadSize(iStation, iRegion, padWidth.at(iRegion), padLength.at(iRegion));