void MakeITSResMisAlignment(){
// Create TClonesArray of residual misalignment objects for ITS
//
- TClonesArray *array = new TClonesArray("AliAlignObjAngles",4000);
+ TClonesArray *array = new TClonesArray("AliAlignObjParams",4000);
TClonesArray &alobj = *array;
+ const char* macroname = "MakeITSResMisAlignment.C";
- if(!gGeoManager) TGeoManager::Import("geometry.root");
- // needed for the constructors with local coordinates not to fail
+ // Activate CDB storage and load geometry from CDB
+ AliCDBManager* cdb = AliCDBManager::Instance();
+ if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+ 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 globalZ = 0.005; // in cm, = 50 microns
Double_t resFact = 0.7;
Double_t ssdZ = 0.010;
TRandom *rnd = new TRandom(65416087);
- AliAlignObjAngles a;
Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
- AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
+ AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
Int_t j = 0;
- new(alobj[j++]) AliAlignObjAngles("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
- AliAlignObjAngles* its_alobj = (AliAlignObjAngles*) array->UncheckedAt(0);
+ new(alobj[j++]) AliAlignObjParams("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
+ AliAlignObjParams* its_alobj = (AliAlignObjParams*) array->UncheckedAt(0);
its_alobj->ApplyToGeometry();
- for ( Int_t l = AliAlignObj::kSPD1; l <= AliAlignObj::kSSD2; l++) {
+ for ( Int_t l = AliGeomManager::kSPD1; l <= AliGeomManager::kSSD2; l++) {
- printf("%i modules in layer %i\n", AliAlignObj::LayerSize(l), l);
- for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(l); iModule++) {
+ printf("%i modules in layer %i\n", AliGeomManager::LayerSize(l), l);
+ for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(l); iModule++) {
dpsi = rnd->Gaus(0., rot);
dtheta = rnd->Gaus(0., rot);
dphi = rnd->Gaus(0., rot);
- iLayer = AliAlignObj::kInvalidLayer;
+ iLayer = AliGeomManager::kInvalidLayer;
switch (l) {
case 1: {
- iLayer = AliAlignObj::kSPD1;
+ iLayer = AliGeomManager::kSPD1;
dx = rnd->Gaus(0., spdXY);
dy = rnd->Gaus(0., spdXY);
dz = rnd->Gaus(0., spdZ);
}; break;
case 2: {
- iLayer = AliAlignObj::kSPD2;
+ iLayer = AliGeomManager::kSPD2;
dx = rnd->Gaus(0., spdXY);
dy = rnd->Gaus(0., spdXY);
dz = rnd->Gaus(0., spdZ);
}; break;
case 3: {
- iLayer = AliAlignObj::kSDD1;
+ iLayer = AliGeomManager::kSDD1;
dx = rnd->Gaus(0., sddXYZ);
dy = rnd->Gaus(0., sddXYZ);
dz = rnd->Gaus(0., sddXYZ);
}; break;
case 4: {
- iLayer = AliAlignObj::kSDD2;
+ iLayer = AliGeomManager::kSDD2;
dx = rnd->Gaus(0., sddXYZ);
dy = rnd->Gaus(0., sddXYZ);
dz = rnd->Gaus(0., sddXYZ);
}; break;
case 5: {
- iLayer = AliAlignObj::kSSD1;
+ iLayer = AliGeomManager::kSSD1;
dx = rnd->Gaus(0., ssdXY);
dy = rnd->Gaus(0., ssdXY);
dz = rnd->Gaus(0., ssdZ);
}; break;
case 6: {
- iLayer = AliAlignObj::kSSD2;
+ iLayer = AliGeomManager::kSSD2;
dx = rnd->Gaus(0., ssdXY);
dy = rnd->Gaus(0., ssdXY);
dz = rnd->Gaus(0., ssdZ);
}; break;
default: Printf("Wrong layer index in ITS (%d) !",l);
};
- UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
- const char *symname = AliAlignObj::SymName(volid);
+ UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
+ const char *symname = AliGeomManager::SymName(volid);
- new(alobj[j]) AliAlignObjAngles(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
+ new(alobj[j]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
j++;
}
}
- if(!gSystem->Getenv("$TOCDB")){
+ if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
// save on file
- TFile f("ITSresidualMisalignment.root","RECREATE");
- if(!f) {cerr<<"cannot open file for output\n";}
+ const char* filename = "ITSresidualMisalignment.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,"ITSAlignObjs","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("Ludovic Gaudichet");
md->SetComment("Alignment objects with actual ITS misalignment");
- md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
- AliCDBId id("ITS/Align/Data",0,9999999);
+ md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+ AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
storage->Put(array,id, md);
}