]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDQADataMakerRec.cxx
Make and print an image of QA user flagged histograms (Yves)
[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
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:
40 // - rec points
41 // - esd data
42 // - raws
43 // Author : Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
44 //_____________________________________________________________________
45
46 ClassImp(AliFMDQADataMakerRec)
47 #if 0
48 ; // For Emacs - do not delete!
49 #endif
50            
51 //_____________________________________________________________________
52 AliFMDQADataMakerRec::AliFMDQADataMakerRec() : 
53   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
54                     "FMD Quality Assurance Data Maker"),
55   fDigitsArray("AliFMDDigit", 0),
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     fDigitsArray(qadm.fDigitsArray),
67     fRecPointsArray(qadm.fRecPointsArray)
68 {
69   // copy ctor 
70   // Parameters: 
71   //    qadm    Object to copy from
72   
73 }
74 //_____________________________________________________________________
75 AliFMDQADataMakerRec& AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm ) 
76 {
77   fDigitsArray = qadm.fDigitsArray;
78   fRecPointsArray = qadm.fRecPointsArray;
79   
80   return *this;
81 }
82 //_____________________________________________________________________
83 AliFMDQADataMakerRec::~AliFMDQADataMakerRec()
84 {
85  
86 }
87
88
89 //_____________________________________________________________________ 
90
91 void 
92 AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, 
93                                          TObjArray ** list)
94 {
95   // Detector specific actions at end of cycle
96   // do the QA checking
97   AliLog::Message(5,"FMD: end of detector cycle",
98                   "AliFMDQADataMakerRec","AliFMDQADataMakerRec",
99                   "AliFMDQADataMakerRec::EndOfDetectorCycle",
100                   "AliFMDQADataMakerRec.cxx",95);
101   AliQAChecker::Instance()->Run(AliQAv1::kFMD, task, list);
102 }
103
104 //_____________________________________________________________________ 
105 void AliFMDQADataMakerRec::InitESDs()
106 {
107   // create Digits histograms in Digits subdir
108   const Bool_t expert   = kTRUE ; 
109   const Bool_t image    = kTRUE ; 
110   
111   TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
112   hEnergyOfESD->SetXTitle("Edep/Emip");
113   hEnergyOfESD->SetYTitle("Counts");
114   Add2ESDsList(hEnergyOfESD, 0, !expert, image);
115     
116 }
117
118 //_____________________________________________________________________ 
119 void AliFMDQADataMakerRec::InitRecPoints()
120 {
121   // create Reconstructed Points histograms in RecPoints subdir
122   const Bool_t expert   = kTRUE ; 
123   const Bool_t image    = kTRUE ; 
124
125   TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
126                                       "Energy Distribution",100,0,3);
127   hEnergyOfRecpoints->SetXTitle("Edep/Emip");
128   hEnergyOfRecpoints->SetYTitle("");
129   Add2RecPointsList(hEnergyOfRecpoints,0, !expert, image);
130 }
131
132 //_____________________________________________________________________ 
133 void AliFMDQADataMakerRec::InitRaws()
134 {
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
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++) {
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);
150       Add2RawsList(hADCCounts, index1, expert, !image, !saveCorr);
151       
152       for(Int_t b = 0; b<=1;b++) {
153         
154         //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
155         UInt_t board = (iring == 1 ? 0 : 1);
156         board = board + b*16;
157         
158         
159         hADCCounts      = new TH1I(Form("hADCCounts_FMD%d%c_board%d",
160                                         det, ring, board), "ADC counts",
161                                    1024,0,1023);
162         hADCCounts->SetXTitle("ADC counts");
163         hADCCounts->SetYTitle("");
164         Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
165         Add2RawsList(hADCCounts, index2, !expert, image, !saveCorr);
166
167       }
168     }
169   }
170 }
171
172 //_____________________________________________________________________
173 void 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
199 /*
200 //_____________________________________________________________________
201 void AliFMDQADataMakerRec::MakeDigits(TClonesArray * digits)
202 {
203   // makes data from Digits  
204   if(!digits)  {
205     AliError("FMD Digit object not found!!") ;
206     return;
207   }
208   for(Int_t i=0;i<digits->GetEntriesFast();i++) {
209     //Raw ADC counts
210     AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
211     GetDigitsData(0)->Fill(digit->Counts());
212   }
213 }
214
215 //_____________________________________________________________________
216 void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
217 {
218   
219   fDigitsArray.Clear();
220   TBranch*      branch = digitTree->GetBranch("FMD");
221   if (!branch) {
222     AliWarning("FMD branch in Digit Tree not found") ; 
223     return;
224   } 
225   TClonesArray* digitsAddress = &fDigitsArray;
226   branch->SetAddress(&digitsAddress);
227   branch->GetEntry(0); 
228   MakeDigits(digitsAddress);
229 }
230 */
231 //_____________________________________________________________________
232 void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
233 {
234  
235   AliFMDRawReader fmdReader(rawReader,0);
236   TClonesArray* digitsAddress = &fDigitsArray;
237   
238   rawReader->Reset();
239                 
240   digitsAddress->Clear();
241   fmdReader.ReadAdcs(digitsAddress);
242   for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
243     //Raw ADC counts
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);
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   }
258 }
259
260 //_____________________________________________________________________
261 void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
262 {
263   // makes data from RecPoints
264   AliFMDParameters* pars = AliFMDParameters::Instance();
265   fRecPointsArray.Clear();
266   TBranch *fmdbranch = clustersTree->GetBranch("FMD");
267   if (!fmdbranch) { 
268     AliError("can't get the branch with the FMD recpoints !");
269     return;
270   }
271   
272   TClonesArray* RecPointsAddress = &fRecPointsArray;
273   
274   fmdbranch->SetAddress(&RecPointsAddress);
275   fmdbranch->GetEntry(0);
276   TIter next(RecPointsAddress) ; 
277   AliFMDRecPoint * rp ; 
278   while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
279     
280     GetRecPointsData(0)->Fill(rp->Edep()/pars->GetEdepMip()) ;
281   
282   }
283
284 }
285
286 //_____________________________________________________________________ 
287 void AliFMDQADataMakerRec::StartOfDetectorCycle()
288 {
289   // What 
290   // to 
291   // do?
292 }
293 //_____________________________________________________________________ 
294 Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det, 
295                                              Char_t ring, 
296                                              UShort_t board, 
297                                              UShort_t monitor) {
298   
299   UShort_t iring  =  (ring == 'I' ? 1 : 0);
300   
301   Int_t index = ( ((det-1) << 3) | (iring << 2) | (board << 1) | (monitor << 0));
302   
303   return index-2;
304   
305 }
306
307 //_____________________________________________________________________ 
308
309
310 //
311 // EOF
312 //