Adding macros for ACORDE: sim&rec, read raw-data,esd & hits (*.C macros and AliAnalys...
[u/mrichter/AliRoot.git] / ACORDE / MakeACORDEFullMisAlignment.C
CommitLineData
85588057 1void MakeACORDEFullMisAlignment(){\r
2 // Create TClonesArray of full misalignment objects for ACORDE\r
3 //\r
4 const char* macroname = "MakeACORDEFullMisAlignment.C";\r
5 // Activate CDB storage and load geometry from CDB\r
6 AliCDBManager* cdb = AliCDBManager::Instance();\r
162637e4 7 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");\r
85588057 8 cdb->SetRun(0);\r
9 \r
10 AliCDBStorage* storage;\r
11 \r
12 //load geom from local file till ACORDE is not switched on by default in standard config-files\r
13 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){\r
14 TString Storage = gSystem->Getenv("STORAGE");\r
15 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {\r
16 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());\r
17 return;\r
18 }\r
19 storage = cdb->GetStorage(Storage.Data());\r
20 if(!storage){\r
21 Error(macroname,"Unable to open storage %s\n",Storage.Data());\r
22 return;\r
23 }\r
24 \r
25 AliCDBPath path("GRP","Geometry","Data");\r
26 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());\r
27 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");\r
28 entry->SetOwner(0);\r
29 TGeoManager* geom = (TGeoManager*) entry->GetObject();\r
30 AliGeomManager::SetGeometry(geom);\r
31 }else{\r
32 AliGeomManager::LoadGeometry(); //load geom from default CDB storage\r
33 \r
34 }\r
35 // AliGeomManager::LoadGeometry("geometry.root"); \r
36\r
79ea46fb 37 TClonesArray *array = new TClonesArray("AliAlignObjParams",60);\r
85588057 38 TClonesArray &alobj = *array;\r
39 \r
40 TRandom *rnd = new TRandom(4321);\r
41 Int_t j = 0;\r
42 Double_t dx, dy, dz, dpsi, dtheta, dphi;\r
43\r
44 // RS = local\r
45 // sigma translation = 1 mm\r
46 // sigma rotation = 0.5 degrees\r
47 Double_t sigmatr = 2;\r
48 Double_t sigmarot = 1;\r
49 \r
50 TString symname;\r
51 TString basename = "ACORDE/Array";\r
52 Int_t iIndex=0;\r
53 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;\r
54 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);\r
55\r
79ea46fb 56 for (Int_t imod=0; imod<60; imod++){\r
85588057 57 dx = rnd->Gaus(0.,sigmatr);\r
58 dy = rnd->Gaus(0.,sigmatr);\r
59 dz = rnd->Gaus(0.,sigmatr);\r
60 dpsi = rnd->Gaus(0.,sigmarot);\r
61 dtheta = rnd->Gaus(0.,sigmarot);\r
62 dphi = rnd->Gaus(0.,sigmarot); \r
63 symname = basename;\r
64 symname += imod; \r
65 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);\r
66 }\r
67\r
68 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){\r
69 // save on file\r
70 const char* filename = "ACORDEfullMisalignment.root";\r
71 TFile f(filename,"RECREATE");\r
72 if(!f){\r
73 Error(macroname,"cannot open file for output\n");\r
74 return;\r
75 }\r
76 Info(macroname,"Saving alignment objects to the file %s", filename);\r
77 f.cd();\r
78 f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");\r
79 f.Close();\r
80 }else{\r
81 // save in CDB storage\r
82 AliCDBMetaData* md = new AliCDBMetaData();\r
83 md->SetResponsible("E. Cuautle & M. Rodriguez");\r
84 md->SetComment("Full misalignment for ACORDE");\r
85 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));\r
86 AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());\r
87 storage->Put(array,id,md);\r
88 }\r
89\r
90 array->Delete();\r
91\r
92}\r
93\r