From 56ade717e04fe45bb1f0e93b78c98cb2111ecb90 Mon Sep 17 00:00:00 2001 From: alla Date: Tue, 24 Oct 2006 06:05:47 +0000 Subject: [PATCH] preprocessor made by Tomasz and fully his responsibility --- START/AliSTARTCalc.cxx | 89 +++++++++++++++ START/AliSTARTCalc.h | 27 +++++ START/AliSTARTDataDCS.cxx | 195 +++++++++++++++++++++++++++++++++ START/AliSTARTDataDCS.h | 69 ++++++++++++ START/AliSTARTDqclass.cxx | 68 ++++++++++++ START/AliSTARTDqclass.h | 42 +++++++ START/AliSTARTPreprocessor.cxx | 88 +++++++++++++++ START/AliSTARTPreprocessor.h | 27 +++++ START/STARTshuttleLinkDef.h | 11 ++ START/TestPreprocessor.C | 79 +++++++++++++ START/libSTARTshuttle.pkg | 9 ++ 11 files changed, 704 insertions(+) create mode 100644 START/AliSTARTCalc.cxx create mode 100644 START/AliSTARTCalc.h create mode 100644 START/AliSTARTDataDCS.cxx create mode 100644 START/AliSTARTDataDCS.h create mode 100644 START/AliSTARTDqclass.cxx create mode 100644 START/AliSTARTDqclass.h create mode 100644 START/AliSTARTPreprocessor.cxx create mode 100644 START/AliSTARTPreprocessor.h create mode 100644 START/STARTshuttleLinkDef.h create mode 100644 START/TestPreprocessor.C create mode 100644 START/libSTARTshuttle.pkg diff --git a/START/AliSTARTCalc.cxx b/START/AliSTARTCalc.cxx new file mode 100644 index 00000000000..61a627f995a --- /dev/null +++ b/START/AliSTARTCalc.cxx @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include + +#include "AliSTARTCalc.h" +#include "TObjArray.h" +#include "TGraph.h" +#include "TFile.h" +#include "AliLog.h" +#include "TObjString.h" + +#include "TAxis.h" +#include "TH2F.h" + + +ClassImp(AliSTARTCalc) + +AliSTARTCalc::AliSTARTCalc() +{ + // + // fGraphs.SetOwner(1); +} + +AliSTARTCalc::AliSTARTCalc(const char* name) +{ + TString namst = "Calib_"; + namst += name; + SetName(namst.Data()); + SetTitle(namst.Data()); +// fGraphs.SetOwner(1); + Reset(); + +} + +//________________________________________________________________ +AliSTARTCalc::AliSTARTCalc(const AliSTARTCalc& calibdata) : TNamed(calibdata) + +{ +// copy constructor + SetName(calibdata.GetName()); + SetTitle(calibdata.GetName()); + + +} + +//________________________________________________________________ +AliSTARTCalc &AliSTARTCalc::operator =(const AliSTARTCalc& calibdata) +{ +// assignment operator + SetName(calibdata.GetName()); + SetTitle(calibdata.GetName()); + + return *this; +} + +//________________________________________________________________ +AliSTARTCalc::~AliSTARTCalc() +{ +// +} + +void AliSTARTCalc::Reset() +{ + memset(fTime,1,24*sizeof(Float_t)); + +} + +void AliSTARTCalc::SetTime(Float_t* daqtime, Float_t* time_shift) +{ + for(Int_t i=0;i<24;i++){ + if (time_shift[i] != 0.) + fTime[i] = daqtime[i]-time_shift[i]; + else + fTime[i] = daqtime[i]; + } +} + + +void AliSTARTCalc::Print(const Option_t*) const +{ + for(Int_t i=0;i<24;i++){ + printf("Total time %d = %.2f\n",i,fTime[i]); + } +} + + + diff --git a/START/AliSTARTCalc.h b/START/AliSTARTCalc.h new file mode 100644 index 00000000000..7bd276ca876 --- /dev/null +++ b/START/AliSTARTCalc.h @@ -0,0 +1,27 @@ +#ifndef AliSTARTCalc_H +#define AliSTARTCalc_H + +#include "TNamed.h" + +class AliSTARTCalc: public TNamed { + + public: + AliSTARTCalc(); + AliSTARTCalc(const char* name); + AliSTARTCalc(const AliSTARTCalc &calibdata); + AliSTARTCalc& operator= (const AliSTARTCalc &calibdata); + virtual ~AliSTARTCalc(); + void Reset(); + void Print(const Option_t* option="") const; + Float_t GetDelay(int channel) {return fTime[channel];} + + void SetTime(Float_t* daqtime, Float_t* dcstime); + + protected: +// TMap fGraphs; + Float_t fTime[24]; + + ClassDef(AliSTARTCalc,4) +}; + +#endif diff --git a/START/AliSTARTDataDCS.cxx b/START/AliSTARTDataDCS.cxx new file mode 100644 index 00000000000..29567c06fc6 --- /dev/null +++ b/START/AliSTARTDataDCS.cxx @@ -0,0 +1,195 @@ +#include "AliSTARTDataDCS.h" + +#include "AliCDBMetaData.h" +#include "AliDCSValue.h" +#include "AliLog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +ClassImp(AliSTARTDataDCS) + +//--------------------------------------------------------------- +AliSTARTDataDCS::AliSTARTDataDCS(): + TObject(), + fRun(0), + fStartTime(0), + fEndTime(0), + fGraphs("TGraph",kNGraphs), + fIsProcessed(kFALSE) +{ + for(int i=0;iGetEntries()<2){ + AliError(Form("Alias %s has just %d entries!", + fAliasNames[j].Data(),aliasArr->GetEntries())); + continue; + } + + TIter iterarray(aliasArr); + + Double_t *time = new Double_t[aliasArr->GetEntries()]; + Double_t *val = new Double_t[aliasArr->GetEntries()]; + + UInt_t ne=0; + while ((aValue = (AliDCSValue*) iterarray.Next())) { + + val[ne] = aValue->GetFloat(); + time[ne] = (Double_t) (aValue->GetTimeStamp()); + // fill histos (alias 0-2) + if(j < 3) fHv[j]->Fill(val[ne]); + ne++; + } + // fill graphs (alias 3-5) + if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val); + delete[] val; + delete[] time; + } + + // calculate mean and rms of the first two histos + for(int i=0;iGetMean(); + fWidth[i] = fHv[i]->GetRMS(); + } + + // pol1 fit of the first graph + if(fGraphs.GetEntries() > 0){ + ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1"); + fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1"); + } + + fIsProcessed=kTRUE; + + +} + +//--------------------------------------------------------------- +void AliSTARTDataDCS::Init(){ + + TH1::AddDirectory(kFALSE); + + fGraphs.SetOwner(1); + + for(int i=0;iGetXaxis()->SetTitle("Hv"); + } +} + +//--------------------------------------------------------------- +void AliSTARTDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){ + + int entries=aliasArr->GetEntries(); + AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data())); + AliInfo(Form(" %d DP values collected",entries)); + +} + +//--------------------------------------------------------------- +void AliSTARTDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y) +{ + + 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 AliSTARTDataDCS::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->Divide(2,2); + ch->cd(1); + fHv[0]->Draw(); + ch->cd(2); + fHv[1]->Draw(); + ch->cd(3); + fHv[2]->Draw(); + + + if(fGraphs.GetEntries() == 0) return; + + TCanvas *cg; + TString canvasGraphName="Graphs"; + cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600); + cg->Divide(2,2); + cg->cd(1); + ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp"); + + cg->cd(2); + ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp"); + cg->cd(3); + ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp"); + + if(fFunc){ + cg->cd(4); + fFunc->Draw("l"); + } + +} + diff --git a/START/AliSTARTDataDCS.h b/START/AliSTARTDataDCS.h new file mode 100644 index 00000000000..156cfaebfd8 --- /dev/null +++ b/START/AliSTARTDataDCS.h @@ -0,0 +1,69 @@ +#ifndef AliSTARTDataDCS_H +#define AliSTARTDataDCS_H + +#include +#include +#include +#include +#include + +class AliSTARTDataDCS : public TObject { +public: + enum {kNAliases=6, kNHistos=3, kNGraphs=3, kNFunctions=2}; + enum {kHvMin=0, kHvMax=20}; + + AliSTARTDataDCS(); + AliSTARTDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime); + ~AliSTARTDataDCS(); + + void SetRun(Int_t run) {fRun = run;} + void SetStartTime(Int_t startTime) {fStartTime = startTime;} + void SetEndTime(Int_t endTime) {fEndTime = endTime;} + Int_t GetRun() {return fRun;} + Int_t GetStartTime() {return fStartTime;} + Int_t GetEndTime() {return fEndTime;} + + void ProcessData(TMap& aliasMap); + + const char* GetAliasName(UInt_t pos) + {return posEval(time) : -1;} + + void Draw(const Option_t* option); + + +private: + void Init(); + void Introduce(UInt_t numAlias, const TObjArray* aliasArr); + void CreateGraph(int i, int dim, const Double_t *x, const Double_t *y); + + Int_t fRun; + UInt_t fStartTime; + UInt_t fEndTime; + + Float_t fMean[kNHistos]; + Float_t fWidth[kNHistos]; + + TString fAliasNames[kNAliases]; + TH1F *fHv[kNHistos]; + TClonesArray fGraphs; + TF1 *fFunc; + + Bool_t fIsProcessed; + + ClassDef(AliSTARTDataDCS, 2); +}; + +#endif diff --git a/START/AliSTARTDqclass.cxx b/START/AliSTARTDqclass.cxx new file mode 100644 index 00000000000..2a00109ac4c --- /dev/null +++ b/START/AliSTARTDqclass.cxx @@ -0,0 +1,68 @@ +/************************************************************************** + * 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$ */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// Output of T0 DAQ // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "AliSTARTDqclass.h" + +ClassImp(AliSTARTDqclass) + +//________________________________________________________________ +AliSTARTDqclass::AliSTARTDqclass() +{ +// fHistMeanPed=0; + Reset(); +} + +//________________________________________________________________ +AliSTARTDqclass::AliSTARTDqclass(const char* name) +{ + // Constructor + TString namst = "Calib_"; + namst += name; + SetName(namst.Data()); + SetTitle(namst.Data()); +// fHistMeanPed=0; + Reset(); +} + + +//________________________________________________________________ +AliSTARTDqclass::~AliSTARTDqclass() +{ +// CleanHistos(); +} + +//________________________________________________________________ +void AliSTARTDqclass::Reset() +{ + // Reset + memset(fTime,0,24*sizeof(Float_t)); + memset(fAmplitude,0,24*sizeof(Float_t)); +} + + +//________________________________________________________________ +void AliSTARTDqclass::Print(Option_t *) const +{ + +} + diff --git a/START/AliSTARTDqclass.h b/START/AliSTARTDqclass.h new file mode 100644 index 00000000000..0746295254f --- /dev/null +++ b/START/AliSTARTDqclass.h @@ -0,0 +1,42 @@ +#ifndef DAQ +#define DAQ + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//////////////////////////////////////////////// +// class for T0 DAQ output // +//////////////////////////////////////////////// + +#include "TNamed.h" + + +class AliSTARTDqclass: public TNamed { + + public: + AliSTARTDqclass( ); + AliSTARTDqclass(const char* name); + virtual ~AliSTARTDqclass(); + void Reset(); + virtual void Print(Option_t *) const; + // + + Float_t GetTime(Int_t channel) const {return fTime[channel];} + Float_t* GetTime() const {return (float*)fTime;} + Float_t GetAmplitude(Int_t channel) const {return fAmplitude[channel];} + Float_t* GetAmplitude() const {return (float*)fAmplitude;} + + void SetTime(Int_t channel, Float_t val) {fTime[channel]=val;} + void SetAmplitude(Int_t channel, Float_t val) {fAmplitude[channel]=val;} + + + protected: + // --- Pedestals + Float_t fTime[24]; // Mean pedestal values + Float_t fAmplitude[24]; // Mean pedestal values + Float_t fTotTime[24]; + + ClassDef(AliSTARTDqclass,1) // DAQ data +}; + +#endif diff --git a/START/AliSTARTPreprocessor.cxx b/START/AliSTARTPreprocessor.cxx new file mode 100644 index 00000000000..7bc2bcf0fa0 --- /dev/null +++ b/START/AliSTARTPreprocessor.cxx @@ -0,0 +1,88 @@ +#include "AliSTARTPreprocessor.h" + +#include "AliCDBMetaData.h" +#include "AliDCSValue.h" +#include "AliLog.h" +#include "AliSTARTCalc.h" + +#include +#include +#include +#include "AliSTARTDqclass.h" + +ClassImp(AliSTARTPreprocessor) + +//____________________________________________________ +AliSTARTPreprocessor::AliSTARTPreprocessor(const char* detector, AliShuttleInterface* shuttle) : + AliPreprocessor(detector, shuttle) +{ + +} + +AliSTARTPreprocessor::~AliSTARTPreprocessor() +{ + +} + +UInt_t AliSTARTPreprocessor::Process(TMap* dcsAliasMap ) +{ + + if(!dcsAliasMap) return 0; + + TObjArray *aliasArr; + // AliDCSValue *aValue; + Float_t hv[24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + for(int j=0; j<24; j++){ + TString aliasName =Form("T0HV%d",j); + // printf("aliasname: %s\n",aliasName.Data()); + aliasArr = dynamic_cast (dcsAliasMap->GetValue(aliasName.Data())); + if(!aliasArr){ + AliError(Form("Alias %s not found!", aliasName.Data())); + continue; + } + AliDCSValue *aValue=dynamic_cast (aliasArr->At(0)); + // printf("I'm here! %f %x\n", aValue->GetFloat(), aValue->GetTimeStamp()); + hv[j]= aValue->GetFloat()*100; + //Float_t timestamp= (Float_t) (aValue->GetTimeStamp()); + // printf("hello! hv = %f timestamp = %f\n" ,hv[j], timestamp); + + } + Float_t numbers[24]; + + AliSTARTCalc *calibdata = new AliSTARTCalc(); + + const char* TimefileName = GetFile(kDAQ, "TIME", "LDC0"); + + + if(TimefileName){ + TFile *file = TFile::Open(TimefileName); + if(!file || !file->IsOpen()) + { + printf("File from DAQ does not exist."); + return 0; + } + AliSTARTDqclass *tempdata = dynamic_cast (file->Get("Time")); + for(Int_t i=0;i<24;i++){ + numbers[i] = tempdata->GetTime(i); + // printf("\nnumbers: %f\n",numbers[i]); + } + file->Close(); + delete tempdata; + } + else {return 0;} + calibdata->SetTime(numbers, hv); + calibdata->Print(); + + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Tomek&Michal"); + metaData.SetComment("This preprocessor returns time to be used for reconstruction."); + + UInt_t result = Store("Calib","Data", calibdata, &metaData); + delete calibdata; + return result; + +} + + diff --git a/START/AliSTARTPreprocessor.h b/START/AliSTARTPreprocessor.h new file mode 100644 index 00000000000..265e8db1096 --- /dev/null +++ b/START/AliSTARTPreprocessor.h @@ -0,0 +1,27 @@ +#ifndef ALI_START_PREPROCESSOR_H +#define ALI_START_PREPRECESSOR_H + +#include "AliPreprocessor.h" + +// +//// Example of a Shuttle Preprocessor +//// +// +class AliSTARTPreprocessor: public AliPreprocessor +{ + public: + AliSTARTPreprocessor(const char* detector, AliShuttleInterface* shuttle); + virtual ~AliSTARTPreprocessor(); + + protected: +// virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); + virtual UInt_t Process(TMap* dcsAliasMap); + + private: + //AliSTARTCalc *fData; + + ClassDef(AliSTARTPreprocessor, 1); + +}; + +#endif diff --git a/START/STARTshuttleLinkDef.h b/START/STARTshuttleLinkDef.h new file mode 100644 index 00000000000..dc4bb2aa4a5 --- /dev/null +++ b/START/STARTshuttleLinkDef.h @@ -0,0 +1,11 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliSTARTCalc+; +#pragma link C++ class AliSTARTPreprocessor+; +#pragma link C++ class AliSTARTDqclass+; + +#endif diff --git a/START/TestPreprocessor.C b/START/TestPreprocessor.C new file mode 100644 index 00000000000..ce4d7dd513c --- /dev/null +++ b/START/TestPreprocessor.C @@ -0,0 +1,79 @@ + + +void TestPreprocessor() +{ + gSystem->Load("libTestShuttle.so"); + + AliCDBManager::Instance()->SetDefaultStorage("local://./TestCDB"); + + AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1); + + TMap* dcsAliasMap = CreateDCSAliasMap(); + + shuttle->SetDCSInput(dcsAliasMap); + + shuttle->AddInputFile(AliTestShuttle::kDAQ, "T00", "TIME", "LDC0", "DAQfile.root"); + + AliPreprocessor* start = new AliSTARTPreprocessor("T00", shuttle); + + shuttle->Process(); + + AliCDBEntry* entry = AliCDBManager::Instance()->Get("T00/Calib/Data", 0); + if (!entry) + { + printf("The file is not there. Something went wrong.\n"); + return; + } + + AliSTARTCalc* output = dynamic_cast (entry->GetObject()); + + // output->Print(); +} + +TMap* CreateDCSAliasMap() +{ + TMap* aliasMap = new TMap; + aliasMap->SetOwner(1); + + for(int nAlias=0;nAlias<24;nAlias++) + { + TObjArray* valueSet = new TObjArray; + valueSet->SetOwner(1); + + TString aliasName="T0HV"; + aliasName += nAlias; + + for (int timeStamp=0;timeStamp<1;timeStamp++) + { + AliDCSValue* dcsVal = new AliDCSValue((Float_t) nAlias, timeStamp); + valueSet->Add(dcsVal); +// printf("hello! dcsVal= %d %d\n" ,dcsVal->GetFloat(), dcsVal->GetTimeStamp()); + } + aliasMap->Add(new TObjString(aliasName), valueSet); + } + + return aliasMap; +} + +TMap* ReadDCSAliasMap() +{ + AliCDBEntry *entry = AliCDBManager::Instance()->Get("DET/DCS/Data", 0); + return dynamic_cast (entry->GetObject()); +} + +void WriteDCSAliasMap() +{ + 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); + + // initialize location of CDB + AliCDBManager::Instance()->SetDefaultStorage("local://./TestCDB"); + + AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); +} diff --git a/START/libSTARTshuttle.pkg b/START/libSTARTshuttle.pkg new file mode 100644 index 00000000000..08ca6c9c2c4 --- /dev/null +++ b/START/libSTARTshuttle.pkg @@ -0,0 +1,9 @@ +#-*- Mode: Makefile -*- +# $Id$ + +SRCS = AliSTARTCalc.cxx AliSTARTPreprocessor.cxx AliSTARTDqclass.cxx +HDRS:= $(SRCS:.cxx=.h) + +DHDR= STARTshuttleLinkDef.h + +EINCLUDE:=RAW -- 2.43.5