]>
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" | |
88128115 | 11 | #include "AliITSNoiseSSDv2.h" |
12 | #include "AliITSPedestalSSDv2.h" | |
13 | #include "AliITSBadChannelsSSDv2.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 | ||
ced4d9bc | 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 | |
ced4d9bc | 66 | //--------------------------------------- |
67 | // initialize the calibration objects | |
88128115 | 68 | AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2(); |
69 | AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2(); | |
70 | AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2(); | |
ced4d9bc | 71 | |
5ca85244 | 72 | TString runType = GetRunType(); |
c9a38d3d | 73 | if(runType == "ELECTRONICS_CALIBRATION_RUN") { |
74 | ||
5ca85244 | 75 | } |
c96050be | 76 | else if(runType == "PEDESTAL") { |
5ca85244 | 77 | |
78 | TList* list = GetFileSources(kDAQ, "CALIBRATION"); | |
79 | if (list && list->GetEntries() > 0) | |
80 | { | |
81 | Log("The following sources produced files with the id CALIBRATION"); | |
82 | list->Print(); | |
83 | ||
84 | // create iterator over list of LDCs (provides list of TObjString) | |
85 | TIter next(list); | |
86 | TObjString *ok; | |
87 | ||
88 | // expect to iterate 3 times (LDC0, LDC1, LDC2) | |
89 | while ( (ok = (TObjString*) next()) ) { | |
90 | ||
91 | TString key = ok->String(); | |
92 | ||
93 | TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data()); | |
94 | if (fileName.Length() > 0) { | |
95 | ||
96 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
97 | ||
98 | TFile *f = new TFile(fileName.Data()); | |
99 | if(!f || !f->IsOpen()){ | |
100 | Log("Error opening file!"); | |
101 | delete list; | |
102 | return 2; | |
103 | } | |
104 | ||
88128115 | 105 | AliITSNoiseSSDv2 *cal; |
106 | f->GetObject("AliITSNoiseSSDv2;1", cal); | |
5ca85244 | 107 | if(!cal) { |
a5edfa6f | 108 | Log("File does not contain expected data for the noise!"); |
5ca85244 | 109 | delete list; |
375ec901 | 110 | return 3; |
a5edfa6f | 111 | } |
88128115 | 112 | AliITSPedestalSSDv2 *ped; |
113 | f->GetObject("AliITSPedestalSSDv2;1", ped); | |
ced4d9bc | 114 | if(!ped) { |
115 | Log("File does not contain expected data for the pedestals!"); | |
116 | delete list; | |
117 | return 5; | |
118 | } | |
88128115 | 119 | AliITSBadChannelsSSDv2 *bad; |
120 | f->GetObject("AliITSBadChannelsSSDv2;1", bad); | |
a5edfa6f | 121 | if(!bad) { |
122 | Log("File does not contain expected data for bad channels !"); | |
123 | delete list; | |
375ec901 | 124 | return 4; |
a5edfa6f | 125 | } |
5ca85244 | 126 | |
ced4d9bc | 127 | for(Int_t module=0; module<fgkNumberOfSSD; module++) { |
128 | for(Int_t strip=0; strip<768; strip++) { | |
129 | if(cal->GetNoiseP(module,strip)) | |
130 | calib->AddNoiseP(module,strip,cal->GetNoiseP(module,strip)); | |
131 | if(cal->GetNoiseN(module,strip)) | |
132 | calib->AddNoiseN(module,strip,cal->GetNoiseN(module,strip)); | |
133 | if(ped->GetPedestalP(module,strip)) | |
134 | pedel->AddPedestalP(module,strip, | |
135 | ped->GetPedestalP(module,strip)); | |
136 | if(ped->GetPedestalN(module,strip)) | |
137 | pedel->AddPedestalN(module,strip, | |
138 | ped->GetPedestalN(module,strip)); | |
139 | if(bad->GetBadChannelP(module,strip)) | |
140 | badch->AddBadChannelP(module,strip, | |
141 | bad->GetBadChannelP(module,strip)); | |
142 | if(bad->GetBadChannelN(module,strip)) | |
143 | badch->AddBadChannelN(module,strip, | |
144 | bad->GetBadChannelN(module,strip)); | |
145 | } | |
5ca85244 | 146 | } |
a5edfa6f | 147 | |
148 | f->Close(); delete f; | |
5ca85244 | 149 | |
150 | } else { | |
151 | Log("GetFile error!"); | |
152 | delete list; | |
375ec901 | 153 | return 6; |
5ca85244 | 154 | } // if filename |
155 | } // end iteration over LDCs | |
156 | ||
157 | delete list; | |
158 | } else { | |
159 | Log("GetFileSources error!"); | |
160 | if(list) delete list; | |
375ec901 | 161 | return 7; |
5ca85244 | 162 | } // if list |
163 | ||
61a57d07 | 164 | //Now we have to store the final CDB file |
165 | AliCDBMetaData metaData; | |
166 | metaData.SetBeamPeriod(0); | |
167 | metaData.SetResponsible("Enrico Fragiacomo"); | |
168 | metaData.SetComment("Fills noise, pedestal and bad channels TObjArray"); | |
169 | ||
170 | if(!Store("Calib", "NoiseSSD", (TObject *)calib, &metaData, 0, 1)) { | |
a5edfa6f | 171 | Log("no store"); |
5ca85244 | 172 | return 1; |
a5edfa6f | 173 | } |
174 | ||
61a57d07 | 175 | if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) { |
a5edfa6f | 176 | Log("no store"); |
177 | return 1; | |
178 | } | |
179 | ||
75b3c0e1 | 180 | if(!StoreReferenceData("Ref","PedestalSSD", (TObject*)pedel, &metaData)) { |
a5edfa6f | 181 | Log("no store"); |
182 | return 1; | |
183 | } | |
184 | ||
51e983b7 | 185 | } // end if pedestal run |
5ca85244 | 186 | else { |
187 | Log("Nothing to do"); | |
188 | return 0; | |
189 | } | |
190 | ||
191 | Log("Database updated"); | |
192 | return 0; // 0 means success | |
193 | ||
194 | } | |
195 |