]>
Commit | Line | Data |
---|---|---|
1895a097 | 1 | void MakeTOFFullMisAlignment(){ |
2 | // Create TClonesArray of full misalignment objects for TOF | |
6fce62af | 3 | // Expects to read objects for FRAME |
1895a097 | 4 | // |
90dbf5fb | 5 | TClonesArray *array = new TClonesArray("AliAlignObjParams",2000); |
6fce62af | 6 | const char* macroname = "MakeTOFFullMisAlignment.C"; |
7 | ||
8 | // Activate CDB storage and load geometry from CDB | |
9 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
162637e4 | 10 | if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
6fce62af | 11 | cdb->SetRun(0); |
12 | ||
13 | AliCDBStorage* storage; | |
a24be56b | 14 | TString Storage; |
6fce62af | 15 | |
a24be56b | 16 | if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ |
17 | Storage = gSystem->Getenv("STORAGE"); | |
6fce62af | 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 | // load FRAME full misalignment objects (if needed, the macro | |
38 | // for FRAME has to be run in advance) and apply them to geometry | |
6fce62af | 39 | AliCDBPath fpath("GRP","Align","Data"); |
a24be56b | 40 | if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){ |
41 | Info(macroname,"Loading FRAME alignment objects from CDB storage %s", | |
42 | Storage.Data()); | |
6fce62af | 43 | AliCDBEntry *eFrame = storage->Get(fpath.GetPath(),cdb->GetRun()); |
6fce62af | 44 | }else{ |
45 | AliCDBEntry *eFrame = cdb->Get(fpath.GetPath()); | |
dfe9c69d | 46 | } |
a24be56b | 47 | if(!eFrame) Fatal(macroname,"Could not get the specified CDB entry!"); |
48 | TClonesArray* arFrame = (TClonesArray*) eFrame->GetObject(); | |
49 | arFrame->Sort(); | |
50 | Int_t nvols = arFrame->GetEntriesFast(); | |
51 | Bool_t flag = kTRUE; | |
52 | for(Int_t j=0; j<nvols; j++) | |
53 | { | |
54 | AliAlignObj* alobj = (AliAlignObj*) arFrame->UncheckedAt(j); | |
55 | if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; | |
56 | } | |
57 | if(!flag) Fatal(macroname,"Error in the application of FRAME alignment objects"); | |
1895a097 | 58 | |
6fce62af | 59 | //Produce objects for TOF supermodules |
1895a097 | 60 | Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT |
ae079791 | 61 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
62 | UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id | |
d3a9c52a | 63 | |
d3a9c52a | 64 | Int_t nSMTOF = 18; |
6fce62af | 65 | Int_t j=0; |
a24be56b | 66 | Double_t smdx, smdy, smdz=0., dpsi=0., dtheta, dphi=0.; |
1895a097 | 67 | TRandom *rnd = new TRandom(2345); |
68 | Double_t sigmatr = 0.4; // max shift in cm w.r.t. local ideal RS | |
69 | Double_t sigmarot = 0.06; // max rot in deg w.r.t. local ideal RS (~ 1 mrad) | |
d3a9c52a | 70 | |
85ce4b22 | 71 | for(Int_t isect=0; isect<nSMTOF; isect++) { |
72 | TString symname(Form("TOF/sm%02d",isect)); | |
6fce62af | 73 | smdx = rnd->Gaus(0.,sigmatr); |
74 | smdy = rnd->Gaus(0.,sigmatr); | |
1895a097 | 75 | dtheta = rnd->Gaus(0.,sigmarot); |
6fce62af | 76 | new((*array)[j++]) AliAlignObjParams(symname.Data(), dvoluid, smdx, smdy, smdz, dpsi, dtheta, dphi, kFALSE); |
d3a9c52a | 77 | } |
6fce62af | 78 | // Apply objects for TOF supermodules |
a24be56b | 79 | Int_t smCounter=0; |
85ce4b22 | 80 | for(Int_t isect=0; isect<nSMTOF; isect++){ |
a24be56b | 81 | AliAlignObjParams* smobj = (AliAlignObjParams*)array->UncheckedAt(smCounter++); |
85ce4b22 | 82 | Info(macroname,Form("Applying object for sector %d ",isect)); |
d3a9c52a | 83 | if(!smobj->ApplyToGeometry()){ |
85ce4b22 | 84 | Fatal(macroname,Form("application of full misalignment object for sector %d failed!",isect)); |
d3a9c52a | 85 | return; |
86 | } | |
87 | } | |
d3a9c52a | 88 | |
6fce62af | 89 | //Produce objects for TOF strips (same sigmas as for residual misalignment) |
ae079791 | 90 | AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF; |
a24be56b | 91 | Int_t strId=-1; |
d3a9c52a | 92 | |
a24be56b | 93 | Double_t sdx=0., sdy=0., sdz=0., sdpsi=0., sdtheta=0., sdphi=0.; |
6ca978d7 | 94 | //TRandom *rnds = new TRandom(4357); |
d3a9c52a | 95 | sigmatr = 0.1; // max shift in cm w.r.t. local ideal RS |
96 | ||
a24be56b | 97 | Int_t nstrA=15; |
98 | Int_t nstrB=19; | |
99 | Int_t nstrC=19; | |
100 | Int_t nSectors=18; | |
101 | Int_t nStrips=nstrA+2*nstrB+2*nstrC; | |
6876838b | 102 | Double_t cuty=0., cutz=0., cut=3*sigmatr; |
a24be56b | 103 | |
85ce4b22 | 104 | for (Int_t isect = 0; isect < nSectors; isect++) { |
a24be56b | 105 | for (Int_t istr = 1; istr <= nStrips; istr++) { |
6876838b | 106 | switch (istr) { |
107 | case 25: | |
108 | case 29: | |
109 | case 63: | |
110 | case 67: | |
111 | cuty = sigmatr*0.6; | |
6ca978d7 | 112 | sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); |
6876838b | 113 | sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut); |
114 | strId++; | |
115 | break; | |
116 | /* | |
117 | case 38: | |
118 | cuty = sigmatr*2.5; | |
119 | cutz = sigmatr*2.5; | |
6ca978d7 | 120 | sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); |
121 | sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut, cutz); | |
6876838b | 122 | strId++; |
123 | break; | |
124 | case 54: | |
125 | cuty = sigmatr*2.5; | |
126 | cutz = sigmatr*2.5; | |
6ca978d7 | 127 | sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut, cuty); |
128 | sdz = AliMathBase::TruncatedGaus(0., sigmatr, cutz, cut); | |
6876838b | 129 | strId++; |
130 | break; | |
131 | */ | |
132 | default: | |
133 | sdy = AliMathBase::TruncatedGaus(0., sigmatr, cut); | |
134 | sdz = AliMathBase::TruncatedGaus(0., sigmatr, cut); | |
135 | strId++; | |
136 | break; | |
137 | } | |
138 | ||
85ce4b22 | 139 | if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; |
85ce4b22 | 140 | new((*array)[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),AliGeomManager::LayerToVolUID(idTOF,strId), sdx, sdy, sdz, sdpsi, sdtheta, sdphi, kFALSE); |
a24be56b | 141 | } |
1895a097 | 142 | } |
143 | ||
a24be56b | 144 | if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){ |
6fce62af | 145 | // save in file |
dfe9c69d | 146 | const char* filename = "TOFfullMisalignment.root"; |
147 | TFile f(filename,"RECREATE"); | |
148 | if(!f){ | |
149 | Error(macroname,"cannot open file for output\n"); | |
150 | return; | |
151 | } | |
6fce62af | 152 | Info(macroname,"Saving alignment objects in file %s", filename); |
1895a097 | 153 | f.cd(); |
154 | f.WriteObject(array,"TOFAlignObjs","kSingleKey"); | |
155 | f.Close(); | |
156 | }else{ | |
157 | // save in CDB storage | |
dfe9c69d | 158 | Info(macroname,"Saving alignment objects in CDB storage %s", |
159 | Storage.Data()); | |
1895a097 | 160 | AliCDBMetaData* md = new AliCDBMetaData(); |
161 | md->SetResponsible("Silvia Arcelli"); | |
6fce62af | 162 | md->SetComment("Full misalignment for TOF"); |
5bd470e1 | 163 | md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); |
dfe9c69d | 164 | AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity()); |
1895a097 | 165 | storage->Put(array,id,md); |
166 | } | |
167 | ||
168 | array->Delete(); | |
169 | ||
170 | } | |
171 | ||
6ca978d7 | 172 | /* |
6876838b | 173 | Double_t LocalTruncatedGaus(Double_t mean, Double_t sigma, Double_t cutatL, Double_t cutatR) |
174 | { | |
175 | // return number generated according to a gaussian distribution N(mean,sigma) truncated at cutat | |
176 | // | |
177 | Double_t value; | |
178 | do{ | |
179 | value=gRandom->Gaus(mean,sigma); | |
180 | }while(value-mean<-cutatL || value-mean>cutatR); | |
181 | return value; | |
182 | } | |
6ca978d7 | 183 | */ |