]>
Commit | Line | Data |
---|---|---|
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 | 21 | ClassImp(AliITSPreprocessorSPD) |
3f0e013c | 22 | |
b15de2d2 | 23 | //______________________________________________________________________________________________ |
24 | AliITSPreprocessorSPD::AliITSPreprocessorSPD(AliShuttleInterface* shuttle) : | |
25 | AliPreprocessor("SPD", shuttle) | |
3f0e013c | 26 | { |
b15de2d2 | 27 | // constructor |
3f0e013c | 28 | } |
29 | ||
b15de2d2 | 30 | //______________________________________________________________________________________________ |
31 | AliITSPreprocessorSPD::~AliITSPreprocessorSPD() | |
3f0e013c | 32 | { |
b15de2d2 | 33 | // destructor |
3f0e013c | 34 | } |
35 | ||
b15de2d2 | 36 | //______________________________________________________________________________________________ |
37 | void 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 | 49 | UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/) |
fcf95fc7 | 50 | { |
b15de2d2 | 51 | // Do the actual preprocessing |
fcf95fc7 | 52 | |
03fc6773 | 53 | |
0c0426a2 | 54 | // *** REFERENCE DATA *** |
03fc6773 | 55 | |
0c0426a2 | 56 | // OLD algorithm (commented out)!!! |
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 | // } | |
0c0426a2 | 73 | // *********************************************************** |
74 | ||
75 | // Store the container files as reference data (one file for each equipment) | |
76 | for (UInt_t eq=0; eq<20; eq++) { | |
77 | Char_t id[20]; | |
78 | sprintf(id,"SPD_reference_%d",eq); | |
79 | TList* list = GetFileSources(kDAQ,id); // (the id should be unique, so always 1 file) | |
80 | if (list) { | |
81 | TObjString* fileNameEntry = (TObjString*) list->First(); | |
82 | if (fileNameEntry!=NULL) { | |
83 | TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data()); | |
84 | Char_t refCAT[10]; | |
85 | sprintf(refCAT,"SPDref_eq_%d.root",eq); | |
86 | if (!StoreReferenceFile(fileName.Data(),refCAT)) { | |
87 | return 1; | |
88 | } | |
89 | } | |
90 | } | |
91 | } | |
03fc6773 | 92 | |
93 | ||
94 | // *** NOISY DATA *** | |
95 | ||
0c0426a2 | 96 | // OLD algorithm (commented out)!!! |
97 | // *********************************************************** | |
98 | // // Read old calibration | |
99 | // AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "SPDNoisy"); | |
100 | // TObjArray* spdEntry; | |
101 | // if(cdbEntry) { | |
102 | // spdEntry = (TObjArray*)cdbEntry->GetObject(); | |
103 | // if(!spdEntry) return 0; | |
104 | // } | |
105 | // else { | |
106 | // Log(Form("Old calibration not found in database. A fresh one will be created.")); | |
107 | // // Create fresh calibration | |
108 | // spdEntry = new TObjArray(240); | |
109 | // for(Int_t module=0;module<240;module++){ | |
110 | // AliITSCalibrationSPD* cal = new AliITSCalibrationSPD(); | |
111 | // spdEntry->Add(cal); | |
112 | // } | |
113 | // spdEntry->SetOwner(kTRUE); | |
114 | // } | |
115 | // *********************************************************** | |
116 | ||
03fc6773 | 117 | // Read old calibration |
0c0426a2 | 118 | AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "SPDNoisy"); |
03fc6773 | 119 | TObjArray* spdEntry; |
120 | if(cdbEntry) { | |
121 | spdEntry = (TObjArray*)cdbEntry->GetObject(); | |
0c0426a2 | 122 | if(!spdEntry) return 1; |
03fc6773 | 123 | } |
124 | else { | |
0c0426a2 | 125 | Log("Old calibration not found in database. This is required for further processing."); |
126 | return 1; | |
03fc6773 | 127 | } |
128 | ||
03fc6773 | 129 | TString pwd = gSystem->pwd(); // remember the working directory, to cd back later |
130 | TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir()); | |
131 | ||
132 | // Retrieve and unpack tared calibration files from FXS | |
133 | TList* list = GetFileSources(kDAQ,"SPD_noisy"); | |
134 | if (list) { | |
135 | UInt_t index = 0; | |
136 | while (list->At(index)!=NULL) { | |
137 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
138 | TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data()); | |
139 | gSystem->cd(tempDir.Data()); | |
140 | Char_t command[100]; | |
141 | sprintf(command,"tar -xf %s",fileName.Data()); | |
142 | gSystem->Exec(command); | |
143 | index++; | |
144 | } | |
145 | } | |
146 | ||
147 | gSystem->cd(pwd.Data()); | |
148 | ||
0c0426a2 | 149 | // Update the database entries if needed |
03fc6773 | 150 | UInt_t nrUpdatedMods = 0; |
151 | AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler(); | |
152 | Char_t fileLoc[100]; | |
153 | sprintf(fileLoc,"%s",AliShuttleInterface::GetShuttleTempDir()); | |
154 | handler->SetFileLocation(fileLoc); | |
155 | for (Int_t module=0; module<240; module++) { | |
156 | handler->SetModuleNr(module); | |
157 | if (handler->ReadFromFile()) { | |
158 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy() ); | |
159 | ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray() ); | |
160 | nrUpdatedMods++; | |
161 | } | |
162 | } | |
163 | delete handler; | |
03fc6773 | 164 | if (nrUpdatedMods>0) { |
0c0426a2 | 165 | Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods)); |
03fc6773 | 166 | // Store the cdb entry |
167 | AliCDBMetaData metaData; | |
168 | metaData.SetBeamPeriod(0); | |
169 | metaData.SetResponsible("Henrik Tydesjo"); | |
170 | metaData.SetComment("Preprocessor test for SPD."); | |
0c0426a2 | 171 | if (!Store("Calib", "SPDNoisy", spdEntry, &metaData, 0, kTRUE)) { |
172 | return 1; | |
173 | } | |
174 | // delete spdEntry; | |
03fc6773 | 175 | Log("Database updated."); |
176 | } | |
177 | ||
0c0426a2 | 178 | return 0; // 0 means success |
03fc6773 | 179 | |
180 | ||
181 | ||
fcf95fc7 | 182 | } |
b15de2d2 | 183 |