1 void MakeTRDFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TRD
3 // Expects to read objects for FRAME
5 TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
6 const char* macroname = "MakeTRDFullMisAlignment.C";
8 // Activate CDB storage and load geometry from CDB
9 AliCDBManager* cdb = AliCDBManager::Instance();
10 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
13 AliCDBStorage* storage;
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());
21 storage = cdb->GetStorage(Storage.Data());
23 Error(macroname,"Unable to open storage %s\n",Storage.Data());
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!");
30 TGeoManager* geom = (TGeoManager*) entry->GetObject();
31 AliGeomManager::SetGeometry(geom);
33 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
36 // load FRAME full misalignment objects (if needed, the macro
37 // for FRAME has to be ran in advance) and apply them to geometry
38 Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
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();
46 Int_t nvols = arFrame->GetEntriesFast();
48 for(Int_t j=0; j<nvols; j++)
50 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
51 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
54 Fatal(macroname,"Error in the application of FRAME objects");
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();
60 Int_t nvols = arFrame->GetEntriesFast();
62 for(Int_t j=0; j<nvols; j++)
64 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
65 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
68 Fatal(macroname,"Error in the application of FRAME objects");
72 // sigmas for the supermodules
73 Double_t smdx=0.3; // 3 mm
74 Double_t smdy=0.3; // 3 mm
75 Double_t smdz=0.3; // 3 mm
76 Double_t smrx=0.4/1000/TMath::Pi()*180; // 0.4 mrad
77 Double_t smry=2.0/1000/TMath::Pi()*180; // 2 mrad
78 Double_t smrz=0.4/1000/TMath::Pi()*180; // 0.4 mrad
81 // sigmas for the chambers
82 Double_t chdx=0.1; // 1 mm
83 Double_t chdy=0.1; // 1 mm
84 Double_t chdz=0.1; // 1 mm
85 Double_t chrx=1.0/1000/TMath::Pi()*180; // 1 mrad
86 Double_t chry=1.0/1000/TMath::Pi()*180; // 1 mrad
87 Double_t chrz=0.7/1000/TMath::Pi()*180; // 0.7 mrad
89 Double_t dx,dy,dz,rx,ry,rz;
92 TRandom *ran = new TRandom(4357);
96 // create the supermodules' alignment objects
97 for (int i; i<18; i++) {
98 TString sm_symname(Form("TRD/sm%02d",i));
108 new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
111 for(Int_t k=0; k<18; k++){
112 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
113 if(!smobj->ApplyToGeometry()){
114 cout<<"application of object "<<k<<" failed!"<<endl;
119 // create the chambers' alignment objects
120 ran = new TRandom(4357);
121 for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
122 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
132 volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
133 symname = AliGeomManager::SymName(volid);
134 new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
138 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
140 const char* filename = "TRDfullMisalignment.root";
141 TFile f(filename,"RECREATE");
143 Error(macroname,"cannot open file for output\n");
146 Info(macroname,"Saving alignment objects to the file %s", filename);
148 f.WriteObject(array,"TRDAlignObjs","kSingleKey");
151 // save in CDB storage
152 Info(macroname,"Saving alignment objects in CDB storage %s",
154 AliCDBMetaData* md = new AliCDBMetaData();
155 md->SetResponsible("Dariusz Miskowiec");
156 md->SetComment("Full misalignment for TRD");
157 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
158 AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
159 storage->Put(array,id,md);