]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCv2.cxx
Adding missing protection if no data - AliTPCCalibViewerGUI.cxx AliTPCCalibViewe...
[u/mrichter/AliRoot.git] / TPC / AliTPCv2.cxx
index 6832f297d2389f8c204179a16648121200f492e8..194c24dd9e5e607b81a91ea58761fd6913a45756 100644 (file)
@@ -35,6 +35,7 @@
 #include <TPDGCode.h>
 #include <TString.h>
 #include "AliLog.h"
+#include "AliTrackReference.h"
 #include "AliTPCParam.h"
 #include "AliTPCTrackHitsV2.h"
 #include "AliTPCv2.h"
@@ -45,6 +46,8 @@
 #include "TGeoTrd1.h"
 #include "TGeoCompositeShape.h"
 #include "TGeoPara.h"
+#include "TGeoPhysicalNode.h"
+
 ClassImp(AliTPCv2)
  
 //_____________________________________________________________________________
@@ -678,12 +681,12 @@ void AliTPCv2::CreateGeometry()
    Double_t x0,y0;
    x0=110.2*TMath::Cos(openingAngle);
    y0=110.2*TMath::Sin(openingAngle);
-   TGeoCombiTrans *combi1a = new TGeoCombiTrans("combi1",x0,y0,1.09+0.222,rot); //a-side 
-   TGeoCombiTrans *combi1c = new TGeoCombiTrans("combi1",x0,y0,1.09+0.195,rot); //c-side
+   TGeoCombiTrans *combi1a = new TGeoCombiTrans("combi1",x0,y0,1.09+0.195,rot); //a-side 
+   TGeoCombiTrans *combi1c = new TGeoCombiTrans("combi1",x0,y0,1.09+0.222,rot); //c-side
    x0=188.45*TMath::Cos(openingAngle);
    y0=188.45*TMath::Sin(openingAngle);
-   TGeoCombiTrans *combi2a = new TGeoCombiTrans("combi2",x0,y0,0.99+0.222,rot); //a-side
-   TGeoCombiTrans *combi2c = new TGeoCombiTrans("combi2",x0,y0,0.99+0.195,rot); //c-side
+   TGeoCombiTrans *combi2a = new TGeoCombiTrans("combi2",x0,y0,0.99+0.195,rot); //a-side
+   TGeoCombiTrans *combi2c = new TGeoCombiTrans("combi2",x0,y0,0.99+0.222,rot); //c-side
    //
    //
    // A-side
@@ -882,6 +885,8 @@ void AliTPCv2::CreateGeometry()
     gGeoManager->Node("TPC_Rod",i+55,"TPC_Drift",x,y,-z,0,kTRUE,upar,3);
   }
 
+  delete [] upar;
+
   TGeoVolume *alice = gGeoManager->GetVolume("ALIC");
   alice->AddNode(v1,1);  
   
@@ -912,17 +917,25 @@ void AliTPCv2::SetInnerChambersAlignable() const
   TString snappend="/InnerChamber";
   TString volpath, symname;
   
-    for(Int_t cnt=1; cnt<=18; cnt++){
-      volpath = vpstr1;
-      volpath += cnt;
-      volpath += vpappend;
-      symname = snstr1;
-      symname += cnt;
-      symname += snappend;
+  for(Int_t cnt=1; cnt<=18; cnt++){
+    volpath = vpstr1;
+    volpath += cnt;
+    volpath += vpappend;
+    symname = snstr1;
+    symname += cnt;
+    symname += snappend;
     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
-      modnum++;
-    }
+    //
+    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data());
+    const char *path = alignableEntry->GetTitle();
+    if (!gGeoManager->cd(path))
+      AliFatal(Form("Volume path %s not valid!",path));
+    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,cnt-1);
+    alignableEntry->SetMatrix(matTtoL);
+    modnum++;
+  }
 
   for(Int_t cnt=1; cnt<=18; cnt++){
     volpath = vpstr2;
@@ -933,6 +946,13 @@ void AliTPCv2::SetInnerChambersAlignable() const
     symname += snappend;
     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
+    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data());
+    const char *path = alignableEntry->GetTitle();
+    if (!gGeoManager->cd(path))
+      AliFatal(Form("Volume path %s not valid!",path));
+    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,18+cnt-1);
+    alignableEntry->SetMatrix(matTtoL);
     modnum++;
   }
 }
@@ -959,6 +979,13 @@ void AliTPCv2::SetOuterChambersAlignable() const
     symname += snappend;
     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
+    TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data());
+    const char *path = alignableEntry->GetTitle();
+    if (!gGeoManager->cd(path))
+      AliFatal(Form("Volume path %s not valid!",path));
+    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,36+cnt-1);
+    alignableEntry->SetMatrix(matTtoL);
     modnum++;
   }
 
