Use double precision everywhere (Federico)
[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
44ed7a66 118//_____________________________________________________________________
119void AliFMDQADataMakerRec::InitDigits()
120{
121 // create Digits histograms in Digits subdir
122 const Bool_t expert = kTRUE ;
123 const Bool_t image = kTRUE ;
124
db72ff3b 125 TH1I* hADCCounts = new TH1I("hADCCounts","Dist of ADC counts;ADC counts;Counts",1024,0,1024);
44ed7a66 126 Add2DigitsList(hADCCounts, 0, !expert, image);
127}
128
129
c9dd1c4d 130//_____________________________________________________________________
c9dd1c4d 131void AliFMDQADataMakerRec::InitRecPoints()
132{
7d297381 133 // create Reconstructed Points histograms in RecPoints subdir
134 const Bool_t expert = kTRUE ;
135 const Bool_t image = kTRUE ;
136
c9dd1c4d 137 TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
138 "Energy Distribution",100,0,3);
139 hEnergyOfRecpoints->SetXTitle("Edep/Emip");
db72ff3b 140 hEnergyOfRecpoints->SetYTitle("Counts");
7d297381 141 Add2RecPointsList(hEnergyOfRecpoints,0, !expert, image);
c9dd1c4d 142}
143
144//_____________________________________________________________________
145void AliFMDQADataMakerRec::InitRaws()
146{
7d297381 147 // create Raws histograms in Raws subdir
148 const Bool_t expert = kTRUE ;
149 const Bool_t saveCorr = kTRUE ;
150 const Bool_t image = kTRUE ;
151
b4da452d 152 TH1I* hADCCounts;
153 for(Int_t det = 1; det<=3; det++) {
154 Int_t firstring = (det==1 ? 1 : 0);
155 for(Int_t iring = firstring;iring<=1;iring++) {
c18fe410 156 Char_t ring = (iring == 1 ? 'I' : 'O');
157 hADCCounts = new TH1I(Form("hADCCounts_FMD%d%c",
db72ff3b 158 det, ring), "ADC counts;Amplitude [ADC counts];Counts",
c18fe410 159 1024,0,1023);
160
161 Int_t index1 = GetHalfringIndex(det, ring, 0,1);
7d297381 162 Add2RawsList(hADCCounts, index1, expert, !image, !saveCorr);
c18fe410 163
b4da452d 164 for(Int_t b = 0; b<=1;b++) {
165
c18fe410 166 //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
b4da452d 167 UInt_t board = (iring == 1 ? 0 : 1);
168 board = board + b*16;
c18fe410 169
b4da452d 170
171 hADCCounts = new TH1I(Form("hADCCounts_FMD%d%c_board%d",
db72ff3b 172 det, ring, board), "ADC counts;Amplitude [ADC counts];Counts",
198942c7 173 1024,0,1023);
b4da452d 174 hADCCounts->SetXTitle("ADC counts");
175 hADCCounts->SetYTitle("");
c18fe410 176 Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
7d297381 177 Add2RawsList(hADCCounts, index2, !expert, image, !saveCorr);
c18fe410 178
b4da452d 179 }
180 }
181 }
c9dd1c4d 182}
183
184//_____________________________________________________________________
185void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
186{
187 if(!esd) {
188 AliError("FMD ESD object not found!!") ;
189 return;
190 }
191 AliESDFMD* fmd = esd->GetFMDData();
192 if (!fmd) return;
193
eca4fa66 194 // Check id histograms already created for this Event Specie
195 if ( ! GetESDsData(0) )
196 InitESDs() ;
197
c9dd1c4d 198 for(UShort_t det=1;det<=3;det++) {
199 for (UShort_t ir = 0; ir < 2; ir++) {
200 Char_t ring = (ir == 0 ? 'I' : 'O');
201 UShort_t nsec = (ir == 0 ? 20 : 40);
202 UShort_t nstr = (ir == 0 ? 512 : 256);
203 for(UShort_t sec =0; sec < nsec; sec++) {
204 for(UShort_t strip = 0; strip < nstr; strip++) {
205 Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
206 if(mult == AliESDFMD::kInvalidMult) continue;
207
208 GetESDsData(0)->Fill(mult);
209 }
210 }
211 }
212 }
213}
214
44ed7a66 215
c9dd1c4d 216//_____________________________________________________________________
217void AliFMDQADataMakerRec::MakeDigits(TClonesArray * digits)
218{
219 // makes data from Digits
220 if(!digits) {
ffa78f64 221 AliError("FMD Digit object not found!!") ;
222 return;
c9dd1c4d 223 }
eca4fa66 224
225 // Check id histograms already created for this Event Specie
226 if ( ! GetDigitsData(0) )
227 InitDigits() ;
228
56236ce9 229 for(Int_t i=0;i<digits->GetEntriesFast();i++) {
c9dd1c4d 230 //Raw ADC counts
56236ce9 231 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
c9dd1c4d 232 GetDigitsData(0)->Fill(digit->Counts());
233 }
234}
235
236//_____________________________________________________________________
237void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
238{
239
56236ce9 240 fDigitsArray.Clear();
ffa78f64 241 TBranch* branch = digitTree->GetBranch("FMD");
242 if (!branch) {
c9dd1c4d 243 AliWarning("FMD branch in Digit Tree not found") ;
244 return;
245 }
56236ce9 246 TClonesArray* digitsAddress = &fDigitsArray;
247 branch->SetAddress(&digitsAddress);
ffa78f64 248 branch->GetEntry(0);
56236ce9 249 MakeDigits(digitsAddress);
c9dd1c4d 250}
44ed7a66 251
c9dd1c4d 252//_____________________________________________________________________
86c6cec8 253void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
c9dd1c4d 254{
198942c7 255
eca4fa66 256 // Check id histograms already created for this Event Specie
257 if ( ! GetRawsData(0) )
258 InitRaws() ;
259
86c6cec8 260 AliFMDRawReader fmdReader(rawReader,0);
261 TClonesArray* digitsAddress = &fDigitsArray;
3ceaa9ad 262
263 rawReader->Reset();
78328afd 264
c18fe410 265 digitsAddress->Clear();
266 fmdReader.ReadAdcs(digitsAddress);
267 for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
268 //Raw ADC counts
b995fc28 269 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
270 UShort_t det = digit->Detector();
271 Char_t ring = digit->Ring();
272 UShort_t sec = digit->Sector();
273 // UShort_t strip = digit->Strip();
274 AliFMDParameters* pars = AliFMDParameters::Instance();
275 Short_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
c18fe410 276
277 Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
278 GetRawsData(index1)->Fill(digit->Counts());
279 Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
280 GetRawsData(index2)->Fill(digit->Counts());
281
282 }
c9dd1c4d 283}
284
285//_____________________________________________________________________
286void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
287{
288 // makes data from RecPoints
eca4fa66 289
290 // Check id histograms already created for this Event Specie
291 if ( ! GetRecPointsData(0) )
292 InitRecPoints() ;
293
198942c7 294 AliFMDParameters* pars = AliFMDParameters::Instance();
56236ce9 295 fRecPointsArray.Clear();
c9dd1c4d 296 TBranch *fmdbranch = clustersTree->GetBranch("FMD");
297 if (!fmdbranch) {
298 AliError("can't get the branch with the FMD recpoints !");
299 return;
300 }
301
56236ce9 302 TClonesArray* RecPointsAddress = &fRecPointsArray;
9bd2ccc2 303
56236ce9 304 fmdbranch->SetAddress(&RecPointsAddress);
c9dd1c4d 305 fmdbranch->GetEntry(0);
56236ce9 306 TIter next(RecPointsAddress) ;
c9dd1c4d 307 AliFMDRecPoint * rp ;
308 while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
198942c7 309
310 GetRecPointsData(0)->Fill(rp->Edep()/pars->GetEdepMip()) ;
311
c9dd1c4d 312 }
c9dd1c4d 313
314}
315
316//_____________________________________________________________________
317void AliFMDQADataMakerRec::StartOfDetectorCycle()
318{
319 // What
320 // to
321 // do?
322}
323//_____________________________________________________________________
b4da452d 324Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det,
325 Char_t ring,
c18fe410 326 UShort_t board,
327 UShort_t monitor) {
b4da452d 328
329 UShort_t iring = (ring == 'I' ? 1 : 0);
330
c18fe410 331 Int_t index = ( ((det-1) << 3) | (iring << 2) | (board << 1) | (monitor << 0));
b4da452d 332
333 return index-2;
334
335}
336
337//_____________________________________________________________________
338
339
c9dd1c4d 340//
341// EOF
342//