Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / T0 / MakeT0ZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakeT0ZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for T0
3 //
4 TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
5 TClonesArray &alobj = *array;
6
7 AliAlignObjAngles a;
8
9 Double_t dx=0, dy=0, dz=0, dpsi=0, dtheta=0, dphi=0;
10
11 TString symName, sn;
12
13 Int_t iIndex=0;
ae079791 14 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
15 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
d3a9c52a 16
17 Int_t j=0;
18 for (Int_t imod=0; imod<24; imod++)
19 {
20 if (imod < 12){
21 sn="T0/C/PMT";
22 }else{
23 sn="T0/A/PMT";
24 }
25 symName = sn;
26 symName += imod+1;
27
28 new(alobj[j++]) AliAlignObjAngles(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
29 }
30
dfe9c69d 31 const char* macroname = "MakeT0ZeroMisAlignment.C";
32 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
d3a9c52a 33 // save on file
dfe9c69d 34 const char* filename = "T0zeroMisalignment.root";
35 TFile f(filename,"RECREATE");
36 if(!f){
37 Error(macroname,"cannot open file for output\n");
38 return;
39 }
40 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 41 f.cd();
dfe9c69d 42 f.WriteObject(array,"T0AlignObjs","kSingleKey");
d3a9c52a 43 f.Close();
44 }else{
45 // save in CDB storage
dfe9c69d 46 TString Storage = gSystem->Getenv("STORAGE");
47 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
48 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
49 return;
50 }
51 Info(macroname,"Saving alignment objects in CDB storage %s",
52 Storage.Data());
d3a9c52a 53 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 54 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
55 if(!storage){
56 Error(macroname,"Unable to open storage %s\n",Storage.Data());
57 return;
58 }
d3a9c52a 59 AliCDBMetaData* md = new AliCDBMetaData();
60 md->SetResponsible("Tomasz Malkiewicz");
61 md->SetComment("Zero misalignment for T0, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
8d0a15a4 62 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
dfe9c69d 63 AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 64 storage->Put(array,id,md);
65 }
66
67 array->Delete();
68
69}
70