Manso tracker is now ported into AliRoot-HLT framework properly.
[u/mrichter/AliRoot.git] / TOF / MakeTOFFullMisAlignment.C
CommitLineData
1895a097 1void MakeTOFFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TOF
6fce62af 3 // Expects to read objects for FRAME
1895a097 4 //
90dbf5fb 5 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
6fce62af 6 const char* macroname = "MakeTOFFullMisAlignment.C";
7
8 // Activate CDB storage and load geometry from CDB
9 AliCDBManager* cdb = AliCDBManager::Instance();
10 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
11 cdb->SetRun(0);
12
13 AliCDBStorage* storage;
14
15 if( 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(); //load geom from default CDB storage
34 }
35
36 // load FRAME full misalignment objects (if needed, the macro
37 // for FRAME has to be run in advance) and apply them to geometry
38 Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
39 Storage.Data());
40 AliCDBPath fpath("GRP","Align","Data");
41 if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
42 AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
43 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
44 TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
45 arFrame->Sort();
46 Int_t nvols = arFrame->GetEntriesFast();
47 Bool_t flag = kTRUE;
48 for(Int_t j=0; j<nvols; j++)
49 {
50 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
51 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
52 }
53 if(!flag)
54 Fatal(macroname,"Error in the application of FRAME alignment objects");
55 }else{
56 AliCDBEntry *eFrame = cdb->Get(fpath.GetPath());
57 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
58 TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
59 arFrame->Sort();
60 Int_t nvols = arFrame->GetEntriesFast();
61 Bool_t flag = kTRUE;
62 for(Int_t j=0; j<nvols; j++)
63 {
64 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
65 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
66 }
67 if(!flag)
68 Fatal(macroname,"Error in the application of FRAME alignment objects");
dfe9c69d 69 }
1895a097 70
6fce62af 71 //Produce objects for TOF supermodules
1895a097 72 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
ae079791 73 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
74 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
d3a9c52a 75
d3a9c52a 76 Int_t nSMTOF = 18;
6fce62af 77 Int_t j=0;
78 Double_t smdx, smdy, smdz, dpsi, dtheta, dphi;
1895a097 79 TRandom *rnd = new TRandom(2345);
80 Double_t sigmatr = 0.4; // max shift in cm w.r.t. local ideal RS
81 Double_t sigmarot = 0.06; // max rot in deg w.r.t. local ideal RS (~ 1 mrad)
d3a9c52a 82
6fce62af 83 for(Int_t i=0; i<nSMTOF; i++) {
d3a9c52a 84 TString symname(Form("TOF/sm%02d",i));
6fce62af 85 smdx = rnd->Gaus(0.,sigmatr);
86 smdy = rnd->Gaus(0.,sigmatr);
87 smdz =0;
3b2d5e3b 88 dpsi = 0.;
1895a097 89 dtheta = rnd->Gaus(0.,sigmarot);
90 dphi = 0.;
6fce62af 91 new((*array)[j++]) AliAlignObjParams(symname.Data(), dvoluid, smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
d3a9c52a 92 }
6fce62af 93 // Apply objects for TOF supermodules
94 for(Int_t i=0; i<nSMTOF; i++){
95 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(i);
d3a9c52a 96 if(!smobj->ApplyToGeometry()){
6fce62af 97 cout<<"application of object "<<i<<" failed!"<<endl;
d3a9c52a 98 return;
99 }
100 }
d3a9c52a 101
6fce62af 102 //Produce objects for TOF strips (same sigmas as for residual misalignment)
ae079791 103 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
d3a9c52a 104
105 Double_t sdx=0.;
106 Double_t sdy=0.;
107 Double_t sdz=0.;
108 Double_t sdpsi, sdtheta, sdphi;
109 TRandom *rnds = new TRandom(4357);
110 sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS
111
ae079791 112 for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
d3a9c52a 113 sdx = 0;
114 sdy = rnds->Gaus(0.,sigmatr);
115 sdz = rnds->Gaus(0.,sigmatr);
116 sdpsi = 0.;
117 sdtheta = 0.;
118 sdphi = 0.;
6fce62af 119 new((*array)[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE);
1895a097 120 }
121
5bd470e1 122 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
6fce62af 123 // save in file
dfe9c69d 124 const char* filename = "TOFfullMisalignment.root";
125 TFile f(filename,"RECREATE");
126 if(!f){
127 Error(macroname,"cannot open file for output\n");
128 return;
129 }
6fce62af 130 Info(macroname,"Saving alignment objects in file %s", filename);
1895a097 131 f.cd();
132 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
133 f.Close();
134 }else{
135 // save in CDB storage
dfe9c69d 136 Info(macroname,"Saving alignment objects in CDB storage %s",
137 Storage.Data());
1895a097 138 AliCDBMetaData* md = new AliCDBMetaData();
139 md->SetResponsible("Silvia Arcelli");
6fce62af 140 md->SetComment("Full misalignment for TOF");
5bd470e1 141 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 142 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
1895a097 143 storage->Put(array,id,md);
144 }
145
146 array->Delete();
147
148}
149
150