1 void MakeTOFResMisAlignment() {
3 // Create TClonesArray of residual misalignment objects for TOF
6 const char* macroname = "MakeTOFResMisAlignment.C";
8 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
9 TClonesArray &alobj = *array;
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");
17 AliCDBStorage* storage;
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());
26 storage = cdb->GetStorage(Storage.Data());
28 Error(macroname,"Unable to open storage %s\n",Storage.Data());
31 AliCDBPath path("GRP","Geometry","Data");
32 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
34 Fatal(macroname,"Could not get the specified CDB entry!");
37 TGeoManager* geom = (TGeoManager*) entry->GetObject();
38 AliGeomManager::SetGeometry(geom);
40 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
42 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
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(),
55 smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
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
66 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
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);
81 dy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
82 dz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
89 dy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
90 dz = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz);
96 dy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
97 dz = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut);
102 dy = AliMathBase::TruncatedGaus(0., sigmatr, cut);
103 dz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
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);
115 if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
117 const char* filename = "TOFresidualMisalignment.root";
118 TFile f(filename,"RECREATE");
120 Error(macroname,"cannot open file for output\n");
123 Info(macroname,"Saving alignment objects to the file %s", filename);
125 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
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);
142 Double_t LocalTruncatedGaus(Double_t mean, Double_t sigma, Double_t cutatL, Double_t cutatR)
144 // return number generated according to a gaussian distribution N(mean,sigma) truncated at cutat
148 value=gRandom->Gaus(mean,sigma);
149 }while(value-mean<-cutatL || value-mean>cutatR);