/* $Id$ */
+
//#include <Riostream.h>
//#include <stdio.h>
//#include <stdlib.h>
#include "AliTOFFEEReader.h"
#include "AliTOFRawStream.h"
#include "AliTOFCableLengthMap.h"
+#include "AliTOFcalibHisto.h"
// TOF preprocessor class.
{
// Processing data from DAQ for online calibration
+ Bool_t updateOCDB = kFALSE;
Log("Processing DAQ delays");
// reading configuration map
Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
- fCal = new AliTOFChannelOnlineArray(fNChannels);
+ /* init array with current calibration, if any */
+ fCal = new AliTOFChannelOnlineArray(fNChannels);
+ AliTOFChannelOnlineArray *curCal = NULL;
+
+ AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay");
+ if (!cdbEntry2 || !cdbEntry2->GetObject()) {
+ /* no CDB entry found. set update flag */
+ Log(" ************ WARNING ************");
+ Log("No CDB ParOnlineDelay entry found, creating a new one!");
+ Log(" *********************************");
+ updateOCDB = kTRUE;
+ }
+ else {
+ Log("Found previous ParOnlineDelay entry. Using it to init calibration");
+ curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject();
+ for (Int_t i = 0; i < fNChannels; i++)
+ fCal->SetDelay(i, curCal->GetDelay(i));
+ }
+
TH1::AddDirectory(0);
}
Int_t nNotStatistics = 0; // number of channel with not enough statistics
- /* FDR flag set. do not compute delays, use nominal cable delays */
+ /* FDR flag set. do not compute delays, use nominal cable delays */
if (fFDRFlag) {
Log(" Not computing delays according to flag set in Config entry in OCDB!");
- Log(" Using nominal cable delays.");
-
- AliTOFRawStream tofrs;
- Int_t det[5], dummy, index;
- Float_t cableTimeShift;
-
- /* temporarly disable warnings */
- AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
- AliLog::SetGlobalLogLevel(AliLog::kError);
-
- /* loop over EO indeces */
- for (Int_t iddl = 0; iddl < 72; iddl++)
- for (Int_t islot = 3; islot <= 12; islot++)
- for (Int_t ichain = 0; ichain < 2; ichain++)
- for (Int_t itdc = 0; itdc < 15; itdc++)
- for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
-
- /* get DO index */
- tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
-
- /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
- dummy = det[3];
- det[3] = det[4];
- det[4] = dummy;
-
- /* check DO index */
- if (det[0] < 0 || det[0] > 17 ||
- det[1] < 0 || det[1] > 4 ||
- det[2] < 0 || det[2] > 18 ||
- det[3] < 0 || det[3] > 1 ||
- det[4] < 0 || det[4] > 47)
- continue;
-
- /* get channel index */
- index = AliTOFGeometry::GetIndex(det);
-
- /* get cable time shift */
- cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
-
- /* set delay */
- if (index<fNChannels) {
- fCal->SetDelay(index,cableTimeShift); // delay in ns
- AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
- }
-
- } /* loop over EO indeces */
-
- /* re-enable warnings */
- AliLog::SetGlobalLogLevel(logLevel);
-
+ FillWithCosmicCalibration(fCal);
+
+ /* check whether the new calibration is different from the previous one */
+ if (curCal) { /* well, check also whether we have a previous calibration */
+ for (Int_t i = 0; i < fNChannels; i++) {
+ if (fCal->GetDelay(i) != curCal->GetDelay(i)) {
+ updateOCDB = kTRUE;
+ break;
+ }
+ }
+ }
+ else /* otherwise update OCDB */
+ updateOCDB = kTRUE;
+
}
else { // computing delays if not in FDR runs
+
+ updateOCDB = kTRUE; /* always update OCDB when computing delays */
+
for (Int_t ich=0;ich<kSize;ich++){
/* check whether channel has been read out during current run.
* if the status is bad it means it has not been read out.
return 6; //return error code for problems in retrieving DAQ data
}
+ /* check whether we don't need to update OCDB.
+ * in this case we can return without errors and
+ * the current FEE is stored in the fStatus object. */
+ if (!updateOCDB) {
+ AliInfo("update OCDB flag not set. Do not overwrite stored file.");
+ return 0; /* return ok */
+ }
+
daqFile=0;
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
nNoiseSource++;
// checking the matching window for current channel
if (fMatchingWindow[ibin] == 0){
- Log(Form("Matching window for channel %i null, but the channel has entries! skipping channel, BUT Please check!",ibin));
+ Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin));
if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;
if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;
continue;
/* load current TOF FEE config from DCS FXS, parse,
* fill current FEE histogram and set FEE status */
- const char * nameFile = GetFile(kDCS,"TofFeeMap","");
+ const char * nameFile = GetFile(kDCS,"TofFeeLightMap","");
AliInfo(Form("nameFile = %s",nameFile));
if (nameFile == NULL) {
return 15;
}
- feeReader.LoadFEEConfig(nameFile);
- Int_t parseFee = feeReader.ParseFEEConfig();
- AliDebug(2,Form("%i enabled channels found in FEE configuration",parseFee));
+ feeReader.LoadFEElightConfig(nameFile);
+ Int_t parseFee = feeReader.ParseFEElightConfig();
+ AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee));
/* load stored TOF FEE from OCDB and compare it with current FEE.
* if stored FEE is different from current FEE set update flag.
* if there is no stored FEE in OCDB set update flag */
}
+//_____________________________________________________________________________
+
+void
+AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal)
+{
+ /*
+ * fill with cosmic calibration
+ */
+
+ Log(" Using cosmic-ray calibration.");
+
+ AliTOFcalibHisto calibHisto;
+ calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE);
+ Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName()));
+ Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName()));
+ calibHisto.LoadCalibPar();
+
+ /* loop over channel index */
+ for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) {
+ cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex));
+ }
+
+}
+
+//_____________________________________________________________________________
+
+void
+AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal)
+{
+ /*
+ * fill with cosmic calibration
+ */
+
+ Log(" Using cable-length map.");
+ AliTOFRawStream tofrs;
+ Int_t det[5], dummy, index;
+ Float_t cableTimeShift;
+
+ /* temporarly disable warnings */
+ AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
+ AliLog::SetGlobalLogLevel(AliLog::kError);
+
+ /* loop over EO indeces */
+ for (Int_t iddl = 0; iddl < 72; iddl++)
+ for (Int_t islot = 3; islot <= 12; islot++)
+ for (Int_t ichain = 0; ichain < 2; ichain++)
+ for (Int_t itdc = 0; itdc < 15; itdc++)
+ for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
+
+ /* get DO index */
+ tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
+
+ /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
+ dummy = det[3];
+ det[3] = det[4];
+ det[4] = dummy;
+
+ /* check DO index */
+ if (det[0] < 0 || det[0] > 17 ||
+ det[1] < 0 || det[1] > 4 ||
+ det[2] < 0 || det[2] > 18 ||
+ det[3] < 0 || det[3] > 1 ||
+ det[4] < 0 || det[4] > 47)
+ continue;
+
+ /* get channel index */
+ index = AliTOFGeometry::GetIndex(det);
+
+ /* get cable time shift */
+ cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
+
+ /* set delay */
+ if (index<fNChannels) {
+ cal->SetDelay(index,cableTimeShift); // delay in ns
+ AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
+ }
+
+ } /* loop over EO indeces */
+
+ /* re-enable warnings */
+ AliLog::SetGlobalLogLevel(logLevel);
+
+}
+
+