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