]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/MakeTOFResMisAlignment.C
file from LDC2 to simulate data from pulser runs
[u/mrichter/AliRoot.git] / TOF / MakeTOFResMisAlignment.C
1 void MakeTOFResMisAlignment(){
2   // Create TClonesArray of residual misalignment objects for TOF
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
5   TClonesArray &alobj = *array;
6    
7   const char* macroname = "MakeTOFResMisAlignment.C";
8
9   // Activate CDB storage and load geometry from CDB
10   AliCDBManager* cdb = AliCDBManager::Instance();
11   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
12   cdb->SetRun(0);
13   
14   AliCDBStorage* storage;
15   
16   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
17     TString Storage = gSystem->Getenv("STORAGE");
18     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
19       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
20       return;
21     }
22     storage = cdb->GetStorage(Storage.Data());
23     if(!storage){
24       Error(macroname,"Unable to open storage %s\n",Storage.Data());
25       return;
26     }
27     AliCDBPath path("GRP","Geometry","Data");
28     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
29     if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
30     entry->SetOwner(0);
31     TGeoManager* geom = (TGeoManager*) entry->GetObject();
32     AliGeomManager::SetGeometry(geom);
33   }else{
34     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
35   }    
36
37   AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
38   Int_t j=0;
39   Int_t strId=-1;
40   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
41   TRandom *rnd   = new TRandom(4357);
42   Double_t sigmatr = 0.1; // sigma (in cm) for shift w.r.t. local ideal RS
43
44   Int_t sActive[18]={0,1,1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1};
45
46   Int_t nstrA=15;
47   Int_t nstrB=19;
48   Int_t nstrC=19;
49   Int_t nSectors=18;
50   Int_t nStrips=nstrA+2*nstrB+2*nstrC;
51
52   for (Int_t isect = 0; isect < nSectors; isect++) {
53     for (Int_t istr = 1; istr <= nStrips; istr++) {
54     dy = rnd->Gaus(0.,sigmatr);
55     dz = rnd->Gaus(0.,sigmatr);
56       strId++;
57       if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
58       if( (TString(gSystem->Getenv("PARTGEOM")) == TString("kTRUE")) && !sActive[iSect] ) continue;
59       new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),AliGeomManager::LayerToVolUID(idTOF,strId), dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
60     }
61   }
62
63   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
64     // save on file
65     const char* filename = "TOFresidualMisalignment.root";
66     TFile f(filename,"RECREATE");
67     if(!f){
68       Error(macroname,"cannot open file for output\n");
69       return;
70     }
71     Info(macroname,"Saving alignment objects to the file %s", filename);
72     f.cd();
73     f.WriteObject(array,"TOFAlignObjs","kSingleKey");
74     f.Close();
75   }else{
76     // save in CDB storage
77     AliCDBMetaData* md = new AliCDBMetaData();
78     md->SetResponsible("Silvia Arcelli");
79     md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
80     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
81     AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
82     storage->Put(array,id,md);
83   }
84
85   array->Delete();
86
87 }
88
89