]>
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); |
317e638f | 82 | } |
461c9263 | 83 | if(retcode!=0) return retcode; |
84 | ||
b478db1a | 85 | Log("Process DCS data"); |
461c9263 | 86 | Bool_t retcodedcs =ProcessDCSDataPoints(dcsAliasMap); |
87 | if(retcodedcs) return 0; | |
88 | else return 1; | |
89 | ||
317e638f | 90 | } |
91 | //______________________________________________________________________ | |
461c9263 | 92 | UInt_t AliITSPreprocessorSDD::ProcessPulser(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 93 | // Process FXS files from PULSER run (baseline, noise, gain) |
461c9263 | 94 | // returns 0 in case of success, |
95 | // 1 in case of storage error, | |
96 | // 2 in case of error with input files | |
317e638f | 97 | TObjArray calSDD(kNumberOfSDD); |
98 | calSDD.SetOwner(kFALSE); | |
7d21c0a9 | 99 | |
317e638f | 100 | Float_t baseline,rawnoise,cmn,corn,gain; |
101 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; | |
e7610d19 | 102 | Int_t th,tl; |
317e638f | 103 | Int_t numOfBadChannels[kNumberOfSDD]; |
18da6e54 | 104 | |
317e638f | 105 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); |
106 | if (!sourceList){ | |
107 | Log("Error: no sources found for SDD_Calib"); | |
108 | return 2; | |
109 | } | |
dfb8947f | 110 | |
317e638f | 111 | Int_t ind = 0; |
112 | while (sourceList->At(ind)!=NULL) { | |
113 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
114 | TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data()); | |
115 | if(tarName.Length()==0){ | |
116 | Log(Form("Baseline tar file from source %d not found.",ind)); | |
117 | return 2; | |
18da6e54 | 118 | } |
7d21c0a9 | 119 | TString command; |
120 | command.Form("tar -xf %s",tarName.Data()); | |
317e638f | 121 | gSystem->Exec(command); |
122 | ind++; | |
123 | } | |
124 | delete sourceList; | |
27416b0d | 125 | // Read ADC sampling frequency from fee.conf |
126 | Int_t amSamplFreq=40; | |
127 | FILE* feefil=fopen("fee.conf","r"); | |
128 | if(feefil){ | |
129 | fscanf(feefil,"%d \n",&amSamplFreq); | |
130 | fclose(feefil); | |
131 | Log(Form("AM sampling frequency = %d MHz",amSamplFreq)); | |
132 | }else{ | |
133 | Log("File fee.conf not found. AM sampling set at 40 MHz by default"); | |
134 | } | |
317e638f | 135 | |
136 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
137 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
138 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
139 | if(modID==-1) continue; | |
140 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
141 | AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated"); | |
27416b0d | 142 | if(amSamplFreq!=40) cal->SetAMAt20MHz(); |
317e638f | 143 | numOfBadChannels[modID]=0; |
144 | Int_t badch[kNumberOfChannels]; | |
145 | for(Int_t isid=0;isid<=1;isid++){ | |
7d21c0a9 | 146 | TString inpFileName; |
147 | inpFileName.Form("./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
148 | ||
317e638f | 149 | FILE* basFil = fopen(inpFileName,"read"); |
150 | if (basFil == 0) { | |
7d21c0a9 | 151 | Log(Form("File %s not found.",inpFileName.Data())); |
317e638f | 152 | cal->SetBad(); |
153 | continue; | |
154 | } | |
155 | fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod); | |
20f3f947 | 156 | if(!isgoodmod) cal->SetBad(); |
e7610d19 | 157 | fscanf(basFil,"%d\n",&th); |
158 | fscanf(basFil,"%d\n",&tl); | |
20f3f947 | 159 | cal->SetZSLowThreshold(isid,tl); |
160 | cal->SetZSHighThreshold(isid,th); | |
317e638f | 161 | for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){ |
162 | fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain); | |
163 | Int_t ich=ian; | |
164 | if(isid==1) ich+=256; | |
165 | if(!isgoodan){ | |
166 | Int_t ibad=numOfBadChannels[modID]; | |
167 | badch[ibad]=ich; | |
168 | numOfBadChannels[modID]++; | |
979b5a5f | 169 | } |
20f3f947 | 170 | cal->SetBaseline(ich,baseline-basoff); |
317e638f | 171 | cal->SetNoiseAfterElectronics(ich,rawnoise); |
172 | cal->SetGain(ich,gain); | |
979b5a5f | 173 | } |
317e638f | 174 | cal->SetDeadChannels(numOfBadChannels[modID]); |
175 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
176 | cal->SetBadChannel(ibad,badch[ibad]); | |
177 | } | |
178 | fclose(basFil); | |
c2bd28b6 | 179 | } |
b478db1a | 180 | Log(Form("Put calib obj for module %d (DDL %d Carlos %d)",modID,iddl,imod)); |
317e638f | 181 | calSDD.AddAt(cal,modID); |
e56160b8 | 182 | } |
317e638f | 183 | } |
184 | AliCDBMetaData *md= new AliCDBMetaData(); | |
185 | md->SetResponsible("Francesco Prino"); | |
186 | md->SetBeamPeriod(0); | |
187 | md->SetComment("AliITSCalibrationSDD from PEDESTAL+PULSER runs"); | |
188 | Bool_t retCode = Store("Calib","CalibSDD",&calSDD,md, 0, kTRUE); | |
461c9263 | 189 | if(retCode) return 0; |
190 | else return 1; | |
317e638f | 191 | } |
192 | //______________________________________________________________________ | |
461c9263 | 193 | UInt_t AliITSPreprocessorSDD::ProcessInjector(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 194 | // Process FXS files from injector events (INJECTOR or PHYSICS runs) |
461c9263 | 195 | // returns 0 in case of success, |
196 | // 1 in case of storage error, | |
197 | // 2 in case of error with input files | |
317e638f | 198 | TObjArray vdrift(2*kNumberOfSDD); |
199 | vdrift.SetOwner(kFALSE); | |
317e638f | 200 | Int_t evNumb,polDeg; |
201 | UInt_t timeStamp; | |
9f963593 | 202 | Bool_t modSet[2*kNumberOfSDD]; // flag modules with good inj. |
5eb2b05e | 203 | for(Int_t ihyb=0; ihyb<2*kNumberOfSDD; ihyb++) modSet[ihyb]=0; |
9f963593 | 204 | Double_t nPt = 0; |
205 | ||
206 | Double_t param[4]; // parameters of poly fit | |
207 | Double_t minValP0=4.; // min value for param[0] | |
208 | Double_t maxValP0=9.; // max value for param[0] | |
209 | Double_t minValP1=0.; // min value for param[1] | |
210 | Double_t aveCoef[4]={0.,0.,0.,0.}; // average param for good mod. | |
211 | Double_t defCoef[4]={6.53227,0.00128941,-5.14493e-06,0}; // default values for param | |
212 | Float_t auxP; | |
e56160b8 | 213 | |
317e638f | 214 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); |
215 | if (!sourceList){ | |
216 | Log("Error: no sources found for SDD_Injec"); | |
217 | return 2; | |
218 | } | |
219 | Int_t ind = 0; | |
220 | while (sourceList->At(ind)!=NULL) { | |
221 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
222 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
223 | if(tarName.Length()==0){ | |
224 | Log(Form("Injector tar file from source %d not found.",ind)); | |
18da6e54 | 225 | return 2; |
226 | } | |
7d21c0a9 | 227 | TString command; |
228 | command.Form("tar -xf %s",tarName.Data()); | |
317e638f | 229 | gSystem->Exec(command); |
230 | ind++; | |
231 | } | |
232 | delete sourceList; | |
9f963593 | 233 | |
234 | ||
317e638f | 235 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ |
236 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
237 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
238 | if(modID==-1) continue; | |
239 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
240 | for(Int_t isid=0;isid<=1;isid++){ | |
241 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
7d21c0a9 | 242 | TString inpFileName; |
243 | inpFileName.Form("./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
317e638f | 244 | FILE* injFil = fopen(inpFileName,"read"); |
245 | if (injFil == 0) { | |
7d21c0a9 | 246 | Log(Form("File %s not found.",inpFileName.Data())); |
317e638f | 247 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(); |
248 | arr->AddDriftSpeed(dsp); | |
979b5a5f | 249 | vdrift.AddAt(arr,2*modID+isid); |
317e638f | 250 | continue; |
251 | } | |
252 | fscanf(injFil,"%d",&polDeg); | |
253 | while (!feof(injFil)){ | |
938494b4 | 254 | fscanf(injFil,"%d %u ",&evNumb,&timeStamp); |
317e638f | 255 | if(feof(injFil)) break; |
9f963593 | 256 | for(Int_t ic=0;ic<4;ic++){ |
257 | fscanf(injFil,"%f ",&auxP); | |
258 | param[ic]=auxP; | |
259 | } | |
260 | ||
261 | if(param[0]>minValP0 && param[0]<maxValP0 && param[1]>minValP1){ | |
262 | for(Int_t ic=0;ic<4;ic++) aveCoef[ic]+=param[ic]; | |
263 | nPt++; | |
264 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
265 | arr->AddDriftSpeed(dsp); | |
266 | modSet[2*modID+isid]=1; | |
267 | } | |
18da6e54 | 268 | } |
9ebc7917 | 269 | fclose(injFil); |
b478db1a | 270 | Log(Form("Put calib obj for hybrid %d (DDL %d Carlos %d)",2*modID+isid,iddl,imod)); |
9f963593 | 271 | if(modSet[2*modID+isid]) vdrift.AddAt(arr,2*modID+isid); |
18da6e54 | 272 | } |
273 | } | |
cfaccd71 | 274 | } |
9f963593 | 275 | |
276 | // set drift speed for modules with bad injectors | |
277 | for(Int_t ic=0;ic<4;ic++){ | |
278 | if(nPt>0) aveCoef[ic]/=nPt; // mean parameters | |
279 | else aveCoef[ic]=defCoef[ic]; // default parameters | |
280 | } | |
281 | AliITSDriftSpeedSDD *avdsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,aveCoef); | |
282 | ||
283 | for(Int_t ihyb=0; ihyb<2*kNumberOfSDD; ihyb++){ | |
284 | if(modSet[ihyb]==0){ | |
285 | AliWarning(Form("No good injector events for mod. %d --> use average values",ihyb/2)); | |
286 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
287 | arr->AddDriftSpeed(avdsp); | |
288 | vdrift.AddAt(arr,ihyb); | |
289 | } | |
290 | } | |
291 | ||
292 | ||
317e638f | 293 | AliCDBMetaData *md= new AliCDBMetaData(); |
294 | md->SetResponsible("Francesco Prino"); | |
295 | md->SetBeamPeriod(0); | |
296 | md->SetComment("AliITSDriftSpeedSDD from injector events"); | |
297 | Bool_t retCode = Store("Calib","DriftSpeedSDD",&vdrift,md,0, kTRUE); | |
461c9263 | 298 | if(retCode) return 0; |
299 | else return 1; | |
317e638f | 300 | } |
301 | //______________________________________________________________________ | |
302 | Bool_t AliITSPreprocessorSDD::ProcessDCSDataPoints(TMap* dcsAliasMap){ | |
303 | // Process DCS data | |
304 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
305 | dcs->AnalyzeData(dcsAliasMap); | |
306 | TObjArray refDCS(kNumberOfSDD); | |
307 | refDCS.SetOwner(kFALSE); | |
308 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ | |
309 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); | |
310 | refDCS.Add(dcsdata); | |
311 | } | |
312 | AliCDBMetaData *md= new AliCDBMetaData(); | |
313 | md->SetResponsible("Francesco Prino"); | |
314 | md->SetBeamPeriod(0); | |
315 | md->SetComment("AliITSDCSDataSDD objects from DCS DB"); | |
316 | Bool_t retCode = StoreReferenceData("DCS","DataSDD",&refDCS,md); | |
317 | return retCode; | |
e56160b8 | 318 | } |
5eb2b05e | 319 |