From 4188a021ac4b30f00c30f850e7079c5434f1b5ee Mon Sep 17 00:00:00 2001 From: mbroz Date: Wed, 5 Nov 2014 09:10:59 +0100 Subject: [PATCH] Preprocessor for AD --- AD/ADbaseLinkDef.h | 5 +- AD/AliADCalibData.cxx | 25 ++- AD/AliADCalibData.h | 5 + AD/AliADDataDCS.cxx | 303 +++++++++++++++++++++++++++++++++ AD/AliADDataDCS.h | 90 ++++++++++ AD/AliADPreprocessor.cxx | 175 +++++++++++++++++++ AD/AliADPreprocessor.h | 32 ++++ AD/CMakelibADbase.pkg | 4 +- AD/macros/AD0da_results.txt | 32 ++++ AD/macros/ADTestPreprocessor.C | 206 ++++++++++++++++++++++ AD/macros/DCSValues.txt | 61 +++++++ 11 files changed, 932 insertions(+), 6 deletions(-) create mode 100644 AD/AliADDataDCS.cxx create mode 100644 AD/AliADDataDCS.h create mode 100644 AD/AliADPreprocessor.cxx create mode 100644 AD/AliADPreprocessor.h create mode 100644 AD/macros/AD0da_results.txt create mode 100644 AD/macros/ADTestPreprocessor.C create mode 100644 AD/macros/DCSValues.txt diff --git a/AD/ADbaseLinkDef.h b/AD/ADbaseLinkDef.h index e2e4fda6566..d133a0931d4 100644 --- a/AD/ADbaseLinkDef.h +++ b/AD/ADbaseLinkDef.h @@ -10,9 +10,8 @@ #pragma link C++ class AliADdigit+; #pragma link C++ class AliADSDigit+; #pragma link C++ class AliADCalibData+; -//#pragma link C++ class AliADCalibData+; -//#pragma link C++ class AliADPreprocessor+; -//#pragma link C++ class AliADDataDCS+; +#pragma link C++ class AliADPreprocessor+; +#pragma link C++ class AliADDataDCS+; //#pragma link C++ class AliADQAChecker+; //#pragma link C++ class AliADMisAligner+; //#pragma link C++ class AliADLogicalSignal+; diff --git a/AD/AliADCalibData.cxx b/AD/AliADCalibData.cxx index 87d744fd0d1..2eced28feca 100644 --- a/AD/AliADCalibData.cxx +++ b/AD/AliADCalibData.cxx @@ -21,8 +21,10 @@ #include #include +#include "AliDCSValue.h" #include "AliCDBManager.h" #include "AliCDBEntry.h" +#include "AliADDataDCS.h" #include "AliADCalibData.h" #include "AliADConst.h" #include "AliLog.h" @@ -293,7 +295,28 @@ Float_t AliADCalibData::GetCalibDiscriThr(Int_t channel, Bool_t scaled) return calThr; } +//_____________________________________________________________________________ +void AliADCalibData::FillDCSData(AliADDataDCS * data){ + // Set all parameters from the data get by the shuttle + TMap * params = data->GetFEEParameters(); + TIter iter(params); + TObjString* aliasName; + + while (( aliasName = (TObjString*) iter.Next() )) { + AliDCSValue* aValue = (AliDCSValue*) params->GetValue(aliasName); + Int_t val; + if(aValue) { + val = aValue->GetInt(); + AliInfo(Form("%s : %d",aliasName->String().Data(), val)); + SetParameter(aliasName->String(),val); + } + } + + SetMeanHV(data->GetMeanHV()); + SetWidthHV(data->GetWidthHV()); + SetDeadMap(data->GetDeadMap()); +} //_____________________________________________________________________________ void AliADCalibData::SetParameter(TString name, Int_t val){ // Set given parameter @@ -317,7 +340,7 @@ void AliADCalibData::SetParameter(TString name, Int_t val){ else if(name.Contains("TriggerCountOffset")) SetTriggerCountOffset((UInt_t) val,iBoard); else if(name.Contains("RollOver")) SetRollOver((UInt_t) val,iBoard); else if(name.Contains("DelayHit")) SetTimeOffset(0.01*(Float_t)val,iBoard,(iChannel-1)); - else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-2040.)/112.,iBoard,(iChannel-1)); + else if(name.Contains("DiscriThr")) SetDiscriThr(((Float_t)val-1040.)/112.,iBoard,(iChannel-1)); else AliError(Form("No Setter found for FEE parameter : %s",name.Data())); // delete nameSplit; diff --git a/AD/AliADCalibData.h b/AD/AliADCalibData.h index 6089ab471cc..a574c92d532 100644 --- a/AD/AliADCalibData.h +++ b/AD/AliADCalibData.h @@ -6,6 +6,10 @@ #include "TNamed.h" #include "AliADConst.h" + +class AliADDataDCS; + + class AliADCalibData: public TNamed { public: @@ -16,6 +20,7 @@ class AliADCalibData: public TNamed { AliADCalibData& operator= (const AliADCalibData &calibda); virtual ~AliADCalibData(); void Reset(); + void FillDCSData(AliADDataDCS * data); Float_t GetPedestal(Int_t channel) const {return fPedestal[channel];} Float_t* GetPedestal() const {return (float*)fPedestal;} diff --git a/AD/AliADDataDCS.cxx b/AD/AliADDataDCS.cxx new file mode 100644 index 00000000000..ca7e0218e88 --- /dev/null +++ b/AD/AliADDataDCS.cxx @@ -0,0 +1,303 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + + +#include "AliADDataDCS.h" + +#include "AliDCSValue.h" +#include "AliLog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +class TH2; +class AliCDBMetaData; +class TDatime; + +// AliADDataDCS class +// main aim to introduce the aliases for the AD DCS +// data points to be then +// stored in the OCDB, and to process them. +// ProcessData() method called by ADPreprocessor + +ClassImp(AliADDataDCS) + +//_____________________________________________________________________________ +AliADDataDCS::AliADDataDCS(): + TObject(), + fRun(0), + fStartTime(0), + fEndTime(0), + fDaqStartTime(0), + fDaqEndTime(0), + fCtpStartTime(0), + fCtpEndTime(0), + fGraphs("TGraph",kNGraphs), + fFEEParameters(NULL), + fIsProcessed(kFALSE) + +{ + // Default constructor + for(int i=0;iSetOwnerValue(); + Init(); + +} + +//_____________________________________________________________________________ +AliADDataDCS::~AliADDataDCS() { + + // destructor + fGraphs.Clear("C"); + delete fFEEParameters; + +} + +//_____________________________________________________________________________ +Bool_t AliADDataDCS::ProcessData(TMap& aliasMap){ + + // method to process the data + Bool_t success = kTRUE; + + if(!(fAliasNames[0])) Init(); + + TObjArray *aliasArr; + AliDCSValue* aValue; + + // starting loop on aliases + for(int iAlias=0; iAliasGetEntries()<2){ + AliWarning(Form("Alias %s has just %d entries!", + fAliasNames[iAlias].Data(),aliasArr->GetEntries())); + } + + TIter iterarray(aliasArr); + + if(iAliasGetEntries(); + + Double_t *times = new Double_t[nentries]; + Double_t *values = new Double_t[nentries]; + + UInt_t iValue=0; + Float_t variation = 0.0; + + while((aValue = (AliDCSValue*) iterarray.Next())) { + UInt_t currentTime = aValue->GetTimeStamp(); + //if(currentTime>fCtpEndTime) break; //What is this for? + + values[iValue] = aValue->GetFloat(); + times[iValue] = (Double_t) (currentTime); + + if(iValue>0) { + if(values[iValue-1]>0.) variation = TMath::Abs(values[iValue]-values[iValue-1])/values[iValue-1]; + if(variation > 0.01) fDeadChannel[GetOfflineChannel(iAlias)] = kTRUE; + } + fHv[iAlias]->Fill(values[iValue]); + printf("%s : %s : %f Dead=%d\n",fAliasNames[iAlias].Data(),TTimeStamp(currentTime).AsString(),values[iValue],fDeadChannel[GetOfflineChannel(iAlias)]); + iValue++; + } + CreateGraph(iAlias, aliasArr->GetEntries(), times, values); // fill graphs + + // calculate mean and rms of the first two histos + // and convert index to aliroot channel + Int_t iChannel = GetOfflineChannel(iAlias); + fMeanHV[iChannel] = fHv[iAlias]->GetMean(); + fWidthHV[iChannel] = fHv[iAlias]->GetRMS(); + + delete[] values; + delete[] times; + } else { // Treating FEE Parameters + AliDCSValue * lastVal = NULL; + while((aValue = (AliDCSValue*) iterarray.Next())) lastVal = aValue; // Take only the last value + fFEEParameters->Add(new TObjString(fAliasNames[iAlias].Data()),lastVal); + } + } + + fIsProcessed=kTRUE; + + return success; +} + +//_____________________________________________________________________________ +void AliADDataDCS::Init(){ + + // initialization of aliases and DCS data + + TString sindex; + int iAlias = 0; + + for(int iSide = 0; iSide<2 ; iSide++){ + for(int iRing = 0; iRing<4 ; iRing++){ + for(int iSector = 0; iSector<2 ; iSector++){ + if(iSide == 0) fAliasNames[iAlias] = "AD0/HV/V0A/SECTOR"; + else fAliasNames[iAlias] = "AD0/HV/V0C/SECTOR"; + sindex.Form("%d/RING%d",iSector,iRing); + fAliasNames[iAlias] += sindex; + + fHv[iAlias] = new TH1F(fAliasNames[iAlias].Data(),fAliasNames[iAlias].Data(), 3000, kHvMin, kHvMax); + fHv[iAlias]->GetXaxis()->SetTitle("Hv"); + iAlias++; + } + } + } + + // Time Resolution Parameters + + for(int iCIU = 0; iCIU<2 ; iCIU++){ + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/TimeResolution",iCIU); + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/WidthResolution",iCIU); + } + + // HPTDC parameters + for(int iCIU = 0; iCIU<2 ; iCIU++){ + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/MatchWindow",iCIU); + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/SearchWindow",iCIU); + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/TriggerCountOffset",iCIU); + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/RollOver",iCIU); + } + + for(int iCIU = 0; iCIU<2 ; iCIU++){ + for(int iCh=1;iCh<=8;iCh++){ + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/DelayHit%d",iCIU,iCh); + } + } + + for(int iCIU = 0; iCIU<2 ; iCIU++){ + for(int iCh=1;iCh<=8;iCh++){ + fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/DiscriThr%d",iCIU,iCh); + } + } + + if(iAlias!=kNAliases) + AliError(Form("Number of DCS Aliases defined not correct")); + +} + +//_____________________________________________________________________________ +void AliADDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const +{ + + // method to introduce new aliases + + int entries=aliasArr->GetEntries(); + AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data())); + AliInfo(Form(" %d DP values collected",entries)); + +} + +//_____________________________________________________________________________ +void AliADDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y) +{ + + // Create graphics + + TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y); + + gr->GetXaxis()->SetTimeDisplay(1); + gr->SetTitle(fAliasNames[i].Data()); + + AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast())); + +} + + +//_____________________________________________________________________________ +void AliADDataDCS::Draw(const Option_t* /*option*/) +{ +// Draw all histos and graphs + + if(!fIsProcessed) return; + + if(fGraphs.GetEntries()==0) return; + + TString canvasName; + TCanvas *cHV[8]; + + for(int iSide = 0 ;iSide<2;iSide++){ + for(int iRing=0;iRing<4;iRing++){ + if(iSide == 0) canvasName = "V0A_Ring"; + else canvasName = "V0C_Ring"; + canvasName += iRing; + int iCanvas = iSide*4 + iRing; + cHV[iCanvas] = new TCanvas(canvasName,canvasName); + cHV[iCanvas]->Divide(3,3); + for(int iSector=0;iSector<2;iSector++){ + cHV[iCanvas]->cd(iSector+1); + int iChannel = iSide*8 + iRing*2 + iSector; + ((TGraph*) fGraphs.UncheckedAt(iChannel))->SetMarkerStyle(20); + ((TGraph*) fGraphs.UncheckedAt(iChannel))->Draw("ALP"); + + } + + } + } + +} + diff --git a/AD/AliADDataDCS.h b/AD/AliADDataDCS.h new file mode 100644 index 00000000000..6cedab4b63f --- /dev/null +++ b/AD/AliADDataDCS.h @@ -0,0 +1,90 @@ +#ifndef AliADDataDCS_H +#define AliADDataDCS_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +#include +#include + +class TMap; +class TH2F; +class TGraph; +class TF1; +class TString; +class TH1F; + +// AliADDataDCS class +// main aim is to process DCS data +// in order to obtain the data to be stored in the OCDB + +class AliADDataDCS : public TObject { +public: + enum {kNAliases=60,kNGraphs=16,kNHvChannel=16,kNLvChannel=4,kNCIUBoards = 2}; + enum {kHvMin=0, kHvMax=3000}; + + AliADDataDCS(); + AliADDataDCS(Int_t nRun, UInt_t timeCreated, UInt_t timeCompleted, UInt_t daqStart, UInt_t daqEnd, UInt_t ctpStart, UInt_t ctpEnd); + ~AliADDataDCS(); + + void SetRun(Int_t run) {fRun = run;} + void SetStartTime(Int_t startTime) {fStartTime = startTime;} + void SetEndTime(Int_t endTime) {fEndTime = endTime;} + void SetDaqStartTime(Int_t startTime) {fDaqStartTime = startTime;} + void SetDaqEndTime(Int_t endTime) {fDaqEndTime = endTime;} + Int_t GetRun() const {return fRun;} + Int_t GetStartTime() const {return fStartTime;} + Int_t GetEndTime() const {return fEndTime;} + Int_t GetDaqStartTime() const {return fDaqStartTime;} + Int_t GetDaqEndTime() const {return fDaqEndTime;} + + Bool_t ProcessData(TMap& aliasMap); + + const char* GetAliasName(Int_t pos) const + {return pos +#include +#include +#include +#include + + +class Tlist; + +// +// This class is a simple preprocessor for AD detector. +// +// It gets High Voltage values for a given run from DCS and Pedestal values from DAQ +// and writes them as Calibration MetaData into OCDB/AD/Calib/Data +// It also retrieves FEE parameters from DCS archive +// and writes them as Trigger MetaData into OCDB/AD/Trigger/Data +// (to be used for trigger simulation) +// + +ClassImp(AliADPreprocessor) + +//______________________________________________________________________________________________ +AliADPreprocessor::AliADPreprocessor(AliShuttleInterface* shuttle) : + AliPreprocessor("AD0", shuttle), + fDCSData(0) + +{ + // constructor + + AddRunType("STANDALONE_PULSER"); + AddRunType("STANDALONE_BC"); + AddRunType("PHYSICS"); + +} + +//______________________________________________________________________________________________ +AliADPreprocessor::~AliADPreprocessor() +{ + // destructor + delete fDCSData; + +} + +//______________________________________________________________________________________________ +void AliADPreprocessor::Initialize(Int_t run, UInt_t startTime, + UInt_t endTime) +{ + // Creates AliADDataDCS object + + AliPreprocessor::Initialize(run, startTime, endTime); + + Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, + TTimeStamp(startTime).AsString(), + TTimeStamp(endTime).AsString())); + + fRun = run; + // fStartTime = startTime; + // fEndTime = endTime; + fStartTime = GetStartTimeDCSQuery (); + fEndTime = GetEndTimeDCSQuery (); + time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi()); + time_t daqEnd = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi()); + time_t ctpStart = (time_t) (((TString)GetRunParameter("TRGTimeStart")).Atoi()); + time_t ctpEnd = (time_t) (((TString)GetRunParameter("TRGTimeEnd")).Atoi()); + + fDCSData = new AliADDataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd,(UInt_t)ctpStart, (UInt_t)ctpEnd); + +} + +//______________________________________________________________________________________________ +UInt_t AliADPreprocessor::Process(TMap* dcsAliasMap) +{ + // Fills data retrieved from DCS and DAQ into a AliADCalibData object and + // stores it into CalibrationDB + + + // *** GET RUN TYPE *** + TString runType = GetRunType(); + + + // *** REFERENCE DATA *** + + TString fileName; + AliADCalibData *calibData = new AliADCalibData(); + + // *************** HV From DCS ****************** + // Fills data into a AliADDataDCS object + if(!dcsAliasMap) return 1; + + // The Processing of the DCS input data is forwarded to AliADDataDCS + if (!fDCSData->ProcessData(*dcsAliasMap)) return 1; + + // Writes AD PMs HV values into AD calibration object and Timing resolution parameters + calibData->FillDCSData(fDCSData); + + // *************** From DAQ ****************** + + TString sourcesId = "AD0da_results"; + + TList* sourceList = GetFileSources(kDAQ, sourcesId.Data()); + if (!sourceList) { + Log(Form("No sources found for id %s", sourcesId.Data())); + return 1; } + Log(Form("The following sources produced files with the id %s",sourcesId.Data())); + sourceList->Print(); + + TIter iter(sourceList); + TObjString *source; + + while((source=dynamic_cast (iter.Next()))){ + fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName()); + if (fileName.Length() > 0) + Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); + FILE *file; + if((file = fopen(fileName.Data(),"r")) == NULL){ + Log(Form("Cannot open file %s",fileName.Data())); + return 1;} + Float_t pedMean[32], pedSigma[32], adcMean[32], adcSigma[32] ; + for(Int_t j=0; j<32; j++) { + Int_t resScan = fscanf(file,"%f %f %f %f", + &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]); + if (resScan != 4) Log(Form("Bad data in file %s !",fileName.Data())); + } + fclose(file); + + calibData->SetPedestal(pedMean); + calibData->SetSigma(pedSigma); + calibData->SetADCmean(adcMean); + calibData->SetADCsigma(adcSigma); + } + + delete source; + + // Check that everything was properly transmitted + +// for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));} +// for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));} +// for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));} +// for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));} +// for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));} +// for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));} + + // Now we store the AD Calibration Object into CalibrationDB + + Bool_t resECal=kTRUE; + + Bool_t result = 0; +// if(sourceList && sourceList->GetEntries()>0) +// { + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Michal Broz"); + metaData.SetComment("This preprocessor fills an AliADCalibData object"); + + resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE); +// } + if(resECal==kFALSE ) result = 1; + + + delete calibData; + delete sourceList; + + + return result; +} + diff --git a/AD/AliADPreprocessor.h b/AD/AliADPreprocessor.h new file mode 100644 index 00000000000..f757726d860 --- /dev/null +++ b/AD/AliADPreprocessor.h @@ -0,0 +1,32 @@ +#ifndef ALI_AD_PREPROCESSOR_H +#define ALI_AD_PREPROCESSOR_H + +#include "AliPreprocessor.h" + +class AliShuttleInterface; +class AliADDataDCS; + +// AD Preprocessor header + +// 1 calibration object from DCS and DAQ is written into OCDB/AD/Calib/Data + +class AliADPreprocessor : public AliPreprocessor +{ + public: + AliADPreprocessor(AliShuttleInterface* shuttle); + virtual ~AliADPreprocessor(); + virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); + + protected: + virtual UInt_t Process(TMap* dcsAliasMap); + + AliADDataDCS *fDCSData; // CDB class that stores the calibration data + + private: + AliADPreprocessor(const AliADPreprocessor&); // Not implemented + AliADPreprocessor& operator=(const AliADPreprocessor&); // Not implemented + + ClassDef(AliADPreprocessor, 1); +}; + +#endif diff --git a/AD/CMakelibADbase.pkg b/AD/CMakelibADbase.pkg index 97f9e6728f2..832ed56cd07 100644 --- a/AD/CMakelibADbase.pkg +++ b/AD/CMakelibADbase.pkg @@ -31,8 +31,8 @@ set ( SRCS AliADdigit.cxx AliADSDigit.cxx AliADCalibData.cxx -# AliADPreprocessor.cxx -# AliADDataDCS.cxx + AliADPreprocessor.cxx + AliADDataDCS.cxx # AliADQAChecker.cxx # AliADMisAligner.cxx # AliADLogicalSignal.cxx diff --git a/AD/macros/AD0da_results.txt b/AD/macros/AD0da_results.txt new file mode 100644 index 00000000000..4d7011a1b80 --- /dev/null +++ b/AD/macros/AD0da_results.txt @@ -0,0 +1,32 @@ +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +21.0 4.3 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +57.0 8.1 50.0 2.0 +16.0 3.0 50.0 2.0 +60.0 6.6 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +16.0 3.0 50.0 2.0 +88.0 8.8 66.6 7.7 diff --git a/AD/macros/ADTestPreprocessor.C b/AD/macros/ADTestPreprocessor.C new file mode 100644 index 00000000000..a638123e769 --- /dev/null +++ b/AD/macros/ADTestPreprocessor.C @@ -0,0 +1,206 @@ +/* $Id: TestPreprocessor.C 30923 2009-02-09 15:47:08Z hristov $ */ + +// This class runs the test 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 + +void ADTestPreprocessor() +{ + // load library + gSystem->Load("libTestShuttle.so"); + + // create AliTestShuttle instance + // The parameters are run, startTime, endTime + AliTestShuttle* shuttle = new AliTestShuttle(12345, 0, 123450); + + // TODO if needed, change location of OCDB and Reference test folders + // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference + AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB"); + AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB"); + + printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); + printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); + + + // TODO(1) + // + // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data, + // some fake data has to be created. + // + // The "fake" input data can be taken using either (a) or (b): + // (a) data from a file: Use ReadDCSAliasMap() + // the format of the file is explained in ReadDCSAliasMap() + // To use it uncomment the following line: + // + //TMap* dcsAliasMap = ReadDCSAliasMap(); + // + // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation + // To use it uncomment the following line: + // + TMap* dcsAliasMap = CreateDCSAliasMap(); + + // now give the alias map to the shuttle + shuttle->SetDCSInput(dcsAliasMap); + + // TODO(2) + // + // The shuttle can also process files that originate from DCS, DAQ and HLT. + // To test it, we provide some local files and locations where these would be found when + // the online machinery would be there. + // In real life this functions would be produces by the sub-detectors + // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. + // + // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: + // AddInputFile(, , , , ) + // In this example we add a file originating from the GDC with the id PEDESTALS + // Three files originating from different LDCs but with the same id are also added + // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow + // the "online" naming convention ALICE-INT-2003-039. +// shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "PEDESTALS", "GDC0", "file1.root"); +// shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC0", "file2a.root"); +// shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC1", "file2b.root"); +// shuttle->AddInputFile(AliShuttleInterface::kDAQ, "TPC", "DRIFTVELOCITY", "LDC2", "file2c.root"); +// shuttle->AddInputFile(AliShuttleInterface::kHLT, "TPC", "HLTData", "source1", "hlt_file1.root"); + shuttle->AddInputFile(AliShuttleInterface::kDAQ, "AD0", "AD0da_results", "source1", "./AD0da_results.txt"); +// + // TODO(3) + // + // The shuttle can read run type stored in the DAQ logbook. + // To test it, we must provide the run type manually. They will be retrieved in the preprocessor + // using GetRunType function. + shuttle->SetInputRunType("PHYSICS"); + + // TODO(4) + // + // The shuttle can read run parameters stored in the DAQ run logbook. + // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor + // using GetRunParameter function. + shuttle->AddInputRunParameter("totalEvents", "30000"); + shuttle->AddInputRunParameter("NumberOfGDCs", "15"); + + // TODO(5) + // + // This is for preprocessor that require data from HLT. + // Since HLT may be switched off, the preprocessor should first query the Run logbook where + // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns + // a bool directly. 1 = HLT ON, 0 = HLT OFF + // + + Bool_t hltStatus=kFALSE; + shuttle->SetInputHLTStatus(hltStatus); + + + // TODO(6) + // Create the preprocessor that should be tested, it registers itself automatically to the shuttle + AliPreprocessor* adPreprocessor = new AliADPreprocessor(shuttle); + + // Test the preprocessor + shuttle->Process(); + + // TODO(7) + // In the preprocessor AliShuttleInterface::Store should be called to put the final + // data to the CDB. To check if all went fine have a look at the files produced in + // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB//SHUTTLE/Data + // + // Check the file which should have been created + AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("AD/Calib/Data", 0); + if (!chkEntry) + { + printf("The file is not there. Something went wrong.\n"); + return; + } + + + AliTestDataDCS* output = dynamic_cast (chkEntry->GetObject()); + // If everything went fine, draw the result + if (output) + output->Draw(); + // +} + +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; + + FILE *fp = fopen("./DCSValues.txt","r"); + + char name[50]; + Float_t val; + while(!(EOF == fscanf(fp,"%s %f",name,&val))){ + TObjArray* valueSet = new TObjArray; + valueSet->SetOwner(1); + + TString aliasName=name; + + //printf("alias: %s\t\t",aliasName.Data()); + + int timeStamp=10; + + + if(aliasName.Contains("HV")) { + for(int i=0;i<10;i++){ + dcsVal = new AliDCSValue((Float_t) (val+random.Gaus(0,10)), timeStamp+10*i); + valueSet->Add(dcsVal); + } + } else { + for(int i=0;i<2;i++){ + AliDCSValue* dcsVal = new AliDCSValue((Int_t) (val), timeStamp+10*i); + valueSet->Add(dcsVal); + } + } + + aliasMap->Add(new TObjString(aliasName), valueSet); + + } + fclose(fp); + return aliasMap; +} + +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()->GetStorage(AliShuttleInterface::GetMainCDB()) + ->Get("DET/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("Responsible person"); + metaData.SetComment("Test object for TestPreprocessor.C"); + + AliCDBId id("DET/DCS/Data", 0, 0); + + // look into AliTestShuttle's CDB main folder + + AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) + ->Put(dcsAliasMap, id, &metaData); +} diff --git a/AD/macros/DCSValues.txt b/AD/macros/DCSValues.txt new file mode 100644 index 00000000000..1530eebcbd1 --- /dev/null +++ b/AD/macros/DCSValues.txt @@ -0,0 +1,61 @@ +AD0/HV/V0A/SECTOR0/RING0 1784 +AD0/HV/V0A/SECTOR0/RING1 1813 +AD0/HV/V0A/SECTOR0/RING2 1738 +AD0/HV/V0A/SECTOR0/RING3 1855 +AD0/HV/V0A/SECTOR1/RING0 1872 +AD0/HV/V0A/SECTOR1/RING1 1734 +AD0/HV/V0A/SECTOR1/RING2 1490 +AD0/HV/V0A/SECTOR1/RING3 1897 +AD0/HV/V0C/SECTOR0/RING0 1882 +AD0/HV/V0C/SECTOR0/RING1 1901 +AD0/HV/V0C/SECTOR0/RING2 1878 +AD0/HV/V0C/SECTOR0/RING3 1787 +AD0/HV/V0C/SECTOR1/RING0 1893 +AD0/HV/V0C/SECTOR1/RING1 1682 +AD0/HV/V0C/SECTOR1/RING2 1958 +AD0/HV/V0C/SECTOR1/RING3 1718 +AD0/FEE/CIU0/TimeResolution 2 +AD0/FEE/CIU0/WidthResolution 8 +AD0/FEE/CIU0/MatchWindow 4 +AD0/FEE/CIU0/SearchWindow 16 +AD0/FEE/CIU0/TriggerCountOffset 3247 +AD0/FEE/CIU0/RollOver 3563 +AD0/FEE/CIU0/DelayHit1 100 +AD0/FEE/CIU0/DelayHit2 100 +AD0/FEE/CIU0/DelayHit3 100 +AD0/FEE/CIU0/DelayHit4 100 +AD0/FEE/CIU0/DelayHit5 100 +AD0/FEE/CIU0/DelayHit6 100 +AD0/FEE/CIU0/DelayHit7 100 +AD0/FEE/CIU0/DelayHit8 100 +AD0/FEE/CIU0/DiscriThr1 2000 +AD0/FEE/CIU0/DiscriThr2 2000 +AD0/FEE/CIU0/DiscriThr3 2000 +AD0/FEE/CIU0/DiscriThr4 2000 +AD0/FEE/CIU0/DiscriThr5 2000 +AD0/FEE/CIU0/DiscriThr6 2000 +AD0/FEE/CIU0/DiscriThr7 2000 +AD0/FEE/CIU0/DiscriThr8 2000 +AD0/FEE/CIU1/TimeResolution 0 +AD0/FEE/CIU1/WidthResolution 5 +AD0/FEE/CIU1/MatchWindow 4 +AD0/FEE/CIU1/SearchWindow 16 +AD0/FEE/CIU1/TriggerCountOffset 3247 +AD0/FEE/CIU1/RollOver 3563 +AD0/FEE/CIU1/DelayHit1 100 +AD0/FEE/CIU1/DelayHit2 100 +AD0/FEE/CIU1/DelayHit3 100 +AD0/FEE/CIU1/DelayHit4 100 +AD0/FEE/CIU1/DelayHit5 100 +AD0/FEE/CIU1/DelayHit6 100 +AD0/FEE/CIU1/DelayHit7 100 +AD0/FEE/CIU1/DelayHit8 100 +AD0/FEE/CIU1/DiscriThr1 2000 +AD0/FEE/CIU1/DiscriThr2 2000 +AD0/FEE/CIU1/DiscriThr3 2000 +AD0/FEE/CIU1/DiscriThr4 2000 +AD0/FEE/CIU1/DiscriThr5 2000 +AD0/FEE/CIU1/DiscriThr6 2000 +AD0/FEE/CIU1/DiscriThr7 2000 +AD0/FEE/CIU1/DiscriThr8 2000 + -- 2.43.0