@@ -971,6 +998,13 @@ void AliTPCv2::SetOuterChambersAlignable() const
     symname += snappend;
     if(!gGeoManager->SetAlignableEntry(symname.Data(),volpath.Data()))
       AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symname.Data(),volpath.Data()));
+     TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(symname.Data());
+    const char *path = alignableEntry->GetTitle();
+    if (!gGeoManager->cd(path))
+      AliFatal(Form("Volume path %s not valid!",path));
+    TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+    TGeoHMatrix* matTtoL = fTPCParam->Tracking2LocalMatrix(globMatrix,36+18+cnt-1);
+    alignableEntry->SetMatrix(matTtoL);
     modnum++;
   }
 }
@@ -1110,9 +1144,17 @@ void AliTPCv2::Init()
   fIDrift=gMC->VolId("TPC_Drift");
   fSecOld=-100; // fake number 
 
-  gMC->SetMaxNStep(30000); // max. number of steps increased
+  gMC->SetMaxNStep(-30000); // max. number of steps increased
+
+  if (fPrimaryIonisation) {
+      gMC->Gstpar(idtmed[2],"PRIMIO_E", 20.77); // 1st ionisation potential
+      gMC->Gstpar(idtmed[2],"PRIMIO_N", 14.35);
+      gMC->Gstpar(idtmed[2],"LOSS", 14); // specific energy loss
+  } else {
+      gMC->Gstpar(idtmed[2],"LOSS", 5); // specific energy loss
+  }
 
-  gMC->Gstpar(idtmed[2],"LOSS",5); // specific energy loss
 
   AliInfo("*** TPC version 2 initialized ***");
   AliInfo(Form("Maximum number of steps = %d",gMC->GetMaxNStep()));
@@ -1145,7 +1187,7 @@ void AliTPCv2::StepManager()
   
   vol[1]=0; // preset row number to 0
   //
-  gMC->SetMaxStep(kbig);
+  if (fPrimaryIonisation) gMC->SetMaxStep(kbig);
   
   if(!gMC->IsTrackAlive()) return; // particle has disappeared
   
@@ -1194,7 +1236,7 @@ void AliTPCv2::StepManager()
   if(sector != fSecOld){
     fSecOld=sector;
     // add track reference
-    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kTPC);
   }  
   // track is in the sensitive strip
   if(id == fIdSens){
@@ -1240,8 +1282,14 @@ void AliTPCv2::StepManager()
   //  charged particle is in the sensitive drift volume
   //-----------------------------------------------------------------
   if(gMC->TrackStep() > 0) {
-
-    Int_t nel = (Int_t)(((gMC->Edep())-kpoti)/kwIon) + 1;
+    Int_t nel=0;
+    if (!fPrimaryIonisation) {
+      nel = (Int_t)(((gMC->Edep())-kpoti)/kwIon) + 1;
+    }
+    else {
+         Float_t edep = gMC->Edep();
+         if (edep > 0.) nel = (Int_t)((gMC->Edep()*1.5)/kwIon) + 1;      
+    }
     nel=TMath::Min(nel,300); // 300 electrons corresponds to 10 keV
     //
     gMC->TrackPosition(p);
@@ -1270,28 +1318,30 @@ void AliTPCv2::StepManager()
   
   Float_t pp;
   TLorentzVector mom;
-  gMC->TrackMomentum(mom);
-  Float_t ptot=mom.Rho();
-  Float_t betaGamma = ptot/gMC->TrackMass();
-  
-  Int_t pid=gMC->TrackPid();
-  if((pid==kElectron || pid==kPositron) && ptot > 0.002)
-    { 
-      pp = kprim*1.58; // electrons above 20 MeV/c are on the plateau!
-    }
-  else
-    {
+  // below is valid only for Geant3 (fPromaryIonisation not set)
+  if(!fPrimaryIonisation){
+    gMC->TrackMomentum(mom);
+    Float_t ptot=mom.Rho();
+    Float_t betaGamma = ptot/gMC->TrackMass();
+
+    Int_t pid=gMC->TrackPid();
+    if((pid==kElectron || pid==kPositron) && ptot > 0.002)
+      { 
+        pp = kprim*1.58; // electrons above 20 MeV/c are on the plateau!
+      }
+    else
+      {
 
-      betaGamma = TMath::Max(betaGamma,(Float_t)7.e-3); // protection against too small bg
-      pp=kprim*BetheBloch(betaGamma); 
+        betaGamma = TMath::Max(betaGamma,(Float_t)7.e-3); // protection against too small bg
+        pp=kprim*BetheBloch(betaGamma); 
    
-      if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
+        if(TMath::Abs(charge) > 1.) pp *= (charge*charge);
     }
   
-  Double_t rnd = gMC->GetRandom()->Rndm();
-  
-  gMC->SetMaxStep(-TMath::Log(rnd)/pp);
+    Double_t rnd = gMC->GetRandom()->Rndm();
   
+    gMC->SetMaxStep(-TMath::Log(rnd)/pp);
+  }
   
 }