From ea932f75d1465601f6bb126a818f6b2574da1e98 Mon Sep 17 00:00:00 2001 From: decaro Date: Sat, 27 Feb 2010 11:02:12 +0000 Subject: [PATCH] Read HVandLV status maps during run from DCS. Store ROandHVandLV status map at EOR in OCDB/TOF/Calib/Status --- TOF/AliTOFDCSmaps.cxx | 107 +++++ TOF/AliTOFDCSmaps.h | 41 ++ TOF/AliTOFGeometry.cxx | 36 ++ TOF/AliTOFGeometry.h | 3 +- TOF/AliTOFLvHvDataPoints.cxx | 900 +++++++++++++++++++++++++++++++++++ TOF/AliTOFLvHvDataPoints.h | 116 +++++ TOF/AliTOFPreprocessor.cxx | 245 ++++++++-- TOF/AliTOFPreprocessor.h | 13 +- TOF/TOFPreprocessorLVHV.C | 448 +++++++++++++++++ TOF/TOFbaseLinkDef.h | 2 + TOF/libTOFbase.pkg | 2 + 11 files changed, 1858 insertions(+), 55 deletions(-) create mode 100644 TOF/AliTOFDCSmaps.cxx create mode 100644 TOF/AliTOFDCSmaps.h create mode 100644 TOF/AliTOFLvHvDataPoints.cxx create mode 100644 TOF/AliTOFLvHvDataPoints.h create mode 100644 TOF/TOFPreprocessorLVHV.C diff --git a/TOF/AliTOFDCSmaps.cxx b/TOF/AliTOFDCSmaps.cxx new file mode 100644 index 00000000000..68e65f75b18 --- /dev/null +++ b/TOF/AliTOFDCSmaps.cxx @@ -0,0 +1,107 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: $ */ + +/////////////////////////////// +// // +// AliTOFDCSmaps class // +// container for HV&&LV maps // +// as found during a run // +// // +/////////////////////////////// + +#include "AliTOFDCSmaps.h" + +ClassImp(AliTOFDCSmaps) + +//////////////////////////////////////////////////////////////////////// +AliTOFDCSmaps::AliTOFDCSmaps() : + TObject(), + fTime(0) +{ + // + // default ctor + // + for (Int_t ii=0; ii<91*96*18; ii++) fArray[ii]=-1; + +} + +//////////////////////////////////////////////////////////////////////// +AliTOFDCSmaps::AliTOFDCSmaps(Int_t time, Short_t array[]) : + TObject(), + fTime(time) +{ + // + // ctor + // + for (Int_t ii=0; ii<91*96*18; ii++) fArray[ii]=array[ii]; +} + +//////////////////////////////////////////////////////////////////////// +AliTOFDCSmaps::AliTOFDCSmaps(const AliTOFDCSmaps & digit): + TObject(digit), + fTime(digit.fTime) +{ + // + // copy ctor + // + for (Int_t ii=0; ii<91*96*18; ii++) fArray[ii]=digit.fArray[ii]; + +} + +//////////////////////////////////////////////////////////////////////// +AliTOFDCSmaps& AliTOFDCSmaps::operator=(const AliTOFDCSmaps & digit) +{ + // + // operator = + // + + if (this == &digit) + return *this; + + TObject::operator=(digit); + + fTime = digit.fTime; + for (Int_t ii=0; ii<91*96*18; ii++) fArray[ii]=digit.fArray[ii]; + return *this; + +} + +//////////////////////////////////////////////////////////////////////// +AliTOFDCSmaps::~AliTOFDCSmaps() +{ + // + // dtor + // +} + +//////////////////////////////////////////////////////////////////////// +void AliTOFDCSmaps::Update(AliTOFDCSmaps *object) +{ + // + // + // + + Short_t value = -1; + + for (Int_t ii=0; ii<91*96*18; ii++) { + value = object->GetCellValue(ii); + if (fArray[ii]==-1 && value!=-1) + fArray[ii] = value; + } + +} + diff --git a/TOF/AliTOFDCSmaps.h b/TOF/AliTOFDCSmaps.h new file mode 100644 index 00000000000..136941d84bd --- /dev/null +++ b/TOF/AliTOFDCSmaps.h @@ -0,0 +1,41 @@ +#ifndef ALITOFDCSMAPS_H +#define ALITOFDCSMAPS_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: $ */ + +/////////////////////////////// +// // +// AliTOFDCSmaps class // +// container for HV&&LV maps // +// as found during a run // +// // +/////////////////////////////// + +#include "TObject.h" + +class AliTOFDCSmaps : public TObject { + + public: + AliTOFDCSmaps(); + AliTOFDCSmaps(Int_t time, Short_t array[]); + AliTOFDCSmaps(const AliTOFDCSmaps & digit); + AliTOFDCSmaps& operator=(const AliTOFDCSmaps & digit) ; + virtual ~AliTOFDCSmaps(); + + Int_t GetTime() const { return fTime; }; + void SetTime(Int_t time) { fTime=time; }; + Short_t GetCellValue(Int_t index) const { return fArray[index]; }; + void SetCellValue(Int_t index, Short_t val) { fArray[index]=val; }; + void Update(AliTOFDCSmaps *object); + private: + Int_t fTime; // time stamp + Short_t fArray[91*96*18]; // array + + ClassDef(AliTOFDCSmaps, 1); + +}; + +#endif diff --git a/TOF/AliTOFGeometry.cxx b/TOF/AliTOFGeometry.cxx index 5dfd0b7b57b..b6f35d561c9 100644 --- a/TOF/AliTOFGeometry.cxx +++ b/TOF/AliTOFGeometry.cxx @@ -1969,6 +1969,42 @@ Int_t AliTOFGeometry::GetStripNumber(Int_t isector, Int_t iplate, Int_t istrip) } //------------------------------------------------------------------------- +void AliTOFGeometry::GetStripAndModule(Int_t iStripPerSM, Int_t &iplate, Int_t &istrip) +{ + // + // Convert the serial number of the TOF strip number iStripPerSM [0,90] + // in module number iplate [0,4] and strip number istrip [0,14/18]. + // + + if (iStripPerSM<0 || iStripPerSM>=kNStripC+kNStripB+kNStripA+kNStripB+kNStripC) { + iplate = -1; + istrip = -1; + } + else if (iStripPerSM=kNStripC && iStripPerSM=kNStripC+kNStripB && iStripPerSM=kNStripC+kNStripB+kNStripA && iStripPerSM=kNStripC+kNStripB+kNStripA+kNStripB && iStripPerSMGetTime()==fLVDataPoints[jj]->GetTime()) + counter++; + } + + + fNumberOfHVandLVmaps = fNumberOfHVdataPoints-2+fNumberOfLVdataPoints-2-counter+2; + AliInfo(Form(" Number of TOF HVandLV dps in the current run = %d",fNumberOfHVandLVmaps)); + + counter=-1; + Int_t timeMaps[kNmaxDataPoints]; + for (Int_t ii=0; iiGetTime(); + + Bool_t check = kTRUE; + for (Int_t jj=0; jjGetTime()!=timeMaps[ii]); + + if (check) { + counter++; + timeMaps[fNumberOfHVdataPoints+counter]=fLVDataPoints[jj]->GetTime(); + } + } + if (fNumberOfHVdataPoints+counter+1!=fNumberOfHVandLVmaps) AliWarning("Something is wrong!"); + + Int_t controller[kNmaxDataPoints]; + for (Int_t ii=0; iiGetCellValue(iPad)*fLVDataPoints[0]->GetCellValue(iPad); + time = timeMaps[controller[0]]; + AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,array); + fMap[0]= object0; + + // HVandLV status map during run + for (Int_t index=1; indexGetTime()==time && fHVDataPoints[ii+1]->GetTime()>time ) && + ( fLVDataPoints[jj]->GetTime()<=time && fLVDataPoints[jj+1]->GetTime()>time ) ) || + ( ( fLVDataPoints[jj]->GetTime()==time && fLVDataPoints[jj+1]->GetTime()>time ) && + ( fHVDataPoints[ii]->GetTime()<=time && fHVDataPoints[ii+1]->GetTime()>time ) ) ) { + + AliDebug(2,Form(" HVdp_time=%d, LVdp_time=%d ",fHVDataPoints[ii]->GetTime(), fLVDataPoints[jj]->GetTime())); + + for (Int_t iPad=0; iPadGetCellValue(iPad)*fLVDataPoints[jj]->GetCellValue(iPad); + AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array); + fMap[index]= object; + break; + } + } + + } + + // HVandLV status map @ EOR + for (Int_t iPad=0; iPadGetCellValue(iPad)*fLVDataPoints[fNumberOfLVdataPoints-1]->GetCellValue(iPad); + time = timeMaps[controller[fNumberOfHVandLVmaps-1]]; + AliTOFDCSmaps *object1 = new AliTOFDCSmaps(time,array); + fMap[fNumberOfHVandLVmaps-1]= object1; + + + return kTRUE; + +} + +//--------------------------------------------------------------- +Bool_t AliTOFLvHvDataPoints::MergeHVmap() { + // + // Create HV maps from HV dps + // + + Bool_t check= kFALSE; + + for (Int_t iPad=0; iPad %1d",iPad,fHVDataPoints[0]->GetCellValue(iPad))); + + if (fNumberOfHVdataPoints==2) + check=kTRUE; + else { + for (Int_t ii=1; iiGetCellValue(iPad)==-1) + fHVDataPoints[ii]->SetCellValue(iPad,fHVDataPoints[ii-1]->GetCellValue(iPad)); + } + for (Int_t iPad=0; iPad %1d",ii,iPad,fHVDataPoints[ii]->GetCellValue(iPad))); + } + + check=kTRUE; + } + + return kTRUE; + +} + +//--------------------------------------------------------------- +Bool_t AliTOFLvHvDataPoints::MergeLVmap() { + // + // Create LV maps from LV dps + // + + Bool_t check= kFALSE; + + for (Int_t iPad=0; iPad %1d",iPad,fLVDataPoints[0]->GetCellValue(iPad))); + + if (fNumberOfLVdataPoints==2) + check=kTRUE; + else { + for (Int_t ii=1; iiGetCellValue(iPad)==-1) + fLVDataPoints[ii]->SetCellValue(iPad,fLVDataPoints[ii-1]->GetCellValue(iPad)); + } + for (Int_t iPad=0; iPad %1d",ii,iPad,fLVDataPoints[ii]->GetCellValue(iPad))); + } + + check=kTRUE; + } + + return check; + +} + +//--------------------------------------------------------------- +Bool_t AliTOFLvHvDataPoints::ReadHVDataPoints(TMap& aliasMap) { + // + // Read HV dps + // + + TObjArray *aliasArr; + AliDCSValue* aValue; + AliDCSValue* aValuePrev; + UInt_t val = 0; + Int_t time = 0; + Int_t nEntries = 0; + + Short_t dummy[kNpads]; + + for (Int_t iBin=0; iBinGetEntries(); + + if (nEntries==0) { + AliError(Form("Alias %s has no entries! Nothing will be stored", + fAliasNamesXHVmap[i][j].Data())); + continue; + } + else { + + for (Int_t iEntry=0; iEntryAt(iEntry); + val = aValue->GetUInt(); + time = aValue->GetTimeStamp(); + if (iEntry==0 || iEntry==nEntries-1) { + FillHVarrayPerDataPoint(i,j,val,dummy); + AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); + InsertHVDataPoint(object); + } + else { + aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1); + if (aValuePrev->GetUInt()!=val) { + FillHVarrayPerDataPoint(i,j,val,dummy); + AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); + InsertHVDataPoint(object); + } + } + + } + } + } + + return kTRUE; + +} + +//--------------------------------------------------------------- +Bool_t AliTOFLvHvDataPoints::ReadLVDataPoints(TMap& aliasMap) { + // + // Read LV dps + // + + TObjArray *aliasArr; + AliDCSValue* aValue; + AliDCSValue* aValuePrev; + UInt_t val = 0; + Int_t time = 0; + Int_t nEntries = 0; + + Short_t dummy[kNpads]; + + for (Int_t iBin=0; iBinGetEntries(); + + if (nEntries==0) { + AliError(Form("Alias %s has no entries! Nothing will be stored", + fAliasNamesXLVmap[i].Data())); + continue; + } + else { + + for (Int_t iEntry=0; iEntryAt(iEntry); + val = aValue->GetUInt(); + time = aValue->GetTimeStamp(); + if (iEntry==0 || iEntry==nEntries-1) { + FillLVarrayPerDataPoint(i,val,dummy); + AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); + InsertLVDataPoint(object); + } + else { + aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1); + if (aValuePrev->GetUInt()!=val) { + FillLVarrayPerDataPoint(i,val,dummy); + AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); + InsertLVDataPoint(object); + } + } + } + } + } + + return kTRUE; + +} + +//--------------------------------------------------------------- +Int_t AliTOFLvHvDataPoints::InsertHVDataPoint(AliTOFDCSmaps *object) +{ + // + // Insert HV dp in the HV dps array. + // The HV dps array is sorted according to increasing dp timeStamp value + // + + if (fNumberOfHVdataPoints==kNmaxDataPoints) { + AliError("Too many HV data points!"); + return 1; + } + + if (fNumberOfHVdataPoints==0) { + fHVDataPoints[fNumberOfHVdataPoints++] = object; + return 0; + } + + for (Int_t index=0; indexGetTime()==fHVDataPoints[index]->GetTime()) { + fHVDataPoints[index]->Update(object); + return 0; + } + } + + Int_t ii = FindHVdpIndex(object->GetTime()); + memmove(fHVDataPoints+ii+1 ,fHVDataPoints+ii,(fNumberOfHVdataPoints-ii)*sizeof(AliTOFDCSmaps*)); + fHVDataPoints[ii] = object; + fNumberOfHVdataPoints++; + + return 0; + +} + +//_________________________________________________________________________ +Int_t AliTOFLvHvDataPoints::FindHVdpIndex(Int_t z) const { + // + // This function returns the index of the nearest HV DP in time + // + + if (fNumberOfHVdataPoints==0) return 0; + if (z <= fHVDataPoints[0]->GetTime()) return 0; + if (z > fHVDataPoints[fNumberOfHVdataPoints-1]->GetTime()) return fNumberOfHVdataPoints; + Int_t b = 0, e = fNumberOfHVdataPoints-1, m = (b+e)/2; + for (; b fHVDataPoints[m]->GetTime()) b=m+1; + else e=m; + } + + return m; + +} + +//--------------------------------------------------------------- +Int_t AliTOFLvHvDataPoints::InsertLVDataPoint(AliTOFDCSmaps *object) +{ + // + // Insert LV dp in the LV dps array. + // The LV dps array is sorted according to increasing dp timeStamp value + // + + if (fNumberOfLVdataPoints==kNmaxDataPoints) { + AliError("Too many LV data points!"); + return 1; + } + + if (fNumberOfLVdataPoints==0) { + fLVDataPoints[fNumberOfLVdataPoints++] = object; + return 0; + } + + for (Int_t index=0; indexGetTime()==fLVDataPoints[index]->GetTime()) { + fLVDataPoints[index]->Update(object); + return 0; + } + } + + Int_t ii = FindLVdpIndex(object->GetTime()); + memmove(fLVDataPoints+ii+1 ,fLVDataPoints+ii,(fNumberOfLVdataPoints-ii)*sizeof(AliTOFDCSmaps*)); + fLVDataPoints[ii] = object; + fNumberOfLVdataPoints++; + + return 0; + +} + +//_________________________________________________________________________ +Int_t AliTOFLvHvDataPoints::FindLVdpIndex(Int_t z) const { + // + // This function returns the index of the nearest LV DP in time + // + + if (fNumberOfLVdataPoints==0) return 0; + if (z <= fLVDataPoints[0]->GetTime()) return 0; + if (z > fLVDataPoints[fNumberOfLVdataPoints-1]->GetTime()) return fNumberOfLVdataPoints; + Int_t b = 0, e = fNumberOfLVdataPoints-1, m = (b+e)/2; + for (; b fLVDataPoints[m]->GetTime()) b=m+1; + else e=m; + } + + return m; + +} + +//--------------------------------------------------------------- +void AliTOFLvHvDataPoints::Init(){ + // + // Initialize aliases and DCS data + // + + TString sindex; + for(int i=0;i=kNddl || nFEAC<0 || nFEAC>=8) return; + + switch (nDDL%4) { + case 0: + firstPadX = 0; + lastPadX = AliTOFGeometry::NpadX()/2-1; + + if (nFEAC<=2) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC; + else if (nFEAC==3) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC; + else if (nFEAC==4) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; + else if (nFEAC==5) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1; + else if (nFEAC==6) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2; + else if (nFEAC==7) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-2; + + break; + case 1: + firstPadX = AliTOFGeometry::NpadX()/2; + lastPadX = AliTOFGeometry::NpadX()-1; + + if (nFEAC<=2) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC; + else if (nFEAC==3) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC; + else if (nFEAC==4) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; + else if (nFEAC==5) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; + else if (nFEAC==6) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1; + else if (nFEAC==7) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2; + + break; + case 2: + firstPadX = AliTOFGeometry::NpadX()/2; + lastPadX = AliTOFGeometry::NpadX()-1; + + if (nFEAC<=2) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC); + else if (nFEAC==3) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC); + else if (nFEAC==4) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); + else if (nFEAC==5) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); + else if (nFEAC==6) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); + else if (nFEAC==7) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); + + break; + case 3: + firstPadX = 0; + lastPadX = AliTOFGeometry::NpadX()/2-1; + + if (nFEAC<=2) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC); + else if (nFEAC==3) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC); + else if (nFEAC==4) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); + else if (nFEAC==5) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); + else if (nFEAC==6) + for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); + else if (nFEAC==7) + for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); + + break; + } + +} + +//--------------------------------------------------------------- +void AliTOFLvHvDataPoints::Draw(const Option_t* /*option*/) +{ + // + // Draw all histos and graphs + // + + if(!fIsProcessed) return; + /* + TCanvas *ch; + TString canvasHistoName="Histos"; + ch = new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600); + ch->cd(); + */ + // to be implemented + +} + + +//--------------------------------------------------------------- +void AliTOFLvHvDataPoints::DrawHVandLVMap(Int_t index) +{ + // + // Draw HV+LV map labelled as index + // + + if(!fIsProcessed) return; + + if (index>=fNumberOfHVandLVmaps) return; + + AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVandLVmap(index); + + char title[100]; + if (index==0) sprintf(title,"HVandLV map at time %d (%dst map)",mappa->GetTime(),index+1); + else if (index==1) sprintf(title,"HVandLV map at time %d (%dnd map)",mappa->GetTime(),index+1); + else if (index==2) sprintf(title,"HVandLV map at time %d (%drd map)",mappa->GetTime(),index+1); + else if (index>=3) sprintf(title,"HVandLV map at time %d (%dth map)",mappa->GetTime(),index+1); + fHisto->Delete(); + fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); + //fHisto->Clear(); + fHisto->SetTitle(title); + + for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); + + fHisto->Draw(); + +} + +//--------------------------------------------------------------- +void AliTOFLvHvDataPoints::DrawLVMap(Int_t index) +{ + // + // Draw LV map labelled as index + // + + if(!fIsProcessed) return; + + if (index>=fNumberOfLVdataPoints) return; + + AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetLVmap(index); + + char title[100]; + if (index==0) sprintf(title,"LV map at time %d (%dst map)",mappa->GetTime(),index+1); + else if (index==1) sprintf(title,"LV map at time %d (%dnd map)",mappa->GetTime(),index+1); + else if (index==2) sprintf(title,"LV map at time %d (%drd map)",mappa->GetTime(),index+1); + else if (index>=3) sprintf(title,"LV map at time %d (%dth map)",mappa->GetTime(),index+1); + fHisto->Delete(); + fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); + //fHisto->Clear(); + fHisto->SetTitle(title); + + for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); + + fHisto->Draw(); + +} + +//--------------------------------------------------------------- +void AliTOFLvHvDataPoints::DrawHVMap(Int_t index) +{ + // + // Draw HV map labelled as index + // + + if(!fIsProcessed) return; + + if (index>=fNumberOfHVdataPoints) return; + + AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVmap(index); + + char title[100]; + if (index==0) sprintf(title,"HV map at time %d (%dst map)",mappa->GetTime(),index+1); + else if (index==1) sprintf(title,"HV map at time %d (%dnd map)",mappa->GetTime(),index+1); + else if (index==2) sprintf(title,"HV map at time %d (%drd map)",mappa->GetTime(),index+1); + else if (index>=3) sprintf(title,"HV map at time %d (%dth map)",mappa->GetTime(),index+1); + fHisto->Delete(); + fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); + //fHisto->Clear(); + fHisto->SetTitle(title); + + for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); + + fHisto->Draw(); + +} + +//--------------------------------------------------------------- +AliTOFDCSmaps *AliTOFLvHvDataPoints::GetHVandLVmapAtEOR() +{ + // + // Returns HVandLV status map at EOR. + // If the end-of-run has been caused by TOF self, + // the last but two value of HVandLV status map + // will be taken into account. + // This last condition is true + // if the time interval between the second-last DP and the last one + // is less than 60s. + // + + AliTOFDCSmaps * lvANDhvMap = 0; + + if (fNumberOfHVandLVmaps==2) { // nothing changed during the run + + lvANDhvMap = fMap[fNumberOfHVandLVmaps-1]; + + } + else { + + if (fMap[fNumberOfHVandLVmaps-1]->GetTime()-fMap[fNumberOfHVandLVmaps-2]->GetTime()<=60) + lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-3]; + else + lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-1]; + + } + + return lvANDhvMap; + +} diff --git a/TOF/AliTOFLvHvDataPoints.h b/TOF/AliTOFLvHvDataPoints.h new file mode 100644 index 00000000000..525c442796a --- /dev/null +++ b/TOF/AliTOFLvHvDataPoints.h @@ -0,0 +1,116 @@ +#ifndef ALITOFLVHVDATAPOINTS_H +#define ALITOFLVHVDATAPOINTS_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id: $ */ + +///////////////////////////////////////////////////////// +// // +// AliTOFLvHvDataPoints class // +// main aim to introduce // +// the aliases for the TOF LV and HV DCS data points // +// to be then stored in the OCDB, and to process them. // +// // +///////////////////////////////////////////////////////// + +#include "TObject.h" +#include "TH1C.h" + +#include "AliTOFDCSmaps.h" + +class TMap; +class TClonesArray; +class TString; + +class AliTOFLvHvDataPoints : public TObject { +public: + enum {kNsectors=18, kNplates=5, kNddl=72, kNpads=18*91*96, kNmaxDataPoints=77777}; + + AliTOFLvHvDataPoints(); + AliTOFLvHvDataPoints(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery ); + AliTOFLvHvDataPoints(const AliTOFLvHvDataPoints & data); + AliTOFLvHvDataPoints& operator=(const AliTOFLvHvDataPoints & data); + ~AliTOFLvHvDataPoints(); + + void SetRun(Int_t run) {fRun = run;} + void SetStartTime(Int_t startTime) {fStartTime = startTime;} + void SetEndTime(Int_t endTime) {fEndTime = endTime;} + void SetStartTimeDCSQuery(Int_t startTimeDCSQuery) {fStartTimeDCSQuery = startTimeDCSQuery;} + void SetEndTimeDCSQuery(Int_t endTimeDCSQuery) {fEndTimeDCSQuery = endTimeDCSQuery;} + Int_t GetRun() const {return fRun;} + Int_t GetStartTime() const {return fStartTime;} + Int_t GetEndTime() const {return fEndTime;} + Int_t GetStartTimeDCSQuery() const {return fStartTimeDCSQuery;} + Int_t GetEndTimeDCSQuery() const {return fEndTimeDCSQuery;} + + Bool_t ProcessData(TMap& aliasMap); + + const char* GetAliasNameXLV(Int_t pos) const + {return pos=fNumberOfHVandLVmaps) return 0x0; else return fMap[index]; }; + Int_t GetNumberOfLVmaps() const { return fNumberOfLVdataPoints; }; + AliTOFDCSmaps * GetLVmap(Int_t index) { if (index>=fNumberOfLVdataPoints) return 0x0; else return fLVDataPoints[index]; }; + Int_t GetNumberOfHVmaps() const { return fNumberOfHVdataPoints; }; + AliTOFDCSmaps * GetHVmap(Int_t index) { if (index>=fNumberOfHVdataPoints) return 0x0; else return fHVDataPoints[index]; }; + +private: + void Init(); + void CreateHisto(int nbin); + void FillHVarrayPerDataPoint(Int_t sector, Int_t plate, UInt_t baseWord, Short_t *array); + void FillLVarrayPerDataPoint(Int_t nDDL, UInt_t baseWord, Short_t *array); + void GetStripsConnectedToFEAC(Int_t nDDL, Int_t nFEAC, Int_t *iStrip, Int_t &firstPadX, Int_t &lastPadX); + + Bool_t ReadHVDataPoints(TMap& aliasMap); + Bool_t ReadLVDataPoints(TMap& aliasMap); + + Bool_t MergeMaps(); + Bool_t MergeHVmap(); + Bool_t MergeLVmap(); + + Int_t InsertHVDataPoint(AliTOFDCSmaps *object); + Int_t FindHVdpIndex(Int_t z) const; + Int_t InsertLVDataPoint(AliTOFDCSmaps *object); + Int_t FindLVdpIndex(Int_t z) const; + Int_t fRun; // Run number + Int_t fStartTime; // start time + Int_t fEndTime; // end time + Int_t fStartTimeDCSQuery; // start time DCSQuery + Int_t fEndTimeDCSQuery; // end time DCSQuery + + Bool_t fIsProcessed; // bool to know processing status + Bool_t fFDR; // bool to know whether we are in a FDR run + + AliTOFDCSmaps *fLVDataPoints[kNmaxDataPoints]; // LV status map VS time + AliTOFDCSmaps *fHVDataPoints[kNmaxDataPoints]; // HV status map VS time + AliTOFDCSmaps *fMap[kNmaxDataPoints]; // LV&&HV status map VS time + + Int_t fNumberOfLVdataPoints; // number of found LV status dps + Int_t fNumberOfHVdataPoints; // number of found HV status dps + Int_t fNumberOfHVandLVmaps; // number of found LV&&HV status maps + + TString fAliasNamesXLVmap[kNddl]; // aliases for LV map + TString fAliasNamesXHVmap[kNsectors][kNplates]; // aliases for HV map + + TH1C * fHisto; // histogram + + ClassDef(AliTOFLvHvDataPoints, 1); +}; + +#endif diff --git a/TOF/AliTOFPreprocessor.cxx b/TOF/AliTOFPreprocessor.cxx index 4952fb8bae7..7e1119f4f20 100644 --- a/TOF/AliTOFPreprocessor.cxx +++ b/TOF/AliTOFPreprocessor.cxx @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -33,6 +35,7 @@ #include "AliTOFChannelOnlineArray.h" #include "AliTOFChannelOnlineStatusArray.h" #include "AliTOFDataDCS.h" +#include "AliTOFLvHvDataPoints.h" #include "AliTOFGeometry.h" #include "AliTOFPreprocessor.h" #include "AliTOFFEEReader.h" @@ -83,13 +86,15 @@ const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to 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"); @@ -118,6 +123,7 @@ void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, 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(); } //_____________________________________________________________________________ @@ -136,7 +142,7 @@ Bool_t AliTOFPreprocessor::ProcessDCS(){ } //_____________________________________________________________________________ -UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap) +UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap * const dcsAliasMap) { // Fills data into a AliTOFDataDCS object @@ -199,6 +205,177 @@ UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap) } //_____________________________________________________________________________ +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; indexGetCellValue(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; indexGetCellValue(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 @@ -985,7 +1162,7 @@ UInt_t AliTOFPreprocessor::ProcessFEEData() 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); @@ -1026,7 +1203,8 @@ UInt_t AliTOFPreprocessor::ProcessFEEData() 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); @@ -1042,7 +1220,8 @@ UInt_t AliTOFPreprocessor::ProcessFEEData() Log(" *********************************"); delete fStatus; fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); - updateOCDB = kTRUE; + //updateOCDB = kTRUE; + fIsStatusMapChanged = kTRUE; } } for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){ @@ -1055,19 +1234,22 @@ UInt_t AliTOFPreprocessor::ProcessFEEData() 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))); } @@ -1109,56 +1291,16 @@ UInt_t AliTOFPreprocessor::ProcessFEEData() } } - /* 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(); @@ -1188,7 +1330,8 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap) } else { Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap); - return iresultDCS; + Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap); + return iresultDCS+iResultHVandLVdps; } } diff --git a/TOF/AliTOFPreprocessor.h b/TOF/AliTOFPreprocessor.h index 0e833d3b776..809daf68df2 100644 --- a/TOF/AliTOFPreprocessor.h +++ b/TOF/AliTOFPreprocessor.h @@ -13,7 +13,9 @@ // and DAQ histograms to compute online calibration constants class AliTOFDataDCS; +class AliTOFLvHvDataPoints; class AliTOFChannelOnlineStatusArray; +class AliTOFChannelOnlineArray; class TObjArray; class TH2S; @@ -29,13 +31,14 @@ class AliTOFPreprocessor : public AliPreprocessor protected: virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); - virtual UInt_t Process(TMap* dcsAliasMap); + virtual UInt_t Process(TMap * const dcsAliasMap); virtual Bool_t ProcessDCS(); private: AliTOFPreprocessor(const AliTOFPreprocessor & proc); // copy constructor AliTOFPreprocessor& operator=(const AliTOFPreprocessor & proc); - UInt_t ProcessDCSDataPoints(TMap* dcsAliasMap); + UInt_t ProcessDCSDataPoints(TMap * const dcsAliasMap); + UInt_t ProcessHVandLVdps(TMap * const dcsAliasMap); UInt_t ProcessOnlineDelays(); UInt_t ProcessPulserData(); UInt_t ProcessNoiseData(); @@ -51,6 +54,7 @@ class AliTOFPreprocessor : public AliPreprocessor static const Double_t fgkThrPar; // parameter used to trigger the // calculation of the delay AliTOFDataDCS *fData; // CDB class that stores the data + AliTOFLvHvDataPoints *fHVLVmaps; // HV and LV status maps AliTOFChannelOnlineArray *fCal; // TOF Calibration object Int_t fNChannels; // number of TOF channels Bool_t fStoreRefData; // Flag to decide storage of Ref Data @@ -60,6 +64,9 @@ class AliTOFPreprocessor : public AliPreprocessor // Array of matching windows (one per channel) - to be used in noise runs Int_t *fLatencyWindow; //[fNChannels] // Array of latency windows (one per channel) - ClassDef(AliTOFPreprocessor, 0); + Bool_t fIsStatusMapChanged; // flag to check is the status map OCDB has to be updated + + ClassDef(AliTOFPreprocessor, 1); + }; #endif diff --git a/TOF/TOFPreprocessorLVHV.C b/TOF/TOFPreprocessorLVHV.C new file mode 100644 index 00000000000..6ed8f3b35bd --- /dev/null +++ b/TOF/TOFPreprocessorLVHV.C @@ -0,0 +1,448 @@ +/* +$Id: TOFPreprocessor.C 38207 2010-01-13 14:08:33Z rpreghen $ +*/ + +// This class runs the test TOF preprocessor +// It uses AliTestShuttle to simulate a full Shuttle process + +// The input data is created in the functions +// CreateDCSAliasMap() creates input that would in the same way come from DCS +// ReadDCSAliasMap() reads from a file +// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle + + +#ifndef __CINT__ +#include "TDatime.h" +#include "TMap.h" +#include "TFile.h" +#include "TObjString.h" +#include "TRandom.h" +#include "TBenchmark.h" +#include "TString.h" + +#include "AliBitPacking.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" +#include "AliDCSValue.h" +#include "AliLog.h" +#include "AliTestShuttle.h" +#include "AliShuttleInterface.h" + +#include "AliTOFDataDCS.h" +#include "AliTOFPreprocessor.h" +#include "AliTOFGeometry.h" +//#include "AliTOFChannelOnlineArray.h" +#endif + +void TOFPreprocessorLVHV(Char_t * RunType="PHYSICS"); +TMap* CreateDCSAliasMap(); +TMap* ReadDCSAliasMap(); +//TMap* CreateInputFilesMap(); +UInt_t CreateHVword(Int_t sec, Int_t pla, Bool_t isAtBorder); +UInt_t CreateLVword(Bool_t isAtBorder); + + + +extern TBenchmark *gBenchmark; +void TOFPreprocessorLVHV(Char_t * RunType) +{ + gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); + + AliLog::SetClassDebugLevel("AliTOFPreprocessor",2); + // initialize location of CDB + AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); + AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); + + // create AliTestShuttle instance + Int_t nrun = 7; + AliTestShuttle* shuttle = new AliTestShuttle(nrun, 30, 980); + //setting run type to physiscs + shuttle->SetInputRunType(RunType); + shuttle->SetTimeCreated(20); + shuttle->SetDCSQueryOffset(20); + + // Generation of "fake" input DCS data + TMap* dcsAliasMap = CreateDCSAliasMap(); + + TFile *file=TFile::Open("dcsMap.root","RECREATE"); + file->cd(); + dcsAliasMap->Write(); + file->Close(); + + + // now give the alias map to the shuttle + shuttle->SetDCSInput(dcsAliasMap); + + // processing files. for the time being, the files are local. + shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root"); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root"); + shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeLightMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEElight.20090616.102605.8000"); + shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20091217.194708.105517"); + + TString filename; + TString LDCname; + //char filename[100]; + //char LDCname[5]; + + for (Int_t iLDC=0;iLDC<2;iLDC++){ + filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2); + LDCname.Form("LDC%i",iLDC*2); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename); + filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2); + LDCname.Form("LDC%i",iLDC*2); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename); + } + + + // instantiation of the preprocessor + AliPreprocessor* pp = new AliTOFPreprocessor(shuttle); + pp->Print(); + + // preprocessing + gBenchmark->Start("process"); + shuttle->Process(); + gBenchmark->Stop("process"); + gBenchmark->Print("process"); + + // checking the file which should have been created + AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnlineDelay", nrun); + if (!chkEntry) + { + printf("The file is not there. Something went wrong.\n"); + return; + } + + AliTOFDataDCS* output = dynamic_cast (chkEntry->GetObject()); + // If everything went fine, draw the result + if (output) + printf("Output found.\n"); + // output->Draw(); + + + //shuttle->Delete(); + +} + +TMap* CreateDCSAliasMap() +{ + // Creates a DCS structure + // The structure is the following: + // TMap (key --> value) + // --> + // is a string + // is a TObjArray of AliDCSValue + // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue + + // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 + // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias + + TMap* aliasMap = new TMap; + aliasMap->SetOwner(1); + + TRandom random; + /* + TDatime *datime = new TDatime(); + Int_t time = datime->GetTime(); + Int_t date = datime->GetDate(); + Int_t pid = gSystem->GetPid(); + delete datime; + Int_t iseed = TMath::Abs(10000 * pid + time - date); + */ + + + Float_t tentHVv=6500, tentHVi=80; + Float_t sigmaHVv=10, sigmaHVi=10; + + Float_t tent=0, sigma=0;//, thr=0; + // to have all the aliases, decomment the following line: + Int_t NAliases=360, NHV=90; + + + // if not all the aliases are there, use this: + //Int_t NAliases=120, NHV=90; + + TString sindex; + TString aliasName; + + for(int nAlias=0;nAliasSetOwner(1); + + if (nAliassigma){ + AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); + valueSet->Add(dcsVal); + } + } + + aliasMap->Add(new TObjString(aliasName), valueSet); + + } + + + + + const Int_t kNsectors = 18; + const Int_t kNplates = 5; + + UInt_t baseWord = 0; + UInt_t oldBaseWord = 0; + + for(int i=0;iSetOwner(1); + + aliasName = "TOF_HVSTATUS_"; + sindex.Form("SM%02dMOD%1d",i,j); + aliasName += sindex; + + + //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) { + for (int timeStamp=0;timeStamp<1201;timeStamp+=600) { + if (timeStamp==0 /*|| timeStamp==1200*/) { + baseWord = CreateHVword(i,j, kTRUE); + oldBaseWord = baseWord; + AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp); + valueSetHV->Add(dcsVal); + } + else { + if (random.Uniform(0.,1.)>=0.5) { + baseWord = CreateHVword(i,j, kFALSE); + if (baseWord<=oldBaseWord) { + oldBaseWord = baseWord; + AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp); + valueSetHV->Add(dcsVal); + } + else { + AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp); + valueSetHV->Add(dcsVal); + } + //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord)); + } + } + } + + /* + baseWord = CreateHVword(i,j, kTRUE); + AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0); + valueSetHV->Add(dcsVal0); + + if ((i==0 && j==2) || (i==9 && j==4)) { + baseWord = CreateHVword(i,j, kFALSE); + AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 600); + valueSetHV->Add(dcsVal1); + } + + baseWord = CreateHVword(i,j, kTRUE); + AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 1200); + valueSetHV->Add(dcsVal2); + */ + + aliasMap->Add(new TObjString(aliasName), valueSetHV); + + } + + + const Int_t kNddl = 72; + baseWord = 0; + oldBaseWord = 0; + + for(int i=0;iSetOwner(1); + + aliasName = "TOF_FEACSTATUS_"; + sindex.Form("%02d",i); + aliasName += sindex; + + + //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) { + for (int timeStamp=0;timeStamp<1201;timeStamp+=400) { + if (timeStamp==0 /*|| timeStamp==1200*/) { + baseWord = CreateLVword(kTRUE); + AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp); + valueSetLV->Add(dcsVal); + oldBaseWord = baseWord; + //Info(Form(" %2d %s %d %d",i,aliasName,timeStamp,baseWord)); + } + else { + if (random.Uniform(0.,1.)>=0.5) { + baseWord = CreateLVword(kFALSE); + if (baseWord<=oldBaseWord) { + oldBaseWord = baseWord; + AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp); + valueSetLV->Add(dcsVal); + } + else { + AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp); + valueSetLV->Add(dcsVal); + } + //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord)); + } + } + } + + /* + baseWord = CreateLVword(kTRUE); + AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0); + valueSetLV->Add(dcsVal0); + + if (i==7 || i==9) { + baseWord = CreateLVword(kFALSE); + AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 400); + valueSetLV->Add(dcsVal1); + } + else if (i==50 || i==35) { + baseWord = CreateLVword(kFALSE); + AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 800); + valueSetLV->Add(dcsVal2); + } + + baseWord = CreateLVword(kTRUE); + AliDCSValue* dcsVal3 = new AliDCSValue(baseWord, 1200); + valueSetLV->Add(dcsVal3); + */ + + aliasMap->Add(new TObjString(aliasName), valueSetLV); + + } + + + return aliasMap; +} + + +UInt_t CreateHVword(Int_t nSector, Int_t nPlate, Bool_t isAtBorder) { + // + // + // + + UInt_t baseWord = 0; + UInt_t word = 0; + TRandom random; + + for (Int_t iStrip=0; iStrip=13 && nSector<=15) + word = 0; + } + else { + random.Uniform(0.,1.)<0.5 ? word = 0 : word = 1; + if (nPlate==2 && nSector>=13 && nSector<=15) + word = 0; + word = 0; + } + + AliBitPacking::PackWord(word,baseWord,iStrip,iStrip); + } + + return baseWord; + +} + + +UInt_t CreateLVword(Bool_t isAtBorder) { + // + // + // + + UInt_t baseWord = 0; + UInt_t word = 0; + TRandom random; + + for (Int_t iFeac=0; iFeac<8; iFeac++) { + + if (isAtBorder) + word = 1; + else { + random.Uniform(0.,1.)<0.5 ? word = 0 : word = 1; + word = 0; + } + + AliBitPacking::PackWord(word,baseWord,iFeac,iFeac); + } + + return baseWord; + +} + + +TMap* ReadDCSAliasMap() +{ + // Open a file that contains DCS input data + // The CDB framework is used to open the file, this means the file is located + // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB//DCS/Data + // The file contains an AliCDBEntry that contains a TMap with the DCS structure. + // An explanation of the structure can be found in CreateDCSAliasMap() + + AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); + return dynamic_cast (entry->GetObject()); +} + +void WriteDCSAliasMap() +{ + // This writes the output from CreateDCSAliasMap to a CDB file + + TMap* dcsAliasMap = CreateDCSAliasMap(); + + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Chiara"); + metaData.SetComment("Test object for TOFPreprocessor.C"); + + AliCDBId id("TOF/DCS/Data", 0, 0); + + // initialize location of CDB + AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); + + AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); +} diff --git a/TOF/TOFbaseLinkDef.h b/TOF/TOFbaseLinkDef.h index 0c55ba0739d..04ff98b6a82 100644 --- a/TOF/TOFbaseLinkDef.h +++ b/TOF/TOFbaseLinkDef.h @@ -38,6 +38,8 @@ #pragma link C++ class AliTOFDeltaBCOffset+; #pragma link C++ class AliTOFCTPLatency+; #pragma link C++ class AliTOFT0Fill+; +#pragma link C++ class AliTOFDCSmaps+; +#pragma link C++ class AliTOFLvHvDataPoints+; #endif diff --git a/TOF/libTOFbase.pkg b/TOF/libTOFbase.pkg index 7442382f1d6..f43673a686e 100644 --- a/TOF/libTOFbase.pkg +++ b/TOF/libTOFbase.pkg @@ -31,6 +31,8 @@ SRCS = AliTOFGeometry.cxx \ AliTOFDeltaBCOffset.cxx \ AliTOFCTPLatency.cxx \ AliTOFT0Fill.cxx \ + AliTOFLvHvDataPoints.cxx \ + AliTOFDCSmaps.cxx HDRS:= $(SRCS:.cxx=.h) -- 2.39.3