]>
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" |
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 | ||
15b67cdc | 44 | //______________________________________________________________________ |
45 | AliITSPreprocessorSDD::AliITSPreprocessorSDD( AliShuttleInterface* shuttle): | |
46 | AliPreprocessor("SDD", shuttle) | |
47 | { | |
48 | // constructor | |
49 | AddRunType("PULSER"); | |
50 | AddRunType("INJECTOR"); | |
51 | AddRunType("PHYSICS"); | |
52 | } | |
e56160b8 | 53 | |
317e638f | 54 | //______________________________________________________________________ |
cfaccd71 | 55 | UInt_t AliITSPreprocessorSDD::Process(TMap* dcsAliasMap){ |
e56160b8 | 56 | |
979b5a5f | 57 | // Get DDL map from OCDB |
58 | AliCDBEntry* entry = GetFromOCDB("Calib", "DDLMapSDD"); | |
59 | if(!entry){ | |
60 | Log("DDL map file not found in OCDB."); | |
61 | return 2; | |
62 | } | |
63 | AliITSDDLModuleMapSDD* ddlmap = (AliITSDDLModuleMapSDD*)entry->GetObject(); | |
64 | if(!ddlmap){ | |
65 | Log("AliITSDDLModuleMapSDD object not in file."); | |
66 | return 2; | |
67 | } | |
e56160b8 | 68 | |
979b5a5f | 69 | //preprocessing |
18da6e54 | 70 | TString runType = GetRunType(); |
461c9263 | 71 | Int_t retcode=0; |
c2bd28b6 | 72 | |
ad2585ed | 73 | if (runType == "PULSER"){ |
317e638f | 74 | retcode=ProcessPulser(ddlmap); |
75 | }else if(runType== "INJECTOR"){ | |
76 | retcode=ProcessInjector(ddlmap); | |
317e638f | 77 | } |
461c9263 | 78 | if(retcode!=0) return retcode; |
79 | ||
80 | Bool_t retcodedcs =ProcessDCSDataPoints(dcsAliasMap); | |
81 | if(retcodedcs) return 0; | |
82 | else return 1; | |
83 | ||
317e638f | 84 | } |
85 | //______________________________________________________________________ | |
461c9263 | 86 | UInt_t AliITSPreprocessorSDD::ProcessPulser(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 87 | // Process FXS files from PULSER run (baseline, noise, gain) |
461c9263 | 88 | // returns 0 in case of success, |
89 | // 1 in case of storage error, | |
90 | // 2 in case of error with input files | |
317e638f | 91 | TObjArray calSDD(kNumberOfSDD); |
92 | calSDD.SetOwner(kFALSE); | |
93 | Char_t command[100]; | |
94 | Char_t inpFileName[100]; | |
95 | Float_t baseline,rawnoise,cmn,corn,gain; | |
96 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; | |
e7610d19 | 97 | Int_t th,tl; |
317e638f | 98 | Int_t numOfBadChannels[kNumberOfSDD]; |
18da6e54 | 99 | |
317e638f | 100 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); |
101 | if (!sourceList){ | |
102 | Log("Error: no sources found for SDD_Calib"); | |
103 | return 2; | |
104 | } | |
dfb8947f | 105 | |
317e638f | 106 | Int_t ind = 0; |
107 | while (sourceList->At(ind)!=NULL) { | |
108 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
109 | TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data()); | |
110 | if(tarName.Length()==0){ | |
111 | Log(Form("Baseline tar file from source %d not found.",ind)); | |
112 | return 2; | |
18da6e54 | 113 | } |
317e638f | 114 | sprintf(command,"tar -xf %s",tarName.Data()); |
115 | gSystem->Exec(command); | |
116 | ind++; | |
117 | } | |
118 | delete sourceList; | |
119 | ||
120 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
121 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
122 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
123 | if(modID==-1) continue; | |
124 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
125 | AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated"); | |
126 | numOfBadChannels[modID]=0; | |
127 | Int_t badch[kNumberOfChannels]; | |
128 | for(Int_t isid=0;isid<=1;isid++){ | |
129 | sprintf(inpFileName,"./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
130 | FILE* basFil = fopen(inpFileName,"read"); | |
131 | if (basFil == 0) { | |
132 | Log(Form("File %s not found.",inpFileName)); | |
133 | cal->SetBad(); | |
134 | continue; | |
135 | } | |
136 | fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod); | |
20f3f947 | 137 | if(!isgoodmod) cal->SetBad(); |
e7610d19 | 138 | fscanf(basFil,"%d\n",&th); |
139 | fscanf(basFil,"%d\n",&tl); | |
20f3f947 | 140 | cal->SetZSLowThreshold(isid,tl); |
141 | cal->SetZSHighThreshold(isid,th); | |
317e638f | 142 | for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){ |
143 | fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain); | |
144 | Int_t ich=ian; | |
145 | if(isid==1) ich+=256; | |
146 | if(!isgoodan){ | |
147 | Int_t ibad=numOfBadChannels[modID]; | |
148 | badch[ibad]=ich; | |
149 | numOfBadChannels[modID]++; | |
979b5a5f | 150 | } |
20f3f947 | 151 | cal->SetBaseline(ich,baseline-basoff); |
317e638f | 152 | cal->SetNoiseAfterElectronics(ich,rawnoise); |
153 | cal->SetGain(ich,gain); | |
979b5a5f | 154 | } |
317e638f | 155 | cal->SetDeadChannels(numOfBadChannels[modID]); |
156 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
157 | cal->SetBadChannel(ibad,badch[ibad]); | |
158 | } | |
159 | fclose(basFil); | |
c2bd28b6 | 160 | } |
317e638f | 161 | calSDD.AddAt(cal,modID); |
e56160b8 | 162 | } |
317e638f | 163 | } |
164 | AliCDBMetaData *md= new AliCDBMetaData(); | |
165 | md->SetResponsible("Francesco Prino"); | |
166 | md->SetBeamPeriod(0); | |
167 | md->SetComment("AliITSCalibrationSDD from PEDESTAL+PULSER runs"); | |
168 | Bool_t retCode = Store("Calib","CalibSDD",&calSDD,md, 0, kTRUE); | |
461c9263 | 169 | if(retCode) return 0; |
170 | else return 1; | |
317e638f | 171 | } |
172 | //______________________________________________________________________ | |
461c9263 | 173 | UInt_t AliITSPreprocessorSDD::ProcessInjector(AliITSDDLModuleMapSDD* ddlmap){ |
317e638f | 174 | // Process FXS files from injector events (INJECTOR or PHYSICS runs) |
461c9263 | 175 | // returns 0 in case of success, |
176 | // 1 in case of storage error, | |
177 | // 2 in case of error with input files | |
317e638f | 178 | TObjArray vdrift(2*kNumberOfSDD); |
179 | vdrift.SetOwner(kFALSE); | |
180 | Char_t command[100]; | |
181 | Char_t inpFileName[100]; | |
182 | Int_t evNumb,polDeg; | |
183 | UInt_t timeStamp; | |
184 | Float_t param[4]; | |
e56160b8 | 185 | |
317e638f | 186 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); |
187 | if (!sourceList){ | |
188 | Log("Error: no sources found for SDD_Injec"); | |
189 | return 2; | |
190 | } | |
191 | Int_t ind = 0; | |
192 | while (sourceList->At(ind)!=NULL) { | |
193 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
194 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
195 | if(tarName.Length()==0){ | |
196 | Log(Form("Injector tar file from source %d not found.",ind)); | |
18da6e54 | 197 | return 2; |
198 | } | |
317e638f | 199 | sprintf(command,"tar -xf %s",tarName.Data()); |
200 | gSystem->Exec(command); | |
201 | ind++; | |
202 | } | |
203 | delete sourceList; | |
204 | ||
205 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
206 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
207 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
208 | if(modID==-1) continue; | |
209 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
210 | for(Int_t isid=0;isid<=1;isid++){ | |
211 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
212 | sprintf(inpFileName,"./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
213 | FILE* injFil = fopen(inpFileName,"read"); | |
214 | if (injFil == 0) { | |
215 | Log(Form("File %s not found.",inpFileName)); | |
216 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(); | |
217 | arr->AddDriftSpeed(dsp); | |
979b5a5f | 218 | vdrift.AddAt(arr,2*modID+isid); |
317e638f | 219 | continue; |
220 | } | |
221 | fscanf(injFil,"%d",&polDeg); | |
222 | while (!feof(injFil)){ | |
223 | fscanf(injFil,"%d %d",&evNumb,&timeStamp); | |
224 | if(feof(injFil)) break; | |
225 | for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",¶m[ic]); | |
226 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
227 | arr->AddDriftSpeed(dsp); | |
18da6e54 | 228 | } |
317e638f | 229 | vdrift.AddAt(arr,2*modID+isid); |
18da6e54 | 230 | } |
231 | } | |
cfaccd71 | 232 | } |
317e638f | 233 | AliCDBMetaData *md= new AliCDBMetaData(); |
234 | md->SetResponsible("Francesco Prino"); | |
235 | md->SetBeamPeriod(0); | |
236 | md->SetComment("AliITSDriftSpeedSDD from injector events"); | |
237 | Bool_t retCode = Store("Calib","DriftSpeedSDD",&vdrift,md,0, kTRUE); | |
461c9263 | 238 | if(retCode) return 0; |
239 | else return 1; | |
317e638f | 240 | } |
241 | //______________________________________________________________________ | |
242 | Bool_t AliITSPreprocessorSDD::ProcessDCSDataPoints(TMap* dcsAliasMap){ | |
243 | // Process DCS data | |
244 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
245 | dcs->AnalyzeData(dcsAliasMap); | |
246 | TObjArray refDCS(kNumberOfSDD); | |
247 | refDCS.SetOwner(kFALSE); | |
248 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ | |
249 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); | |
250 | refDCS.Add(dcsdata); | |
251 | } | |
252 | AliCDBMetaData *md= new AliCDBMetaData(); | |
253 | md->SetResponsible("Francesco Prino"); | |
254 | md->SetBeamPeriod(0); | |
255 | md->SetComment("AliITSDCSDataSDD objects from DCS DB"); | |
256 | Bool_t retCode = StoreReferenceData("DCS","DataSDD",&refDCS,md); | |
257 | return retCode; | |
e56160b8 | 258 | } |