X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FMakeEMCALResMisAlignment.C;h=5a3b3d276db0e5883026d3963498a9723d3f4454;hb=f3dd29bfcbce4d86ce3a91128d5f71b6ad738735;hp=7fe39f1786b8c7a0aba107ec7529d5505d204f27;hpb=7e154d52537ff5be2593b968e21305a1ef560c88;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/MakeEMCALResMisAlignment.C b/EMCAL/MakeEMCALResMisAlignment.C index 7fe39f1786b..5a3b3d276db 100644 --- a/EMCAL/MakeEMCALResMisAlignment.C +++ b/EMCAL/MakeEMCALResMisAlignment.C @@ -1,31 +1,66 @@ -void MakeEMCALResMisAlignment(){ +void MakeEMCALResMisAlignment(TString geoname = "EMCAL_COMPLETE"){ // Create TClonesArray of residual misalignment objects for EMCAL // - TClonesArray *array = new TClonesArray("AliAlignObjAngles",10); + const char* macroname = "MakeEMCALResMisAlignment.C"; + if(geoname=="")geoname=AliEMCALGeometry::GetDefaultGeometryName(); + const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(geoname,""); + if(!emcalGeom) { + Error("MakeEMCALResMisAlignment","Cannot obtain AliEMCALGeometry singleton\n"); + return; + } + + TClonesArray *array = new TClonesArray("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules()); TClonesArray &alobj = *array; - if(!gGeoManager) TGeoManager::Import("geometry.root"); - // needed for the constructors with local coordinates not to fail - AliAlignObjAngles a; + // Activate CDB storage and load geometry from CDB + AliCDBManager* cdb = AliCDBManager::Instance(); + if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + cdb->SetRun(0); + + AliCDBStorage* storage; + + if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ + TString Storage = gSystem->Getenv("STORAGE"); + if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) { + Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data()); + return; + } + storage = cdb->GetStorage(Storage.Data()); + if(!storage){ + Error(macroname,"Unable to open storage %s\n",Storage.Data()); + return; + } + AliCDBPath path("GRP","Geometry","Data"); + AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun()); + if(!entry) Fatal(macroname,"Could not get the specified CDB entry!"); + entry->SetOwner(0); + TGeoManager* geom = (TGeoManager*) entry->GetObject(); + AliGeomManager::SetGeometry(geom); + }else{ + AliGeomManager::LoadGeometry(); //load geom from default CDB storage + } Double_t dx, dy, dz, dpsi, dtheta, dphi; const TString basepath = "EMCAL/FullSupermodule"; + const TString hbasepath = "EMCAL/HalfSupermodule"; TString pathstr; Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT - AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; - UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex); + AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; + UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); Int_t i; + Int_t j=0; // RS = local // sigma translation = 1mm // sigma rotation = 0.1 degree TRandom *rnd = new TRandom(4321); - Double_t sigmatr = 0.1; // max shift in cm w.r.t. local RS + Double_t sigmatr = 0.05; // max shift in cm w.r.t. local RS Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS + for(i=0; i<10; i++){ dx = rnd->Gaus(0.,sigmatr); dy = rnd->Gaus(0.,sigmatr); @@ -35,26 +70,40 @@ void MakeEMCALResMisAlignment(){ dphi = rnd->Gaus(0.,sigmarot); pathstr=basepath; pathstr+=(i+1); - new(alobj[i]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE); + new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE); + } + + for(i=0; i<2; i++){ + dx = rnd->Gaus(0.,sigmatr); + dy = rnd->Gaus(0.,sigmatr); + dz = rnd->Gaus(0.,sigmatr); + dpsi = rnd->Gaus(0.,sigmarot); + dtheta = rnd->Gaus(0.,sigmarot); + dphi = rnd->Gaus(0.,sigmarot); + pathstr=hbasepath; + pathstr+=(i+1); + new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE); } - if(!gSystem->Getenv("$TOCDB")){ + if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ // save on file - TFile f("EMCALresidualMisalignment.root","RECREATE"); - if(!f) cerr<<"cannot open file for output\n"; + const char* filename = "EMCALresidualMisalignment.root"; + TFile f(filename,"RECREATE"); + if(!f){ + Error(macroname,"cannot open file for output\n"); + return; + } + Info(macroname,"Saving alignment objects to the file %s", filename); f.cd(); - f.WriteObject(array,"T0ResidualObjs ","kSingleKey"); + f.WriteObject(array,"EMCALAlignObjs","kSingleKey"); f.Close(); }else{ // save in CDB storage - const char* Storage = gSystem->Getenv("$STORAGE"); - AliCDBManager* cdb = AliCDBManager::Instance(); - AliCDBStorage* storage = cdb->GetStorage(Storage); AliCDBMetaData* md = new AliCDBMetaData(); - md->SetResponsible("Jennifer Clay"); - md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS"); - md->SetAliRootVersion(gSystem->Getenv("$ARVERSION")); - AliCDBId id("EMCAL/Align/Data",0,9999999); + md->SetResponsible("Jennifer Klay"); + md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.1 in the local RS"); + md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); + AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity()); storage->Put(array,id,md); }