1 ///////////////////////////////////////////////
2 // Author: Henrik Tydesjo //
3 // Preprocessor Class for the SPD //
5 ///////////////////////////////////////////////
7 #include "AliITSPreprocessorSPD.h"
8 #include "AliITSCalibrationSPD.h"
9 #include "AliITSOnlineCalibrationSPD.h"
10 #include "AliITSOnlineCalibrationSPDhandler.h"
11 #include "AliCDBManager.h"
12 #include "AliCDBStorage.h"
13 #include "AliCDBEntry.h"
14 #include "AliCDBMetaData.h"
15 #include "AliShuttleInterface.h"
17 #include <TTimeStamp.h>
18 #include <TObjString.h>
21 ClassImp(AliITSPreprocessorSPD)
23 //______________________________________________________________________________________________
24 AliITSPreprocessorSPD::AliITSPreprocessorSPD(AliShuttleInterface* shuttle) :
25 AliPreprocessor("SPD", shuttle)
30 //______________________________________________________________________________________________
31 AliITSPreprocessorSPD::~AliITSPreprocessorSPD()
36 //______________________________________________________________________________________________
37 void AliITSPreprocessorSPD::Initialize(Int_t run, UInt_t startTime,
41 AliPreprocessor::Initialize(run, startTime, endTime);
43 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
44 TTimeStamp(startTime).AsString(),
45 TTimeStamp(endTime).AsString()));
48 //______________________________________________________________________________________________
49 UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
51 // Do the actual preprocessing
54 // *** CHECK RUN TYPE ***
56 TString runType = GetRunType();
57 if(runType != "SPD_STANDALONE_CALIBRATION") {
63 // *** REFERENCE DATA ***
65 // Store the container files as reference data (one file for each equipment)
66 for (UInt_t eq=0; eq<20; eq++) {
68 sprintf(id,"SPD_reference_%d",eq);
69 TList* list = GetFileSources(kDAQ,id); // (the id should be unique, so always 1 file)
71 TObjString* fileNameEntry = (TObjString*) list->First();
72 if (fileNameEntry!=NULL) {
73 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
75 sprintf(refCAT,"SPDref_eq_%d.root",eq);
76 if (!StoreReferenceFile(fileName.Data(),refCAT)) {
86 // Read old calibration
87 AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "CalibSPD");
90 spdEntry = (TObjArray*)cdbEntry->GetObject();
91 if(!spdEntry) return 1;
94 Log("Old calibration not found in database. This is required for further processing.");
98 TString pwd = gSystem->pwd(); // remember the working directory, to cd back later
99 TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir());
101 // Retrieve and unpack tared calibration files from FXS
102 TList* list = GetFileSources(kDAQ,"SPD_noisy");
105 while (list->At(index)!=NULL) {
106 TObjString* fileNameEntry = (TObjString*) list->At(index);
107 TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data());
108 gSystem->cd(tempDir.Data());
110 sprintf(command,"tar -xf %s",fileName.Data());
111 gSystem->Exec(command);
116 gSystem->cd(pwd.Data());
118 // Update the database entries if needed
119 UInt_t nrUpdatedMods = 0;
120 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
122 sprintf(fileLoc,"%s",AliShuttleInterface::GetShuttleTempDir());
123 handler->SetFileLocation(fileLoc);
124 for (Int_t module=0; module<240; module++) {
125 handler->SetModuleNr(module);
126 if (handler->ReadFromFile()) {
127 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy() );
128 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray() );
133 if (nrUpdatedMods>0) {
134 Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods));
135 // Store the cdb entry
136 AliCDBMetaData metaData;
137 metaData.SetBeamPeriod(0);
138 metaData.SetResponsible("Henrik Tydesjo");
139 metaData.SetComment("Preprocessor test for SPD.");
140 if (!Store("Calib", "CalibSPD", spdEntry, &metaData, 0, kTRUE)) {
144 Log("Database updated.");
147 return 0; // 0 means success