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
56 // // *** REFERENCE DATA ***
58 // // Store the container files as reference data (one for each equipment)
59 // for (UInt_t eq=0; eq<20; eq++) {
61 // sprintf(id,"SPDref%d",eq);
62 // TList* list = GetFileSources(kDAQ,id); // (the id is actually unique, so always 1 file)
64 // TObjString* fileNameEntry = (TObjString*) list->First();
65 // Char_t* fileName = (Char_t*) GetFile(kDAQ, id, fileNameEntry->GetString().Data());
66 // AliITSOnlineSPDscan *scan = new AliITSOnlineSPDscan((Char_t*)fileName);
67 // TObjArray* arr = scan->GetAsTObjArray();
69 // sprintf(refCAT,"Ref%d",eq);
70 // StoreReferenceData("SHUTTLE", refCAT, arr, &metaData, 0, 0);
78 // Read old calibration
79 TString runStr = GetRunParameter("run");
80 Int_t run = atoi(runStr);
81 AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB());
82 if(!storage) return 0;
83 AliCDBEntry* cdbEntry = storage->Get("ITS/Calib/SPDNoisy", run);
86 spdEntry = (TObjArray*)cdbEntry->GetObject();
87 if(!spdEntry) return 0;
90 Log(Form("Old calibration not found in database. A fresh one will be created."));
91 // Create fresh calibration
92 spdEntry = new TObjArray(240);
93 for(Int_t module=0;module<240;module++){
94 AliITSCalibrationSPD* cal = new AliITSCalibrationSPD();
97 spdEntry->SetOwner(kTRUE);
101 TString pwd = gSystem->pwd(); // remember the working directory, to cd back later
102 TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir());
104 // Retrieve and unpack tared calibration files from FXS
105 TList* list = GetFileSources(kDAQ,"SPD_noisy");
108 while (list->At(index)!=NULL) {
109 TObjString* fileNameEntry = (TObjString*) list->At(index);
110 TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data());
111 gSystem->cd(tempDir.Data());
113 sprintf(command,"tar -xf %s",fileName.Data());
114 gSystem->Exec(command);
119 gSystem->cd(pwd.Data());
122 // Update the database entries
123 UInt_t nrUpdatedMods = 0;
124 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
126 sprintf(fileLoc,"%s",AliShuttleInterface::GetShuttleTempDir());
127 handler->SetFileLocation(fileLoc);
128 for (Int_t module=0; module<240; module++) {
129 handler->SetModuleNr(module);
130 if (handler->ReadFromFile()) {
131 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy() );
132 ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray() );
138 if (nrUpdatedMods>0) {
139 Log(Form("Noisy lists for %d modules updated.",nrUpdatedMods));
141 // Store the cdb entry
142 AliCDBMetaData metaData;
143 metaData.SetBeamPeriod(0);
144 metaData.SetResponsible("Henrik Tydesjo");
145 metaData.SetComment("Preprocessor test for SPD.");
146 result = Store("Calib", "SPDNoisy", spdEntry, &metaData, 0, kTRUE);
148 Log("Database updated.");