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