]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAlignObj.cxx
Updated path to the TRD alignable volumes (Dariusz)
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
index ed562b233a8b1b04b3fb3bfbccbb09351e4a661f..61f49af2398d4641ca8b9b620ae3fae4abf41572 100644 (file)
@@ -45,7 +45,7 @@ Int_t AliAlignObj::fgLayerSize[kLastLayer - kFirstLayer] = {
   748, 950, // ITS SSD
   36, 36,   // TPC
   90, 90, 90, 90, 90, 90,  // TRD
-  1674,     // TOF
+  1638,     // TOF
   1, 1,     // PHOS ??
   7,        // RICH ??
   1         // MUON ??
@@ -98,6 +98,23 @@ AliAlignObj::AliAlignObj():
   InitVolPaths();
 }
 
+//_____________________________________________________________________________
+AliAlignObj::AliAlignObj(const char* volpath, UShort_t voluid) : TObject()
+{
+  // standard constructor
+  //
+  fVolPath=volpath;
+  fVolUID=voluid;
+}
+
+AliAlignObj::AliAlignObj(const char* volpath, ELayerID detId, Int_t volId) : TObject()
+{
+  // standard constructor
+  // 
+  fVolPath=volpath;
+  SetVolUID(detId,volId); 
+}
+
 //_____________________________________________________________________________
 AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
   TObject(theAlignObj)
@@ -160,6 +177,32 @@ void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
   layerId = VolUIDToLayer(fVolUID,modId);
 }
 
