]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDQADataMakerRec.cxx
Fixed coding convention issues as given by the automatic
[u/mrichter/AliRoot.git] / FMD / AliFMDQADataMakerRec.cxx
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"
31 #include "AliFMDRawReader.h"
32 #include "AliRawReader.h"
33 #include "AliFMDAltroMapping.h"
34 #include "AliFMDDebug.h"
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:
41 // - rec points
42 // - esd data
43 // - raws
44 // Author : Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
45 //_____________________________________________________________________
46
47 ClassImp(AliFMDQADataMakerRec)
48 #if 0
49 ; // For Emacs - do not delete!
50 #endif
51            
52 //_____________________________________________________________________
53 AliFMDQADataMakerRec::AliFMDQADataMakerRec() : 
54   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
55                     "FMD Quality Assurance Data Maker"),
56   fRecPointsArray("AliFMDRecPoint", 1000)
57 {
58   // ctor
59  
60 }
61
62 //_____________________________________________________________________
63 AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm) 
64   : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
65                       "FMD Quality Assurance Data Maker"),
66     fRecPointsArray(qadm.fRecPointsArray)
67 {
68   // copy ctor 
69   // Parameters: 
70   //    qadm    Object to copy from
71   
72 }
73 //_____________________________________________________________________
74 AliFMDQADataMakerRec& 
75 AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm ) 
76 {
77   // 
78   // Assignment operator 
79   // 
80   // Parameters:
81   //    qadm What to assign from 
82   // 
83   // Return:
84   //    Reference to this
85   //
86   fRecPointsArray = qadm.fRecPointsArray;
87   
88   return *this;
89 }
90 //_____________________________________________________________________
91 AliFMDQADataMakerRec::~AliFMDQADataMakerRec()
92 {
93   // 
94   // Destrcutor 
95   // 
96 }
97
98
99 //_____________________________________________________________________ 
100
101 void 
102 AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, 
103                                          TObjArray ** list)
104 {
105   // Detector specific actions at end of cycle
106   // do the QA checking
107   AliLog::Message(5,"FMD: end of detector cycle",
108                   "AliFMDQADataMakerRec","AliFMDQADataMakerRec",
109                   "AliFMDQADataMakerRec::EndOfDetectorCycle",
110                   "AliFMDQADataMakerRec.cxx",95);
111   AliQAChecker::Instance()->Run(AliQAv1::kFMD, task, list);
112 }
113
114 //_____________________________________________________________________ 
115 void AliFMDQADataMakerRec::InitESDs()
116 {
117   // create Digits histograms in Digits subdir
118   const Bool_t expert   = kTRUE ; 
119   const Bool_t image    = kTRUE ; 
120   
121   TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
122   hEnergyOfESD->SetXTitle("Edep/Emip");
123   hEnergyOfESD->SetYTitle("Counts");
124   Add2ESDsList(hEnergyOfESD, 0, !expert, image);
125     
126 }
127
128 //_____________________________________________________________________
129 void AliFMDQADataMakerRec::InitDigits()
130 {
131   // create Digits histograms in Digits subdir
132   const Bool_t expert   = kTRUE ; 
133   const Bool_t image    = kTRUE ; 
134   
135   TH1I* hADCCounts = new TH1I("hADCCounts",
136                               "Dist of ADC counts;ADC counts;Counts",
137                               1024,0,1024);
138   Add2DigitsList(hADCCounts, 0, !expert, image);
139 }
140
141
142 //_____________________________________________________________________ 
143 void AliFMDQADataMakerRec::InitRecPoints()
144 {
145   // create Reconstructed Points histograms in RecPoints subdir
146   const Bool_t expert   = kTRUE ; 
147   const Bool_t image    = kTRUE ; 
148
149   TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
150                                       "Energy Distribution",100,0,3);
151   hEnergyOfRecpoints->SetXTitle("Edep/Emip");
152   hEnergyOfRecpoints->SetYTitle("Counts");
153   Add2RecPointsList(hEnergyOfRecpoints,0, !expert, image);
154 }
155
156 //_____________________________________________________________________ 
157 void AliFMDQADataMakerRec::InitRaws()
158 {
159   // create Raws histograms in Raws subdir  
160   const Bool_t expert   = kTRUE ; 
161   const Bool_t saveCorr = kTRUE ; 
162   const Bool_t image    = kTRUE ; 
163   Int_t colors[3] = {kRed,kGreen,kBlue};
164   TH1I* hADCCounts;
165   for(Int_t det = 1; det<=3; det++) {
166     Int_t firstring = (det==1 ? 1 : 0);
167     for(Int_t iring = firstring;iring<=1;iring++) {
168       Char_t ring = (iring == 1 ? 'I' : 'O');
169       hADCCounts = 
170         new TH1I(Form("hADCCounts_FMD%d%c", det, ring), 
171                  Form("FMD%d%c ADC counts;Amplitude [ADC counts];Counts",
172                       det,ring),1024,0,1023);
173       hADCCounts->SetFillStyle(3001);
174       hADCCounts->SetFillColor(colors[det-1]+2+iring);
175       hADCCounts->SetDrawOption("LOGY");
176
177       Int_t index1 = GetHalfringIndex(det, ring, 0,1);
178       Add2RawsList(hADCCounts, index1, !expert, image, !saveCorr);
179       
180       for(Int_t b = 0; b<=1;b++) {
181         
182         //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
183         UInt_t board = (iring == 1 ? 0 : 1);
184         board = board + b*16;
185         
186         
187         hADCCounts      = 
188           new TH1I(Form("hADCCounts_FMD%d%c_0x%02x", det, ring, board), 
189                    Form("FMD%d%c_0x%x ADC counts;Amplitude [ADC counts];Counts",
190                         det,ring, board),1024,0,1023);
191         hADCCounts->SetXTitle("ADC counts");
192         hADCCounts->SetYTitle("");
193         hADCCounts->SetFillStyle(3001);
194         hADCCounts->SetFillColor(colors[det-1]+2+iring);
195         hADCCounts->SetDrawOption("LOGY");
196         Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
197         Add2RawsList(hADCCounts, index2, expert, !image, !saveCorr);
198
199       }
200     }
201   }
202 }
203
204 #if 0
205 struct FillESDHist : public AliESDFMD::ForOne
206 {
207   FillESDHist(AliFMDQADataMakerRec* m) : fM(m) {}
208   FillESDHist(const FillESDHist& o) : fM(o.fM) {}
209   FillESDHist& operator=(const FillESDHist& o) { fM = o.fM; return *this;  }
210   Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Float_t m, Float_t) 
211   {
212     // Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
213     if(m == AliESDFMD::kInvalidMult) return true;
214     
215     fM->GetESDsData(0)->Fill(m);    
216     return true;
217   }
218   AliFMDQADataMakerRec* fM;
219 };
220 #endif
221
222 //_____________________________________________________________________
223 void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
224 {
225   // 
226   // Analyse ESD event
227   // 
228   // Parameters:
229   //    esd ESD event
230   //
231   if(!esd) {
232     AliError("FMD ESD object not found!!") ; 
233     return;
234   }
235   AliFMDDebug(2, ("Will loop over ESD data and fill histogram"));
236
237   AliESDFMD* fmd = esd->GetFMDData();
238   if (!fmd) return;
239
240 #if 0
241   FillESDHist f(this);
242   fmd->ForEach(f);
243 #else
244
245
246
247   // FIXME - we should use AliESDFMD::ForOne subclass to do this!
248   for(UShort_t det=1;det<=3;det++) {
249     UShort_t nrng = (det == 1 ? 1 : 2);
250     for (UShort_t ir = 0; ir < nrng; ir++) {
251       Char_t   ring = (ir == 0 ? 'I' : 'O');
252       UShort_t nsec = (ir == 0 ? 20  : 40);
253       UShort_t nstr = (ir == 0 ? 512 : 256);
254       for(UShort_t sec =0; sec < nsec;  sec++)  {
255         for(UShort_t strip = 0; strip < nstr; strip++) {
256           Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
257           if(mult == AliESDFMD::kInvalidMult) continue;
258           
259           GetESDsData(0)->Fill(mult);
260         }
261       }
262     }
263   }
264 #endif
265 }
266
267
268 //_____________________________________________________________________
269 void AliFMDQADataMakerRec::MakeDigits()
270 {
271   // makes data from Digits  
272   if(!fDigitsArray)  {
273     AliError("FMD Digit object not found!!") ;
274     return;
275   }
276   
277   for(Int_t i=0;i<fDigitsArray->GetEntriesFast();i++) {
278     //Raw ADC counts
279     AliFMDDigit* digit = static_cast<AliFMDDigit*>(fDigitsArray->At(i));
280     GetDigitsData(0)->Fill(digit->Counts());
281   }
282 }
283
284 //_____________________________________________________________________
285 void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
286 {
287   // 
288   // Analyse digits
289   // 
290   // Parameters:
291   //    digitTree Tree of digits
292   //
293   
294   if (fDigitsArray) 
295     fDigitsArray->Clear();
296   else 
297     fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
298
299   TBranch*      branch = digitTree->GetBranch("FMD");
300   if (!branch) {
301     AliWarning("FMD branch in Digit Tree not found") ; 
302     return;
303   } 
304   branch->SetAddress(&fDigitsArray);
305   branch->GetEntry(0); 
306   MakeDigits();
307 }
308
309 //_____________________________________________________________________
310 void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
311 {
312   // 
313   // Analyse raw 
314   // 
315   // Parameters:
316   //    rawReader Raw reader
317   //
318  
319   AliFMDRawReader fmdReader(rawReader,0);
320   
321   if (fDigitsArray) 
322     fDigitsArray->Clear();
323   else 
324     fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
325
326   TClonesArray* digitsAddress = fDigitsArray;
327   
328   rawReader->Reset();
329                 
330   digitsAddress->Clear();
331   fmdReader.ReadAdcs(digitsAddress);
332   for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
333     //Raw ADC counts
334     AliFMDDigit*      digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
335     UShort_t          det   = digit->Detector();
336     Char_t            ring  = digit->Ring();
337     UShort_t          sec   = digit->Sector();
338     // UShort_t strip = digit->Strip();
339     AliFMDParameters* pars  = AliFMDParameters::Instance();
340     Short_t           board = pars->GetAltroMap()->Sector2Board(ring, sec);
341     
342     Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
343     GetRawsData(index1)->Fill(digit->Counts());
344     Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
345     GetRawsData(index2)->Fill(digit->Counts());
346     
347   }
348 }
349
350 //_____________________________________________________________________
351 void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
352 {
353   // makes data from RecPoints
354   
355    AliFMDParameters* pars = AliFMDParameters::Instance();
356   fRecPointsArray.Clear();
357   TBranch *fmdbranch = clustersTree->GetBranch("FMD");
358   if (!fmdbranch) { 
359     AliError("can't get the branch with the FMD recpoints !");
360     return;
361   }
362   
363   TClonesArray* RecPointsAddress = &fRecPointsArray;
364   
365   fmdbranch->SetAddress(&RecPointsAddress);
366   fmdbranch->GetEntry(0);
367   TIter next(RecPointsAddress) ; 
368   AliFMDRecPoint * rp ; 
369   while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
370     
371     GetRecPointsData(0)->Fill(rp->Edep()/pars->GetEdepMip()) ;
372   
373   }
374
375 }
376
377 //_____________________________________________________________________ 
378 void AliFMDQADataMakerRec::StartOfDetectorCycle()
379 {
380   // What 
381   // to 
382   // do?
383 }
384 //_____________________________________________________________________ 
385 Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det, 
386                                              Char_t ring, 
387                                              UShort_t board, 
388                                              UShort_t monitor) const
389 {
390   // 
391   // Get the half-ring index
392   // 
393   // Parameters:
394   //    det      Detector
395   //    ring     Ring
396   //    board    Board number
397   //    monitor  Monitor 
398   // 
399   // Return:
400   //    Half ring index
401   //  
402   UShort_t iring  =  (ring == 'I' ? 1 : 0);
403   Int_t index = ( ((det-1) << 3) | (iring << 2) | (board << 1) | 
404                   (monitor << 0));
405   
406   return index-2;
407 }
408
409 //_____________________________________________________________________ 
410
411
412 //
413 // EOF
414 //