1 ///////////////////////////////////////////////
2 // Author: Henrik Tydesjo //
3 // Preprocessor Class for the SPD //
5 ///////////////////////////////////////////////
7 #include "AliITSPreprocessorSPD.h"
8 #include "AliITSCalibrationSPD.h"
9 #include "AliITSOnlineCalibrationSPDhandler.h"
10 #include "AliCDBEntry.h"
11 #include "AliCDBMetaData.h"
12 #include "AliShuttleInterface.h"
14 #include <TTimeStamp.h>
15 #include <TObjString.h>
19 ClassImp(AliITSPreprocessorSPD)
21 //______________________________________________________________________________________________
22 AliITSPreprocessorSPD::AliITSPreprocessorSPD(AliShuttleInterface* shuttle) :
23 AliPreprocessor("SPD", shuttle)
28 //______________________________________________________________________________________________
29 AliITSPreprocessorSPD::~AliITSPreprocessorSPD()
34 //______________________________________________________________________________________________
35 void AliITSPreprocessorSPD::Initialize(Int_t run, UInt_t startTime,
39 AliPreprocessor::Initialize(run, startTime, endTime);
41 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
42 TTimeStamp(startTime).AsString(),
43 TTimeStamp(endTime).AsString()));
46 //______________________________________________________________________________________________
47 UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
49 // Do the actual preprocessing
52 // *** GET RUN TYPE ***
54 TString runType = GetRunType();
58 // *** REFERENCE DATA *** //
61 if (runType == "DAQ_MIN_TH_SCAN" ||
62 runType == "DAQ_MEAN_TH_SCAN" ||
63 runType == "DAQ_UNIFORMITY_SCAN" ||
64 runType == "DAQ_NOISY_PIX_SCAN" ||
65 runType == "DAQ_PIX_DELAY_SCAN" ||
66 runType == "DAQ_FO_UNIF_SCAN") {
67 // Store the scan container files as reference data (one file for each equipment)
68 for (UInt_t eq=0; eq<20; eq++) {
69 TString id = Form("SPD_reference_%d",eq);
70 TList* list = GetFileSources(kDAQ,id.Data()); // (the id should be unique, so always 1 file)
72 TObjString* fileNameEntry = (TObjString*) list->First();
73 if (fileNameEntry!=NULL) {
74 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
75 TString refCAT = Form("SPDref_eq_%d.root",eq);
76 if (!StoreReferenceFile(fileName.Data(),refCAT.Data())) {
77 Log(Form("Failed to store reference file %s.",fileName.Data()));
85 // Physics runs (online monitoring):
86 if (runType == "PHYSICS") {
87 // *** code to be written *** //
92 // *** NOISY AND DEAD DATA *** //
94 if (runType == "DAQ_NOISY_PIX_SCAN" || runType == "PHYSICS") {
95 // Read old calibration
96 AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "CalibSPD");
99 spdEntry = (TObjArray*)cdbEntry->GetObject();
100 if(!spdEntry) return 1;
103 Log("Old calibration not found in database. This is required for further processing.");
108 if (runType == "DAQ_NOISY_PIX_SCAN") {
109 UInt_t nrUpdatedMods = 0;
110 // Retrieve and unpack tared calibration files from FXS
111 TList* list = GetFileSources(kDAQ,"SPD_noisy");
114 while (list->At(index)!=NULL) {
115 TObjString* fileNameEntry = (TObjString*) list->At(index);
116 TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data());
117 TString command = Form("tar -xf %s",fileName.Data());
118 gSystem->Exec(command.Data());
122 // Update the database entries for the modules that were scanned
123 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
124 TString fileLoc = ".";
125 handler->SetFileLocation(fileLoc.Data());
126 for (Int_t module=0; module<240; module++) {
127 if (handler->ReadFromFile(module)) {
128 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy(module) );
129 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray(module) );
134 // Store the new calibration objects (if any modifications were made) in OCDB
135 if (nrUpdatedMods>0) {
136 Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods));
137 AliCDBMetaData metaData;
138 metaData.SetBeamPeriod(0);
139 metaData.SetResponsible("Henrik Tydesjo");
140 metaData.SetComment("Preprocessor test for SPD.");
141 if (!Store("Calib", "CalibSPD", spdEntry, &metaData, 0, kTRUE)) {
142 Log("Failed to store calibration data.");
145 Log("Database updated.");
149 // Physics runs (online monitoring):
150 if (runType == "PHYSICS") {
151 // *** code to be written *** //
159 return 0; // 0 means success