Optional scoring for background studies in HALL.
[u/mrichter/AliRoot.git] / STRUCT / AliHALLv3.cxx
index ea33cca..48260d9 100644 (file)
@@ -32,6 +32,8 @@
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliLog.h"
+#include "AliMC.h"
+#include "AliTrackReference.h"
 #include <TGeoVolume.h>
 #include <TGeoManager.h>
 #include <TGeoMatrix.h>
@@ -47,7 +49,7 @@
 ClassImp(AliHALL)
  
 //_____________________________________________________________________________
-AliHALLv3::AliHALLv3()
+AliHALLv3::AliHALLv3() : fNewShield24(0), fRefVolumeId(-1), fScoring(0)
 {
   //
   // Default constructor for the experimental Hall
@@ -56,7 +58,7 @@ AliHALLv3::AliHALLv3()
  
 //_____________________________________________________________________________
 AliHALLv3::AliHALLv3(const char *name, const char *title)
-       : AliHALL(name,title)
+  : AliHALL(name,title), fNewShield24(0), fRefVolumeId(-1), fScoring(0)
 {
   //
   // Standard constructor for the experimental Hall
@@ -83,14 +85,13 @@ void AliHALLv3::CreateGeometry()
   
   // Rotations
   // rotation by 90 deg in the y-z plane
-  TGeoRotation* rot000 = new TGeoRotation("rot000",  90., 0.,  0.,  0., 90., 90.);  
-  TGeoRotation* rot001 = new TGeoRotation("rot001", 270., 0., 90., 90.,  0.,  0.);  
+  TGeoRotation* rot000 = new TGeoRotation("rot000",  90., 0.,180.,  0.,    90., 90.);  
+  TGeoRotation* rot001 = new TGeoRotation("rot001", 270., 0., 90., 90.,   180.,  0.);  
 
   // Materials
   TGeoMedium* kMedCC     = gGeoManager->GetMedium("HALL_CC_C2");
   TGeoMedium* kMedST     = gGeoManager->GetMedium("HALL_STST_C2");
   TGeoMedium* kMedAir    = gGeoManager->GetMedium("HALL_AIR_C2");
-  kMedST->Dump();
   
   // Floor thickness 
   Float_t dyFloor  =  190.;
@@ -141,15 +142,15 @@ void AliHALLv3::CreateGeometry()
                                      new TGeoTrd1(xl +dl, xl, hullen, dh / 2.),
                                      kMedCC);
   r2 = hullen + zHall26;
-  asHall->AddNode(voHUFL, 1, new TGeoCombiTrans(70., -100. - dh / 2., -r2, rot000));
+  asHall->AddNode(voHUFL, 1, new TGeoCombiTrans(70., -100. - dh / 2., -r2 - 0.755, rot000));
 
   //
   // RB24/26 wall 
   phid     = phi * kRaddeg;
   TGeoVolume* voHUWA = new TGeoVolume("HUWA",
-                                     new TGeoTubeSeg(r, r+dr, hullen, phid - 90., 270. - phid),
+                                     new TGeoTubeSeg(r, r+dr, hullen, phid - 90. + 0.002, 270. - phid - 0.002),
                                      kMedCC);
-  asHall->AddNode(voHUWA, 1, new TGeoTranslation(70., 40., -zHall26 - hullen ));
+  asHall->AddNode(voHUWA, 1, new TGeoTranslation(70., 40., -zHall26 - hullen + 0.002 ));
   //
   // Air inside tunnel
   TGeoTube* shHUWAT1 = new TGeoTube(0., r, hullen);
@@ -168,14 +169,14 @@ void AliHALLv3::CreateGeometry()
   
   TGeoCompositeShape*  shHUWAT = new TGeoCompositeShape("HUWAT", "(shHUWAT1-shHUWAT2:tHUWAT2)-shHUWAT3:tHUWAT3");
   TGeoVolume* voHUWAT = new TGeoVolume("HUWAT", shHUWAT, kMedAir);
-  asHall->AddNode(voHUWAT, 1, new TGeoTranslation(70., 40., -zHall26 - hullen));
+  asHall->AddNode(voHUWAT, 1, new TGeoTranslation(70., 40., -zHall26 - hullen - 0.755));
   
   //
   //  Hall floor 
   //  RB26 side
   phid      = 16.197;
   Float_t dzFloor26 = zHall26 - dzL3/2.;
-  TGeoBBox* shHHF1 = new TGeoBBox(dxFloor/2. + 470., dyFloor/2., dzFloor26/2.);
+  TGeoBBox* shHHF1 = new TGeoBBox(dxFloor/2. + 470., dyFloor/2., dzFloor26/2. - 0.002);
   shHHF1->SetName("shHHF1");
   TGeoVolume* voHHF1 = new TGeoVolume("HHF1", shHHF1, kMedCC);
   asHall->AddNode(voHHF1, 2, new TGeoTranslation(0., yFloor, -(dzL3/2. + dzFloor26/2.)));
@@ -201,7 +202,7 @@ void AliHALLv3::CreateGeometry()
   Float_t trALP1 = TMath::ATan((trBL1 - trTL1) / 2. / trH1) * kRaddeg;
   dx = 1.5 * trBL1 - 0.5 * trTL1 + dxFloor/2. + dyFloor * TMath::Tan(phid * kDegrad);
   TGeoVolume* voHHW11 = new TGeoVolume("HHW11",
-                                      new TGeoTrap(dzFloor26/2., 0., 0., 
+                                      new TGeoTrap(dzFloor26/2. - 0.002, 0., 0., 
                                                    trH1, trBL1, trTL1, trALP1, trH1, trBL1, trTL1, trALP1),
                                       kMedCC);
   TGeoVolume* voHHW12 = new TGeoVolume("HHW12",
@@ -213,13 +214,13 @@ void AliHALLv3::CreateGeometry()
   
   asHall->AddNode(voHHW12, 1, new TGeoTranslation( dx, dy,  (dzL3/2. + dzFloor24/2.)));
   asHall->AddNode(voHHW12, 2, new TGeoCombiTrans (-dx, dy,  (dzL3/2. + dzFloor24/2.), rot001));
-  asHall->AddNode(voHHW11, 3, new TGeoTranslation( dx, dy, -(dzL3/2. + dzFloor26/2.)));
-  asHall->AddNode(voHHW11, 4, new TGeoCombiTrans (-dx, dy, -(dzL3/2. + dzFloor26/2.), rot001));
+  asHall->AddNode(voHHW11, 1, new TGeoTranslation( dx, dy, -(dzL3/2. + dzFloor26/2.)));
+  asHall->AddNode(voHHW11, 2, new TGeoCombiTrans (-dx, dy, -(dzL3/2. + dzFloor26/2.), rot001));
 
   Float_t boDY =  (yHall - (yFloor + dyFloor/2.) - 2. * trH1)/ 2.;
   Float_t dzHall = zHall26 + zHall24;
 
-  TGeoVolume* voHBW1 = new TGeoVolume("HBW1", new TGeoBBox(50., boDY, dzHall / 2.), kMedCC);
+  TGeoVolume* voHBW1 = new TGeoVolume("HBW1", new TGeoBBox(50., boDY, dzHall / 2. - 0.05), kMedCC);
 
   asHall->AddNode(voHBW1, 1,  new TGeoTranslation( 1120., yHall - boDY, (zHall24-zHall26)/2.));
   asHall->AddNode(voHBW1, 2,  new TGeoTranslation(-1120., yHall - boDY, (zHall24-zHall26)/2.));
@@ -232,7 +233,7 @@ void AliHALLv3::CreateGeometry()
   am   = hm * TMath::Tan(phim / 2. * kDegrad);
   bm   = (hm + 76.) / hm * am;
   cm   = bm * 2. / TMath::Sqrt(2.);
-  trH1   =  (1273.78 - cm) / 2.;
+  trH1   =  (1273.78 - cm) / 2. - 0.002;
   trBL1  =  235. - cm * TMath::Tan(phid * kDegrad) / 2.;
   trTL1  =   50.;
   trALP1 = TMath::ATan((trBL1 - trTL1) / 2. / trH1) * kRaddeg;
@@ -241,7 +242,7 @@ void AliHALLv3::CreateGeometry()
   dx = cm * TMath::Tan(phid * kDegrad) + dxFloor/2. + trBL1 * 1.5 - trTL1 * .5;
 
   TGeoVolume* voHHW2 = new TGeoVolume("HHW2",
-                                     new TGeoTrap(dzL3/2., 0., 0., 
+                                     new TGeoTrap(dzL3/2. - 0.002, 0., 0., 
                                                   trH1, trBL1, trTL1, trALP1, trH1, trBL1, trTL1, trALP1),
                                      kMedCC);
 
@@ -272,10 +273,10 @@ void AliHALLv3::CreateGeometry()
   
   
   TGeoVolume* voHHF2 = new TGeoVolume("HHF2", 
-                                     new TGeoTrd1(dx1FloorL3, dx2FloorL3, dzL3/2., dyFloorL3/2.), 
+                                     new TGeoTrd1(dx1FloorL3 - 0.5, dx2FloorL3 - 0.5, dzL3/2., dyFloorL3/2.), 
                                      kMedCC);
 
-  asHall->AddNode(voHHF2, 1, new TGeoCombiTrans(0., yFloor - dyFloor / 2. + dyFloorL3 / 2.,0., rot000));
+  asHall->AddNode(voHHF2, 1, new TGeoCombiTrans(0., yFloor - dyFloor / 2. + dyFloorL3 / 2. - 0.5,0., rot000));
   //
   // Tunnel roof and pit
   // Roof
@@ -301,6 +302,7 @@ void AliHALLv3::CreateGeometry()
 
   //
   // Pit wall ground level
+  dy = yFloor + 1206. / 2. + dyFloor/2.;
   TGeoTube* shHHCPW1 = new TGeoTube(rPit, rPit + 100., 1206./2.);
   shHHCPW1->SetName("shHHCPW1");
   TGeoCombiTrans* trHHCPW1 = new TGeoCombiTrans("trHHCPW1", 0., 0., 0., rot000);
@@ -308,14 +310,21 @@ void AliHALLv3::CreateGeometry()
 
   TGeoBBox* shHHCPW2 = new TGeoBBox(rPit + 100., 1206./ 2. + 20., rPit + 100.);
   shHHCPW2->SetName("shHHCPW2");
+  
+  TGeoTube* shHHCPW3 = new TGeoTube(0., 60., 60.);
+  shHHCPW3->SetName("shHHCPW3");
 
   
   TGeoTranslation* trHHCPW2 = new TGeoTranslation("trHHCPW2", 0., 0., -(rPit + 100.) - oPit);
   trHHCPW2->RegisterYourself();
 
-  TGeoCompositeShape*  shHHCPW = new TGeoCompositeShape("HHCPW", "shHHCPW1:trHHCPW1-shHHCPW2:trHHCPW2");
+  TGeoTranslation* trHHCPW3 = new TGeoTranslation("trHHCPW3", 0., -dy, rPit + 50.);
+  trHHCPW3->RegisterYourself();
+
+  TGeoCompositeShape*  shHHCPW 
+      = new TGeoCompositeShape("HHCPW", "shHHCPW1:trHHCPW1-(shHHCPW2:trHHCPW2+shHHCPW3:trHHCPW3)");
   TGeoVolume* voHHCPW = new TGeoVolume("HHCPW", shHHCPW, kMedCC);
-  dy = yFloor + 1206. / 2. + dyFloor/2.;
+
   asHall->AddNode(voHHCPW, 1, new TGeoTranslation(0., dy, 2300.));
   // 
   // Foundations of the Muon Spectrometer
@@ -334,9 +343,9 @@ void AliHALLv3::CreateGeometry()
   //
   // Transverse bars
   ys += dy;
-  dy = 126.46/2.;
+  dy = 91.32/2.;
   ys += dy;
-  TGeoVolume* voFmsMfTb1 = new TGeoVolume("FmsMfTb1", new TGeoBBox(330., dy,  90.), kMedCC);
+  TGeoVolume* voFmsMfTb1 = new TGeoVolume("FmsMfTb1", new TGeoBBox(330., dy,  60.), kMedCC);
   asFMS->AddNode(voFmsMfTb1, 1, new TGeoTranslation(0., ys, zFil));
   ys += dy;
   dy = 41.14/2.;
@@ -346,7 +355,7 @@ void AliHALLv3::CreateGeometry()
   //
   // Dipole foundation
   ys = yFloor + dyFloor / 2.;
-  dy = 263.54/2;
+  dy = (263.54 - 6.2)/2.;
   ys += dy;
   TGeoVolume* voFmsDf1 = new TGeoVolume("FmsDf1", new TGeoBBox(370., dy,  448.0 / 2.), kMedCC);
   asFMS->AddNode(voFmsDf1, 1, new TGeoTranslation(0., ys, zFil + 240. + 224.));
@@ -370,12 +379,25 @@ void AliHALLv3::CreateGeometry()
   TGeoVolume* voShRb24Ro = new TGeoVolume("ShRb24Ro", new TGeoBBox(395., 80., 520.), kMedCC);
   asShRb24->AddNode(voShRb24Ro, 1, new TGeoTranslation(0., +80. + 140., 0.));
   //
-  // Plug
+  // Concrete Plug
   TGeoBBox* shShRb24Pl1 = new TGeoBBox(235., 140., 40.);
   shShRb24Pl1->SetName("ShRb24Pl1");
+  // Steel Plug
+  TGeoBBox* shShRb24Pl4 = new TGeoBBox(15., 20., 40.);
+  shShRb24Pl4->SetName("ShRb24Pl4");
+
+  TGeoBBox* shShRb24Pl41 = new TGeoBBox(15., 20., 45.);
+  shShRb24Pl41->SetName("ShRb24Pl41");
+  
   //
   // Opening for beam pipe
-  TGeoBBox* shShRb24Pl2 = new TGeoBBox(15., 20., 60.);
+  Float_t dxShRb24Pl = 14.5;
+  Float_t dyShRb24Pl = 20.0;
+  if (fNewShield24) {
+    dxShRb24Pl = 6.;
+    dyShRb24Pl = 6.;
+  }
+  TGeoBBox* shShRb24Pl2 = new TGeoBBox(dxShRb24Pl, dyShRb24Pl, 60.);
   shShRb24Pl2->SetName("ShRb24Pl2");
   //
   // Opening for tubes
@@ -384,9 +406,29 @@ void AliHALLv3::CreateGeometry()
 
   TGeoTranslation* trPl3 = new TGeoTranslation("trPl3", +235. -90., 80., 0.);
   trPl3->RegisterYourself();
-  TGeoCompositeShape*  shRb24Pl = new TGeoCompositeShape("Rb24Pl", "ShRb24Pl1-(ShRb24Pl2+ShRb24Pl3:trPl3)");
+
+  TGeoTranslation* trPl4 = new TGeoTranslation("trPl4", 0., -6., 0.);
+  trPl4->RegisterYourself();
+  TGeoTranslation* trPl5 = new TGeoTranslation("trPl5", 0., +6., 0.);
+  trPl5->RegisterYourself();
+
+  TGeoCompositeShape*  shRb24Pl   = 0;
+  TGeoCompositeShape*  shRb24PlSS = 0;
+  if (!fNewShield24) {
+    shRb24Pl = new TGeoCompositeShape("Rb24Pl", "ShRb24Pl1-ShRb24Pl2:trPl4-ShRb24Pl3:trPl3");
+  } else {
+    shRb24Pl   = new TGeoCompositeShape("Rb24Pl",   "ShRb24Pl1-(ShRb24Pl41:trPl4+ShRb24Pl3:trPl3)");
+    shRb24PlSS = new TGeoCompositeShape("Rb24PlSS", "ShRb24Pl4-ShRb24Pl2:trPl5");
+  }
+
   TGeoVolume* voRb24Pl = new TGeoVolume("Rb24Pl", shRb24Pl, kMedCC);
+
   asShRb24->AddNode(voRb24Pl, 1, new TGeoTranslation(0., 0., 520. - 40.));
+  if (fNewShield24) {
+    TGeoVolume* voRb24PlSS = new TGeoVolume("Rb24PlSS", shRb24PlSS, kMedST);
+    asShRb24->AddNode(voRb24PlSS, 1, new TGeoTranslation(0., -6., 520. - 40.));
+   }
+
 
   //
   // Concrete platform and shielding PX24
@@ -419,14 +461,77 @@ void AliHALLv3::CreateGeometry()
   TGeoBBox* shShPx24Pl1 = new TGeoBBox(155., 140., 40.);
   shShPx24Pl1->SetName("ShPx24Pl1");
   // Opening for beam pipe
-  TGeoBBox* shShPx24Pl2 = new TGeoBBox(15., 20., 60.);
+  Float_t dxPx24Pl2 =  9.5;
+  Float_t dyPx24Pl2 = 14.0;
+  // Option for new shielding closer to the beam pipe
+  if (fNewShield24) {
+    dxPx24Pl2 = 6.;
+    dyPx24Pl2 = 6.;
+  }
+  //
+  TGeoBBox* shShPx24Pl2 = new TGeoBBox(dxPx24Pl2, dyPx24Pl2, 60.);
   shShPx24Pl2->SetName("ShPx24Pl2");
-  TGeoCompositeShape*  shPx24Pl = new TGeoCompositeShape("Px24Pl", "ShPx24Pl1-ShPx24Pl2");
+  TGeoTranslation* trPl2  = new TGeoTranslation("trPl2",  -55., 0., 0.);
+  trPl2->RegisterYourself();
+
+  TGeoCompositeShape*  shPx24Pl = new TGeoCompositeShape("Px24Pl", "ShPx24Pl1-ShPx24Pl2:trPl2");
   TGeoVolume* voPx24Pl = new TGeoVolume("Px24Pl", shPx24Pl, kMedST);
   asShPx24->AddNode(voPx24Pl, 1, new TGeoTranslation(55., 0., -1205./2. + 40.));
   asHall->AddNode(asFMS, 1, new TGeoTranslation(0.,  0., 0.));
-  
+
+  //
+  // Scoring plane for beam background simulations
+  //
+  TGeoVolume* voRB24Scoring = new TGeoVolume("RB24Scoring", new TGeoTube(4.3, 300., 1.), kMedAir);
+  asHall->AddNode(voRB24Scoring, 1, new TGeoTranslation(0., 0., 735.));
   //
+
   top->AddNode(asHall, 1, gGeoIdentity);
   
 }
+
+void AliHALLv3::Init()
+{
+  //
+  // Initialise the module after the geometry has been defined
+  //
+    if(AliLog::GetGlobalDebugLevel()>0) {
+       printf("%s: **************************************"
+              " HALL "
+              "**************************************\n",ClassName());
+       printf("\n%s:      Version 3 of HALL initialised\n\n",ClassName());
+       printf("%s: **************************************"
+              " HALL "
+              "**************************************\n",ClassName());
+    }
+//
+// The reference volume id
+    fRefVolumeId = gMC->VolId("RB24Scoring");
+}
+
+void AliHALLv3::StepManager()
+{
+//
+// Stepmanager of AliHALLv2
+// Used for recording of reference tracks entering scoring plane
+//
+  if (!fScoring) return;
+  Int_t   copy, id;
+  
+  //
+  // Only charged tracks
+  if( !(gMC->TrackCharge()) ) return; 
+  //
+  // Only tracks entering mother volume
+  // 
+
+  id=gMC->CurrentVolID(copy);
+
+  if ((id != fRefVolumeId))   return;
+  if(!gMC->IsTrackEntering()) return;
+  //
+  // Add the reference track
+  //
+  AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kHALL);
+}
+