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),
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()
69 if(fHistoFile) delete fHistoFile;
73 //-----------------------------------------------------------------------------
74 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(const AliPHOSCalibHistoProducer &histoproducer) :
75 TObject(histoproducer),fRawDecoder(histoproducer.fRawDecoder),fHistoFile(histoproducer.fHistoFile),
76 fUpdatingRate(histoproducer.fUpdatingRate),fIsOldRCUFormat(histoproducer.fIsOldRCUFormat),
77 fEvents(histoproducer.fEvents)
81 for(Int_t module=0; module<5; module++) {
82 for(Int_t column=0; column<56; column++) {
83 for(Int_t row=0; row<64; row++) {
85 sprintf(hname,"mod%dcol%drow%d",module,column,row);
86 TH1F* hist = (TH1F*)histoproducer.fHistoFile->Get(hname);
88 fAmpHisto[module][column][row]= new TH1F(*hist);
90 fAmpHisto[module][column][row]=0;
96 //-----------------------------------------------------------------------------
97 AliPHOSCalibHistoProducer& AliPHOSCalibHistoProducer::operator=
98 (const AliPHOSCalibHistoProducer &histoproducer)
100 //Assignment operator.
102 if(this != &histoproducer) {
104 fRawDecoder = histoproducer.fRawDecoder;
105 fHistoFile = histoproducer.fHistoFile;
106 fUpdatingRate = histoproducer.fUpdatingRate;
107 fIsOldRCUFormat = histoproducer.fIsOldRCUFormat;
108 fEvents = histoproducer.fEvents;
110 for(Int_t module=0; module<5; module++) {
111 for(Int_t column=0; column<56; column++) {
112 for(Int_t row=0; row<64; row++) {
113 if(fAmpHisto[module][column][row]){
114 delete fAmpHisto[module][column][row];
115 fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row];
118 fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row];
128 //-----------------------------------------------------------------------------
129 void AliPHOSCalibHistoProducer::Run()
131 // Reads raw data of current event and fills amplitude histograms
132 // The histograms are written to file every fUpdatingRate events
134 if(!fRawDecoder) AliFatal("Raw decoder not set!");
140 fRawDecoder->SetOldRCUFormat(kTRUE);
142 while(fRawDecoder->NextDigit()) {
144 if(fRawDecoder->IsLowGain()) continue;
146 energy = fRawDecoder->GetEnergy();
147 if(energy<10) continue; // noise
149 mod = fRawDecoder->GetModule()-1;
150 col = fRawDecoder->GetColumn()-1;
151 row = fRawDecoder->GetRow()-1;
153 if(fAmpHisto[mod][col][row]) {
154 fAmpHisto[mod][col][row]->Fill(energy);
158 sprintf(hname,"mod%dcol%drow%d",mod,col,row);
159 fAmpHisto[mod][col][row] = new TH1F(hname,hname,100,0.,1000.);
160 fAmpHisto[mod][col][row]->Fill(energy);
163 // update histograms in local file every 100th event
164 if(fEvents%fUpdatingRate == 0) {
165 AliInfo(Form("Updating histo file, event %d, run %d\n",
166 fEvents,fRawDecoder->GetRawReader()->GetRunNumber()));
170 // UpdateHistoFile();
171 // AliInfo(Form("%d events of run %d processed.",iEvent,runNum));
178 //-----------------------------------------------------------------------------
179 void AliPHOSCalibHistoProducer::UpdateHistoFile()
181 // Write histograms to file
183 if(!fHistoFile) return;
184 if(!fHistoFile->IsOpen()) return;
190 for(Int_t module=0; module<5; module++) {
191 sprintf(hname,"hMeanE%d",module);
192 sprintf(htitle,"Mean energies in module %d",module);
193 TH2F hMeanE(hname,htitle,56,0.,56.,64,0.,64);
195 for(Int_t column=0; column<56; column++) {
196 for(Int_t row=0; row<64; row++) {
197 hist = fAmpHisto[module][column][row];
198 if(hist) hist->Write(hist->GetName(),TObject::kWriteDelete);
199 if(hist) hMeanE.SetBinContent(column,row,hist->GetMean());
202 hMeanE.Write(hMeanE.GetName(),TObject::kWriteDelete);