]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDalignment.cxx
Minor change in error code
[u/mrichter/AliRoot.git] / TRD / AliTRDalignment.cxx
index a3820e5061b84f7c1c508f1af9cd6ba5774e619e..e41c6bec3a804580280f9fec681172fe4a70340e 100644 (file)
@@ -46,7 +46,7 @@
 // TGeoManager::Import("geometry.root"); a.WriteRoot("kuku.root");           //
 // TGeoManager::Import("geometry.root"); a.WriteDB("kukudb.root",0,0);       //
 // TGeoManager::Import("geometry.root");                                     //
-// a.WriteDB("local://$ALICE_ROOT", "TRD/Align/Data", 0,0);                  //
+// a.WriteDB("local://$ALICE_ROOT/OCDB", "TRD/Align/Data", 0,0);                  //
 // TGeoManager::Import("geometry.root"); a.WriteGeo("kukugeometry.root");    //
 //                                                                           //
 // b.ReadAscii("kuku.dat");                                                  //
@@ -296,12 +296,12 @@ void AliTRDalignment::SetSmRandom(double a[6])
   //
 
   double x[6];
+  double xmax[6]={999, 0.6, 999, 999, 999, 999};
 
   for (int i = 0; i < 18; i++) {
-    fRan.Rannor(x[0],x[1]);
-    fRan.Rannor(x[2],x[3]);
-    fRan.Rannor(x[4],x[5]);
-    for (int j = 0; j < 6; j++) x[j] *= a[j];
+    for (int j = 0; j < 6; j++) {
+      do {x[j] = fRan.Gaus(0,a[j]);} while (TMath::Abs(x[j]) > xmax[j]);
+    }
     SetSm(i,x);
     //PrintSm(i);
   }
@@ -485,15 +485,13 @@ void AliTRDalignment::ReadCurrentGeo()
   // represent just the last alignment. -- check this!
   //
 
+  TGeoPNEntry *pne;
   TGeoHMatrix *ideSm[18];  // ideal
   TGeoHMatrix *misSm[18];  // misaligned
