Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / HMPID / MakeHMPIDResMisAlignment.C
CommitLineData
d3da6dc4 1void MakeHMPIDResMisAlignment(){
2 // Create TClonesArray of residual misalignment objects for HMPID
3 //
4 Float_t sigmaTrans=0.1; // 1mm
5 Float_t sigmaRot=0.001*180/TMath::Pi(); // 1 mrad
6 Float_t dX, dY, dX; Float_t dPsi, dTheta, dPhi; //displacements
7
8 TClonesArray *pCA = new TClonesArray("AliAlignObjMatrix",10);
9
10 TRandom *pRnd = new TRandom(4357);
11
12 AliAlignObjMatrix o;
13
ae079791 14 Int_t idHMPID = AliGeomManager::kHMPID;
d3da6dc4 15 for (Int_t iCh = 0; iCh < 7; iCh++) {
16 dX = (pRnd->Uniform()-0.5)*sigmaTrans; dY = (pRnd->Uniform()-0.5)*sigmaTrans; dZ = (pRnd->Uniform()-0.5)*sigmaTrans;
17 dPsi = (pRnd->Uniform()-0.5)*sigmaRot; dTheta = (pRnd->Uniform()-0.5)*sigmaRot; dPhi = (pRnd->Uniform()-0.5)*sigmaRot;
ae079791 18 new((*pCA)[iCh]) AliAlignObjMatrix(AliGeomManager::SymName(idHMPID,iCh),AliGeomManager::LayerToVolUID(idHMPID,iCh),dX,dY,dZ,dPsi,dTheta,dPhi,kTRUE);
d3da6dc4 19 }
20
21// pCA->Print();
22
dfe9c69d 23 const char* macroname = "MakeHMPIDResMisAlignment.C";
5bd470e1 24 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
d3da6dc4 25 // save on file
dfe9c69d 26 const char* filename = "HMPIDresidualMisalignment.root";
27 TFile f(filename,"RECREATE");
28 if(!f){
29 Error(macroname,"cannot open file for output\n");
30 return;
31 }
32 Info(macroname,"Saving alignment objects to the file %s", filename);
d3da6dc4 33 f.cd();
34 f.WriteObject(pCA,"HMPIDAlignObjs","kSingleKey");
35 f.Close();
36 }else{
37 // save in CDB storage
dfe9c69d 38 TString Storage = gSystem->Getenv("STORAGE");
39 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
40 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
41 return;
42 }
43 Info(macroname,"Saving alignment objects in CDB storage %s",
44 Storage.Data());
d3da6dc4 45 AliCDBManager* cdb = AliCDBManager::Instance();
dfe9c69d 46 AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
47 if(!storage){
48 Error(macroname,"Unable to open storage %s\n",Storage.Data());
49 return;
50 }
d3da6dc4 51 AliCDBMetaData *pMeta= new AliCDBMetaData();
52 pMeta->SetResponsible("HMPID Expert");
53 pMeta->SetComment("Residual alignment objects for HMPID produced with sigmaTrans=1mm and sigmaRot=1mrad");
5bd470e1 54 pMeta->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 55 AliCDBId id("HMPID/Align/Data",0,AliCDBRunRange::Infinity());
d3da6dc4 56 storage->Put(pCA,id,pMeta);
57 }
58
59 pCA->Delete();
60}