QA mods to fix warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONQADataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17
18 // --- MUON header files ---
19 #include "AliMUONQADataMakerRec.h"
20
21 #include "AliMUONConstants.h"  
22 #include "AliMUONDDLTrigger.h"
23 #include "AliMUONDarcHeader.h"
24 #include "AliMUONDigitMaker.h"
25 #include "AliMUONDigitStoreV2R.h"
26 #include "AliMUONQAMappingCheck.h"
27 #include "AliMUONGlobalTriggerBoard.h"
28 #include "AliMUONGlobalCrateConfig.h"
29 #include "AliMUONLocalStruct.h"
30 #include "AliMUONLocalTrigger.h"
31 #include "AliMUONLocalTriggerBoard.h"
32 #include "AliMUONRawStreamTracker.h"
33 #include "AliMUONRawStreamTriggerHP.h"
34 #include "AliMUONRegHeader.h"
35 #include "AliMUONTrackerDataMaker.h"
36 #include "AliMUONTriggerDisplay.h"
37 #include "AliMUONVCluster.h"
38 #include "AliMUONVClusterStore.h"
39 #include "AliMUONVDigit.h"
40 #include "AliMUONVDigitStore.h"
41 #include "AliMUONVTrackerData.h"
42 #include "AliMUONVTriggerStore.h"
43 #include "AliMUONTrack.h"
44 #include "AliMUONTrackParam.h"
45 #include "AliMUONTriggerElectronics.h"
46 #include "AliMUONTriggerStoreV1.h"
47 #include "AliMUONESDInterface.h"
48 #include "AliMUONCalibrationData.h"
49 #include "AliMpBusPatch.h"
50 #include "AliMpCDB.h"
51 #include "AliMpConstants.h"
52 #include "AliMpDDLStore.h"
53 #include "AliMpDEIterator.h"
54 #include "AliMpDEManager.h"
55 #include "AliMpDetElement.h"
56 #include "AliMpLocalBoard.h"
57 #include "AliMpStationType.h"
58 #include "AliMpTriggerCrate.h"
59 #include "AliMpDCSNamer.h"
60 #include "AliRawEventHeaderBase.h"
61
62 // --- AliRoot header files ---
63 #include "AliCDBManager.h"
64 #include "AliCDBStorage.h"
65 #include "AliESDEvent.h"
66 #include "AliESDMuonTrack.h"
67 #include "AliESDMuonCluster.h"
68 #include "AliLog.h"
69 #include "AliRawReader.h"
70 #include "AliQAChecker.h"
71 #include "AliCodeTimer.h"
72 #include "AliDCSValue.h"
73 #include "AliMUONVDigit.h"
74
75 // --- ROOT system ---
76 #include <TClonesArray.h>
77 #include <TFile.h> 
78 #include <TH1F.h> 
79 #include <TH1I.h> 
80 #include <TH2F.h>
81 #include <TLine.h>
82 #include <TPaveText.h>
83 #include <Riostream.h>
84 #include <TMath.h>
85
86 //-----------------------------------------------------------------------------
87 /// \class AliMUONQADataMakerRec
88 ///
89 /// MUON base class for quality assurance data (histo) maker
90 ///
91 /// \author C. Finck, D. Stocco, L. Aphecetche
92
93 /// \cond CLASSIMP
94 ClassImp(AliMUONQADataMakerRec)
95 /// \endcond
96            
97
98 namespace {
99   
100   int trim(Int_t n, 
101            Double_t* x,
102            Double_t alpha,
103            Double_t& tmean,
104            Double_t& tvar,
105            Double_t& min,
106            Double_t& max)
107   {
108     //
109     // Calculates the trimmed (tmean) mean
110     // of a sample (x) and estimates the variance (tvar)
111     // of that mean.
112     //
113     
114     // First check input parameters
115     
116     // number of observations
117     if ( n < 2 )
118     {
119       return -1;
120     }
121     
122     if ( alpha < 0 || alpha >= 0.5 )
123       // proportion of observations
124       // to be trimmed at each end of the sorted sample
125     {
126       return -2;
127     }
128     
129     // Input parameters are good. Let's move on.
130     
131     // Insure we use a sample sorted into ascending order.
132     
133     Int_t* indices = new Int_t[n];
134     
135     TMath::Sort(n,x,indices,kFALSE);
136     
137     Double_t* sx = new Double_t[n];
138     
139     for ( Int_t i = 0; i < n; ++i )
140     {
141       sx[i] = x[indices[i]];
142     }
143     delete[] indices;
144     
145   
146     // Number of observations trimmed at each end.
147     
148     Int_t k = static_cast<Int_t>(floorf(alpha * n));
149     
150     double sum = 0.0;
151     
152     for ( Int_t i = k; i < n - k ; ++i )
153     {
154       sum += sx[i];
155     }
156     
157     tmean = sum / ( n - 2 * k );
158   
159     double t2 = 0.0;
160     
161     for ( Int_t i = k; i < n - k; ++i )
162     {
163       t2 += (sx[i] - tmean) * (sx[i] - tmean);
164     }
165     
166     tvar = (
167             t2 +
168             k * (sx[k] - tmean) * (sx[k] - tmean) +
169             k * (sx[n - k - 1] - tmean) * (sx[n - k - 1] - tmean)
170             ) / (n * n);
171     
172     // get the min and max for the non-rejected values
173     min = DBL_MAX;
174     max = 0.0;
175     
176     for ( Int_t i = k; i < n-k; ++i ) 
177     {
178       min = TMath::Min(min,sx[i]);
179       max = TMath::Max(max,sx[i]);
180     }
181     
182     delete[] sx;
183     
184     return 0;
185   }
186 }
187
188 //____________________________________________________________________________ 
189 AliMUONQADataMakerRec::AliMUONQADataMakerRec() : 
190 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kMUON), "MUON Quality Assurance Data Maker"),
191 fDigitStore(0x0),
192 fDigitMaker(0x0),
193 fClusterStore(0x0),
194 fTrackerDataMaker(0x0),
195 fMappingCheckRecPoints(0x0),
196 fCalibrationData(0x0),
197 fTriggerProcessor(0x0)
198 {
199     /// ctor
200         
201   AliDebug(AliQAv1::GetQADebugLevel(),"");
202
203         Ctor();
204 }
205
206 //____________________________________________________________________________ 
207 void
208 AliMUONQADataMakerRec::Ctor()
209 {
210         /// Init some members
211   AliCodeTimerAuto("",0);
212         fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
213         fDigitMaker = new AliMUONDigitMaker(kTRUE);
214         fCalibrationData = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
215         fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
216 }
217
218 //____________________________________________________________________________ 
219 AliMUONQADataMakerRec::AliMUONQADataMakerRec(const AliMUONQADataMakerRec& qadm) :
220 AliQADataMakerRec(qadm),
221 fDigitStore(0x0),
222 fDigitMaker(0x0),
223 fClusterStore(0x0),
224 fTrackerDataMaker(0x0),
225 fMappingCheckRecPoints(0x0),
226 fCalibrationData(0x0),
227 fTriggerProcessor(0x0)
228 {
229     ///copy ctor 
230
231   AliDebug(AliQAv1::GetQADebugLevel(),"");
232
233
234     SetName((const char*)qadm.GetName()) ; 
235     SetTitle((const char*)qadm.GetTitle()); 
236
237         // Do not copy the digit store and digit maker, but create its own ones
238         
239         Ctor();
240         
241 }
242
243 //__________________________________________________________________
244 AliMUONQADataMakerRec& AliMUONQADataMakerRec::operator = (const AliMUONQADataMakerRec& qadm )
245 {
246   /// Assignment operator
247
248   AliDebug(AliQAv1::GetQADebugLevel(),"");
249
250   // check assignment to self
251   if (this == &qadm) return *this;
252
253   this->~AliMUONQADataMakerRec();
254   new(this) AliMUONQADataMakerRec(qadm);
255   return *this;
256 }
257
258 //__________________________________________________________________
259 AliMUONQADataMakerRec::~AliMUONQADataMakerRec()
260 {
261     /// dtor
262   
263   AliDebug(AliQAv1::GetQADebugLevel(),"");
264
265   AliCodeTimerAuto("",0);
266   
267   delete fDigitStore;
268   delete fDigitMaker;
269   delete fClusterStore;
270   delete fTrackerDataMaker;
271   delete fCalibrationData;
272   delete fTriggerProcessor;
273   delete fMappingCheckRecPoints;
274 }
275
276 //____________________________________________________________________________ 
277 void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
278 {
279   /// Detector specific actions at end of cycle
280   
281   AliCodeTimerAuto("",0);
282   
283   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
284   {
285     if (! IsValidEventSpecie(specie, list)  ) continue;
286     
287     SetEventSpecie(AliRecoParam::ConvertIndex(specie));
288         
289     if ( task == AliQAv1::kRAWS && fTrackerDataMaker ) 
290     {
291       // export trackerdata as is, and also make a summarized version (buspatchoccupancy)
292       EndOfDetectorCycleRaws(specie,list);
293     }
294     
295     if ( task == AliQAv1::kRECPOINTS )
296     {
297       // normalize recpoints histograms
298       EndOfDetectorCycleRecPoints(specie,list);
299     }
300     
301     if ( task == AliQAv1::kESDS ) 
302     {
303       // normalize esds histograms
304       EndOfDetectorCycleESDs();
305     }
306     
307     // Display trigger histos in a more user friendly way
308     DisplayTriggerInfo(task);
309     
310   } // loop on specie
311     
312   // do the QA checking
313   AliQAChecker::Instance()->Run(AliQAv1::kMUON,task,list);
314 }
315
316 //____________________________________________________________________________ 
317 void AliMUONQADataMakerRec::InsertTrackerData(Int_t specie, TObjArray** list,
318                                               TObject* object, Int_t indexNumber,
319                                               Bool_t replace)
320 {
321   /// Insert an object to a given list
322   
323   TIter next(list[specie]);
324   TObject* o;
325   TObject* old(0x0);
326   Bool_t alreadyThere(kFALSE);
327   while ( ( o = next() ) && !alreadyThere )
328   {
329     TString classname(o->ClassName());
330     if ( classname.Contains("TrackerData") ) 
331     {
332       alreadyThere = kTRUE;
333       old = o;
334     }
335   }
336   if ( (!alreadyThere && object) || (alreadyThere && replace) )
337   {
338     delete old;
339     AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s to the list of qa objects",object->GetName()));
340     list[specie]->AddAt(object,indexNumber);
341   }
342 }
343
344 //____________________________________________________________________________ 
345 void AliMUONQADataMakerRec::EndOfDetectorCycleESDs()
346 {
347   /// Normalize ESD histograms
348   
349   if (!GetESDsData(kESDnClustersPerTrack)) return;
350   
351   Double_t nTracks = GetESDsData(kESDnClustersPerTrack)->GetEntries();
352   if (nTracks <= 0) return;
353   
354   TH1* hESDnClustersPerCh = GetESDsData(kESDnClustersPerCh);
355   TH1* hESDnClustersPerDE = GetESDsData(kESDnClustersPerDE);
356   TH1* hESDClusterChargePerChMean = GetESDsData(kESDClusterChargePerChMean);
357   TH1* hESDClusterChargePerChSigma = GetESDsData(kESDClusterChargePerChSigma);
358   TH1* hESDClusterSizePerChMean = GetESDsData(kESDClusterSizePerChMean);
359   TH1* hESDClusterSizePerChSigma = GetESDsData(kESDClusterSizePerChSigma);
360   TH1* hESDResidualXPerChMean = GetESDsData(kESDResidualXPerChMean);
361   TH1* hESDResidualXPerChSigma = GetESDsData(kESDResidualXPerChSigma);
362   TH1* hESDResidualYPerChMean = GetESDsData(kESDResidualYPerChMean);
363   TH1* hESDResidualYPerChSigma = GetESDsData(kESDResidualYPerChSigma);
364   TH1* hESDLocalChi2XPerChMean = GetESDsData(kESDLocalChi2XPerChMean);
365   TH1* hESDLocalChi2YPerChMean = GetESDsData(kESDLocalChi2YPerChMean);
366   TH1* hESDLocalChi2PerChMean = GetESDsData(kESDLocalChi2PerChMean);
367   TH1* hESDClusterChargePerDE = GetESDsData(kESDClusterChargePerDE);
368   TH1* hESDClusterSizePerDE = GetESDsData(kESDClusterSizePerDE);
369   TH1* hESDResidualXPerDEMean = GetESDsData(kESDResidualXPerDEMean);
370   TH1* hESDResidualXPerDESigma = GetESDsData(kESDResidualXPerDESigma);
371   TH1* hESDResidualYPerDEMean = GetESDsData(kESDResidualYPerDEMean);
372   TH1* hESDResidualYPerDESigma = GetESDsData(kESDResidualYPerDESigma);
373   TH1* hESDLocalChi2XPerDEMean = GetESDsData(kESDLocalChi2XPerDEMean);
374   TH1* hESDLocalChi2YPerDEMean = GetESDsData(kESDLocalChi2YPerDEMean);
375   TH1* hESDLocalChi2PerDEMean = GetESDsData(kESDLocalChi2PerDEMean);
376   TH1* hESDnTotClustersPerCh = GetESDsData(kESDnTotClustersPerCh);
377   TH1* hESDnTotClustersPerDE = GetESDsData(kESDnTotClustersPerDE);
378   TH1* hESDnTotFullClustersPerDE = GetESDsData(kESDnTotFullClustersPerDE);
379   TH1* hESDSumClusterChargePerDE = GetESDsData(kESDSumClusterChargePerDE);
380   TH1* hESDSumClusterSizePerDE = GetESDsData(kESDSumClusterSizePerDE);
381   TH1* hESDSumResidualXPerDE = GetESDsData(kESDSumResidualXPerDE);
382   TH1* hESDSumResidualYPerDE = GetESDsData(kESDSumResidualYPerDE);
383   TH1* hESDSumResidualX2PerDE = GetESDsData(kESDSumResidualX2PerDE);
384   TH1* hESDSumResidualY2PerDE = GetESDsData(kESDSumResidualY2PerDE);
385   TH1* hESDSumLocalChi2XPerDE = GetESDsData(kESDSumLocalChi2XPerDE);
386   TH1* hESDSumLocalChi2YPerDE = GetESDsData(kESDSumLocalChi2YPerDE);
387   TH1* hESDSumLocalChi2PerDE = GetESDsData(kESDSumLocalChi2PerDE);
388   
389   hESDnClustersPerCh->Reset();
390   hESDnClustersPerDE->Reset();
391   hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
392   hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
393   
394   // loop over chambers
395   for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
396     
397     TH1* hESDClusterChargeInCh = GetESDsData(kESDClusterChargeInCh+iCh);
398     Double_t sigmaCharge = hESDClusterChargeInCh->GetRMS();
399     hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
400     hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
401     hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
402     hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
403     
404     TH1* hESDClusterSizeInCh = GetESDsData(kESDClusterSizeInCh+iCh);
405     Double_t sigmaSize = hESDClusterSizeInCh->GetRMS();
406     hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
407     hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
408     hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
409     hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
410     
411     TH1* hESDResidualXInCh = GetESDsData(kESDResidualXInCh+iCh);
412     Double_t sigmaResidualX = hESDResidualXInCh->GetRMS();
413     hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
414     hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
415     hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
416     hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
417     
418     TH1* hESDResidualYInCh = GetESDsData(kESDResidualYInCh+iCh);
419     Double_t sigmaResidualY = hESDResidualYInCh->GetRMS();
420     hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
421     hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
422     hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
423     hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
424     
425     TH1* hESDLocalChi2XInCh = GetESDsData(kESDLocalChi2XInCh+iCh);
426     Double_t sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
427     hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
428     hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
429     
430     TH1* hESDLocalChi2YInCh = GetESDsData(kESDLocalChi2YInCh+iCh);
431     Double_t sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
432     hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
433     hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
434     
435     TH1* hESDLocalChi2InCh = GetESDsData(kESDLocalChi2InCh+iCh);
436     Double_t sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
437     hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
438     hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
439     
440     // loop over DE into chamber iCh
441     AliMpDEIterator it;
442     it.First(iCh);
443     while ( !it.IsDone()) {
444       
445       Int_t iDE = it.CurrentDEId();
446       
447       Double_t nClusters = hESDnTotClustersPerDE->GetBinContent(iDE+1);
448       if (nClusters > 1) {
449         
450         hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
451         hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
452         
453         Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
454         hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
455         hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
456         hESDResidualXPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
457         hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
458         
459         Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
460         hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
461         hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
462         hESDResidualYPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
463         hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
464         
465         hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
466         hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
467         
468         hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
469         hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
470         
471         hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
472         hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
473         
474       } else {
475         
476         hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
477         hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
478         
479         hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
480         hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
481         hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
482         hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
483         
484         hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
485         hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
486         hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
487         hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
488         
489         hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
490         hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
491         
492         hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
493         hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
494         
495         hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
496         hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
497         
498       }
499       
500       Double_t nFullClusters = hESDnTotFullClustersPerDE->GetBinContent(iDE+1);
501       if (nFullClusters > 1) {
502         
503         hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
504         hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
505         
506       } else {
507         
508         hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
509         hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
510         
511       }
512       
513       it.Next();
514     }
515
516   }
517
518 }
519   
520 //____________________________________________________________________________ 
521 void AliMUONQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t specie, TObjArray** list)
522 {
523   /// Normalize RecPoints histograms
524   
525   if (!GetRecPointsData(kTrackerClusterChargePerChMean)) return;
526   
527   TH1* hTrackerClusterChargePerChMean = GetRecPointsData(kTrackerClusterChargePerChMean);
528   TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(kTrackerClusterChargePerChSigma);
529   TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(kTrackerClusterMultiplicityPerChMean);
530   TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(kTrackerClusterMultiplicityPerChSigma);
531   TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(kTrackerClusterChargePerDEMean);
532   TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(kTrackerClusterMultiplicityPerDEMean);
533   
534   // loop over chambers
535   for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
536     
537     TH1* hTrackerClusterChargePerChamber = GetRecPointsData(kTrackerClusterChargePerChamber+iCh);
538     Double_t sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
539     hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
540     hTrackerClusterChargePerChMean->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetMeanError());
541     hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
542     hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
543     
544     TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(kTrackerClusterMultiplicityPerChamber+iCh);
545     Double_t sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
546     hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
547     hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
548     hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
549     hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
550     
551     // loop over DE into chamber iCh
552     AliMpDEIterator it;
553     it.First(iCh);
554     while ( !it.IsDone()) {
555       
556       Int_t iDE = it.CurrentDEId();
557       
558       TH1* hTrackerClusterChargePerDE = GetRecPointsData(kTrackerClusterChargePerDE+iDE);
559       hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
560       Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
561       if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
562       else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber->GetXaxis()->GetXmax());
563       
564       TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(kTrackerClusterMultiplicityPerDE+iDE);
565       hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
566       nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
567       if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
568       else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax());
569       
570       it.Next();
571     }
572   }
573   
574   if ( fMappingCheckRecPoints ) InsertTrackerData(specie,list,fMappingCheckRecPoints->CreateData("RecPoints"),kTrackerRecPoints,kTRUE);
575 }
576
577
578 //____________________________________________________________________________ 
579 void AliMUONQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArray** list)
580 {
581   /// create Raws histograms in Raws subdir
582   
583   if ( !GetRawsData(kTrackerBusPatchOccupancy) ) return;
584
585   if ( fTrackerDataMaker ) 
586   {
587     InsertTrackerData(specie,list,fTrackerDataMaker->Data(),kTrackerData);
588
589     TH1* hbp = GetRawsData(kTrackerBusPatchOccupancy);
590     hbp->Reset();
591     TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
592     AliMpBusPatch* bp(0x0);
593     AliMUONVTrackerData* data = fTrackerDataMaker->Data();
594     Int_t occDim = 2;
595     
596     while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
597     {
598       Int_t busPatchId = bp->GetId();
599       Int_t bin = hbp->FindBin(busPatchId);
600       hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
601     }
602     
603     BeautifyTrackerBusPatchOccupancy(*hbp);
604   }
605
606   // Normalize RawData histos
607       Float_t nbevent = GetRawsData(kRawNAnalyzedEvents)->GetBinContent(1);
608       TH1* htemp = GetRawsData(kTriggerError);
609       Float_t temp=htemp->GetBinContent(4);
610       htemp->SetBinContent(4, temp/192.);
611       if (nbevent>0) htemp->Scale(100./nbevent);
612 }
613
614 //____________________________________________________________________________ 
615 void AliMUONQADataMakerRec::InitRaws()
616 {
617     /// create Raws histograms in Raws subdir
618         
619   AliCodeTimerAuto("",0);
620   
621   const Bool_t expert   = kTRUE ; 
622   const Bool_t saveCorr = kTRUE ; 
623   const Bool_t image    = kTRUE ; 
624  
625   TString boardName = "Local board Id";
626
627   Int_t nbLocalBoard = AliMUONConstants::NTriggerCircuit();
628   
629   TString histoName, histoTitle;
630   for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
631     TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
632     for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
633       histoName = Form("hTriggerScalers%sChamber%i", cathName.Data(), 11+iChamber);
634       histoTitle = Form("Chamber %i - %s: trigger scaler counts", 11+iChamber, cathName.Data());
635       TH2F* h3 = new TH2F(histoName.Data(), histoTitle.Data(),
636                           234, 0.5, 234.5,
637                           16, -0.5, 15.5);
638       h3->GetXaxis()->SetTitle(boardName.Data());
639       h3->GetYaxis()->SetTitle("Strip");        
640       h3->SetOption("COLZ");    
641       Add2RawsList(h3, kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
642     }
643   }
644         
645         AliMUONTriggerDisplay triggerDisplay;
646         for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
647                 TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
648                 for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
649                         histoName = Form("hScalersDisplay%sChamber%i", cathName.Data(), 11+iChamber);
650                         histoTitle = Form("Chamber %i - %s: Hit rate from scalers (Hz/cm^{2})", 11+iChamber, cathName.Data());
651                         TH2F* h5 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
652                                                                               iCath, iChamber, histoTitle);
653                         h5->SetOption("COLZ");
654                         Add2RawsList(h5, kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image, !saveCorr);
655                 }
656         }
657
658         FillTriggerDCSHistos();
659
660         TH1F* h10 = new TH1F("hTriggerScalersTime", "Acquisition time from trigger scalers", 1, 0.5, 1.5);
661         h10->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
662         h10->GetYaxis()->SetTitle("Cumulated scaler time (s)");
663         Add2RawsList(h10, kTriggerScalersTime, !expert, !image, !saveCorr);
664         
665         Char_t *globalXaxisName[6] = {"US HPt", "US LPt", "LS HPt", "LS LPt", "SGL HPt", "SGL LPt"};
666         Char_t *allLevelXaxisName[10] = {"Local algo X", "Local algo Y", "Local LUT","Local Y Copy" , "Local2Regional", "Regional", "Regional2Global", "GlobalFromInGlobal", "GlobalFromInLocal", "GlobalFromOutLocal"};
667
668         TString errorAxisTitle = "Number of errors";
669
670         TH1F* h11 = new TH1F("ErrorLocalXPos", "ErrorLocalXPos",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
671         h11->GetXaxis()->SetTitle(boardName.Data());
672         h11->GetYaxis()->SetTitle(errorAxisTitle.Data());
673         Add2RawsList(h11, kTriggerErrorLocalXPos, expert, !image, !saveCorr);
674
675         TH1F* h12 = new TH1F("ErrorLocalYPos", "ErrorLocalYPos",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
676         h12->GetXaxis()->SetTitle(boardName.Data());
677         h12->GetYaxis()->SetTitle(errorAxisTitle.Data());
678         Add2RawsList(h12, kTriggerErrorLocalYPos, expert, !image, !saveCorr);
679
680         TH1F* h13 = new TH1F("ErrorLocalDev", "ErrorLocalDev",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
681         h13->GetXaxis()->SetTitle(boardName.Data());
682         h13->GetYaxis()->SetTitle(errorAxisTitle.Data());
683         Add2RawsList(h13, kTriggerErrorLocalDev, expert, !image, !saveCorr);
684
685         TH1F* h14 = new TH1F("ErrorLocalTriggerDec", "ErrorLocalTriggerDec",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
686         h14->GetXaxis()->SetTitle(boardName.Data());
687         h14->GetYaxis()->SetTitle(errorAxisTitle.Data());
688         Add2RawsList(h14, kTriggerErrorLocalTriggerDec, expert, !image, !saveCorr);
689
690         TH1F* h15 = new TH1F("ErrorLocalLPtLSB", "ErrorLocalLPtLSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
691         h15->GetXaxis()->SetTitle(boardName.Data());
692         h15->GetYaxis()->SetTitle(errorAxisTitle.Data());
693         Add2RawsList(h15, kTriggerErrorLocalLPtLSB, expert, !image, !saveCorr);
694
695         TH1F* h16 = new TH1F("ErrorLocalLPtMSB", "ErrorLocalLPtMSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
696         h16->GetXaxis()->SetTitle(boardName.Data());
697         h16->GetYaxis()->SetTitle(errorAxisTitle.Data());
698         Add2RawsList(h16, kTriggerErrorLocalLPtMSB, expert, !image, !saveCorr);
699
700         TH1F* h17 = new TH1F("ErrorLocalHPtLSB", "ErrorLocalHPtLSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
701         h17->GetXaxis()->SetTitle(boardName.Data());
702         h17->GetYaxis()->SetTitle(errorAxisTitle.Data());
703         Add2RawsList(h17, kTriggerErrorLocalHPtLSB, expert, !image, !saveCorr);
704
705         TH1F* h18 = new TH1F("ErrorLocalHPtMSB", "ErrorLocalHPtMSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
706         h18->GetXaxis()->SetTitle(boardName.Data());
707         h18->GetYaxis()->SetTitle(errorAxisTitle.Data());
708         Add2RawsList(h18, kTriggerErrorLocalHPtMSB, expert, !image, !saveCorr);
709
710         TH1F* h19 = new TH1F("ErrorLocal2RegionalLPtLSB", "ErrorLocal2RegionalLPtLSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
711         h19->GetXaxis()->SetTitle(boardName.Data());
712         h19->GetYaxis()->SetTitle(errorAxisTitle.Data());
713         Add2RawsList(h19, kTriggerErrorLocal2RegionalLPtLSB, expert, !image, !saveCorr);
714
715         TH1F* h20 = new TH1F("ErrorLocal2RegionalLPtMSB", "ErrorLocal2RegionalLPtMSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
716         h20->GetXaxis()->SetTitle(boardName.Data());
717         h20->GetYaxis()->SetTitle(errorAxisTitle.Data());
718         Add2RawsList(h20, kTriggerErrorLocal2RegionalLPtMSB, expert, !image, !saveCorr);
719
720         TH1F* h21 = new TH1F("ErrorLocal2RegionalHPtLSB", "ErrorLocal2RegionalHPtLSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
721         h21->GetXaxis()->SetTitle(boardName.Data());
722         h21->GetYaxis()->SetTitle(errorAxisTitle.Data());
723         Add2RawsList(h21, kTriggerErrorLocal2RegionalHPtLSB, expert, !image, !saveCorr);
724
725         TH1F* h22 = new TH1F("ErrorLocal2RegionalHPtMSB", "ErrorLocal2RegionalHPtMSB",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
726         h22->GetXaxis()->SetTitle(boardName.Data());
727         h22->GetYaxis()->SetTitle(errorAxisTitle.Data());
728         Add2RawsList(h22, kTriggerErrorLocal2RegionalHPtMSB, expert, !image, !saveCorr);
729
730         TH1F* h23 = new TH1F("ErrorOutGlobalFromInGlobal", "ErrorOutGlobalFromInGlobal",6,0,6);
731         h23->GetYaxis()->SetTitle(errorAxisTitle.Data());
732         for (int i=0;i<6;i++){
733             h23->GetXaxis()->SetBinLabel(i+1,globalXaxisName[i]);
734         }
735         Add2RawsList(h23, kTriggerErrorOutGlobalFromInGlobal, expert, !image, !saveCorr);
736
737         TH1F* h24 = new TH1F("ErrorTrigger", "ErrorTrigger",11,0,11);
738         h24->GetYaxis()->SetTitle("Percentage of error");
739         for (int i=0;i<10;i++){
740             h24->GetXaxis()->SetBinLabel(i+1,allLevelXaxisName[i]);
741         }
742         Add2RawsList(h24, kTriggerError, !expert, !image, !saveCorr);
743
744         TH1F* h25 = new TH1F("ErrorLocalTrigY", "ErrorLocalTrigY",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
745         h25->GetXaxis()->SetTitle(boardName.Data());
746         h25->GetYaxis()->SetTitle(errorAxisTitle.Data());
747         Add2RawsList(h25, kTriggerErrorLocalTrigY, expert, !image, !saveCorr);
748
749         TH1F* h26 = new TH1F("ErrorLocalYCopy", "ErrorLocalYCopy",nbLocalBoard+1,-0.5,(Float_t)nbLocalBoard+0.5);
750         h26->GetXaxis()->SetTitle(boardName.Data());
751         h26->GetYaxis()->SetTitle(errorAxisTitle.Data());
752         Add2RawsList(h26, kTriggerErrorLocalYCopy, expert, !image, !saveCorr);
753         
754         TH1F* h27 = new TH1F("hRawNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
755         Int_t esindex = AliRecoParam::AConvert(fEventSpecie);
756         h27->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
757         h27->GetYaxis()->SetTitle("Number of analyzed events");
758         Add2RawsList(h27, kRawNAnalyzedEvents, expert, !image, !saveCorr);
759
760   Int_t bpmin(999999);
761   Int_t bpmax(0);
762   
763   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
764   AliMpBusPatch* bp(0x0);
765   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
766   {
767     bpmin = TMath::Min(bpmin,bp->GetId());
768     bpmax = TMath::Max(bpmax,bp->GetId());
769   }
770   
771   Double_t xmin = bpmin-0.5;
772   Double_t xmax = bpmax+0.5;
773   Int_t nbins = bpmax-bpmin+1;
774   
775   TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",nbins,xmin,xmax);
776
777   TH1* hbpnpads = new TH1F("hTrackerBusPatchNofPads","Number of pads per bus patch",nbins,xmin,xmax);
778
779   TH1* hbpnmanus = new TH1F("hTrackerBusPatchNofManus","Number of manus per bus patch",nbins,xmin,xmax);
780
781   Add2RawsList(hbp,kTrackerBusPatchOccupancy, !expert, image, !saveCorr);
782   Add2RawsList(hbpnpads,kTrackerBusPatchNofPads, expert, !image, !saveCorr);
783   Add2RawsList(hbpnmanus,kTrackerBusPatchNofManus, expert, !image, !saveCorr);
784
785   const Bool_t histogram(kFALSE);
786
787   if(!fTrackerDataMaker) 
788   {
789     fTrackerDataMaker = new AliMUONTrackerDataMaker(GetMUONRecoParam(),
790                                                     AliCDBManager::Instance()->GetRun(),
791                                                     0x0,
792                                                     "",
793                                                     "NOGAIN",
794                                                     histogram,
795                                                     0.0,0.0);
796   }
797   
798   fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
799
800   fTrackerDataMaker->SetRunning(kTRUE);
801 }
802
803 //__________________________________________________________________
804 void AliMUONQADataMakerRec::InitDigits() 
805 {
806   /// Initialized Digits spectra 
807   const Bool_t expert   = kTRUE ; 
808   const Bool_t image    = kTRUE ; 
809   
810   TH1I* h0 = new TH1I("hDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  1400, 100, 1500); 
811   Add2DigitsList(h0, 0, !expert, image);
812   
813   TH1I* h1 = new TH1I("hDigitsADC", "ADC distribution in Digits;ACD value;Counts", 4096, 0, 4095); 
814   Add2DigitsList(h1, 1, !expert, image);    
815
816
817 //____________________________________________________________________________ 
818 void AliMUONQADataMakerRec::InitRecPoints()
819 {
820         /// create Reconstructed Points histograms in RecPoints subdir
821   
822   AliCodeTimerAuto("",0);
823   
824         InitRecPointsTrigger();
825         InitRecPointsTracker();
826 }
827
828 //____________________________________________________________________________ 
829 void AliMUONQADataMakerRec::InitRecPointsTracker()
830 {
831   /// create Reconstructed Points histograms in RecPoints subdir for the
832   /// MUON tracker subsystem.
833   const Bool_t expert   = kTRUE ; 
834   const Bool_t image    = kTRUE ; 
835   
836   AliCodeTimerAuto("",0);
837   
838   TH1I *h1I;
839   TH1F *h1F;
840   TH2F *h2F;
841   
842   // histograms per chamber
843   Int_t nCh = AliMpConstants::NofTrackingChambers();
844   for ( Int_t i = 0; i < nCh; ++i ) 
845   {
846     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
847     Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerChamber+i, expert, !image);
848     
849     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC);Counts",i+1), 100,0,1000);
850     Add2RecPointsList(h1I,kTrackerClusterChargePerChamber+i, expert, !image);
851     
852     Float_t rMax = AliMUONConstants::Rmax(i/2);
853     h2F = new TH2F(Form("hTrackerClusterHitMapForChamber%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1), 100, -rMax, rMax, 100, -rMax, rMax);
854     Add2RecPointsList(h2F, kTrackerClusterHitMapPerChamber+i, expert, !image);
855   }
856   
857   // summary histograms per chamber
858   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
859   Add2RecPointsList(h1I,kTrackerNumberOfClustersPerChamber, !expert, image);
860   
861   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
862   h1F->SetOption("P");
863   h1F->SetMarkerStyle(kFullDotMedium);
864   h1F->SetMarkerColor(kRed);
865   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChMean, !expert, image);
866   
867   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
868   h1F->SetOption("P");
869   h1F->SetMarkerStyle(kFullDotMedium);
870   h1F->SetMarkerColor(kRed);
871   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChSigma, !expert, image);
872   
873   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh,-0.5,nCh-0.5);
874   h1F->SetOption("P");
875   h1F->SetMarkerStyle(kFullDotMedium);
876   h1F->SetMarkerColor(kRed);
877   Add2RecPointsList(h1F, kTrackerClusterChargePerChMean, !expert, image);
878   
879   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh,-0.5,nCh-0.5);
880   h1F->SetOption("P");
881   h1F->SetMarkerStyle(kFullDotMedium);
882   h1F->SetMarkerColor(kRed);
883   Add2RecPointsList(h1F, kTrackerClusterChargePerChSigma, !expert, image);
884   
885   // histograms per DE
886   Int_t ndes(0);
887   AliMpDEIterator it;
888   it.First();
889   while ( !it.IsDone())
890   {
891     Int_t detElemId = it.CurrentDEId();
892     
893     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
894     {
895       ndes = TMath::Max(ndes,detElemId);
896       
897       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
898       Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
899       
900       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (fC)",detElemId), 100,0,1000);
901       Add2RecPointsList(h1I,kTrackerClusterChargePerDE+detElemId, expert, !image);
902     }
903     
904     it.Next();
905   }
906   
907   // summary histograms per DE
908   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
909   Add2RecPointsList(h1I, kTrackerNumberOfClustersPerDE, !expert, image);
910   
911   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
912   h1F->SetOption("P");
913   h1F->SetMarkerStyle(kFullDotMedium);
914   h1F->SetMarkerColor(kRed);
915   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerDEMean, !expert, image);
916   
917   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", ndes+1,-0.5,ndes+0.5);
918   h1F->SetOption("P");
919   h1F->SetMarkerStyle(kFullDotMedium);
920   h1F->SetMarkerColor(kRed);
921   Add2RecPointsList(h1F, kTrackerClusterChargePerDEMean, !expert, image);
922   
923   if (!fMappingCheckRecPoints) fMappingCheckRecPoints = new AliMUONQAMappingCheck(fRun);  
924 }
925
926 //____________________________________________________________________________ 
927 void AliMUONQADataMakerRec::InitRecPointsTrigger()
928 {
929         /// create Reconstructed Points histograms in RecPoints subdir for the
930         /// MUON Trigger subsystem.
931         
932   const Bool_t expert   = kTRUE ; 
933   const Bool_t image    = kTRUE ; 
934
935   TString boardName = "Local board Id";
936
937   TString histoName, histoTitle;
938   for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
939     TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
940     for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
941       histoName = Form("hTriggerDigits%sChamber%i", cathName.Data(), 11+iChamber);
942       histoTitle = Form("Chamber %i - %s: counts per strip", 11+iChamber, cathName.Data());
943       TH2F* h0 = new TH2F(histoName.Data(), histoTitle.Data(),
944                           234, 0.5, 234.5,
945                           16, -0.5, 15.5);
946       h0->GetXaxis()->SetTitle(boardName.Data());
947       h0->GetYaxis()->SetTitle("Strip");
948       h0->SetOption("COLZ");
949       Add2RecPointsList(h0, kTriggerDigits + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image);
950     }
951   }
952
953     TH1F* h2 = new TH1F("hTriggeredBoards", "Triggered boards", 234, 0.5, 234.5);
954     Add2RecPointsList(h2, kTriggeredBoards, expert, !image);
955
956     AliMUONTriggerDisplay triggerDisplay;
957     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
958       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
959       for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
960         histoName = Form("hTriggerDigitsDisplay%sChamber%i", cathName.Data(), 11+iChamber);
961         histoTitle = Form("Chamber %i - %s: Occupancy per strip (counts/event)", 11+iChamber, cathName.Data());
962         TH2F* h3 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
963                                                               iCath, iChamber, histoTitle);
964         h3->SetOption("COLZ");
965         Add2RecPointsList(h3, kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image);
966       }
967     }
968
969     TH2F* h4 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto("hFiredBoardsDisplay", AliMUONTriggerDisplay::kDisplayBoards,
970                                                           0, 0, "Local board triggers / event");
971     h4->SetOption("COLZ");
972     Add2RecPointsList(h4, kTriggerBoardsDisplay, !expert, image);
973
974     TH1F* h5 = new TH1F("hNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
975     Int_t esindex = AliRecoParam::AConvert(fEventSpecie);
976     h5->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
977     h5->GetYaxis()->SetTitle("Number of analyzed events");
978     Add2RecPointsList(h5, kNAnalyzedEvents, !expert, image);
979 }
980
981
982 //____________________________________________________________________________ 
983 void AliMUONQADataMakerRec::InitESDs()
984 {
985   ///create ESDs histograms in ESDs subdir
986   
987   const Bool_t expert   = kTRUE ; 
988   const Bool_t image    = kTRUE ; 
989   
990   Int_t nCh = AliMUONConstants::NTrackingCh();
991   Int_t nDE = 1100;
992   
993   // track info
994   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
995   Add2ESDsList(hESDnTracks, kESDnTracks, !expert, image);
996
997   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
998   Add2ESDsList(hESDMatchTrig, kESDMatchTrig, !expert, image);
999   
1000   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
1001   Add2ESDsList(hESDMomentum, kESDMomentum, !expert, image);
1002
1003   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
1004   Add2ESDsList(hESDPt, kESDPt, !expert, image);
1005
1006   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
1007   Add2ESDsList(hESDRapidity, kESDRapidity, !expert, image);
1008
1009   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
1010   Add2ESDsList(hESDChi2, kESDChi2, !expert, image);
1011   
1012   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
1013   Add2ESDsList(hESDProbChi2, kESDProbChi2, !expert, image);
1014   
1015   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
1016   Add2ESDsList(hESDThetaX, kESDThetaX, !expert, image);
1017   
1018   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
1019   Add2ESDsList(hESDThetaY, kESDThetaY, !expert, image);
1020   
1021   // cluster info
1022   for (Int_t i = 0; i < nCh; i++) {
1023     Float_t rMax = AliMUONConstants::Rmax(i/2);
1024     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
1025                                        100, -rMax, rMax, 100, -rMax, rMax);
1026     Add2ESDsList(hESDClusterHitMap, kESDClusterHitMap+i, expert, !image);
1027   }
1028   
1029   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
1030   Add2ESDsList(hESDnClustersPerTrack, kESDnClustersPerTrack, !expert, image);
1031   
1032   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
1033   hESDnClustersPerCh->SetFillColor(kRed);
1034   Add2ESDsList(hESDnClustersPerCh, kESDnClustersPerCh, !expert, image);
1035   
1036   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
1037   hESDnClustersPerDE->SetFillColor(kRed);
1038   Add2ESDsList(hESDnClustersPerDE, kESDnClustersPerDE, !expert, image);
1039   
1040   for (Int_t i = 0; i < nCh; i++) {
1041     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
1042     Add2ESDsList(hESDClusterChargeInCh, kESDClusterChargeInCh+i, expert, !image);
1043   }
1044   
1045   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
1046   hESDClusterChargePerChMean->SetOption("P");
1047   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
1048   hESDClusterChargePerChMean->SetMarkerColor(kRed);
1049   Add2ESDsList(hESDClusterChargePerChMean, kESDClusterChargePerChMean, !expert, image);
1050   
1051   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
1052   hESDClusterChargePerChSigma->SetOption("P");
1053   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
1054   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
1055   Add2ESDsList(hESDClusterChargePerChSigma, kESDClusterChargePerChSigma, !expert, image);
1056   
1057   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
1058   hESDClusterChargePerDE->SetOption("P");
1059   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
1060   hESDClusterChargePerDE->SetMarkerColor(kRed);
1061   Add2ESDsList(hESDClusterChargePerDE, kESDClusterChargePerDE, !expert, image);
1062   
1063   for (Int_t i = 0; i < nCh; i++) {
1064     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
1065     Add2ESDsList(hESDClusterSizeInCh, kESDClusterSizeInCh+i, expert, !image);
1066   }
1067   
1068   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
1069   hESDClusterSizePerChMean->SetOption("P");
1070   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
1071   hESDClusterSizePerChMean->SetMarkerColor(kRed);
1072   Add2ESDsList(hESDClusterSizePerChMean, kESDClusterSizePerChMean, !expert, image);
1073   
1074   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
1075   hESDClusterSizePerChSigma->SetOption("P");
1076   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
1077   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
1078   Add2ESDsList(hESDClusterSizePerChSigma, kESDClusterSizePerChSigma, !expert, image);
1079   
1080   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
1081   hESDClusterSizePerDE->SetOption("P");
1082   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
1083   hESDClusterSizePerDE->SetMarkerColor(kRed);
1084   Add2ESDsList(hESDClusterSizePerDE, kESDClusterSizePerDE, !expert, image);
1085   
1086   // cluster - track info
1087   for (Int_t i = 0; i < nCh; i++) {
1088     TH1F* hESDResidualXInCh = new TH1F(Form("hESDResidualXInCh%d",i+1), Form("cluster-track residual-X distribution in chamber %d;#Delta_{X} (cm)",i+1), 1000, -5., 5.);
1089     Add2ESDsList(hESDResidualXInCh, kESDResidualXInCh+i, expert, !image);
1090     
1091     TH1F* hESDResidualYInCh = new TH1F(Form("hESDResidualYInCh%d",i+1), Form("cluster-track residual-Y distribution in chamber %d;#Delta_{Y} (cm)",i+1), 1000, -1., 1.);
1092     Add2ESDsList(hESDResidualYInCh, kESDResidualYInCh+i, expert, !image);
1093     
1094     TH1F* hESDLocalChi2XInCh = new TH1F(Form("hESDLocalChi2XInCh%d",i+1), Form("local chi2-X distribution in chamber %d;local #chi^{2}_{X}",i+1), 1000, 0., 25);
1095     Add2ESDsList(hESDLocalChi2XInCh, kESDLocalChi2XInCh+i, expert, !image);
1096     
1097     TH1F* hESDLocalChi2YInCh = new TH1F(Form("hESDLocalChi2YInCh%d",i+1), Form("local chi2-Y distribution in chamber %d;local #chi^{2}_{Y}",i+1), 1000, 0., 25);
1098     Add2ESDsList(hESDLocalChi2YInCh, kESDLocalChi2YInCh+i, expert, !image);
1099     
1100     TH1F* hESDLocalChi2InCh = new TH1F(Form("hESDLocalChi2InCh%d",i+1), Form("local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) distribution in chamber %d;local #chi^{2}",i+1), 1000, 0., 25);
1101     Add2ESDsList(hESDLocalChi2InCh, kESDLocalChi2InCh+i, expert, !image);
1102   }
1103   
1104   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
1105   hESDResidualXPerChMean->SetOption("P");
1106   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
1107   hESDResidualXPerChMean->SetMarkerColor(kRed);
1108   Add2ESDsList(hESDResidualXPerChMean, kESDResidualXPerChMean, !expert, image);
1109   
1110   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
1111   hESDResidualYPerChMean->SetOption("P");
1112   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
1113   hESDResidualYPerChMean->SetMarkerColor(kRed);
1114   Add2ESDsList(hESDResidualYPerChMean, kESDResidualYPerChMean, !expert, image);
1115   
1116   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
1117   hESDResidualXPerChSigma->SetOption("P");
1118   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
1119   hESDResidualXPerChSigma->SetMarkerColor(kRed);
1120   Add2ESDsList(hESDResidualXPerChSigma, kESDResidualXPerChSigma, !expert, image);
1121   
1122   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
1123   hESDResidualYPerChSigma->SetOption("P");
1124   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
1125   hESDResidualYPerChSigma->SetMarkerColor(kRed);
1126   Add2ESDsList(hESDResidualYPerChSigma, kESDResidualYPerChSigma, !expert, image);
1127   
1128   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerCh", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
1129   hESDLocalChi2XPerChMean->SetOption("P");
1130   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
1131   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
1132   Add2ESDsList(hESDLocalChi2XPerChMean, kESDLocalChi2XPerChMean, !expert, image);
1133   
1134   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerCh", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
1135   hESDLocalChi2YPerChMean->SetOption("P");
1136   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
1137   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
1138   Add2ESDsList(hESDLocalChi2YPerChMean, kESDLocalChi2YPerChMean, !expert, image);
1139   
1140   TH1F* hESDLocalChi2PerChMean = new TH1F("hESDLocalChi2PerCh", "local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per Ch: mean;chamber ID;<local #chi^{2}>", nCh, -0.5, nCh-0.5);
1141   hESDLocalChi2PerChMean->SetOption("P");
1142   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
1143   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
1144   Add2ESDsList(hESDLocalChi2PerChMean, kESDLocalChi2PerChMean, !expert, image);
1145   
1146   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
1147   hESDResidualXPerDEMean->SetOption("P");
1148   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
1149   hESDResidualXPerDEMean->SetMarkerColor(kRed);
1150   Add2ESDsList(hESDResidualXPerDEMean, kESDResidualXPerDEMean, !expert, image);
1151   
1152   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
1153   hESDResidualYPerDEMean->SetOption("P");
1154   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
1155   hESDResidualYPerDEMean->SetMarkerColor(kRed);
1156   Add2ESDsList(hESDResidualYPerDEMean, kESDResidualYPerDEMean, !expert, image);
1157   
1158   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
1159   hESDResidualXPerDESigma->SetOption("P");
1160   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
1161   hESDResidualXPerDESigma->SetMarkerColor(kRed);
1162   Add2ESDsList(hESDResidualXPerDESigma, kESDResidualXPerDESigma, !expert, image);
1163   
1164   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
1165   hESDResidualYPerDESigma->SetOption("P");
1166   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
1167   hESDResidualYPerDESigma->SetMarkerColor(kRed);
1168   Add2ESDsList(hESDResidualYPerDESigma, kESDResidualYPerDESigma, !expert, image);
1169   
1170   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDE", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
1171   hESDLocalChi2XPerDEMean->SetOption("P");
1172   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
1173   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
1174   Add2ESDsList(hESDLocalChi2XPerDEMean, kESDLocalChi2XPerDEMean, !expert, image);
1175   
1176   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDE", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
1177   hESDLocalChi2YPerDEMean->SetOption("P");
1178   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
1179   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
1180   Add2ESDsList(hESDLocalChi2YPerDEMean, kESDLocalChi2YPerDEMean, !expert, image);
1181   
1182   TH1F* hESDLocalChi2PerDEMean = new TH1F("hESDLocalChi2PerDE", "local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per DE: mean;DetElem ID;<local #chi^{2}>", nDE+1, -0.5, nDE+0.5);
1183   hESDLocalChi2PerDEMean->SetOption("P");
1184   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
1185   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
1186   Add2ESDsList(hESDLocalChi2PerDEMean, kESDLocalChi2PerDEMean, !expert, image);
1187   
1188   // intermediate histograms
1189   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
1190   Add2ESDsList(hESDnTotClustersPerCh, kESDnTotClustersPerCh, expert, !image);
1191   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
1192   Add2ESDsList(hESDnTotClustersPerDE, kESDnTotClustersPerDE, expert, !image);
1193   TH1F* hESDnTotFullClustersPerDE = new TH1F("hESDnTotFullClustersPerDE", "total number of associated clusters containing pad info per DE;DetElem ID;#Sigma(n_{full clusters})", nDE+1, -0.5, nDE+0.5);
1194   Add2ESDsList(hESDnTotFullClustersPerDE, kESDnTotFullClustersPerDE, expert, !image);
1195   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (fC)", nDE+1, -0.5, nDE+0.5);
1196   Add2ESDsList(hESDSumClusterChargePerDE, kESDSumClusterChargePerDE, expert, !image);
1197   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
1198   Add2ESDsList(hESDSumClusterSizePerDE, kESDSumClusterSizePerDE, expert, !image);
1199   TH1F* hESDSumResidualXPerDE = new TH1F("hESDSumResidualXPerDE", "sum of cluster-track residual-X per DE;DetElem ID;#Sigma(#Delta_{X}) (cm)", nDE+1, -0.5, nDE+0.5);
1200   Add2ESDsList(hESDSumResidualXPerDE, kESDSumResidualXPerDE, expert, !image);
1201   TH1F* hESDSumResidualYPerDE = new TH1F("hESDSumResidualYPerDE", "sum of cluster-track residual-Y per DE;DetElem ID;#Sigma(#Delta_{Y}) (cm)", nDE+1, -0.5, nDE+0.5);
1202   Add2ESDsList(hESDSumResidualYPerDE, kESDSumResidualYPerDE, expert, !image);
1203   TH1F* hESDSumResidualX2PerDE = new TH1F("hESDSumResidualX2PerDE", "sum of cluster-track residual-X**2 per DE;DetElem ID;#Sigma(#Delta_{X}^{2}) (cm^{2})", nDE+1, -0.5, nDE+0.5);
1204   Add2ESDsList(hESDSumResidualX2PerDE, kESDSumResidualX2PerDE, expert, !image);
1205   TH1F* hESDSumResidualY2PerDE = new TH1F("hESDSumResidualY2PerDE", "sum of cluster-track residual-Y**2 per DE;DetElem ID;#Sigma(#Delta_{Y}^{2}) (cm^{2})", nDE+1, -0.5, nDE+0.5);
1206   Add2ESDsList(hESDSumResidualY2PerDE, kESDSumResidualY2PerDE, expert, !image);
1207   TH1F* hESDSumLocalChi2XPerDE = new TH1F("hESDSumLocalChi2XPerDE", "sum of local chi2-X per DE;DetElem ID;#Sigma(local #chi^{2}_{X})", nDE+1, -0.5, nDE+0.5);
1208   Add2ESDsList(hESDSumLocalChi2XPerDE, kESDSumLocalChi2XPerDE, expert, !image);
1209   TH1F* hESDSumLocalChi2YPerDE = new TH1F("hESDSumLocalChi2YPerDE", "sum of local chi2-Y per DE;DetElem ID;#Sigma(local #chi^{2}_{Y})", nDE+1, -0.5, nDE+0.5);
1210   Add2ESDsList(hESDSumLocalChi2YPerDE, kESDSumLocalChi2YPerDE, expert, !image);
1211   TH1F* hESDSumLocalChi2PerDE = new TH1F("hESDSumLocalChi2PerDE", "sum of local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per DE;DetElem ID;#Sigma(local #chi^{2})", nDE+1, -0.5, nDE+0.5);
1212   Add2ESDsList(hESDSumLocalChi2PerDE, kESDSumLocalChi2PerDE, expert, !image);
1213 }
1214
1215 //____________________________________________________________________________
1216 void AliMUONQADataMakerRec::MakeRaws(AliRawReader* rawReader)
1217 {
1218     /// make QA for rawdata
1219
1220     // Check id histograms already created for this Event Specie
1221
1222   AliDebug(AliQAv1::GetQADebugLevel(),
1223            Form("RAW event type %s", AliRawEventHeaderBase::GetTypeName(rawReader->GetType())));
1224   
1225   if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ) 
1226   {
1227     rawReader->Reset();
1228     MakeRawsTracker(rawReader);
1229   }
1230   
1231   if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ||
1232        rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent ) 
1233   {
1234     rawReader->Reset();    
1235     MakeRawsTrigger(rawReader);
1236   }
1237 }
1238
1239 //____________________________________________________________________________
1240 void AliMUONQADataMakerRec::MakeRawsTracker(AliRawReader* rawReader)
1241 {
1242         /// make QA for rawdata tracker
1243         
1244   /// forces init
1245   GetRawsData(kTrackerBusPatchOccupancy);
1246   
1247         ((AliMUONTrackerDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader);
1248         
1249         fTrackerDataMaker->ProcessEvent();
1250 }
1251
1252 //____________________________________________________________________________
1253 void AliMUONQADataMakerRec::MakeRawsTrigger(AliRawReader* rawReader)
1254 {
1255         /// make QA for rawdata trigger
1256         
1257
1258     GetRawsData(kRawNAnalyzedEvents)->Fill(1.);
1259
1260     // Init Local/Regional/Global decision with fake values
1261  
1262     Int_t globaltemp[4];
1263     for (Int_t bit=0; bit<4; bit++){
1264         globaltemp[bit]=0;
1265         fgitmp[bit]=0;
1266     }
1267
1268     for (Int_t loc=0;loc<235;loc++){
1269         fTriggerErrorLocalYCopy[loc]=kFALSE;
1270
1271         fTriggerOutputLocalRecTriggerDec[loc]=0;
1272         fTriggerOutputLocalRecLPtDec[0][loc]=0;
1273         fTriggerOutputLocalRecLPtDec[1][loc]=0;
1274         fTriggerOutputLocalRecHPtDec[0][loc]=0;
1275         fTriggerOutputLocalRecHPtDec[1][loc]=0;
1276         fTriggerOutputLocalRecXPos[loc]=0;
1277         fTriggerOutputLocalRecYPos[loc]=15;
1278         fTriggerOutputLocalRecDev[loc]=0;
1279         fTriggerOutputLocalRecTrigY[loc]=1;
1280
1281         fTriggerOutputLocalDataTriggerDec[loc]=0;
1282         fTriggerOutputLocalDataLPtDec[0][loc]=0;
1283         fTriggerOutputLocalDataLPtDec[1][loc]=0;
1284         fTriggerOutputLocalDataHPtDec[0][loc]=0;
1285         fTriggerOutputLocalDataHPtDec[1][loc]=0;
1286         fTriggerOutputLocalDataXPos[loc]=0;
1287         fTriggerOutputLocalDataYPos[loc]=15;
1288         fTriggerOutputLocalDataDev[loc]=0;
1289         fTriggerOutputLocalDataTrigY[loc]=1;
1290         fTriggerInputRegionalDataLPt[0][loc]=0;
1291         fTriggerInputRegionalDataLPt[1][loc]=0;
1292         fTriggerInputRegionalDataHPt[0][loc]=0;
1293         fTriggerInputRegionalDataHPt[1][loc]=0; 
1294     }
1295
1296     for (Int_t reg=0;reg<16;reg++){
1297         fTriggerOutputRegionalData[reg]=0;
1298         for (Int_t bit=0;bit<4;bit++){
1299             fTriggerInputGlobalDataLPt[reg][bit]=0;
1300             fTriggerInputGlobalDataHPt[reg][bit]=0;
1301         }
1302     }
1303
1304     for (Int_t bit=0;bit<6;bit++){
1305         fgotmp[bit]=0;
1306         fTriggerOutputGlobalData[bit]=0;
1307         fTriggerOutputGlobalRecFromGlobalInput[bit]=0;
1308     }
1309
1310     for (Int_t loc=0;loc<243;loc++){
1311         for (Int_t bit=0;bit<16;bit++){
1312             fTriggerPatternX1[loc][bit]=0;
1313             fTriggerPatternX2[loc][bit]=0;
1314             fTriggerPatternX3[loc][bit]=0;
1315             fTriggerPatternX4[loc][bit]=0;
1316
1317             fTriggerPatternY1[loc][bit]=0;
1318             fTriggerPatternY2[loc][bit]=0;
1319             fTriggerPatternY3[loc][bit]=0;
1320             fTriggerPatternY4[loc][bit]=0;
1321         }
1322     }
1323
1324     AliMUONDigitStoreV2R digitStore;
1325     digitStore.Create();
1326     digitStore.Clear();
1327
1328     
1329     AliMUONTriggerStoreV1 triggerStore;
1330     triggerStore.Create();
1331     triggerStore.Clear();
1332     
1333     // Get trigger Local, Regional, Global in/outputs and scalers
1334
1335     Int_t loCircuit=0;
1336     AliMpCDB::LoadDDLStore();
1337
1338     const AliMUONRawStreamTriggerHP::AliHeader*          darcHeader  = 0x0;
1339     const AliMUONRawStreamTriggerHP::AliRegionalHeader*  regHeader   = 0x0;
1340     const AliMUONRawStreamTriggerHP::AliLocalStruct*     localStruct = 0x0;
1341
1342     AliMUONRawStreamTriggerHP rawStreamTrig(rawReader);
1343     
1344     while (rawStreamTrig.NextDDL()) 
1345     {
1346       Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
1347
1348       darcHeader = rawStreamTrig.GetHeaders();
1349
1350       if (darcHeader->GetGlobalFlag()){
1351         UInt_t nOfClocks = darcHeader->GetGlobalClock();
1352         Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
1353         ((TH1F*)GetRawsData(kTriggerScalersTime))->Fill(1., nOfSeconds);
1354
1355         //Get Global datas
1356         for (Int_t bit=1; bit<7; bit++){
1357           fTriggerOutputGlobalData[bit-1]=Int_t(((darcHeader->GetGlobalOutput())>>bit)&1);
1358         }
1359         for (Int_t Bit=0; Bit<32; Bit++){
1360           fTriggerInputGlobalDataLPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(0)>>Bit)&1);
1361           fTriggerInputGlobalDataLPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(1)>>Bit)&1);
1362           fTriggerInputGlobalDataHPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(2)>>Bit)&1);
1363           fTriggerInputGlobalDataHPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(3)>>Bit)&1);
1364         }
1365
1366         globaltemp[0]=darcHeader->GetGlobalInput(0);
1367         globaltemp[1]=darcHeader->GetGlobalInput(1);
1368         globaltemp[2]=darcHeader->GetGlobalInput(2);
1369         globaltemp[3]=darcHeader->GetGlobalInput(3);
1370       }
1371     
1372       Int_t nReg = rawStreamTrig.GetRegionalHeaderCount();
1373
1374       for(Int_t iReg = 0; iReg < nReg ;iReg++)
1375       {   //reg loop
1376
1377           Int_t regId=rawStreamTrig.GetDDL()*8+iReg;
1378
1379         // crate info  
1380           AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->GetTriggerCrate(rawStreamTrig.GetDDL(), iReg);
1381
1382           regHeader =  rawStreamTrig.GetRegionalHeader(iReg);
1383
1384         //Get regional outputs -> not checked, hardware read-out doesn't work
1385         fTriggerOutputRegionalData[regId]=Int_t(regHeader->GetOutput());
1386
1387         // loop over local structures
1388         Int_t nLocal = regHeader->GetLocalStructCount();
1389
1390         for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
1391         {
1392             
1393             localStruct = regHeader->GetLocalStruct(iLocal);
1394
1395           // if card exist
1396           if (!localStruct) continue;
1397           
1398           loCircuit = crate->GetLocalBoardId(localStruct->GetId());
1399
1400           if ( !loCircuit ) continue; // empty slot
1401
1402           AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
1403
1404           // skip copy cards
1405           if( !localBoard->IsNotified()) 
1406             continue;
1407
1408           TArrayS xyPattern[2];
1409           
1410           localStruct->GetXPattern(xyPattern[0]);
1411           localStruct->GetYPattern(xyPattern[1]);
1412
1413           fDigitMaker->TriggerDigits(loCircuit, xyPattern, digitStore);
1414
1415           Int_t cathode = localStruct->GetComptXY()%2;
1416
1417           //Get electronic Decisions from data
1418
1419           //Get regional inputs -> not checked, hardware read-out doesn't work
1420           fTriggerInputRegionalDataLPt[0][loCircuit]=Int_t(((regHeader->GetInput(0))>>(2*iLocal))&1);
1421           fTriggerInputRegionalDataLPt[1][loCircuit]=Int_t(((regHeader->GetInput(1))>>((2*iLocal)+1))&1);
1422           
1423           //Get local in/outputs
1424           if (Int_t(localStruct->GetDec())!=0){
1425               fTriggerOutputLocalDataTriggerDec[loCircuit]++;
1426           }
1427           
1428           fTriggerOutputLocalDataLPtDec[0][loCircuit]=((localStruct->GetLpt())&1);
1429           fTriggerOutputLocalDataLPtDec[1][loCircuit]=((localStruct->GetLpt()>>1)&1);
1430           fTriggerOutputLocalDataHPtDec[0][loCircuit]=((localStruct->GetHpt())&1);
1431           fTriggerOutputLocalDataHPtDec[1][loCircuit]=((localStruct->GetHpt()>>1)&1);
1432           fTriggerOutputLocalDataXPos[loCircuit]=Int_t(localStruct->GetXPos());
1433           fTriggerOutputLocalDataYPos[loCircuit]=Int_t(localStruct->GetYPos());
1434           fTriggerOutputLocalDataDev[loCircuit]=Int_t((localStruct->GetXDev())*(pow(-1.0,(localStruct->GetSXDev()))));
1435           fTriggerOutputLocalDataTrigY[loCircuit]=Int_t(localStruct->GetTrigY());
1436           
1437           UShort_t x1  = (Int_t)localStruct->GetX1();
1438           UShort_t x2  = (Int_t)localStruct->GetX2();
1439           UShort_t x3  = (Int_t)localStruct->GetX3();
1440           UShort_t x4  = (Int_t)localStruct->GetX4();
1441
1442           UShort_t y1  = (Int_t)localStruct->GetY1();
1443           UShort_t y2  = (Int_t)localStruct->GetY2();
1444           UShort_t y3  = (Int_t)localStruct->GetY3();
1445           UShort_t y4  = (Int_t)localStruct->GetY4();
1446
1447           // loop over strips
1448           for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
1449
1450               fTriggerPatternX1[loCircuit][ibitxy]=Int_t((x1>>ibitxy)&1);
1451               fTriggerPatternX2[loCircuit][ibitxy]=Int_t((x2>>ibitxy)&1);
1452               fTriggerPatternX3[loCircuit][ibitxy]=Int_t((x3>>ibitxy)&1);
1453               fTriggerPatternX4[loCircuit][ibitxy]=Int_t((x4>>ibitxy)&1);
1454               
1455               fTriggerPatternY1[loCircuit][ibitxy]=Int_t((y1>>ibitxy)&1);
1456               fTriggerPatternY2[loCircuit][ibitxy]=Int_t((y2>>ibitxy)&1);
1457               fTriggerPatternY3[loCircuit][ibitxy]=Int_t((y3>>ibitxy)&1);
1458               fTriggerPatternY4[loCircuit][ibitxy]=Int_t((y4>>ibitxy)&1);
1459               
1460               if (scalerEvent){
1461                   if (ibitxy==0){
1462                       AliDebug(AliQAv1::GetQADebugLevel(),"Filling trigger scalers");
1463                   }
1464                   
1465                   if(localStruct->GetXY1(ibitxy) > 0)
1466                       ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 0))
1467                           ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY1(ibitxy));
1468                   if(localStruct->GetXY2(ibitxy) > 0)
1469                       ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 1))
1470                           ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY2(ibitxy));
1471                   if(localStruct->GetXY3(ibitxy) > 0)
1472                       ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 2))
1473                           ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY3(ibitxy));
1474                   if(localStruct->GetXY4(ibitxy) > 0)
1475                       ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 3))
1476                           ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY4(ibitxy));
1477               }
1478           } // loop on strips
1479         } // iLocal
1480       } // iReg
1481     } // NextDDL
1482
1483   fTriggerProcessor->Digits2Trigger(digitStore,triggerStore);
1484
1485   TIter next(triggerStore.CreateLocalIterator());
1486   AliMUONLocalTrigger *localTrigger;
1487
1488   while ( ( localTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
1489   {
1490     
1491       //... extract information
1492       loCircuit = localTrigger->LoCircuit();
1493
1494       AliMpLocalBoard* localBoardMp = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit);  // get local board objectfor switch value
1495       if (localTrigger->GetLoDecision() != 0){
1496           fTriggerOutputLocalRecTriggerDec[loCircuit]++;
1497       }
1498       
1499       fTriggerOutputLocalRecLPtDec[0][loCircuit]=Int_t(localTrigger->LoLpt() & 1);
1500       fTriggerOutputLocalRecLPtDec[1][loCircuit]=Int_t((localTrigger->LoLpt()>>1) & 1);
1501       fTriggerOutputLocalRecHPtDec[0][loCircuit]=Int_t(localTrigger->LoHpt() & 1);
1502       fTriggerOutputLocalRecHPtDec[1][loCircuit]=Int_t((localTrigger->LoHpt()>>1) & 1);
1503       fTriggerOutputLocalRecXPos[loCircuit]=localTrigger->LoStripX();
1504       fTriggerOutputLocalRecYPos[loCircuit]=localTrigger->LoStripY();
1505       fTriggerOutputLocalRecTrigY[loCircuit]=localTrigger->LoTrigY();
1506       fTriggerOutputLocalRecDev[loCircuit]=Int_t(localTrigger->LoDev()*(pow(-1.,localTrigger->LoSdev())));
1507
1508       Bool_t firstFillYCopy=kTRUE;
1509
1510       for (int bit=0; bit<16; bit++){
1511           if (fTriggerPatternY1[loCircuit][bit]!=((localTrigger->GetY1Pattern()>>bit) & 1))
1512           {
1513               fTriggerErrorLocalYCopy[loCircuit]=kTRUE;
1514               if (firstFillYCopy){
1515                   ((TH1F*)GetRawsData(kTriggerErrorLocalYCopy))->Fill(loCircuit);
1516                   ((TH1F*)GetRawsData(kTriggerError))->Fill(3);
1517                   firstFillYCopy=kFALSE;
1518               }
1519           }
1520           if (fTriggerPatternY2[loCircuit][bit]!=((localTrigger->GetY2Pattern()>>bit) & 1))
1521           {
1522               fTriggerErrorLocalYCopy[loCircuit]=kTRUE;
1523               if (firstFillYCopy){
1524                   ((TH1F*)GetRawsData(kTriggerErrorLocalYCopy))->Fill(loCircuit);
1525                   ((TH1F*)GetRawsData(kTriggerError))->Fill(3);
1526                   firstFillYCopy=kFALSE;
1527               }
1528           }
1529           if (fTriggerPatternY3[loCircuit][bit]!=((localTrigger->GetY3Pattern()>>bit) & 1))
1530           {
1531               fTriggerErrorLocalYCopy[loCircuit]=kTRUE;
1532               if (localBoardMp->GetSwitch(4)) fTriggerErrorLocalYCopy[loCircuit-1]=kTRUE;
1533               if (localBoardMp->GetSwitch(3)) fTriggerErrorLocalYCopy[loCircuit+1]=kTRUE;
1534               if (firstFillYCopy){
1535                   ((TH1F*)GetRawsData(kTriggerErrorLocalYCopy))->Fill(loCircuit);
1536                   ((TH1F*)GetRawsData(kTriggerError))->Fill(3);
1537                   firstFillYCopy=kFALSE;
1538               }
1539           }
1540           if (fTriggerPatternY4[loCircuit][bit]!=((localTrigger->GetY4Pattern()>>bit) & 1))
1541           {
1542               fTriggerErrorLocalYCopy[loCircuit]=kTRUE;
1543               if (localBoardMp->GetSwitch(4)) fTriggerErrorLocalYCopy[loCircuit-1]=kTRUE;
1544               if (localBoardMp->GetSwitch(3)) fTriggerErrorLocalYCopy[loCircuit+1]=kTRUE;
1545               if (firstFillYCopy){
1546                   ((TH1F*)GetRawsData(kTriggerErrorLocalYCopy))->Fill(loCircuit);
1547                   ((TH1F*)GetRawsData(kTriggerError))->Fill(3);
1548                   firstFillYCopy=kFALSE;
1549               }
1550           }
1551       }
1552   }
1553
1554     //Reconstruct Global decision from Global inputs
1555     for (Int_t bit=0; bit<4; bit++){
1556         for (Int_t i=0; i<32; i=i+4){
1557             fgitmp[bit]+=UInt_t(((globaltemp[bit]>>i)&1)*pow(2.0,i+1));
1558             fgitmp[bit]+=UInt_t(((globaltemp[bit]>>(i+1))&1)*pow(2.0,i));
1559             fgitmp[bit]+=UInt_t(((globaltemp[bit]>>(i+2))&1)*pow(2.0,i+2));
1560             fgitmp[bit]+=UInt_t(((globaltemp[bit]>>(i+3))&1)*pow(2.0,i+3));
1561             }
1562     }
1563     RawTriggerInGlobal2OutGlobal();
1564     for (Int_t bit=0; bit<6; bit++){
1565         fTriggerOutputGlobalRecFromGlobalInput[bit]=fgotmp[bit];
1566     }
1567
1568     // Compare data and reconstructed decisions and fill histos
1569     RawTriggerMatchOutLocal();
1570     RawTriggerMatchOutLocalInRegional(); // Not tested, hardware read-out doesn't work
1571     RawTriggerMatchOutGlobalFromInGlobal();
1572 }
1573
1574 //__________________________________________________________________
1575 void AliMUONQADataMakerRec::MakeDigits(TTree* digitsTree)         
1576 {
1577   /// makes data from Digits
1578
1579   // Do nothing in case of calibration event
1580   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1581
1582   if (!fDigitStore)
1583     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1584   fDigitStore->Connect(*digitsTree, false);
1585   digitsTree->GetEvent(0);
1586   
1587   TIter next(fDigitStore->CreateIterator());
1588   
1589   AliMUONVDigit* dig = 0x0;
1590   
1591   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1592     {
1593     GetDigitsData(0)->Fill(dig->DetElemId());
1594     GetDigitsData(1)->Fill(dig->ADC());
1595     }
1596 }
1597
1598 //____________________________________________________________________________
1599 void AliMUONQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1600 {
1601         /// Fill histograms from treeR
1602
1603   // Do nothing in case of calibration event
1604   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1605         
1606   GetRecPointsData(kNAnalyzedEvents)->Fill(1.);
1607
1608   MakeRecPointsTracker(clustersTree);
1609         MakeRecPointsTrigger(clustersTree);
1610 }
1611
1612
1613
1614 //____________________________________________________________________________
1615 void AliMUONQADataMakerRec::MakeRecPointsTracker(TTree* clustersTree)
1616 {
1617         /// Fill histograms related to tracker clusters 
1618         
1619         // First things first : do we have clusters in the TreeR ?
1620         // In "normal" production mode, it should be perfectly normal
1621         // *not* to have them.
1622         // But if for some reason we de-activated the combined tracking,
1623         // then we have clusters in TreeR, so let's take that opportunity
1624         // to QA them...
1625         
1626   AliCodeTimerAuto("",0);
1627
1628   // Do nothing in case of calibration event
1629   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1630
1631         if (!fClusterStore)
1632         {
1633           AliCodeTimerAuto("ClusterStore creation",1);
1634                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1635                 if (!fClusterStore) 
1636                 {
1637                         return;
1638                 }
1639         }
1640         
1641         fClusterStore->Connect(*clustersTree,kFALSE);
1642         clustersTree->GetEvent(0);
1643
1644         TIter next(fClusterStore->CreateIterator());
1645         AliMUONVCluster* cluster;
1646         
1647   if ( fMappingCheckRecPoints ) fMappingCheckRecPoints->NewEvent();
1648   
1649         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1650         {
1651                 Int_t detElemId = cluster->GetDetElemId();
1652                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1653                 
1654                 GetRecPointsData(kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1655                 GetRecPointsData(kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1656                 GetRecPointsData(kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1657
1658                 GetRecPointsData(kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1659                 GetRecPointsData(kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1660                 GetRecPointsData(kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1661                 GetRecPointsData(kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1662                 
1663     if ( fMappingCheckRecPoints ) fMappingCheckRecPoints->Store(*cluster);
1664     
1665         }
1666         
1667         fClusterStore->Clear();
1668 }
1669
1670 //____________________________________________________________________________
1671 void AliMUONQADataMakerRec::MakeRecPointsTrigger(TTree* clustersTree)
1672 {
1673         /// makes data from trigger response
1674
1675   AliCodeTimerAuto("",0);
1676
1677     // Fired pads info
1678     fDigitStore->Clear();
1679
1680     AliMUONVTriggerStore *triggerStore = AliMUONVTriggerStore::Create(*clustersTree);
1681     triggerStore->Clear();
1682     triggerStore->Connect(*clustersTree, false);
1683     clustersTree->GetEvent(0);
1684
1685     AliMUONLocalTrigger* locTrg;
1686     TIter nextLoc(triggerStore->CreateLocalIterator());
1687
1688     while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(nextLoc()) ) ) 
1689     {
1690       if (locTrg->IsNull()) continue;
1691    
1692       TArrayS xyPattern[2];
1693       locTrg->GetXPattern(xyPattern[0]);
1694       locTrg->GetYPattern(xyPattern[1]);
1695
1696       Int_t nBoard = locTrg->LoCircuit();
1697
1698       Bool_t xTrig=locTrg->IsTrigX();
1699       Bool_t yTrig=locTrg->IsTrigY();
1700     
1701       if (xTrig && yTrig)
1702         ((TH1F*)GetRecPointsData(kTriggeredBoards))->Fill(nBoard);
1703
1704       fDigitMaker->TriggerDigits(nBoard, xyPattern, *fDigitStore);
1705     }
1706
1707     TIter nextDigit(fDigitStore->CreateIterator());
1708     AliMUONVDigit* mDigit;
1709     while ( ( mDigit = static_cast<AliMUONVDigit*>(nextDigit()) ) )
1710     {
1711       Int_t detElemId = mDigit->DetElemId();
1712       Int_t ch = detElemId/100;
1713       Int_t localBoard = mDigit->ManuId();
1714       Int_t channel = mDigit->ManuChannel();
1715       Int_t cathode = mDigit->Cathode();
1716       Int_t iChamber = ch - 11;
1717       
1718       ((TH2F*)GetRecPointsData(kTriggerDigits + AliMpConstants::NofTriggerChambers()*cathode + iChamber))
1719         ->Fill(localBoard, channel);
1720     }
1721
1722     delete triggerStore;
1723 }
1724
1725 //____________________________________________________________________________
1726 void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
1727 {
1728   /// make QA data from ESDs
1729
1730   AliCodeTimerAuto("",0);
1731   
1732   // Do nothing in case of calibration event
1733   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1734   
1735   // load ESD event in the interface
1736   AliMUONESDInterface esdInterface;
1737   if (GetMUONRecoParam()) AliMUONESDInterface::ResetTracker(GetMUONRecoParam());
1738   else AliError("Unable to get recoParam: use default ones for residual calculation");
1739   esdInterface.LoadEvent(*esd);
1740   
1741   GetESDsData(kESDnTracks)->Fill(esdInterface.GetNTracks());
1742   
1743   Int_t nTrackMatchTrig = 0;
1744   
1745   // loop over tracks
1746   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1747   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1748     
1749     // get the ESD track and skip "ghosts"
1750     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1751     if (!esdTrack->ContainTrackerData()) continue;
1752     
1753     // get corresponding MUON track
1754     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1755     
1756     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1757     
1758     GetESDsData(kESDMomentum)->Fill(esdTrack->P());
1759     GetESDsData(kESDPt)->Fill(esdTrack->Pt());
1760     GetESDsData(kESDRapidity)->Fill(esdTrack->Y());
1761     GetESDsData(kESDChi2)->Fill(track->GetNormalizedChi2());
1762     GetESDsData(kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1763     GetESDsData(kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1764     GetESDsData(kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1765     GetESDsData(kESDnClustersPerTrack)->Fill(track->GetNClusters());
1766     
1767     // loop over clusters
1768     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1769     while (trackParam) {
1770       
1771       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1772       Int_t chId = cluster->GetChamberId();
1773       Int_t deID = cluster->GetDetElemId();
1774       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1775       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1776       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1777       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1778       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1779       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1780       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1781       
1782       GetESDsData(kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1783       
1784       GetESDsData(kESDnTotClustersPerCh)->Fill(chId);
1785       GetESDsData(kESDnTotClustersPerDE)->Fill(deID);
1786       
1787       GetESDsData(kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1788       GetESDsData(kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1789       
1790       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1791         GetESDsData(kESDnTotFullClustersPerDE)->Fill(deID);
1792         GetESDsData(kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1793         GetESDsData(kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1794       }
1795       
1796       GetESDsData(kESDResidualXInCh+chId)->Fill(residualX);
1797       GetESDsData(kESDResidualYInCh+chId)->Fill(residualY);
1798       GetESDsData(kESDSumResidualXPerDE)->Fill(deID, residualX);
1799       GetESDsData(kESDSumResidualYPerDE)->Fill(deID, residualY);
1800       GetESDsData(kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1801       GetESDsData(kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1802       
1803       GetESDsData(kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1804       GetESDsData(kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1805       GetESDsData(kESDLocalChi2InCh+chId)->Fill(localChi2);
1806       GetESDsData(kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1807       GetESDsData(kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1808       GetESDsData(kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1809       
1810       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1811       
1812     }
1813     
1814   }
1815
1816   GetESDsData(kESDMatchTrig)->Fill(nTrackMatchTrig);
1817   
1818 }
1819
1820 //____________________________________________________________________________ 
1821 void AliMUONQADataMakerRec::StartOfDetectorCycle()
1822 {
1823     /// Detector specific actions at start of cycle
1824   
1825 }
1826
1827 //____________________________________________________________________________ 
1828 void AliMUONQADataMakerRec::DisplayTriggerInfo(AliQAv1::TASKINDEX_t task)
1829 {
1830   //
1831   /// Display trigger information in a user-friendly way:
1832   /// from local board and strip numbers to their position on chambers
1833   //
1834   
1835
1836   if(task!=AliQAv1::kRECPOINTS && task!=AliQAv1::kRAWS) return;
1837
1838   // check we get histograms, otherwise return right now
1839   if ( task == AliQAv1::kRECPOINTS )
1840   {
1841     if ( !GetRecPointsData(kTriggerDigits) ) return;
1842   }
1843   
1844   if ( task == AliQAv1::kRAWS ) 
1845   {
1846     if ( !GetRawsData(kTriggerScalers) ) return;
1847   }
1848   
1849   AliMUONTriggerDisplay triggerDisplay;
1850   
1851   TH2F* histoStrips=0x0;
1852   TH2F* histoDisplayStrips=0x0;
1853   AliMUONTriggerDisplay::EDisplayOption displayOption = AliMUONTriggerDisplay::kDefaultDisplay;
1854   if(task == AliQAv1::kRAWS) displayOption = AliMUONTriggerDisplay::kNormalizeToArea;
1855
1856   for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
1857   {    
1858     for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
1859     {
1860       if(task==AliQAv1::kRECPOINTS){
1861         histoStrips = (TH2F*)GetRecPointsData(kTriggerDigits + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1862       }
1863       else if(task==AliQAv1::kRAWS){
1864         histoStrips = (TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1865       }
1866
1867       if(histoStrips->GetEntries()==0) continue; // No events found => No need to display
1868
1869       if(task==AliQAv1::kRECPOINTS){
1870         histoDisplayStrips = (TH2F*)GetRecPointsData(kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1871       }
1872       else if(task==AliQAv1::kRAWS){
1873         histoDisplayStrips = (TH2F*)GetRawsData(kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1874       }
1875
1876       triggerDisplay.FillDisplayHistogram(histoStrips, histoDisplayStrips,
1877                                           AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber, displayOption);
1878
1879       Float_t scaleValue = 0.;
1880       if(task==AliQAv1::kRAWS) {
1881         scaleValue = ((TH1F*)GetRawsData(kTriggerScalersTime))->GetBinContent(1);
1882       }
1883       else if ( task == AliQAv1::kRECPOINTS ) {
1884         scaleValue = GetRecPointsData(kNAnalyzedEvents)->GetBinContent(1);
1885       }
1886       if(scaleValue>0.) histoDisplayStrips->Scale(1./scaleValue);
1887     } // iChamber
1888   } // iCath
1889
1890   if(task==AliQAv1::kRECPOINTS){
1891     TH1F* histoBoards = (TH1F*)GetRecPointsData(kTriggeredBoards);
1892     TH2F* histoDisplayBoards = (TH2F*)GetRecPointsData(kTriggerBoardsDisplay);
1893     triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
1894     Float_t scaleValue = GetRecPointsData(kNAnalyzedEvents)->GetBinContent(1);
1895     if(scaleValue>0.) histoDisplayBoards->Scale(1./scaleValue);
1896   }
1897 }
1898
1899
1900 //_____________________________________________________________________________
1901 Bool_t 
1902 AliMUONQADataMakerRec::FillTriggerDCSHistos()
1903 {
1904   /// Get HV and currents values for one trigger chamber
1905   
1906   AliCodeTimerAuto("",0);
1907
1908   TMap* triggerDcsMap = fCalibrationData->TriggerDCS();
1909
1910   if ( !triggerDcsMap ) 
1911   {
1912     AliError("Cannot fill DCS histos, as triggerDcsMap is NULL");
1913     return kFALSE;
1914   }
1915
1916   AliMpDEIterator deIt;
1917   
1918   deIt.First();
1919     
1920   AliMpDCSNamer triggerDcsNamer("TRIGGER");
1921
1922   TH2* currHisto = 0x0;
1923   Int_t histoIndex = 0;
1924   TString histoName, histoTitle;
1925
1926   Bool_t error = kFALSE;
1927   Bool_t expert   = kTRUE;
1928   Bool_t saveCorr = kTRUE;
1929   Bool_t image    = kTRUE;
1930   
1931   while ( !deIt.IsDone() )
1932   {
1933     Int_t detElemId = deIt.CurrentDEId();
1934     
1935     if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStationTrigger) {
1936
1937       Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
1938       Int_t slat = detElemId%100;
1939
1940       for(Int_t iMeas=0; iMeas<AliMpDCSNamer::kNDCSMeas; iMeas++){
1941         TString currAlias = triggerDcsNamer.DCSChannelName(detElemId, 0, iMeas);
1942
1943         AliDebug(AliQAv1::GetQADebugLevel(), Form("\nDetElemId %i   dcsAlias %s", detElemId, currAlias.Data()));
1944
1945         TPair* triggerDcsPair = static_cast<TPair*>(triggerDcsMap->FindObject(currAlias.Data()));
1946
1947         if (!triggerDcsPair)
1948         {
1949           AliError(Form("Did not find expected alias (%s) for DE %d",
1950                         currAlias.Data(),detElemId));  
1951           error = kTRUE;
1952         }
1953         else
1954         {
1955           TObjArray* values = static_cast<TObjArray*>(triggerDcsPair->Value());
1956           if (!values)
1957           {
1958             AliError(Form("Could not get values for alias %s",currAlias.Data()));
1959             error = kTRUE;
1960           }
1961           else
1962           {
1963             TIter next(values);
1964             AliDCSValue* val = 0x0;
1965
1966             Int_t ich = iChamber - AliMpConstants::NofTrackingChambers();
1967
1968             switch(iMeas){
1969             case AliMpDCSNamer::kDCSI:
1970               histoIndex = kTriggerRPCi + ich;
1971               histoName = Form("hRPCIChamber%i", 11+ich);
1972               histoTitle = Form("Chamber %i: RPC Currents (#muA)", 11+ich);
1973               break;
1974             case AliMpDCSNamer::kDCSHV:
1975               histoIndex = kTriggerRPChv + ich;
1976               histoName = Form("hRPCHVChamber%i", 11+ich);
1977               histoTitle = Form("Chamber %i: RPC HV (V)", 11+ich);
1978               break;
1979             }
1980
1981             currHisto = (TH2F*) GetRawsData(histoIndex);
1982
1983             if(!currHisto){
1984               Int_t npoints = values->GetEntries();
1985               TArrayF axisSlat(18+1), axisTime(npoints+1);
1986               for(Int_t islat=0; islat<=18; islat++){
1987                 axisSlat[islat] = -0.5 + (Float_t)islat;
1988               }
1989               for(Int_t ientry=0; ientry<npoints; ientry++){
1990                 val = static_cast<AliDCSValue*>(values->At(ientry));
1991                 axisTime[ientry] = val->GetTimeStamp();
1992               }
1993               axisTime[npoints] = val->GetTimeStamp() + 100;
1994
1995               currHisto  = new TH2F(histoName.Data(), histoTitle.Data(),
1996                                     npoints, axisTime.GetArray(),
1997                                     18, axisSlat.GetArray());
1998               currHisto->GetXaxis()->SetTitle("Time");
1999               currHisto->GetXaxis()->SetTimeDisplay(1);
2000               //currHisto->GetXaxis()->SetTimeFormat("%d%b%y %H:%M:%S");
2001               currHisto->GetYaxis()->SetTitle("RPC");
2002               currHisto->SetOption("COLZ");
2003               Add2RawsList(currHisto, histoIndex, !expert, image, !saveCorr);
2004             }
2005
2006             while ( ( val = static_cast<AliDCSValue*>(next()) ) )
2007             {
2008               Float_t hvi = val->GetFloat();
2009
2010               AliDebug(AliQAv1::GetQADebugLevel(), Form("Value %f", hvi));
2011  
2012               currHisto->Fill(1.0001 * val->GetTimeStamp(), slat, hvi);
2013             } // loop on values
2014           } // if (!values)
2015         } // if (!triggerDcsPair)
2016       } // loop on measured types (HV and currents)
2017     } // if (stationType == kStationTrigger)
2018
2019     deIt.Next();
2020   }
2021   return error;
2022 }
2023
2024 //____________________________________________________________________________ 
2025 AliMUONVTrackerData* AliMUONQADataMakerRec::GetTrackerData() const
2026
2027 /// Return tracker data
2028   
2029   return fTrackerDataMaker->Data(); 
2030   
2031 }
2032
2033 //____________________________________________________________________________ 
2034 void
2035 AliMUONQADataMakerRec::BeautifyTrackerBusPatchOccupancy(TH1& hbp)
2036 {
2037   /// Put labels, limits and so on on the TrackerBusPatchOccupancy histogram
2038   
2039   hbp.SetXTitle("Absolute Bus Patch Id");
2040   hbp.SetYTitle("Occupancy (percent)");
2041   hbp.SetStats(kFALSE);
2042   
2043   Double_t xmin = hbp.GetXaxis()->GetXmin();
2044   Double_t xmax = hbp.GetXaxis()->GetXmax();
2045   
2046   Double_t occMax(0.1); // 0.1% y-limit for the plot
2047   Double_t occError(1.0); // 1.0% y-limit to count the "errors"
2048   
2049   TLine* line = new TLine(xmin,occError,xmax,occError);
2050   line->SetLineColor(2);
2051   line->SetLineWidth(3);
2052   
2053   hbp.GetListOfFunctions()->Add(line);
2054   
2055   TH1* hnpads = GetRawsData(kTrackerBusPatchNofPads);
2056   hnpads->SetStats(kFALSE);
2057   TH1* hnmanus = GetRawsData(kTrackerBusPatchNofManus);
2058   hnmanus->SetStats(kFALSE);
2059   
2060   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
2061   AliMpBusPatch* bp(0x0);
2062   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
2063   {
2064     Int_t n(0);
2065     for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
2066     {
2067       Int_t manuId = bp->GetManuId(imanu);
2068       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(bp->GetDEId());      
2069       n += de->NofChannelsInManu(manuId);
2070     }
2071     hnpads->Fill(bp->GetId(),n*1.0);
2072     hnmanus->Fill(bp->GetId(),bp->GetNofManus()*1.0);
2073   }
2074   
2075   next.Reset();
2076   
2077   Int_t nMissingPads(0);
2078   Int_t nPads(0);
2079   Int_t nBusPatches(0);
2080   Int_t nMissingBusPatches(0);
2081
2082   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
2083   {
2084     Int_t bin = hbp.FindBin(bp->GetId());
2085     Int_t n = hnpads->GetBinContent(bin);
2086     
2087     ++nBusPatches;
2088
2089     nPads += n;
2090     
2091     if ( hbp.GetBinContent(bin) <= 0 ) 
2092     {
2093       nMissingPads += n;
2094       ++nMissingBusPatches;
2095     }
2096   }
2097
2098   next.Reset();
2099   
2100   Int_t ok(-1);
2101   Int_t n(0);
2102   Int_t nBusPatchesAboveLimit(0);
2103   Double_t alpha(0.1); // trim 10% of data
2104   Double_t tmean(0.0),tvar(0.0);
2105   Double_t ymin(0.0),ymax(0.0);
2106   
2107   
2108   if ( nBusPatches ) 
2109   {
2110     Double_t* x = new Double_t[nBusPatches];
2111   
2112     while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
2113     {
2114       Int_t bin = hbp.FindBin(bp->GetId());
2115       if ( hbp.GetBinContent(bin) > 0 )
2116       {
2117         x[n] = hbp.GetBinContent(bin);
2118         ++n;
2119       }
2120       if ( hbp.GetBinContent(bin) > occError )
2121       {
2122         ++nBusPatchesAboveLimit;
2123       }
2124     }
2125   
2126     // computed the truncated mean of the occupancy values, in order to get a 
2127     // reasonable y-range for the histogram (without giant peaks to the roof 
2128     // for misbehaving buspatches).
2129     ok = trim(n,x,alpha,tmean,tvar,ymin,ymax);
2130     
2131     delete[] x;
2132   }
2133   
2134   if ( ok < 0 ) 
2135   {
2136     ymax = occMax;
2137   }
2138   else
2139   {
2140     ymax = TMath::Max(ymax,occMax);
2141   }
2142   
2143   hbp.SetMaximum(ymax*1.4);
2144   
2145   TPaveText* text = new TPaveText(0.55,0.85,0.99,0.99,"NDC");
2146   
2147   if (ok < 0 ) 
2148   {
2149     text->AddText("Could not compute truncated mean. Not enough events ?");
2150     text->SetFillColor(2);
2151   }
2152   else if (!nPads || !nBusPatches)
2153   {
2154     text->AddText("Could not get the total number of pads. ERROR !!!");
2155     text->SetFillColor(2);
2156   }
2157   else
2158   {
2159     Float_t missingPadFraction = nMissingPads*100.0/nPads;
2160     Float_t missingBusPatchFraction = nMissingBusPatches*100.0/nBusPatches;
2161     Float_t aboveLimitFraction = nBusPatchesAboveLimit*100.0/nBusPatches;
2162     
2163     text->AddText(Form("%5.2f %% of missing buspatches (%d out of %d)",missingBusPatchFraction,nMissingBusPatches,nBusPatches));
2164     text->AddText(Form("%5.2f %% of missing pads (%d out of %d)",missingPadFraction,nMissingPads,nPads));
2165     text->AddText(Form("%5.2f %% bus patches above the %5.2f %% limit",aboveLimitFraction,occError));
2166     text->AddText(Form("Truncated mean at %2d %% is %7.2f %%",(Int_t)(alpha*100),tmean));
2167     
2168     if ( missingPadFraction > 10.0 || aboveLimitFraction > 5.0 ) 
2169     {
2170       text->SetFillColor(2);
2171     }
2172     else
2173     {
2174       text->SetFillColor(3);
2175     }
2176   }
2177   
2178   hbp.GetListOfFunctions()->Add(text);
2179 }
2180
2181 //____________________________________________________________________________ 
2182 void AliMUONQADataMakerRec::RawTriggerInGlobal2OutGlobal()
2183 {
2184   //
2185   /// Reconstruct Global Trigger decision using Global Inputs
2186   //
2187
2188     AliMUONGlobalCrateConfig* globalConfig = fCalibrationData->GlobalTriggerCrateConfig();
2189
2190     AliMUONGlobalTriggerBoard globalTriggerBoard;
2191     globalTriggerBoard.Reset();
2192     for (Int_t i = 0; i < 4; i++) {
2193         globalTriggerBoard.Mask(i,globalConfig->GetGlobalMask(i));
2194     }
2195
2196
2197     UShort_t regional[16];
2198
2199     for (Int_t iReg = 0; iReg < 16; iReg++) {
2200       regional[iReg] = 0;
2201       if (iReg < 8) {    // right
2202         // Lpt
2203         regional[iReg] |=  (fgitmp[0] >> (4*iReg))     & 0xF;
2204         // Hpt
2205         regional[iReg] |= ((fgitmp[2] >> (4*iReg))     & 0xF) << 4;
2206       } else {           // left
2207         // Lpt
2208         regional[iReg] |=  (fgitmp[1] >> (4*(iReg-8))) & 0xF;
2209         // Hpt
2210         regional[iReg] |= ((fgitmp[3] >> (4*(iReg-8))) & 0xF) << 4;
2211       }
2212     }
2213     globalTriggerBoard.SetRegionalResponse(regional);
2214     globalTriggerBoard.Response();
2215
2216     for (Int_t bit=1; bit<7; bit++){
2217         fgotmp[bit-1]=Int_t((globalTriggerBoard.GetResponse())>>bit&1);
2218     }
2219 }
2220
2221 //____________________________________________________________________________ 
2222 void AliMUONQADataMakerRec::RawTriggerMatchOutLocal()
2223 {
2224   //
2225   /// Match data and reconstructed Local Trigger decision
2226   //
2227
2228     Bool_t firstFillXPosDev=kTRUE;
2229     Bool_t firstFillYPosTrigY=kTRUE;
2230     Bool_t firstFillLUT=kTRUE;
2231
2232     for (int localId=1;localId<235;localId++){
2233         if(fTriggerOutputLocalDataTriggerDec[localId]!=fTriggerOutputLocalRecTriggerDec[localId]){
2234             ((TH1F*)GetRawsData(kTriggerErrorLocalTriggerDec))->Fill(localId);
2235         }
2236         if(fTriggerOutputLocalDataTrigY[localId]!=fTriggerOutputLocalRecTrigY[localId]){
2237             if(fTriggerErrorLocalYCopy[localId]) continue;
2238             ((TH1F*)GetRawsData(kTriggerErrorLocalTrigY))->Fill(localId);
2239              if (firstFillYPosTrigY){
2240                  ((TH1F*)GetRawsData(kTriggerError))->Fill(1);
2241                  firstFillYPosTrigY=kFALSE;
2242              }
2243         }
2244
2245         if(fTriggerOutputLocalDataYPos[localId]!=fTriggerOutputLocalRecYPos[localId]){
2246             if(fTriggerErrorLocalYCopy[localId]) continue;
2247             ((TH1F*)GetRawsData(kTriggerErrorLocalYPos))->Fill(localId);
2248             if (firstFillYPosTrigY){
2249                  ((TH1F*)GetRawsData(kTriggerError))->Fill(1);
2250                  firstFillYPosTrigY=kFALSE;
2251              }
2252         }
2253         if(fTriggerOutputLocalDataXPos[localId]!=fTriggerOutputLocalRecXPos[localId]){
2254             ((TH1F*)GetRawsData(kTriggerErrorLocalXPos))->Fill(localId);
2255              if (firstFillXPosDev){
2256                  ((TH1F*)GetRawsData(kTriggerError))->Fill(0);
2257                  firstFillXPosDev=kFALSE;
2258              }
2259         }
2260         if(fTriggerOutputLocalDataDev[localId]!=fTriggerOutputLocalRecDev[localId]){
2261             ((TH1F*)GetRawsData(kTriggerErrorLocalDev))->Fill(localId);
2262              if (firstFillXPosDev){
2263                  ((TH1F*)GetRawsData(kTriggerError))->Fill(0);
2264                  firstFillXPosDev=kFALSE;
2265              }
2266         }
2267         if(fTriggerOutputLocalDataLPtDec[0][localId]!=fTriggerOutputLocalRecLPtDec[0][localId]){
2268             ((TH1F*)GetRawsData(kTriggerErrorLocalLPtLSB))->Fill(localId);
2269              if (firstFillLUT){
2270                  ((TH1F*)GetRawsData(kTriggerError))->Fill(2);
2271                  firstFillLUT=kFALSE;
2272              }
2273         }
2274         if(fTriggerOutputLocalDataLPtDec[1][localId]!=fTriggerOutputLocalRecLPtDec[1][localId]){
2275             ((TH1F*)GetRawsData(kTriggerErrorLocalLPtMSB))->Fill(localId);
2276              if (firstFillLUT){
2277                  ((TH1F*)GetRawsData(kTriggerError))->Fill(2);
2278                  firstFillLUT=kFALSE;
2279              }
2280         }
2281         if(fTriggerOutputLocalDataHPtDec[0][localId]!=fTriggerOutputLocalRecHPtDec[0][localId]){
2282             ((TH1F*)GetRawsData(kTriggerErrorLocalHPtLSB))->Fill(localId);
2283              if (firstFillLUT){
2284                  ((TH1F*)GetRawsData(kTriggerError))->Fill(2);
2285                  firstFillLUT=kFALSE;
2286              }
2287         }
2288         if(fTriggerOutputLocalDataHPtDec[1][localId]!=fTriggerOutputLocalRecHPtDec[1][localId]){
2289             ((TH1F*)GetRawsData(kTriggerErrorLocalHPtMSB))->Fill(localId);
2290              if (firstFillLUT){
2291                  ((TH1F*)GetRawsData(kTriggerError))->Fill(2);
2292                  firstFillLUT=kFALSE;
2293              }
2294         }
2295     } // loop over Local Boards
2296 }
2297
2298 //____________________________________________________________________________ 
2299 void AliMUONQADataMakerRec::RawTriggerMatchOutLocalInRegional()
2300 {
2301   //
2302   /// Match Local outputs and Regional inputs
2303   /// Not tested, hardware read-out doesn't work
2304   //
2305
2306     for (int localId=1;localId<235;localId++){
2307         if(fTriggerOutputLocalDataLPtDec[0][localId]!=fTriggerInputRegionalDataLPt[0][localId]){
2308             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalLPtLSB))->Fill(localId);
2309         }
2310         if(fTriggerOutputLocalDataLPtDec[1][localId]!=fTriggerInputRegionalDataLPt[1][localId]){
2311             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalLPtMSB))->Fill(localId);
2312         }
2313         if(fTriggerOutputLocalDataHPtDec[0][localId]!=fTriggerInputRegionalDataHPt[0][localId]){
2314             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalHPtLSB))->Fill(localId);
2315         }
2316         if(fTriggerOutputLocalDataHPtDec[1][localId]!=fTriggerInputRegionalDataHPt[1][localId]){
2317             ((TH1F*)GetRawsData(kTriggerErrorLocal2RegionalHPtMSB))->Fill(localId);
2318         }
2319     }
2320
2321 }
2322
2323 //____________________________________________________________________________ 
2324 void AliMUONQADataMakerRec::RawTriggerMatchOutGlobalFromInGlobal()
2325 {
2326   //
2327   /// Match data and reconstructed Global Trigger decision for a reconstruction from Global inputs
2328   //
2329
2330     Bool_t firstFill=kTRUE;
2331
2332     for (int bit=0;bit<6;bit++){
2333          if(fTriggerOutputGlobalData[bit]!=fTriggerOutputGlobalRecFromGlobalInput[bit]){
2334              ((TH1F*)GetRawsData(kTriggerErrorOutGlobalFromInGlobal))->Fill(5-bit);
2335              if (firstFill){
2336                  ((TH1F*)GetRawsData(kTriggerError))->Fill(7);
2337                  firstFill=kFALSE;
2338              }
2339          }
2340     } 
2341 }
2342
2343
2344
2345
2346