// error Error on gain
// chi2 Chi^2 per degrees of freedom of fit
//
+// See also
+//
+// http://aliceinfo.cern.ch/Offline/Activities/Shuttle.html
+//
// Latest changes by Christian Holm Christensen
//
#include "AliFMDPreprocessor.h"
#include "AliFMDCalibPedestal.h"
#include "AliFMDCalibGain.h"
+#include "AliFMDCalibStripRange.h"
+#include "AliFMDCalibSampleRate.h"
#include "AliFMDParameters.h"
#include "AliCDBMetaData.h"
#include "AliCDBManager.h"
;
#endif
+
+//____________________________________________________
+AliFMDPreprocessor::AliFMDPreprocessor(AliShuttleInterface* shuttle)
+ : AliPreprocessor("FMD", shuttle)
+{
+ AddRunType("PHYSICS");
+ AddRunType("STANDALONE");
+ AddRunType("PEDESTAL");
+ AddRunType("GAIN");
+}
+
+
+//____________________________________________________
+Bool_t AliFMDPreprocessor::GetAndCheckFileSources(TList*& list,
+ Int_t system,
+ const char* id)
+{
+ // Convinience function
+ // Parameters:
+ // list On return, list of files.
+ // system Alice system (DAQ, DCS, ...)
+ // id File id
+ // Return:
+ // kTRUE on success.
+ list = GetFileSources(system, id);
+ if (!list) {
+ TString sys;
+ switch (system) {
+ case kDAQ: sys = "DAQ"; break;
+ case kDCS: sys = "DCS"; break;
+ default: sys = "unknown"; break;
+ }
+ Log(Form("Failed to get file sources for %s/%s", sys.Data(), system));
+ return kFALSE;
+ }
+ return kTRUE;
+}
+
+//____________________________________________________
+AliCDBEntry*
+AliFMDPreprocessor::GetFromCDB(const char* second, const char* third)
+{
+ return GetFromOCDB(second, third);
+}
+
+
//____________________________________________________
UInt_t AliFMDPreprocessor::Process(TMap* /* dcsAliasMap */)
{
// Parameters:
// dcsAliassMap Map of DCS data point aliases.
// Return
- // ?
+ // 0 on success, >0 otherwise
+ Bool_t resultPed = kTRUE;
+ Bool_t resultGain = kTRUE;
+ Bool_t resultRange = kTRUE;
+ Bool_t resultRate = kTRUE;
+ Bool_t resultZero = kTRUE;
// Do we need this ?
// if(!dcsAliasMap) return 1;
// cdb->SetDefaultStorage("local://$ALICE_ROOT");
// cdb->SetRun(0);
AliFMDParameters* pars = AliFMDParameters::Instance();
- pars->Init(false, AliFMDParameters::kAltroMap);
-
+ pars->Init(this, false, AliFMDParameters::kAltroMap);
+
+ // This is if the SOR contains Fee parameters, and we run a DA to
+ // extract these parameters. The same code could work if we get
+ // the information from DCS via the FXS
+ TList* files = 0;
+ AliFMDCalibSampleRate* calibRate = 0;
+ AliFMDCalibStripRange* calibRange = 0;
+ AliFMDCalibZeroSuppression* calibZero = 0;
+ // Disabled for now.
+#if 0
+ if (GetAndCheckFileSources(files, kDAQ,pars->GetConditionsShuttleID()))
+ GetInfoCalibration(files, calibRate, calibRange, calibZero);
+ resultRate = (!calibRate ? kFALSE : kTRUE);
+ resultRange = (!calibRange ? kFALSE : kTRUE);
+ resultZero = (!calibZero ? kFALSE : kTRUE);
+#endif
+
+ // Gt the run type
+ TString runType(GetRunType());
+
//Creating calibration objects
- TList* pedFiles = GetFileSources(kDAQ,"pedestal");
- TList* gainFiles = GetFileSources(kDAQ, "gain");
- AliFMDCalibPedestal* calibPed = GetPedestalCalibration(pedFiles);
- AliFMDCalibGain* calibGain = GetGainCalibration(gainFiles);
-
+ AliFMDCalibPedestal* calibPed = 0;
+ AliFMDCalibGain* calibGain = 0;
+ if (runType.Contains("PEDESTAL", TString::kIgnoreCase)) {
+ if (GetAndCheckFileSources(files, kDAQ, pars->GetPedestalShuttleID())) {
+ if(files->GetSize())
+ calibPed = GetPedestalCalibration(files);
+ }
+ resultPed = (calibPed ? kTRUE : kFALSE);
+ }
+ if (runType.Contains("GAIN", TString::kIgnoreCase)) {
+ if (GetAndCheckFileSources(files, kDAQ, pars->GetGainShuttleID())) {
+ if(files->GetSize())
+ calibGain = GetGainCalibration(files);
+ }
+ resultGain = (calibGain ? kTRUE : kFALSE);
+ }
//Storing Calibration objects
AliCDBMetaData metaData;
metaData.SetResponsible("Hans H. Dalsgaard");
metaData.SetComment("Preprocessor stores pedestals and gains for the FMD.");
- Bool_t resultPed = kFALSE, resultGain = kFALSE;
- if(calibPed) resultPed = Store("Calib","Pedestal", calibPed, &metaData);
- if(calibGain) resultGain = Store("Calib","PulseGain", calibGain, &metaData);
- if (calibPed) delete calibPed;
- if (calibGain) delete calibGain;
+ if(calibPed) {
+ resultPed = Store("Calib","Pedestal", calibPed, &metaData, 0, kTRUE);
+ delete calibPed;
+ }
+ if(calibGain) {
+ resultGain = Store("Calib","PulseGain", calibGain, &metaData, 0, kTRUE);
+ delete calibGain;
+ }
+ if(calibRange) {
+ resultRange = Store("Calib","StripRange", calibRange, &metaData, 0, kTRUE);
+ delete calibRange;
+ }
+ if(calibRate) {
+ resultRate = Store("Calib","SampleRate", calibRate, &metaData, 0, kTRUE);
+ delete calibRate;
+ }
+ if(calibZero) {
+ resultZero = Store("Calib","ZeroSuppression", calibZero,&metaData,0,kTRUE);
+ delete calibZero;
+ }
+
+#if 0
+ // Disabled until we implement GetInfoCalibration properly
+ Bool_t success = (resultPed && resultGain && resultRange &&
+ resultRate && resultZero);
+#endif
+ Bool_t success = resultPed && resultGain;
+ Log(Form("FMD preprocessor was %s", (success ? "successful" : "failed")));
+ return (success ? 0 : 1);
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDPreprocessor::GetInfoCalibration(TList* files,
+ AliFMDCalibSampleRate*& s,
+ AliFMDCalibStripRange*& r,
+ AliFMDCalibZeroSuppression*& z)
+{
+ // Get info calibrations.
+ // Parameters:
+ // files List of files.
+ // s On return, newly allocated object
+ // r On return, newly allocated object
+ // z On return, newly allocated object
+ // Return:
+ // kTRUE on success
+ if (!files) return kTRUE; // Should really be false
+ if (files->GetEntries() <= 0) return kTRUE;
+
+ s = new AliFMDCalibSampleRate();
+ r = new AliFMDCalibStripRange();
+ z = new AliFMDCalibZeroSuppression();
- return (resultPed && resultGain ? 0 : 1);
+ AliFMDParameters* pars = AliFMDParameters::Instance();
+ TIter iter(files);
+ TObjString* fileSource;
+
+ while((fileSource = dynamic_cast<TObjString*>(iter.Next()))) {
+ const Char_t* filename = GetFile(kDAQ, pars->GetConditionsShuttleID(), fileSource->GetName());
+ std::ifstream in(filename);
+ if(!in) {
+ Log(Form("File %s not found!", filename));
+ continue;
+ }
+ }
+ return kTRUE;
}
+
//____________________________________________________________________
AliFMDCalibPedestal*
AliFMDPreprocessor::GetPedestalCalibration(TList* pedFiles)
TObjString* fileSource;
while((fileSource = dynamic_cast<TObjString*>(iter.Next()))) {
- const Char_t* filename = GetFile(kDAQ, "pedestal", fileSource->GetName());
+ const Char_t* filename = GetFile(kDAQ, pars->GetPedestalShuttleID(), fileSource->GetName());
std::ifstream in(filename);
if(!in) {
- AliError(Form("File %s not found!", filename));
+ Log(Form("File %s not found!", filename));
continue;
}
header.ReadLine(in);
header.ToLower();
if(!header.Contains("pedestal")) {
- AliError("File header is not from pedestal!");
+ Log("File header is not from pedestal!");
continue;
}
Log("File contains data from pedestals");
header.ReadLine(in);
// Loop until EOF
- while(!in.eof()) {
+ while(in.peek()!=EOF) {
if(in.bad()) {
- AliError(Form("Bad read at line %d in %s", lineno, filename));
+ Log(Form("Bad read at line %d in %s", lineno, filename));
break;
}
- UInt_t ddl=2, board, chip, channel, strip, tb;
+ UInt_t ddl=2, board, chip, channel, strip, sample, tb;
Float_t ped, noise, mu, sigma, chi2ndf;
- Char_t c[10];
+ Char_t c[11];
- in // >> ddl >> c[0]
+ in >> ddl >> c[0]
>> board >> c[1]
>> chip >> c[2]
>> channel >> c[3]
>> strip >> c[4]
- >> tb >> c[5]
- >> ped >> c[6]
- >> noise >> c[7]
- >> mu >> c[8]
- >> sigma >> c[9]
+ >> sample >> c[5]
+ >> tb >> c[6]
+ >> ped >> c[7]
+ >> noise >> c[8]
+ >> mu >> c[9]
+ >> sigma >> c[10]
>> chi2ndf;
lineno++;
+
// Ignore trailing garbage
if (strip > 127) continue;
+ //Setting DDL to comply with the FMD in DAQ
+ UInt_t FmdDDLBase = 3072;
+ ddl = ddl - FmdDDLBase;
//Setting the pedestals via the hardware address
UShort_t det, sec, str;
Char_t ring;
-
+
pars->Hardware2Detector(ddl,board,chip,channel,det,ring,sec,str);
strip += str;
+
calibPed->Set(det,ring,sec,strip,ped,noise);
+
}
}
return calibPed;
TIter iter(gainFiles);
TObjString* fileSource;
while((fileSource = dynamic_cast<TObjString *>(iter.Next()))) {
- const Char_t* filename = GetFile(kDAQ, "gain", fileSource->GetName());
+ const Char_t* filename = GetFile(kDAQ, pars->GetGainShuttleID(), fileSource->GetName());
std::ifstream in(filename);
if(!in) {
- AliError(Form("File %s not found!", filename));
+ Log(Form("File %s not found!", filename));
continue;
}
header.ReadLine(in);
header.ToLower();
if(!header.Contains("gain")) {
- AliError("File header is not from gain!");
+ Log("File header is not from gain!");
continue;
}
Log("File contains data from pulse gain");
int lineno = 2;
// Read until EOF
- while(!in.eof()) {
+ while(in.peek()!=EOF) {
if(in.bad()) {
- AliError(Form("Bad read at line %d in %s", lineno, filename));
+ Log(Form("Bad read at line %d in %s", lineno, filename));
break;
}
UInt_t ddl=2, board, chip, channel, strip;
Float_t gain,error, chi2ndf;
Char_t c[7];
- in // >> ddl >> c[0]
+ in >> ddl >> c[0]
>> board >> c[1]
>> chip >> c[2]
>> channel >> c[3]
// Ignore trailing garbage
if(strip > 127) continue;
+ //Setting DDL to comply with the FMD in DAQ
+ UInt_t FmdDDLBase = 3072;
+ ddl = ddl - FmdDDLBase;
//Setting the pedestals via the hardware address
UShort_t det, sec, str;
Char_t ring;