#include "AliITSPreprocessorSPD.h"
#include "AliITSCalibrationSPD.h"
-#include "AliITSOnlineCalibrationSPD.h"
#include "AliITSOnlineCalibrationSPDhandler.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
#include "AliCDBEntry.h"
#include "AliCDBMetaData.h"
#include "AliShuttleInterface.h"
#include <TTimeStamp.h>
#include <TObjString.h>
#include <TSystem.h>
+#include <TList.h>
ClassImp(AliITSPreprocessorSPD)
// Do the actual preprocessing
- // *** REFERENCE DATA ***
-
-// OLD algorithm (commented out)!!!
-// ***********************************************************
-// // Store the container files as reference data (one for each equipment)
-// for (UInt_t eq=0; eq<20; eq++) {
-// Char_t id[20];
-// sprintf(id,"SPDref%d",eq);
-// TList* list = GetFileSources(kDAQ,id); // (the id is actually unique, so always 1 file)
-// if (list) {
-// TObjString* fileNameEntry = (TObjString*) list->First();
-// Char_t* fileName = (Char_t*) GetFile(kDAQ, id, fileNameEntry->GetString().Data());
-// AliITSOnlineSPDscan *scan = new AliITSOnlineSPDscan((Char_t*)fileName);
-// TObjArray* arr = scan->GetAsTObjArray();
-// Char_t refCAT[10];
-// sprintf(refCAT,"Ref%d",eq);
-// StoreReferenceData("SHUTTLE", refCAT, arr, &metaData, 0, 0);
-// }
-// }
-// ***********************************************************
-
- // Store the container files as reference data (one file for each equipment)
- for (UInt_t eq=0; eq<20; eq++) {
- Char_t id[20];
- sprintf(id,"SPD_reference_%d",eq);
- TList* list = GetFileSources(kDAQ,id); // (the id should be unique, so always 1 file)
- if (list) {
- TObjString* fileNameEntry = (TObjString*) list->First();
- if (fileNameEntry!=NULL) {
- TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
- Char_t refCAT[10];
- sprintf(refCAT,"SPDref_eq_%d.root",eq);
- if (!StoreReferenceFile(fileName.Data(),refCAT)) {
- return 1;
+ // *** GET RUN TYPE ***
+
+ TString runType = GetRunType();
+
+
+
+ // *** REFERENCE DATA *** //
+
+ // Standalone runs:
+ if (runType == "DAQ_MIN_TH_SCAN" ||
+ runType == "DAQ_MEAN_TH_SCAN" ||
+ runType == "DAQ_UNIFORMITY_SCAN" ||
+ runType == "DAQ_NOISY_PIX_SCAN" ||
+ runType == "DAQ_PIX_DELAY_SCAN" ||
+ runType == "DAQ_FO_UNIF_SCAN") {
+ // Store the scan container files as reference data (one file for each equipment)
+ for (UInt_t eq=0; eq<20; eq++) {
+ TString id = Form("SPD_reference_%d",eq);
+ TList* list = GetFileSources(kDAQ,id.Data()); // (the id should be unique, so always 1 file)
+ if (list) {
+ TObjString* fileNameEntry = (TObjString*) list->First();
+ if (fileNameEntry!=NULL) {
+ TString fileName = GetFile(kDAQ, id, fileNameEntry->GetString().Data());
+ TString refCAT = Form("SPDref_eq_%d.root",eq);
+ if (!StoreReferenceFile(fileName.Data(),refCAT.Data())) {
+ Log(Form("Failed to store reference file %s.",fileName.Data()));
+ return 1;
+ }
}
}
}
}
-
- // *** NOISY DATA ***
-
-// OLD algorithm (commented out)!!!
-// ***********************************************************
-// // Read old calibration
-// AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "SPDNoisy");
-// TObjArray* spdEntry;
-// if(cdbEntry) {
-// spdEntry = (TObjArray*)cdbEntry->GetObject();
-// if(!spdEntry) return 0;
-// }
-// else {
-// Log(Form("Old calibration not found in database. A fresh one will be created."));
-// // Create fresh calibration
-// spdEntry = new TObjArray(240);
-// for(Int_t module=0;module<240;module++){
-// AliITSCalibrationSPD* cal = new AliITSCalibrationSPD();
-// spdEntry->Add(cal);
-// }
-// spdEntry->SetOwner(kTRUE);
-// }
-// ***********************************************************
-
- // Read old calibration
- AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "SPDNoisy");
- TObjArray* spdEntry;
- if(cdbEntry) {
- spdEntry = (TObjArray*)cdbEntry->GetObject();
- if(!spdEntry) return 1;
- }
- else {
- Log("Old calibration not found in database. This is required for further processing.");
- return 1;
+ // Physics runs (online monitoring):
+ if (runType == "PHYSICS") {
+ // *** code to be written *** //
}
- TString pwd = gSystem->pwd(); // remember the working directory, to cd back later
- TString tempDir = Form("%s",AliShuttleInterface::GetShuttleTempDir());
-
- // Retrieve and unpack tared calibration files from FXS
- TList* list = GetFileSources(kDAQ,"SPD_noisy");
- if (list) {
- UInt_t index = 0;
- while (list->At(index)!=NULL) {
- TObjString* fileNameEntry = (TObjString*) list->At(index);
- TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data());
- gSystem->cd(tempDir.Data());
- Char_t command[100];
- sprintf(command,"tar -xf %s",fileName.Data());
- gSystem->Exec(command);
- index++;
- }
- }
- gSystem->cd(pwd.Data());
-
- // Update the database entries if needed
- UInt_t nrUpdatedMods = 0;
- AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
- Char_t fileLoc[100];
- sprintf(fileLoc,"%s",AliShuttleInterface::GetShuttleTempDir());
- handler->SetFileLocation(fileLoc);
- for (Int_t module=0; module<240; module++) {
- handler->SetModuleNr(module);
- if (handler->ReadFromFile()) {
- ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy() );
- ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray() );
- nrUpdatedMods++;
+
+ // *** NOISY AND DEAD DATA *** //
+
+ if (runType == "DAQ_NOISY_PIX_SCAN" || runType == "PHYSICS") {
+ // Read old calibration
+ AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "CalibSPD");
+ TObjArray* spdEntry;
+ if(cdbEntry) {
+ spdEntry = (TObjArray*)cdbEntry->GetObject();
+ if(!spdEntry) return 1;
}
- }
- delete handler;
- if (nrUpdatedMods>0) {
- Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods));
- // Store the cdb entry
- AliCDBMetaData metaData;
- metaData.SetBeamPeriod(0);
- metaData.SetResponsible("Henrik Tydesjo");
- metaData.SetComment("Preprocessor test for SPD.");
- if (!Store("Calib", "SPDNoisy", spdEntry, &metaData, 0, kTRUE)) {
+ else {
+ Log("Old calibration not found in database. This is required for further processing.");
return 1;
}
- // delete spdEntry;
- Log("Database updated.");
+
+ // Standalone runs:
+ if (runType == "DAQ_NOISY_PIX_SCAN") {
+ UInt_t nrUpdatedMods = 0;
+ // Retrieve and unpack tared calibration files from FXS
+ TList* list = GetFileSources(kDAQ,"SPD_noisy");
+ if (list) {
+ UInt_t index = 0;
+ while (list->At(index)!=NULL) {
+ TObjString* fileNameEntry = (TObjString*) list->At(index);
+ TString fileName = GetFile(kDAQ, "SPD_noisy", fileNameEntry->GetString().Data());
+ TString command = Form("tar -xf %s",fileName.Data());
+ gSystem->Exec(command.Data());
+ index++;
+ }
+ }
+ // Update the database entries for the modules that were scanned
+ AliITSOnlineCalibrationSPDhandler* handler = new AliITSOnlineCalibrationSPDhandler();
+ TString fileLoc = ".";
+ handler->SetFileLocation(fileLoc.Data());
+ for (Int_t module=0; module<240; module++) {
+ if (handler->ReadFromFile(module)) {
+ ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrNoisy( handler->GetNrNoisy(module) );
+ ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNoisyList( handler->GetNoisyArray(module) );
+ nrUpdatedMods++;
+ }
+ }
+ delete handler;
+ // Store the new calibration objects (if any modifications were made) in OCDB
+ if (nrUpdatedMods>0) {
+ Log(Form("Noisy lists for %d modules will be updated and stored...",nrUpdatedMods));
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Henrik Tydesjo");
+ metaData.SetComment("Preprocessor test for SPD.");
+ if (!Store("Calib", "CalibSPD", spdEntry, &metaData, 0, kTRUE)) {
+ Log("Failed to store calibration data.");
+ return 1;
+ }
+ Log("Database updated.");
+ }
+ }
+
+ // Physics runs (online monitoring):
+ if (runType == "PHYSICS") {
+ // *** code to be written *** //
+ }
+
+
}
- return 0; // 0 means success
+ return 0; // 0 means success
}