1 /**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
17 // Class AliPHOSCpvDA1 accumulates histograms with amplitudes per CPV channel.
18 // It is intended to run at DAQ or HLT computers.
19 // Author: Boris Polishchuk, 25 January 2008.
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "AliPHOSCpvDA1.h"
25 ClassImp(AliPHOSCpvDA1)
27 //----------------------------------------------------------------
28 AliPHOSCpvDA1::AliPHOSCpvDA1(int module) : TNamed(),
29 fHistoFile(0),fMod(module)
32 // Create DA1 ("Calibration DA") object.
33 // module is the CPV module number (0..4).
34 // Checks existence of histograms which might have been left
35 // from the previous runs to continue their filling.
36 // Histogram names: module_iX_iZ.
37 // Root file name: CPV_ModuleX_Calib.root, where X - module number.
40 TString sname="CPV_Module%d_Calib";
41 snprintf(name,sname.Length(),sname.Data(),fMod);
45 TString stitle="Calibration Detector Algorithm for CPV module %d";
46 snprintf(title,stitle.Length(),stitle.Data(),fMod);
50 TString srootname="%s.root";
51 snprintf(rootname,srootname.Length(),srootname.Data(),GetName());
53 fHistoFile = new TFile(rootname,"update");
57 TString shname="%d_%d_%d";
59 for(Int_t iX=0; iX<128; iX++) {
60 for(Int_t iZ=0; iZ<56; iZ++) {
61 snprintf(hname,shname.Length(),shname.Data(),fMod,iX,iZ);
62 hist1 = (TH1F*)fHistoFile->Get(hname);
63 if(hist1) fCharge[iX][iZ] = hist1;
71 //-------------------------------------------------------------------
72 AliPHOSCpvDA1::AliPHOSCpvDA1(const AliPHOSCpvDA1& da) : TNamed(da),
73 fHistoFile(0),fMod(da.fMod)
77 fHistoFile = new TFile(da.GetName(),"update");
82 for(Int_t iX=0; iX<128; iX++) {
83 for(Int_t iZ=0; iZ<56; iZ++) {
85 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
86 hist1 = (TH1F*)da.fHistoFile->Get(hname);
87 if(hist1) fCharge[iX][iZ] = new TH1F(*hist1);
95 //-------------------------------------------------------------------
96 AliPHOSCpvDA1& AliPHOSCpvDA1::operator= (const AliPHOSCpvDA1& da)
98 //Assignment operator.
102 TString oldname(fHistoFile->GetName());
103 TString newname(da.fHistoFile->GetName());
105 if(oldname != newname) {
107 fHistoFile = new TFile(da.fHistoFile->GetName(),"update");
112 SetName(da.GetName());
113 SetTitle(da.GetTitle());
115 for(Int_t iX=0; iX<128; iX++) {
116 for(Int_t iZ=0; iZ<56; iZ++) {
118 if(fCharge[iX][iZ]) delete fCharge[iX][iZ];
119 fCharge[iX][iZ] = da.fCharge[iX][iZ];
129 //-------------------------------------------------------------------
130 AliPHOSCpvDA1::~AliPHOSCpvDA1()
135 if(fHistoFile) delete fHistoFile;
139 //-------------------------------------------------------------------
140 void AliPHOSCpvDA1::FillHistograms(Float_t e[128][56])
142 // Fill charge deposit histograms of one event.
143 // Charge data is encoded as e[X][Z],
144 // where X(0..127) and Z(0..55) - pad position in the CPV module,
145 // Charge in ADC counts.
146 // If no charge read for particular channel,
147 // the correspondent array entry should be filled by zero.
148 // WARNING: this function should be called once per event!
153 for(Int_t iX=0; iX<128; iX++) {
154 for (Int_t iZ=0; iZ<56; iZ++) {
156 if(!e[iX][iZ]) continue;
159 fCharge[iX][iZ]->Fill(e[iX][iZ]);
161 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
162 sprintf(htitl,"Charge deposited on the pad %d_%d_%d",fMod,iX,iZ);
163 fCharge[iX][iZ] = new TH1F(hname,htitl,1024,0.,1024.);
164 fCharge[iX][iZ]->Fill(e[iX][iZ]);
172 //-------------------------------------------------------------------
173 void AliPHOSCpvDA1::UpdateHistoFile()
175 // Write histograms to file
177 if(!fHistoFile) return;
178 if(!fHistoFile->IsOpen()) return;
182 for(Int_t iX=0; iX<128; iX++) {
183 for(Int_t iZ=0; iZ<56; iZ++) {
185 hist1 = fCharge[iX][iZ];
186 if(hist1) hist1->Write(hist1->GetName(),TObject::kWriteDelete);