Updated HMPID DA. It uses now recently introduced AilHMPIDRawStream class. The DA...
[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   AliAlignObjMatrix o;
13  
14   Int_t idHMPID =  AliGeomManager::kHMPID;
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;
18     new((*pCA)[iCh]) AliAlignObjMatrix(AliGeomManager::SymName(idHMPID,iCh),AliGeomManager::LayerToVolUID(idHMPID,iCh),dX,dY,dZ,dPsi,dTheta,dPhi,kTRUE);
19   }
20
21 //   pCA->Print();
22   
23   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
24     // save on file
25     TFile f("HMPIDresidualMisalignment.root","RECREATE");
26     if(!f) cerr<<"cannot open file for output\n";
27     f.cd();
28     f.WriteObject(pCA,"HMPIDAlignObjs","kSingleKey");
29     f.Close();
30   }else{
31     // save in CDB storage
32     const char* Storage = gSystem->Getenv("STORAGE");
33     AliCDBManager* cdb = AliCDBManager::Instance();
34     AliCDBStorage* storage = cdb->GetStorage(Storage);
35     AliCDBMetaData *pMeta= new AliCDBMetaData();  
36     pMeta->SetResponsible("HMPID Expert");
37     pMeta->SetComment("Residual alignment objects for HMPID produced with sigmaTrans=1mm and sigmaRot=1mrad");
38     pMeta->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
39     AliCDBId id("HMPID/Align/Data",0,9999999);
40     storage->Put(pCA,id,pMeta);
41   }
42   
43   pCA->Delete();
44 }