-  for (int i = 0; i < 18; i++) {
+  for (int i = 0; i < 18; i++) if ((pne = gGeoManager->GetAlignableEntry(GetSmName(i)))) {
 
     // read misaligned and original matrices
 
-    TGeoPNEntry      *pne  = gGeoManager->GetAlignableEntry(GetSmName(i));
-    if (!pne) AliError(Form("no such physical node entry: %s",GetSmName(i)));
-    if (!pne) continue;
     TGeoPhysicalNode *node = pne->GetPhysicalNode();
     if (!node) AliError(Form("physical node entry %s has no physical node",GetSmName(i)));
     if (!node) continue;
@@ -525,13 +523,10 @@ void AliTRDalignment::ReadCurrentGeo()
 
   TGeoHMatrix *ideCh[540]; // ideal
   TGeoHMatrix *misCh[540]; // misaligned
-  for (int i = 0; i < 540; i++) {
+  for (int i = 0; i < 540; i++) if ((pne = gGeoManager->GetAlignableEntry(GetChName(i)))) {
 
     // read misaligned and original matrices
 
-    TGeoPNEntry      *pne  = gGeoManager->GetAlignableEntry(GetChName(i));
-    if (!pne) AliError(Form("no such physical node entry: %s",GetChName(i)));
-    if (!pne) continue;
     TGeoPhysicalNode *node = pne->GetPhysicalNode();
     if (!node) AliError(Form("physical node entry %s has no physical node",GetChName(i)));
     if (!node) continue;
@@ -645,11 +640,14 @@ Bool_t AliTRDalignment::DecodeSurveyPointName(TString pna, Int_t &sm, Int_t &iz,
   ir = -1;
   if (pna(9) == 'l') ir=0; // low radius
   if (pna(9) == 'h') ir=1; // high radius
-  iphi = atoi(pna(10,0).Data()); // phi within supermodule
+  iphi = -1;
+  if (pna(10) == '0') iphi = 0; // low phi within supermodule
+  if (pna(10) == '1') iphi = 1; // high phi within supermodule
   if (sm>=0 && sm<18 && iz>=0 && iz<2 && ir>=0 && ir<2 && iphi>=0 && iphi<2) return kTRUE;
   AliError(Form("cannot decode point name: %s",pna.Data()));
   return kFALSE;
 }
+
 //_____________________________________________________________________________
 void AliTRDalignment::ReadSurveyReport(char *filename) 
 {
@@ -747,20 +745,17 @@ void AliTRDalignment::ReadSurveyReport(char *filename)
       fSurveyEZ[i][j][k][l] = precision/10; // "precision" is supposed to be in mm
       // if, at some point, separate precision numbers for x,y,z show up in the 
       // survey reports the function will fail here
-      std::cout << "decoded "<<pna<<" "
-               <<fSurveyX[i][j][k][l]<<" "
-               <<fSurveyY[i][j][k][l]<<" "
-               <<fSurveyZ[i][j][k][l]<<" "
-               <<fSurveyEX[i][j][k][l]<<" "
-               <<fSurveyEY[i][j][k][l]<<" "
-               <<fSurveyEZ[i][j][k][l]<<" "<<std::endl;        
+      printf("decoded %s %02d %d %d %d  %8.2f %8.2f %8.2f %6.2f %6.2f %6.2f\n", 
+            pna.Data(), i, j, k, l,
+            fSurveyX[i][j][k][l], fSurveyY[i][j][k][l], fSurveyZ[i][j][k][l],
+            fSurveyEX[i][j][k][l], fSurveyEY[i][j][k][l], fSurveyEZ[i][j][k][l]);
     } else AliError(Form("cannot decode point name: %s",pna.Data()));
   }
   in.close();
   TString info = "Survey "+title+" "+date+" "+url+" "+version+" "+observations;
   info.ReplaceAll("\r","");
   fComment.SetString(info.Data());
-                        
 }
 
 //_____________________________________________________________________________
@@ -831,8 +826,8 @@ void AliTRDalignment::ReadSurveyReport(AliSurveyObj *so)
   // the right place in the arrays fSurveyX etc.
 
   TObjArray *points = so->GetData();
-  for (int i = 0; i<points->GetEntries(); i++) {
-    AliSurveyPoint *po = (AliSurveyPoint *) points->At(i);
+  for (int ip = 0; ip<points->GetEntries(); ++ip) {
+    AliSurveyPoint *po = (AliSurveyPoint *) points->At(ip);
     TString pna = po->GetPointName();
     Int_t i,j,k,l;
     if (DecodeSurveyPointName(pna,i,j,k,l)) {
@@ -842,13 +837,10 @@ void AliTRDalignment::ReadSurveyReport(AliSurveyObj *so)
       fSurveyEX[i][j][k][l] = po->GetPrecisionX()/10; // "precision" is supposed to be in mm
       fSurveyEY[i][j][k][l] = po->GetPrecisionY()/10;
       fSurveyEZ[i][j][k][l] = po->GetPrecisionZ()/10;
-      std::cout << "decoded "<<pna<<" "
-               <<fSurveyX[i][j][k][l]<<" "
-               <<fSurveyY[i][j][k][l]<<" "
-               <<fSurveyZ[i][j][k][l]<<" "
-               <<fSurveyEX[i][j][k][l]<<" "
-               <<fSurveyEY[i][j][k][l]<<" "
-               <<fSurveyEZ[i][j][k][l]<<" "<<std::endl;        
+      printf("decoded %s %02d %d %d %d  %8.2f %8.2f %8.2f %6.2f %6.2f %6.2f\n", 
+            pna.Data(), i, j, k, l,
+            fSurveyX[i][j][k][l], fSurveyY[i][j][k][l], fSurveyZ[i][j][k][l],
+            fSurveyEX[i][j][k][l], fSurveyEY[i][j][k][l], fSurveyEZ[i][j][k][l]);
     } else AliError(Form("cannot decode point name: %s",pna.Data()));
   }
 
@@ -920,9 +912,9 @@ void trdAlignmentFcn(int &npar, double *g, double &f, double *par, int iflag) {
   AliTRDalignment *alignment = (AliTRDalignment*) gMinuit->GetObjectFit(); 
 
   f = alignment->SurveyChi2(par);
-  if (iflag==3);
-  if (npar); 
-  if (g); // no warnings about unused stuff...
+  if (iflag==3) {}
+  if (npar) {} 
+  if (g) {} // no warnings about unused stuff...
 
 }
 
@@ -1041,7 +1033,7 @@ void AliTRDalignment::WriteDB(char *filename, int run0, int run1)
 
   TClonesArray   *ar = new TClonesArray("AliAlignObjParams",10000);
   NumbersToAr(ar);
-  char *path = "TRD/Align/Data";
+  const Char_t *path = "TRD/Align/Data";
   AliCDBId id(path,run0,run1);
   AliCDBMetaData *md = new AliCDBMetaData();
   md->SetResponsible("Dariusz Miskowiec");
@@ -1204,13 +1196,15 @@ void AliTRDalignment::NumbersToAr(TClonesArray *ar)
   }
 
   for (int i = 0; i < 540; i++) {
-    new(alobj[nobj]) AliAlignObjParams(GetChName(i)
-                                      ,GetVoi(i)
-                                     ,fCh[i][0],fCh[i][1],fCh[i][2]
-                                     ,fCh[i][3],fCh[i][4],fCh[i][5]
-                                     ,0);
-    ((AliAlignObj *) alobj[nobj])->ApplyToGeometry();
-    nobj++;
+    if (gGeoManager->GetAlignableEntry(GetChName(i))) {
+      new(alobj[nobj]) AliAlignObjParams(GetChName(i)
+                                        ,GetVoi(i)
+                                        ,fCh[i][0],fCh[i][1],fCh[i][2]
+                                        ,fCh[i][3],fCh[i][4],fCh[i][5]
+                                        ,0);
+      ((AliAlignObj *) alobj[nobj])->ApplyToGeometry();
+      nobj++;
+    }
   }
   AliInfo("current geometry modified");