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