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 "AliPHOSDigit.h"
34 #include "AliPHOSRawDecoder.h"
35 #include "AliPHOSRawDigiProducer.h"
36 #include "AliPHOSGeometry.h"
37 #include "TClonesArray.h"
39 ClassImp(AliPHOSCalibHistoProducer)
41 //-----------------------------------------------------------------------------
42 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(AliRawReader* rawReader) :
43 fRawReader(rawReader),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE)
45 // Constructor: initializes input data stream supplied by rawReader
46 // Checks existence of histograms which might have been left
47 // from the previous runs to continues their filling
49 fHistoFile = new TFile("calibHisto.root","update");
51 for(Int_t module=0; module<5; module++) {
52 for(Int_t column=0; column<56; column++) {
53 for(Int_t row=0; row<64; row++) {
55 sprintf(hname,"mod%dcol%drow%d",module,column,row);
56 TH1F* hist = (TH1F*)fHistoFile->Get(hname);
58 fAmpHisto[module][column][row]=hist;
60 fAmpHisto[module][column][row]=0;
66 //-----------------------------------------------------------------------------
67 AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() :
68 fRawReader(0),fHistoFile(0),fUpdatingRate(0),fIsOldRCUFormat(kFALSE)
70 // Default constructor
73 //-----------------------------------------------------------------------------
74 AliPHOSCalibHistoProducer::~AliPHOSCalibHistoProducer()
77 if(fHistoFile) delete fHistoFile;
80 //-----------------------------------------------------------------------------
81 void AliPHOSCalibHistoProducer::Run()
83 // Reads raw data stream and fills amplitude histograms
84 // The histograms are written to file every fUpdatingRate events
92 TClonesArray *digits = new TClonesArray("AliPHOSDigit",100);
93 AliPHOSGeometry* geo = AliPHOSGeometry::GetInstance("IHEP");
95 AliPHOSRawDecoder dc(fRawReader);
97 dc.SetOldRCUFormat(kTRUE);
99 AliPHOSRawDigiProducer producer;
101 // Read raw data event by event
103 while (fRawReader->NextEvent()) {
104 runNum = fRawReader->GetRunNumber();
105 producer.MakeDigits(digits,&dc);
107 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
108 digit = (AliPHOSDigit*)digits->At(iDigit);
109 energy = digit->GetEnergy(); // no pedestal subtraction!
110 geo->AbsToRelNumbering(digit->GetId(),relId);
111 Int_t mod = relId[0]-1;
112 Int_t col = relId[3]-1;
113 Int_t row = relId[2]-1;
115 if(fAmpHisto[mod][col][row]) {
116 fAmpHisto[mod][col][row]->Fill(energy);
120 sprintf(hname,"mod%dcol%drow%d",mod,col,row);
121 fAmpHisto[mod][col][row] = new TH1F(hname,hname,100,0.,1000.);
124 // update histograms in local file every 100th event
125 if(iEvent%fUpdatingRate == 0) {
126 AliInfo(Form("Updating histo file, event %d, run %d\n",iEvent,runNum));
138 AliInfo(Form("%d events of run %d processed.",iEvent,runNum));
141 //-----------------------------------------------------------------------------
142 void AliPHOSCalibHistoProducer::UpdateHistoFile()
144 // Write histograms to file
146 if(!fHistoFile) return;
147 if(!fHistoFile->IsOpen()) return;
151 for(Int_t module=0; module<5; module++) {
152 for(Int_t column=0; column<56; column++) {
153 for(Int_t row=0; row<64; row++) {
154 hist = fAmpHisto[module][column][row];
155 if(hist) hist->Write(hist->GetName(),TObject::kWriteDelete);