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