]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDQADataMakerRec.cxx
new version to include raw data
[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
33 //_____________________________________________________________________
34 // This is the class that collects the QA data for the FMD during
35 // reconstruction.  
36 //
37 // The following data types are picked up:
38 // - digits
39 // - rec points
40 // - esd data
41 // The following data types are not supported (yet):
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(AliQA::GetDetName(AliQA::kFMD), 
54                     "FMD Quality Assurance Data Maker"),
55   fDigitsArray("AliFMDDigit", 1000),
56   fRecPointsArray("AliFMDRecPoints", 1000)
57 {
58   // ctor
59  
60 }
61
62 //_____________________________________________________________________
63 AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm) 
64   : AliQADataMakerRec(AliQA::GetDetName(AliQA::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(AliQA::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(AliQA::kFMD, task, list);
102 }
103
104 //_____________________________________________________________________ 
105 void AliFMDQADataMakerRec::InitESDs()
106 {
107   // create Digits histograms in Digits subdir
108   TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
109   hEnergyOfESD->SetXTitle("Edep/Emip");
110   hEnergyOfESD->SetYTitle("Counts");
111   Add2ESDsList(hEnergyOfESD, 0);
112     
113 }
114
115 //_____________________________________________________________________ 
116 /*void AliFMDQADataMakerRec::InitDigits()
117 {
118   // create Digits histograms in Digits subdir
119   TH1I* hADCCounts      = new TH1I("hADCCounts","Dist of ADC counts",
120                                    1024,0,1024);
121   hADCCounts->SetXTitle("ADC counts");
122   hADCCounts->SetYTitle("");
123   Add2DigitsList(hADCCounts, 0);
124   
125 }
126 */
127 //_____________________________________________________________________ 
128 void AliFMDQADataMakerRec::InitRecPoints()
129 {
130   TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
131                                       "Energy Distribution",100,0,3);
132   hEnergyOfRecpoints->SetXTitle("Edep/Emip");
133   hEnergyOfRecpoints->SetYTitle("");
134   Add2RecPointsList(hEnergyOfRecpoints,0);
135 }
136
137 //_____________________________________________________________________ 
138 void AliFMDQADataMakerRec::InitRaws()
139 {
140   TH1I* hADCCounts      = new TH1I("hADCCounts","Dist of ADC counts",
141                                    1024,0,1024);
142   hADCCounts->SetXTitle("ADC counts");
143   hADCCounts->SetYTitle("");
144   Add2RawsList(hADCCounts, 0);
145
146 }
147
148 //_____________________________________________________________________
149 void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
150 {
151   if(!esd) {
152     AliError("FMD ESD object not found!!") ; 
153     return;
154   }
155   AliESDFMD* fmd = esd->GetFMDData();
156   if (!fmd) return;
157   
158   for(UShort_t det=1;det<=3;det++) {
159     for (UShort_t ir = 0; ir < 2; ir++) {
160       Char_t   ring = (ir == 0 ? 'I' : 'O');
161       UShort_t nsec = (ir == 0 ? 20  : 40);
162       UShort_t nstr = (ir == 0 ? 512 : 256);
163       for(UShort_t sec =0; sec < nsec;  sec++)  {
164         for(UShort_t strip = 0; strip < nstr; strip++) {
165           Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
166           if(mult == AliESDFMD::kInvalidMult) continue;
167           
168           GetESDsData(0)->Fill(mult);
169         }
170       }
171     }
172   }
173 }
174
175 /*
176 //_____________________________________________________________________
177 void AliFMDQADataMakerRec::MakeDigits(TClonesArray * digits)
178 {
179   // makes data from Digits  
180   if(!digits)  {
181     AliError("FMD Digit object not found!!") ;
182     return;
183   }
184   for(Int_t i=0;i<digits->GetEntriesFast();i++) {
185     //Raw ADC counts
186     AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
187     GetDigitsData(0)->Fill(digit->Counts());
188   }
189 }
190
191 //_____________________________________________________________________
192 void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
193 {
194   
195   fDigitsArray.Clear();
196   TBranch*      branch = digitTree->GetBranch("FMD");
197   if (!branch) {
198     AliWarning("FMD branch in Digit Tree not found") ; 
199     return;
200   } 
201   TClonesArray* digitsAddress = &fDigitsArray;
202   branch->SetAddress(&digitsAddress);
203   branch->GetEntry(0); 
204   MakeDigits(digitsAddress);
205 }
206 */
207 //_____________________________________________________________________
208 void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
209 {
210   fDigitsArray.Clear();
211   AliFMDRawReader fmdReader(rawReader,0);
212   TClonesArray* digitsAddress = &fDigitsArray;
213   fmdReader.ReadAdcs(digitsAddress);
214  
215   for(Int_t i=0;i<fDigitsArray.GetEntriesFast();i++) {
216     //Raw ADC counts
217     AliFMDDigit* digit = static_cast<AliFMDDigit*>(fDigitsArray.At(i));
218     GetDigitsData(0)->Fill(digit->Counts());
219   }
220   
221 }
222
223 //_____________________________________________________________________
224 void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
225 {
226   // makes data from RecPoints
227   fRecPointsArray.Clear();
228   TBranch *fmdbranch = clustersTree->GetBranch("FMD");
229   if (!fmdbranch) { 
230     AliError("can't get the branch with the FMD recpoints !");
231     return;
232   }
233   
234   TClonesArray* RecPointsAddress = &fRecPointsArray;
235   
236   fmdbranch->SetAddress(&RecPointsAddress);
237   fmdbranch->GetEntry(0);
238     
239   TIter next(RecPointsAddress) ; 
240   AliFMDRecPoint * rp ; 
241   while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
242     GetRecPointsData(0)->Fill(rp->Edep()) ;
243   }
244
245 }
246
247 //_____________________________________________________________________ 
248 void AliFMDQADataMakerRec::StartOfDetectorCycle()
249 {
250   // What 
251   // to 
252   // do?
253 }
254 //_____________________________________________________________________ 
255 //
256 // EOF
257 //