]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPreprocessorSPD.cxx
Interfaced to AliAODJet and AliAODHandler.
[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"
9#include "AliITSOnlineCalibrationSPD.h"
10#include "AliITSOnlineCalibrationSPDhandler.h"
03fc6773 11#include "AliCDBManager.h"
12#include "AliCDBStorage.h"
13#include "AliCDBEntry.h"
b15de2d2 14#include "AliCDBMetaData.h"
03fc6773 15#include "AliShuttleInterface.h"
b15de2d2 16#include "AliLog.h"
03fc6773 17#include <TTimeStamp.h>
18#include <TObjString.h>
19#include <TSystem.h>
3f0e013c 20
b15de2d2 21ClassImp(AliITSPreprocessorSPD)
3f0e013c 22
b15de2d2 23//______________________________________________________________________________________________
24AliITSPreprocessorSPD::AliITSPreprocessorSPD(AliShuttleInterface* shuttle) :
25 AliPreprocessor("SPD", shuttle)
3f0e013c 26{
b15de2d2 27 // constructor
3f0e013c 28}
29
b15de2d2 30//______________________________________________________________________________________________
31AliITSPreprocessorSPD::~AliITSPreprocessorSPD()
3f0e013c 32{
b15de2d2 33 // destructor
3f0e013c 34}
35
b15de2d2 36//______________________________________________________________________________________________
37void AliITSPreprocessorSPD::Initialize(Int_t run, UInt_t startTime,
38 UInt_t endTime)
3f0e013c 39{
b15de2d2 40 // initialize
41 AliPreprocessor::Initialize(run, startTime, endTime);
3f0e013c 42
b15de2d2 43 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
44 TTimeStamp(startTime).AsString(),
45 TTimeStamp(endTime).AsString()));
3f0e013c 46}
fcf95fc7 47
b15de2d2 48//______________________________________________________________________________________________
0c0426a2 49UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
fcf95fc7 50{
b15de2d2 51 // Do the actual preprocessing
fcf95fc7 52
03fc6773 53
ad18504e 54 // *** CHECK RUN TYPE ***
55
56 TString runType = GetRunType();
57 if(runType != "SPD_STANDALONE_CALIBRATION") {
58 Log("Nothing to do");
59 return 0;
60 }
03fc6773 61
ad18504e 62
63 // *** REFERENCE DATA ***
0c0426a2 64
65 // Store the container files as reference data (one file for each equipment)
66 for (UInt_t eq=0; eq<20; eq++) {
67 Char_t id[20];
68 sprintf(id,"SPD_reference_%d",eq);
69 TList* list = GetFileSources(kDAQ,id); // (the id should be unique, so always 1 file)
70 if (list) {
71 TObjString* fileNameEntry = (TObjString*) list->First();
72 if (fileNameEntry!=NULL) {
73 TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
74 Char_t refCAT[10];
75 sprintf(refCAT,"SPDref_eq_%d.root",eq);
76 if (!StoreReferenceFile(fileName.Data(),refCAT)) {
77 return 1;
78 }
79 }
80 }
81 }
03fc6773 82
83
84 // *** NOISY DATA ***
85
86 // Read old calibration
ad18504e 87 AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "CalibSPD");
03fc6773 88 TObjArray* spdEntry;
89 if(cdbEntry) {
90 spdEntry = (TObjArray*)cdbEntry->GetObject();
0c0426a2 91 if(!spdEntry) return 1;
03fc6773 92 }
93 else {
0c0426a2 94 Log("Old calibration not found in database. This is required for further processing.");
95 return 1;
03fc6773 96 }
97
03fc6773 98 TString pwd = gSystem->pwd(); // remember the working directory, to cd back later
99 TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir());
100
101 // Retrieve and unpack tared calibration files from FXS
102 TList* list = GetFileSources(kDAQ,"SPD_noisy");
103 if (list) {
104 UInt_t index = 0;
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());
109 Char_t command[100];
110 sprintf(command,"tar -xf %s",fileName.Data());
111 gSystem->Exec(command);
112 index++;
113 }
114 }
115
116 gSystem->cd(pwd.Data());
117
0c0426a2 118 // Update the database entries if needed
03fc6773 119 UInt_t nrUpdatedMods = 0;
120 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
121 Char_t fileLoc[100];
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() );
129 nrUpdatedMods++;
130 }
131 }
132 delete handler;
03fc6773 133 if (nrUpdatedMods>0) {
0c0426a2 134 Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods));
03fc6773 135 // Store the cdb entry
136 AliCDBMetaData metaData;
137 metaData.SetBeamPeriod(0);
138 metaData.SetResponsible("Henrik Tydesjo");
139 metaData.SetComment("Preprocessor test for SPD.");
ad18504e 140 if (!Store("Calib", "CalibSPD", spdEntry, &metaData, 0, kTRUE)) {
0c0426a2 141 return 1;
142 }
143 // delete spdEntry;
03fc6773 144 Log("Database updated.");
145 }
146
0c0426a2 147 return 0; // 0 means success
03fc6773 148
149
150
fcf95fc7 151}
b15de2d2 152