1 void MakeTOFFullMisAlignment() {
3 // Create TClonesArray of full misalignment objects for TOF
4 // Expects to read objects for FRAME
7 const char* macroname = "MakeTOFFullMisAlignment.C";
9 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
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!");
36 TGeoManager* geom = (TGeoManager*) entry->GetObject();
37 AliGeomManager::SetGeometry(geom);
39 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
41 // load FRAME full misalignment objects (if needed, the macro
42 // for FRAME has to be run in advance) and apply them to geometry
43 AliCDBPath fpath("GRP","Align","Data");
44 if ( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ) {
45 Info(macroname,"Loading FRAME alignment objects from CDB storage %s",
47 AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun());
49 AliCDBEntry *eFrame = cdb->Get(fpath.GetPath());
52 Fatal(macroname,"Could not get the specified CDB entry!");
54 TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject();
56 Int_t nvols = arFrame->GetEntriesFast();
58 for(Int_t j=0; j<nvols; j++)
60 AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j);
61 if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE;
64 Fatal(macroname,"Error in the application of FRAME alignment objects");
66 //Produce objects for TOF supermodules
67 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
68 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
69 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
73 Double_t smdx, smdy, smdz=0., dpsi=0., dtheta, dphi=0.;
74 TRandom *rnd = new TRandom(2345);
75 Double_t sigmatr = 0.4; // max shift in cm w.r.t. local ideal RS
76 Double_t sigmarot = 0.06; // max rot in deg w.r.t. local ideal RS (~ 1 mrad)
78 for (Int_t isect=0; isect<nSMTOF; isect++) {
79 TString symname(Form("TOF/sm%02d",isect));
80 smdx = rnd->Gaus(0.,sigmatr);
81 smdy = rnd->Gaus(0.,sigmatr);
82 dtheta = rnd->Gaus(0.,sigmarot);
83 new((*array)[j++]) AliAlignObjParams(symname.Data(),
85 smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE);
87 // Apply objects for TOF supermodules
89 for (Int_t isect=0; isect<nSMTOF; isect++) {
90 AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(smCounter++);
91 //Info(macroname,Form("Applying object for sector %d ",isect));
92 if ( !smobj->ApplyToGeometry() )
93 Fatal(macroname,Form("application of full misalignment object for sector %d failed!",isect));
97 //Produce objects for TOF strips (same sigmas as for residual misalignment)
98 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
101 Double_t sdx=0., sdy=0., sdz=0., sdpsi=0., sdtheta=0., sdphi=0.;
102 //TRandom *rnds = new TRandom(4357);
103 sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS
109 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
110 Double_t cuty=0., cutz=0., cut=3*sigmatr;
112 for (Int_t isect = 0; isect < nSectors; isect++) {
113 for (Int_t istr = 1; istr <= nStrips; istr++) {
120 sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
121 sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
128 sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
129 sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz);
135 sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty);
136 sdz = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut);
141 sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut);
142 sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut);
147 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
148 new((*array)[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),
149 AliGeomManager::LayerToVolUID(idTOF,strId),
150 sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE);
154 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
156 const char* filename = "TOFfullMisalignment.root";
157 TFile f(filename,"RECREATE");
159 Error(macroname,"cannot open file for output\n");
162 Info(macroname,"Saving alignment objects in file %s", filename);
164 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
167 // save in CDB storage
168 Info(macroname,"Saving alignment objects in CDB storage %s",
170 AliCDBMetaData* md = new AliCDBMetaData();
171 md->SetResponsible("Silvia Arcelli");
172 md->SetComment("Full misalignment for TOF");
173 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
174 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
175 storage->Put(array,id,md);
183 Double_t LocalTruncatedGaus(Double_t mean, Double_t sigma, Double_t cutatL, Double_t cutatR)
185 // return number generated according to a gaussian distribution N(mean,sigma) truncated at cutat
189 value=gRandom->Gaus(mean,sigma);
190 }while(value-mean<-cutatL || value-mean>cutatR);