]>
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 | |
20f3f947 | 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" |
5e6e7c0c | 31 | #include "AliITSHLTforSDD.h" |
e56160b8 | 32 | #include "AliShuttleInterface.h" |
979b5a5f | 33 | #include "AliCDBEntry.h" |
e56160b8 | 34 | #include "AliCDBMetaData.h" |
35 | #include "TObjArray.h" | |
e56160b8 | 36 | #include "AliLog.h" |
dfb8947f | 37 | #include <TObjString.h> |
38 | #include <TSystem.h> | |
39 | #include <TList.h> | |
e56160b8 | 40 | |
7537d03c | 41 | const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal"; |
42 | const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise"; | |
e56160b8 | 43 | ClassImp(AliITSPreprocessorSDD) |
44 | ||
15b67cdc | 45 | //______________________________________________________________________ |
46 | AliITSPreprocessorSDD::AliITSPreprocessorSDD( AliShuttleInterface* shuttle): | |
47 | AliPreprocessor("SDD", shuttle) | |
48 | { | |
49 | // constructor | |
50 | AddRunType("PULSER"); | |
51 | AddRunType("INJECTOR"); | |
52 | AddRunType("PHYSICS"); | |
53 | } | |
e56160b8 | 54 | |
317e638f | 55 | //______________________________________________________________________ |
cfaccd71 | 56 | UInt_t AliITSPreprocessorSDD::Process(TMap* dcsAliasMap){ |
e56160b8 | 57 | |
7d21c0a9 | 58 | |
979b5a5f | 59 | // Get DDL map from OCDB |
60 | AliCDBEntry* entry = GetFromOCDB("Calib", "DDLMapSDD"); | |
61 | if(!entry){ | |
62 | Log("DDL map file not found in OCDB."); | |
63 | return 2; | |
64 | } | |
65 | AliITSDDLModuleMapSDD* ddlmap = (AliITSDDLModuleMapSDD*)entry->GetObject(); | |
66 | if(!ddlmap){ | |
67 | Log("AliITSDDLModuleMapSDD object not in file."); | |
68 | return 2; | |
69 | } | |
b478db1a | 70 | ddlmap->PrintDDLMap(); |
e56160b8 | 71 | |
979b5a5f | 72 | //preprocessing |
18da6e54 | 73 | TString runType = GetRunType(); |
461c9263 | 74 | Int_t retcode=0; |
c2bd28b6 | 75 | |
ad2585ed | 76 | if (runType == "PULSER"){ |
b478db1a | 77 | Log("Process FXS files from PULSER RUN"); |
317e638f | 78 | retcode=ProcessPulser(ddlmap); |
79 | }else if(runType== "INJECTOR"){ | |
b478db1a | 80 | Log("Process FXS files from INJECTOR RUN"); |
317e638f | 81 | retcode=ProcessInjector(ddlmap); |
5e6e7c0c | 82 | }else if(runType== "PHYSICS"){ |
83 | retcode=ProcessPhysics(); | |
317e638f | 84 | } |
461c9263 | 85 | if(retcode!=0) return retcode; |
86 | ||
b478db1a | 87 | Log("Process DCS data"); |
461c9263 | 88 | Bool_t retcodedcs =ProcessDCSDataPoints(dcsAliasMap); |
89 | if(retcodedcs) return 0; | |
90 | else return 1; | |
91 | ||
317e638f | 92 | } |
93 | //______________________________________________________________________ | |
5e6e7c0c | 94 | UInt_t AliITSPreprocessorSDD::ProcessPhysics(){ |
95 | // Get the HLT status for the PHYSICS run | |
96 | // needeed to define the raw data format | |
97 | ||
98 | AliITSHLTforSDD *hltSDD=new AliITSHLTforSDD(); | |
99 | TString hltMode = GetRunParameter("HLTmode"); | |
100 | TSubString firstChar = hltMode(0,1); | |
101 | if (firstChar == "C") hltSDD->SetHLTmodeC(kTRUE); | |
102 | else hltSDD->SetHLTmodeC(kFALSE); | |
103 | ||
104 | AliCDBMetaData *md= new AliCDBMetaData(); | |
105 | md->SetResponsible("Francesco Prino"); | |
106 | md->SetBeamPeriod(0); | |
107 | md->SetComment("HLT mode C flag for PHYSICS run"); | |
108 | Bool_t retCode = Store("Calib","HLTforSDD",hltSDD,md); | |
109 | if(retCode) return 0; | |
110 | else return 1; | |
111 | } | |
112 | //______________________________________________________________________ | |
461c9263 | 113 | UInt_t AliITSPreprocessorSDD::ProcessPulser(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 114 | // Process FXS files from PULSER run (baseline, noise, gain) |
461c9263 | 115 | // returns 0 in case of success, |
116 | // 1 in case of storage error, | |
117 | // 2 in case of error with input files | |
317e638f | 118 | TObjArray calSDD(kNumberOfSDD); |
119 | calSDD.SetOwner(kFALSE); | |
7d21c0a9 | 120 | |
317e638f | 121 | Float_t baseline,rawnoise,cmn,corn,gain; |
122 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; | |
e7610d19 | 123 | Int_t th,tl; |
317e638f | 124 | Int_t numOfBadChannels[kNumberOfSDD]; |
18da6e54 | 125 | |
317e638f | 126 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); |
127 | if (!sourceList){ | |
128 | Log("Error: no sources found for SDD_Calib"); | |
129 | return 2; | |
130 | } | |
dfb8947f | 131 | |
317e638f | 132 | Int_t ind = 0; |
133 | while (sourceList->At(ind)!=NULL) { | |
134 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
135 | TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data()); | |
136 | if(tarName.Length()==0){ | |
137 | Log(Form("Baseline tar file from source %d not found.",ind)); | |
138 | return 2; | |
18da6e54 | 139 | } |
7d21c0a9 | 140 | TString command; |
141 | command.Form("tar -xf %s",tarName.Data()); | |
317e638f | 142 | gSystem->Exec(command); |
143 | ind++; | |
144 | } | |
145 | delete sourceList; | |
146 | ||
147 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
148 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
149 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
150 | if(modID==-1) continue; | |
151 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
152 | AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated"); | |
9f963593 | 153 | cal->SetUseCorrectionMaps(0,0); // temporary disabling of maps |
2140af73 | 154 | cal->SetAMAt20MHz(); // for runs > 51275 with clock at 20 MHz |
317e638f | 155 | numOfBadChannels[modID]=0; |
156 | Int_t badch[kNumberOfChannels]; | |
157 | for(Int_t isid=0;isid<=1;isid++){ | |
7d21c0a9 | 158 | TString inpFileName; |
159 | inpFileName.Form("./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
160 | ||
317e638f | 161 | FILE* basFil = fopen(inpFileName,"read"); |
162 | if (basFil == 0) { | |
7d21c0a9 | 163 | Log(Form("File %s not found.",inpFileName.Data())); |
317e638f | 164 | cal->SetBad(); |
165 | continue; | |
166 | } | |
167 | fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod); | |
20f3f947 | 168 | if(!isgoodmod) cal->SetBad(); |
e7610d19 | 169 | fscanf(basFil,"%d\n",&th); |
170 | fscanf(basFil,"%d\n",&tl); | |
20f3f947 | 171 | cal->SetZSLowThreshold(isid,tl); |
172 | cal->SetZSHighThreshold(isid,th); | |
317e638f | 173 | for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){ |
174 | fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain); | |
175 | Int_t ich=ian; | |
176 | if(isid==1) ich+=256; | |
177 | if(!isgoodan){ | |
178 | Int_t ibad=numOfBadChannels[modID]; | |
179 | badch[ibad]=ich; | |
180 | numOfBadChannels[modID]++; | |
979b5a5f | 181 | } |
20f3f947 | 182 | cal->SetBaseline(ich,baseline-basoff); |
317e638f | 183 | cal->SetNoiseAfterElectronics(ich,rawnoise); |
184 | cal->SetGain(ich,gain); | |
979b5a5f | 185 | } |
317e638f | 186 | cal->SetDeadChannels(numOfBadChannels[modID]); |
187 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
188 | cal->SetBadChannel(ibad,badch[ibad]); | |
189 | } | |
190 | fclose(basFil); | |
c2bd28b6 | 191 | } |
b478db1a | 192 | Log(Form("Put calib obj for module %d (DDL %d Carlos %d)",modID,iddl,imod)); |
317e638f | 193 | calSDD.AddAt(cal,modID); |
e56160b8 | 194 | } |
317e638f | 195 | } |
196 | AliCDBMetaData *md= new AliCDBMetaData(); | |
197 | md->SetResponsible("Francesco Prino"); | |
198 | md->SetBeamPeriod(0); | |
199 | md->SetComment("AliITSCalibrationSDD from PEDESTAL+PULSER runs"); | |
200 | Bool_t retCode = Store("Calib","CalibSDD",&calSDD,md, 0, kTRUE); | |
461c9263 | 201 | if(retCode) return 0; |
202 | else return 1; | |
317e638f | 203 | } |
204 | //______________________________________________________________________ | |
461c9263 | 205 | UInt_t AliITSPreprocessorSDD::ProcessInjector(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 206 | // Process FXS files from injector events (INJECTOR or PHYSICS runs) |
461c9263 | 207 | // returns 0 in case of success, |
208 | // 1 in case of storage error, | |
209 | // 2 in case of error with input files | |
317e638f | 210 | TObjArray vdrift(2*kNumberOfSDD); |
211 | vdrift.SetOwner(kFALSE); | |
317e638f | 212 | Int_t evNumb,polDeg; |
213 | UInt_t timeStamp; | |
9f963593 | 214 | Bool_t modSet[2*kNumberOfSDD]; // flag modules with good inj. |
5eb2b05e | 215 | for(Int_t ihyb=0; ihyb<2*kNumberOfSDD; ihyb++) modSet[ihyb]=0; |
9f963593 | 216 | Double_t nPt = 0; |
217 | ||
218 | Double_t param[4]; // parameters of poly fit | |
219 | Double_t minValP0=4.; // min value for param[0] | |
220 | Double_t maxValP0=9.; // max value for param[0] | |
221 | Double_t minValP1=0.; // min value for param[1] | |
222 | Double_t aveCoef[4]={0.,0.,0.,0.}; // average param for good mod. | |
223 | Double_t defCoef[4]={6.53227,0.00128941,-5.14493e-06,0}; // default values for param | |
224 | Float_t auxP; | |
e56160b8 | 225 | |
317e638f | 226 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); |
227 | if (!sourceList){ | |
228 | Log("Error: no sources found for SDD_Injec"); | |
229 | return 2; | |
230 | } | |
231 | Int_t ind = 0; | |
232 | while (sourceList->At(ind)!=NULL) { | |
233 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
234 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
235 | if(tarName.Length()==0){ | |
236 | Log(Form("Injector tar file from source %d not found.",ind)); | |
18da6e54 | 237 | return 2; |
238 | } | |
7d21c0a9 | 239 | TString command; |
240 | command.Form("tar -xf %s",tarName.Data()); | |
317e638f | 241 | gSystem->Exec(command); |
242 | ind++; | |
243 | } | |
244 | delete sourceList; | |
9f963593 | 245 | |
246 | ||
317e638f | 247 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ |
248 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
249 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
250 | if(modID==-1) continue; | |
251 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
252 | for(Int_t isid=0;isid<=1;isid++){ | |
253 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
7d21c0a9 | 254 | TString inpFileName; |
255 | inpFileName.Form("./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
317e638f | 256 | FILE* injFil = fopen(inpFileName,"read"); |
257 | if (injFil == 0) { | |
7d21c0a9 | 258 | Log(Form("File %s not found.",inpFileName.Data())); |
317e638f | 259 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(); |
260 | arr->AddDriftSpeed(dsp); | |
979b5a5f | 261 | vdrift.AddAt(arr,2*modID+isid); |
317e638f | 262 | continue; |
263 | } | |
264 | fscanf(injFil,"%d",&polDeg); | |
265 | while (!feof(injFil)){ | |
938494b4 | 266 | fscanf(injFil,"%d %u ",&evNumb,&timeStamp); |
317e638f | 267 | if(feof(injFil)) break; |
9f963593 | 268 | for(Int_t ic=0;ic<4;ic++){ |
269 | fscanf(injFil,"%f ",&auxP); | |
270 | param[ic]=auxP; | |
271 | } | |
272 | ||
273 | if(param[0]>minValP0 && param[0]<maxValP0 && param[1]>minValP1){ | |
274 | for(Int_t ic=0;ic<4;ic++) aveCoef[ic]+=param[ic]; | |
275 | nPt++; | |
276 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
277 | arr->AddDriftSpeed(dsp); | |
278 | modSet[2*modID+isid]=1; | |
279 | } | |
18da6e54 | 280 | } |
b478db1a | 281 | Log(Form("Put calib obj for hybrid %d (DDL %d Carlos %d)",2*modID+isid,iddl,imod)); |
9f963593 | 282 | if(modSet[2*modID+isid]) vdrift.AddAt(arr,2*modID+isid); |
18da6e54 | 283 | } |
284 | } | |
cfaccd71 | 285 | } |
9f963593 | 286 | |
287 | // set drift speed for modules with bad injectors | |
288 | for(Int_t ic=0;ic<4;ic++){ | |
289 | if(nPt>0) aveCoef[ic]/=nPt; // mean parameters | |
290 | else aveCoef[ic]=defCoef[ic]; // default parameters | |
291 | } | |
292 | AliITSDriftSpeedSDD *avdsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,aveCoef); | |
293 | ||
294 | for(Int_t ihyb=0; ihyb<2*kNumberOfSDD; ihyb++){ | |
295 | if(modSet[ihyb]==0){ | |
296 | AliWarning(Form("No good injector events for mod. %d --> use average values",ihyb/2)); | |
297 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
298 | arr->AddDriftSpeed(avdsp); | |
299 | vdrift.AddAt(arr,ihyb); | |
300 | } | |
301 | } | |
302 | ||
303 | ||
317e638f | 304 | AliCDBMetaData *md= new AliCDBMetaData(); |
305 | md->SetResponsible("Francesco Prino"); | |
306 | md->SetBeamPeriod(0); | |
307 | md->SetComment("AliITSDriftSpeedSDD from injector events"); | |
308 | Bool_t retCode = Store("Calib","DriftSpeedSDD",&vdrift,md,0, kTRUE); | |
461c9263 | 309 | if(retCode) return 0; |
310 | else return 1; | |
317e638f | 311 | } |
312 | //______________________________________________________________________ | |
313 | Bool_t AliITSPreprocessorSDD::ProcessDCSDataPoints(TMap* dcsAliasMap){ | |
314 | // Process DCS data | |
315 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
316 | dcs->AnalyzeData(dcsAliasMap); | |
317 | TObjArray refDCS(kNumberOfSDD); | |
318 | refDCS.SetOwner(kFALSE); | |
319 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ | |
320 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); | |
321 | refDCS.Add(dcsdata); | |
322 | } | |
323 | AliCDBMetaData *md= new AliCDBMetaData(); | |
324 | md->SetResponsible("Francesco Prino"); | |
325 | md->SetBeamPeriod(0); | |
326 | md->SetComment("AliITSDCSDataSDD objects from DCS DB"); | |
327 | Bool_t retCode = StoreReferenceData("DCS","DataSDD",&refDCS,md); | |
328 | return retCode; | |
e56160b8 | 329 | } |
5eb2b05e | 330 |