]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEQADataMakerRec.cxx
Updated syst unc on the efficiency in vs. out
[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: Sept. 29th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) \r
29 //      --> ACOMultiSL0_DQM_Shifter filling histogram fixed\r
30 //      --> Expert histogram updated: 2 histograms (Checks the hits for SL0 and AMU mode)\r
31 //      --> To be include in the next update: threshold settings from AliACORDEQAThreshold class (not yet)\r
32 // Last update: May 5th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) -->Creates QA expert histograms \r
33 // and QA-shifter histograms also with threshold lines and visual alarm\r
34 // Last Update: Aug. 27th 2008 --> Implementation to declare QA expert histogram\r
35 // Last update: Nov. 14t 2009 --> MRC <mrodrigu@mail.cern.ch> (FCFM-BUAP) \r
36 //                      |--> Change in Multiplicity histogram for AMORE (to detect empty triggers events of ACORDE)\r
37 \r
38 \r
39 \r
40 // --- ROOT system ---\r
41 #include <TClonesArray.h>\r
42 #include <TFile.h> \r
43 #include <TH1F.h> \r
44 #include <TDirectory.h>\r
45 #include <TPaveText.h>\r
46 // --- Standard library ---\r
47 \r
48 // --- AliRoot header files ---\r
49 #include "AliESDEvent.h"\r
50 #include "AliLog.h"\r
51 #include "AliACORDEdigit.h" \r
52 #include "AliACORDEhit.h"\r
53 #include "AliACORDEQADataMakerRec.h"\r
54 #include "AliQAChecker.h"\r
55 #include "AliACORDERawReader.h"\r
56 #include "AliACORDERawStream.h"\r
57 ClassImp(AliACORDEQADataMakerRec)\r
58            \r
59 //____________________________________________________________________________ \r
60  AliACORDEQADataMakerRec::AliACORDEQADataMakerRec():AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")\r
61 {\r
62 \r
63 }\r
64 //____________________________________________________________________________ \r
65 AliACORDEQADataMakerRec::AliACORDEQADataMakerRec(const AliACORDEQADataMakerRec& qadm):\r
66   AliQADataMakerRec()\r
67 {\r
68   SetName((const char*)qadm.GetName()) ; \r
69   SetTitle((const char*)qadm.GetTitle()); \r
70 }\r
71 \r
72 //__________________________________________________________________\r
73 AliACORDEQADataMakerRec::~AliACORDEQADataMakerRec()\r
74 {\r
75 }\r
76 \r
77 //__________________________________________________________________\r
78 AliACORDEQADataMakerRec& AliACORDEQADataMakerRec::operator = (const AliACORDEQADataMakerRec& qadm )\r
79 {\r
80   // Equal operator.\r
81   this->~AliACORDEQADataMakerRec();\r
82   new(this) AliACORDEQADataMakerRec(qadm);\r
83   return *this;\r
84 }\r
85 //____________________________________________________________________________\r
86 void AliACORDEQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)\r
87 {\r
88   //Detector specific actions at end of cycle\r
89   // do the QA checking\r
90   ResetEventTrigClasses(); // reset triggers list to select all histos\r
91   // Update for DQM GUI\r
92   //\r
93 \r
94   for (Int_t specie = 0; specie < AliRecoParam::kNSpecies ; specie++) {\r
95     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ;\r
96     // \r
97     // RS Set event specie\r
98     SetEventSpecie(AliRecoParam::ConvertIndex(specie));\r
99     //\r
100     for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS Loop over the trigger classes\r
101       //\r
102         TObjArray * parr = GetRawsDataOfTrigClass(itc);\r
103         if (!parr) continue;\r
104         TObjArray &harr = *parr;\r
105         TH1* h0 = (TH1*)harr[0];\r
106         TH1* h2 = (TH1*)harr[2];\r
107         if (!h0 || !h2) continue;\r
108 \r
109         Double_t integralSL0 = 0;\r
110         Double_t integralAMU = 0;\r
111 \r
112         if ((itc==-1) && ( (integralAMU=h2->Integral()==0) || (integralSL0=h0->Integral()==0) ) ) continue;\r
113 \r
114         Float_t maxSL0 = 1*h0->GetMaximum();\r
115         Float_t scaleSL0 = 0.;\r
116         if (maxSL0!=0) scaleSL0 = 1/maxSL0;\r
117         else scaleSL0 = 1.;\r
118         h0->Scale(scaleSL0);\r
119 \r
120 \r
121         Float_t maxAMU = 1*h2->GetMaximum();\r
122         Float_t scaleAMU = 0.;\r
123         if (maxAMU!=0) scaleAMU = 1/maxAMU;\r
124         else scaleAMU = 1.;\r
125         h2->Scale(scaleAMU);\r
126       \r
127         Int_t indexActiveModuleSL0 = 0;\r
128         Int_t indexActiveModuleAMU = 0;\r
129 \r
130         for(Int_t iModule = 0; iModule < 60; iModule++){\r
131                 if (h0->GetBinContent(iModule) > 0) indexActiveModuleSL0++;\r
132                 if (h2->GetBinContent(iModule) > 0) indexActiveModuleAMU++;\r
133         }\r
134         \r
135         Float_t meanHitsSL0 = 0.;\r
136         Float_t meanHitsAMU = 0.;\r
137         //if ((indexActiveModuleSL0==0) || (indexActiveModuleAMU == 0)) continue;\r
138         if (indexActiveModuleAMU == 0) continue;\r
139 \r
140         meanHitsSL0 = h0->Integral()/indexActiveModuleSL0;\r
141         meanHitsAMU = h2->Integral()/indexActiveModuleAMU;\r
142 \r
143         TH1* h6 = (TH1*)harr[6];\r
144         //TH1* h7 = (TH1*)harr[7];\r
145 \r
146         //Int_t goodModulesSL0 = 0;\r
147         //Int_t badModulesSL0 = 0;\r
148         Int_t goodModulesAMU = 0;\r
149         Int_t badModulesAMU = 0;\r
150 \r
151         for (Int_t imod = 0; imod < 60; imod++)\r
152         {\r
153                 //if (TMath::Abs(h0->GetBinContent(imod)/meanHitsSL0-1) < 0.65) goodModulesSL0++;\r
154                 //else badModulesSL0++;\r
155                 if (meanHitsAMU!=0)\r
156                 {\r
157                         if (TMath::Abs(h2->GetBinContent(imod)/meanHitsAMU-1) <= 0.90) goodModulesAMU++;\r
158                         else badModulesAMU++;\r
159                 }\r
160 \r
161         }\r
162         h6->Fill(1,goodModulesAMU);\r
163         h6->Fill(2,badModulesAMU);\r
164 \r
165         Float_t maxMod = 1*h6->GetMaximum();\r
166         Float_t scaleMaxMod = 0;\r
167         if (maxMod!=0) scaleMaxMod = 1./maxMod;\r
168         else scaleMaxMod = 0;\r
169         h6->Scale(scaleMaxMod);\r
170 \r
171         TH1* h4 = (TH1*)harr[4];\r
172         TH1* h5 = (TH1*)harr[5];\r
173 \r
174         if (h4 && h5 && meanHitsAMU!=0 && meanHitsSL0!=0){\r
175                 for (Int_t iModule = 0; iModule < 60; iModule++){\r
176                         h4->Fill(h0->GetBinContent(iModule)/meanHitsSL0-1);\r
177                         h5->Fill(h2->GetBinContent(iModule)/meanHitsAMU-1);\r
178                 }\r
179         }\r
180 \r
181     } // end of trigger classes loop\r
182   } // end specie loop\r
183   // QA Checker standar (to be updated)\r
184   //\r
185   AliQAChecker::Instance()->Run(AliQAv1::kACORDE, task, list) ;\r
186 }\r
187 \r
188 //____________________________________________________________________________\r
189 void AliACORDEQADataMakerRec::StartOfDetectorCycle()\r
190 {\r
191   //Detector specific actions at start of cycle\r
192 \r
193 }\r
194  \r
195 //____________________________________________________________________________ \r
196 void AliACORDEQADataMakerRec::InitRaws()\r
197 {\r
198   // create Raw histograms in Raw subdir\r
199 \r
200         const Bool_t expert   = kTRUE ; \r
201         const Bool_t saveCorr = kTRUE ; \r
202         const Bool_t image    = kTRUE ; \r
203         TH1F * fhACORDEBitPatternDQM = new TH1F("ACOHitsSL0_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode\r
204         TH1F * fhACORDEMultiplicitySL0DQM = new TH1F("ACOMultiSL0_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode\r
205         TH1F * fhACORDEBitPatternAMUDQM = new TH1F("ACOHitsAMU_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode\r
206         TH1F * fhACORDEMultiplicityAMUDQM = new TH1F("ACOMultiAMU_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode\r
207         TH1F * fhACORDEBitPatternCheckDQMSL0 = new TH1F("ACOHitsTriggerCheck_DQMExpertSL0","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)\r
208         TH1F * fhACORDEBitPatternCheckDQMAMU = new TH1F("ACOHitsTriggerCheck_DQMExpertAMU","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)\r
209 \r
210   //const char *acoStatus[4]={"O.K.","High","Low","Not O.K."};\r
211   const char *acoStatus[2]={"STABLE RATE","FLUCTUATING RATE"};\r
212 \r
213 \r
214 \r
215         TH1F * fhACORDEStatusAMU_DQM = new TH1F("fhACORDEStatusAMU_DQM","Status of rate for ACORDE's modules (AMU mode)",2,1,3);\r
216         for (Int_t i=0;i<2;i++) \r
217         {\r
218                 fhACORDEStatusAMU_DQM->GetXaxis()->SetBinLabel(i+1,acoStatus[i]); \r
219         }\r
220         fhACORDEStatusAMU_DQM->SetYTitle("No. of modules (Norm.)");\r
221 \r
222         Add2RawsList(fhACORDEStatusAMU_DQM,6,!expert,image,!saveCorr);\r
223 \r
224         fhACORDEStatusAMU_DQM->SetFillColor(kAzure-7);\r
225 \r
226 \r
227          // Expert histograms\r
228          // Check the hits multiplicity from trigger configuration\r
229          Add2RawsList(fhACORDEBitPatternCheckDQMSL0,4,expert,image,!saveCorr);\r
230          fhACORDEBitPatternCheckDQMSL0->SetFillColor(kOrange);\r
231          Add2RawsList(fhACORDEBitPatternCheckDQMAMU,5,expert,image,!saveCorr);\r
232          fhACORDEBitPatternCheckDQMAMU->SetFillColor(kRed+2);\r
233 \r
234         \r
235         // AMORE diplay settings for shifter on GUI\r
236  \r
237         // For SL0 ACO trigger mode\r
238  \r
239          Add2RawsList(fhACORDEBitPatternDQM,0,expert,image,!saveCorr);\r
240          ForbidCloning(fhACORDEBitPatternDQM);\r
241          Add2RawsList(fhACORDEMultiplicitySL0DQM,1,expert,image,!saveCorr);\r
242          ForbidCloning(fhACORDEMultiplicitySL0DQM);\r
243 \r
244          // For Hits distribution on ACORDE\r
245  \r
246          fhACORDEBitPatternDQM->SetFillColor(kMagenta+2);\r
247  \r
248          // For ACORDE Multiplicity distribution of fired modules\r
249  \r
250          fhACORDEMultiplicitySL0DQM->SetFillColor(kMagenta);\r
251  \r
252          // For AMU ACO trigger mode\r
253  \r
254          Add2RawsList(fhACORDEBitPatternAMUDQM,2,expert,image,!saveCorr);\r
255          Add2RawsList(fhACORDEMultiplicityAMUDQM,3,expert,image,!saveCorr);\r
256  \r
257          // For Hits distribution on ACORDE\r
258  \r
259          fhACORDEBitPatternAMUDQM->SetFillColor(kViolet+7);\r
260  \r
261          // For ACORDE Multiplicity distribution of fired modules\r
262  \r
263          fhACORDEMultiplicityAMUDQM->SetFillColor(kViolet+6);\r
264  \r
265   //\r
266   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line\r
267 }\r
268 \r
269 //____________________________________________________________________________ \r
270 void AliACORDEQADataMakerRec::InitDigits()\r
271 {\r
272   // create Digits histograms in Digits subdir\r
273   \r
274   const Bool_t expert   = kTRUE ; \r
275   const Bool_t image    = kTRUE ; \r
276   TH1F *    fhDigitsModule;\r
277   const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
278                         "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
279                         "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
280                         "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
281                         "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
282                         "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
283 \r
284 \r
285   fhDigitsModule = new TH1F("ACORDEBitPatternfromDigits","Distribution of ACORDE from DIGITS;Modules;Counts",60,1,60);\r
286   Add2DigitsList(fhDigitsModule,0,!expert,image);\r
287   for (Int_t i=0;i<60;i++) fhDigitsModule->GetXaxis()->SetBinLabel(i+1,acoModule[i]); \r
288   //\r
289   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line\r
290 }\r
291 \r
292 //____________________________________________________________________________ \r
293 \r
294 void AliACORDEQADataMakerRec::InitRecPoints()\r
295 {\r
296   // create cluster histograms in RecPoint subdir\r
297   // Not needed for ACORDE by now !!!\r
298   //\r
299   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line\r
300 }\r
301 \r
302 //____________________________________________________________________________\r
303 void AliACORDEQADataMakerRec::InitESDs()\r
304 {\r
305   //create ESDs histograms in ESDs subdir\r
306 \r
307   const Bool_t expert   = kTRUE ; \r
308   const Bool_t image    = kTRUE ; \r
309   \r
310   TH1F *    fhESDsSingle;\r
311   TH1F *    fhESDsMulti;\r
312   TH1F *        fhESDsMultiplicity;\r
313   const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
314                         "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
315                         "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
316                         "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
317                         "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
318                         "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
319 \r
320 \r
321    fhESDsSingle = new TH1F("ACORDEBitPatternfromESDsSingle","Distribution of ACORDE fired modules from ESDs-Single;Modules;Counts",60,1,60);\r
322    Add2ESDsList(fhESDsSingle,0,!expert,image);\r
323 \r
324    fhESDsMulti = new TH1F("ACORDEBitPatternfromESDsMulti","Distribution of ACORDE fired modules from ESDs-Multi;Modules;Counts",60,1,60);\r
325    Add2ESDsList(fhESDsMulti,1,!expert,image);\r
326    \r
327    fhESDsMultiplicity = new TH1F("ACORDEMultiplicityfromESD","Number of fired ACORDE modules; No. of fired ACORDE modules;No. of events in ACORDE",60,-0.5,60);\r
328    Add2ESDsList(fhESDsMultiplicity,2,!expert,image);    \r
329    for (Int_t i=0;i<60;i++)\r
330    {\r
331         fhESDsSingle->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
332         fhESDsMulti->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
333    }\r
334    //\r
335    ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line\r
336 }\r
337 //____________________________________________________________________________\r
338 void AliACORDEQADataMakerRec::MakeRaws(AliRawReader* rawReader)\r
339 {\r
340   //fills QA histos for RAW\r
341   IncEvCountCycleRaws();\r
342   IncEvCountTotalRaws();\r
343   rawReader->Reset();\r
344   AliACORDERawStream rawStream(rawReader);\r
345   size_t contSingle=0;\r
346   size_t contMulti=0;\r
347   UInt_t dy[4];\r
348 \r
349   bool kroSingle[60],kroMulti[60];\r
350   UInt_t tmpDy;\r
351 \r
352   for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}\r
353 \r
354 if(rawStream.Next())\r
355 {\r
356         dy[0]=rawStream.GetWord(0);\r
357         dy[1]=rawStream.GetWord(1);\r
358         dy[2]=rawStream.GetWord(2);\r
359         dy[3]=rawStream.GetWord(3);\r
360         tmpDy=dy[0];\r
361         for(Int_t r=0;r<30;r++)\r
362         {\r
363                 kroSingle[r] = tmpDy & 1;\r
364                 tmpDy>>=1;\r
365         }\r
366         tmpDy=dy[1];\r
367         for(Int_t r=30;r<60;r++)\r
368         {\r
369                 kroSingle[r] = tmpDy & 1;\r
370                 tmpDy>>=1;\r
371         }\r
372         tmpDy=dy[2];\r
373         for(Int_t r=0;r<30;r++)\r
374         {\r
375                 kroMulti[r] = tmpDy & 1;\r
376                 tmpDy>>=1;\r
377         }\r
378         tmpDy=dy[3];\r
379         for(Int_t r=30;r<60;r++)\r
380         {\r
381                 kroMulti[r] = tmpDy & 1;\r
382                 tmpDy>>=1;\r
383         }\r
384         contSingle=0;\r
385         contMulti=0;\r
386         for(Int_t r=0;r<60;r++)\r
387         {\r
388                         if(kroSingle[r]==1)\r
389                         {\r
390                           FillRawsData(0,r);\r
391                           //FillRawsData(4,r);\r
392                           contSingle++;\r
393                         }\r
394                         if(kroMulti[r]==1)\r
395                         {\r
396                           FillRawsData(2,r);\r
397                           //FillRawsData(6,r);\r
398                           contMulti++;\r
399                         }\r
400                         \r
401         } \r
402         FillRawsData(1,contSingle); \r
403         FillRawsData(3,contMulti); \r
404         //      FillRawsData(7,contMulti);\r
405 }\r
406 }\r
407 //____________________________________________________________________________\r
408 void AliACORDEQADataMakerRec::MakeDigits( TTree *digitsTree)\r
409 {\r
410   //fills QA histos for Digits\r
411   IncEvCountCycleDigits();\r
412   IncEvCountTotalDigits();\r
413 \r
414   if (fDigitsArray) \r
415     fDigitsArray->Clear() ; \r
416   else \r
417     fDigitsArray = new TClonesArray("AliACORDEdigit",1000);\r
418   TBranch * branch = digitsTree->GetBranch("ACORDEdigit");\r
419   if (!branch) {\r
420     AliWarning("ACORDE branch in Digits Tree not found");\r
421   } else {\r
422     branch->SetAddress(&fDigitsArray);\r
423     for(Int_t track = 0 ; track < branch->GetEntries() ; track++) {\r
424       branch->GetEntry(track);\r
425       for(Int_t idigit = 0 ; idigit < fDigitsArray->GetEntriesFast() ; idigit++) {\r
426         AliACORDEdigit *AcoDigit = (AliACORDEdigit*) fDigitsArray->UncheckedAt(idigit);\r
427         if (!AcoDigit) {\r
428           AliError("The unchecked digit doesn't exist");\r
429           continue ;\r
430         }\r
431         FillDigitsData(0,AcoDigit->GetModule()-1);\r
432       }\r
433     }\r
434   }\r
435 }\r
436 \r
437 //____________________________________________________________________________\r
438 void AliACORDEQADataMakerRec::MakeESDs(AliESDEvent * esd)\r
439 {\r
440   //fills QA histos for ESD\r
441   IncEvCountCycleESDs();\r
442   IncEvCountTotalESDs();\r
443   //\r
444   AliESDACORDE * fESDACORDE= esd->GetACORDEData();\r
445   Int_t acoMulti=0;\r
446   for(int i=0;i<60;i++)\r
447   {\r
448     if(fESDACORDE->GetHitChannel(i)) \r
449           {\r
450           FillESDsData(0,i+1);\r
451           FillESDsData(1,i+1);\r
452           acoMulti++;\r
453         }\r
454   } FillESDsData(2,acoMulti);\r
455 \r
456 }\r