]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Align.cxx
...also histos are now correctly booked
[u/mrichter/AliRoot.git] / T0 / AliT0Align.cxx
index ac82c400a66cc1efe8d818790a67ed23ea3c36ff..593d1f5c361b2daf902ded433f11222abc8cfe24 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-// Class creating the T0 aligmnent objects from the surveys.
+/*
+$Log: AliT0Align.cxx,v $
+ Revision   2008/01/30
+Removing code violations 
 
-//
-//  Creates the T0 align object
-//
+ Version 1.1  2006/10
+Preliminary test version (T.Malkiewicz)
+*/
 
 #include "AliT0Align.h"
-//
 #include "TROOT.h"
 #include "Riostream.h"
 #include "TFile.h"
 #include "TMath.h"
 #include "TSystem.h"
+#include "TString.h"
 #include "AliSurveyObj.h"
-#include "AliSurveyPoint.h"
 #include "AliAlignObjParams.h"
 #include "AliCDBStorage.h"
 #include <TClonesArray.h>
 #include <TFile.h>
 #include "AliLog.h"
 #include "AliCDBManager.h"
+#include "AliSurveyPoint.h" 
+
+// Class creating the T0 aligmnent objects 
+// from the surveys done by surveyers at Point2.
+// Survey results are fetched from 
+// Survey Depot, based on survey results 
+// position of T0 alignment objects is computed.
+
 
 ClassImp(AliT0Align)
 
 AliT0Align::AliT0Align() :
   TObject(),
+  fFileGlob(0x0),
   fT0AAlignObj(0x0),
   fT0CAlignObj(0x0),
-  fFileGlob(0x0),
-  fXPos(0.),
-  fYPos(0.),
   fDebug(0),
-  fRepLoc(0)
+  fXPosC(0.),
+  fYPosC(0.),
+  fXPosA(0.),
+  fYPosA(0.),
+  fRepLoc(0),
+  fRepGlob(0),
+  fSide(0x0),
+  fUser(0x0)
 {
   //
   //  default constructor
   //
 }   
 //________________________________________________________________________
-AliT0Align::AliT0Align(Int_t reportloc, Int_t reportglob) :
+AliT0Align::AliT0Align(Int_t reportloc, Int_t side, Int_t reportglob) :
   TObject(),
+  fFileGlob(0x0),
   fT0AAlignObj(0x0),
   fT0CAlignObj(0x0),
-  fFileGlob(0x0),
-  fXPos(0.),
-  fYPos(0.),
   fDebug(0),
-  fRepLoc(0)
+  fXPosC(0.),
+  fYPosC(0.),
+  fXPosA(0.),
+  fYPosA(0.),
+  fRepLoc(0),
+  fRepGlob(0),
+  fSide(0x0),
+  fUser(0x0)
 {
   //
   // constructor - defines data files
   //
   fRepLoc = reportloc;
-  Char_t path[50];
-  fFileGlob = new Char_t[80];
-  sprintf(path,gSystem->Getenv("ALICE_ROOT")); 
+  fRepGlob = reportglob;
+  fSide = side;
+  // Char_t path[50];
+  TString path = Form("%s",gSystem->Getenv("ALICE_ROOT")) ;
+  // fFileGlob = new Char_t[80];
+  //  fUser = new Char_t[10];
+  fFileGlob = Form("%s/T0/Survey_%d_V0.txt",path.Data(),reportglob);
+  fUser = Form("%s/T0/Survey_%d_V0.txt",path.Data(),reportglob);
+  // sprintf(path,gSystem->Getenv("ALICE_ROOT")); 
   //
   // sprintf(fFileLoc,"%s/T0/Survey_%d_T0.txt",path,reportloc);
-  sprintf(fFileGlob,"%s/T0/Survey_%d_V0.txt",path,reportglob);
+  // sprintf(fFileGlob,"%s/T0/Survey_%d_V0.txt",path,reportglob);
   //
-
+  // sprintf(fUser,gSystem->Getenv("alien_API_USER"));
 }
 //_________________________________________________________________________
 AliT0Align::AliT0Align(const AliT0Align &align) :
   TObject(),
+  fFileGlob(0x0),
   fT0AAlignObj(0x0),
   fT0CAlignObj(0x0),
-  fFileGlob(0x0),
-  fXPos(0.),
-  fYPos(0.),
   fDebug(0),
-  fRepLoc(0)
+  fXPosC(0.),
+  fYPosC(0.),
+  fXPosA(0.),
+  fYPosA(0.),
+  fRepLoc(0),
+  fRepGlob(0),
+  fSide(0x0),
+  fUser(0x0)  
 {
   //
   //  copy constructor - dummy
@@ -102,13 +133,15 @@ AliT0Align & AliT0Align::operator =(const AliT0Align & align)
 }
 
 //__________________________________________________________________________
