@@ -539,6 +539,8 @@ void Detector::CreateHCALSpaghetti()
539539 }
540540 }
541541
542+ bool splitDet = mGeometry ->getDetectorOpeningRight () > 0.0 || mGeometry ->getDetectorOpeningLeft () > 0.0 ;
543+
542544 double TowerSize = mGeometry ->getHCALTowerSize ();
543545 double CuBoxThickness = 0.3 ; // Thickness of the Cu box carrying capillary tubes
544546
@@ -598,25 +600,57 @@ void Detector::CreateHCALSpaghetti()
598600 Columns = 0 ;
599601 RowPos = 0 .;
600602 Int_t NumTowers = 1 ;
601- for (Rows = 0 ; Rows < nTowersY; Rows++) {
602603
603- float ColumnPos = 0 .;
604- RowPos = Rows * TowerSize;
605- for (Columns = 0 ; Columns < nTowersX; Columns++) {
606- ColumnPos = Columns * TowerSize;
607- TGeoTranslation* trans = new TGeoTranslation (ColumnPos - SizeXHCAL / 2 + TowerSize / 2 , RowPos - SizeYHCAL / 2 + TowerSize / 2 , 0 .);
604+ if (splitDet) {
605+ SizeXHCAL = SizeXHCAL / 2 ;
608606
609- // Remove the Towers that overlaps with the beam pipe
610- Double_t RadialDistance = TMath::Power (trans->GetTranslation ()[0 ], 2 ) + TMath::Power (trans->GetTranslation ()[1 ], 2 );
607+ TGeoVolumeAssembly* volHalfHCAL = new TGeoVolumeAssembly (" HalfHCAL" );
611608
612- if (RadialDistance < MinRadius * MinRadius || TMath::Abs (trans->GetTranslation ()[0 ]) > SizeXHCAL / 2 ) {
613- continue ;
609+ for (Rows = 0 ; Rows < nTowersY; Rows++) {
610+
611+ float ColumnPos = 0 .;
612+ RowPos = Rows * TowerSize;
613+ for (Columns = 0 ; Columns < nTowersX / 2 ; Columns++) {
614+ ColumnPos = Columns * TowerSize;
615+ TGeoTranslation* trans = new TGeoTranslation (ColumnPos - SizeXHCAL / 2 + TowerSize / 2 , RowPos - SizeYHCAL / 2 + TowerSize / 2 , 0 .);
616+
617+ // Shit the beampipe towers by TowerSize/2
618+ if (Rows == nTowersY / 2 ) {
619+ trans->SetDx (trans->GetTranslation ()[0 ] + TowerSize / 2 );
620+ }
621+
622+ // Adding the Tower to the HCAL
623+ volHalfHCAL->AddNode (volTowerHCAL, NumTowers, trans);
624+
625+ NumTowers++;
614626 }
627+ volHCAL->AddNode (volHalfHCAL, 1 , new TGeoTranslation (SizeXHCAL / 2 + mGeometry ->getDetectorOpeningRight (), 0 , 0 ));
628+ TGeoRotation* rotFlipZ = new TGeoRotation ();
629+ rotFlipZ->RotateY (180 ); // Flip around Y to reverse Z
630+ TGeoCombiTrans* combHalf = new TGeoCombiTrans (-SizeXHCAL / 2 - mGeometry ->getDetectorOpeningLeft (), 0 ., 0 ., rotFlipZ);
631+ volHCAL->AddNode (volHalfHCAL, 2 , combHalf);
632+ }
633+ } else {
634+ for (Rows = 0 ; Rows < nTowersY; Rows++) {
615635
616- // Adding the Tower to the HCAL
617- volHCAL->AddNode (volTowerHCAL, NumTowers, trans);
636+ float ColumnPos = 0 .;
637+ RowPos = Rows * TowerSize;
638+ for (Columns = 0 ; Columns < nTowersX; Columns++) {
639+ ColumnPos = Columns * TowerSize;
640+ TGeoTranslation* trans = new TGeoTranslation (ColumnPos - SizeXHCAL / 2 + TowerSize / 2 , RowPos - SizeYHCAL / 2 + TowerSize / 2 , 0 .);
618641
619- NumTowers++;
642+ // Remove the Towers that overlaps with the beam pipe
643+ Double_t RadialDistance = TMath::Power (trans->GetTranslation ()[0 ], 2 ) + TMath::Power (trans->GetTranslation ()[1 ], 2 );
644+
645+ if (RadialDistance < MinRadius * MinRadius || TMath::Abs (trans->GetTranslation ()[0 ]) > SizeXHCAL / 2 ) {
646+ continue ;
647+ }
648+
649+ // Adding the Tower to the HCAL
650+ volHCAL->AddNode (volTowerHCAL, NumTowers, trans);
651+
652+ NumTowers++;
653+ }
620654 }
621655 }
622656
@@ -791,6 +825,8 @@ void Detector::CreateECALGeometry()
791825 // this shifts all the pixel layers to the center near the beampipe
792826 double pixshift = geom->getTowerSizeX () - (geom->getGlobalPixelWaferSizeX () * geom->getNumberOfPIXsInX ());
793827
828+ bool splitDet = mGeometry ->getDetectorOpeningRight () > 0.0 || mGeometry ->getDetectorOpeningLeft () > 0.0 ;
829+
794830 float offset = pars[2 ];
795831 // gMC->Gsvolu("EMSC1", "BOX", idtmed[3698], pars, 4);//Left towers (pixels shifted right)
796832 // gMC->Gsvolu("EMSC2", "BOX", idtmed[3698], pars, 4);//Right towers (pixels shifted left)
@@ -977,9 +1013,13 @@ void Detector::CreateECALGeometry()
9771013 // const auto towerCenter = geom->getGeoTowerCenter(number); //only ECAL part, second parameter = -1 by default
9781014 // xp = std::get<0>towerCenter;
9791015 // std::tie(xp, yp, zp) = geom->getGeoTowerCenter(number);
980- const auto [xp, yp, zp] = geom->getGeoTowerCenter (number); // only ECAL part, second parameter = -1 by default
1016+ auto [xp, yp, zp] = geom->getGeoTowerCenter (number); // only ECAL part, second parameter = -1 by default
9811017
9821018 if (itowerx == 0 ) {
1019+ if (splitDet) {
1020+ xp -= geom->getDetectorOpeningLeft ();
1021+ }
1022+
9831023 TVirtualMC::GetMC ()->Gspos (" EMSC1" , number + 1 , " ECAL" , xp, yp, 0 , 0 , " ONLY" );
9841024 // Add the SiPad front volumes directly under the FOCAL volume
9851025 if (geom->getInsertFrontPadLayers ()) {
@@ -992,6 +1032,10 @@ void Detector::CreateECALGeometry()
9921032 }
9931033 }
9941034 if (itowerx == 1 ) {
1035+ if (splitDet) {
1036+ xp += geom->getDetectorOpeningRight ();
1037+ }
1038+
9951039 TVirtualMC::GetMC ()->Gspos (" EMSC2" , number + 1 , " ECAL" , xp, yp, 0 , 0 , " ONLY" );
9961040 // Add the SiPad front volumes directly under the FOCAL volume
9971041 if (geom->getInsertFrontPadLayers ()) {
0 commit comments