]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPreprocessorSSD.cxx
compilation warnings
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSSD.cxx
CommitLineData
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 25const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698;
26
5ca85244 27ClassImp(AliITSPreprocessorSSD)
28
29//______________________________________________________________________________________________
30void 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//______________________________________________________________________________________________
43UInt_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;
375ec901 92 return 3;
a5edfa6f 93 }
375ec901 94
95 //---------------------------------------
96 // in case some module was not calibrated!
97 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
98 AliITSNoiseSSD *calib = new AliITSNoiseSSD();
99 calib->SetMod((UShort_t) i+500);
100 calib->SetNNoiseP(768);
101 calib->SetNNoiseN(768);
102 // take a reasonable averaged value for the noise on P- and N-side strips
103 for(Int_t j=0; j<768; j++) {
104 calib->AddNoiseP(j,2.);
105 calib->AddNoiseN(j,4.);
106 }
107 calib_array.AddAt(calib,i);
108 }
109 //-----------------------------------------
110
5ca85244 111 Int_t nmod = cal->GetEntries();
a5edfa6f 112 for(Int_t mod=0; mod<nmod; mod++) {
113 AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(mod);
114 if((calib->GetMod()<500)||(calib->GetMod()>2198)) continue;
115 calib_array.AddAt(calib,calib->GetMod()-500);
116 }
5ca85244 117
375ec901 118
119 //---------------------------------------
120 // in case some module was not calibrated!
121 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
122 AliITSBadChannelsSSD *badch = new AliITSBadChannelsSSD();
123 badch->SetMod((UShort_t) i+500);
124 badch_array.AddAt(badch,i);
125 }
126 //-----------------------------------------
127
128 //-----------------------------------------
a5edfa6f 129 TObjArray *bad;
130 f->GetObject("BadChannels;1", bad);
131 if(!bad) {
132 Log("File does not contain expected data for bad channels !");
133 delete list;
375ec901 134 return 4;
a5edfa6f 135 }
136 nmod = bad->GetEntries();
5ca85244 137 for(Int_t mod=0; mod<nmod; mod++) {
a5edfa6f 138 AliITSBadChannelsSSD *badch = (AliITSBadChannelsSSD*) bad->At(mod);
139 if((badch->GetMod()<500)||(badch->GetMod()>2198)) continue;
140 badch_array.AddAt(badch,badch->GetMod()-500);
141 }
5ca85244 142
375ec901 143 //---------------------------------------
144 // in case some module was not calibrated!
145 for(Int_t i=0; i<fgkNumberOfSSD; i++) {
146 AliITSPedestalSSD *pedel = new AliITSPedestalSSD();
147 pedel->SetMod((UShort_t) i+500);
148 pedel->SetNPedestalP(768);
149 pedel->SetNPedestalN(768);
150 for(Int_t j=0; j<768; j++) {
151 pedel->AddPedestalP(j,0.);
152 pedel->AddPedestalN(j,0.);
153 }
154 ped_array.AddAt(pedel,i);
155 }
156 //-----------------------------------------
157
a5edfa6f 158 TObjArray *ped;
159 f->GetObject("Pedestal;1", ped);
160 if(!ped) {
161 Log("File does not contain expected data for the pedestals!");
162 delete list;
375ec901 163 return 5;
a5edfa6f 164 }
165 nmod = ped->GetEntries();
166 for(Int_t mod=0; mod<nmod; mod++) {
167 AliITSPedestalSSD *pedel = (AliITSPedestalSSD*) ped->At(mod);
168 if((pedel->GetMod()<500)||(pedel->GetMod()>2198)) continue;
169 ped_array.AddAt(pedel,pedel->GetMod()-500);
5ca85244 170 }
a5edfa6f 171
172 f->Close(); delete f;
5ca85244 173
174 } else {
175 Log("GetFile error!");
176 delete list;
375ec901 177 return 6;
5ca85244 178 } // if filename
179 } // end iteration over LDCs
180
181 delete list;
182 } else {
183 Log("GetFileSources error!");
184 if(list) delete list;
375ec901 185 return 7;
5ca85244 186 } // if list
187
188 //Now we have to store the final CDB file
189 AliCDBMetaData metaData;
190 metaData.SetBeamPeriod(0);
191 metaData.SetResponsible("Enrico Fragiacomo");
a5edfa6f 192 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
5ca85244 193
a5edfa6f 194 if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) {
195 Log("no store");
5ca85244 196 return 1;
a5edfa6f 197 }
198
199 if(!Store("Calib", "BadChannelsSSD", &badch_array, &metaData, 0, 1)) {
200 Log("no store");
201 return 1;
202 }
203
204 if(!StoreReferenceData("Calib","PedestalSSD", &ped_array, &metaData)) {
205 Log("no store");
206 return 1;
207 }
208
5ca85244 209 } // end if noise_run
210 else {
211 Log("Nothing to do");
212 return 0;
213 }
214
215 Log("Database updated");
216 return 0; // 0 means success
217
218}
219