]>
Commit | Line | Data |
---|---|---|
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
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 | ||
26 | #include "AliITSPreprocessorSDD.h" | |
27 | #include "AliITSCalibrationSDD.h" | |
28 | #include "AliITSDriftSpeedSDD.h" | |
29 | #include "AliITSDDLModuleMapSDD.h" | |
30 | #include "AliITSDriftSpeedArraySDD.h" | |
31 | #include "AliITSDCSAnalyzerSDD.h" | |
32 | #include "AliShuttleInterface.h" | |
33 | #include "AliCDBEntry.h" | |
34 | #include "AliCDBMetaData.h" | |
35 | #include "TObjArray.h" | |
36 | #include "AliLog.h" | |
37 | #include <TObjString.h> | |
38 | #include <TSystem.h> | |
39 | #include <TList.h> | |
40 | ||
41 | const TString AliITSPreprocessorSDD::fgkNameHistoPedestals = "hpedestal"; | |
42 | const TString AliITSPreprocessorSDD::fgkNameHistoNoise = "hnoise"; | |
43 | ClassImp(AliITSPreprocessorSDD) | |
44 | ||
45 | ||
46 | UInt_t AliITSPreprocessorSDD::Process(TMap* dcsAliasMap){ | |
47 | ||
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 | } | |
59 | ||
60 | //preprocessing | |
61 | TString runType = GetRunType(); | |
62 | Bool_t retcode; | |
63 | Char_t command[100]; | |
64 | Char_t inpFileName[100]; | |
65 | AliCDBMetaData *md1= new AliCDBMetaData(); | |
66 | md1->SetResponsible("Francesco Prino"); | |
67 | md1->SetBeamPeriod(0); | |
68 | md1->SetAliRootVersion("head 30 November 2007"); //root version | |
69 | md1->SetComment("This is a test"); | |
70 | ||
71 | if (runType == "PULSER"){ | |
72 | TObjArray calSDD(kNumberOfSDD); | |
73 | calSDD.SetOwner(kFALSE); | |
74 | Float_t baseline,rawnoise,cmn,corn,gain; | |
75 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; | |
76 | Int_t numOfBadChannels[kNumberOfSDD]; | |
77 | ||
78 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); | |
79 | if (!sourceList){ | |
80 | Log("Error: no sources found for SDD_Calib"); | |
81 | return 2; | |
82 | } | |
83 | ||
84 | Int_t ind = 0; | |
85 | while (sourceList->At(ind)!=NULL) { | |
86 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
87 | TString tarName = GetFile(kDAQ, "SDD_Calib", tarId->GetString().Data()); | |
88 | if(tarName.Length()==0){ | |
89 | Log(Form("Baseline tar file from source %d not found.",ind)); | |
90 | return 2; | |
91 | } | |
92 | sprintf(command,"tar -xf %s",tarName.Data()); | |
93 | gSystem->Exec(command); | |
94 | ind++; | |
95 | } | |
96 | delete sourceList; | |
97 | ||
98 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
99 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
100 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
101 | if(modID==-1) continue; | |
102 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
103 | AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated"); | |
104 | numOfBadChannels[modID]=0; | |
105 | Int_t badch[kNumberOfChannels]; | |
106 | for(Int_t isid=0;isid<=1;isid++){ | |
107 | sprintf(inpFileName,"./SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
108 | FILE* basFil = fopen(inpFileName,"read"); | |
109 | if (basFil == 0) { | |
110 | Log(Form("File %s not found.",inpFileName)); | |
111 | return 2; | |
112 | } | |
113 | fscanf(basFil,"%d %d %d\n",&im,&is,&isgoodmod); | |
114 | if(!isgoodmod) cal->SetBad(); | |
115 | for(Int_t ian=0;ian<(kNumberOfChannels/2);ian++){ | |
116 | fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain); | |
117 | Int_t ich=ian; | |
118 | if(isid==1) ich+=256; | |
119 | if(!isgoodan){ | |
120 | Int_t ibad=numOfBadChannels[modID]; | |
121 | badch[ibad]=ich; | |
122 | numOfBadChannels[modID]++; | |
123 | } | |
124 | cal->SetBaseline(ich,baseline); | |
125 | cal->SetNoiseAfterElectronics(ich,rawnoise); | |
126 | cal->SetGain(ich,gain); | |
127 | } | |
128 | cal->SetDeadChannels(numOfBadChannels[modID]); | |
129 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
130 | cal->SetBadChannel(ibad,badch[ibad]); | |
131 | } | |
132 | fclose(basFil); | |
133 | } | |
134 | calSDD.AddAt(cal,modID); | |
135 | } | |
136 | } | |
137 | md1->SetObjectClassName("AliITSCalibration"); | |
138 | retcode = Store("Calib","CalibSDD",&calSDD,md1, 0, kTRUE); | |
139 | }else if(runType == "PHYSICS" || runType== "INJECTOR"){ | |
140 | ||
141 | TObjArray vdrift(2*kNumberOfSDD); | |
142 | vdrift.SetOwner(kFALSE); | |
143 | Int_t evNumb,polDeg; | |
144 | UInt_t timeStamp; | |
145 | Float_t param[4]; | |
146 | ||
147 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); | |
148 | if (!sourceList){ | |
149 | Log("Error: no sources found for SDD_Injec"); | |
150 | return 2; | |
151 | } | |
152 | Int_t ind = 0; | |
153 | while (sourceList->At(ind)!=NULL) { | |
154 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
155 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
156 | if(tarName.Length()==0){ | |
157 | Log(Form("Injector tar file from source %d not found.",ind)); | |
158 | return 2; | |
159 | } | |
160 | sprintf(command,"tar -xf %s",tarName.Data()); | |
161 | gSystem->Exec(command); | |
162 | ind++; | |
163 | } | |
164 | delete sourceList; | |
165 | ||
166 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ | |
167 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
168 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
169 | if(modID==-1) continue; | |
170 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
171 | for(Int_t isid=0;isid<=1;isid++){ | |
172 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
173 | sprintf(inpFileName,"./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
174 | FILE* injFil = fopen(inpFileName,"read"); | |
175 | if (injFil == 0) { | |
176 | Log(Form("File %s not found.",inpFileName)); | |
177 | return 2; | |
178 | } | |
179 | fscanf(injFil,"%d",&polDeg); | |
180 | while (!feof(injFil)){ | |
181 | fscanf(injFil,"%d %d",&evNumb,&timeStamp); | |
182 | if(feof(injFil)) break; | |
183 | for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",¶m[ic]); | |
184 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
185 | arr->AddDriftSpeed(dsp); | |
186 | } | |
187 | vdrift.AddAt(arr,2*modID+isid); | |
188 | } | |
189 | } | |
190 | } | |
191 | md1->SetObjectClassName("AliITSDriftSpeedArraySDD"); | |
192 | retcode = Store("Calib","DriftSpeedSDD",&vdrift,md1,0, kTRUE); | |
193 | }else{ | |
194 | // do nothing for other run types | |
195 | retcode=1; | |
196 | } | |
197 | if(retcode){ | |
198 | // process DCS data | |
199 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
200 | dcs->AnalyzeData(dcsAliasMap); | |
201 | TObjArray refDCS(kNumberOfSDD); | |
202 | refDCS.SetOwner(kFALSE); | |
203 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ | |
204 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); | |
205 | refDCS.Add(dcsdata); | |
206 | } | |
207 | ||
208 | AliCDBMetaData *mddcs= new AliCDBMetaData(); | |
209 | mddcs->SetResponsible("Francesco Prino"); | |
210 | mddcs->SetBeamPeriod(0); | |
211 | mddcs->SetAliRootVersion("head 18 December 2007"); //root version | |
212 | mddcs->SetComment("This is a test"); | |
213 | mddcs->SetObjectClassName("AliITSDCSDataSDD"); | |
214 | Int_t retcodedcs = StoreReferenceData("DCS","DataSDD",&refDCS,mddcs); | |
215 | ||
216 | if(retcodedcs) return 0; | |
217 | } | |
218 | return 1; | |
219 | } |