]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSPreprocessorSSD.cxx
commented define _ClusterTopology_ - to be used only for the special productions
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSSD.cxx
... / ...
CommitLineData
1//
2// Author: Enrico Fragiacomo
3// Date: 13/10/2006
4//
5// SHUTTLE preprocessing class for SSD calibration files
6
7/* $Id$ */
8
9#include "AliITSPreprocessorSSD.h"
10
11#include "AliCDBMetaData.h"
12#include "AliLog.h"
13#include "TFile.h"
14
15#include <TTimeStamp.h>
16#include <TObjString.h>
17
18#include "AliITSRawStreamSSD.h"
19#include "AliITSNoiseSSDv2.h"
20#include "AliITSPedestalSSDv2.h"
21#include "AliITSBadChannelsSSDv2.h"
22#include <Riostream.h>
23
24
25const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698;
26
27ClassImp(AliITSPreprocessorSSD)
28
29//-----------------------------------------------------------------------
30AliITSPreprocessorSSD::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//______________________________________________________________________________________________
42void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime,
43 UInt_t endTime)
44{
45 // initialize
46
47 AliPreprocessor::Initialize(run, startTime, endTime);
48
49 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
50 TTimeStamp(startTime).AsString(),
51 TTimeStamp(endTime).AsString()));
52
53}
54
55//______________________________________________________________________________________________
56UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/)
57{
58
59 // Note. To be modified: dcsAliasMap is not needed but I can not get rid
60 // of it unless the base class AliPreprocessor is modified accordingly.
61
62 // TObjArray calib_array(fgkNumberOfSSD);
63 //TObjArray badch_array(fgkNumberOfSSD);
64 //TObjArray ped_array(fgkNumberOfSSD);
65 //Float_t noise=0, gain=0;
66
67 //---------------------------------------
68 // initialize the calibration objects
69 AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
70 AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
71 AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
72
73 TString runType = GetRunType();
74 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
75
76 }
77 else if(runType == "PEDESTAL") {
78
79 TList* list = GetFileSources(kDAQ, "CALIBRATION");
80 if (list && list->GetEntries() > 0)
81 {
82 Log("The following sources produced files with the id CALIBRATION");
83 list->Print();
84
85 // create iterator over list of LDCs (provides list of TObjString)
86 TIter next(list);
87 TObjString *ok;
88
89 // expect to iterate 3 times (LDC0, LDC1, LDC2)
90 while ( (ok = (TObjString*) next()) ) {
91
92 TString key = ok->String();
93
94 TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data());
95 if (fileName.Length() > 0) {
96
97 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
98
99 TFile *f = new TFile(fileName.Data());
100 if(!f || !f->IsOpen()){
101 Log("Error opening file!");
102 delete list;
103 return 2;
104 }
105
106 AliITSNoiseSSDv2 *cal;
107 f->GetObject("AliITSNoiseSSDv2;1", cal);
108 if(!cal) {
109 Log("File does not contain expected data for the noise!");
110 delete list;
111 return 3;
112 }
113 AliITSPedestalSSDv2 *ped;
114 f->GetObject("AliITSPedestalSSDv2;1", ped);
115 if(!ped) {
116 Log("File does not contain expected data for the pedestals!");
117 delete list;
118 return 5;
119 }
120 AliITSBadChannelsSSDv2 *bad;
121 f->GetObject("AliITSBadChannelsSSDv2;1", bad);
122 if(!bad) {
123 Log("File does not contain expected data for bad channels !");
124 delete list;
125 return 4;
126 }
127
128 for(Int_t module=0; module<fgkNumberOfSSD; module++) {
129 for(Int_t strip=0; strip<768; strip++) {
130 if(cal->GetNoiseP(module,strip))
131 calib->AddNoiseP(module,strip,cal->GetNoiseP(module,strip));
132 if(cal->GetNoiseN(module,strip))
133 calib->AddNoiseN(module,strip,cal->GetNoiseN(module,strip));
134 if(ped->GetPedestalP(module,strip))
135 pedel->AddPedestalP(module,strip,
136 ped->GetPedestalP(module,strip));
137 if(ped->GetPedestalN(module,strip))
138 pedel->AddPedestalN(module,strip,
139 ped->GetPedestalN(module,strip));
140 if(bad->GetBadChannelP(module,strip))
141 badch->AddBadChannelP(module,strip,
142 bad->GetBadChannelP(module,strip));
143 if(bad->GetBadChannelN(module,strip))
144 badch->AddBadChannelN(module,strip,
145 bad->GetBadChannelN(module,strip));
146 }
147 }
148
149 f->Close(); delete f;
150
151 } else {
152 Log("GetFile error!");
153 delete list;
154 return 6;
155 } // if filename
156 } // end iteration over LDCs
157
158 delete list;
159 } else {
160 Log("GetFileSources error!");
161 if(list) delete list;
162 return 7;
163 } // if list
164
165 //Now we have to store the final CDB file
166 AliCDBMetaData metaData;
167 metaData.SetBeamPeriod(0);
168 metaData.SetResponsible("Enrico Fragiacomo");
169 metaData.SetComment("Fills noise, pedestal and bad channels TObjArray");
170
171 if(!Store("Calib", "NoiseSSD", (TObject *)calib, &metaData, 0, 1)) {
172 Log("no store");
173 return 1;
174 }
175
176 if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
177 Log("no store");
178 return 1;
179 }
180
181 if(!StoreReferenceData("Ref","PedestalSSD", (TObject*)pedel, &metaData)) {
182 Log("no store");
183 return 1;
184 }
185
186 } // end if pedestal run
187 else {
188 Log("Nothing to do");
189 return 0;
190 }
191
192 Log("Database updated");
193 return 0; // 0 means success
194
195}
196