]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSPreprocessorSSD.cxx
Adding more information to the debug output
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSSD.cxx
... / ...
CommitLineData
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 "AliITSNoiseSSDv2.h"
12#include "AliITSPedestalSSDv2.h"
13#include "AliITSBadChannelsSSDv2.h"
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
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
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//______________________________________________________________________________________________
55UInt_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
61 // TObjArray calib_array(fgkNumberOfSSD);
62 //TObjArray badch_array(fgkNumberOfSSD);
63 //TObjArray ped_array(fgkNumberOfSSD);
64 //Float_t noise=0, gain=0;
65
66 //---------------------------------------
67 // initialize the calibration objects
68 AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
69 AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
70 AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
71
72 TString runType = GetRunType();
73 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
74
75 }
76 else if(runType == "PEDESTAL") {
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
105 AliITSNoiseSSDv2 *cal;
106 f->GetObject("AliITSNoiseSSDv2;1", cal);
107 if(!cal) {
108 Log("File does not contain expected data for the noise!");
109 delete list;
110 return 3;
111 }
112 AliITSPedestalSSDv2 *ped;
113 f->GetObject("AliITSPedestalSSDv2;1", ped);
114 if(!ped) {
115 Log("File does not contain expected data for the pedestals!");
116 delete list;
117 return 5;
118 }
119 AliITSBadChannelsSSDv2 *bad;
120 f->GetObject("AliITSBadChannelsSSDv2;1", bad);
121 if(!bad) {
122 Log("File does not contain expected data for bad channels !");
123 delete list;
124 return 4;
125 }
126
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 }
146 }
147
148 f->Close(); delete f;
149
150 } else {
151 Log("GetFile error!");
152 delete list;
153 return 6;
154 } // if filename
155 } // end iteration over LDCs
156
157 delete list;
158 } else {
159 Log("GetFileSources error!");
160 if(list) delete list;
161 return 7;
162 } // if list
163
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)) {
171 Log("no store");
172 return 1;
173 }
174
175 if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
176 Log("no store");
177 return 1;
178 }
179
180 if(!StoreReferenceData("Calib","PedestalSSD", (TObject*)pedel, &metaData)) {
181 Log("no store");
182 return 1;
183 }
184
185 } // end if pedestal run
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