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