]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerQADataMakerRec.cxx
Bug fix for HMPID bits in readout list.
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerQADataMakerRec.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 // $Id: AliMUONTriggerQADataMakerRec.cxx 35760 2009-10-21 21:45:42Z ivana $
17
18 // --- MUON header files ---
19 #include "AliMUONTriggerQADataMakerRec.h"
20
21 //-----------------------------------------------------------------------------
22 /// \class AliMUONTriggerQADataMakerRec
23 ///
24 /// MUON class for quality assurance data (histo) maker
25 ///
26 /// \author C. Finck, D. Stocco, L. Aphecetche, A. Blanc
27
28 /// \cond CLASSIMP
29 ClassImp(AliMUONTriggerQADataMakerRec)
30 /// \endcond
31            
32 #include "AliCodeTimer.h"
33 #include "AliMUONConstants.h"
34 #include "AliMpConstants.h"
35 #include "AliMUONTriggerDisplay.h"
36 #include "TH2.h"
37 #include "TH1F.h"
38 #include "TString.h"
39 #include "AliRecoParam.h"
40 #include "AliMUONDigitStoreV2R.h"
41 #include "AliMUONTriggerStoreV1.h"
42 #include "AliMpCDB.h"
43 #include "AliMUONRawStreamTriggerHP.h"
44 #include "AliMpDDLStore.h"
45 #include "AliMpTriggerCrate.h"
46 #include "AliMpLocalBoard.h"
47 #include "AliQAv1.h"
48 #include "AliRawReader.h"
49 #include "AliMUONDigitMaker.h"
50 #include "AliMUONLocalTrigger.h"
51 #include "AliMUONRecoParam.h"
52 #include "AliMUONTriggerElectronics.h"
53 #include "AliMUONCalibrationData.h"
54 #include "AliDCSValue.h"
55 #include "AliMpDCSNamer.h"
56 #include "AliMpDEManager.h"
57 #include "AliMpDEIterator.h"
58 #include "AliCDBManager.h"
59 #include "TTree.h"
60 #include "AliMUONGlobalTriggerBoard.h"
61 #include "AliMUONGlobalTrigger.h"
62 #include "AliMUONGlobalCrateConfig.h"
63 #include "AliMUONQAIndices.h"
64
65 namespace
66 {
67   Double_t ProtectedSqrt(Double_t x)
68   {
69     return ( x > 0.0 ? TMath::Sqrt(x) : 0.0 );
70   }
71 }
72 //____________________________________________________________________________ 
73 AliMUONTriggerQADataMakerRec::AliMUONTriggerQADataMakerRec(AliQADataMakerRec* master) : 
74 AliMUONVQADataMakerRec(master),
75 fDigitMaker(new AliMUONDigitMaker(kFALSE)),
76 fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())),
77 fTriggerProcessor(new AliMUONTriggerElectronics(fCalibrationData)),
78 fDigitStore(0x0)
79 {
80     /// ctor
81 }
82
83
84 //__________________________________________________________________
85 AliMUONTriggerQADataMakerRec::~AliMUONTriggerQADataMakerRec()
86 {
87     /// dtor
88   delete fDigitMaker;
89   delete fDigitStore;
90   delete fTriggerProcessor;
91   delete fCalibrationData;
92 }
93
94 //____________________________________________________________________________ 
95 void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleESDs(Int_t /*specie*/, TObjArray** /*list*/)
96 {
97   /// Normalize ESD histograms
98 }
99   
100 //____________________________________________________________________________ 
101 void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t /*specie*/, TObjArray** /*list*/)
102 {
103   /// Normalize RecPoints histograms
104   
105 }
106
107
108 //____________________________________________________________________________ 
109 void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRaws(Int_t /*specie*/, TObjArray** /*list*/)
110 {
111   /// create Raws histograms in Raws subdir
112
113   DisplayTriggerInfo();
114
115   // Normalize RawData histos
116   Float_t nbevent = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->GetBinContent(1);
117   Int_t histoRawsIndex[] = {
118     AliMUONQAIndices::kTriggerErrorSummary,
119     AliMUONQAIndices::kTriggerCalibSummary,
120     AliMUONQAIndices::kTriggerReadOutErrors,
121     AliMUONQAIndices::kTriggerGlobalOutput
122   };
123   Int_t histoRawsScaledIndex[] = {
124     AliMUONQAIndices::kTriggerErrorSummaryNorm,
125     AliMUONQAIndices::kTriggerCalibSummaryNorm,
126     AliMUONQAIndices::kTriggerReadOutErrorsNorm,
127     AliMUONQAIndices::kTriggerGlobalOutputNorm
128   };
129   const Int_t kNrawsHistos = sizeof(histoRawsIndex)/sizeof(histoRawsIndex[0]);
130   Float_t scaleFactor[kNrawsHistos] = {100., 100., 100., 1.};
131   for(Int_t ihisto=0; ihisto<kNrawsHistos; ihisto++){
132     TH1* inputHisto = GetRawsData(histoRawsIndex[ihisto]);
133     TH1* scaledHisto = GetRawsData(histoRawsScaledIndex[ihisto]);
134     if ( scaledHisto && inputHisto &&  nbevent > 0 ) {
135       scaledHisto->Reset();
136       scaledHisto->Add(inputHisto);
137       scaledHisto->Scale(scaleFactor[ihisto]/nbevent);
138     }
139   } // loop on histos
140
141   TH1* hYCopy = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy); //number of YCopy error per board
142   TH1* hYCopyTests = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest); //contains the number of YCopy test per board
143   TH1* hYCopyNorm = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyNorm); 
144   hYCopyNorm->Reset();
145   hYCopyNorm->Divide(hYCopy, hYCopyTests, 100., 1.);
146      
147   Float_t mean = hYCopyNorm->Integral();
148       
149   TH1* hSummary = GetRawsData(AliMUONQAIndices::kTriggerErrorSummary);
150   hSummary->SetBinContent(AliMUONQAIndices::kAlgoLocalYCopy+1,mean/192.); //put the mean of the % of YCopy error in the kTriggerError's corresponding bin
151
152   TH1F* hTriggerRatio = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434);
153   if ( hTriggerRatio ){
154     hTriggerRatio->Divide(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec)),((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec)));
155
156     FillRatio4434Histos(1);
157
158     //reset bins temporary used to store informations
159     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(0,0); 
160     Int_t nbins =  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->GetNbinsX();
161     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(nbins+1,0);
162
163     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434))->SetMaximum(1.1);
164     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetMaximum(1.1);
165     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetMaximum(1.1);
166   }
167 }
168
169 //____________________________________________________________________________ 
170 void AliMUONTriggerQADataMakerRec::InitRaws()
171 {
172     /// create Raws histograms in Raws subdir
173         
174   AliCodeTimerAuto("",0);
175   
176   const Bool_t expert   = kTRUE ; 
177   const Bool_t saveCorr = kTRUE ; 
178   const Bool_t image    = kTRUE ; 
179  
180   TString boardName = "Local board Id";
181
182   Int_t nbLocalBoard = AliMUONConstants::NTriggerCircuit();
183
184   TH1F* histo1D = 0x0;
185   TH2F* histo2D = 0x0;
186
187   AliMUONTriggerDisplay triggerDisplay;
188
189   TString histoName, histoTitle;
190   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
191     histo1D = new TH1F("hTriggerScalersTime", "Acquisition time from trigger scalers", 1, 0.5, 1.5);
192     histo1D->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
193     histo1D->GetYaxis()->SetTitle("Cumulated scaler time (s)");
194     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerScalersTime, expert, !image, !saveCorr);
195
196     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
197       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
198       for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
199         histoName = Form("hTriggerScalers%sChamber%i", cathName.Data(), 11+iChamber);
200         histoTitle = Form("Chamber %i - %s: trigger scaler counts", 11+iChamber, cathName.Data());
201         histo2D = new TH2F(histoName.Data(), histoTitle.Data(),
202                            nbLocalBoard, 0.5, (Float_t)nbLocalBoard + 0.5,
203                            16, -0.5, 15.5);
204         histo2D->GetXaxis()->SetTitle(boardName.Data());
205         histo2D->GetYaxis()->SetTitle("Strip"); 
206         histo2D->SetOption("COLZ");     
207         Add2RawsList(histo2D, AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
208       } // loop on chambers
209     } // loop on cathodes
210         
211     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
212       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
213       for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
214         histoName = Form("hTriggerScalersDisplay%sChamber%i", cathName.Data(), 11+iChamber);
215         histoTitle = Form("Chamber %i - %s: Hit rate from scalers (Hz/cm^{2})", 11+iChamber, cathName.Data());
216         histo2D = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
217                                                              iCath, iChamber, histoTitle);
218         histo2D->SetOption("COLZ");
219         Add2RawsList(histo2D, AliMUONQAIndices::kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
220       } // loop on chambers
221     } // loop on cathodes    
222
223     TString axisLabel[AliMUONQAIndices::kNtrigCalibSummaryBins] = {"#splitline{Dead}{Channels}", "#splitline{Dead}{Local Boards}", "#splitline{Dead}{Regional Boards}", "#splitline{Dead}{Global Board}", "#splitline{Noisy}{Strips}"};
224
225     TH1F* histoCalib = new TH1F("hTriggerCalibSummaryAll", "MTR calibration summary counts", AliMUONQAIndices::kNtrigCalibSummaryBins, -0.5, (Float_t)AliMUONQAIndices::kNtrigCalibSummaryBins - 0.5);
226     for (Int_t ibin=1; ibin<=AliMUONQAIndices::kNtrigCalibSummaryBins; ibin++){
227       histoCalib->GetXaxis()->SetBinLabel(ibin, axisLabel[ibin-1].Data());
228     }
229     histoCalib->SetFillColor(kBlue);
230     histoCalib->GetYaxis()->SetTitle("Counts");
231     // Copy of previous histo for scaling purposes
232     TH1F* histoCalibNorm = (TH1F*)histoCalib->Clone("hTriggerCalibSummary");
233     histoCalibNorm->SetTitle("MTR calibration summary");
234     histoCalibNorm->SetOption("bar2");
235     histoCalibNorm->GetYaxis()->SetTitle("Percentage per event (%)");
236     // Adding both histos after cloning to avoid problems with the expert bit
237     Add2RawsList(histoCalib,     AliMUONQAIndices::kTriggerCalibSummary,      expert, !image, !saveCorr);
238     Add2RawsList(histoCalibNorm, AliMUONQAIndices::kTriggerCalibSummaryNorm, !expert,  image, !saveCorr);
239   } // Calibration reco param
240         
241   const char *globalXaxisName[6] = {"US HPt", "US LPt", "LS HPt", "LS LPt", "SGL HPt", "SGL LPt"};
242   const char *allLevelXaxisName[AliMUONQAIndices::kNtrigAlgoErrorBins] = {"Local algo X", "Local algo Y", "Local LUT","Local Y Copy" , "Local2Regional", "Regional", "Regional2Global", "GlobalFromInGlobal", "GlobalFromInLocal", "GlobalFromOutLocal"};
243   const char *readoutErrNames[AliMUONQAIndices::kNtrigStructErrorBins]={"Local","Regional","Global","DARC"};
244
245   TString errorAxisTitle = "Number of errors";
246
247   histo1D = new TH1F("hTriggerErrorLocalXPos", "ErrorLocalXPos",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
248   histo1D->GetXaxis()->SetTitle(boardName.Data());
249   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
250   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalXPos, expert, !image, !saveCorr);
251
252   histo1D = new TH1F("hTriggerErrorLocalYPos", "ErrorLocalYPos",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
253   histo1D->GetXaxis()->SetTitle(boardName.Data());
254   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
255   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalYPos, expert, !image, !saveCorr);
256
257   histo1D = new TH1F("hTriggerErrorLocalDev", "ErrorLocalDev",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
258   histo1D->GetXaxis()->SetTitle(boardName.Data());
259   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
260   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalDev, expert, !image, !saveCorr);
261
262   histo1D = new TH1F("hTriggerErrorLocalTriggerDec", "ErrorLocalTriggerDec",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
263   histo1D->GetXaxis()->SetTitle(boardName.Data());
264   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
265   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalTriggerDec, expert, !image, !saveCorr);
266
267   histo1D = new TH1F("hTriggerErrorLocalLPtLSB", "ErrorLocalLPtLSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
268   histo1D->GetXaxis()->SetTitle(boardName.Data());
269   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
270   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalLPtLSB, expert, !image, !saveCorr);
271
272   histo1D = new TH1F("hTriggerErrorLocalLPtMSB", "ErrorLocalLPtMSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
273   histo1D->GetXaxis()->SetTitle(boardName.Data());
274   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
275   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalLPtMSB, expert, !image, !saveCorr);
276
277   histo1D = new TH1F("hTriggerErrorLocalHPtLSB", "ErrorLocalHPtLSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
278   histo1D->GetXaxis()->SetTitle(boardName.Data());
279   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
280   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalHPtLSB, expert, !image, !saveCorr);
281
282   histo1D = new TH1F("hTriggerErrorLocalHPtMSB", "ErrorLocalHPtMSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
283   histo1D->GetXaxis()->SetTitle(boardName.Data());
284   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
285   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalHPtMSB, expert, !image, !saveCorr);
286
287   histo1D = new TH1F("hTriggerErrorLocalTrigY", "ErrorLocalTrigY",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
288   histo1D->GetXaxis()->SetTitle(boardName.Data());
289   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
290   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalTrigY, expert, !image, !saveCorr);
291
292   if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
293     histo1D = new TH1F("hTriggerRatio4434Local", "Ratio4434Local",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
294     histo1D->GetXaxis()->SetTitle(boardName.Data());
295     histo1D->GetYaxis()->SetTitle("ratio 44/34");
296     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerLocalRatio4434, expert, !image, !saveCorr);                                               
297     histo1D = new TH1F("hTriggerRatio4434AllEvents", "Ratio4434AllEvents",1,0,1);
298     histo1D->GetXaxis()->SetTitle("Event number");
299     histo1D->GetYaxis()->SetTitle("ratio 44/34");
300     histo1D->SetLineColor(4);                           
301     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434AllEvents, expert, !image, !saveCorr);                                               
302     histo1D = new TH1F("hTriggerRatio4434SinceLastUpdate", "Ratio4434SinceLastUpdate",1,0,1);
303     histo1D->GetXaxis()->SetTitle("Event number");
304     histo1D->GetYaxis()->SetTitle("ratio 44/34");                           
305     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate, expert, !image, !saveCorr);
306   }
307
308   histo1D = new TH1F("hTriggerErrorLocal2RegionalLPtLSB", "ErrorLocal2RegionalLPtLSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
309   histo1D->GetXaxis()->SetTitle(boardName.Data());
310   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
311   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocal2RegionalLPtLSB, expert, !image, !saveCorr);
312
313   histo1D = new TH1F("hTriggerErrorLocal2RegionalLPtMSB", "ErrorLocal2RegionalLPtMSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
314   histo1D->GetXaxis()->SetTitle(boardName.Data());
315   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
316   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocal2RegionalLPtMSB, expert, !image, !saveCorr);
317
318   histo1D = new TH1F("hTriggerErrorLocal2RegionalHPtLSB", "ErrorLocal2RegionalHPtLSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
319   histo1D->GetXaxis()->SetTitle(boardName.Data());
320   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
321   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocal2RegionalHPtLSB, expert, !image, !saveCorr);
322
323   histo1D = new TH1F("hTriggerErrorLocal2RegionalHPtMSB", "ErrorLocal2RegionalHPtMSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
324   histo1D->GetXaxis()->SetTitle(boardName.Data());
325   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
326   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocal2RegionalHPtMSB, expert, !image, !saveCorr);
327
328   histo1D = new TH1F("hTriggerErrorOutGlobalFromInGlobal", "ErrorOutGlobalFromInGlobal",6,-0.5,6-0.5);
329   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
330   for (int ibin=0;ibin<6;ibin++){
331     histo1D->GetXaxis()->SetBinLabel(ibin+1,globalXaxisName[ibin]);
332   }
333   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorOutGlobalFromInGlobal, expert, !image, !saveCorr);
334
335   histo1D = new TH1F("hTriggerErrorOutGlobalFromInLocal", "ErrorOutGlobalFromInLocal",6,-0.5,6-0.5);
336   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
337   for (int ibin=0;ibin<6;ibin++){
338     histo1D->GetXaxis()->SetBinLabel(ibin+1,globalXaxisName[ibin]);
339   }
340   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorOutGlobalFromInLocal, expert, !image, !saveCorr);
341
342   TH1F* histoAlgoErr = new TH1F("hTriggerAlgoNumOfErrors", "Trigger Algorithm total errors",AliMUONQAIndices::kNtrigAlgoErrorBins,-0.5,(Float_t)AliMUONQAIndices::kNtrigAlgoErrorBins-0.5);
343   histoAlgoErr->GetYaxis()->SetTitle("Number of events with errors");
344   for (int ibin=0;ibin<AliMUONQAIndices::kNtrigAlgoErrorBins;ibin++){
345     histoAlgoErr->GetXaxis()->SetBinLabel(ibin+1,allLevelXaxisName[ibin]);
346   }
347   histoAlgoErr->SetFillColor(kBlue);
348   // Copy of previous histo for scaling purposes
349   TH1F* histoAlgoErrNorm = (TH1F*)histoAlgoErr->Clone("hTriggerAlgoErrors");
350   histoAlgoErrNorm->SetOption("bar2");
351   histoAlgoErrNorm->SetTitle("Trigger algorithm errors");
352   histoAlgoErrNorm->GetYaxis()->SetTitle("% of events with errors");
353   // Adding both histos after cloning to avoid problems with the expert bit
354   Add2RawsList(histoAlgoErr,     AliMUONQAIndices::kTriggerErrorSummary,      expert, !image, !saveCorr);
355   Add2RawsList(histoAlgoErrNorm, AliMUONQAIndices::kTriggerErrorSummaryNorm, !expert,  image, !saveCorr);  
356
357   histo1D = new TH1F("hTriggerTriggeredBoards", "Triggered boards", nbLocalBoard, 0.5, (Float_t)nbLocalBoard + 0.5);
358   Add2RawsList(histo1D, AliMUONQAIndices::kTriggeredBoards, expert, !image, !saveCorr);
359
360   histo2D = (TH2F*)triggerDisplay.GetEmptyDisplayHisto("hTriggerFiredBoardsDisplay", AliMUONTriggerDisplay::kDisplayBoards,
361                                                        0, 0, "Local board triggers / event");
362   histo2D->SetOption("COLZ");
363   Add2RawsList(histo2D, AliMUONQAIndices::kTriggerBoardsDisplay, expert, !image, !saveCorr);
364
365   TH1F* histoYCopyErr = new TH1F("hTriggerErrorLocalYCopy", "Number of YCopy errors",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
366   histoYCopyErr->GetXaxis()->SetTitle(boardName.Data());
367   histoYCopyErr->GetYaxis()->SetTitle(errorAxisTitle.Data());
368   // Copy of previous histo for scaling purposes
369   TH1F* histoYCopyErrTest = (TH1F*)histoYCopyErr->Clone("hTriggerErrorLocalYCopyTest");
370   histoYCopyErrTest->SetTitle("Number of YCopy tested");
371   // Copy of previous histo for scaling purposes
372   TH1F* histoYCopyErrNorm = (TH1F*)histoYCopyErr->Clone("hTriggerErrorLocalYCopyNorm");
373   histoYCopyErrNorm->SetTitle("% of YCopy errors");
374   // Adding both histos after cloning to avoid problems with the expert bit
375   Add2RawsList(histoYCopyErr,     AliMUONQAIndices::kTriggerErrorLocalYCopy,     expert, !image, !saveCorr);
376   Add2RawsList(histoYCopyErrTest, AliMUONQAIndices::kTriggerErrorLocalYCopyTest, expert, !image, !saveCorr);
377   Add2RawsList(histoYCopyErrNorm, AliMUONQAIndices::kTriggerErrorLocalYCopyNorm, expert, !image, !saveCorr);
378
379   TH1F* histoROerr = new TH1F("hTriggerReadoutNumOfErrors","Trigger Read-Out total errors", AliMUONQAIndices::kNtrigStructErrorBins, -0.5, (Float_t)AliMUONQAIndices::kNtrigStructErrorBins-0.5);
380   histoROerr->GetYaxis()->SetTitle("Fraction of errors");
381   histoROerr->SetFillColor(kBlue);
382   for (int ibin=0;ibin<AliMUONQAIndices::kNtrigStructErrorBins;ibin++){
383     histoROerr->GetXaxis()->SetBinLabel(ibin+1,readoutErrNames[ibin]);
384   }
385   // Copy of previous histo for scaling purposes
386   TH1F* histoROerrNorm = (TH1F*)histoROerr->Clone("hTriggerReadoutErrors");
387   histoROerrNorm->SetTitle("Trigger Read-Out errors");
388   histoROerrNorm->SetOption("bar2");
389   histoROerrNorm->GetYaxis()->SetTitle("% of errors per event");
390   // Adding both histos after cloning to avoid problems with the expert bit
391   Add2RawsList(histoROerr,     AliMUONQAIndices::kTriggerReadOutErrors,      expert, !image, !saveCorr);
392   Add2RawsList(histoROerrNorm, AliMUONQAIndices::kTriggerReadOutErrorsNorm, !expert,  image, !saveCorr);
393
394   TH1F* histoGlobalMult = new TH1F("hTriggerGlobalOutMultiplicity","Trigger global outputs multiplicity", 6, -0.5, 6.-0.5);
395   histoGlobalMult->GetYaxis()->SetTitle("Number of triggers"); 
396   histoGlobalMult->GetXaxis()->SetTitle("Global output");
397   for (int ibin=0;ibin<6;ibin++){
398     histoGlobalMult->GetXaxis()->SetBinLabel(ibin+1,globalXaxisName[ibin]);
399   }        
400   histoGlobalMult->SetFillColor(kBlue);
401   // Copy of previous histo for scaling purposes
402   TH1F* histoGlobalMultNorm = (TH1F*)histoGlobalMult->Clone("hTriggerGlobalOutMultiplicityPerEvt");
403   histoGlobalMultNorm->SetTitle("Trigger global outputs multiplicity per event");
404   histoGlobalMultNorm->SetOption("bar2");
405   histoGlobalMultNorm->SetBarWidth(0.5);
406   histoGlobalMultNorm->SetBarOffset(0.25);
407   histoGlobalMultNorm->GetYaxis()->SetTitle("Triggers per event");
408   // Adding both histos after cloning to avoid problems with the expert bit
409   Add2RawsList(histoGlobalMult,     AliMUONQAIndices::kTriggerGlobalOutput,     expert, !image, !saveCorr);
410   Add2RawsList(histoGlobalMultNorm, AliMUONQAIndices::kTriggerGlobalOutputNorm, expert, !image, !saveCorr);
411
412   histo1D = new TH1F("hTriggerRawNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
413   Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
414   histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
415   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
416   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRawNAnalyzedEvents, expert, !image, !saveCorr);
417
418   if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
419     histo1D = new TH1F("hTriggerNumberOf34Dec", "Number of 3/4",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
420     histo1D->GetXaxis()->SetTitle(boardName.Data());
421     histo1D->GetYaxis()->SetTitle("Number of 3/4");
422     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerNumberOf34Dec, expert, !image, !saveCorr);
423
424     histo1D = new TH1F("hTriggerNumberOf44Dec", "Number of 4/4",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
425     histo1D->GetXaxis()->SetTitle(boardName.Data());
426     histo1D->GetYaxis()->SetTitle("Number of 4/4");
427     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerNumberOf44Dec, expert, !image, !saveCorr);
428   }
429 }
430
431 //__________________________________________________________________
432 void AliMUONTriggerQADataMakerRec::InitDigits() 
433 {
434   /// Initialized Digits spectra 
435   const Bool_t expert   = kTRUE ; 
436   const Bool_t image    = kTRUE ; 
437   
438   TH1I* h0 = new TH1I("hTriggerDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  400, 1100, 1500); 
439   Add2DigitsList(h0, 0, !expert, image);
440
441
442 //____________________________________________________________________________ 
443 void AliMUONTriggerQADataMakerRec::InitRecPoints()
444 {
445         /// create Reconstructed Points histograms in RecPoints subdir for the
446         /// MUON Trigger subsystem.
447
448   const Bool_t expert   = kTRUE ; 
449   const Bool_t image    = kTRUE ; 
450
451   TH1F* histo1D = 0x0;
452
453   histo1D = new TH1F("hTriggerNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
454   Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
455   histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
456   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
457   Add2RecPointsList(histo1D, AliMUONQAIndices::kTriggerNAnalyzedEvents, expert, !image);
458
459   histo1D = new TH1F("hTriggerTrippedChambers", "Trigger RPCs in trip", 418, 1100-0.5, 1417+0.5);
460   histo1D->GetXaxis()->SetTitle("DetElemId");
461   histo1D->GetYaxis()->SetTitle("# of trips");
462   histo1D->SetFillColor(kRed);
463   histo1D->SetLineColor(kRed);
464   Add2RecPointsList(histo1D, AliMUONQAIndices::kTriggerRPCtrips, !expert, image);
465
466   FillTriggerDCSHistos();       
467 }
468
469
470 //____________________________________________________________________________ 
471 void AliMUONTriggerQADataMakerRec::InitESDs()
472 {
473   /// Empty implementation
474 }
475
476 //____________________________________________________________________________
477 void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
478 {
479         /// make QA for rawdata trigger
480
481     AliCodeTimerAuto("",0);
482         
483     // Init Local/Regional/Global decision with fake values
484
485     UInt_t globalInput[4];
486     for (Int_t bit=0; bit<4; bit++){
487         globalInput[bit]=0;
488     }
489
490     //for (Int_t reg=0;reg<16;reg++){
491     //fTriggerOutputRegionalData[reg]=0;
492     //for (Int_t bit=0;bit<4;bit++){
493     //fTriggerInputGlobalDataLPt[reg][bit]=0;
494     //fTriggerInputGlobalDataHPt[reg][bit]=0;
495     //}
496     //}
497
498     AliMUONDigitStoreV2R digitStore;
499
500     AliMUONDigitStoreV2R digitStoreAll;
501     TArrayS xyPatternAll[2];
502     for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
503       xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
504       xyPatternAll[icath].Reset(1);
505     }
506     
507     AliMUONTriggerStoreV1 recoTriggerStore;
508
509     AliMUONTriggerStoreV1 inputTriggerStore;
510
511     AliMUONGlobalTrigger inputGlobalTrigger;
512
513     UShort_t maxNcounts = 0xFFFF;
514     
515     // Get trigger Local, Regional, Global in/outputs and scalers
516
517     Int_t loCircuit=0;
518     AliMpCDB::LoadDDLStore();
519
520     const AliMUONRawStreamTriggerHP::AliHeader*          darcHeader  = 0x0;
521     const AliMUONRawStreamTriggerHP::AliRegionalHeader*  regHeader   = 0x0;
522     const AliMUONRawStreamTriggerHP::AliLocalStruct*     localStruct = 0x0;
523
524     Int_t nDeadLocal = 0, nDeadRegional = 0, nDeadGlobal = 0, nNoisyStrips = 0;
525
526     // When a crate is not present, the loop on boards is not performed
527     // This should allow to correctly count the local boards
528     Int_t countNotifiedBoards = 0, countAllBoards = 0;
529
530     Bool_t containTriggerData = kFALSE;
531     AliMUONRawStreamTriggerHP rawStreamTrig(rawReader);
532     while (rawStreamTrig.NextDDL()) 
533     {
534       containTriggerData = kTRUE;
535
536       Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
537
538       Bool_t fillScalerHistos = ( scalerEvent && 
539                                   ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) );
540
541       if ( scalerEvent != fillScalerHistos ) {
542         Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
543         AliWarning(Form("Scaler event found but event specie is %s. Scaler histos will not be filled", AliRecoParam::GetEventSpecieName(esindex)));
544       }
545
546       darcHeader = rawStreamTrig.GetHeaders();
547
548       if (darcHeader->GetGlobalFlag()){
549         if ( fillScalerHistos ) {
550           UInt_t nOfClocks = darcHeader->GetGlobalClock();
551           Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
552           ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime))->Fill(1., nOfSeconds);
553         }
554
555         //Get Global datas
556         inputGlobalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
557         Bool_t resp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
558                           inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
559                           inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()}; 
560         for (Int_t bit=0; bit<6; bit++){
561           if ( ! resp[bit] ){
562             if ( fillScalerHistos )
563               nDeadGlobal++;
564           }
565           else
566             ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerGlobalOutput))->Fill(bit);
567         }
568
569         //for (Int_t Bit=0; Bit<32; Bit++){
570         //fTriggerInputGlobalDataLPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(0)>>Bit)&1);
571         //fTriggerInputGlobalDataLPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(1)>>Bit)&1);
572         //fTriggerInputGlobalDataHPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(2)>>Bit)&1);
573         //fTriggerInputGlobalDataHPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(3)>>Bit)&1);
574         //}
575
576         for (Int_t i=0; i<4; i++){
577           globalInput[i]=darcHeader->GetGlobalInput(i);
578         }
579       }
580
581       Int_t nReg = rawStreamTrig.GetRegionalHeaderCount();
582
583       for(Int_t iReg = 0; iReg < nReg ;iReg++)
584       {   //reg loop
585
586         //Int_t regId=rawStreamTrig.GetDDL()*8+iReg;
587
588         // crate info  
589           AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->GetTriggerCrate(rawStreamTrig.GetDDL(), iReg);
590
591           regHeader =  rawStreamTrig.GetRegionalHeader(iReg);
592
593           //Get regional outputs -> not checked, hardware read-out doesn't work
594           //fTriggerOutputRegionalData[regId]=Int_t(regHeader->GetOutput());
595           // if ( ! fTriggerOutputRegionalData[regId] )
596           // nDeadRegional++;
597         Int_t nBoardsInReg = 0; // Not necessary when regional output will work
598
599         // loop over local structures
600         Int_t nLocal = regHeader->GetLocalStructCount();
601
602         for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
603         {
604             
605             localStruct = regHeader->GetLocalStruct(iLocal);
606
607           // if card exist
608           if (!localStruct) continue;
609           
610           loCircuit = crate->GetLocalBoardId(localStruct->GetId());
611
612           if ( !loCircuit ) continue; // empty slot
613
614           AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
615
616           nBoardsInReg++; // Not necessary when regional output will work
617           countAllBoards++;
618
619           // skip copy cards
620           if( !localBoard->IsNotified()) 
621             continue;
622
623           AliMUONLocalTrigger inputLocalTrigger;
624           inputLocalTrigger.SetLocalStruct(loCircuit, *localStruct);
625           inputTriggerStore.Add(inputLocalTrigger);
626
627           countNotifiedBoards++;  
628
629           TArrayS xyPattern[2];   
630           localStruct->GetXPattern(xyPattern[0]);
631           localStruct->GetYPattern(xyPattern[1]);
632           fDigitMaker->TriggerDigits(loCircuit, xyPattern, digitStore);
633           if ( fillScalerHistos ) // Compute total number of strips
634             fDigitMaker->TriggerDigits(loCircuit, xyPatternAll, digitStoreAll);
635
636           //Get electronic Decisions from data
637
638           //Get regional inputs -> not checked, hardware read-out doesn't work
639           //fTriggerInputRegionalDataLPt[0][loCircuit]=Int_t(((regHeader->GetInput(0))>>(2*iLocal))&1);
640           //fTriggerInputRegionalDataLPt[1][loCircuit]=Int_t(((regHeader->GetInput(1))>>((2*iLocal)+1))&1);
641
642           //Get local in/outputs
643           if (Int_t(localStruct->GetDec())!=0){
644               ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggeredBoards))->Fill(loCircuit);
645           }
646           else if ( fillScalerHistos ){
647             nDeadLocal++;
648           }
649
650           // loop over strips
651           if ( fillScalerHistos ) {
652             Int_t cathode = localStruct->GetComptXY()%2;
653             for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
654               if (ibitxy==0){
655                 AliDebug(AliQAv1::GetQADebugLevel(),"Filling trigger scalers");
656               }
657
658               UShort_t scalerVal[4] = {
659                 localStruct->GetXY1(ibitxy),
660                 localStruct->GetXY2(ibitxy),
661                 localStruct->GetXY3(ibitxy),
662                 localStruct->GetXY4(ibitxy)
663               };
664
665               for(Int_t ich=0; ich<AliMpConstants::NofTriggerChambers(); ich++){
666                 if ( scalerVal[ich] > 0 )
667                   ((TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + ich))
668                     ->Fill(loCircuit, ibitxy, 2*(Float_t)scalerVal[ich]);
669
670                 if ( scalerVal[ich] >= maxNcounts )
671                   nNoisyStrips++;
672               } // loop on chamber
673             } // loop on strips
674           } // scaler event
675         } // iLocal
676         if ( nBoardsInReg == 0 )
677           nDeadRegional++; // Not necessary when regional output will work
678       } // iReg
679
680       Float_t readoutErrors[AliMUONQAIndices::kNtrigStructErrorBins] = {
681         ((Float_t)rawStreamTrig.GetLocalEoWErrors())/((Float_t)countAllBoards),
682         ((Float_t)rawStreamTrig.GetRegEoWErrors())/16.,
683         ((Float_t)rawStreamTrig.GetGlobalEoWErrors())/6.,
684         ((Float_t)rawStreamTrig.GetDarcEoWErrors())/2.
685       };
686     
687       for (Int_t ibin=0; ibin<AliMUONQAIndices::kNtrigStructErrorBins; ibin++){
688         if ( readoutErrors[ibin] > 0 )
689           ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerReadOutErrors))->Fill(ibin, readoutErrors[ibin]);
690       }
691     } // NextDDL
692
693     if ( ! containTriggerData ) return;
694
695     GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->Fill(1.);
696
697     nDeadLocal += AliMUONConstants::NTriggerCircuit() - countNotifiedBoards;
698     Int_t nStripsTot = digitStoreAll.GetSize();
699     if ( nStripsTot > 0 ) { // The value is != 0 only for scaler events
700       Float_t fraction[AliMUONQAIndices::kNtrigCalibSummaryBins] = {
701         ((Float_t)(nStripsTot - digitStore.GetSize())) / ((Float_t)nStripsTot),
702         //(Float_t)nDeadLocal / ((Float_t)countNotifiedBoards),
703         (Float_t)nDeadLocal / ((Float_t)AliMUONConstants::NTriggerCircuit()),
704         (Float_t)nDeadRegional / 16.,
705         (Float_t)nDeadGlobal / 6., // Number of bits of global response
706         (Float_t)nNoisyStrips / ((Float_t)nStripsTot),
707       };
708
709       for(Int_t ibin = 0; ibin < AliMUONQAIndices::kNtrigCalibSummaryBins; ibin++){
710         if ( fraction[ibin] > 0. )
711           ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerCalibSummary))->Fill(ibin, fraction[ibin]);
712       }
713     }
714
715   fTriggerProcessor->Digits2Trigger(digitStore,recoTriggerStore);
716
717   AliMUONGlobalTrigger* recoGlobalTriggerFromLocal;
718   recoGlobalTriggerFromLocal = recoTriggerStore.Global();
719
720   //Reconstruct Global decision from Global inputs
721   UChar_t recoResp = RawTriggerInGlobal2OutGlobal(globalInput);
722   AliMUONGlobalTrigger recoGlobalTriggerFromGlobal;
723   recoGlobalTriggerFromGlobal.SetFromGlobalResponse(recoResp);
724
725   // Compare data and reconstructed decisions and fill histos
726   RawTriggerMatchOutLocal(inputTriggerStore, recoTriggerStore);
727   //Fill ratio 44/34 histos
728   FillRatio4434Histos(fgkUpdateRatio4434);
729   //RawTriggerMatchOutLocalInRegional(); // Not tested, hardware read-out doesn't work
730   RawTriggerMatchOutGlobal(inputGlobalTrigger, recoGlobalTriggerFromGlobal, 'G');
731   // Global, reconstruction from Local inputs: compare data and reconstructed decisions and fill histos
732   RawTriggerMatchOutGlobal(inputGlobalTrigger, *recoGlobalTriggerFromLocal, 'L');
733   // Global, reconstruction from Global inputs: compare data and reconstructed decisions and fill histos
734 }
735
736 //__________________________________________________________________
737 void AliMUONTriggerQADataMakerRec::MakeDigits(TTree* digitsTree)         
738 {
739   /// makes data from Digits
740
741   // Do nothing in case of calibration event
742   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
743
744   if (!fDigitStore)
745     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
746
747   fDigitStore->Clear();
748   fDigitStore->Connect(*digitsTree, false);
749   digitsTree->GetEvent(0);
750   
751   TIter next(fDigitStore->CreateIterator());
752   
753   AliMUONVDigit* dig = 0x0;
754   
755   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
756     {
757     GetDigitsData(0)->Fill(dig->DetElemId());
758     }
759 }
760
761 //____________________________________________________________________________
762 void AliMUONTriggerQADataMakerRec::MakeRecPoints(TTree* /*clustersTree*/)
763 {
764   /// Fill histogram with total number of analyzed events for normalization purposes
765
766   // Do nothing in case of calibration event
767   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
768         
769   GetRecPointsData(AliMUONQAIndices::kTriggerNAnalyzedEvents)->Fill(1.);
770 }
771
772 //____________________________________________________________________________
773 void AliMUONTriggerQADataMakerRec::MakeESDs(AliESDEvent* /*esd*/)
774 {  
775   /// Empty implementation
776 }
777
778
779 //____________________________________________________________________________ 
780 void AliMUONTriggerQADataMakerRec::DisplayTriggerInfo()
781 {
782   //
783   /// Display trigger information in a user-friendly way:
784   /// from local board and strip numbers to their position on chambers
785   //
786
787   AliMUONTriggerDisplay triggerDisplay;
788   
789   TH2F* histoStrips=0x0;
790   TH2F* histoDisplayStrips=0x0;
791   if ( GetRawsData(AliMUONQAIndices::kTriggerScalers) ) {
792     AliMUONTriggerDisplay::EDisplayOption displayOption = AliMUONTriggerDisplay::kNormalizeToArea;
793     for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
794       {    
795         for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
796           {
797             histoStrips = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
798
799             if(histoStrips->GetEntries()==0) continue; // No events found => No need to display
800
801             histoDisplayStrips = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
802
803             triggerDisplay.FillDisplayHistogram(histoStrips, histoDisplayStrips,
804                                                 AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber, displayOption);
805
806             Float_t scaleValue = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime))->GetBinContent(1);
807             if(scaleValue>0.) histoDisplayStrips->Scale(1./scaleValue);
808           } // iChamber
809       } // iCath
810   }
811
812   if ( GetRawsData(AliMUONQAIndices::kTriggeredBoards) ){
813     TH1F* histoBoards = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggeredBoards);
814     TH2F* histoDisplayBoards = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerBoardsDisplay);
815     triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
816     Float_t scaleValue = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->GetBinContent(1);
817     if(scaleValue>0.) histoDisplayBoards->Scale(1./scaleValue);
818   }
819 }
820
821
822 //_____________________________________________________________________________
823 Bool_t 
824 AliMUONTriggerQADataMakerRec::FillTriggerDCSHistos()
825 {
826   /// Get HV and currents values for one trigger chamber
827   
828   AliCodeTimerAuto("",0);
829
830   TMap* triggerDcsMap = fCalibrationData->TriggerDCS();
831
832   if ( !triggerDcsMap ) 
833   {
834     AliError("Cannot fill DCS histos, as triggerDcsMap is NULL");
835     return kFALSE;
836   }
837
838   const Double_t kMaxDelay = 3.;
839   const Double_t kMaxVariation = 25.; // Volts
840   const Int_t kDefaultNpoints = 200;
841   Double_t scaleFactor = 1./1000.;
842
843   Bool_t error = kFALSE;
844   Bool_t expert   = kTRUE;
845   Bool_t image    = kTRUE;
846
847   AliMpDEIterator deIt;
848   
849   AliMpDCSNamer triggerDcsNamer("TRIGGER");
850
851   TH2F* currHisto = 0x0;
852   Int_t histoIndex = 0;
853   TString histoName, histoTitle;
854
855   TArrayD axisSlat(18+1);
856   for(Int_t islat=0; islat<=18; islat++){
857     axisSlat[islat] = -0.5 + (Float_t)islat;
858   }
859
860   TArrayD axisTimeAux[4], axisTime[4], axisTimeDE(kDefaultNpoints);
861   TArrayI index[4], npoints(4);
862
863   // Build axis of times
864   npoints.Reset();
865   for(Int_t ich=0; ich<4; ich++){
866     axisTimeAux[ich].Set(kDefaultNpoints);
867     axisTimeAux[ich].Reset(-1.);
868   }
869
870   deIt.First();
871   while ( !deIt.IsDone() )
872   {
873     Int_t detElemId = deIt.CurrentDEId();
874     TObjArray* values = GetDCSValues(AliMpDCSNamer::kDCSHV, detElemId, triggerDcsMap, triggerDcsNamer);
875
876     if ( values ) {
877
878       AliDebug(AliQAv1::GetQADebugLevel(), Form("DetElemId %i", detElemId));
879
880       axisTimeDE.Reset(-1.);
881
882       TIter next(values);
883       AliDCSValue* val = 0x0;
884       Double_t previousVal = -999.;
885       Int_t npointsde = 0;
886       while ( ( val = static_cast<AliDCSValue*>(next()) ) )
887       {
888         if ( npointsde + 1 > kDefaultNpoints ) {
889           axisTimeDE.Set(npointsde + 1);
890         }
891
892         Double_t currVal = val->GetFloat();
893         Double_t currTime = (Double_t)val->GetTimeStamp();
894         if (npointsde > 0 ){
895           if ( TMath::Abs( currVal - previousVal ) < kMaxVariation && 
896                TMath::Abs( currTime - axisTimeDE[npointsde-1] ) < 40 ) continue;
897         }
898
899         axisTimeDE[npointsde] = currTime;
900         previousVal = currVal;
901         npointsde++;
902       } // loop on values
903
904       //      AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding DE point %2i  (%2i)  %.2f  (%i)\n", previousBin, npointsde, axisTimeDE[previousBin], nTimesPerBin));
905
906       Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
907       Int_t ich = iChamber - AliMpConstants::NofTrackingChambers();
908
909       for(Int_t ipde=0; ipde<npointsde; ipde++){
910
911         if ( npoints[ich] + 1 > kDefaultNpoints ) {
912           axisTimeAux[ich].Set(npoints[ich] + 1);
913         }
914
915         for(Int_t ipoint = 0; ipoint < axisTimeAux[ich].GetSize(); ipoint++){
916           if (axisTimeAux[ich][ipoint] < 0.) {
917             axisTimeAux[ich][ipoint] = axisTimeDE[ipde];
918             npoints[ich]++;
919             AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding point %2i  %.0f\n", ipoint, axisTimeAux[ich][ipoint]));
920             break;
921           }
922           if ( TMath::Abs( axisTimeDE[ipde] - axisTimeAux[ich][ipoint]) < kMaxDelay ) {
923             axisTimeAux[ich][ipoint] = TMath::Min(axisTimeAux[ich][ipoint], axisTimeDE[ipde]);
924             break;
925           }
926         } // loop on points
927       } // loop on reorganized values
928
929     } // if ( values ) 
930     deIt.Next();
931   } // loop on DetElemId
932
933   for(Int_t ich=0; ich<4; ich++){
934     axisTimeAux[ich].Set(npoints[ich]);
935     index[ich].Set(npoints[ich]);
936     TMath::Sort(npoints[ich], axisTimeAux[ich].GetArray(), index[ich].GetArray(), kFALSE);
937
938     axisTime[ich].Set(npoints[ich]+1);
939     for(Int_t ipoint = 0; ipoint < axisTimeAux[ich].GetSize(); ipoint++){
940       axisTime[ich][ipoint] = axisTimeAux[ich][index[ich][ipoint]];
941     }
942     Double_t minStartEndWidth = 0.1 * (axisTime[ich][npoints[ich]-1] - axisTime[ich][0]);
943     axisTime[ich][npoints[ich]] = axisTime[ich][npoints[ich]-1] + minStartEndWidth;
944     if ( npoints[ich] >= 1)
945       if ( axisTime[ich][1] - axisTime[ich][0] < minStartEndWidth )
946         axisTime[ich][0] = axisTime[ich][1] - minStartEndWidth;
947   }
948
949
950   // Loop again on detection elements: create and fill histos
951   deIt.First();
952   while ( !deIt.IsDone() )
953   {
954     Int_t detElemId = deIt.CurrentDEId();
955     TObjArray* values = GetDCSValues(AliMpDCSNamer::kDCSHV, detElemId, triggerDcsMap, triggerDcsNamer);
956
957     if ( values ) {
958       Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
959       Int_t ich = iChamber - AliMpConstants::NofTrackingChambers();
960
961       histoIndex = AliMUONQAIndices::kTriggerRPChv + ich;
962       histoName = Form("hTriggerRPCHVChamber%i", 11+ich);
963       histoTitle = Form("Chamber %i: RPC HV (kV)", 11+ich);
964
965       currHisto = (TH2F*)GetRecPointsData(histoIndex);
966
967       if(!currHisto){
968         currHisto  = new TH2F(histoName.Data(), histoTitle.Data(),
969                               npoints[ich], axisTime[ich].GetArray(),
970                               18, axisSlat.GetArray());
971         currHisto->GetXaxis()->SetTitle("Time");
972         currHisto->GetXaxis()->SetTimeDisplay(1);
973         //currHisto->GetXaxis()->SetTimeFormat("%d%b%y %H:%M:%S");
974         currHisto->GetXaxis()->SetLabelSize(0.03);
975         currHisto->GetYaxis()->SetTitle("RPC");
976         currHisto->SetOption("TEXT45COLZ");
977         Add2RecPointsList(currHisto, histoIndex, expert, !image);
978       }
979
980       Int_t slat = detElemId%100;
981       Int_t slatBin = currHisto->GetYaxis()->FindBin(slat);
982
983       TIter next(values);
984       AliDCSValue* val = 0x0;
985       Double_t sumValuesPerBin = 0.;
986       Int_t nValuesPerBin = 0;
987       Int_t previousBin = -1;
988       Double_t previousTime = -1., previousVal = -999., sumVal = 0., sumTime = 0.;
989       Bool_t isTrip = kFALSE;
990       Int_t nPointsForSlope = 0;
991       while ( ( val = static_cast<AliDCSValue*>(next()) ) )
992       {
993         Double_t currTime = (Double_t)val->GetTimeStamp();
994         Int_t currentBin = currHisto->GetXaxis()->FindBin(currTime+0.5);
995         Double_t currVal = val->GetFloat();
996         Double_t deltaVal = currVal - previousVal;
997         Bool_t isRepeated = kFALSE;
998         if ( previousTime > 0 ){
999           isRepeated = ( TMath::Abs( currVal - previousVal ) < kMaxVariation && 
1000                          TMath::Abs( currTime - previousTime ) < 40 );
1001
1002           // Check for trips
1003           sumTime += currTime - previousTime;
1004           sumVal += deltaVal;
1005           nPointsForSlope++;
1006
1007           if ( sumTime > 0. && nPointsForSlope >= 3 ){
1008             Double_t slope = sumVal / sumTime;
1009             if ( slope < -10. ) // going down of more than 10V/s
1010               isTrip = kTRUE;
1011           }
1012
1013           if ( deltaVal * sumVal < 0. ) {
1014             sumTime = 0.;
1015             sumVal = 0.;
1016             nPointsForSlope = 0;
1017           }
1018         }
1019
1020         if ( ! isRepeated ) {
1021           if ( currentBin != previousBin ) {
1022             if ( previousBin >= 0 ) {
1023               currHisto->SetBinContent(previousBin, slatBin, scaleFactor*sumValuesPerBin/((Double_t)nValuesPerBin));
1024               sumValuesPerBin = 0.;
1025               nValuesPerBin = 0;
1026             }
1027             previousBin = currentBin;
1028           }
1029         }
1030           
1031         sumValuesPerBin += currVal;
1032         nValuesPerBin++;
1033         previousTime = currTime;
1034         previousVal = currVal;
1035       } // loop on values
1036       currHisto->SetBinContent(previousBin, slatBin, scaleFactor*sumValuesPerBin/((Double_t)nValuesPerBin)); // Fill last value
1037       if ( isTrip ) ((TH1F*)GetRecPointsData(AliMUONQAIndices::kTriggerRPCtrips))->Fill(detElemId);
1038     } // if ( values ) 
1039     deIt.Next();
1040   } // loop on detElem
1041   return error;
1042 }
1043
1044
1045 //____________________________________________________________________________ 
1046 TObjArray* 
1047 AliMUONTriggerQADataMakerRec::GetDCSValues(Int_t iMeas, Int_t detElemId,
1048                                            TMap* triggerDcsMap, AliMpDCSNamer& triggerDcsNamer)
1049 {
1050   //
1051   /// Get values of DCS data points from the map
1052   //
1053
1054   if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger) return 0x0;
1055
1056   TString currAlias = triggerDcsNamer.DCSChannelName(detElemId, 0, iMeas);
1057
1058   TPair* triggerDcsPair = static_cast<TPair*>(triggerDcsMap->FindObject(currAlias.Data()));
1059
1060   if (!triggerDcsPair)
1061   {
1062     AliError(Form("Did not find expected alias (%s) for DE %d\n",
1063                   currAlias.Data(),detElemId));
1064     return 0x0;
1065   }
1066
1067   TObjArray* values = static_cast<TObjArray*>(triggerDcsPair->Value());
1068   if (!values)
1069   {
1070     AliError(Form("Could not get values for alias %s\n",currAlias.Data()));
1071     return 0x0;
1072   }
1073
1074   return values;
1075 }
1076
1077
1078 //____________________________________________________________________________ 
1079 UChar_t AliMUONTriggerQADataMakerRec::RawTriggerInGlobal2OutGlobal(UInt_t globalInput[4])
1080 {
1081   //
1082   /// Reconstruct Global Trigger decision using Global Inputs
1083   //
1084
1085     AliCodeTimerAuto("",0);
1086
1087     AliMUONGlobalCrateConfig* globalConfig = fCalibrationData->GlobalTriggerCrateConfig();
1088
1089     AliMUONGlobalTriggerBoard globalTriggerBoard;
1090     globalTriggerBoard.Reset();
1091     for (Int_t i = 0; i < 4; i++) {
1092         globalTriggerBoard.Mask(i,globalConfig->GetGlobalMask(i));
1093     }
1094
1095     globalTriggerBoard.RecomputeRegional(globalInput);
1096     globalTriggerBoard.Response();
1097     return globalTriggerBoard.GetResponse();
1098
1099 }
1100
1101 //____________________________________________________________________________ 
1102 void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTriggerStore& inputTriggerStore,
1103                                                            const AliMUONVTriggerStore& recoTriggerStore)
1104 {
1105   //
1106   /// Match data and reconstructed Local Trigger decision
1107   //
1108
1109   AliCodeTimerAuto("",0);
1110
1111   Bool_t skipBoard[234];
1112   memset(skipBoard,0,AliMUONConstants::NTriggerCircuit()*sizeof(Bool_t));
1113
1114   Bool_t errorInYCopy = kFALSE;
1115
1116   // First search for YCopy errors.
1117   Int_t loCircuit = -1;
1118   TIter next(recoTriggerStore.CreateLocalIterator());
1119   AliMUONLocalTrigger* recoLocalTrigger, *inputLocalTrigger;
1120   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
1121   {  
1122     loCircuit = recoLocalTrigger->LoCircuit();
1123     Int_t iboard = loCircuit - 1;
1124
1125     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest))->Fill(loCircuit);
1126   
1127     inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
1128
1129     Int_t recoTrigPattern[4]  = {recoLocalTrigger->GetY1Pattern(), recoLocalTrigger->GetY2Pattern(), recoLocalTrigger->GetY3Pattern(), recoLocalTrigger->GetY4Pattern()};
1130     Int_t inputTrigPattern[4] = {inputLocalTrigger->GetY1Pattern(), inputLocalTrigger->GetY2Pattern(), inputLocalTrigger->GetY3Pattern(), inputLocalTrigger->GetY4Pattern()};
1131
1132     AliMpLocalBoard* localBoardMp = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit); // get local board object for switch value
1133
1134     Bool_t errorInCopyBoard = kFALSE;
1135     for(Int_t ich=0; ich<4; ich++){
1136       if ( recoTrigPattern[ich] != inputTrigPattern[ich] ){
1137         skipBoard[iboard] = kTRUE;
1138         if ( ich >=2 ){
1139           if ( localBoardMp->GetSwitch(AliMpLocalBoard::kOR0) )
1140             skipBoard[iboard+1] = kTRUE;
1141           if ( localBoardMp->GetSwitch(AliMpLocalBoard::kOR1) )
1142             skipBoard[iboard-1] = kTRUE;
1143         }
1144         errorInCopyBoard = kTRUE;
1145         errorInYCopy = kTRUE;
1146       }
1147     } // loop on chambers
1148     if ( errorInCopyBoard )
1149       ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy))->Fill(loCircuit);    
1150   } // loop on local boards
1151
1152   if (errorInYCopy)
1153     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalYCopy);
1154   
1155   Bool_t errorInXPosDev = kFALSE;
1156   Bool_t errorInYPosTrigY = kFALSE;
1157   Bool_t errorInLUT = kFALSE;
1158
1159   next.Reset();
1160   Bool_t respBendPlane, respNonBendPlane;
1161   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
1162   {  
1163     loCircuit = recoLocalTrigger->LoCircuit();
1164     Int_t iboard = loCircuit - 1;
1165   
1166     // Fill ratio 44/34 histos (if not scaler event)
1167     if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
1168       Bool_t is34 = ( recoLocalTrigger->GetLoDecision() != 0 );
1169       Bool_t is44 = fTriggerProcessor->ModifiedLocalResponse(loCircuit, respBendPlane, respNonBendPlane, kTRUE);
1170       if ( is34 ) ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec))->Fill(loCircuit);
1171       if ( is44 ) ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec))->Fill(loCircuit);
1172
1173       if ( is44 && ! is34 )
1174         AliWarning("Event satisfies the 4/4 conditions but not the 3/4");
1175     }
1176     
1177     inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
1178
1179     if ( recoLocalTrigger->LoStripX() != inputLocalTrigger->LoStripX() ) {
1180       ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalXPos))->Fill(loCircuit);
1181       errorInXPosDev = kTRUE;
1182     }
1183
1184     if ( recoLocalTrigger->GetDeviation() != inputLocalTrigger->GetDeviation() ) {
1185       ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalDev))->Fill(loCircuit);
1186       errorInXPosDev = kTRUE;
1187     }
1188
1189     // Skip following checks in case we previously found YCopy error and YPos or trigY errors
1190     if ( (!skipBoard[iboard]) || ( (recoLocalTrigger->LoStripY() == inputLocalTrigger->LoStripY()) && (recoLocalTrigger->LoTrigY() == inputLocalTrigger->LoTrigY())) ) {
1191         
1192         if ( recoLocalTrigger->GetLoDecision() != inputLocalTrigger->GetLoDecision() ) {
1193             ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalTriggerDec))->Fill(loCircuit);
1194         }
1195         
1196         // Test Hpt and LPT
1197         Int_t recoLut[2]  = { recoLocalTrigger->LoLpt(),  recoLocalTrigger->LoHpt() };
1198         Int_t inputLut[2] = {inputLocalTrigger->LoLpt(), inputLocalTrigger->LoHpt() };
1199         Int_t currIndex[2][2] = {{AliMUONQAIndices::kTriggerErrorLocalLPtLSB, AliMUONQAIndices::kTriggerErrorLocalLPtMSB},
1200                                  {AliMUONQAIndices::kTriggerErrorLocalHPtMSB, AliMUONQAIndices::kTriggerErrorLocalHPtMSB}};
1201         for (Int_t ilut=0; ilut<2; ilut++){
1202             Int_t bitDiff = recoLut[ilut]^inputLut[ilut];
1203             if ( bitDiff == 0 ) continue;
1204             for (Int_t ibit=0; ibit<2; ibit++){
1205                 Bool_t isBitDifferent = (bitDiff>>ibit)&1;
1206                 if ( isBitDifferent ){
1207                     ((TH1F*)GetRawsData(currIndex[ilut][ibit]))->Fill(loCircuit);
1208                     errorInLUT = kTRUE;
1209                 }
1210             }
1211         }
1212     }
1213     
1214  
1215     // Skip following checks in case we previously found YCopy errors
1216     if ( skipBoard[iboard] ) continue;
1217
1218     if ( recoLocalTrigger->LoStripY() != inputLocalTrigger->LoStripY() ) {
1219       ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYPos))->Fill(loCircuit);
1220       errorInYPosTrigY = kTRUE;
1221     }
1222
1223     if ( recoLocalTrigger->LoTrigY() != inputLocalTrigger->LoTrigY()  ) {
1224       ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalTrigY))->Fill(loCircuit); 
1225       errorInYPosTrigY = kTRUE;
1226     }
1227   } // loop on local boards
1228
1229   if (errorInXPosDev)
1230     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalX);
1231
1232   if (errorInLUT)
1233     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalLUT);
1234
1235   if (errorInYPosTrigY)
1236     ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalY);
1237
1238 }
1239 /*
1240 //____________________________________________________________________________ 
1241 void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocalInRegional()
1242 {
1243   //
1244   /// Match Local outputs and Regional inputs
1245   /// Not tested, hardware read-out doesn't work
1246   //
1247
1248     for (int localId=1;localId<235;localId++){
1249         if(fTriggerOutputLocalDataLPtDec[0][localId]!=fTriggerInputRegionalDataLPt[0][localId]){
1250             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalLPtLSB))->Fill(localId);
1251         }
1252         if(fTriggerOutputLocalDataLPtDec[1][localId]!=fTriggerInputRegionalDataLPt[1][localId]){
1253             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalLPtMSB))->Fill(localId);
1254         }
1255         if(fTriggerOutputLocalDataHPtDec[0][localId]!=fTriggerInputRegionalDataHPt[0][localId]){
1256             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalHPtLSB))->Fill(localId);
1257         }
1258         if(fTriggerOutputLocalDataHPtDec[1][localId]!=fTriggerInputRegionalDataHPt[1][localId]){
1259             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalHPtMSB))->Fill(localId);
1260         }
1261     }
1262 }
1263 */
1264
1265
1266 //____________________________________________________________________________ 
1267 void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutGlobal(AliMUONGlobalTrigger& inputGlobalTrigger, 
1268                                                                         AliMUONGlobalTrigger& recoGlobalTrigger, 
1269                                                                         Char_t histo)
1270 {
1271   //
1272   /// Match data and reconstructed Global Trigger decision for a reconstruction from Global inputs.
1273   /// histo='G': fill FromGlobalInput histo='F': fill from Local input;
1274   //
1275
1276   if ( recoGlobalTrigger.GetGlobalResponse() == inputGlobalTrigger.GetGlobalResponse() )
1277     return;
1278   Int_t histoToFill;
1279   Int_t binToFill;
1280   
1281   if (histo=='G'){
1282       histoToFill=AliMUONQAIndices::kTriggerErrorOutGlobalFromInGlobal;
1283       binToFill=AliMUONQAIndices::kAlgoGlobalFromGlobal;
1284   }else{
1285       if (histo=='L'){
1286           histoToFill=AliMUONQAIndices::kTriggerErrorOutGlobalFromInLocal;
1287           binToFill=AliMUONQAIndices::kAlgoGlobalFromLocal;
1288       }else{
1289           AliWarning(Form("Global histos not filled, 3rd argument must be 'G' or 'F'"));
1290           return;
1291       } 
1292   }
1293
1294   ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(binToFill);
1295
1296   Bool_t inputResp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
1297                          inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
1298                          inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()};
1299
1300   Bool_t recoResp[6] = {recoGlobalTrigger.PairUnlikeHpt(), recoGlobalTrigger.PairUnlikeLpt(),
1301                         recoGlobalTrigger.PairLikeHpt(), recoGlobalTrigger.PairLikeLpt(),
1302                         recoGlobalTrigger.SingleHpt(), recoGlobalTrigger.SingleLpt()};
1303
1304   for (int bit=0;bit<6;bit++){
1305     if ( recoResp[bit] != inputResp[bit] )
1306       ((TH1F*)GetRawsData(histoToFill))->Fill(bit);
1307   }
1308 }
1309
1310 //____________________________________________________________________________ 
1311 void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval)
1312 {
1313   /// Fill ratio 44/34 histos
1314
1315   Int_t numEvent = Int_t(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents))->GetBinContent(1));
1316
1317   // Fill every fgkUpdateRatio4434 events
1318   if (numEvent % evtInterval != 0)
1319     return;
1320
1321   Float_t totalNumberOf44 = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec))->GetSumOfWeights();
1322   Float_t totalNumberOf34 = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec))->GetSumOfWeights();
1323
1324   if ( totalNumberOf34 == 0 )
1325     return;
1326
1327   TH1F* histoAllEvents = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents);
1328   if ( ! histoAllEvents ) return;
1329   Int_t nbins =  histoAllEvents->GetNbinsX();
1330   Float_t maxBin = histoAllEvents->GetXaxis()->GetBinLowEdge(nbins+1);
1331
1332   if ( numEvent - maxBin < 1) return;
1333
1334   // Use the underflow and overflow to store the number of 34 and 44
1335   // in previous event
1336   Float_t previousNumOf34 = histoAllEvents->GetBinContent(0);
1337   Float_t previousNumOf44 = histoAllEvents->GetBinContent(nbins+1);
1338
1339   Float_t numOf34Update = totalNumberOf34 - previousNumOf34;
1340   Float_t numOf44Update = totalNumberOf44 - previousNumOf44;
1341
1342   // Not enough new tracks since last update
1343   //if ( numOf34Update == 0 && numOf44Update == 0 )
1344   if ( numOf34Update < evtInterval - 1 )
1345     return;
1346
1347   Int_t newNbins = ( (Int_t)maxBin % fgkUpdateRatio4434 ) ? nbins : nbins+1;
1348   TString cloneName;
1349
1350   Int_t hIndex[2] = {AliMUONQAIndices::kTriggerRatio4434AllEvents, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate};
1351   
1352   for (Int_t ihisto=0; ihisto<2; ihisto++){
1353     TH1F* currHisto = (TH1F*)GetRawsData(hIndex[ihisto]);
1354     cloneName = Form("%sClone", currHisto->GetName());
1355     TArrayD newAxis(newNbins+1);
1356     for (Int_t ibin=0; ibin<newNbins; ibin++){
1357       newAxis[ibin] = currHisto->GetXaxis()->GetBinLowEdge(ibin+1);
1358     }
1359     newAxis[newNbins] = numEvent;
1360     TH1F* copyHisto = (TH1F*)currHisto->Clone(cloneName.Data());
1361     //currHisto->SetBins(newNbins, 0., fgkUpdateRatio4434*newNbins);
1362     currHisto->SetBins(newNbins, newAxis.GetArray());
1363     for (Int_t ibin=1; ibin<newNbins; ibin++){
1364       currHisto->SetBinContent(ibin, copyHisto->GetBinContent(ibin));
1365       currHisto->SetBinError(ibin, copyHisto->GetBinError(ibin));
1366     }
1367     delete copyHisto;
1368   }
1369
1370   Float_t ratio4434 = totalNumberOf44/totalNumberOf34;
1371   Float_t errorRatio4434 = ProtectedSqrt(totalNumberOf44*(1-ratio4434))/totalNumberOf34;
1372     
1373   histoAllEvents->SetBinContent(newNbins,ratio4434);
1374   histoAllEvents->SetBinError(newNbins,errorRatio4434);
1375
1376   Float_t ratio4434Update = 0.;
1377   Float_t errorRatio4434Update = 0.;
1378
1379   if(numOf34Update!=0){
1380     ratio4434Update = numOf44Update/numOf34Update;
1381     if ( numOf44Update > numOf34Update ){
1382       AliWarning(Form("Number of 4/4 (%f) is higher than number of 3/4 (%f)", numOf44Update, numOf34Update));
1383     }
1384     errorRatio4434Update = ProtectedSqrt(numOf44Update*(1-ratio4434Update))/numOf34Update;
1385   }
1386
1387   ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinContent(newNbins,ratio4434Update);
1388   ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinError(newNbins,errorRatio4434Update);
1389
1390   histoAllEvents->SetBinContent(0,totalNumberOf34);
1391   histoAllEvents->SetBinContent(newNbins+1,totalNumberOf44);
1392
1393 }
1394