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