1 void MakeTOFFullMisAlignment(){
2 // Create TClonesArray of full misalignment objects for TOF
3 // Expects to read objects for FRAME
5 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
6 const char* macroname = "MakeTOFFullMisAlignment.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 run 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 alignment 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 alignment objects");
71 //Produce objects for TOF supermodules
72 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
73 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
74 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
78 Double_t smdx, smdy, smdz, dpsi, dtheta, dphi;
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)
83 for(Int_t i=0; i<nSMTOF; i++) {
84 TString symname(Form("TOF/sm%02d",i));
85 smdx = rnd->Gaus(0.,sigmatr);
86 smdy = rnd->Gaus(0.,sigmatr);
89 dtheta = rnd->Gaus(0.,sigmarot);
91 new((*array)[j++]) AliAlignObjParams(symname.Data(), dvoluid, smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
93 // Apply objects for TOF supermodules
94 for(Int_t i=0; i<nSMTOF; i++){
95 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(i);
96 if(!smobj->ApplyToGeometry()){
97 cout<<"application of object "<<i<<" failed!"<<endl;
102 //Produce objects for TOF strips (same sigmas as for residual misalignment)
103 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
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
112 for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
114 sdy = rnds->Gaus(0.,sigmatr);
115 sdz = rnds->Gaus(0.,sigmatr);
119 new((*array)[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE);
122 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
124 const char* filename = "TOFfullMisalignment.root";
125 TFile f(filename,"RECREATE");
127 Error(macroname,"cannot open file for output\n");
130 Info(macroname,"Saving alignment objects in file %s", filename);
132 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
135 // save in CDB storage
136 Info(macroname,"Saving alignment objects in CDB storage %s",
138 AliCDBMetaData* md = new AliCDBMetaData();
139 md->SetResponsible("Silvia Arcelli");
140 md->SetComment("Full misalignment for TOF");
141 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
142 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
143 storage->Put(array,id,md);