]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAlignObj.cxx
New version of the jet finder (Rafael)
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
index 1b198fa658db189fd36edefc8dce4894bd381dcc..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)
@@ -250,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);
@@ -274,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)
 {
@@ -386,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;
   }
 
@@ -407,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;
@@ -466,6 +523,7 @@ Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
   return kTRUE;
 }
 
+//_____________________________________________________________________________
 void  AliAlignObj::InitAlignObjFromGeometry()
 {
   // Loop over all alignable volumes and extract
@@ -476,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;
@@ -499,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;
@@ -673,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++;
     }
@@ -697,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++;
     }
@@ -720,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);
@@ -799,42 +838,40 @@ void AliAlignObj::InitVolPaths()
 
   /*********************      TRD layers 0-6   *******************/
   {
-  TString strSM[18]={"ALIC_1/B077_1/B075_1/BTR3_1/UTR3_3/UTS3_3/UTI3_3/UT",
-                     "ALIC_1/B077_1/B075_2/BTR3_1/UTR3_3/UTS3_3/UTI3_3/UT",
-                    "ALIC_1/B077_1/B075_3/BTR3_1/UTR3_3/UTS3_3/UTI3_3/UT",
-                    "ALIC_1/B077_1/B071_6/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_7/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_8/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_9/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_10/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_11/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_12/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_13/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B074_1/BTR2_1/UTR2_2/UTS2_2/UTI2_2/UT",
-                    "ALIC_1/B077_1/B074_2/BTR2_1/UTR2_2/UTS2_2/UTI2_2/UT",
-                    "ALIC_1/B077_1/B071_1/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_2/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_3/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_4/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                    "ALIC_1/B077_1/B071_5/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT"};
-    Int_t start[18] = {60,60,60,0,0,0,0,0,0,0,0,30,30,0,0,0,0,0};
+    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";
-
-    Int_t layer, sm, stacknum, chnum, modnum;
+    TString zeroStr = "0";
     TString volpath;
-    Int_t TRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
 
-    for(layer=0; layer<6; layer++){
-      modnum=0;
-      for(sm = 0; sm<18; sm++){
-       for(stacknum = 0; stacknum<5; stacknum++){
-         chnum = start[sm] + layer + stacknum*6;
+    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;
+         if(chnum<10) volpath += zeroStr;
          volpath += chnum;
          volpath += strPost;
-         fgVolPath[TRDlayId[layer]-kFirstLayer][modnum] = volpath.Data();
+         fgVolPath[arTRDlayId[layer]-kFirstLayer][modnum] = volpath.Data();
          modnum++;
        }
       }