]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0v2.cxx
Bug fix, the equalized sums were completely wrong.
[u/mrichter/AliRoot.git] / T0 / AliT0v2.cxx
index 826a643eea836d777d580c3a0425bc608829fa89..56a4074b1230f5ecf7804f5d7d95fc15aa2fb8b8 100644 (file)
 #include <Riostream.h>
 #include <stdlib.h>
 
-#include <TGeometry.h>
 #include <TLorentzVector.h>
 #include <TMath.h>
-#include <TNode.h>
-#include <TTUBE.h>
 #include <TVirtualMC.h>
 
 #include "AliMagF.h"
@@ -46,8 +43,6 @@
 #include "AliT0hit.h"
 #include "AliT0v2.h"
 #include "AliMC.h"
-//#include "AliT0hitPhoton.h"
-//#include "TGeant3.h"
 
 ClassImp(AliT0v2)
 
@@ -100,13 +95,13 @@ void AliT0v2::CreateGeometry()
 
   AliMatrix (idrotm[901], 90., 0., 90., 90., 180., 0.);
     
-  gMC->Gsvolu ("0RST", "TUBE", idtmed[3], pstart, 3);
-  gMC->Gsvolu ("0LST", "TUBE", idtmed[3], pstart, 3);
-  gMC->Gspos ("0RST", 1, "ALIC", 0., 0., -zRight, 0, "ONLY");
-  gMC->Gspos ("0LST", 1, "ALIC", 0., 0., zLeft, idrotm[901], "ONLY");
+  TVirtualMC::GetMC()->Gsvolu ("0RST", "TUBE", idtmed[3], pstart, 3);
+  TVirtualMC::GetMC()->Gsvolu ("0LST", "TUBE", idtmed[3], pstart, 3);
+  TVirtualMC::GetMC()->Gspos ("0RST", 1, "ALIC", 0., 0., -zRight, 0, "ONLY");
+  TVirtualMC::GetMC()->Gspos ("0LST", 1, "ALIC", 0., 0., zLeft, idrotm[901], "ONLY");
 
 //  12 unit: PMT + divider
-  gMC->Gsvolu("0INS", "TUBE", idtmed[3], pinstart, 3);   
+  TVirtualMC::GetMC()->Gsvolu("0INS", "TUBE", idtmed[3], pinstart, 3);   
   z = 0;
   for (i = 0; i < 12; i++)
   {
@@ -123,28 +118,28 @@ void AliT0v2::CreateGeometry()
                                 90. + theta, phi[1],
                                 theta,       phi[2]);  
 
-     gMC->Gspos ("0INS", i + 1, "0RST", x, y, z, idrotm[902 + i], "ONLY");
-     gMC->Gspos ("0INS", i + 13, "0LST", x, y, z, 0, "ONLY");
+     TVirtualMC::GetMC()->Gspos ("0INS", i + 1, "0RST", x, y, z, idrotm[902 + i], "ONLY");
+     TVirtualMC::GetMC()->Gspos ("0INS", i + 13, "0LST", x, y, z, 0, "ONLY");
   }
 
-  gMC->Gsvolu ("0PMT", "TUBE", idtmed[1], ppmt, 3);     
+  TVirtualMC::GetMC()->Gsvolu ("0PMT", "TUBE", idtmed[1], ppmt, 3);     
   x = y = 0;      
   z = -pinstart[2] + ppmt[2];
-  gMC->Gspos ("0PMT", 1, "0INS", x, y, z, 0, "ONLY");
+  TVirtualMC::GetMC()->Gspos ("0PMT", 1, "0INS", x, y, z, 0, "ONLY");
     
 // PMT
   // Entry window (glass)
-  gMC->Gsvolu ("0TOP", "TUBE", idtmed[6], ptop, 3);
+  TVirtualMC::GetMC()->Gsvolu ("0TOP", "TUBE", idtmed[6], ptop, 3);
   z = -ppmt[2] + ptop[2];
-  gMC->Gspos ("0TOP", 1, "0PMT", 0, 0, z, 0, "ONLY");
+  TVirtualMC::GetMC()->Gspos ("0TOP", 1, "0PMT", 0, 0, z, 0, "ONLY");
 
-  gMC->Gsvolu ("0REG", "TUBE", idtmed[6], preg, 3);
+  TVirtualMC::GetMC()->Gsvolu ("0REG", "TUBE", idtmed[6], preg, 3);
   z = -ppmt[2] + 2 * ptop[2] + preg[2];
