]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDalignment.cxx
ALIROOT-5488 Remove build/include from the include directories
[u/mrichter/AliRoot.git] / TRD / AliTRDalignment.cxx
index 073be48bea65c771e9be15db9061d041b71cf59e..80e511f5c341725ec4121f8a9c53b15705f8a0ec 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");                                                  //
@@ -67,7 +67,6 @@
 
 #include <iostream>
 #include <fstream>
-//#include <string>
 
 #include "TMath.h"
 #include "TFile.h"
@@ -85,7 +84,6 @@
 #include "AliCDBStorage.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBEntry.h"
-#include "AliCDBId.h"
 #include "AliSurveyObj.h"
 #include "AliSurveyPoint.h"
 
@@ -93,6 +91,8 @@
 
 void trdAlignmentFcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *x, Int_t iflag);
 
+using std::ostream;
+using std::fstream;
 ClassImp(AliTRDalignment)
 
 //_____________________________________________________________________________
@@ -148,6 +148,11 @@ AliTRDalignment::AliTRDalignment()
     fSurveyZ0[j][k][l] = z[k];
   }
 
+  for (int i=0; i<1000; i++) {
+    fIbuffer[i] = 0;
+    fDbuffer[i] = 0.0;
+  }
+
 }
 
 //_____________________________________________________________________________
@@ -175,6 +180,10 @@ AliTRDalignment::AliTRDalignment(const AliTRDalignment& source)
     fSurveyY0[j][k][l] = source.fSurveyY0[j][k][l];
     fSurveyZ0[j][k][l] = source.fSurveyZ0[j][k][l];
   }
+  for (int i=0; i<1000; i++) {
+    fIbuffer[i] = 0;
+    fDbuffer[i] = 0.0;
+  }
 
 }
 
@@ -296,12 +305,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);
   }
