In AliMUONChamberCalibrationTask:
[u/mrichter/AliRoot.git] / FMD / AliFMDQADataMakerRec.cxx
CommitLineData
c9dd1c4d 1/**************************************************************************
2 * Copyright(c) 2004, 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// --- ROOT system ---
16#include <iostream>
17#include <TClonesArray.h>
18#include <TFile.h>
19#include <TH1F.h>
20#include <TH1I.h>
21
22// --- AliRoot header files ---
23#include "AliESDEvent.h"
24#include "AliLog.h"
25#include "AliFMDQADataMakerRec.h"
26#include "AliFMDDigit.h"
27#include "AliFMDRecPoint.h"
28#include "AliQAChecker.h"
29#include "AliESDFMD.h"
30#include "AliFMDParameters.h"
86c6cec8 31#include "AliFMDRawReader.h"
3ceaa9ad 32#include "AliRawReader.h"
b995fc28 33#include "AliFMDAltroMapping.h"
f4b5062e 34#include "AliFMDDebug.h"
c9dd1c4d 35
36//_____________________________________________________________________
37// This is the class that collects the QA data for the FMD during
38// reconstruction.
39//
40// The following data types are picked up:
c9dd1c4d 41// - rec points
42// - esd data
c9dd1c4d 43// - raws
44// Author : Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
45//_____________________________________________________________________
46
47ClassImp(AliFMDQADataMakerRec)
48#if 0
49; // For Emacs - do not delete!
50#endif
51
52//_____________________________________________________________________
53AliFMDQADataMakerRec::AliFMDQADataMakerRec() :
4e25ac79 54 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD),
a7e41e8d 55 "FMD Quality Assurance Data Maker"),
198942c7 56 fRecPointsArray("AliFMDRecPoint", 1000)
c9dd1c4d 57{
58 // ctor
56236ce9 59
c9dd1c4d 60}
61
62//_____________________________________________________________________
a7e41e8d 63AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm)
4e25ac79 64 : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD),
a7e41e8d 65 "FMD Quality Assurance Data Maker"),
a7e41e8d 66 fRecPointsArray(qadm.fRecPointsArray)
c9dd1c4d 67{
ffa78f64 68 // copy ctor
c9dd1c4d 69 // Parameters:
70 // qadm Object to copy from
71
72}
9bd2ccc2 73//_____________________________________________________________________
a7e41e8d 74AliFMDQADataMakerRec& AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm )
75{
a7e41e8d 76 fRecPointsArray = qadm.fRecPointsArray;
77
78 return *this;
79}
80//_____________________________________________________________________
9bd2ccc2 81AliFMDQADataMakerRec::~AliFMDQADataMakerRec()
82{
56236ce9 83
9bd2ccc2 84}
c9dd1c4d 85
86
87//_____________________________________________________________________
88
89void
4e25ac79 90AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task,
57acd2d2 91 TObjArray ** list)
c9dd1c4d 92{
93 // Detector specific actions at end of cycle
94 // do the QA checking
ffa78f64 95 AliLog::Message(5,"FMD: end of detector cycle",
96 "AliFMDQADataMakerRec","AliFMDQADataMakerRec",
97 "AliFMDQADataMakerRec::EndOfDetectorCycle",
98 "AliFMDQADataMakerRec.cxx",95);
4e25ac79 99 AliQAChecker::Instance()->Run(AliQAv1::kFMD, task, list);
c9dd1c4d 100}
101
102//_____________________________________________________________________
103void AliFMDQADataMakerRec::InitESDs()
104{
105 // create Digits histograms in Digits subdir
7d297381 106 const Bool_t expert = kTRUE ;
107 const Bool_t image = kTRUE ;
108
c9dd1c4d 109 TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
110 hEnergyOfESD->SetXTitle("Edep/Emip");
111 hEnergyOfESD->SetYTitle("Counts");
7d297381 112 Add2ESDsList(hEnergyOfESD, 0, !expert, image);
c9dd1c4d 113
114}
115
44ed7a66 116//_____________________________________________________________________
117void AliFMDQADataMakerRec::InitDigits()
118{
119 // create Digits histograms in Digits subdir
120 const Bool_t expert = kTRUE ;
121 const Bool_t image = kTRUE ;
122
db72ff3b 123 TH1I* hADCCounts = new TH1I("hADCCounts","Dist of ADC counts;ADC counts;Counts",1024,0,1024);
44ed7a66 124 Add2DigitsList(hADCCounts, 0, !expert, image);
125}
126
127
c9dd1c4d 128//_____________________________________________________________________
c9dd1c4d 129void AliFMDQADataMakerRec::InitRecPoints()
130{
7d297381 131 // create Reconstructed Points histograms in RecPoints subdir
132 const Bool_t expert = kTRUE ;
133 const Bool_t image = kTRUE ;
134
c9dd1c4d 135 TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
136 "Energy Distribution",100,0,3);
137 hEnergyOfRecpoints->SetXTitle("Edep/Emip");
db72ff3b 138 hEnergyOfRecpoints->SetYTitle("Counts");
7d297381 139 Add2RecPointsList(hEnergyOfRecpoints,0, !expert, image);
c9dd1c4d 140}
141
142//_____________________________________________________________________
143void AliFMDQADataMakerRec::InitRaws()
144{
7d297381 145 // create Raws histograms in Raws subdir
146 const Bool_t expert = kTRUE ;
147 const Bool_t saveCorr = kTRUE ;
148 const Bool_t image = kTRUE ;
149
b4da452d 150 TH1I* hADCCounts;
151 for(Int_t det = 1; det<=3; det++) {
152 Int_t firstring = (det==1 ? 1 : 0);
153 for(Int_t iring = firstring;iring<=1;iring++) {
c18fe410 154 Char_t ring = (iring == 1 ? 'I' : 'O');
155 hADCCounts = new TH1I(Form("hADCCounts_FMD%d%c",
db72ff3b 156 det, ring), "ADC counts;Amplitude [ADC counts];Counts",
c18fe410 157 1024,0,1023);
158
159 Int_t index1 = GetHalfringIndex(det, ring, 0,1);
7d297381 160 Add2RawsList(hADCCounts, index1, expert, !image, !saveCorr);
c18fe410 161
b4da452d 162 for(Int_t b = 0; b<=1;b++) {
163
c18fe410 164 //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
b4da452d 165 UInt_t board = (iring == 1 ? 0 : 1);
166 board = board + b*16;
c18fe410 167
b4da452d 168
169 hADCCounts = new TH1I(Form("hADCCounts_FMD%d%c_board%d",
db72ff3b 170 det, ring, board), "ADC counts;Amplitude [ADC counts];Counts",
198942c7 171 1024,0,1023);
b4da452d 172 hADCCounts->SetXTitle("ADC counts");
173 hADCCounts->SetYTitle("");
c18fe410 174 Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
7d297381 175 Add2RawsList(hADCCounts, index2, !expert, image, !saveCorr);
c18fe410 176
b4da452d 177 }
178 }
179 }
c9dd1c4d 180}
181
182//_____________________________________________________________________
183void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
184{
185 if(!esd) {
186 AliError("FMD ESD object not found!!") ;
187 return;
188 }
f4b5062e 189 AliFMDDebug(2, ("Will loop over ESD data and fill histogram"));
190
c9dd1c4d 191 AliESDFMD* fmd = esd->GetFMDData();
192 if (!fmd) return;
f4b5062e 193
194 // FIXME - we should use AliESDFMD::ForOne subclass to do this!
c9dd1c4d 195 for(UShort_t det=1;det<=3;det++) {
f4b5062e 196 UShort_t nrng = (det == 1 ? 1 : 2);
197 for (UShort_t ir = 0; ir < nrng; ir++) {
c9dd1c4d 198 Char_t ring = (ir == 0 ? 'I' : 'O');
199 UShort_t nsec = (ir == 0 ? 20 : 40);
200 UShort_t nstr = (ir == 0 ? 512 : 256);
201 for(UShort_t sec =0; sec < nsec; sec++) {
202 for(UShort_t strip = 0; strip < nstr; strip++) {
203 Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
204 if(mult == AliESDFMD::kInvalidMult) continue;
205
206 GetESDsData(0)->Fill(mult);
207 }
208 }
209 }
210 }
211}
212
44ed7a66 213
c9dd1c4d 214//_____________________________________________________________________
6252ceeb 215void AliFMDQADataMakerRec::MakeDigits()
c9dd1c4d 216{
217 // makes data from Digits
6252ceeb 218 if(!fDigitsArray) {
ffa78f64 219 AliError("FMD Digit object not found!!") ;
220 return;
c9dd1c4d 221 }
eca4fa66 222
6252ceeb 223 for(Int_t i=0;i<fDigitsArray->GetEntriesFast();i++) {
c9dd1c4d 224 //Raw ADC counts
6252ceeb 225 AliFMDDigit* digit = static_cast<AliFMDDigit*>(fDigitsArray->At(i));
c9dd1c4d 226 GetDigitsData(0)->Fill(digit->Counts());
227 }
228}
229
230//_____________________________________________________________________
231void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
232{
233
6252ceeb 234 if (fDigitsArray)
235 fDigitsArray->Clear();
236 else
237 fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
238
ffa78f64 239 TBranch* branch = digitTree->GetBranch("FMD");
240 if (!branch) {
c9dd1c4d 241 AliWarning("FMD branch in Digit Tree not found") ;
242 return;
243 }
6252ceeb 244 branch->SetAddress(&fDigitsArray);
ffa78f64 245 branch->GetEntry(0);
6252ceeb 246 MakeDigits();
c9dd1c4d 247}
44ed7a66 248
c9dd1c4d 249//_____________________________________________________________________
86c6cec8 250void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
c9dd1c4d 251{
198942c7 252
6252ceeb 253 AliFMDRawReader fmdReader(rawReader,0);
254
255 if (fDigitsArray)
256 fDigitsArray->Clear();
257 else
258 fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
eca4fa66 259
6252ceeb 260 TClonesArray* digitsAddress = fDigitsArray;
3ceaa9ad 261
262 rawReader->Reset();
78328afd 263
c18fe410 264 digitsAddress->Clear();
265 fmdReader.ReadAdcs(digitsAddress);
266 for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
267 //Raw ADC counts
b995fc28 268 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
269 UShort_t det = digit->Detector();
270 Char_t ring = digit->Ring();
271 UShort_t sec = digit->Sector();
272 // UShort_t strip = digit->Strip();
273 AliFMDParameters* pars = AliFMDParameters::Instance();
274 Short_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
c18fe410 275
276 Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
277 GetRawsData(index1)->Fill(digit->Counts());
278 Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
279 GetRawsData(index2)->Fill(digit->Counts());
280
281 }
c9dd1c4d 282}
283
284//_____________________________________________________________________
285void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
286{
287 // makes data from RecPoints
eca4fa66 288
6252ceeb 289 AliFMDParameters* pars = AliFMDParameters::Instance();
56236ce9 290 fRecPointsArray.Clear();
c9dd1c4d 291 TBranch *fmdbranch = clustersTree->GetBranch("FMD");
292 if (!fmdbranch) {
293 AliError("can't get the branch with the FMD recpoints !");
294 return;
295 }
296
56236ce9 297 TClonesArray* RecPointsAddress = &fRecPointsArray;
9bd2ccc2 298
56236ce9 299 fmdbranch->SetAddress(&RecPointsAddress);
c9dd1c4d 300 fmdbranch->GetEntry(0);
56236ce9 301 TIter next(RecPointsAddress) ;
c9dd1c4d 302 AliFMDRecPoint * rp ;
303 while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
198942c7 304
305 GetRecPointsData(0)->Fill(rp->Edep()/pars->GetEdepMip()) ;
306
c9dd1c4d 307 }
c9dd1c4d 308
309}
310
311//_____________________________________________________________________
312void AliFMDQADataMakerRec::StartOfDetectorCycle()
313{
314 // What
315 // to
316 // do?
317}
318//_____________________________________________________________________
b4da452d 319Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det,
320 Char_t ring,
c18fe410 321 UShort_t board,
322 UShort_t monitor) {
b4da452d 323
324 UShort_t iring = (ring == 'I' ? 1 : 0);
325
c18fe410 326 Int_t index = ( ((det-1) << 3) | (iring << 2) | (board << 1) | (monitor << 0));
b4da452d 327
328 return index-2;
329
330}
331
332//_____________________________________________________________________
333
334
c9dd1c4d 335//
336// EOF
337//