]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCParam.cxx
Revert of a harmful change (A.Goel)
[u/mrichter/AliRoot.git] / TPC / AliTPCParam.cxx
index a24382ff175d7cce8efa9d8eb3acadbed1ddb0b9..7835205c877c843f864c6761051c8806845b5248 100644 (file)
@@ -33,7 +33,7 @@
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
 #include "AliAlignObj.h"
-#include "AliAlignObjAngles.h"
+#include "AliAlignObjParams.h"
 #include "AliLog.h"
 
 ClassImp(AliTPCParam)
@@ -41,16 +41,94 @@ ClassImp(AliTPCParam)
 
 //___________________________________________
 AliTPCParam::AliTPCParam()
+            :AliDetectorParam(),
+            fbStatus(kFALSE),
+             fInnerRadiusLow(0.),
+             fInnerRadiusUp(0.),
+             fOuterRadiusUp(0.),
+             fOuterRadiusLow(0.),
+            fInnerAngle(0.),
+            fInnerAngleShift(0.),
+            fOuterAngle(0.),
+            fOuterAngleShift(0.),
+            fInnerFrameSpace(0.),
+            fOuterFrameSpace(0.),
+            fInnerWireMount(0.),
+            fOuterWireMount(0.),
+            fNInnerSector(0),
+            fNOuterSector(0),
+            fNSector(0),
+            fZLength(0),
+            fRotAngle(),
+            fGeometryType(0),
+            fTrackingMatrix(0),
+            fClusterMatrix(0), 
+            fGlobalMatrix(0),
+            fNInnerWiresPerPad(0),
+            fInnerWWPitch(0),
+            fInnerDummyWire(0),
+            fInnerOffWire(0.),
+            fRInnerFirstWire(0.),
+            fRInnerLastWire(0.),
+            fLastWireUp1(0.),
+            fNOuter1WiresPerPad(0),
+            fNOuter2WiresPerPad(0),
+            fOuterWWPitch(0.),
+            fOuterDummyWire(0),
+            fOuterOffWire(0.),
+            fROuterFirstWire(0.),
+            fROuterLastWire(0.),
+            fInnerPadPitchLength(0.),
+            fInnerPadPitchWidth(0.),
+            fInnerPadLength(0.),
+            fInnerPadWidth(0.),
+            fOuter1PadPitchLength(0.),
+            fOuter2PadPitchLength(0.),
+            fOuterPadPitchWidth(0.),
+            fOuter1PadLength(0.),
+            fOuter2PadLength(0.),
+            fOuterPadWidth(0.),
+            fBMWPCReadout(kFALSE),
+            fNCrossRows(0),
+            fNRowLow(0),
+            fNRowUp1(0),
+            fNRowUp2(0),
+            fNRowUp(0),
+            fNtRows(0),
+            fDiffT(0.),
+            fDiffL(0.),
+            fGasGain(0.),
+            fDriftV(0.),
+            fOmegaTau(0.),
+            fAttCoef(0.),
+            fOxyCont(0.),
+            fPadCoupling(0.),
+            fZeroSup(0),
+            fNoise(0.),
+            fChipGain(0.),
+            fChipNorm(0.),
+            fTSample(0.),
+            fZWidth(0.),
+            fTSigma(0.),
+            fMaxTBin(0),
+            fADCSat(0),
+            fADCDynRange(0.),
+            fTotalNormFac(0.),
+            fNoiseNormFac(0.),
+            fNResponseMax(0),
+            fResponseThreshold(0.),
+            fCurrentMax(0),
+            fResponseBin(0),
+            fResponseWeight(0),
+            fGateDelay(0.),
+            fL1Delay(0.),
+            fNTBinsBeforeL1(0),
+            fNTBinsL1(0.)   
 {   
   //
   //constructor sets the default parameters
   //
 
-  fResponseBin = 0;
-  fResponseWeight = 0;
-  fRotAngle = 0;
-  //  fChamberPos = fChamberRot = 0;
-  fTrackingMatrix = fClusterMatrix = fGlobalMatrix = 0;
   SetTitle("75x40_100x60_150x60");
   SetDefault();  
 }
@@ -64,24 +142,25 @@ AliTPCParam::~AliTPCParam()
   if (fResponseBin!=0)    delete [] fResponseBin;
   if (fResponseWeight!=0) delete [] fResponseWeight;
   if (fRotAngle      !=0) delete [] fRotAngle;
