]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSPreprocessorSPD.cxx
Modifications in order to reconstruct cosmic rays (Y. Belikov)
[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//______________________________________________________________________________________________
49UInt_t AliITSPreprocessorSPD::Process(TMap* dcsAliasMap)
fcf95fc7 50{
b15de2d2 51 // Do the actual preprocessing
fcf95fc7 52
03fc6773 53 UInt_t result = 1;
54
55
56// // *** REFERENCE DATA ***
57
b15de2d2 58// // Store the container files as reference data (one for each equipment)
59// for (UInt_t eq=0; eq<20; eq++) {
60// Char_t id[20];
61// sprintf(id,"SPDref%d",eq);
62// TList* list = GetFileSources(kDAQ,id); // (the id is actually unique, so always 1 file)
63// if (list) {
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();
68// Char_t refCAT[10];
69// sprintf(refCAT,"Ref%d",eq);
70// StoreReferenceData("SHUTTLE", refCAT, arr, &metaData, 0, 0);
71// }
72// }
73
03fc6773 74
75
76 // *** NOISY DATA ***
77
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);
84 TObjArray* spdEntry;
85 if(cdbEntry) {
86 spdEntry = (TObjArray*)cdbEntry->GetObject();
87 if(!spdEntry) return 0;
88 }
89 else {
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();
95 spdEntry->Add(cal);
96 }
97 spdEntry->SetOwner(kTRUE);
98 }
99
100
101 TString pwd = gSystem->pwd(); // remember the working directory, to cd back later
102 TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir());
103
104 // Retrieve and unpack tared calibration files from FXS
105 TList* list = GetFileSources(kDAQ,"SPD_noisy");
106 if (list) {
107 UInt_t index = 0;
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());
112 Char_t command[100];
113 sprintf(command,"tar -xf %s",fileName.Data());
114 gSystem->Exec(command);
115 index++;
116 }
117 }
118
119 gSystem->cd(pwd.Data());
120
121
122 // Update the database entries
123 UInt_t nrUpdatedMods = 0;
124 AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
125 Char_t fileLoc[100];
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() );
133 nrUpdatedMods++;
134 }
135 }
136 delete handler;
137
138 if (nrUpdatedMods>0) {
139 Log(Form("Noisy lists for %d modules updated.",nrUpdatedMods));
140
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);
147 delete spdEntry;
148 Log("Database updated.");
149 }
150
b15de2d2 151 return result;
03fc6773 152
153
154
fcf95fc7 155}
b15de2d2 156