Fix over the QA Histogram in AliACORDEQADataMaker::MakeRaws
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQADataMakerRec.cxx
1 /**************************************************************************\r
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3  *                                                                        *\r
4  * Author: The ALICE Off-line Project.                                    *\r
5  * Contributors are mentioned in the code where appropriate.              *\r
6  *                                                                        *\r
7  * Permission to use, copy, modify and distribute this software and its   *\r
8  * documentation strictly for non-commercial purposes is hereby granted   *\r
9  * without fee, provided that the above copyright notice appears in all   *\r
10  * copies and that both the copyright notice and this permission notice   *\r
11  * appear in the supporting documentation. The authors make no claims     *\r
12  * about the suitability of this software for any purpose. It is          *\r
13  * provided "as is" without express or implied warranty.                  *\r
14  **************************************************************************/\r
15 //---\r
16 //  Produces the data needed to calculate the quality assurance. \r
17 //  All data must be mergeable objects.\r
18 \r
19 \r
20 //  Authors:\r
21 //\r
22 //  Luciano Diaz Gonzalez <luciano.diaz@nucleares.unam.mx> (ICN-UNAM)\r
23 //  Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch> (FCFM-BUAP)\r
24 //  Arturo Fernandez Tellez <afernan@mail.cern.ch (FCFM-BUAP)\r
25 //\r
26 //  Created: June 13th 2008\r
27 //---\r
28 // Last Update: Aug. 27th 2008 --> Implementation to declare QA expert histogram\r
29 \r
30 \r
31 // --- ROOT system ---\r
32 #include <TClonesArray.h>\r
33 #include <TFile.h> \r
34 #include <TH1F.h> \r
35 #include <TDirectory.h>\r
36 // --- Standard library ---\r
37 \r
38 // --- AliRoot header files ---\r
39 #include "AliESDEvent.h"\r
40 #include "AliLog.h"\r
41 #include "AliACORDEdigit.h" \r
42 #include "AliACORDEhit.h"\r
43 #include "AliACORDEQADataMakerRec.h"\r
44 #include "AliQAChecker.h"\r
45 #include "AliACORDERawReader.h"\r
46 #include "AliACORDERawStream.h"\r
47 ClassImp(AliACORDEQADataMakerRec)\r
48            \r
49 //____________________________________________________________________________ \r
50 AliACORDEQADataMakerRec::AliACORDEQADataMakerRec():AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")\r
51 {\r
52 \r
53 }\r
54 //____________________________________________________________________________ \r
55 AliACORDEQADataMakerRec::AliACORDEQADataMakerRec(const AliACORDEQADataMakerRec& qadm):AliQADataMakerRec() \r
56 {\r
57   SetName((const char*)qadm.GetName()) ; \r
58   SetTitle((const char*)qadm.GetTitle()); \r
59 }\r
60 //__________________________________________________________________\r
61 AliACORDEQADataMakerRec& AliACORDEQADataMakerRec::operator = (const AliACORDEQADataMakerRec& qadm )\r
62 {\r
63   // Equal operator.\r
64   this->~AliACORDEQADataMakerRec();\r
65   new(this) AliACORDEQADataMakerRec(qadm);\r
66   return *this;\r
67 }\r
68 //____________________________________________________________________________\r
69 void AliACORDEQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)\r
70 {\r
71   //Detector specific actions at end of cycle\r
72   // do the QA checking\r
73   AliQAChecker::Instance()->Run(AliQAv1::kACORDE, task, list) ;\r
74 }\r
75 \r
76 //____________________________________________________________________________\r
77 void AliACORDEQADataMakerRec::StartOfDetectorCycle()\r
78 {\r
79   //Detector specific actions at start of cycle\r
80 \r
81 }\r
82  \r
83 //____________________________________________________________________________ \r
84 void AliACORDEQADataMakerRec::InitRaws()\r
85 {\r
86   // create Raw histograms in Raw subdir\r
87 \r
88   const Bool_t expert   = kTRUE ; \r
89   const Bool_t saveCorr = kTRUE ; \r
90   const Bool_t image    = kTRUE ; \r
91   char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
92                         "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
93                         "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
94                         "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
95                         "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
96                         "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
97 \r
98 \r
99   TH1F *fhACORDEBitPattern[4];\r
100   fhACORDEBitPattern[0] = new TH1F("ACORDEBitPatternfromRAWSingle","Distribution of ACORDE fired modules from RAW-Single;Modules;Counts",60,1,60);//AcordeSingleMuon BitPattern\r
101   fhACORDEBitPattern[1] = new TH1F("ACORDEBitPatternfromRAWMulti","Distribution of ACORDE fired modules from RAW-Multi;Modules;Counts",60,1,60);//AcordeMultiMuon BitPattern\r
102   fhACORDEBitPattern[2] = new TH1F("ACORDEMultiplicityfromRAWSingle","Number of fired ACORDE modules;No. of fired ACORDE modules;No. of events in ACORDE",60,1,60);//AcordeSingleMuon Multiplicity\r
103   fhACORDEBitPattern[3] = new TH1F("ACORDEMultiplicityfromRAWMulti","Number of fired ACORDE modules; No. of fired ACORDE modules;No. of events in ACORDE",60,1,60);//AcordeMultiMuon Multiplicity\r
104   for(Int_t i=0;i<4;i++) \r
105     Add2RawsList(fhACORDEBitPattern[i],i,!expert, image, !saveCorr);\r
106   \r
107   for (Int_t iModule = 0; iModule<60; iModule++)\r
108   {\r
109         fhACORDEBitPattern[0]->GetXaxis()->SetBinLabel(iModule+1,acoModule[iModule]);\r
110         fhACORDEBitPattern[1]->GetXaxis()->SetBinLabel(iModule+1,acoModule[iModule]);\r
111   }\r
112 \r
113 }\r
114 //____________________________________________________________________________ \r
115 void AliACORDEQADataMakerRec::InitDigits()\r
116 {\r
117   // create Digits histograms in Digits subdir\r
118   \r
119   const Bool_t expert   = kTRUE ; \r
120   const Bool_t image    = kTRUE ; \r
121   TH1F *    fhDigitsModule;\r
122    char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
123                         "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
124                         "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
125                         "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
126                         "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
127                         "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
128 \r
129 \r
130   fhDigitsModule = new TH1F("ACORDEBitPatternfromDigits","Distribution of ACORDE from DIGITS;Modules;Counts",60,1,60);\r
131   Add2DigitsList(fhDigitsModule,0,!expert,image);\r
132   for (Int_t i=0;i<60;i++) fhDigitsModule->GetXaxis()->SetBinLabel(i+1,acoModule[i]); \r
133 }\r
134 \r
135 //____________________________________________________________________________ \r
136 \r
137 void AliACORDEQADataMakerRec::InitRecPoints()\r
138 {\r
139   // create cluster histograms in RecPoint subdir\r
140   // Not needed for ACORDE by now !!!\r
141 }\r
142 \r
143 //____________________________________________________________________________\r
144 void AliACORDEQADataMakerRec::InitESDs()\r
145 {\r
146   //create ESDs histograms in ESDs subdir\r
147 \r
148   const Bool_t expert   = kTRUE ; \r
149   const Bool_t image    = kTRUE ; \r
150   \r
151   TH1F *    fhESDsSingle;\r
152   TH1F *    fhESDsMulti;\r
153    char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
154                         "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
155                         "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
156                         "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
157                         "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
158                         "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
159 \r
160 \r
161    fhESDsSingle = new TH1F("ACORDEBitPatternfromESDsSingle","Distribution of ACORDE fired modules from ESDs-Single;Modules;Counts",60,1,60);\r
162    Add2ESDsList(fhESDsSingle,0,!expert,image);\r
163 \r
164    fhESDsMulti = new TH1F("ACORDEBitPatternfromESDsMulti","Distribution of ACORDE fired modules from ESDs-Multi;Modules;Counts",60,1,60);\r
165    Add2ESDsList(fhESDsMulti,1,!expert,image);\r
166         \r
167    for (Int_t i=0;i<60;i++)\r
168    {\r
169         fhESDsSingle->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
170         fhESDsMulti->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
171    }\r
172 \r
173 \r
174 }\r
175 //____________________________________________________________________________\r
176 void AliACORDEQADataMakerRec::MakeRaws(AliRawReader* rawReader)\r
177 {\r
178   //fills QA histos for RAW\r
179 \r
180   rawReader->Reset();\r
181   AliACORDERawStream rawStream(rawReader);\r
182   size_t contSingle=0;\r
183   size_t contMulti=0;\r
184   UInt_t dy[4];\r
185 \r
186   bool kroSingle[60],kroMulti[60];\r
187   UInt_t tmpDy;\r
188 \r
189   for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}\r
190 \r
191 if(rawStream.Next())\r
192 {\r
193         dy[0]=rawStream.GetWord(0);\r
194         dy[1]=rawStream.GetWord(1);\r
195         dy[2]=rawStream.GetWord(2);\r
196         dy[3]=rawStream.GetWord(3);\r
197         tmpDy=dy[0];\r
198         for(Int_t r=0;r<30;r++)\r
199         {\r
200                 kroSingle[r] = tmpDy & 1;\r
201                 tmpDy>>=1;\r
202         }\r
203         tmpDy=dy[1];\r
204         for(Int_t r=30;r<60;r++)\r
205         {\r
206                 kroSingle[r] = tmpDy & 1;\r
207                 tmpDy>>=1;\r
208         }\r
209         tmpDy=dy[2];\r
210         for(Int_t r=0;r<30;r++)\r
211         {\r
212                 kroMulti[r] = tmpDy & 1;\r
213                 tmpDy>>=1;\r
214         }\r
215         tmpDy=dy[3];\r
216         for(Int_t r=30;r<60;r++)\r
217         {\r
218                 kroMulti[r] = tmpDy & 1;\r
219                 tmpDy>>=1;\r
220         }\r
221         contSingle=0;\r
222         contMulti=0;\r
223         for(Int_t r=0;r<60;r++)\r
224         {\r
225                 if(kroSingle[r]==1)\r
226                 {\r
227                         GetRawsData(0)->Fill(r+1);\r
228                         contSingle++;\r
229                 }\r
230                 if(kroMulti[r]==1)\r
231                 {\r
232                         GetRawsData(1)->Fill(r+1);\r
233                         contMulti++;\r
234                 }\r
235 \r
236         }GetRawsData(2)->Fill(contSingle);GetRawsData(3)->Fill(contMulti);\r
237 }\r
238 }\r
239 //____________________________________________________________________________\r
240 void AliACORDEQADataMakerRec::MakeDigits( TTree *digitsTree)\r
241 {\r
242   //fills QA histos for Digits\r
243   if (fDigitsArray) \r
244     fDigitsArray->Clear() ; \r
245   else \r
246     fDigitsArray = new TClonesArray("AliACORDEdigit",1000);\r
247   TBranch * branch = digitsTree->GetBranch("ACORDEdigit");\r
248   if (!branch) {\r
249     AliWarning("ACORDE branch in Digits Tree not found");\r
250   } else {\r
251     branch->SetAddress(&fDigitsArray);\r
252     for(Int_t track = 0 ; track < branch->GetEntries() ; track++) {\r
253       branch->GetEntry(track);\r
254       for(Int_t idigit = 0 ; idigit < fDigitsArray->GetEntriesFast() ; idigit++) {\r
255         AliACORDEdigit *AcoDigit = (AliACORDEdigit*) fDigitsArray->UncheckedAt(idigit);\r
256         if (!AcoDigit) {\r
257           AliError("The unchecked digit doesn't exist");\r
258           continue ;\r
259         }\r
260         GetDigitsData(0)->Fill(AcoDigit->GetModule()-1);\r
261       }\r
262     }\r
263   }\r
264 }\r
265 \r
266 //____________________________________________________________________________\r
267 void AliACORDEQADataMakerRec::MakeESDs(AliESDEvent * esd)\r
268 {\r
269   //fills QA histos for ESD\r
270 \r
271   AliESDACORDE * fESDACORDE= esd->GetACORDEData();\r
272        \r
273   for(int i=0;i<60;i++)\r
274   {\r
275         if(fESDACORDE->GetHitChannel(i)) \r
276         {\r
277                 GetESDsData(0)->Fill(i);\r
278                 GetESDsData(1)->Fill(i);\r
279         }\r
280   }\r
281 \r
282 }\r