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