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