From 55ec1be0028f56bb82dce98311f63763edc5561e Mon Sep 17 00:00:00 2001 From: policheh Date: Fri, 25 Jan 2008 15:45:41 +0000 Subject: [PATCH] CPV calibration detector algorithm class common for DAQ and HLT. --- PHOS/AliPHOSCpvDA1.cxx | 188 +++++++++++++++++++++++++++++++++++++++++ PHOS/AliPHOSCpvDA1.h | 38 +++++++++ 2 files changed, 226 insertions(+) create mode 100644 PHOS/AliPHOSCpvDA1.cxx create mode 100644 PHOS/AliPHOSCpvDA1.h diff --git a/PHOS/AliPHOSCpvDA1.cxx b/PHOS/AliPHOSCpvDA1.cxx new file mode 100644 index 00000000000..876ee7cf49b --- /dev/null +++ b/PHOS/AliPHOSCpvDA1.cxx @@ -0,0 +1,188 @@ +/************************************************************************** + * Copyright(c) 1998-2008, 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. * + **************************************************************************/ + +/////////////////////////////////////////////////////////////////////////////// +// Class AliPHOSCpvDA1 accumulates histograms with amplitudes per CPV channel. +// It is intended to run at DAQ or HLT computers. +// Author: Boris Polishchuk, 25 January 2008. +/////////////////////////////////////////////////////////////////////////////// + +#include "AliPHOSCpvDA1.h" +#include "TString.h" + +ClassImp(AliPHOSCpvDA1) + +//---------------------------------------------------------------- +AliPHOSCpvDA1::AliPHOSCpvDA1(int module) : TNamed(), + fHistoFile(0),fMod(module) + +{ + // Create DA1 ("Calibration DA") object. + // module is the CPV module number (0..4). + // Checks existence of histograms which might have been left + // from the previous runs to continue their filling. + // Histogram names: module_iX_iZ. + // Root file name: CPV_ModuleX_Calib.root, where X - module number. + + char name[128]; + sprintf(name,"CPV_Module%d_Calib",fMod); + SetName(name); + + char title[128]; + sprintf(title,"Calibration Detector Algorithm for CPV module %d",fMod); + SetTitle(title); + + char rootname[128]; + sprintf(rootname,"%s.root",GetName()); + + fHistoFile = new TFile(rootname,"update"); + + char hname[128]; + TH1F* hist1=0; + + for(Int_t iX=0; iX<128; iX++) { + for(Int_t iZ=0; iZ<56; iZ++) { + + sprintf(hname,"%d_%d_%d",fMod,iX,iZ); + hist1 = (TH1F*)fHistoFile->Get(hname); + if(hist1) fCharge[iX][iZ] = hist1; + else + fCharge[iX][iZ] = 0; + } + } + +} + +//------------------------------------------------------------------- +AliPHOSCpvDA1::AliPHOSCpvDA1(const AliPHOSCpvDA1& da) : TNamed(da), + fHistoFile(0),fMod(da.fMod) +{ + // Copy constructor. + + fHistoFile = new TFile(da.GetName(),"update"); + + char hname[128]; + TH1F* hist1=0; + + for(Int_t iX=0; iX<128; iX++) { + for(Int_t iZ=0; iZ<56; iZ++) { + + sprintf(hname,"%d_%d_%d",fMod,iX,iZ); + hist1 = (TH1F*)da.fHistoFile->Get(hname); + if(hist1) fCharge[iX][iZ] = new TH1F(*hist1); + else + fCharge[iX][iZ] = 0; + } + } + +} + +//------------------------------------------------------------------- +AliPHOSCpvDA1& AliPHOSCpvDA1::operator= (const AliPHOSCpvDA1& da) +{ + //Assignment operator. + + if(this != &da) { + + TString oldname(fHistoFile->GetName()); + TString newname(da.fHistoFile->GetName()); + + if(oldname != newname) { + delete fHistoFile; + fHistoFile = new TFile(da.fHistoFile->GetName(),"update"); + } + + fMod = da.fMod; + + SetName(da.GetName()); + SetTitle(da.GetTitle()); + + for(Int_t iX=0; iX<128; iX++) { + for(Int_t iZ=0; iZ<56; iZ++) { + + if(fCharge[iX][iZ]) delete fCharge[iX][iZ]; + fCharge[iX][iZ] = da.fCharge[iX][iZ]; + } + } + + } + + return *this; +} + + +//------------------------------------------------------------------- +AliPHOSCpvDA1::~AliPHOSCpvDA1() +{ + // Destructor + + UpdateHistoFile(); + if(fHistoFile) delete fHistoFile; + +} + +//------------------------------------------------------------------- +void AliPHOSCpvDA1::FillHistograms(Float_t e[128][56]) +{ + // Fill charge deposit histograms of one event. + // Charge data is encoded as e[X][Z], + // where X(0..127) and Z(0..55) - pad position in the CPV module, + // Charge in ADC counts. + // If no charge read for particular channel, + // the correspondent array entry should be filled by zero. + // WARNING: this function should be called once per event! + + char hname[128]; + char htitl[128]; + + for(Int_t iX=0; iX<128; iX++) { + for (Int_t iZ=0; iZ<56; iZ++) { + + if(!e[iX][iZ]) continue; + + if(fCharge[iX][iZ]) + fCharge[iX][iZ]->Fill(e[iX][iZ]); + else { + sprintf(hname,"%d_%d_%d",fMod,iX,iZ); + sprintf(htitl,"Charge deposited on the pad %d_%d_%d",fMod,iX,iZ); + fCharge[iX][iZ] = new TH1F(hname,htitl,1024,0.,1024.); + fCharge[iX][iZ]->Fill(e[iX][iZ]); + } + + } + } + +} + +//------------------------------------------------------------------- +void AliPHOSCpvDA1::UpdateHistoFile() +{ + // Write histograms to file + + if(!fHistoFile) return; + if(!fHistoFile->IsOpen()) return; + + TH1F* hist1=0; + + for(Int_t iX=0; iX<128; iX++) { + for(Int_t iZ=0; iZ<56; iZ++) { + + hist1 = fCharge[iX][iZ]; + if(hist1) hist1->Write(hist1->GetName(),TObject::kWriteDelete); + } + } + +} + diff --git a/PHOS/AliPHOSCpvDA1.h b/PHOS/AliPHOSCpvDA1.h new file mode 100644 index 00000000000..04a54830c99 --- /dev/null +++ b/PHOS/AliPHOSCpvDA1.h @@ -0,0 +1,38 @@ +#ifndef AliPHOSCPVDA1_H +#define AliPHOSCPVDA1_H +/* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////////////////// +// Class AliPHOSCpvDA1 accumulates histograms with amplitudes per CPV channel. +// It is intended to run at DAQ or HLT computers. +/////////////////////////////////////////////////////////////////////////////// + +#include "TNamed.h" +#include "TH1.h" +#include "TFile.h" + +class AliPHOSCpvDA1 : public TNamed { + + public: + + AliPHOSCpvDA1(Int_t module); + AliPHOSCpvDA1(const AliPHOSCpvDA1& ); + AliPHOSCpvDA1& operator= (const AliPHOSCpvDA1& ); + ~AliPHOSCpvDA1(); + + void FillHistograms(Float_t e[128][56]); + Int_t GetModule() { return fMod; } + void UpdateHistoFile(); + + private: + + TFile* fHistoFile; // root file to store histograms in + TH1F* fCharge[128][56]; // charge deposited on CPV pads + Int_t fMod; // PHOS module number (0..4) + + ClassDef(AliPHOSCpvDA1,1) + +}; + +#endif -- 2.43.0