]>
Commit | Line | Data |
---|---|---|
1ab07e55 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
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 | |
24 | // | |
25 | // Author: Boris Polichtchouk, 4 October 2006 | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "AliLog.h" | |
29 | #include "AliPHOSCalibHistoProducer.h" | |
30 | #include "TH1.h" | |
a3925367 | 31 | #include "TH2F.h" |
1ab07e55 | 32 | #include "TFile.h" |
4fc0021f | 33 | #include "AliPHOSRawDecoder.h" |
1ab07e55 | 34 | |
35 | ClassImp(AliPHOSCalibHistoProducer) | |
36 | ||
37 | //----------------------------------------------------------------------------- | |
383d8adb | 38 | AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() : |
a3925367 | 39 | fRawDecoder(0),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE), |
40 | fEvents(0) | |
1ab07e55 | 41 | { |
383d8adb | 42 | // Constructor: initializes data members |
1ab07e55 | 43 | // Checks existence of histograms which might have been left |
44 | // from the previous runs to continues their filling | |
45 | ||
46 | fHistoFile = new TFile("calibHisto.root","update"); | |
a3925367 | 47 | |
1ab07e55 | 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++) { | |
51 | char hname[128]; | |
52 | sprintf(hname,"mod%dcol%drow%d",module,column,row); | |
53 | TH1F* hist = (TH1F*)fHistoFile->Get(hname); | |
54 | if(hist) | |
55 | fAmpHisto[module][column][row]=hist; | |
a3925367 | 56 | else |
57 | fAmpHisto[module][column][row] = 0; | |
1ab07e55 | 58 | } |
59 | } | |
60 | } | |
61 | } | |
62 | ||
63 | //----------------------------------------------------------------------------- | |
383d8adb | 64 | AliPHOSCalibHistoProducer::~AliPHOSCalibHistoProducer() |
1ab07e55 | 65 | { |
383d8adb | 66 | // Destructor |
67 | ||
68 | UpdateHistoFile(); | |
383d8adb | 69 | if(fHistoFile) delete fHistoFile; |
383d8adb | 70 | |
1ab07e55 | 71 | } |
72 | ||
73 | //----------------------------------------------------------------------------- | |
383d8adb | 74 | AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(const AliPHOSCalibHistoProducer &histoproducer) : |
a3925367 | 75 | TObject(histoproducer),fRawDecoder(histoproducer.fRawDecoder),fHistoFile(histoproducer.fHistoFile), |
383d8adb | 76 | fUpdatingRate(histoproducer.fUpdatingRate),fIsOldRCUFormat(histoproducer.fIsOldRCUFormat), |
a3925367 | 77 | fEvents(histoproducer.fEvents) |
1ab07e55 | 78 | { |
383d8adb | 79 | //Copy constructor. |
80 | ||
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++) { | |
84 | char hname[128]; | |
85 | sprintf(hname,"mod%dcol%drow%d",module,column,row); | |
86 | TH1F* hist = (TH1F*)histoproducer.fHistoFile->Get(hname); | |
87 | if(hist) | |
88 | fAmpHisto[module][column][row]= new TH1F(*hist); | |
89 | else | |
90 | fAmpHisto[module][column][row]=0; | |
91 | } | |
92 | } | |
93 | } | |
1ab07e55 | 94 | } |
95 | ||
383d8adb | 96 | //----------------------------------------------------------------------------- |
97 | AliPHOSCalibHistoProducer& AliPHOSCalibHistoProducer::operator= | |
98 | (const AliPHOSCalibHistoProducer &histoproducer) | |
99 | { | |
100 | //Assignment operator. | |
101 | ||
102 | if(this != &histoproducer) { | |
103 | ||
a3925367 | 104 | fRawDecoder = histoproducer.fRawDecoder; |
383d8adb | 105 | fHistoFile = histoproducer.fHistoFile; |
106 | fUpdatingRate = histoproducer.fUpdatingRate; | |
107 | fIsOldRCUFormat = histoproducer.fIsOldRCUFormat; | |
383d8adb | 108 | fEvents = histoproducer.fEvents; |
109 | ||
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]; | |
116 | } | |
117 | else | |
118 | fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row]; | |
119 | } | |
120 | } | |
121 | } | |
122 | ||
123 | ||
124 | } | |
125 | ||
126 | return *this; | |
127 | } | |
1ab07e55 | 128 | //----------------------------------------------------------------------------- |
129 | void AliPHOSCalibHistoProducer::Run() | |
130 | { | |
383d8adb | 131 | // Reads raw data of current event and fills amplitude histograms |
1ab07e55 | 132 | // The histograms are written to file every fUpdatingRate events |
133 | ||
a3925367 | 134 | if(!fRawDecoder) AliFatal("Raw decoder not set!"); |
135 | ||
4fc0021f | 136 | Double_t energy; |
a3925367 | 137 | Int_t mod,col,row; |
383d8adb | 138 | |
72429802 | 139 | if(fIsOldRCUFormat) |
a3925367 | 140 | fRawDecoder->SetOldRCUFormat(kTRUE); |
141 | ||
142 | while(fRawDecoder->NextDigit()) { | |
4fc0021f | 143 | |
a3925367 | 144 | if(fRawDecoder->IsLowGain()) continue; |
383d8adb | 145 | |
a3925367 | 146 | energy = fRawDecoder->GetEnergy(); |
147 | if(energy<10) continue; // noise | |
148 | ||
149 | mod = fRawDecoder->GetModule()-1; | |
150 | col = fRawDecoder->GetColumn()-1; | |
151 | row = fRawDecoder->GetRow()-1; | |
152 | ||
383d8adb | 153 | if(fAmpHisto[mod][col][row]) { |
154 | fAmpHisto[mod][col][row]->Fill(energy); | |
1ab07e55 | 155 | } |
383d8adb | 156 | else { |
157 | char hname[128]; | |
158 | sprintf(hname,"mod%dcol%drow%d",mod,col,row); | |
159 | fAmpHisto[mod][col][row] = new TH1F(hname,hname,100,0.,1000.); | |
a3925367 | 160 | fAmpHisto[mod][col][row]->Fill(energy); |
383d8adb | 161 | } |
162 | ||
163 | // update histograms in local file every 100th event | |
164 | if(fEvents%fUpdatingRate == 0) { | |
a3925367 | 165 | AliInfo(Form("Updating histo file, event %d, run %d\n", |
166 | fEvents,fRawDecoder->GetRawReader()->GetRunNumber())); | |
383d8adb | 167 | UpdateHistoFile(); |
a3925367 | 168 | } |
169 | ||
170 | // UpdateHistoFile(); | |
171 | // AliInfo(Form("%d events of run %d processed.",iEvent,runNum)); | |
1ab07e55 | 172 | } |
383d8adb | 173 | |
383d8adb | 174 | fEvents++; |
a3925367 | 175 | |
1ab07e55 | 176 | } |
177 | ||
178 | //----------------------------------------------------------------------------- | |
179 | void AliPHOSCalibHistoProducer::UpdateHistoFile() | |
180 | { | |
181 | // Write histograms to file | |
182 | ||
183 | if(!fHistoFile) return; | |
184 | if(!fHistoFile->IsOpen()) return; | |
185 | ||
186 | TH1F* hist=0; | |
a3925367 | 187 | char hname[128]; |
188 | char htitle[128]; | |
1ab07e55 | 189 | |
190 | for(Int_t module=0; module<5; module++) { | |
a3925367 | 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); | |
194 | ||
1ab07e55 | 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); | |
a3925367 | 199 | if(hist) hMeanE.SetBinContent(column,row,hist->GetMean()); |
1ab07e55 | 200 | } |
201 | } | |
a3925367 | 202 | hMeanE.Write(hMeanE.GetName(),TObject::kWriteDelete); |
1ab07e55 | 203 | } |
204 | ||
205 | } |