]>
Commit | Line | Data |
---|---|---|
1 | void MakeTRDResMisAlignment(){ | |
2 | // Create TClonesArray of residual misalignment objects for TRD | |
3 | // | |
4 | const char* macroname = "MakeTRDResMisAlignment.C"; | |
5 | TClonesArray *array = new TClonesArray("AliAlignObjParams",1000); | |
6 | TClonesArray &alobj = *array; | |
7 | ||
8 | // Activate CDB storage and load geometry from CDB | |
9 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
10 | if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
11 | cdb->SetRun(0); | |
12 | ||
13 | AliCDBStorage* storage; | |
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 | } | |
33 | else { | |
34 | AliGeomManager::LoadGeometry(); //load geom from default CDB storage | |
35 | } | |
36 | ||
37 | // sigmas for the chambers | |
38 | Double_t chdx = 0.002; // 20 microns | |
39 | Double_t chdy = 0.003; // 30 microns | |
40 | Double_t chdz = 0.007; // 70 microns | |
41 | Double_t chrx = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad | |
42 | Double_t chry = 0.0005 / 1000.0 / TMath::Pi()*180; // 0 mrad | |
43 | Double_t chrz = 0.1 / 1000.0 / TMath::Pi()*180; // 0.1 mrad | |
44 | // Truncation for the chambers | |
45 | Double_t cutChdx = 3.0 * chdx; | |
46 | Double_t cutChdy = 3.0 * chdy; | |
47 | Double_t cutChdz = 0.14 * chdz; | |
48 | ||
49 | Int_t sActive[18]={1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1}; | |
50 | Double_t dx=0.,dy=0.,dz=0.,rx=0.,ry=0.,rz=0.; | |
51 | ||
52 | Int_t j=0; | |
53 | UShort_t volid; | |
54 | const char* symname; | |
55 | ||
56 | // create the supermodules' alignment objects | |
57 | for (Int_t iSect=0; iSect<18; iSect++) { | |
58 | TString sm_symname(Form("TRD/sm%02d",iSect)); | |
59 | if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; | |
60 | new((*array)[j++]) | |
61 | AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kTRUE); | |
62 | } | |
63 | ||
64 | // create the chambers' alignment objects | |
65 | Int_t chId; | |
66 | for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) { | |
67 | chId=-1; | |
68 | for (Int_t iSect = 0; iSect < 18; iSect++){ | |
69 | for (Int_t iCh = 0; iCh < 5; iCh++) { | |
70 | dx = AliMathBase::TruncatedGaus(0.0,chdx,cutChdx); | |
71 | dy = AliMathBase::TruncatedGaus(0.0,chdy,cutChdy); | |
72 | dz = AliMathBase::TruncatedGaus(0.0,chdz,cutChdz); | |
73 | rx = gRandom->Rndm() * 2.0*chrx - chrx; | |
74 | ry = gRandom->Rndm() * 2.0*chry - chry; | |
75 | rz = gRandom->Rndm() * 2.0*chrz - chrz; | |
76 | chId++; | |
77 | if ((iSect==13 || iSect==14 || iSect==15) && iCh==2) continue; | |
78 | volid = AliGeomManager::LayerToVolUID(iLayer,chId); | |
79 | if( (TString(gSystem->Getenv("REALSETUP")) == TString("kTRUE")) && !sActive[iSect] ) continue; | |
80 | symname = AliGeomManager::SymName(volid); | |
81 | new(alobj[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE); | |
82 | } | |
83 | } | |
84 | } | |
85 | ||
86 | if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) { | |
87 | // save on file | |
88 | const char* filename = "TRDresidualMisalignment.root"; | |
89 | TFile f(filename,"RECREATE"); | |
90 | if(!f){ | |
91 | Error(macroname,"cannot open file for output\n"); | |
92 | return; | |
93 | } | |
94 | Info(macroname,"Saving alignment objects to the file %s", filename); | |
95 | f.cd(); | |
96 | f.WriteObject(array,"TRDAlignObjs","kSingleKey"); | |
97 | f.Close(); | |
98 | } | |
99 | else { | |
100 | // save in CDB storage | |
101 | AliCDBMetaData* md = new AliCDBMetaData(); | |
102 | md->SetResponsible("Dariusz Miskowiec"); | |
103 | md->SetComment("Residual misalignment for TRD"); | |
104 | md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); | |
105 | AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity()); | |
106 | storage->Put(array,id,md); | |
107 | } | |
108 | ||
109 | array->Delete(); | |
110 | ||
111 | } | |
112 | ||
113 |