@@ -405,7 +414,7 @@ void AliTRDalignment::SetChResidual()
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::PrintSm(int i, FILE *fp) const 
+void AliTRDalignment::PrintSm(int i, FILE * const fp) const 
 {
   //
   // print the supermodule data
@@ -418,7 +427,7 @@ void AliTRDalignment::PrintSm(int i, FILE *fp) const
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::PrintCh(int i, FILE *fp) const 
+void AliTRDalignment::PrintCh(int i, FILE * const fp) const 
 {
   //
   // print the chamber data
@@ -431,7 +440,7 @@ void AliTRDalignment::PrintCh(int i, FILE *fp) const
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadAscii(char *filename) 
+void AliTRDalignment::ReadAscii(const char * const filename) 
 {
   //
   // read the alignment data from ascii file
@@ -563,7 +572,7 @@ void AliTRDalignment::ReadCurrentGeo()
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadRoot(char *filename) 
+void AliTRDalignment::ReadRoot(const char * const filename) 
 {
   //
   // read the alignment data from root file
@@ -583,7 +592,7 @@ void AliTRDalignment::ReadRoot(char *filename)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadDB(char *filename) 
+void AliTRDalignment::ReadDB(const char * const filename) 
 {
   //
   // read the alignment data from database file
@@ -606,8 +615,8 @@ void AliTRDalignment::ReadDB(char *filename)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadDB(char *db, char *path, int run
-                           , int version, int subversion)
+void AliTRDalignment::ReadDB(const char * const db, const char * const path, 
+                            int run, int version, int subversion)
 {
   //
   // read the alignment data from database
@@ -640,13 +649,16 @@ 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) 
+void AliTRDalignment::ReadSurveyReport(const char * const filename) 
 {
   //
   // Read survey report and store the numbers in fSurveyX, fSurveyY, fSurveyZ, 
@@ -742,24 +754,21 @@ 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());
-                        
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadSurveyReport(AliSurveyObj *so) 
+void AliTRDalignment::ReadSurveyReport(const AliSurveyObj * const so) 
 {
   //
   // Read survey report and store the numbers in fSurveyX, fSurveyY, fSurveyZ, 
@@ -837,13 +846,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()));
   }
 
@@ -853,7 +859,7 @@ void AliTRDalignment::ReadSurveyReport(AliSurveyObj *so)
 }
 
 //_____________________________________________________________________________
-double AliTRDalignment::SurveyChi2(int i, double *a) {
+double AliTRDalignment::SurveyChi2(int i, const double * const a) {
 
   //
   // Compare the survey results to the ideal positions of the survey marks
@@ -864,10 +870,14 @@ double AliTRDalignment::SurveyChi2(int i, double *a) {
   if (!IsGeoLoaded()) return 0;
   printf("Survey of supermodule %d\n",i);
   AliAlignObjParams al(GetSmName(i),0,a[0],a[1],a[2],a[3],a[4],a[5],0);
+
   TGeoPNEntry      *pne  = gGeoManager->GetAlignableEntry(GetSmName(i));
   if (!pne) AliError(Form("no such physical node entry: %s",GetSmName(i)));
   TGeoPhysicalNode *node = pne->GetPhysicalNode();
-  if (!node) AliError(Form("physical node entry %s has no physical node",GetSmName(i))); 
+  if (!node) {
+    AliWarning(Form("physical node entry %s has no physical node; making a new one",GetSmName(i))); 
+    node = gGeoManager->MakeAlignablePN(pne);
+  }
 
   //  al.ApplyToGeometry();    
   //  node = pne->GetPhysicalNode(); // changed in the meantime
@@ -915,14 +925,14 @@ 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...
 
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::SurveyToAlignment(int i,char *flag) {
+void AliTRDalignment::SurveyToAlignment(int i, const char * const flag) {
 
   //
   // Find the supermodule alignment parameters needed to make the survey 
@@ -970,7 +980,7 @@ void AliTRDalignment::SurveyToAlignment(int i,char *flag) {
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ReadAny(char *filename) 
+void AliTRDalignment::ReadAny(const char * const filename) 
 {
   //
   // read the alignment data from any kind of file
@@ -987,7 +997,7 @@ void AliTRDalignment::ReadAny(char *filename)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::WriteAscii(char *filename) const
+void AliTRDalignment::WriteAscii(const char * const filename) const
 {
   //
   // store the alignment data on ascii file
@@ -1007,7 +1017,7 @@ void AliTRDalignment::WriteAscii(char *filename) const
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::WriteRoot(char *filename) 
+void AliTRDalignment::WriteRoot(const char * const filename) 
 {
   //
   // store the alignment data on root file
@@ -1028,7 +1038,7 @@ void AliTRDalignment::WriteRoot(char *filename)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::WriteDB(char *filename, int run0, int run1
+void AliTRDalignment::WriteDB(const char * const filename, int run0, int run1, int ver, int subver
 {
   //
   // dumping on a DB-like file
@@ -1036,12 +1046,14 @@ 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");
   md->SetComment(fComment.GetString().Data());
-  AliCDBEntry    *e  = new AliCDBEntry(ar, id, md);
+  AliCDBEntry *e  = new AliCDBEntry(ar, id, md);
+  e->SetVersion(ver);
+  e->SetSubVersion(subver);
   TFile fi(filename,"RECREATE");
   if (fi.IsOpen()) {
     e->Write();
@@ -1058,7 +1070,7 @@ void AliTRDalignment::WriteDB(char *filename, int run0, int run1)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::WriteDB(char *db, char *path, int run0, int run1) 
+void AliTRDalignment::WriteDB(char * const db, const char * const path, int run0, int run1) 
 {
   //
   // store the alignment data in database
@@ -1156,7 +1168,7 @@ void AliTRDalignment::PrintChRMS() const
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::ArToNumbers(TClonesArray *ar) 
+void AliTRDalignment::ArToNumbers(TClonesArray * const ar) 
 {
   //
   // for each of the alignment objects in array ar extract the six local 
@@ -1176,7 +1188,7 @@ void AliTRDalignment::ArToNumbers(TClonesArray *ar)
 }
 
 //_____________________________________________________________________________
-void AliTRDalignment::NumbersToAr(TClonesArray *ar) 
+void AliTRDalignment::NumbersToAr(TClonesArray * const ar) 
 {
   //
   // build array of AliAlignObj objects based on fSm and fCh data