]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/MakeTOFResMisAlignment.C
Changes for report #74151: Important update in AliTOFPIDResponse class: use also...
[u/mrichter/AliRoot.git] / TOF / MakeTOFResMisAlignment.C
1 void MakeTOFResMisAlignment() {
2   //
3   // Create TClonesArray of residual misalignment objects for TOF
4   //
5
6   const char* macroname = "MakeTOFResMisAlignment.C";
7
8   TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
9   TClonesArray &alobj = *array;
10    
11   // Activate CDB storage and load geometry from CDB
12   AliCDBManager* cdb = AliCDBManager::Instance();
13   if (!cdb->IsDefaultStorageSet())
14     cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
15   cdb->SetRun(0);
16
17   AliCDBStorage* storage;
18   TString Storage;
19
20   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
21     Storage = gSystem->Getenv("STORAGE");
22     if (!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
23       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
24       return;
25     }
26     storage = cdb->GetStorage(Storage.Data());
27     if (!storage) {
28       Error(macroname,"Unable to open storage %s\n",Storage.Data());
29       return;
30     }
31     AliCDBPath path("GRP","Geometry","Data");
32     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
33     if (!entry)
34       Fatal(macroname,"Could not get the specified CDB entry!");
35
36     entry->SetOwner(0);
37     TGeoManager* geom = (TGeoManager*) entry->GetObject();
38     AliGeomManager::SetGeometry(geom);
39   } else
40     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
41
42   AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
43   Int_t j=0;
44   Int_t nSectors=18;
45
46   //Produce objects for TOF supermodules
47   Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
48   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
49   UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id 
50   Double_t smdx, smdy, smdz=0., dpsi=0., dtheta, dphi=0.;
51   for(Int_t isect=0; isect<nSectors; isect++) {
52     TString symname(Form("TOF/sm%02d",isect));
53     new(alobj[j++]) AliAlignObjParams(symname.Data(),
54                                       dvoluid,
55                                       smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
56   }
57
58   Int_t strId=-1;
59   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
60   //TRandom *rnd   = new TRandom(4357);
61   Double_t sigmatr = 0.1; // sigma (in cm) for shift w.r.t. local ideal RS
62
63   Int_t nstrA=15;
64   Int_t nstrB=19;
65   Int_t nstrC=19;
66   Int_t nStrips=nstrA+2*nstrB+2*nstrC;
67
68   Double_t cuty=0., cutz=0., cut=3*sigmatr;
69   for (Int_t isect = 0; isect < nSectors; isect++) {
70     for (Int_t istr = 1; istr <= nStrips; istr++) {
71       //dy = rnd->Gaus(0.,sigmatr);
72       //dz = rnd->Gaus(0.,sigmatr);
73       //strId++;
74
75       switch (istr) {
76       case 25:
77       case 29:
78       case 63:
79       case 67:
80         cuty = sigmatr*0.6;
81         dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
82         dz  = AliMathBase::TruncatedGaus(0., sigmatr, cut);
83         strId++;
84         break;
85         /*
86       case 38:
87         cuty = sigmatr*2.5;
88         cutz = sigmatr*2.5;
89         dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
90         dz  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz);
91         strId++;
92         break;
93       case 54:
94         cuty = sigmatr*2.5;
95         cutz = sigmatr*2.5;
96         dy  = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
97         dz  = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut);
98         strId++;
99         break;
100         */
101       default:
102         dy = AliMathBase::TruncatedGaus(0., sigmatr, cut);
103         dz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
104         strId++;
105         break;
106       }
107
108       if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
109       new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),
110                                         AliGeomManager::LayerToVolUID(idTOF,strId),
111                                         dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
112     }
113   }
114
115   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
116     // save on file
117     const char* filename = "TOFresidualMisalignment.root";
118     TFile f(filename,"RECREATE");
119     if(!f){
120       Error(macroname,"cannot open file for output\n");
121       return;
122     }
123     Info(macroname,"Saving alignment objects to the file %s", filename);
124     f.cd();
125     f.WriteObject(array,"TOFAlignObjs","kSingleKey");
126     f.Close();
127   } else {
128     // save in CDB storage
129     AliCDBMetaData* md = new AliCDBMetaData();
130     md->SetResponsible("Silvia Arcelli");
131     md->SetComment("Residual misalignment for TOF, sigmatr=1mm in the local RS");
132     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
133     AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
134     storage->Put(array,id,md);
135   }
136
137   array->Delete();
138
139 }
140
141 /*
142 Double_t LocalTruncatedGaus(Double_t mean, Double_t sigma, Double_t cutatL, Double_t cutatR)
143 {
144   // return number generated according to a gaussian distribution N(mean,sigma) truncated at cutat
145   //
146   Double_t value;
147   do{
148     value=gRandom->Gaus(mean,sigma);
149   }while(value-mean<-cutatL || value-mean>cutatR);
150   return value;
151 }
152 */