-  gMC->Gspos ("0REG", 1, "0PMT", 0, 0, z, 0, "ONLY");
+  TVirtualMC::GetMC()->Gspos ("0REG", 1, "0PMT", 0, 0, z, 0, "ONLY");
 
-  gMC->Gsvolu ("0DES", "TUBE", idtmed[6], pdes, 3);
+  TVirtualMC::GetMC()->Gsvolu ("0DES", "TUBE", idtmed[6], pdes, 3);
   z = -ppmt[2] + 2 * ptop[2] + preg[2];
-  gMC->Gspos ("0DES", 1, "0PMT", 0, 0, z, 0, "ONLY");
+  TVirtualMC::GetMC()->Gspos ("0DES", 1, "0PMT", 0, 0, z, 0, "ONLY");
 }   
  
 
@@ -153,11 +148,12 @@ void AliT0v2::CreateGeometry()
 //////////////////////////////////////////////////////////////////////
 void AliT0v2::CreateMaterials()
 {
-   Int_t isxfld   = gAlice->Field()->Integ();
-   Float_t sxmgmx = gAlice->Field()->Max();
+   Int_t isxfld   = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
+   Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
+   
+   Double_t a, z, d, radl, absl;
+   TArrayT par;
    
-   Float_t a, z, d, radl, absl, buf[1];
-   Int_t nbuf;
 
 // Scintillator CH
    Float_t     ascin[2] = {1.01, 12.01};
@@ -191,6 +187,44 @@ void AliT0v2::CreateMaterials()
    Float_t wribber[3] = { 6., 12.,  1.};
    Float_t denribber  = 0.8;
    
+    
+   AliMaterial (0, "T0 Steel$", 55.850, 26., 7.87, 1.76, 999);
+   AliMaterial (1, "T0 Vacuum$", 1.e-16, 1.e-16, 1.e-16, 1.e16, 999);
+   AliMaterial (2, "T0 Air$", 14.61, 7.3, .001205, 30423., 999); 
+   
+   AliMixture (3, "Al2O3   $", aal2o3, zal2o3, denscer, -2, wal2o3);
+   AliMixture (4, "PMT glass   $", aglass, zglass, dglass, -2, wglass);
+   TString namate;
+   TVirtualMC::GetMC()->GetMaterial((*fIdmate)[3], namate, a, z, d, radl, absl, par);
+   acer[0] = a;
+   zcer[0] = z;
+   TVirtualMC::GetMC()->GetMaterial((*fIdmate)[4], namate, a, z, d, radl, absl, par);
+   acer[1] = a;
+   zcer[1] = z;
+   
+   AliMixture (5, "Scintillator$",ascin,zscin,denscin,-2,wscin);
+   AliMixture (6, "Brass    $", abrass, zbrass, denbrass, 2, wbrass);
+   AliMixture (7, "Ribber $",aribber,zribber,denribber,-3,wribber);
+   AliMixture (9, "Ceramic    $", acer, zcer, denscer, 2, wcer);
+   
+   AliMedium (1, "T0 Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
+   AliMedium (2, "Scintillator$", 5, 1, isxfld, sxmgmx, 10., .01, 1., .003, .003);
+   AliMedium (3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
+   AliMedium (4, "Ceramic$", 9, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
+   AliMedium (6, "Glass$", 4, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
+   AliMedium (8, "Steel$", 0, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
+   AliMedium (9, "Ribber  $", 7, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
+   AliMedium(11, "Brass  $", 6, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// Definition of optical properties for the Forward Multiplicity Detector
+//////////////////////////////////////////////////////////////////////
+void AliT0v2::DefineOpticalProperties()
+{
+// Optical properties definition.
 // Definition Cherenkov parameters
   const Int_t NUMENTRIES = 32;
 
@@ -237,74 +271,17 @@ void AliT0v2::CreateMaterials()
    
   Int_t *idtmed = fIdtmed->GetArray();
 
-    
-   AliMaterial (0, "T0 Steel$", 55.850, 26., 7.87, 1.76, 999);
-   AliMaterial (1, "T0 Vacuum$", 1.e-16, 1.e-16, 1.e-16, 1.e16, 999);
-   AliMaterial (2, "T0 Air$", 14.61, 7.3, .001205, 30423., 999); 
-   
-   AliMixture (3, "Al2O3   $", aal2o3, zal2o3, denscer, -2, wal2o3);
-   AliMixture (4, "PMT glass   $", aglass, zglass, dglass, -2, wglass);
-   char namate[21]="";
-   gMC->Gfmate ((*fIdmate)[3], namate, a, z, d, radl, absl, buf, nbuf);
-   acer[0] = a;
-   zcer[0] = z;
-   gMC->Gfmate ((*fIdmate)[4], namate, a, z, d, radl, absl, buf, nbuf);
-   acer[1] = a;
-   zcer[1] = z;
-   
-   AliMixture (5, "Scintillator$",ascin,zscin,denscin,-2,wscin);
-   AliMixture (6, "Brass    $", abrass, zbrass, denbrass, 2, wbrass);
-   AliMixture (7, "Ribber $",aribber,zribber,denribber,-3,wribber);
-   AliMixture (9, "Ceramic    $", acer, zcer, denscer, 2, wcer);
-   
-   AliMedium (1, "T0 Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
-   AliMedium (2, "Scintillator$", 5, 1, isxfld, sxmgmx, 10., .01, 1., .003, .003);
-   AliMedium (3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
-   AliMedium (4, "Ceramic$", 9, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
-   AliMedium (6, "Glass$", 4, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
-   AliMedium (8, "Steel$", 0, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
-   AliMedium (9, "Ribber  $", 7, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
-   AliMedium(11, "Brass  $", 6, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
-
-   gMC->SetCerenkov (idtmed[6], NUMENTRIES, ppckov, absor_qwarz, effic_all, rindex_qwarz);
-   gMC->SetCerenkov (idtmed[1], NUMENTRIES, ppckov, absor_air, effic_all, rindex_air);
+   TVirtualMC::GetMC()->SetCerenkov (idtmed[6], NUMENTRIES, ppckov, absor_qwarz, effic_all, rindex_qwarz);
+   TVirtualMC::GetMC()->SetCerenkov (idtmed[1], NUMENTRIES, ppckov, absor_air, effic_all, rindex_air);
 }
 
-
-//////////////////////////////////////////////////////////////////////
-// Draw a shaded view of the Forward multiplicity detector version 2
-//////////////////////////////////////////////////////////////////////
-void AliT0v2::DrawModule() const
-{  
-  //Set ALIC mother transparent
-  gMC->Gsatt ("ALIC", "SEEN", 0);
-
-  //Set volumes visible
-  gMC->Gsatt ("0STA", "SEEN", 0);
-  gMC->Gsatt ("0PMT", "SEEN", 1);
-  gMC->Gsatt ("0DIV", "SEEN", 1);
-
-  gMC->Gdopt ("hide", "on");
-  gMC->Gdopt ("shad", "on");
-  gMC->SetClipBox (".");
-  gMC->SetClipBox ("*", 0, 1000, -1000, 1000, -1000, 1000);
-  gMC->DefaultRange();
-  gMC->Gdraw ("alic", 40, 30, 0, 12, 9.5, 0.7, 0.7);
-  gMC->Gdhead (1111, "T-Zero detector");
-  gMC->Gdopt ("hide", "off");
-}
-
-
 //////////////////////////////////////////////////////////////////////
 // Initialises version 2 of the Forward Multiplicity Detector
 //////////////////////////////////////////////////////////////////////
 void AliT0v2::Init()
 {
-//Int_t *idtmed  = gAlice->Idtmed();
-
   AliT0::Init();
-  fIdSens1 = gMC->VolId ("0REG");
-
+  fIdSens1 = TVirtualMC::GetMC()->VolId ("0REG");
   printf ("*** T0 version 2 initialized ***\n");
 }
 
@@ -327,9 +304,9 @@ void AliT0v2::StepManager()
   TLorentzVector               mom;
   
   
-  if(!gMC->IsTrackAlive()) return; // particle has disappeared
+  if(!TVirtualMC::GetMC()->IsTrackAlive()) return; // particle has disappeared
 
-//  TGeant3  *g3 = (TGeant3*) gMC;
+//  TGeant3  *g3 = (TGeant3*) TVirtualMC::GetMC();
 //  g3->Gpcxyz();
 
   TClonesArray         &lhits = *fHits;
@@ -338,16 +315,16 @@ void AliT0v2::StepManager()
 ///////////////////////////////////////////////
 // If particles is photon then ...
 
-  if (gMC->TrackPid() == 50000050)
+  if (TVirtualMC::GetMC()->TrackPid() == 50000050)
   {
-     id = gMC->CurrentVolID(copy);
+     id = TVirtualMC::GetMC()->CurrentVolID(copy);
 
      // Check the sensetive volume
      if (id == fIdSens1) 
      {
-       if (gMC->IsTrackEntering()) 
+       if (TVirtualMC::GetMC()->IsTrackEntering()) 
        {
-          gMC->CurrentVolOffID(2,copy);
+          TVirtualMC::GetMC()->CurrentVolOffID(2,copy);
           if (copy < 13) 
             {
               vol[0] = RIGHT_ARRAY;
@@ -359,26 +336,26 @@ void AliT0v2::StepManager()
               vol[1] = copy - 12;
             }
 
-          gMC->TrackPosition(pos);
-          gMC->TrackMomentum(mom);
+          TVirtualMC::GetMC()->TrackPosition(pos);
+          TVirtualMC::GetMC()->TrackMomentum(mom);
           XYZ[0] = pos[0];
           XYZ[1] = pos[1];
           XYZ[2] = pos[2];
-          gMC->Gmtod (XYZ, xyz, 1);
+          TVirtualMC::GetMC()->Gmtod (XYZ, xyz, 1);
 
           hitPhoton[0] = sqrt (xyz[0] * xyz[0] + xyz[1] * xyz[1]);
           hitPhoton[1] = mom[0];
           hitPhoton[2] = mom[1];
           hitPhoton[3] = mom[2];
-          hitPhoton[4] = 1e9 * gMC->TrackTime();
-          hitPhoton[5] = 1e9 * gMC->Etot();
+          hitPhoton[4] = 1e9 * TVirtualMC::GetMC()->TrackTime();
+          hitPhoton[5] = 1e9 * TVirtualMC::GetMC()->Etot();
           
           AddHitPhoton (gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hitPhoton);
        }
-       gMC->StopTrack();
+       TVirtualMC::GetMC()->StopTrack();
      }
      else  
-       if (id == gMC->VolId ("0DES"))  gMC->StopTrack();
+       if (id == TVirtualMC::GetMC()->VolId ("0DES"))  TVirtualMC::GetMC()->StopTrack();
   }
 
 // end photon particalary
@@ -388,16 +365,16 @@ void AliT0v2::StepManager()
 ///////////////////////////////////////////////
 // If particles is charge then ...
  
-  // Float_t charge = gMC->TrackCharge();
+  // Float_t charge = TVirtualMC::GetMC()->TrackCharge();
   //  if(TMath::Abs(charge) <= 0.) return;
-  id = gMC->CurrentVolID(copy);
+  id = TVirtualMC::GetMC()->CurrentVolID(copy);
 
   
-  //  printf("gMC->ckine->ipart %d",gMC->ckine->ipart);
+  //  printf("TVirtualMC::GetMC()->ckine->ipart %d",TVirtualMC::GetMC()->ckine->ipart);
   // Check the sensetive volume
-  if(id==gMC->VolId("0TOP") ) {
-    if(gMC->IsTrackEntering()) {
-      gMC->CurrentVolOffID(2,copy);
+  if(id==TVirtualMC::GetMC()->VolId("0TOP") ) {
+    if(TVirtualMC::GetMC()->IsTrackEntering()) {
+      TVirtualMC::GetMC()->CurrentVolOffID(2,copy);
       if (copy < 13) 
        {
          vol[0] = RIGHT_ARRAY;
@@ -409,27 +386,27 @@ void AliT0v2::StepManager()
          vol[1] = copy - 12;
        }
       
-      gMC->TrackPosition(pos);
+      TVirtualMC::GetMC()->TrackPosition(pos);
       hits[0] = pos[0];
       hits[1] = pos[1];
       hits[2] = pos[2];
-      Float_t etot = gMC->Etot();
+      Float_t etot = TVirtualMC::GetMC()->Etot();
       hits[4] = etot;
-      Int_t part = gMC->TrackPid();
+      Int_t part = TVirtualMC::GetMC()->TrackPid();
       hits[5] = part;
-      Float_t ttime = gMC->TrackTime();
+      Float_t ttime = TVirtualMC::GetMC()->TrackTime();
       hits[6] = ttime*1e9;
       edep = 0;
     }
-    if(gMC->IsTrackInside())   {
-      Float_t de = gMC->Edep(); 
+    if(TVirtualMC::GetMC()->IsTrackInside())   {
+      Float_t de = TVirtualMC::GetMC()->Edep(); 
       edep = edep + de;
       //       printf ("E deposition %f\n",edep);
       //    for (i=0; i<=6; i++){
       //    printf(" HITS on T0 inside %f\n",hits[i]); } 
     }
-    if(gMC->IsTrackExiting())  {
-      Float_t de = gMC->Edep(); 
+    if(TVirtualMC::GetMC()->IsTrackExiting())  {
+      Float_t de = TVirtualMC::GetMC()->Edep(); 
       edep = edep + de;
       hits[3] = edep * 1e3;