1 void MakeTOFResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for TOF
4 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
5 TClonesArray &alobj = *array;
7 const char* macroname = "MakeTOFResMisAlignment.C";
9 // Activate CDB storage and load geometry from CDB
10 AliCDBManager* cdb = AliCDBManager::Instance();
11 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
14 AliCDBStorage* storage;
17 if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
18 Storage = gSystem->Getenv("STORAGE");
19 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
20 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
23 storage = cdb->GetStorage(Storage.Data());
25 Error(macroname,"Unable to open storage %s\n",Storage.Data());
28 AliCDBPath path("GRP","Geometry","Data");
29 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
30 if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
32 TGeoManager* geom = (TGeoManager*) entry->GetObject();
33 AliGeomManager::SetGeometry(geom);
35 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
38 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
41 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
42 TRandom *rnd = new TRandom(4357);
43 Double_t sigmatr = 0.1; // sigma (in cm) for shift w.r.t. local ideal RS
45 Int_t sActive[18]={0,1,1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1};
51 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
53 for (Int_t isect = 0; isect < nSectors; isect++) {
54 for (Int_t istr = 1; istr <= nStrips; istr++) {
55 dy = rnd->Gaus(0.,sigmatr);
56 dz = rnd->Gaus(0.,sigmatr);
58 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
59 if( (TString(gSystem->Getenv("PARTGEOM")) == TString("kTRUE")) && !sActive[isect] ) continue;
60 new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),AliGeomManager::LayerToVolUID(idTOF,strId), dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
64 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
66 const char* filename = "TOFresidualMisalignment.root";
67 TFile f(filename,"RECREATE");
69 Error(macroname,"cannot open file for output\n");
72 Info(macroname,"Saving alignment objects to the file %s", filename);
74 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
77 // save in CDB storage
78 AliCDBMetaData* md = new AliCDBMetaData();
79 md->SetResponsible("Silvia Arcelli");
80 md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
81 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
82 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
83 storage->Put(array,id,md);