]>
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 | |
5a9fd7dd | 16 | /* $Id$ */ |
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" |
979b5a5f | 29 | #include "AliITSDDLModuleMapSDD.h" |
18da6e54 | 30 | #include "AliITSDriftSpeedArraySDD.h" |
cfaccd71 | 31 | #include "AliITSDCSAnalyzerSDD.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 | ||
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 | Char_t command[100]; |
18da6e54 | 64 | Char_t inpFileName[100]; |
65 | AliCDBMetaData *md1= new AliCDBMetaData(); | |
979b5a5f | 66 | md1->SetResponsible("Francesco Prino"); |
18da6e54 | 67 | md1->SetBeamPeriod(0); |
68 | md1->SetAliRootVersion("head 30 November 2007"); //root version | |
69 | md1->SetComment("This is a test"); | |
c2bd28b6 | 70 | |
ad2585ed | 71 | if (runType == "PULSER"){ |
979b5a5f | 72 | TObjArray calSDD(kNumberOfSDD); |
18da6e54 | 73 | calSDD.SetOwner(kFALSE); |
74 | Float_t baseline,rawnoise,cmn,corn,gain; | |
af066a8f | 75 | Int_t isgoodan,i,im,is,isgoodmod,basmin,basoff; |
979b5a5f | 76 | Int_t numOfBadChannels[kNumberOfSDD]; |
18da6e54 | 77 | |
78 | TList* sourceList = GetFileSources(kDAQ, "SDD_Calib"); | |
79 | if (!sourceList){ | |
80 | Log("Error: no sources found for SDD_Calib"); | |
ba541030 | 81 | return 2; |
82 | } | |
dfb8947f | 83 | |
18da6e54 | 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)); | |
dfb8947f | 90 | return 2; |
afa07040 | 91 | } |
18da6e54 | 92 | sprintf(command,"tar -xf %s",tarName.Data()); |
93 | gSystem->Exec(command); | |
94 | ind++; | |
95 | } | |
96 | delete sourceList; | |
c2bd28b6 | 97 | |
979b5a5f | 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->SetDead(); | |
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 | Int_t iChip=cal->GetChip(ich); | |
127 | Int_t iChInChip=cal->GetChipChannel(ich); | |
128 | cal->SetGain(gain,isid,iChip,iChInChip); | |
129 | } | |
130 | cal->SetDeadChannels(numOfBadChannels[modID]); | |
131 | for(Int_t ibad=0;ibad<numOfBadChannels[modID];ibad++){ | |
132 | cal->SetBadChannel(ibad,badch[ibad]); | |
133 | } | |
134 | fclose(basFil); | |
135 | } | |
136 | calSDD.AddAt(cal,modID); | |
c2bd28b6 | 137 | } |
e56160b8 | 138 | } |
18da6e54 | 139 | md1->SetObjectClassName("AliITSCalibration"); |
140 | retcode = Store("Calib","CalibSDD",&calSDD,md1, 0, kTRUE); | |
ad2585ed | 141 | }else if(runType == "PHYSICS" || runType== "INJECTOR"){ |
e56160b8 | 142 | |
979b5a5f | 143 | TObjArray vdrift(2*kNumberOfSDD); |
18da6e54 | 144 | vdrift.SetOwner(kFALSE); |
145 | Int_t evNumb,polDeg; | |
146 | UInt_t timeStamp; | |
147 | Float_t param[4]; | |
e56160b8 | 148 | |
18da6e54 | 149 | TList* sourceList = GetFileSources(kDAQ, "SDD_Injec"); |
150 | if (!sourceList){ | |
151 | Log("Error: no sources found for SDD_Injec"); | |
152 | return 2; | |
153 | } | |
154 | Int_t ind = 0; | |
155 | while (sourceList->At(ind)!=NULL) { | |
156 | TObjString* tarId = (TObjString*) sourceList->At(ind); | |
157 | TString tarName = GetFile(kDAQ, "SDD_Injec", tarId->GetString().Data()); | |
158 | if(tarName.Length()==0){ | |
159 | Log(Form("Injector tar file from source %d not found.",ind)); | |
160 | return 2; | |
161 | } | |
162 | sprintf(command,"tar -xf %s",tarName.Data()); | |
163 | gSystem->Exec(command); | |
164 | ind++; | |
165 | } | |
166 | delete sourceList; | |
e56160b8 | 167 | |
979b5a5f | 168 | for(Int_t iddl=0;iddl<kNumberOfDDL;iddl++){ |
169 | for(Int_t imod=0;imod<kModulesPerDDL;imod++){ | |
170 | Int_t modID=ddlmap->GetModuleNumber(iddl,imod); | |
171 | if(modID==-1) continue; | |
172 | modID-=240; // to have SDD modules numbering from 0 to 260 | |
173 | for(Int_t isid=0;isid<=1;isid++){ | |
174 | AliITSDriftSpeedArraySDD *arr=new AliITSDriftSpeedArraySDD(); | |
175 | sprintf(inpFileName,"./SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
176 | FILE* injFil = fopen(inpFileName,"read"); | |
177 | if (injFil == 0) { | |
178 | Log(Form("File %s not found.",inpFileName)); | |
179 | return 2; | |
180 | } | |
181 | fscanf(injFil,"%d",&polDeg); | |
182 | while (!feof(injFil)){ | |
183 | fscanf(injFil,"%d %d",&evNumb,&timeStamp); | |
184 | if(feof(injFil)) break; | |
185 | for(Int_t ic=0;ic<4;ic++) fscanf(injFil,"%f",¶m[ic]); | |
186 | AliITSDriftSpeedSDD *dsp=new AliITSDriftSpeedSDD(evNumb,timeStamp,polDeg,param); | |
187 | arr->AddDriftSpeed(dsp); | |
188 | } | |
189 | vdrift.AddAt(arr,2*modID+isid); | |
18da6e54 | 190 | } |
18da6e54 | 191 | } |
192 | } | |
193 | md1->SetObjectClassName("AliITSDriftSpeedArraySDD"); | |
194 | retcode = Store("Calib","DriftSpeedSDD",&vdrift,md1,0, kTRUE); | |
195 | }else{ | |
196 | // do nothing for other run types | |
197 | retcode=1; | |
198 | } | |
cfaccd71 | 199 | if(retcode){ |
200 | // process DCS data | |
201 | AliITSDCSAnalyzerSDD *dcs=new AliITSDCSAnalyzerSDD(); | |
202 | dcs->AnalyzeData(dcsAliasMap); | |
979b5a5f | 203 | TObjArray refDCS(kNumberOfSDD); |
cfaccd71 | 204 | refDCS.SetOwner(kFALSE); |
979b5a5f | 205 | for(Int_t imod=0;imod<kNumberOfSDD;imod++){ |
cfaccd71 | 206 | AliITSDCSDataSDD *dcsdata=dcs->GetDCSData(imod); |
207 | refDCS.Add(dcsdata); | |
208 | } | |
209 | ||
210 | AliCDBMetaData *mddcs= new AliCDBMetaData(); | |
211 | mddcs->SetResponsible("Francesco Prino"); | |
212 | mddcs->SetBeamPeriod(0); | |
213 | mddcs->SetAliRootVersion("head 18 December 2007"); //root version | |
214 | mddcs->SetComment("This is a test"); | |
215 | mddcs->SetObjectClassName("AliITSDCSDataSDD"); | |
216 | Int_t retcodedcs = StoreReferenceData("DCS","DataSDD",&refDCS,mddcs); | |
217 | ||
218 | if(retcodedcs) return 0; | |
219 | } | |
220 | return 1; | |
e56160b8 | 221 | } |