]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPreprocessorSPD.cxx
Put index into track's name instead of its label.
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSPD.cxx
CommitLineData
b15de2d2 1///////////////////////////////////////////////
2// Author: Henrik Tydesjo //
3// Preprocessor Class for the SPD //
4// //
5///////////////////////////////////////////////
3f0e013c 6
3f0e013c 7#include "AliITSPreprocessorSPD.h"
b15de2d2 8#include "AliITSCalibrationSPD.h"
b15de2d2 9#include "AliITSOnlineCalibrationSPDhandler.h"
03fc6773 10#include "AliCDBEntry.h"
b15de2d2 11#include "AliCDBMetaData.h"
03fc6773 12#include "AliShuttleInterface.h"
b15de2d2 13#include "AliLog.h"
03fc6773 14#include <TTimeStamp.h>
15#include <TObjString.h>
16#include <TSystem.h>
53ae21ce 17#include <TList.h>
3f0e013c 18
b15de2d2 19ClassImp(AliITSPreprocessorSPD)
3f0e013c 20
b15de2d2 21//______________________________________________________________________________________________
22AliITSPreprocessorSPD::AliITSPreprocessorSPD(AliShuttleInterface* shuttle) :
23 AliPreprocessor("SPD", shuttle)
3f0e013c 24{
b15de2d2 25 // constructor
3f0e013c 26}
27
b15de2d2 28//______________________________________________________________________________________________
29AliITSPreprocessorSPD::~AliITSPreprocessorSPD()
3f0e013c 30{
b15de2d2 31 // destructor
3f0e013c 32}
33
b15de2d2 34//______________________________________________________________________________________________
35void AliITSPreprocessorSPD::Initialize(Int_t run, UInt_t startTime,
36 UInt_t endTime)
3f0e013c 37{
b15de2d2 38 // initialize
39 AliPreprocessor::Initialize(run, startTime, endTime);
3f0e013c 40
b15de2d2 41 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
42 TTimeStamp(startTime).AsString(),
43 TTimeStamp(endTime).AsString()));
3f0e013c 44}
fcf95fc7 45
b15de2d2 46//______________________________________________________________________________________________
0c0426a2 47UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
fcf95fc7 48{
b15de2d2 49 // Do the actual preprocessing
fcf95fc7 50
03fc6773 51
53ae21ce 52 // *** GET RUN TYPE ***
ad18504e 53
54 TString runType = GetRunType();
03fc6773 55
6727e2db 56 UInt_t nrEqForScan = 0;
57 UInt_t nrEqForPhysN = 0;
58 UInt_t nrEqForPhysD = 0;
ad18504e 59
6727e2db 60 // ******************************************************************************************** //
53ae21ce 61 // *** REFERENCE DATA *** //
62
63 // Standalone runs:
64 if (runType == "DAQ_MIN_TH_SCAN" ||
65 runType == "DAQ_MEAN_TH_SCAN" ||
66 runType == "DAQ_UNIFORMITY_SCAN" ||
67 runType == "DAQ_NOISY_PIX_SCAN" ||
68 runType == "DAQ_PIX_DELAY_SCAN" ||
69 runType == "DAQ_FO_UNIF_SCAN") {
6727e2db 70 // Store the scan container files as reference data (0 or 1 file for each equipment)
53ae21ce 71 for (UInt_t eq=0; eq<20; eq++) {
6727e2db 72 TString id = Form("SPD_ref_scan_%d",eq);
53ae21ce 73 TList* list = GetFileSources(kDAQ,id.Data()); // (the id should be unique, so always 1 file)
74 if (list) {
75 TObjString* fileNameEntry = (TObjString*) list->First();
76 if (fileNameEntry!=NULL) {
6727e2db 77 nrEqForScan++;
53ae21ce 78 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
6727e2db 79 TString refCAT = Form("SPD_ref_scan_eq_%d",eq);
53ae21ce 80 if (!StoreReferenceFile(fileName.Data(),refCAT.Data())) {
81 Log(Form("Failed to store reference file %s.",fileName.Data()));
82 return 1;
83 }
0c0426a2 84 }
85 }
86 }
87 }
03fc6773 88
53ae21ce 89 // Physics runs (online monitoring):
90 if (runType == "PHYSICS") {
6727e2db 91 // Store the phys "per run" container files as reference data (0 or 1 file for each equipment)
92 for (UInt_t eq=0; eq<20; eq++) {
93 TString id = Form("SPD_ref_phys_%d",eq);
94 TList* list = GetFileSources(kDAQ,id.Data()); // (the id should be unique, so always 1 file)
95 if (list) {
96 TObjString* fileNameEntry = (TObjString*) list->First();
97 if (fileNameEntry!=NULL) {
98 nrEqForPhysN++;
99 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
100 TString refCAT = Form("SPD_ref_phys_eq_%d",eq);
101 if (!StoreReferenceFile(fileName.Data(),refCAT.Data())) {
102 Log(Form("Failed to store reference file %s.",fileName.Data()));
103 return 1;
104 }
105 }
106 }
107 }
108 // Store the phys "dead" container files as reference data (0 or 1 file for each equipment)
109 for (UInt_t eq=0; eq<20; eq++) {
110 TString id = Form("SPD_ref_phys_dead_%d",eq);
111 TList* list = GetFileSources(kDAQ,id.Data()); // (the id should be unique, so always 1 file)
112 if (list) {
113 TObjString* fileNameEntry = (TObjString*) list->First();
114 if (fileNameEntry!=NULL) {
115 nrEqForPhysD++;
116 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
117 TString refCAT = Form("SPD_ref_phys_dead_eq_%d",eq);
118 if (!StoreReferenceFile(fileName.Data(),refCAT.Data())) {
119 Log(Form("Failed to store reference file %s.",fileName.Data()));
120 return 1;
121 }
122 }
123 }
124 }
53ae21ce 125 }
03fc6773 126
6727e2db 127 // ******************************************************************************************** //
03fc6773 128
03fc6773 129
53ae21ce 130 // *** NOISY AND DEAD DATA *** //
03fc6773 131
6727e2db 132 // Standalone runs:
133 if (runType == "DAQ_NOISY_PIX_SCAN") {
134 // Retrieve and unpack tared calibration files from FXS
135 TList* list = GetFileSources(kDAQ,"SPD_scan_noisy");
136 if (list) {
137 UInt_t index = 0;
138 while (list->At(index)!=NULL) {
139 TObjString* fileNameEntry = (TObjString*) list->At(index);
140 TString fileName = GetFile(kDAQ, "SPD_scan_noisy", fileNameEntry->GetString().Data());
141 TString command = Form("tar -xf %s",fileName.Data());
142 gSystem->Exec(command.Data());
143 index++;
144 }
145 }
146 // Create new database entries
147 TObjArray* spdEntryNoisy = new TObjArray(240);
148 spdEntryNoisy->SetOwner(kTRUE);
149 for(UInt_t module=0; module<240; module++){
150 AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
151 spdEntryNoisy->Add(calObj);
152 }
153 // Add noisy from the copied FXS files
154 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
155 TString fileLoc = ".";
156 handler->SetFileLocation(fileLoc.Data());
157 handler->ReadNoisyFromFiles();
158 for (Int_t module=0; module<240; module++) {
159 ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetNrBad( handler->GetNrNoisy(module) );
160 ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetBadList( handler->GetNoisyArray(module) );
161 }
162 delete handler;
163 // Store the new calibration objects in OCDB
164 Log("Noisy lists (scan) will be stored...");
165 AliCDBMetaData metaData;
166 metaData.SetBeamPeriod(0);
167 metaData.SetResponsible("Henrik Tydesjo");
168 metaData.SetComment("Created by SPD PreProcessor");
169 // validity for this run until infinity
170 if (!Store("Calib", "SPDNoisy", spdEntryNoisy, &metaData, 0, kTRUE)) {
171 Log("Failed to store calibration data.");
172 return 1;
173 }
174 Log("Database updated.");
175 delete spdEntryNoisy;
176 }
177
178 // Physics runs (online monitoring):
179 else if (runType == "PHYSICS") {
180
181 // Noisy pixels:
182 // Read noisy from previous calibration
183 AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "SPDNoisy");
184 TObjArray* spdEntryNoisy;
53ae21ce 185 if(cdbEntry) {
6727e2db 186 spdEntryNoisy = (TObjArray*)cdbEntry->GetObject();
187 if(!spdEntryNoisy) return 1;
03fc6773 188 }
53ae21ce 189 else {
190 Log("Old calibration not found in database. This is required for further processing.");
0c0426a2 191 return 1;
192 }
6727e2db 193 AliITSOnlineCalibrationSPDhandler* handOld = new AliITSOnlineCalibrationSPDhandler();
194 handOld->ReadNoisyFromCalibObj(spdEntryNoisy);
195 // Retrieve and unpack tared calibration files from FXS
196 TList* listN = GetFileSources(kDAQ,"SPD_phys_noisy");
197 if (listN) {
198 UInt_t index = 0;
199 while (listN->At(index)!=NULL) {
200 TObjString* fileNameEntry = (TObjString*) listN->At(index);
201 TString fileName = GetFile(kDAQ, "SPD_phys_noisy", fileNameEntry->GetString().Data());
202 TString command = Form("tar -xf %s",fileName.Data());
203 gSystem->Exec(command.Data());
204 index++;
53ae21ce 205 }
6727e2db 206 }
207 AliITSOnlineCalibrationSPDhandler* handNew = new AliITSOnlineCalibrationSPDhandler();
208 handNew->SetFileLocation(".");
209 handNew->ReadNoisyFromFiles();
210 // add the new list to the old one
211 UInt_t nrNewNoisy = handOld->AddNoisyFrom(handNew);
212 // If new noisy pixels were found: Update calibration objects
213 if (nrNewNoisy>0) {
53ae21ce 214 for (Int_t module=0; module<240; module++) {
6727e2db 215 ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetNrBad( handOld->GetNrNoisy(module) );
216 ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetBadList( handOld->GetNoisyArray(module) );
53ae21ce 217 }
6727e2db 218 // Store the new calibration objects in OCDB
219 Log("Noisy lists (phys) will be stored...");
220 AliCDBMetaData metaData;
221 metaData.SetBeamPeriod(0);
222 metaData.SetResponsible("Henrik Tydesjo");
223 metaData.SetComment("Created by SPD PreProcessor");
224 // validity for this run only
225 if (!Store("Calib", "SPDNoisy", spdEntryNoisy, &metaData, 0, kFALSE)) {
226 Log("Failed to store calibration data.");
227 return 1;
53ae21ce 228 }
6727e2db 229 Log("Database updated.");
53ae21ce 230 }
6727e2db 231 delete handNew;
53ae21ce 232
6727e2db 233 // Dead pixels:
234 // Retrieve and unpack tared calibration files from FXS
235 TList* listD = GetFileSources(kDAQ,"SPD_phys_dead");
236 if (listD) {
237 UInt_t index = 0;
238 while (listD->At(index)!=NULL) {
239 TObjString* fileNameEntry = (TObjString*) listD->At(index);
240 TString fileName = GetFile(kDAQ, "SPD_phys_dead", fileNameEntry->GetString().Data());
241 TString command = Form("tar -xf %s",fileName.Data());
242 gSystem->Exec(command.Data());
243 index++;
244 }
53ae21ce 245 }
6727e2db 246 // Create new database entries
247 TObjArray* spdEntryDead = new TObjArray(240);
248 spdEntryDead->SetOwner(kTRUE);
249 for(UInt_t module=0; module<240; module++){
250 AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
251 spdEntryDead->Add(calObj);
252 }
253 // Add dead from the copied FXS files
254 handOld->SetFileLocation(".");
255 handOld->ReadDeadFromFiles();
256 for (Int_t module=0; module<240; module++) {
257 ((AliITSCalibrationSPD*) spdEntryDead->At(module)) -> SetNrBad( handOld->GetNrDead(module) );
258 ((AliITSCalibrationSPD*) spdEntryDead->At(module)) -> SetBadList( handOld->GetDeadArray(module) );
259 }
260 delete handOld;
261 // Store the new calibration objects in OCDB
262 Log("Dead lists (phys) will be stored...");
263 AliCDBMetaData metaData;
264 metaData.SetBeamPeriod(0);
265 metaData.SetResponsible("Henrik Tydesjo");
266 metaData.SetComment("Created by SPD PreProcessor");
267 // validity for this run only
268 if (!Store("Calib", "SPDDead", spdEntryDead, &metaData, 0, kFALSE)) {
269 Log("Failed to store calibration data.");
270 return 1;
271 }
272 Log("Database updated.");
273 delete spdEntryDead;
53ae21ce 274
03fc6773 275 }
276
03fc6773 277
53ae21ce 278 return 0; // 0 means success
03fc6773 279
fcf95fc7 280}
b15de2d2 281