]> git.uio.no Git - u/mrichter/AliRoot.git/blob - macros/MakeAllDETsResMisAlignment.C
Minors
[u/mrichter/AliRoot.git] / macros / MakeAllDETsResMisAlignment.C
1 const char* GetARversion();
2
3 void MakeAllDETsResMisAlignment(Char_t* CDBstorage = "local://$HOME/Residual"){
4   // Make residual misalignment objects for all detectors
5   // Pass different "CDBstorage" argument if needed (e.g. to fill
6   // conditions' data base on alien) or set it to null string to have
7   // the objects saved locally on file 
8   // This macro defines the default name and place for the detector-macros
9   // in charge of producing the residual misalignment objects as 
10   // $ALICE_ROOT/DET/MakeDETResidualMisAlignment.C
11   //
12   const char* macroname="MakeAllDETsResMisAlignment.C";
13
14   TString strStorage(CDBstorage);
15   if(strStorage.IsNull()){
16     gSystem->Setenv("TOCDB","kFALSE");
17   }else{  
18     gSystem->Setenv("TOCDB","kTRUE");
19     gSystem->Setenv("STORAGE",strStorage.Data());
20     gSystem->Setenv("ARVERSION",GetARversion());
21   }
22
23   // Load geometry from CDB updating it if we are producing the
24   // alignment objects for the CDB
25   AliCDBManager* cdb = AliCDBManager::Instance();
26   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
27   cdb->SetRun(0);
28   
29   if(strStorage.IsNull()){ //if we produce the objects into a file
30     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
31   }else{ // if we produce the objects in a CDB storage
32     // update geometry in it
33     Info(macroname,"Updating geometry in CDB storage %s",strStorage.Data());
34     gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C");
35     UpdateCDBIdealGeom(strStorage.Data());
36     // load the same geometry from given CDB storage
37     AliCDBPath path("GRP","Geometry","Data");
38     AliCDBStorage* storage = cdb->GetStorage(strStorage.Data());
39     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
40     if(!entry) Fatal(macroname,"Couldn't load geometry data from CDB!");
41     entry->SetOwner(0);
42     TGeoManager* geom = (TGeoManager*) entry->GetObject();
43     if (!geom) Fatal(macroname,"Couldn't find TGeoManager in the specified CDB entry!");
44     AliGeomManager::SetGeometry(geom);
45   }
46   
47   // run macro for non-sensitive modules
48   // (presently generates only FRAME alignment objects)
49   gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTResMisAlignment.C");
50
51   // run macros for sensitive modules
52   TString sModules="EMCAL,FMD,HMPID,ITS,MUON,PMD,PHOS,T0,TRD,TPC,TOF,VZERO,ZDC";
53   TObjArray *detArray = sModules.Tokenize(',');
54   TIter iter(detArray);
55   TObjString *ostr;
56   TString exec_det_macro;
57
58   while((ostr = (TObjString*) iter.Next())){
59     TString str(ostr->String());
60     exec_det_macro="aliroot -b -q $ALICE_ROOT/";
61     exec_det_macro+=str;
62     exec_det_macro+="/Make";
63     exec_det_macro+=str;
64     exec_det_macro+="ResMisAlignment.C";
65     
66     gSystem->Exec(exec_det_macro.Data());
67   }
68
69   return;
70 }
71
72 const char* GetARversion(){
73   // Get AliRoot version from $ALICE_ROOT/CVS/Repository file
74   // It's the best we can do without a GetVersion() method
75   TFile *fv= TFile::Open("$ALICE_ROOT/CVS/Repository?filetype=raw","READ");
76   Int_t size = fv->GetSize();
77   char *buf = new Char_t[size];
78   memset(buf, '\0', size);
79   fv->Seek(0);
80   const char* alirootv;
81   if ( fv->ReadBuffer(buf, size) ) {
82     Printf("Error reading AliRoot version from file to buffer!");
83     alirootv = "";
84   }
85   if(buf=="AliRoot"){
86     alirootv="HEAD";
87   }else{
88     alirootv = buf;
89   }
90   return alirootv;
91 }