Adding macros to create Calibration objects
[u/mrichter/AliRoot.git] / TRD / MakeTRDZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakeTRDZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for TRD
3 //
6fce62af 4 const char* macroname = "MakeTRDZeroMisAlignment.C";
90dbf5fb 5 TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
d3a9c52a 6 TClonesArray &alobj = *array;
7
28377a52 8 // Activate CDB storage and load geometry from CDB
9 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 10 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
28377a52 11 cdb->SetRun(0);
12
13 AliCDBStorage* storage = NULL;
14
15 if(TString(gSystem->Getenv("TOCDB")) == TString("kTRUE")){
16 TString Storage = gSystem->Getenv("STORAGE");
17 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
18 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
19 return;
20 }
21 storage = cdb->GetStorage(Storage.Data());
22 if(!storage){
23 Error(macroname,"Unable to open storage %s\n",Storage.Data());
24 return;
25 }
26 AliCDBPath path("GRP","Geometry","Data");
27 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
28 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
29 entry->SetOwner(0);
30 TGeoManager* geom = (TGeoManager*) entry->GetObject();
31 AliGeomManager::SetGeometry(geom);
32 }else{
33 AliGeomManager::LoadGeometry("geometry.root"); //load geom from default CDB storage
34 }
35
05b6df61 36 Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1};
d3a9c52a 37 Double_t dx=0.,dy=0.,dz=0.,rx=0.,ry=0.,rz=0.;
38
39 Int_t j=0;
40 UShort_t volid;
41 const char *symname;
42
6fce62af 43 // create the supermodules' alignment objects
a24be56b 44 for (Int_t iSect; iSect<18; iSect++) {
45 TString sm_symname(Form("TRD/sm%02d",iSect));
05b6df61 46 if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue;
6fce62af 47 new(alobj[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kTRUE);
48 }
49
50 // create the chambers' alignment objects
a24be56b 51 Int_t chId;
ae079791 52 for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
a24be56b 53 chId=-1;
54 for (Int_t iSect = 0; iSect < 18; iSect++){
55 for (Int_t iCh = 0; iCh < 5; iCh++) {
56 chId++;
5be6574e 57 if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue;
a24be56b 58 volid = AliGeomManager::LayerToVolUID(iLayer,chId);
05b6df61 59 if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue;
5be6574e 60 symname = AliGeomManager::SymName(volid);
5be6574e 61 new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kTRUE);
62 }
d3a9c52a 63 }
64 }
65
a24be56b 66 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
d3a9c52a 67 // save on file
dfe9c69d 68 const char* filename = "TRDzeroMisalignment.root";
69 TFile f(filename,"RECREATE");
70 if(!f){
71 Error(macroname,"cannot open file for output\n");
72 return;
73 }
74 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 75 f.cd();
76 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
77 f.Close();
78 }else{
79 // save in CDB storage
dfe9c69d 80 Info(macroname,"Saving alignment objects in CDB storage %s",
81 Storage.Data());
d3a9c52a 82 AliCDBMetaData* md = new AliCDBMetaData();
83 md->SetResponsible("Dariusz Miskowiec");
84 md->SetComment("Zero misalignment for TRD");
5bd470e1 85 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 86 AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 87 storage->Put(array,id,md);
88 }
89
90 array->Delete();
91
92}
93
94