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 sprintf(name,"CPV_Module%d_Calib",fMod);
44 sprintf(title,"Calibration Detector Algorithm for CPV module %d",fMod);
48 sprintf(rootname,"%s.root",GetName());
50 fHistoFile = new TFile(rootname,"update");
55 for(Int_t iX=0; iX<128; iX++) {
56 for(Int_t iZ=0; iZ<56; iZ++) {
58 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
59 hist1 = (TH1F*)fHistoFile->Get(hname);
60 if(hist1) fCharge[iX][iZ] = hist1;
68 //-------------------------------------------------------------------
69 AliPHOSCpvDA1::AliPHOSCpvDA1(const AliPHOSCpvDA1& da) : TNamed(da),
70 fHistoFile(0),fMod(da.fMod)
74 fHistoFile = new TFile(da.GetName(),"update");
79 for(Int_t iX=0; iX<128; iX++) {
80 for(Int_t iZ=0; iZ<56; iZ++) {
82 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
83 hist1 = (TH1F*)da.fHistoFile->Get(hname);
84 if(hist1) fCharge[iX][iZ] = new TH1F(*hist1);
92 //-------------------------------------------------------------------
93 AliPHOSCpvDA1& AliPHOSCpvDA1::operator= (const AliPHOSCpvDA1& da)
95 //Assignment operator.
99 TString oldname(fHistoFile->GetName());
100 TString newname(da.fHistoFile->GetName());
102 if(oldname != newname) {
104 fHistoFile = new TFile(da.fHistoFile->GetName(),"update");
109 SetName(da.GetName());
110 SetTitle(da.GetTitle());
112 for(Int_t iX=0; iX<128; iX++) {
113 for(Int_t iZ=0; iZ<56; iZ++) {
115 if(fCharge[iX][iZ]) delete fCharge[iX][iZ];
116 fCharge[iX][iZ] = da.fCharge[iX][iZ];
126 //-------------------------------------------------------------------
127 AliPHOSCpvDA1::~AliPHOSCpvDA1()
132 if(fHistoFile) delete fHistoFile;
136 //-------------------------------------------------------------------
137 void AliPHOSCpvDA1::FillHistograms(Float_t e[128][56])
139 // Fill charge deposit histograms of one event.
140 // Charge data is encoded as e[X][Z],
141 // where X(0..127) and Z(0..55) - pad position in the CPV module,
142 // Charge in ADC counts.
143 // If no charge read for particular channel,
144 // the correspondent array entry should be filled by zero.
145 // WARNING: this function should be called once per event!
150 for(Int_t iX=0; iX<128; iX++) {
151 for (Int_t iZ=0; iZ<56; iZ++) {
153 if(!e[iX][iZ]) continue;
156 fCharge[iX][iZ]->Fill(e[iX][iZ]);
158 sprintf(hname,"%d_%d_%d",fMod,iX,iZ);
159 sprintf(htitl,"Charge deposited on the pad %d_%d_%d",fMod,iX,iZ);
160 fCharge[iX][iZ] = new TH1F(hname,htitl,1024,0.,1024.);
161 fCharge[iX][iZ]->Fill(e[iX][iZ]);
169 //-------------------------------------------------------------------
170 void AliPHOSCpvDA1::UpdateHistoFile()
172 // Write histograms to file
174 if(!fHistoFile) return;
175 if(!fHistoFile->IsOpen()) return;
179 for(Int_t iX=0; iX<128; iX++) {
180 for(Int_t iZ=0; iZ<56; iZ++) {
182 hist1 = fCharge[iX][iZ];
183 if(hist1) hist1->Write(hist1->GetName(),TObject::kWriteDelete);