]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDv1.cxx
Fix of TOF problem, Calculation of dEdx and PID during propagation to TOF, Writing...
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
index 0c238f9c51b1b11165d97fbed4d692f133ca0b11..19b1a7e4beb092999648b0bf7365e01a26ef511e 100644 (file)
 #include <TVector.h>
 #include <TVirtualMC.h>
 #include <TGeoManager.h>
+#include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
 
 #include "AliConst.h"
 #include "AliLog.h"
+#include "AliTrackReference.h"
 #include "AliMC.h"
 #include "AliRun.h"
 
 #include "AliTRDgeometry.h"
 #include "AliTRDhit.h"
-#include "AliTRDsim.h"
+#include "AliTRDsimTR.h"
 #include "AliTRDv1.h"
 
 ClassImp(AliTRDv1)
@@ -117,14 +120,16 @@ void AliTRDv1::AddAlignableVolumes() const
   TString volPath;
   TString symName;
 
-  TString vpStr  = "ALIC_1/B077_1/BSEGMO";
-  TString vpApp1 = "_1/BTRD";
-  TString vpApp2 = "_1";
-  TString vpApp3 = "/UTR1_1/UTS1_1/UTI1_1/UT";
+  TString vpStr   = "ALIC_1/B077_1/BSEGMO";
+  TString vpApp1  = "_1/BTRD";
+  TString vpApp2  = "_1";
+  TString vpApp3a = "/UTR1_1/UTS1_1/UTI1_1/UT";
+  TString vpApp3b = "/UTR2_1/UTS2_1/UTI2_1/UT";
+  TString vpApp3c = "/UTR3_1/UTS3_1/UTI3_1/UT";
 
-  TString snStr  = "TRD/sm";
-  TString snApp1 = "/st";
-  TString snApp2 = "/pl";
+  TString snStr   = "TRD/sm";
+  TString snApp1  = "/st";
+  TString snApp2  = "/pl";
 
   //
   // The super modules
@@ -154,6 +159,9 @@ void AliTRDv1::AddAlignableVolumes() const
   //                         TRD/sm17/st4/pl5
   //
   for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) {
+
+    if (fGeometry->GetSMstatus(isect) == 0) continue;
+
     for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) {
       for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) {
 
@@ -164,7 +172,22 @@ void AliTRDv1::AddAlignableVolumes() const
         volPath += vpApp1;
         volPath += isect;
         volPath += vpApp2;
-        volPath += vpApp3;
+        switch (isect) {
+        case 13:
+        case 14:
+        case 15:
+          if (icham == 2) {
+            continue;
+         }
+          volPath += vpApp3c;
+          break;
+        case 11:
+        case 12:
+          volPath += vpApp3b;
+          break;
+        default:
+          volPath += vpApp3a;
+       };
         volPath += Form("%02d",idet);
         volPath += vpApp2;
 
@@ -175,7 +198,26 @@ void AliTRDv1::AddAlignableVolumes() const
         symName += snApp2;
         symName += iplan;
 
-        gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
+        TGeoPNEntry *alignableEntry = 
+         gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data());
+
+       // Add the tracking to local matrix following the TPC example
+       if (alignableEntry) {
+         const char *path = alignableEntry->GetTitle();
+         if (!gGeoManager->cd(path)) {
+           AliFatal(Form("Volume path %s not valid!",path));
+         }
+         // Is this correct still????
+         TGeoHMatrix *globMatrix = gGeoManager->GetCurrentMatrix();
+         Double_t sectorAngle = 20.0 * (isect % 18) + 10.0;
+         TGeoHMatrix *t2lMatrix  = new TGeoHMatrix();
+         t2lMatrix->RotateZ(sectorAngle);
+         t2lMatrix->MultiplyLeft(&(globMatrix->Inverse()));
+         alignableEntry->SetMatrix(t2lMatrix);
+       }
+       else {
+         AliError(Form("Alignable entry %s is not valid!",symName.Data()));
+       }
 
       }
     }
@@ -297,12 +339,11 @@ void AliTRDv1::CreateTRhit(Int_t det)
 
     // Add the hit to the array. TR photon hits are marked 
     // by negative charge
-    // The hit time is needed for pile-up events
     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
           ,det
           ,posHit
           ,-q
-         ,gMC->TrackTime()*1.0e06
+          ,gMC->TrackTime()*1.0e06
           ,kTRUE);
 
   }
