Optional scoring for background studies in HALL.
[u/mrichter/AliRoot.git] / ACORDE / MakeACORDEResMisAlignment.C
CommitLineData
f9a965ae 1void MakeACORDEResMisAlignment(){\r
2 // Create TClonesArray of Residual misalignment objects for ACORDE\r
3 //\r
4 const char* macroname = "MakeACORDEResMisAlignment.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
f9a965ae 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 }\r
36 // AliGeomManager::LoadGeometry("geometry.root"); \r
37\r
38 TClonesArray *array = new TClonesArray("AliAlignObjParams",64);\r
39 TClonesArray &alobj = *array;\r
40 \r
41 TRandom *rnd = new TRandom(4321);\r
42 Int_t j = 0;\r
43 Double_t dx, dy, dz, dpsi, dtheta, dphi;\r
44\r
45 // RS = local\r
46 // sigma translation\r
47 // sigma rotation \r
48 Double_t sigmatr = 2; // max shift in cm\r
49 Double_t sigmarot = 1; // max rot in degrees\r
50 \r
51 TString symname;\r
52 TString basename = "ACORDE/Array";\r
53 Int_t iIndex=0;\r
54 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;\r
55 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);\r
56\r
79ea46fb 57 for (Int_t imod=0; imod<60; imod++){\r
f9a965ae 58 dx = rnd->Gaus(0.,sigmatr);\r
59 dy = rnd->Gaus(0.,sigmatr);\r
60 dz = rnd->Gaus(0.,sigmatr);\r
61 dpsi = rnd->Gaus(0.,sigmarot);\r
62 dtheta = rnd->Gaus(0.,sigmarot);\r
63 dphi = rnd->Gaus(0.,sigmarot); \r
64 symname = basename;\r
65 symname += imod; \r
66 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz,dpsi, dtheta, dphi, kFALSE);\r
67 }\r
68\r
69 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){\r
70 // save on file\r
71 const char* filename = "ACORDEResMisalignment.root";\r
72 TFile f(filename,"RECREATE");\r
73 if(!f){\r
74 Error(macroname,"cannot open file for output\n");\r
75 return;\r
76 }\r
77 Info(macroname,"Saving residual misalignment objects to the file %s", filename);\r
78 f.cd();\r
79 f.WriteObject(array,"ACORDEAlignObjs","kSingleKey");\r
80 f.Close();\r
81 }else{\r
82 // save in CDB storage\r
83 AliCDBMetaData* md = new AliCDBMetaData();\r
84 md->SetResponsible("E. Cuautle & M. Rodriguez ");\r
85 md->SetComment("Residual misalignment for ACORDE");\r
86 md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));\r
87 AliCDBId id("ACORDE/Align/Data",0,AliCDBRunRange::Infinity());\r
88 storage->Put(array,id,md);\r
89 }\r
90\r
91 array->Delete();\r
92\r
93}\r
94\r