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"
32 #include "AliRawReader.h"
33 #include "AliPHOSRawStream.h"
35 ClassImp(AliPHOSCalibHistoProducer)
37 //-----------------------------------------------------------------------------
38 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(AliRawReader* rawReader) :
39 fRawReader(rawReader),fHistoFile(0),fUpdatingRate(100)
41 // Constructor: initializes input data stream supplied by rawReader
42 // Checks existence of histograms which might have been left
43 // from the previous runs to continues their filling
45 fHistoFile = new TFile("calibHisto.root","update");
47 for(Int_t module=0; module<5; module++) {
48 for(Int_t column=0; column<56; column++) {
49 for(Int_t row=0; row<64; row++) {
51 sprintf(hname,"mod%dcol%drow%d",module,column,row);
52 TH1F* hist = (TH1F*)fHistoFile->Get(hname);
54 fAmpHisto[module][column][row]=hist;
56 fAmpHisto[module][column][row]=0;
62 //-----------------------------------------------------------------------------
63 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() :
64 fRawReader(0),fHistoFile(0),fUpdatingRate(0)
66 // Default constructor
69 //-----------------------------------------------------------------------------
70 AliPHOSCalibHistoProducer::~AliPHOSCalibHistoProducer()
73 if(fHistoFile) delete fHistoFile;
76 //-----------------------------------------------------------------------------
77 void AliPHOSCalibHistoProducer::Run()
79 // Reads raw data stream and fills amplitude histograms
80 // The histograms are written to file every fUpdatingRate events
88 AliPHOSRawStream in(fRawReader);
89 in.SetOldRCUFormat(kTRUE);
91 // Read raw data event by event
93 while (fRawReader->NextEvent()) {
94 runNum = fRawReader->GetRunNumber();
98 if(!gHighGain) gHighGain = new TH1F("gHighGain","High gain",
99 in.GetTimeLength(),0,in.GetTimeLength());
100 if(!gLowGain) gLowGain = new TH1F("gLowGain","Low gain",
101 in.GetTimeLength(),0,in.GetTimeLength());
103 Bool_t lowGainFlag = in.IsLowGain();
106 gLowGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
108 gHighGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
113 if(iBin==in.GetTimeLength()) {
119 energy = gHighGain->GetMaximum(); // no pedestal subtraction!
122 energy = gLowGain->GetMaximum(); // no pedestal subtraction!
125 Int_t mod = in.GetModule();
126 Int_t col = in.GetColumn();
127 Int_t row = in.GetRow();
129 if(fAmpHisto[mod][col][row]) {
131 fAmpHisto[mod][col][row]->Fill(energy);
136 sprintf(hname,"mod%dcol%drow%d",mod,col,row);
137 fAmpHisto[mod][col][row] = new TH1F(hname,hname,100,0.,1000.);
144 // update histograms in local file every 100th event
145 if(iEvent%fUpdatingRate == 0) {
146 AliInfo(Form("Updating histo file, event %d, run %d\n",iEvent,runNum));
153 AliInfo(Form("%d events of run %d processed.",iEvent,runNum));
156 //-----------------------------------------------------------------------------
157 void AliPHOSCalibHistoProducer::UpdateHistoFile()
159 // Write histograms to file
161 if(!fHistoFile) return;
162 if(!fHistoFile->IsOpen()) return;
166 for(Int_t module=0; module<5; module++) {
167 for(Int_t column=0; column<56; column++) {
168 for(Int_t row=0; row<64; row++) {
169 hist = fAmpHisto[module][column][row];
170 if(hist) hist->Write(hist->GetName(),TObject::kWriteDelete);