void MakeTRDFullMisAlignment(){
// Create TClonesArray of full misalignment objects for TRD
+ // Expects to read objects for FRAME
//
- TClonesArray *array = new TClonesArray("AliAlignObjAngles",1000);
- TClonesArray &alobj = *array;
-
- AliAlignObjAngles a;
+ TClonesArray *array = new TClonesArray("AliAlignObjParams",1000);
+ const char* macroname = "MakeTRDFullMisAlignment.C";
+ // 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( 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
+ }
+
+ // load FRAME full misalignment objects (if needed, the macro
+ // for FRAME has to be ran in advance) and apply them to geometry
+ Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
+ Storage.Data());
+ AliCDBPath fpath("GRP","Align","Data");
+ if( gSystem->Getenv("TOCDB") == TString("kTRUE") ){
+ AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
+ if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+ TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
+ arFrame->Sort();
+ Int_t nvols = arFrame->GetEntriesFast();
+ Bool_t flag = kTRUE;
+ for(Int_t j=0; j<nvols; j++)
+ {
+ AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
+ if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
+ }
+ if(!flag)
+ Fatal(macroname,"Error in the application of FRAME objects");
+ }else{
+ AliCDBEntry *eFrame = cdb->Get(fpath.GetPath());
+ if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+ TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
+ arFrame->Sort();
+ Int_t nvols = arFrame->GetEntriesFast();
+ Bool_t flag = kTRUE;
+ for(Int_t j=0; j<nvols; j++)
+ {
+ AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
+ if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
+ }
+ if(!flag)
+ Fatal(macroname,"Error in the application of FRAME objects");
+ }
+
+
// sigmas for the supermodules
Double_t smdx=0.3; // 3 mm
Double_t smdy=0.3; // 3 mm
UShort_t volid;
const char *symname;
- TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO.root"); // geometry where the BSEGMO volumes have been misaligned
-
// create the supermodules' alignment objects
for (int i; i<18; i++) {
TString sm_symname(Form("TRD/sm%02d",i));
rx*=smrx;
ry*=smry;
rz*=smrz;
- new(alobj[j++]) AliAlignObjAngles(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
+ new((*array)[j++]) AliAlignObjParams(sm_symname.Data(),0,dx,dy,dz,rx,ry,rz,kFALSE);
}
for(Int_t k=0; k<18; k++){
- AliAlignObjAngles* smobj = (AliAlignObjAngles*)array->UncheckedAt(k);
+ AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(k);
if(!smobj->ApplyToGeometry()){
cout<<"application of object "<<k<<" failed!"<<endl;
return;
}
}
- gGeoManager->Export("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_trdSM.root");
- gGeoManager=0x0;
- TGeoManager::Import("/home/rgrosso/MacroAllineamento010207/geom_misalBSEGMO_trdSM.root");
+
// create the chambers' alignment objects
ran = new TRandom(4357);
for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
rz*=chrz;
volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
symname = AliGeomManager::SymName(volid);
- new(alobj[j++]) AliAlignObjAngles(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
+ new((*array)[j++]) AliAlignObjParams(symname,volid,dx,dy,dz,rx,ry,rz,kFALSE);
}
}
if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
// save on file
- TFile f("TRDfullMisalignment.root","RECREATE");
- if(!f) cerr<<"cannot open file for output\n";
+ const char* filename = "TRDfullMisalignment.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,"TRDAlignObjs","kSingleKey");
f.Close();
}else{
// save in CDB storage
- const char* Storage = gSystem->Getenv("STORAGE");
- AliCDBManager* cdb = AliCDBManager::Instance();
- AliCDBStorage* storage = cdb->GetStorage(Storage);
+ Info(macroname,"Saving alignment objects in CDB storage %s",
+ Storage.Data());
AliCDBMetaData* md = new AliCDBMetaData();
md->SetResponsible("Dariusz Miskowiec");
md->SetComment("Full misalignment for TRD");
md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
- AliCDBId id("TRD/Align/Data",0,9999999);
+ AliCDBId id("TRD/Align/Data",0,AliCDBRunRange::Infinity());
storage->Put(array,id,md);
}
array->Delete();
-
}