]>
Commit | Line | Data |
---|---|---|
5ca85244 | 1 | #include "AliITSPreprocessorSSD.h" |
51e983b7 | 2 | |
5ca85244 | 3 | #include "AliCDBMetaData.h" |
4 | #include "AliLog.h" | |
5 | #include "TFile.h" | |
6 | ||
7 | #include <TTimeStamp.h> | |
8 | #include <TObjString.h> | |
9 | ||
10 | #include "AliITSRawStreamSSD.h" | |
11 | #include "AliITSNoiseSSD.h" | |
a5edfa6f | 12 | #include "AliITSPedestalSSD.h" |
13 | #include "AliITSBadChannelsSSD.h" | |
5ca85244 | 14 | #include <Riostream.h> |
15 | ||
16 | ||
17 | // | |
18 | // Author: Enrico Fragiacomo | |
19 | // Date: 13/10/2006 | |
20 | // | |
21 | // SHUTTLE preprocessing class for SSD calibration files | |
22 | ||
23 | /* $Id$ */ | |
24 | ||
a5edfa6f | 25 | const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698; |
26 | ||
5ca85244 | 27 | ClassImp(AliITSPreprocessorSSD) |
28 | ||
51e983b7 | 29 | //----------------------------------------------------------------------- |
30 | AliITSPreprocessorSSD::AliITSPreprocessorSSD(AliShuttleInterface* shuttle) : | |
31 | AliPreprocessor("SSD", shuttle) | |
32 | { | |
33 | // constructor | |
34 | ||
35 | AddRunType("ELECTRONICS_CALIBRATION_RUN"); | |
36 | AddRunType("PEDESTAL"); | |
37 | AddRunType("PHYSICS"); | |
38 | ||
39 | } | |
40 | ||
41 | ///______________________________________________________________________________________________ | |
5ca85244 | 42 | void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime, |
43 | UInt_t endTime) | |
44 | { | |
45 | ||
46 | AliPreprocessor::Initialize(run, startTime, endTime); | |
47 | ||
48 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
49 | TTimeStamp(startTime).AsString(), | |
50 | TTimeStamp(endTime).AsString())); | |
51 | ||
52 | } | |
53 | ||
54 | //______________________________________________________________________________________________ | |
55 | UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/) | |
56 | { | |
57 | ||
58 | // Note. To be modified: dcsAliasMap is not needed but I can not get rid | |
59 | // of it unless the base class AliPreprocessor is modified accordingly. | |
60 | ||
a5edfa6f | 61 | TObjArray calib_array(fgkNumberOfSSD); |
62 | TObjArray badch_array(fgkNumberOfSSD); | |
63 | TObjArray ped_array(fgkNumberOfSSD); | |
5ca85244 | 64 | //Float_t noise=0, gain=0; |
c9a38d3d | 65 | |
5ca85244 | 66 | TString runType = GetRunType(); |
c9a38d3d | 67 | if(runType == "ELECTRONICS_CALIBRATION_RUN") { |
68 | ||
5ca85244 | 69 | } |
c96050be | 70 | else if(runType == "PEDESTAL") { |
5ca85244 | 71 | |
72 | TList* list = GetFileSources(kDAQ, "CALIBRATION"); | |
73 | if (list && list->GetEntries() > 0) | |
74 | { | |
75 | Log("The following sources produced files with the id CALIBRATION"); | |
76 | list->Print(); | |
77 | ||
78 | // create iterator over list of LDCs (provides list of TObjString) | |
79 | TIter next(list); | |
80 | TObjString *ok; | |
81 | ||
51e983b7 | 82 | //--------------------------------------- |
83 | // in case some module was not calibrated! | |
84 | for(Int_t i=0; i<fgkNumberOfSSD; i++) { | |
85 | AliITSNoiseSSD *calib = new AliITSNoiseSSD(); | |
86 | calib->SetMod((UShort_t) i+500); | |
87 | calib->SetNNoiseP(768); | |
88 | calib->SetNNoiseN(768); | |
89 | // take a reasonable averaged value for the noise on P- and N-side strips | |
90 | for(Int_t j=0; j<768; j++) { | |
91 | calib->AddNoiseP(j,1000.); | |
92 | calib->AddNoiseN(j,1000.); | |
93 | } | |
94 | calib_array.AddAt(calib,i); | |
95 | } | |
96 | //----------------------------------------- | |
97 | //--------------------------------------- | |
98 | // in case some module was not calibrated! | |
99 | for(Int_t i=0; i<fgkNumberOfSSD; i++) { | |
100 | AliITSBadChannelsSSD *badch = new AliITSBadChannelsSSD(); | |
101 | badch->SetMod((UShort_t) i+500); | |
102 | badch_array.AddAt(badch,i); | |
103 | } | |
104 | //----------------------------------------- | |
105 | ||
106 | //--------------------------------------- | |
107 | // in case some module was not calibrated! | |
108 | for(Int_t i=0; i<fgkNumberOfSSD; i++) { | |
109 | AliITSPedestalSSD *pedel = new AliITSPedestalSSD(); | |
110 | pedel->SetMod((UShort_t) i+500); | |
111 | pedel->SetNPedestalP(768); | |
112 | pedel->SetNPedestalN(768); | |
113 | for(Int_t j=0; j<768; j++) { | |
114 | pedel->AddPedestalP(j,0.); | |
115 | pedel->AddPedestalN(j,0.); | |
116 | } | |
117 | ped_array.AddAt(pedel,i); | |
118 | } | |
119 | //----------------------------------------- | |
120 | ||
121 | ||
122 | ||
5ca85244 | 123 | // expect to iterate 3 times (LDC0, LDC1, LDC2) |
124 | while ( (ok = (TObjString*) next()) ) { | |
125 | ||
126 | TString key = ok->String(); | |
127 | ||
128 | TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data()); | |
129 | if (fileName.Length() > 0) { | |
130 | ||
131 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
132 | ||
133 | TFile *f = new TFile(fileName.Data()); | |
134 | if(!f || !f->IsOpen()){ | |
135 | Log("Error opening file!"); | |
136 | delete list; | |
137 | return 2; | |
138 | } | |
139 | ||
140 | TObjArray *cal; | |
a5edfa6f | 141 | f->GetObject("Noise;1", cal); |
5ca85244 | 142 | if(!cal) { |
a5edfa6f | 143 | Log("File does not contain expected data for the noise!"); |
5ca85244 | 144 | delete list; |
375ec901 | 145 | return 3; |
a5edfa6f | 146 | } |
375ec901 | 147 | |
5ca85244 | 148 | Int_t nmod = cal->GetEntries(); |
51e983b7 | 149 | Log(Form("\n#Mod %d", nmod )); |
a5edfa6f | 150 | for(Int_t mod=0; mod<nmod; mod++) { |
151 | AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod); | |
51e983b7 | 152 | Log(Form("\nModId %d", calib->GetMod() )); |
a5edfa6f | 153 | if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue; |
154 | calib_array.AddAt(calib,calib->GetMod()-500); | |
155 | } | |
5ca85244 | 156 | |
a5edfa6f | 157 | TObjArray *bad; |
158 | f->GetObject("BadChannels;1", bad); | |
159 | if(!bad) { | |
160 | Log("File does not contain expected data for bad channels !"); | |
161 | delete list; | |
375ec901 | 162 | return 4; |
a5edfa6f | 163 | } |
164 | nmod = bad->GetEntries(); | |
5ca85244 | 165 | for(Int_t mod=0; mod<nmod; mod++) { |
a5edfa6f | 166 | AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod); |
167 | if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue; | |
168 | badch_array.AddAt(badch,badch->GetMod()-500); | |
169 | } | |
5ca85244 | 170 | |
a5edfa6f | 171 | TObjArray *ped; |
172 | f->GetObject("Pedestal;1", ped); | |
173 | if(!ped) { | |
174 | Log("File does not contain expected data for the pedestals!"); | |
175 | delete list; | |
375ec901 | 176 | return 5; |
a5edfa6f | 177 | } |
178 | nmod = ped->GetEntries(); | |
179 | for(Int_t mod=0; mod<nmod; mod++) { | |
180 | AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod); | |
181 | if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue; | |
182 | ped_array.AddAt(pedel,pedel->GetMod()-500); | |
5ca85244 | 183 | } |
a5edfa6f | 184 | |
185 | f->Close(); delete f; | |
5ca85244 | 186 | |
187 | } else { | |
188 | Log("GetFile error!"); | |
189 | delete list; | |
375ec901 | 190 | return 6; |
5ca85244 | 191 | } // if filename |
192 | } // end iteration over LDCs | |
193 | ||
194 | delete list; | |
195 | } else { | |
196 | Log("GetFileSources error!"); | |
197 | if(list) delete list; | |
375ec901 | 198 | return 7; |
5ca85244 | 199 | } // if list |
200 | ||
201 | //Now we have to store the final CDB file | |
202 | AliCDBMetaData metaData; | |
203 | metaData.SetBeamPeriod(0); | |
204 | metaData.SetResponsible("Enrico Fragiacomo"); | |
a5edfa6f | 205 | metaData.SetComment("Fills noise, pedestal and bad channels TObjArray"); |
5ca85244 | 206 | |
a5edfa6f | 207 | if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) { |
208 | Log("no store"); | |
5ca85244 | 209 | return 1; |
a5edfa6f | 210 | } |
211 | ||
212 | if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) { | |
213 | Log("no store"); | |
214 | return 1; | |
215 | } | |
216 | ||
217 | if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) { | |
218 | Log("no store"); | |
219 | return 1; | |
220 | } | |
221 | ||
51e983b7 | 222 | } // end if pedestal run |
5ca85244 | 223 | else { |
224 | Log("Nothing to do"); | |
225 | return 0; | |
226 | } | |
227 | ||
228 | Log("Database updated"); | |
229 | return 0; // 0 means success | |
230 | ||
231 | } | |
232 |