-  //  if (fChamberPos    !=0) delete [] fChamberPos;
-  //  if (fChamberRot    !=0) delete [] fChamberRot;
-
-//   if (fTrackingMatrix!=0) {
-//     for(Int_t i=0;i<fNSector;i++)
-//       delete fTrackingMatrix[i];
-//     delete [] fTrackingMatrix;
-//   }
-//   if (fClusterMatrix!=0) {
-//     for(Int_t i=0;i<fNSector;i++)
-//       delete fClusterMatrix[i];
-//     delete [] fClusterMatrix;
-//   }
-//   if (fGlobalMatrix!=0) {
-//     for(Int_t i=0;i<fNSector;i++)
-//       delete fGlobalMatrix[i];
-//     delete [] fGlobalMatrix;
-//   }
+
+  if (fTrackingMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fTrackingMatrix[i];
+    delete [] fTrackingMatrix;
+  }
+
+  if (fClusterMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fClusterMatrix[i];
+    delete [] fClusterMatrix;
+  }
+
+  if (fGlobalMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fGlobalMatrix[i];
+    delete [] fGlobalMatrix;
+  }
+
 }
 
 
@@ -117,7 +196,8 @@ Int_t  AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index)  const
       if (xyz[2]<0)    sector+=(fNOuterSector>>1);            
     }
     else   
-      if (xyz[2]<0) sector+=(fNInnerSector>>1);    
+      if (xyz[2]<0) sector+=(fNInnerSector>>1);  
+  if (sector<0 || sector>=fNSector) AliError(Form("Wrong sector %d",sector));
   index[1]=sector; // calculated sector number
   index[0]=1; // indicates system after transformation
   return sector;
@@ -351,9 +431,12 @@ void AliTPCParam::SetDefault()
   static const Int_t     kNResponseMax=100;
   static const Float_t   kResponseThreshold=0.01;     
   //L1 constants
-  static const Float_t   kGateDelay=6.1e-6; //In s
-  static const Float_t   kL1Delay=6.5e-6; //In s
-  static const UShort_t  kNTBinsBeforeL1=14;
+  //  static const Float_t   kGateDelay=6.1e-6; //In s
+  static const Float_t   kGateDelay=0.; //For the moment no gating
+  //  static const Float_t   kL1Delay=6.5e-6; //In s
+  static const Float_t   kL1Delay=0.; //For the moment no delay
+  //  static const UShort_t  kNTBinsBeforeL1=14;
+  static const UShort_t  kNTBinsBeforeL1=0; //For the moment no shift
   fbStatus = kFALSE;
   //
   //set sector parameters
@@ -513,8 +596,8 @@ Bool_t AliTPCParam::Update()
   //
   //response data
   //
-  if (fResponseBin==0) delete [] fResponseBin;
-  if (fResponseWeight==0) delete [] fResponseBin;
+  if (fResponseBin) delete [] fResponseBin;
+  if (fResponseWeight) delete [] fResponseWeight;
   fResponseBin    = new Int_t[3*fNResponseMax];
   fResponseWeight = new Float_t[fNResponseMax];
 
