]>
Commit | Line | Data |
---|---|---|
5ca85244 | 1 | #include "AliITSPreprocessorSSD.h" |
2 | ||
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 | ||
29 | //______________________________________________________________________________________________ | |
30 | void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime, | |
31 | UInt_t endTime) | |
32 | { | |
33 | ||
34 | AliPreprocessor::Initialize(run, startTime, endTime); | |
35 | ||
36 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
37 | TTimeStamp(startTime).AsString(), | |
38 | TTimeStamp(endTime).AsString())); | |
39 | ||
40 | } | |
41 | ||
42 | //______________________________________________________________________________________________ | |
43 | UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/) | |
44 | { | |
45 | ||
46 | // Note. To be modified: dcsAliasMap is not needed but I can not get rid | |
47 | // of it unless the base class AliPreprocessor is modified accordingly. | |
48 | ||
a5edfa6f | 49 | TObjArray calib_array(fgkNumberOfSSD); |
50 | TObjArray badch_array(fgkNumberOfSSD); | |
51 | TObjArray ped_array(fgkNumberOfSSD); | |
5ca85244 | 52 | //Float_t noise=0, gain=0; |
53 | ||
54 | TString runType = GetRunType(); | |
a5edfa6f | 55 | if(runType == "ELECTRONICS_CALIBRATION_RUN") { |
5ca85244 | 56 | |
57 | } | |
58 | else if(runType == "PEDESTAL_RUN") { | |
59 | ||
60 | TList* list = GetFileSources(kDAQ, "CALIBRATION"); | |
61 | if (list && list->GetEntries() > 0) | |
62 | { | |
63 | Log("The following sources produced files with the id CALIBRATION"); | |
64 | list->Print(); | |
65 | ||
66 | // create iterator over list of LDCs (provides list of TObjString) | |
67 | TIter next(list); | |
68 | TObjString *ok; | |
69 | ||
70 | // expect to iterate 3 times (LDC0, LDC1, LDC2) | |
71 | while ( (ok = (TObjString*) next()) ) { | |
72 | ||
73 | TString key = ok->String(); | |
74 | ||
75 | TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data()); | |
76 | if (fileName.Length() > 0) { | |
77 | ||
78 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
79 | ||
80 | TFile *f = new TFile(fileName.Data()); | |
81 | if(!f || !f->IsOpen()){ | |
82 | Log("Error opening file!"); | |
83 | delete list; | |
84 | return 2; | |
85 | } | |
86 | ||
87 | TObjArray *cal; | |
a5edfa6f | 88 | f->GetObject("Noise;1", cal); |
5ca85244 | 89 | if(!cal) { |
a5edfa6f | 90 | Log("File does not contain expected data for the noise!"); |
5ca85244 | 91 | delete list; |
a5edfa6f | 92 | } |
5ca85244 | 93 | Int_t nmod = cal->GetEntries(); |
a5edfa6f | 94 | for(Int_t mod=0; mod<nmod; mod++) { |
95 | AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod); | |
96 | if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue; | |
97 | calib_array.AddAt(calib,calib->GetMod()-500); | |
98 | } | |
5ca85244 | 99 | |
a5edfa6f | 100 | TObjArray *bad; |
101 | f->GetObject("BadChannels;1", bad); | |
102 | if(!bad) { | |
103 | Log("File does not contain expected data for bad channels !"); | |
104 | delete list; | |
105 | } | |
106 | nmod = bad->GetEntries(); | |
5ca85244 | 107 | for(Int_t mod=0; mod<nmod; mod++) { |
a5edfa6f | 108 | AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod); |
109 | if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue; | |
110 | badch_array.AddAt(badch,badch->GetMod()-500); | |
111 | } | |
5ca85244 | 112 | |
a5edfa6f | 113 | TObjArray *ped; |
114 | f->GetObject("Pedestal;1", ped); | |
115 | if(!ped) { | |
116 | Log("File does not contain expected data for the pedestals!"); | |
117 | delete list; | |
118 | } | |
119 | nmod = ped->GetEntries(); | |
120 | for(Int_t mod=0; mod<nmod; mod++) { | |
121 | AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod); | |
122 | if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue; | |
123 | ped_array.AddAt(pedel,pedel->GetMod()-500); | |
5ca85244 | 124 | } |
a5edfa6f | 125 | |
126 | f->Close(); delete f; | |
5ca85244 | 127 | |
128 | } else { | |
129 | Log("GetFile error!"); | |
130 | delete list; | |
131 | return 3; | |
132 | } // if filename | |
133 | } // end iteration over LDCs | |
134 | ||
135 | delete list; | |
136 | } else { | |
137 | Log("GetFileSources error!"); | |
138 | if(list) delete list; | |
139 | return 4; | |
140 | } // if list | |
141 | ||
142 | //Now we have to store the final CDB file | |
143 | AliCDBMetaData metaData; | |
144 | metaData.SetBeamPeriod(0); | |
145 | metaData.SetResponsible("Enrico Fragiacomo"); | |
a5edfa6f | 146 | metaData.SetComment("Fills noise, pedestal and bad channels TObjArray"); |
5ca85244 | 147 | |
a5edfa6f | 148 | if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) { |
149 | Log("no store"); | |
5ca85244 | 150 | return 1; |
a5edfa6f | 151 | } |
152 | ||
153 | if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) { | |
154 | Log("no store"); | |
155 | return 1; | |
156 | } | |
157 | ||
158 | if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) { | |
159 | Log("no store"); | |
160 | return 1; | |
161 | } | |
162 | ||
5ca85244 | 163 | } // end if noise_run |
164 | else { | |
165 | Log("Nothing to do"); | |
166 | return 0; | |
167 | } | |
168 | ||
169 | Log("Database updated"); | |
170 | return 0; // 0 means success | |
171 | ||
172 | } | |
173 |