#include <TFile.h>
#include <TH2S.h>
+#include <TH1F.h>
+#include <TCanvas.h>
#include <TMath.h>
#include <TObjArray.h>
#include <TObjString.h>
#include "AliTOFChannelOnlineArray.h"
#include "AliTOFChannelOnlineStatusArray.h"
#include "AliTOFDataDCS.h"
+#include "AliTOFLvHvDataPoints.h"
#include "AliTOFGeometry.h"
#include "AliTOFPreprocessor.h"
#include "AliTOFFEEReader.h"
AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
AliPreprocessor("TOF", shuttle),
fData(0),
+ fHVLVmaps(0),
fCal(0),
fNChannels(0),
fStoreRefData(kTRUE),
fFDRFlag(kFALSE),
fStatus(0),
fMatchingWindow(0),
- fLatencyWindow(0)
+ fLatencyWindow(0),
+ fIsStatusMapChanged(0)
{
// constructor
AddRunType("PHYSICS");
TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
+ fHVLVmaps = new AliTOFLvHvDataPoints(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
}
//_____________________________________________________________________________
}
//_____________________________________________________________________________
-UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap)
+UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap * const dcsAliasMap)
{
// Fills data into a AliTOFDataDCS object
}
//_____________________________________________________________________________
+UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap * const dcsAliasMap)
+{
+ //
+ //Fills data into a AliTOFLvHvDataPoints object
+ // Merges fStatus object with LV and HV status at SOR
+ // Updates fStatus object with LV and HV status
+ // at EOR in case of correct end of run
+ // at last but two value in case of end-of-run caused by TOF detector.
+ //
+
+ Log("Processing HV and LV DCS DPs");
+ TH1::AddDirectory(0);
+
+ Bool_t resultDCSMap=kFALSE;
+
+ // processing DCS
+
+ fHVLVmaps->SetFDRFlag(fFDRFlag);
+
+ if (!dcsAliasMap){
+ Log("No DCS map found: TOF exiting from Shuttle");
+ if (fHVLVmaps){
+ delete fHVLVmaps;
+ fHVLVmaps = 0;
+ }
+ return 1;// return error Code for DCS input data not found
+ }
+ else {
+
+ // The processing of the DCS input data is forwarded to AliTOFDataDCS
+ resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap);
+ if (!resultDCSMap) {
+ Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
+ if (fHVLVmaps) {
+ delete fHVLVmaps;
+ fHVLVmaps = 0;
+ }
+ return 2;// return error Code for processed DCS data not stored
+ }
+ else {
+
+ // check with plots. Start...
+ /*
+ TH1F *hROsor = new TH1F("hROsor","RO status map at SOR",91*96*18,-0.5,91*96*18-0.5);
+ for (Int_t ii=1; ii<=91*96*18; ii++) hROsor->SetBinContent(ii,-1);
+ for (Int_t ii=0; ii<91*96*18; ii++) {
+ if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
+ hROsor->SetBinContent(ii+1,0);
+ else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
+ hROsor->SetBinContent(ii+1,1);
+ }
+
+ TH1F *hROandHVandLVsor = new TH1F("hROandHVandLVsor","RO.and.HV.andLV status map at SOR",91*96*18,-0.5,91*96*18-0.5);
+ for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVsor->SetBinContent(ii,-1);
+ TH1F *hROandHVandLVeor = new TH1F("hROandHVandLVeor","RO.and.HV.andLV status map at EOR",91*96*18,-0.5,91*96*18-0.5);
+ for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVeor->SetBinContent(ii,-1);
+ */
+
+ AliTOFDCSmaps * lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtSOR(); // Get LV.and.HV status map at SOR
+ for (Int_t index=0; index<fNChannels; index++) {
+ if ( ( lvANDhvMap->GetCellValue(index)==0 &&
+ fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
+ ( lvANDhvMap->GetCellValue(index)==1 &&
+ fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
+ fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
+ fIsStatusMapChanged=kTRUE;
+ }
+ }
+
+ // check with plots. Start...
+ /*
+ for (Int_t ii=0; ii<91*96*18; ii++) {
+ if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
+ hROandHVandLVsor->SetBinContent(ii+1,0);
+ else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
+ hROandHVandLVsor->SetBinContent(ii+1,1);
+ }
+ */
+
+ lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtEOR(); // Get LV.and.HV status map at EOR
+ for (Int_t index=0; index<fNChannels; index++) {
+ if ( ( lvANDhvMap->GetCellValue(index)==0 &&
+ fStatus->GetHWStatus(index)!=AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
+ ( lvANDhvMap->GetCellValue(index)==1 &&
+ fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
+ fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
+ fIsStatusMapChanged=kTRUE;
+ }
+ }
+
+ // check with plots. Start...
+ /*
+ for (Int_t ii=0; ii<91*96*18; ii++) {
+ if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
+ hROandHVandLVeor->SetBinContent(ii+1,0);
+ else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
+ hROandHVandLVeor->SetBinContent(ii+1,1);
+ }
+
+ TCanvas *canvas = new TCanvas("canvas","",10,10,1000,1000);
+ canvas->SetFillColor(0);
+ canvas->Divide(2,2);
+ canvas->cd(1);
+ hROsor->SetLineWidth(2);
+ hROsor->Draw();
+ canvas->cd(2);
+ hROandHVandLVsor->SetLineWidth(2);
+ hROandHVandLVsor->Draw();
+ canvas->cd(3);
+ hROandHVandLVeor->SetLineWidth(2);
+ hROandHVandLVeor->Draw();
+ canvas->cd();
+ */
+
+ }
+ }
+
+
+ /* check whether we don't need to update OCDB.
+ * in this case we can return without errors. */
+
+ if (!fIsStatusMapChanged) {
+ AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
+ return 0; // return ok
+ }
+
+ TString runType = GetRunType();
+ if (runType != "PHYSICS") {
+ AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
+ return 0; // return ok
+ }
+
+ // update the OCDB with the current FEE.and.HV.and.LV
+ // since even a little difference has been detected.
+
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Roberto Preghenella");
+ metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.HV.and.LV data.");
+ AliInfo("Storing Status data from current run. Collected RO.and.HV.and.LV infos @ EOR");
+ // store FEE data
+ if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
+ // failed
+ Log("problems while storing RO.and.HV.and.LV Status data object");
+ if (fStatus){
+ delete fStatus;
+ fStatus = 0;
+ }
+ if (fHVLVmaps) {
+ delete fHVLVmaps;
+ fHVLVmaps = 0;
+ }
+ return 17; // return error code for problems while storing FEE data
+ }
+
+ // everything fine. return
+
+ if (fStatus){
+ delete fStatus;
+ fStatus = 0;
+ }
+
+ if (fHVLVmaps) {
+ delete fHVLVmaps;
+ fHVLVmaps = 0;
+ }
+
+ return 0;
+}
+//_____________________________________________________________________________
+
UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
{
// Processing data from DAQ for online calibration
Log("Processing FEE");
- Bool_t updateOCDB = kFALSE;
+ //Bool_t updateOCDB = kFALSE;
AliTOFFEEReader feeReader;
TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
Log("No CDB Status entry found, creating a new one!");
Log(" *********************************");
fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
- updateOCDB = kTRUE;
+ //updateOCDB = kTRUE;
+ fIsStatusMapChanged = kTRUE;
}
else {
if (cdbEntry) cdbEntry->SetOwner(kFALSE);
Log(" *********************************");
delete fStatus;
fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
- updateOCDB = kTRUE;
+ //updateOCDB = kTRUE;
+ fIsStatusMapChanged = kTRUE;
}
}
for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
if (feeReader.IsChannelEnabled(iChannel)) {
hCurrentFEE.SetBinContent(iChannel + 1, 1);
if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
- updateOCDB = kTRUE;
+ //updateOCDB = kTRUE;
+ fIsStatusMapChanged = kTRUE;
fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
}
if (fStatus->GetLatencyWindow(iChannel)!=fLatencyWindow[iChannel]){
- updateOCDB = kTRUE;
+ //updateOCDB = kTRUE;
+ fIsStatusMapChanged = kTRUE;
fStatus->SetLatencyWindow(iChannel,fLatencyWindow[iChannel]);
AliDebug(3,Form( " changed latency window: channel %i latency window after FEE = %i",iChannel,fStatus->GetLatencyWindow(iChannel)));
}
}
else {
if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
- updateOCDB = kTRUE;
+ //updateOCDB = kTRUE;
+ fIsStatusMapChanged = kTRUE;
fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
}
}
}
- /* 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("TOF FEE config has not changed. Do not overwrite stored file.");
- return 0; /* return ok */
- }
-
- TString runType = GetRunType();
- if (runType != "PHYSICS") {
- AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
- return 0; /* return ok */
- }
-
- /* update the OCDB with the current FEE since even
- * a little difference has been detected. */
-
- AliCDBMetaData metaData;
- metaData.SetBeamPeriod(0);
- metaData.SetResponsible("Roberto Preghenella");
- metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE data.");
- AliInfo("Storing Status data from current run after FEE parsing");
- /* store FEE data */
- if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
- /* failed */
- Log("problems while storing FEE data object");
- if (fStatus){
- delete fStatus;
- fStatus = 0;
- }
- return 17; /* return error code for problems while storing FEE data */
- }
-
- /* everything fine. return */
-
- if (fStatus){
- delete fStatus;
- fStatus = 0;
- }
-
return 0;
}
//_____________________________________________________________________________
-UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
+UInt_t AliTOFPreprocessor::Process(TMap * const dcsAliasMap)
{
//
- //
+ // Main AliTOFPreprocessor method called by SHUTTLE
//
TString runType = GetRunType();
}
else {
Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
- return iresultDCS;
+ Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap);
+ return iresultDCS+iResultHVandLVdps;
}
}