@@ -528,12 +611,12 @@ Bool_t AliTPCParam::Update()
 
 Bool_t AliTPCParam::ReadGeoMatrices(){
   //
-  //read geo matrixes
+  // read geo matrixes
   //
   if (!gGeoManager){
     AliFatal("Geo manager not initialized\n");
   }
-  AliAlignObjAngles o;
+  AliAlignObjParams o;
   //
   if (fTrackingMatrix) delete [] fTrackingMatrix;
   fTrackingMatrix = new TGeoHMatrix*[fNSector];
@@ -541,38 +624,90 @@ Bool_t AliTPCParam::ReadGeoMatrices(){
   fClusterMatrix = new TGeoHMatrix*[fNSector];
   if (fGlobalMatrix) delete [] fGlobalMatrix;
   fGlobalMatrix = new TGeoHMatrix*[fNSector];
+  for (Int_t isec=0; isec<fNSector; isec++) {
+    fGlobalMatrix[isec] = 0;
+    fClusterMatrix[isec]= 0;
+    fTrackingMatrix[isec]=0;
+  }   
   //
   for (Int_t isec=0; isec<fNSector; isec++) {
     fGlobalMatrix[isec] = 0;
-    AliAlignObj::ELayerID iLayer;
+    fClusterMatrix[isec]= 0;
+    fTrackingMatrix[isec]=0;   
+    AliGeomManager::ELayerID iLayer;
     Int_t iModule;
 
     if(isec<fNInnerSector) {
-      iLayer = AliAlignObj::kTPC1;
+      iLayer = AliGeomManager::kTPC1;
       iModule = isec;
     }
     else {
-      iLayer = AliAlignObj::kTPC2;
+      iLayer = AliGeomManager::kTPC2;
       iModule = isec - fNInnerSector;
     }
 
-    UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
-    const char *path = AliAlignObj::GetVolPath(volid);
-    gGeoManager->cd(path);
-    TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
+    UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
+    TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(volid);
+    if(!pne)
+    {
+      AliError(Form("Alignable entry for volume ID %d not in geometry. Exiting!",volid));
+      return kFALSE;
+    }
+    const char *path = pne->GetTitle();
+    if (!gGeoManager->cd(path)) return kFALSE;
+    TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
+    // Since GEANT4 does not allow reflections, in this case the reflection
+    // component if the matrix is embedded by TGeo inside TGeoScaledShape
+    if (gGeoManager->GetCurrentVolume()->GetShape()->IsReflected()) 
+       m->ReflectZ(kFALSE, kTRUE);
     //
     TGeoRotation mchange; 
     mchange.RotateY(90); mchange.RotateX(90);
-    Float_t x0 = GetChamberCenter(isec);
-    TGeoTranslation center("center",-x0,0,0);
+    Float_t ROCcenter[3]; 
+    GetChamberCenter(isec,ROCcenter);
+    //
     // Convert to global coordinate system
-    //m->Multiply(&center);
+    //
     fGlobalMatrix[isec] = new TGeoHMatrix(*m);
     fGlobalMatrix[isec]->Multiply(&(mchange.Inverse()));
+    TGeoTranslation center("center",-ROCcenter[0],-ROCcenter[1],-ROCcenter[2]);
+    fGlobalMatrix[isec]->Multiply(&center);
+    //
+    //  cluster correction matrix
+    //
+    fClusterMatrix[isec] = new TGeoHMatrix;
+    Double_t sectorAngle = 20.*(isec%18)+10;
+    TGeoHMatrix  rotMatrix;
+    rotMatrix.RotateZ(sectorAngle);
+    if (GetGlobalMatrix(isec)->GetTranslation()[2]>0){
+      //
+      // mirrored system 
+      //
+      TGeoRotation mirrorZ;
+      mirrorZ.SetAngles(90,0,90,90,180,0);
+      fClusterMatrix[isec]->Multiply(&mirrorZ);
+    }
+    TGeoTranslation trans(0,0,GetZLength(isec));
+    fClusterMatrix[isec]->MultiplyLeft(&trans);
+    fClusterMatrix[isec]->MultiplyLeft((GetGlobalMatrix(isec)));       
+    fClusterMatrix[isec]->MultiplyLeft(&(rotMatrix.Inverse()));
   }
   return kTRUE;
 }
 
+TGeoHMatrix *  AliTPCParam::Tracking2LocalMatrix(const TGeoHMatrix * geoMatrix, Int_t sector) const{
+  //
+  // make local to tracking matrix
+  //
+  Double_t sectorAngle = 20.*(sector%18)+10;
+  TGeoHMatrix *newMatrix = new TGeoHMatrix();
+  newMatrix->RotateZ(sectorAngle);
+  newMatrix->MultiplyLeft(&(geoMatrix->Inverse()));
+  return newMatrix;
+}
+
+
+
 
 Bool_t AliTPCParam::GetStatus() const
 {
@@ -669,14 +804,30 @@ Int_t AliTPCParam::GetSectorIndex(Float_t angle, Int_t row, Float_t z) const
   return sector;
 }
 
-Float_t AliTPCParam::GetChamberCenter(Int_t isec) const
+Float_t AliTPCParam::GetChamberCenter(Int_t isec, Float_t * center) const
 {
   // returns the default radial position
   // of the readout chambers
-  if (isec<fNInnerSector)
-    return (fInnerRadiusLow+fInnerRadiusUp)/2.;
-  else
-    return (fOuterRadiusLow+fOuterRadiusUp)/2.;
+
+  const Float_t kROCcenterIn = 110.2;
+  const Float_t kROCcenterOut = 188.45;
+
+  if (isec<fNInnerSector){
+    if (center){
+      center[0] = kROCcenterIn;
+      center[1] = 0; 
+      center[2] = -5.51-0.08; 
+    }
+    return kROCcenterIn;
+  }
+  else{
+    if (center){
+      center[0] = kROCcenterOut;
+      center[1] = 0; 
+      center[2] = -5.61-0.08; 
+    }
+    return kROCcenterOut;
+  }
 }