@@ -325,7 +366,7 @@ void AliTRDv1::Init()
     AliInfo("TR simulation off");
   }
   else {
-    fTR = new AliTRDsim();
+    fTR = new AliTRDsimTR();
   }
 
   // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
@@ -511,7 +552,7 @@ void AliTRDv1::StepManagerGeant()
         // Create a track reference at the entrance of each
         // chamber that contains the momentum components of the particle
         gMC->TrackMomentum(mom);
-        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
 
         // Create the hits from TR photons if electron/positron is
         // entering the drift volume
@@ -527,7 +568,7 @@ void AliTRDv1::StepManagerGeant()
         // Create a track reference at the exit of each
         // chamber that contains the momentum components of the particle
         gMC->TrackMomentum(mom);
-        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
 
       }
 
@@ -595,12 +636,11 @@ void AliTRDv1::StepManagerGeant()
         qTot = ((Int_t) (eDelta / kWion) + 1);
 
         // Create a new dEdx hit
-        // The hit time is needed for pile-up events
         AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
               ,det
               ,hits
               ,qTot
-             ,gMC->TrackTime()*1.0e06
+              ,gMC->TrackTime()*1.0e06
               ,drRegion);
 
       }
@@ -759,7 +799,7 @@ void AliTRDv1::StepManagerErmilova()
         // Create a track reference at the entrance of each
         // chamber that contains the momentum components of the particle
         gMC->TrackMomentum(mom);
-        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
 
         // Create the hits from TR photons if electron/positron is
         // entering the drift volume
@@ -775,7 +815,7 @@ void AliTRDv1::StepManagerErmilova()
         // Create a track reference at the exit of each
         // chamber that contains the momentum components of the particle
         gMC->TrackMomentum(mom);
-        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+        AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
 
       }
 
@@ -789,13 +829,12 @@ void AliTRDv1::StepManagerErmilova()
         qTot = ((Int_t) (eDelta / kWion) + 1);
 
        // Create a new dEdx hit
-        // The hit time is needed for pile-up events
         if (drRegion) {
           AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber()
                 ,det
                 ,hits
                 ,qTot
-               ,gMC->TrackTime()*1.0e06
+                ,gMC->TrackTime()*1.0e06
                 ,kTRUE);
        }
         else {
@@ -803,7 +842,7 @@ void AliTRDv1::StepManagerErmilova()
                 ,det
                 ,hits
                 ,qTot
-               ,gMC->TrackTime()*1.0e06
+                ,gMC->TrackTime()*1.0e06
                 ,kFALSE);
        }
 
@@ -945,7 +984,7 @@ void AliTRDv1::StepManagerFixedStep()
   // The detector number
   det = fGeometry->GetDetector(pla,cha,sec);
 
-  // 0:InFlight 1:Entering 2:Exiting
+  // 0: InFlight 1:Entering 2:Exiting
   Int_t trkStat = 0;
 
   // Special hits only in the drift region
@@ -955,7 +994,7 @@ void AliTRDv1::StepManagerFixedStep()
     // Create a track reference at the entrance of each
     // chamber that contains the momentum components of the particle
     gMC->TrackMomentum(mom);
-    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
     trkStat = 1;
 
     // Create the hits from TR photons if electron/positron is
@@ -972,14 +1011,13 @@ void AliTRDv1::StepManagerFixedStep()
     // Create a track reference at the exit of each
     // chamber that contains the momentum components of the particle
     gMC->TrackMomentum(mom);
-    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTRD);
     trkStat = 2;
 
   }
   
   // Calculate the charge according to GEANT Edep
   // Create a new dEdx hit
-  // The hit time is needed for pile-up events
   eDep = TMath::Max(gMC->Edep(),0.0) * 1.0e+09;
   qTot = (Int_t) (eDep / kWion);
   if ((qTot) ||
@@ -988,7 +1026,7 @@ void AliTRDv1::StepManagerFixedStep()
           ,det
           ,hits
           ,qTot
-         ,gMC->TrackTime()*1.0e06
+          ,gMC->TrackTime()*1.0e06
           ,drRegion);
   }
 
@@ -1189,6 +1227,10 @@ Double_t IntSpecGeant(Double_t *x, Double_t *)
   Int_t    i;
   Double_t energy = x[0];
 
+  if (energy >= arre[npts-1]) {
+    return 0.0;
+  }
+
   for (i = 0; i < npts; i++) {
     if (energy < arre[i]) {
       break;