]>
Commit | Line | Data |
---|---|---|
979b5a5f | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
e56160b8 | 15 | |
e7610d19 | 16 | /* $Id:$ */ |
5a9fd7dd | 17 | |
979b5a5f | 18 | /////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Implementation of the class for SDD preprocessing // | |
21 | // Origin: E.Crescio, Torino, crescio@to.infn.it // | |
22 | // F.Prino, Torino, prino@to.infn.it // | |
23 | // // | |
24 | /////////////////////////////////////////////////////////////////// | |
25 | ||
e56160b8 | 26 | #include "AliITSPreprocessorSDD.h" |
27 | #include "AliITSCalibrationSDD.h" | |
18da6e54 | 28 | #include "AliITSDriftSpeedSDD.h" |
29 | #include "AliITSDriftSpeedArraySDD.h" | |
cfaccd71 | 30 | #include "AliITSDCSAnalyzerSDD.h" |
e56160b8 | 31 | #include "AliShuttleInterface.h" |
979b5a5f | 32 | #include "AliCDBEntry.h" |
e56160b8 | 33 | #include "AliCDBMetaData.h" |
34 | #include "TObjArray.h" | |
e56160b8 | 35 | #include "AliLog.h" |
dfb8947f | 36 | #include <TObjString.h> |
37 | #include <TSystem.h> | |
38 | #include <TList.h> | |
e56160b8 | 39 | |
7537d03c | 40 | const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal"; |
41 | const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise"; | |
e56160b8 | 42 | ClassImp(AliITSPreprocessorSDD) |
43 | ||
44 | ||
317e638f | 45 | //______________________________________________________________________ |
cfaccd71 | 46 | UInt_t AliITSPreprocessorSDD::Process(TMap* dcsAliasMap){ |
e56160b8 | 47 | |
979b5a5f | 48 | // Get DDL map from OCDB |
49 | AliCDBEntry* entry = GetFromOCDB("Calib", "DDLMapSDD"); | |
50 | if(!entry){ | |
51 | Log("DDL map file not found in OCDB."); | |
52 | return 2; | |
53 | } | |
54 | AliITSDDLModuleMapSDD* ddlmap = (AliITSDDLModuleMapSDD*)entry->GetObject(); | |
55 | if(!ddlmap){ | |
56 | Log("AliITSDDLModuleMapSDD object not in file."); | |
57 | return 2; | |
58 | } | |
e56160b8 | 59 | |
979b5a5f | 60 | //preprocessing |
18da6e54 | 61 | TString runType = GetRunType(); |
62 | Bool_t retcode; | |
c2bd28b6 | 63 | |
ad2585ed | 64 | if (runType == "PULSER"){ |
317e638f | 65 | retcode=ProcessPulser(ddlmap); |
66 | }else if(runType== "INJECTOR"){ | |
67 | retcode=ProcessInjector(ddlmap); | |
68 | }else{ | |
69 | // do nothing for other run types | |
70 | retcode=1; | |
71 | } | |
72 | if(retcode){ | |
73 | Bool_t retcodedcs =ProcessDCSDataPoints(dcsAliasMap); | |
74 | if(retcodedcs) return 0; | |
75 | } | |
76 | return 1; | |
77 | } | |
78 | //______________________________________________________________________ | |
79 | Bool_t AliITSPreprocessorSDD::ProcessPulser(AliITSDDLModuleMapSDD* ddlmap){ | |
80 | // Process FXS files from PULSER run (baseline, noise, gain) | |
81 | TObjArray calSDD(kNumberOfSDD); | |
82 | calSDD.SetOwner(kFALSE); | |
83 | Char_t command[100]; | |
84 | Char_t inpFileName[100]; | |
85 | Float_t baseline,rawnoise,cmn,corn,gain; | |
86 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; | |
e7610d19 | 87 | Int_t th,tl; |
317e638f | 88 | Int_t numOfBadChannels[kNumberOfSDD]; |
18da6e54 | 89 | |
317e638f | 90 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); |
91 | if (!sourceList){ | |
92 | Log("Error: no sources found for SDD_Calib"); | |
93 | return 2; | |
94 | } | |
dfb8947f | 95 | |
317e638f | 96 | Int_t ind = 0; |
97 | while (sourceList->At(ind)!=NULL) { | |
98 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
99 | TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data()); | |
100 | if(tarName.Length()==0){ | |
101 | Log(Form("Baseline tar file from source %d not found.",ind)); | |
102 | return 2; | |
18da6e54 | 103 | } |
317e638f | 104 | sprintf(command,"tar -xf %s",tarName.Data()); |
105 | gSystem->Exec(command); | |
106 | ind++; | |
107 | } | |
108 | delete sourceList; | |
109 | ||
110 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
111 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
112 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
113 | if(modID==-1) continue; | |
114 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
115 | AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated"); | |
116 | numOfBadChannels[modID]=0; | |
117 | Int_t badch[kNumberOfChannels]; | |
118 | for(Int_t isid=0;isid<=1;isid++){ | |
119 | sprintf(inpFileName,"./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
120 | FILE* basFil = fopen(inpFileName,"read"); | |
121 | if (basFil == 0) { | |
122 | Log(Form("File %s not found.",inpFileName)); | |
123 | cal->SetBad(); | |
124 | continue; | |
125 | } | |
126 | fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod); | |
e7610d19 | 127 | fscanf(basFil,"%d\n",&th); |
128 | fscanf(basFil,"%d\n",&tl); | |
317e638f | 129 | if(!isgoodmod) cal->SetBad(); |
130 | for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){ | |
131 | fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain); | |
132 | Int_t ich=ian; | |
133 | if(isid==1) ich+=256; | |
134 | if(!isgoodan){ | |
135 | Int_t ibad=numOfBadChannels[modID]; | |
136 | badch[ibad]=ich; | |
137 | numOfBadChannels[modID]++; | |
979b5a5f | 138 | } |
317e638f | 139 | cal->SetBaseline(ich,baseline); |
140 | cal->SetNoiseAfterElectronics(ich,rawnoise); | |
141 | cal->SetGain(ich,gain); | |
979b5a5f | 142 | } |
317e638f | 143 | cal->SetDeadChannels(numOfBadChannels[modID]); |
144 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
145 | cal->SetBadChannel(ibad,badch[ibad]); | |
146 | } | |
147 | fclose(basFil); | |
c2bd28b6 | 148 | } |
317e638f | 149 | calSDD.AddAt(cal,modID); |
e56160b8 | 150 | } |
317e638f | 151 | } |
152 | AliCDBMetaData *md= new AliCDBMetaData(); | |
153 | md->SetResponsible("Francesco Prino"); | |
154 | md->SetBeamPeriod(0); | |
155 | md->SetComment("AliITSCalibrationSDD from PEDESTAL+PULSER runs"); | |
156 | Bool_t retCode = Store("Calib","CalibSDD",&calSDD,md, 0, kTRUE); | |
157 | return retCode; | |
158 | } | |
159 | //______________________________________________________________________ | |
160 | Bool_t AliITSPreprocessorSDD::ProcessInjector(AliITSDDLModuleMapSDD* ddlmap){ | |
161 | // Process FXS files from injector events (INJECTOR or PHYSICS runs) | |
162 | TObjArray vdrift(2*kNumberOfSDD); | |
163 | vdrift.SetOwner(kFALSE); | |
164 | Char_t command[100]; | |
165 | Char_t inpFileName[100]; | |
166 | Int_t evNumb,polDeg; | |
167 | UInt_t timeStamp; | |
168 | Float_t param[4]; | |
e56160b8 | 169 | |
317e638f | 170 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); |
171 | if (!sourceList){ | |
172 | Log("Error: no sources found for SDD_Injec"); | |
173 | return 2; | |
174 | } | |
175 | Int_t ind = 0; | |
176 | while (sourceList->At(ind)!=NULL) { | |
177 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
178 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
179 | if(tarName.Length()==0){ | |
180 | Log(Form("Injector tar file from source %d not found.",ind)); | |
18da6e54 | 181 | return 2; |
182 | } | |
317e638f | 183 | sprintf(command,"tar -xf %s",tarName.Data()); |
184 | gSystem->Exec(command); | |
185 | ind++; | |
186 | } | |
187 | delete sourceList; | |
188 | ||
189 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
190 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
191 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
192 | if(modID==-1) continue; | |
193 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
194 | for(Int_t isid=0;isid<=1;isid++){ | |
195 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
196 | sprintf(inpFileName,"./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
197 | FILE* injFil = fopen(inpFileName,"read"); | |
198 | if (injFil == 0) { | |
199 | Log(Form("File %s not found.",inpFileName)); | |
200 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(); | |
201 | arr->AddDriftSpeed(dsp); | |
979b5a5f | 202 | vdrift.AddAt(arr,2*modID+isid); |
317e638f | 203 | continue; |
204 | } | |
205 | fscanf(injFil,"%d",&polDeg); | |
206 | while (!feof(injFil)){ | |
207 | fscanf(injFil,"%d %d",&evNumb,&timeStamp); | |
208 | if(feof(injFil)) break; | |
209 | for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",¶m[ic]); | |
210 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
211 | arr->AddDriftSpeed(dsp); | |
18da6e54 | 212 | } |
317e638f | 213 | vdrift.AddAt(arr,2*modID+isid); |
18da6e54 | 214 | } |
215 | } | |
cfaccd71 | 216 | } |
317e638f | 217 | AliCDBMetaData *md= new AliCDBMetaData(); |
218 | md->SetResponsible("Francesco Prino"); | |
219 | md->SetBeamPeriod(0); | |
220 | md->SetComment("AliITSDriftSpeedSDD from injector events"); | |
221 | Bool_t retCode = Store("Calib","DriftSpeedSDD",&vdrift,md,0, kTRUE); | |
222 | return retCode; | |
223 | } | |
224 | //______________________________________________________________________ | |
225 | Bool_t AliITSPreprocessorSDD::ProcessDCSDataPoints(TMap* dcsAliasMap){ | |
226 | // Process DCS data | |
227 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
228 | dcs->AnalyzeData(dcsAliasMap); | |
229 | TObjArray refDCS(kNumberOfSDD); | |
230 | refDCS.SetOwner(kFALSE); | |
231 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ | |
232 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); | |
233 | refDCS.Add(dcsdata); | |
234 | } | |
235 | AliCDBMetaData *md= new AliCDBMetaData(); | |
236 | md->SetResponsible("Francesco Prino"); | |
237 | md->SetBeamPeriod(0); | |
238 | md->SetComment("AliITSDCSDataSDD objects from DCS DB"); | |
239 | Bool_t retCode = StoreReferenceData("DCS","DataSDD",&refDCS,md); | |
240 | return retCode; | |
e56160b8 | 241 | } |