1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
19 // Class AliPHOSCalibHistoProducer accumulating histograms
20 // with amplitudes per PHOS channel
21 // It is intended to run at DAQ computers (LDC, GDC, HLT or MOOD)
22 // and it fills the histograms with amplitudes per channel.
23 // Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C
25 // Author: Boris Polichtchouk, 4 October 2006
26 ///////////////////////////////////////////////////////////////////////////////
29 #include "AliPHOSCalibHistoProducer.h"
33 #include "AliPHOSRawDecoder.h"
35 ClassImp(AliPHOSCalibHistoProducer)
37 //-----------------------------------------------------------------------------
38 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() :
39 fRawDecoder(0),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE),
40 fEvents(0),fNbins(100),fXlow(0.),fXup(1000.)
42 // Constructor: initializes data members
43 // Checks existence of histograms which might have been left
44 // from the previous runs to continues their filling
46 fHistoFile = new TFile("calibHisto.root","update");
48 for(Int_t module=0; module<5; module++) {
49 for(Int_t column=0; column<56; column++) {
50 for(Int_t row=0; row<64; row++) {
52 sprintf(hname,"mod%dcol%drow%d",module,column,row);
53 TH1F* hist = (TH1F*)fHistoFile->Get(hname);
55 fAmpHisto[module][column][row]=hist;
57 fAmpHisto[module][column][row] = 0;
63 //-----------------------------------------------------------------------------
64 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(Int_t nbinsx, Double_t xlow, Double_t xup) :
65 fRawDecoder(0),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE),
66 fEvents(0),fNbins(nbinsx),fXlow(xlow),fXup(xup)
68 // Constructor: initializes data members.
69 // Checks existence of histograms which might have been left
70 // from the previous runs to continues their filling.
71 // In addition sets number of bins, low and upper limits common for all histograms.
73 fHistoFile = new TFile("calibHisto.root","update");
75 for(Int_t module=0; module<5; module++) {
76 for(Int_t column=0; column<56; column++) {
77 for(Int_t row=0; row<64; row++) {
79 sprintf(hname,"mod%dcol%drow%d",module,column,row);
80 TH1F* hist = (TH1F*)fHistoFile->Get(hname);
82 fAmpHisto[module][column][row]=hist;
84 fAmpHisto[module][column][row] = 0;
90 //-----------------------------------------------------------------------------
91 AliPHOSCalibHistoProducer::~AliPHOSCalibHistoProducer()
96 if(fHistoFile) delete fHistoFile;
100 //-----------------------------------------------------------------------------
101 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(const AliPHOSCalibHistoProducer &histoproducer) :
102 TObject(histoproducer),fRawDecoder(histoproducer.fRawDecoder),fHistoFile(histoproducer.fHistoFile),
103 fUpdatingRate(histoproducer.fUpdatingRate),fIsOldRCUFormat(histoproducer.fIsOldRCUFormat),
104 fEvents(histoproducer.fEvents),fNbins(histoproducer.fNbins),fXlow(histoproducer.fXlow),fXup(histoproducer.fXup)
108 for(Int_t module=0; module<5; module++) {
109 for(Int_t column=0; column<56; column++) {
110 for(Int_t row=0; row<64; row++) {
112 sprintf(hname,"mod%dcol%drow%d",module,column,row);
113 TH1F* hist = (TH1F*)histoproducer.fHistoFile->Get(hname);
115 fAmpHisto[module][column][row]= new TH1F(*hist);
117 fAmpHisto[module][column][row]=0;
123 //-----------------------------------------------------------------------------
124 AliPHOSCalibHistoProducer& AliPHOSCalibHistoProducer::operator=
125 (const AliPHOSCalibHistoProducer &histoproducer)
127 //Assignment operator.
129 if(this != &histoproducer) {
131 fRawDecoder = histoproducer.fRawDecoder;
132 fHistoFile = histoproducer.fHistoFile;
133 fUpdatingRate = histoproducer.fUpdatingRate;
134 fIsOldRCUFormat = histoproducer.fIsOldRCUFormat;
135 fEvents = histoproducer.fEvents;
136 fEvents = histoproducer.fEvents;
137 fNbins = histoproducer.fNbins;
138 fXlow = histoproducer.fXlow;
139 fXup = histoproducer.fXup;
141 for(Int_t module=0; module<5; module++) {
142 for(Int_t column=0; column<56; column++) {
143 for(Int_t row=0; row<64; row++) {
144 if(fAmpHisto[module][column][row]){
145 delete fAmpHisto[module][column][row];
146 fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row];
149 fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row];
159 //-----------------------------------------------------------------------------
160 void AliPHOSCalibHistoProducer::Run()
162 // Reads raw data of current event and fills amplitude histograms
163 // The histograms are written to file every fUpdatingRate events
165 if(!fRawDecoder) AliFatal("Raw decoder not set!");
171 fRawDecoder->SetOldRCUFormat(kTRUE);
173 while(fRawDecoder->NextDigit()) {
175 if(fRawDecoder->IsLowGain()) continue;
177 energy = fRawDecoder->GetEnergy();
178 if(energy<5) continue; // noise
180 mod = fRawDecoder->GetModule()-1;
181 col = fRawDecoder->GetColumn()-1;
182 row = fRawDecoder->GetRow()-1;
184 if(fAmpHisto[mod][col][row]) {
185 fAmpHisto[mod][col][row]->Fill(energy);
189 sprintf(hname,"mod%dcol%drow%d",mod,col,row);
190 fAmpHisto[mod][col][row] = new TH1F(hname,hname,fNbins,fXlow,fXup);
191 fAmpHisto[mod][col][row]->Fill(energy);
194 // update histograms in local file every 100th event
195 if(fEvents%fUpdatingRate == 0) {
196 AliInfo(Form("Updating histo file, event %d, run %d\n",
197 fEvents,fRawDecoder->GetRawReader()->GetRunNumber()));
201 // UpdateHistoFile();
202 // AliInfo(Form("%d events of run %d processed.",iEvent,runNum));
209 //-----------------------------------------------------------------------------
210 void AliPHOSCalibHistoProducer::UpdateHistoFile()
212 // Write histograms to file
214 if(!fHistoFile) return;
215 if(!fHistoFile->IsOpen()) return;
221 for(Int_t module=0; module<5; module++) {
222 sprintf(hname,"hMeanE%d",module);
223 sprintf(htitle,"Mean energies in module %d",module);
224 TH2F hMeanE(hname,htitle,56,0.,56.,64,0.,64);
226 for(Int_t column=0; column<56; column++) {
227 for(Int_t row=0; row<64; row++) {
228 hist = fAmpHisto[module][column][row];
229 if(hist) hist->Write(hist->GetName(),TObject::kWriteDelete);
230 if(hist) hMeanE.SetBinContent(column,row,hist->GetMean());
233 hMeanE.Write(hMeanE.GetName(),TObject::kWriteDelete);