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