+//_____________________________________________________________________________
+Int_t AliAlignObj::GetLevel() const
+{
+  // Return the geometry level of
+  // the alignable volume to which
+  // the alignment object is associated
+  TString volpath = fVolPath;
+  return (volpath.CountChar('/')+1);
+}
+
+//_____________________________________________________________________________
+Int_t AliAlignObj::Compare(const TObject *obj) const
+{
+  // Compare the levels of two
+  // alignment objects
+  // Used in the sorting during
+  // the application of alignment
+  // objects to the geometry
+  Int_t level = GetLevel();
+  Int_t level2 = ((AliAlignObj *)obj)->GetLevel();
+  if (level == level2)
+    return 0;
+  else
+    return ((level > level2) ? 1 : -1);
+}
+
 //_____________________________________________________________________________
 void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
 {
@@ -189,7 +232,7 @@ Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
 {
   // Calculates the Euler angles in "x y z" notation
   // using the rotation matrix
-  if(rot[0]<1e-7 || rot[8]<1e-7) return kFALSE;
+  if(TMath::Abs(rot[0])<1e-7 || TMath::Abs(rot[8])<1e-7) return kFALSE;
   Double_t raddeg = TMath::RadToDeg();
   angles[0]=raddeg*TMath::ATan2(-rot[5],rot[8]);
   angles[1]=raddeg*TMath::ASin(rot[2]);
@@ -224,9 +267,11 @@ void AliAlignObj::Transform(AliTrackPoint &p) const
   
 }
 
-//______________________________________________________________________________
+//_____________________________________________________________________________
 void AliAlignObj::Transform(AliTrackPointArray &array) const
 {
+  // This method is used to transform all the track points
+  // from the input AliTrackPointArray
   AliTrackPoint p;
   for (Int_t i = 0; i < array.GetNPoints(); i++) {
     array.GetPoint(p,i);
@@ -248,17 +293,48 @@ void AliAlignObj::Print(Option_t *) const
   TGeoHMatrix m;
   GetMatrix(m);
   const Double_t *rot = m.GetRotationMatrix();
-//   printf("Volume=%s ID=%u\n", GetVolPath(),GetVolUID());
-  ELayerID layerId;
-  Int_t modId;
-  GetVolUID(layerId,modId);
-  printf("Volume=%s LayerID=%d ModuleID=%d\n", GetVolPath(),layerId,modId);
-  printf("%12.6f%12.6f%12.6f    Tx = %12.6f    Psi   = %12.6f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
-  printf("%12.6f%12.6f%12.6f    Ty = %12.6f    Theta = %12.6f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
-  printf("%12.6f%12.6f%12.6f    Tz = %12.6f    Phi   = %12.6f\n", rot[6], rot[7], rot[8], tr[2], angles[2]);
+
+  printf("Volume=%s\n",GetVolPath());
+  if (GetVolUID() != 0) {
+    ELayerID layerId;
+    Int_t modId;
+    GetVolUID(layerId,modId);
+    printf("VolumeID=%d LayerID=%d ( %s ) ModuleID=%d\n", GetVolUID(),layerId,LayerName(layerId),modId);
+  }
+  printf("%12.8f%12.8f%12.8f    Tx = %12.8f    Psi   = %12.8f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
+  printf("%12.8f%12.8f%12.8f    Ty = %12.8f    Theta = %12.8f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
+  printf("%12.8f%12.8f%12.8f    Tz = %12.8f    Phi   = %12.8f\n", rot[6], rot[7], rot[8], tr[2], angles[2]);
 
 }
 
+//_____________________________________________________________________________
+Int_t AliAlignObj::LayerSize(Int_t layerId)
+{
+  // Get the corresponding layer size.
+  // Implemented only for ITS,TPC,TRD,TOF and RICH
+  if (layerId < kFirstLayer || layerId >= kLastLayer) {
+    AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
+    return 0;
+  }
+  else {
+    return fgLayerSize[layerId - kFirstLayer];
+ }
+}
+
+//_____________________________________________________________________________
+const char* AliAlignObj::LayerName(Int_t layerId)
+{
+  // Get the corresponding layer name.
+  // Implemented only for ITS,TPC,TRD,TOF and RICH
+  if (layerId < kFirstLayer || layerId >= kLastLayer) {
+    AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
+    return "Invalid Layer!";
+  }
+  else {
+    return fgLayerName[layerId - kFirstLayer];
+ }
+}
+
 //_____________________________________________________________________________
 UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
 {
@@ -360,13 +436,20 @@ Bool_t AliAlignObj::ApplyToGeometry()
   }
   
   const char* volpath = GetVolPath();
-  TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
-  if (!node) {
+
+  if (gGeoManager->GetListOfPhysicalNodes()->FindObject(volpath)) {
+    AliError(Form("Volume %s has been already misaligned!",volpath));
+    return kFALSE;
+  }
+
+  if (!gGeoManager->cd(volpath)) {
     AliError(Form("Volume path %s not valid!",volpath));
     return kFALSE;
   }
-  if (node->IsAligned()) {
-    AliWarning(Form("Volume %s has been already misaligned!",volpath));
+
+  TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
+  if (!node) {
+    AliError(Form("Volume path %s not valid!",volpath));
     return kFALSE;
   }
 
@@ -381,7 +464,7 @@ Bool_t AliAlignObj::ApplyToGeometry()
   AliAlignObj::ELayerID layerId; // unique identity for volume in the alobj
   Int_t modId; // unique identity for volume in the alobj
   GetVolUID(layerId, modId);
-  AliInfo(Form("Aligning volume %s of detector layer %d with local ID %d",volpath,layerId,modId));
+  AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",volpath,layerId,modId));
   node->Align(ginv);
 
   return kTRUE;
@@ -418,8 +501,14 @@ Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
     if (strcmp(path,nodePath) == 0) break;
   }
   if (!node) {
-    AliWarningClass(Form("Volume path %s not found!",path));
-    return kFALSE;
+    if (!gGeoManager->cd(path)) {
+      AliErrorClass(Form("Volume path %s not found!",path));
+      return kFALSE;
+    }
+    else {
+      AliWarningClass(Form("Volume (%s) has not been misaligned!",path));
+      return kTRUE;
+    }
   }
 
   TGeoHMatrix align,gprime,g,ginv,l;
@@ -434,6 +523,7 @@ Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
   return kTRUE;
 }
 
+//_____________________________________________________________________________
 void  AliAlignObj::InitAlignObjFromGeometry()
 {
   // Loop over all alignable volumes and extract
@@ -444,22 +534,31 @@ void  AliAlignObj::InitAlignObjFromGeometry()
   
   InitVolPaths();
 
-  for (Int_t iLayer = 0; iLayer < (AliAlignObj::kLastLayer - AliAlignObj::kFirstLayer); iLayer++) {
-    fgAlignObjs[iLayer] = new AliAlignObj*[AliAlignObj::LayerSize(iLayer)];
+  for (Int_t iLayer = kFirstLayer; iLayer < AliAlignObj::kLastLayer; iLayer++) {
+    fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[AliAlignObj::LayerSize(iLayer)];
     for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
-      UShort_t volid = AliAlignObj::LayerToVolUID(iLayer+ AliAlignObj::kFirstLayer,iModule);
-      fgAlignObjs[iLayer][iModule] = new AliAlignObjAngles("",volid,0,0,0,0,0,0);
+      UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
+      fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjAngles("",volid,0,0,0,0,0,0);
       const char *path = GetVolPath(volid);
-      if (!GetFromGeometry(path, *fgAlignObjs[iLayer][iModule]))
+      if (!GetFromGeometry(path, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
        AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,path));
     }
   }
   
 }
 
+//_____________________________________________________________________________
+AliAlignObj* AliAlignObj::GetAlignObj(UShort_t voluid) {
+  // Returns the alignment object for given volume ID
+  Int_t modId;
+  ELayerID layerId = VolUIDToLayer(voluid,modId);
+  return GetAlignObj(layerId,modId);
+}
+
 //_____________________________________________________________________________
 AliAlignObj* AliAlignObj::GetAlignObj(ELayerID layerId, Int_t modId)
 {
+  // Returns pointer to alignment object givent its layer and module ID
   if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
     AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
     return NULL;
@@ -467,9 +566,18 @@ AliAlignObj* AliAlignObj::GetAlignObj(ELayerID layerId, Int_t modId)
   return fgAlignObjs[layerId-kFirstLayer][modId];
 }
 
+//_____________________________________________________________________________
+const char* AliAlignObj::GetVolPath(UShort_t voluid) {
+  // Returns the volume path for given volume ID
+  Int_t modId;
+  ELayerID layerId = VolUIDToLayer(voluid,modId);
+  return GetVolPath(layerId,modId);
+}
+
 //_____________________________________________________________________________
 const char* AliAlignObj::GetVolPath(ELayerID layerId, Int_t modId)
 {
+  // Returns volume path to alignment object givent its layer and module ID
   if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
     AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
     return NULL;
@@ -641,20 +749,20 @@ void AliAlignObj::InitVolPaths()
     Int_t modnum = 0;
     TString str1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
     TString str2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
-    TString str_in = "/TPC_IROC_1";
+    TString strIn = "/TPC_IROC_1";
     TString volpath;
     
     for(Int_t cnt=1; cnt<=18; cnt++){
       volpath = str1;
       volpath += cnt;
-      volpath += str_in;
+      volpath += strIn;
       fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
       modnum++;
     }
     for(Int_t cnt=1; cnt<=18; cnt++){
       volpath = str2;
       volpath += cnt;
-      volpath += str_in;
+      volpath += strIn;
       fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
       modnum++;
     }
@@ -665,20 +773,20 @@ void AliAlignObj::InitVolPaths()
     Int_t modnum = 0;
     TString str1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
     TString str2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
-    TString str_out = "/TPC_OROC_1";
+    TString strOut = "/TPC_OROC_1";
     TString volpath;
     
     for(Int_t cnt=1; cnt<=18; cnt++){
       volpath = str1;
       volpath += cnt;
-      volpath += str_out;
+      volpath += strOut;
       fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
       modnum++;
     }
     for(Int_t cnt=1; cnt<=18; cnt++){
       volpath = str2;
       volpath += cnt;
-      volpath += str_out;
+      volpath += strOut;
       fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
       modnum++;
     }
@@ -688,64 +796,27 @@ void AliAlignObj::InitVolPaths()
   {
     Int_t nstrA=15;
     Int_t nstrB=19;
-    Int_t nstrC=20;
+    Int_t nstrC=19;
+    Int_t nsec=18;
     Int_t nStripSec=nstrA+2*nstrB+2*nstrC;
+    Int_t nStrip=nStripSec*nsec;
 
-    for (Int_t modnum=0; modnum < 1674; modnum++) {
+    for (Int_t modnum=0; modnum < nStrip; modnum++) {
 
       Int_t sector = modnum/nStripSec;
       Char_t  string1[100];
       Char_t  string2[100];
-
       Int_t icopy=-1;
+      if(sector<13){
+       icopy=sector+5;}  
+      else{ icopy=sector-13;}
 
-      if(sector<3){
-       icopy=sector+1;
-       sprintf(string1,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
-      }
-      else if(sector<11){
-       icopy=sector-2;
-       sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
-      }
-      else if(sector==11 || sector==12){
-       icopy=sector-10;
-       sprintf(string1,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
-      }
-      else {
-       icopy=sector-4;
-       sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
-      }
-
+      sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1/FTOA_0/FLTA_0",sector,sector);
+      
       Int_t strInSec=modnum%nStripSec;
-
-      if( strInSec < nstrC){
-       icopy= nstrC - (strInSec+1) + 1;
-       sprintf(string2,"FTOC_1/FLTC_0/FSTR_%i",icopy);
-      }
-      else if(strInSec< nstrC+nstrB){
-       icopy= nstrB - (strInSec-nstrC+1) + 1;
-       sprintf(string2,"FTOB_1/FLTB_0/FSTR_%i",icopy);
-
-      }
-      else if(strInSec< nstrC+nstrB+nstrA){   
-
-       icopy= strInSec-(nstrC+nstrB)+1;
-       sprintf(string2,"FTOA_0/FLTA_0/FSTR_%i",icopy); 
-      }
-      else if(strInSec< nstrC+2*nstrB+nstrA){ 
-
-       icopy= strInSec-(nstrC+nstrB+nstrA)+1;
-       sprintf(string2,"FTOB_2/FLTB_0/FSTR_%i",icopy);
-
-      }
-      else  { 
-
-       icopy= strInSec-(nstrC+2*nstrB+nstrA)+1;
-       sprintf(string2,"FTOC_2/FLTC_0/FSTR_%i",icopy);
-
-      }
-  
+      icopy= strInSec;
+      icopy++;
+      sprintf(string2,"FSTR_%i",icopy);      
       Char_t  path[100];
       sprintf(path,"%s/%s",string1,string2); 
       //      printf("%d  %s\n",modnum,path);
@@ -764,4 +835,47 @@ void AliAlignObj::InitVolPaths()
       fgVolPath[kRICH-kFirstLayer][modnum] = volpath.Data();
     }
   }
+
+  /*********************      TRD layers 0-6   *******************/
+  {
+    TString strSM[18]={"ALIC_1/B077_1/BSEGMO5_1/BTRD5_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO6_1/BTRD6_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO7_1/BTRD7_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO8_1/BTRD8_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO9_1/BTRD9_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO10_1/BTRD10_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO11_1/BTRD11_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO12_1/BTRD12_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO13_1/BTRD13_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO14_1/BTRD14_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO15_1/BTRD15_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO16_1/BTRD16_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO17_1/BTRD17_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO0_1/BTRD0_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO1_1/BTRD1_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO2_1/BTRD2_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO3_1/BTRD3_1/UTR1_1/UTS1_1/UTI1_1/UT",
+                      "ALIC_1/B077_1/BSEGMO4_1/BTRD4_1/UTR1_1/UTS1_1/UTI1_1/UT"};
+    TString strPost = "_1";
+    TString zeroStr = "0";
+    TString volpath;
+
+    Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
+
+    for(Int_t layer=0; layer<6; layer++){
+      Int_t modnum=0;
+      for(Int_t sm = 0; sm < 18; sm++){
+       for(Int_t stacknum = 0; stacknum < 5; stacknum++){
+         Int_t chnum = layer + stacknum*6;
+         volpath = strSM[sm];
+         if(chnum<10) volpath += zeroStr;
+         volpath += chnum;
+         volpath += strPost;
+         fgVolPath[arTRDlayId[layer]-kFirstLayer][modnum] = volpath.Data();
+         modnum++;
+       }
+      }
+    }
+  }
+
 }