-AliT0Align::~AliT0Align(){
+AliT0Align::~AliT0Align()
+{
   //
   // destructor
   //
   if(fT0AAlignObj) delete fT0AAlignObj;
   if(fT0CAlignObj) delete fT0CAlignObj;
-
+  if(fFileGlob) delete[] fFileGlob;
+  if(fUser) delete[] fUser;
 }
 //__________________________________________________________________________
 Bool_t AliT0Align::LoadSurveyData()
@@ -117,16 +150,29 @@ Bool_t AliT0Align::LoadSurveyData()
   // Create a new survey object and fill it.
  
  AliSurveyObj * s1 = new AliSurveyObj();
+ const int numberPoints = 2;
+ TString pointNames[numberPoints]={"Flange_0","C67_6_Beamcircle"}; 
  
  if(fRepLoc == 0) 
- //
- // Filling from DCDB (via GRID)
- //
- {
-   s1->SetGridUser("tomatkie");
-   s1->Fill("V0", 835615, "tomatkie");
+ { 
+   //
+   // Filling from DCDB (via GRID)
+   //
+   s1->SetGridUser(fUser);
+   if(fSide == 0) 
+   {
+     s1->Fill("T0", fRepGlob, fUser);
+   }
+   else if(fSide == 1)
+   {
+     s1->Fill("VZERO", fRepGlob, fUser);
+   }
+   else
+   {
+     cout<<"Enter the side properly: '0'- A side, '1'- C side'" <<endl;
+     return 0;
+   }
  }
-
  else
  //
  // Filling from local file
@@ -135,11 +181,7 @@ Bool_t AliT0Align::LoadSurveyData()
    s1->FillFromLocalFile(fFileGlob);
  }
  //
- Int_t numberPoints = 3;
- //
- TString pointNames[3] = {"C67_6_Beamcircle", "T0A", "VERTEX"}; 
- //
- Float_t surveyedPoints [3][2];
+ Float_t surveyedPoints [numberPoints][2];
  AliSurveyPoint *currPoint;
 
  //
@@ -165,8 +207,16 @@ Bool_t AliT0Align::LoadSurveyData()
      }
    }  
  }
- fXPos = surveyedPoints[0][0]; 
- fYPos = surveyedPoints[0][1];
+ if(fSide == 0)
+ {
+   fXPosA = surveyedPoints[0][0];
+   fYPosA = surveyedPoints[0][1];
+ }
+ else if(fSide == 1)
+ {
+   fXPosC = surveyedPoints[1][0]; 
+   fYPosC = surveyedPoints[1][1];
+ }
  //
  delete s1;
  //
@@ -178,31 +228,35 @@ Double_t AliT0Align::ComputePosition()
 {
  //  Float_t fZPos, shift;
  //  fZPos = surveyedPoints[3] - shift;
-  return 99999;
+  return 0;
 }
 //_______________________________________________________________________
-void AliT0Align::CreateAlignObj(){
+void AliT0Align::CreateAlignObj()
+{
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
+  //  TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
   // TClonesArray &alobj = *array;
   
-
   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
+  dx=fXPosA;
+  dy=fYPosA;
   fT0AAlignObj = new AliAlignObjParams("ALIC_1/0STL_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
   
-  dx=fXPos;
-  dy=fYPos;
+  dx=fXPosC;
+  dy=fYPosC;
   // dz=surveyedPoints[2];
   dz=0.;
   fT0CAlignObj = new AliAlignObjParams("ALIC_1/0STR_1",0,dx,dy,dz,dpsi,dtheta,dphi,kTRUE);
+  
 }
 
 //______________________________________________________________________
-void AliT0Align::Run(){
+void AliT0Align::Run()
+{
   //
   // runs the full chain
   //
-  SetDebug(0);
+  // SetDebug(0);
   Bool_t flag = LoadSurveyData();
     if(flag) 
   {
@@ -217,8 +271,11 @@ void AliT0Align::Run(){
 
 void AliT0Align::StoreAlignObj()
 {
+ //
+ // Storing T0 alignment objects 
+ //
  AliCDBManager* cdb = AliCDBManager::Instance();
- if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+ if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  //
  TClonesArray *array = new TClonesArray("AliAlignObjParams",2);
 //
@@ -239,9 +296,10 @@ void AliT0Align::StoreAlignObj()
   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "T0SurveyMisalignment.root";
-    Char_t fullname[80];
-    sprintf(fullname,"%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"),filename);
-    TFile *f = new TFile(fullname,"RECREATE");
+    //  Char_t fullname[80];
+    //  sprintf(fullname,"%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"),filename);
+    TString fullname = Form("%s/T0/Align/Data/%s",gSystem->Getenv("ALICE_ROOT"), filename);
+    TFile *f = new TFile(fullname.Data(),"RECREATE");
     if(!f){
       AliError("cannot open file for output\n");
       return;
@@ -268,7 +326,7 @@ void AliT0Align::StoreAlignObj()
     //
     AliCDBMetaData* md = new AliCDBMetaData();
     md->SetResponsible("Tomasz Malkiewicz");
-    md->SetComment("Full misalignment of T0-C from surveyors");
+    md->SetComment("Position of T0-A and T0-C from survey");
     AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }