]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSrec/AliITSPreprocessorSSD.cxx
MUON DAs
[u/mrichter/AliRoot.git] / ITS / ITSrec / AliITSPreprocessorSSD.cxx
CommitLineData
6f67f5b3 1//
2// Author: Enrico Fragiacomo
3// Date: 13/10/2006
4//
5// SHUTTLE preprocessing class for SSD calibration files
6
7/* $Id$ */
8
5ca85244 9#include "AliITSPreprocessorSSD.h"
51e983b7 10
5ca85244 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"
88128115 19#include "AliITSNoiseSSDv2.h"
20#include "AliITSPedestalSSDv2.h"
21#include "AliITSBadChannelsSSDv2.h"
5ca85244 22#include <Riostream.h>
23
24
a5edfa6f 25const Int_t AliITSPreprocessorSSD::fgkNumberOfSSD = 1698;
26
5ca85244 27ClassImp(AliITSPreprocessorSSD)
28
51e983b7 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
6f67f5b3 41//______________________________________________________________________________________________
5ca85244 42void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime,
43 UInt_t endTime)
44{
6f67f5b3 45 // initialize
46
5ca85244 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
ced4d9bc 62 // TObjArray calib_array(fgkNumberOfSSD);
63 //TObjArray badch_array(fgkNumberOfSSD);
64 //TObjArray ped_array(fgkNumberOfSSD);
5ca85244 65 //Float_t noise=0, gain=0;
c9a38d3d 66
ced4d9bc 67 //---------------------------------------
68 // initialize the calibration objects
88128115 69 AliITSNoiseSSDv2 *calib = new AliITSNoiseSSDv2();
70 AliITSBadChannelsSSDv2 *badch = new AliITSBadChannelsSSDv2();
71 AliITSPedestalSSDv2 *pedel = new AliITSPedestalSSDv2();
ced4d9bc 72
5ca85244 73 TString runType = GetRunType();
c9a38d3d 74 if(runType == "ELECTRONICS_CALIBRATION_RUN") {
75
5ca85244 76 }
c96050be 77 else if(runType == "PEDESTAL") {
5ca85244 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
88128115 106 AliITSNoiseSSDv2 *cal;
107 f->GetObject("AliITSNoiseSSDv2;1", cal);
5ca85244 108 if(!cal) {
a5edfa6f 109 Log("File does not contain expected data for the noise!");
5ca85244 110 delete list;
375ec901 111 return 3;
a5edfa6f 112 }
88128115 113 AliITSPedestalSSDv2 *ped;
114 f->GetObject("AliITSPedestalSSDv2;1", ped);
ced4d9bc 115 if(!ped) {
116 Log("File does not contain expected data for the pedestals!");
117 delete list;
118 return 5;
119 }
88128115 120 AliITSBadChannelsSSDv2 *bad;
121 f->GetObject("AliITSBadChannelsSSDv2;1", bad);
a5edfa6f 122 if(!bad) {
123 Log("File does not contain expected data for bad channels !");
124 delete list;
375ec901 125 return 4;
a5edfa6f 126 }
5ca85244 127
ced4d9bc 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 }
5ca85244 147 }
a5edfa6f 148
149 f->Close(); delete f;
5ca85244 150
151 } else {
152 Log("GetFile error!");
153 delete list;
375ec901 154 return 6;
5ca85244 155 } // if filename
156 } // end iteration over LDCs
157
158 delete list;
159 } else {
160 Log("GetFileSources error!");
161 if(list) delete list;
375ec901 162 return 7;
5ca85244 163 } // if list
164
61a57d07 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)) {
a5edfa6f 172 Log("no store");
5ca85244 173 return 1;
a5edfa6f 174 }
175
61a57d07 176 if(!Store("Calib", "BadChannelsSSD", (TObject*)badch, &metaData, 0, 1)) {
a5edfa6f 177 Log("no store");
178 return 1;
179 }
180
75b3c0e1 181 if(!StoreReferenceData("Ref","PedestalSSD", (TObject*)pedel, &metaData)) {
a5edfa6f 182 Log("no store");
183 return 1;
184 }
185
51e983b7 186 } // end if pedestal run
5ca85244 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