]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackerQADataMakerRec.cxx
Only call raw QA for events where we are readout
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerQADataMakerRec.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: AliMUONTrackerQADataMakerRec.cxx 35760 2009-10-21 21:45:42Z ivana $
17
18 // --- MUON header files ---
19 #include "AliMUONTrackerQADataMakerRec.h"
20
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
23 #include "AliDAQ.h"
24 #include "AliESDEvent.h"
25 #include "AliESDMuonTrack.h"
26 #include "AliLog.h"
27 #include "AliMUON2DMap.h"
28 #include "AliMUONCalibParamND.h"
29 #include "AliMUONCalibrationData.h"
30 #include "AliMUONConstants.h"  
31 #include "AliMUONDigitMaker.h"
32 #include "AliMUONESDInterface.h"
33 #include "AliMUONLogger.h"
34 #include "AliMUONQADataMakerRec.h"
35 #include "AliMUONQAIndices.h"
36 #include "AliMUONQAMappingCheck.h"
37 #include "AliMUONTrack.h"
38 #include "AliMUONTrackParam.h"
39 #include "AliMUONTrackerData.h"
40 #include "AliMUONTrackerDataMaker.h"
41 #include "AliMUONVCluster.h"
42 #include "AliMUONVClusterStore.h"
43 #include "AliMUONVDigit.h"
44 #include "AliMUONVDigit.h"
45 #include "AliMUONVDigitStore.h"
46 #include "AliMpBusPatch.h"
47 #include "AliMpConstants.h"
48 #include "AliMpDDL.h"
49 #include "AliMpDDLStore.h"
50 #include "AliMpDEIterator.h"
51 #include "AliMpDEManager.h"
52 #include "AliMpDetElement.h"
53 #include "AliMpManuIterator.h"
54 #include "AliQAv1.h"
55 #include "AliRawReader.h"
56 #include "AliRawEventHeaderBase.h"
57 #include <Riostream.h>
58 #include <TH1F.h> 
59 #include <TH1I.h> 
60 #include <TH2F.h>
61 #include <TMath.h>
62 #include <TObjArray.h>
63 #include <TPaveText.h>
64
65 //-----------------------------------------------------------------------------
66 /// \class AliMUONTrackerQADataMakerRec
67 ///
68 /// Quality assurance data (histo) maker for MUON tracker
69 ///
70 ///
71 /// Note that all the methods of this class shoud not be called when eventSpecie is AliRecoParam::kCalib !
72 ///
73 /// \author C. Finck, D. Stocco, L. Aphecetche
74
75 /// \cond CLASSIMP
76 ClassImp(AliMUONTrackerQADataMakerRec)
77 /// \endcond
78            
79 namespace
80 {
81   Double_t ProtectedSqrt(Double_t x)
82   {
83     return ( x > 0.0 ? TMath::Sqrt(x) : 0.0 );
84   }
85   
86 }
87
88 //____________________________________________________________________________ 
89 AliMUONTrackerQADataMakerRec::AliMUONTrackerQADataMakerRec(AliQADataMakerRec* master) : 
90 AliMUONVQADataMakerRec(master),
91 fDigitStore(0x0),
92 fDigitMaker(new AliMUONDigitMaker(kTRUE)),
93 fClusterStore(0x0),
94 fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())),
95 fLogger(0x0),
96 fBusPatchConfig(0x0),
97 fBPxmin(0),
98 fBPxmax(0),
99 fBPnbins(0),
100 fTrackerDataMakerArray(0x0),
101 fTrackerCalDataArray(0x0),
102 fTrackerRecDataArray(0x0),
103 fMappingCheckRecPointsArray(0x0)
104 {
105   /// ctor
106 }
107
108 //__________________________________________________________________
109 AliMUONTrackerQADataMakerRec::~AliMUONTrackerQADataMakerRec()
110 {
111   /// dtor
112   delete fDigitStore;
113   delete fDigitMaker;
114   delete fClusterStore;
115   delete fCalibrationData;
116   delete fMappingCheckRecPointsArray;
117   if (fLogger)
118   {
119     if ( fLogger->NumberOfEntries() != 0 ) 
120     {
121       AliError("Some unprocessed logged errors are still there... Please check");
122     }
123     delete fLogger;    
124   }
125   delete fTrackerDataMakerArray;
126   delete fTrackerCalDataArray;
127   delete fTrackerRecDataArray;
128   delete fBusPatchConfig;  
129 }
130
131 //____________________________________________________________________________ 
132 void AliMUONTrackerQADataMakerRec::InsertTrackerData(Int_t specie, 
133                                                      TObjArray** list,
134                                                      TObject* object, 
135                                                      Int_t indexNumber,
136                                                      Bool_t replace)
137 {
138   /// Insert an object to a given list
139   
140   TIter next(list[specie]);
141   TObject* o;
142   TObject* old(0x0);
143   Bool_t alreadyThere(kFALSE);
144   
145   while ( ( o = next() ) && !alreadyThere )
146   {
147     TString classname(o->ClassName());
148     if ( classname.Contains("TrackerData") ) 
149     {
150       if ( !strcmp(object->GetName(),o->GetName()) ) 
151       {
152         alreadyThere = kTRUE;
153         old = o;
154       }
155     }
156   }
157   if ( (!alreadyThere && object) || (alreadyThere && replace) )
158   {
159     delete old;
160     AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s to the list of qa objects",object->GetName()));
161     TNamed* named = static_cast<TNamed*>(object);
162     named->SetName(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),object->GetName()));
163     object->SetBit(AliQAv1::GetExpertBit());
164     list[specie]->AddAt(object,indexNumber);
165   }
166 }
167
168 //____________________________________________________________________________ 
169 void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleESDs(Int_t, TObjArray**)
170 {
171   /// Normalize ESD histograms
172   
173   if (!GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)) return;
174   
175   AliCodeTimerAuto("",0);
176   
177   Double_t nTracks = GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->GetEntries();
178   if (nTracks <= 0) return;
179   
180   TH1* hESDnClustersPerCh = GetESDsData(AliMUONQAIndices::kESDnClustersPerCh);
181   TH1* hESDnClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnClustersPerDE);
182   TH1* hESDClusterChargePerChMean = GetESDsData(AliMUONQAIndices::kESDClusterChargePerChMean);
183   TH1* hESDClusterChargePerChSigma = GetESDsData(AliMUONQAIndices::kESDClusterChargePerChSigma);
184   TH1* hESDClusterSizePerChMean = GetESDsData(AliMUONQAIndices::kESDClusterSizePerChMean);
185   TH1* hESDClusterSizePerChSigma = GetESDsData(AliMUONQAIndices::kESDClusterSizePerChSigma);
186   TH1* hESDResidualXPerChMean = GetESDsData(AliMUONQAIndices::kESDResidualXPerChMean);
187   TH1* hESDResidualXPerChSigma = GetESDsData(AliMUONQAIndices::kESDResidualXPerChSigma);
188   TH1* hESDResidualYPerChMean = GetESDsData(AliMUONQAIndices::kESDResidualYPerChMean);
189   TH1* hESDResidualYPerChSigma = GetESDsData(AliMUONQAIndices::kESDResidualYPerChSigma);
190   TH1* hESDLocalChi2XPerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerChMean);
191   TH1* hESDLocalChi2YPerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerChMean);
192   TH1* hESDLocalChi2PerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2PerChMean);
193   TH1* hESDClusterChargePerDE = GetESDsData(AliMUONQAIndices::kESDClusterChargePerDE);
194   TH1* hESDClusterSizePerDE = GetESDsData(AliMUONQAIndices::kESDClusterSizePerDE);
195   TH1* hESDResidualXPerDEMean = GetESDsData(AliMUONQAIndices::kESDResidualXPerDEMean);
196   TH1* hESDResidualXPerDESigma = GetESDsData(AliMUONQAIndices::kESDResidualXPerDESigma);
197   TH1* hESDResidualYPerDEMean = GetESDsData(AliMUONQAIndices::kESDResidualYPerDEMean);
198   TH1* hESDResidualYPerDESigma = GetESDsData(AliMUONQAIndices::kESDResidualYPerDESigma);
199   TH1* hESDLocalChi2XPerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerDEMean);
200   TH1* hESDLocalChi2YPerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerDEMean);
201   TH1* hESDLocalChi2PerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2PerDEMean);
202   TH1* hESDnTotClustersPerCh = GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh);
203   TH1* hESDnTotClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE);
204   TH1* hESDnTotFullClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE);
205   TH1* hESDSumClusterChargePerDE = GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE);
206   TH1* hESDSumClusterSizePerDE = GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE);
207   TH1* hESDSumResidualXPerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE);
208   TH1* hESDSumResidualYPerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE);
209   TH1* hESDSumResidualX2PerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE);
210   TH1* hESDSumResidualY2PerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE);
211   TH1* hESDSumLocalChi2XPerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE);
212   TH1* hESDSumLocalChi2YPerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE);
213   TH1* hESDSumLocalChi2PerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE);
214   
215   hESDnClustersPerCh->Reset();
216   hESDnClustersPerDE->Reset();
217   hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
218   hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
219   
220   // loop over chambers
221   for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
222     
223     TH1* hESDClusterChargeInCh = GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+iCh);
224     Double_t sigmaCharge = hESDClusterChargeInCh->GetRMS();
225     hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
226     hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
227     hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
228     hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
229     
230     TH1* hESDClusterSizeInCh = GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+iCh);
231     Double_t sigmaSize = hESDClusterSizeInCh->GetRMS();
232     hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
233     hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
234     hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
235     hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
236     
237     TH1* hESDResidualXInCh = GetESDsData(AliMUONQAIndices::kESDResidualXInCh+iCh);
238     Double_t sigmaResidualX = hESDResidualXInCh->GetRMS();
239     hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
240     hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
241     hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
242     hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
243     
244     TH1* hESDResidualYInCh = GetESDsData(AliMUONQAIndices::kESDResidualYInCh+iCh);
245     Double_t sigmaResidualY = hESDResidualYInCh->GetRMS();
246     hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
247     hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
248     hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
249     hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
250     
251     TH1* hESDLocalChi2XInCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+iCh);
252     Double_t sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
253     hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
254     hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
255     
256     TH1* hESDLocalChi2YInCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+iCh);
257     Double_t sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
258     hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
259     hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
260     
261     TH1* hESDLocalChi2InCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+iCh);
262     Double_t sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
263     hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
264     hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
265     
266     // loop over DE into chamber iCh
267     AliMpDEIterator it;
268     it.First(iCh);
269     while ( !it.IsDone()) {
270       
271       Int_t iDE = it.CurrentDEId();
272       
273       Double_t nClusters = hESDnTotClustersPerDE->GetBinContent(iDE+1);
274       if (nClusters > 1) {
275         
276         hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
277         hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
278         
279         Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
280         hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
281         hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
282         hESDResidualXPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
283         hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
284         
285         Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
286         hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
287         hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
288         hESDResidualYPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
289         hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
290         
291         hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
292         hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
293         
294         hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
295         hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
296         
297         hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
298         hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
299         
300       } else {
301         
302         hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
303         hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
304         
305         hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
306         hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
307         hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
308         hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
309         
310         hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
311         hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
312         hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
313         hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
314         
315         hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
316         hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
317         
318         hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
319         hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
320         
321         hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
322         hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
323         
324       }
325       
326       Double_t nFullClusters = hESDnTotFullClustersPerDE->GetBinContent(iDE+1);
327       if (nFullClusters > 1) {
328         
329         hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
330         hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
331         
332       } else {
333         
334         hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
335         hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
336         
337       }
338       
339       it.Next();
340     }
341
342   }
343
344 }
345   
346 //____________________________________________________________________________ 
347 void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t specie, TObjArray** list)
348 {
349   /// Normalize RecPoints histograms
350   
351   if (!GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChMean)) return;
352   
353   AliCodeTimerAuto("",0);
354   
355   TH1* hTrackerClusterChargePerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChMean);
356   TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChSigma);
357   TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean);
358   TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma);
359   TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDEMean);
360   TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean);
361   
362   // loop over chambers
363   for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
364     
365     TH1* hTrackerClusterChargePerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+iCh);
366     Double_t sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
367     hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
368     hTrackerClusterChargePerChMean->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetMeanError());
369     hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
370     hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
371     
372     TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+iCh);
373     Double_t sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
374     hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
375     hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
376     hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
377     hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
378     
379     // loop over DE into chamber iCh
380     AliMpDEIterator it;
381     it.First(iCh);
382     while ( !it.IsDone()) {
383       
384       Int_t iDE = it.CurrentDEId();
385       
386       TH1* hTrackerClusterChargePerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+iDE);
387       hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
388       Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
389       if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
390       else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber->GetXaxis()->GetXmax());
391       
392       TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+iDE);
393       hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
394       nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
395       if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
396       else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax());
397       
398       it.Next();
399     }
400   }
401   
402   if ( MappingCheckRecPoints(specie) ) 
403   {
404     InsertTrackerData(specie,list,MappingCheckRecPoints(specie)->CreateData("RecPoints"),AliMUONQAIndices::kTrackerRecPoints,kTRUE);    
405   }
406   
407   if ( TrackerRecData(specie) )
408   {
409     /// put the trackerdata in the pipeline
410     InsertTrackerData(specie,list,TrackerRecData(specie),AliMUONQAIndices::kTrackerData);
411     
412     TH1* hbp = GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
413     TH1* hnevents = GetRecPointsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed);
414     TH1* hddl = GetRecPointsData(AliMUONQAIndices::kTrackerDDLOccupancy);
415     TH1* hddlevents = GetRecPointsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed);
416     
417     if ( !hbp || !hnevents || !hddl || !hddlevents)
418     {
419       AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
420       return;
421     }
422     
423     ProjectTrackerData(TrackerRecData(specie),
424                        *hbp,*hnevents,*hddl,*hddlevents);    
425   }
426   else
427   {
428     AliError(Form("TrackerRecData is null for specie %s",AliRecoParam::GetEventSpecieName(specie)));
429   }
430   
431 }
432
433 //____________________________________________________________________________ 
434 void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleDigits(Int_t specie, TObjArray** list)
435 {
436   /// create digits histograms in digits subdir
437   
438   if ( TrackerCalData(specie) )
439   {
440     AliCodeTimerAuto("",0);
441     
442     /// put the trackerdata in the pipeline
443     InsertTrackerData(specie,list,TrackerCalData(specie),AliMUONQAIndices::kTrackerData);
444     
445     TH1* hbp = GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
446     TH1* hnevents = GetDigitsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed);
447     TH1* hddl = GetDigitsData(AliMUONQAIndices::kTrackerDDLOccupancy);
448     TH1* hddlevents = GetDigitsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed);
449     
450     if ( !hbp || !hnevents || !hddl || !hddlevents)
451     {
452       AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
453       return;
454     }
455     
456     ProjectTrackerData(TrackerCalData(specie),
457                        *hbp,*hnevents,*hddl,*hddlevents);    
458   }
459 }
460
461 //____________________________________________________________________________ 
462 AliMUONQADataMakerRec* AliMUONTrackerQADataMakerRec::Master() const
463 {
464   /// Get our master
465   return static_cast<AliMUONQADataMakerRec*>(fMaster); 
466 }
467
468 //____________________________________________________________________________ 
469 void AliMUONTrackerQADataMakerRec::ProjectTrackerData(AliMUONVTrackerData* data, 
470                                                       TH1& hbp,
471                                                       TH1& hnevents,
472                                                       TH1& hddl,
473                                                       TH1& hddlevents)
474 {
475   /// Project tracker data into shifter-friendly histograms
476   
477   AliCodeTimerAuto(Form("%s",data->Name()),0);
478   
479   /// project the tracerdata into buspatch occupancies (for the experts)
480   hbp.Reset();
481   hbp.SetStats(kFALSE);
482   
483   TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
484   AliMpBusPatch* bp(0x0);
485   Int_t occDim = 2;
486   
487   while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
488   {
489     Int_t busPatchId = bp->GetId();
490     Int_t bin = hbp.FindBin(busPatchId);
491     if ( data->HasBusPatch(busPatchId) )
492     {
493       hbp.SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
494     }
495   }
496   
497   /// log the readout errors (for the shifter)
498   hnevents.Reset();
499   hnevents.SetStats(kFALSE);
500   hnevents.SetBinContent(1,data->NumberOfEvents(-1));
501   
502   /// project tracker data into DDL occupancies (for the shifter)
503   hddl.Reset();
504   hddl.SetStats(kFALSE);
505   hddlevents.Reset();
506   hddlevents.SetStats(kFALSE);
507   
508   const Int_t nddls = AliDAQ::NumberOfDdls("MUONTRK");
509   const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
510   
511   for ( Int_t iddl = 0; iddl < nddls; ++iddl )
512   {
513     AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(iddl);
514     
515     Int_t ddlId = offset + ddl->GetId();
516     Int_t npads = 0;
517     
518     Int_t nevents = data->NumberOfEvents(iddl);
519     
520     hddlevents.Fill(ddlId,nevents);
521     
522     Double_t occ(0.0);
523     
524     if ( nevents > 0 )
525     {
526       for ( Int_t ide = 0; ide < ddl->GetNofDEs(); ++ide )
527       {
528         Int_t de = ddl->GetDEId(ide);
529         
530         npads += TMath::Nint(data->DetectionElement(de,3));
531         
532         occ +=  data->DetectionElement(de,4);
533       }
534       
535       if ( npads > 0 )
536       {
537         occ = occ/npads/nevents;
538       }
539       else 
540       {
541         occ = 0.0;
542       }
543     }
544     
545     hddl.Fill(ddlId,100.0*occ); // occ in percent
546   }
547   
548   TPaveText* text = new TPaveText(0.50,0.8,0.9,0.9,"NDC");
549   
550   text->AddText(Form("MCH RUN %d - %d events",AliCDBManager::Instance()->GetRun(),data->NumberOfEvents(-1)));
551
552   hddl.GetListOfFunctions()->Add(text);
553 }
554
555 //____________________________________________________________________________ 
556 void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArray** list)
557 {
558   /// create Raws histograms in Raws subdir
559   
560   if ( TrackerDataMaker(specie) && TrackerDataMaker(specie)->Data() ) 
561   {
562     AliCodeTimerAuto("",0);
563     
564     /// put the trackerdata in the pipeline
565     InsertTrackerData(specie,list,TrackerDataMaker(specie)->Data(),AliMUONQAIndices::kTrackerData);
566     TrackerDataMaker(specie)->SetOwnerOfData(kFALSE); // now that it's attached to list, list will take care of the deletion
567     
568     TH1* hbp = GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
569     TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed);
570     TH1* hddl = GetRawsData(AliMUONQAIndices::kTrackerDDLOccupancy);
571     TH1* hddlevents = GetRawsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed);
572
573     if ( !hbp || !hnevents || !hddl || !hddlevents)
574     {
575       AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
576       return;
577     }
578     
579     ProjectTrackerData(TrackerDataMaker(specie)->Data(),
580                        *hbp,*hnevents,*hddl,*hddlevents);
581     
582     FillReadoutStatus(*fLogger,TrackerDataMaker(specie)->Data());      
583   }    
584 }
585
586 //____________________________________________________________________________ 
587 void AliMUONTrackerQADataMakerRec::FillReadoutStatus(AliMUONLogger& log, AliMUONVTrackerData* data)
588 {
589   log.ResetItr();
590
591   TString msg;
592   Int_t occurence;
593   
594   TH1* hparity = GetRawsData(AliMUONQAIndices::kTrackerBusPatchParityErrors);
595
596   TH1* htoken = GetRawsData(AliMUONQAIndices::kTrackerBusPatchTokenLostErrors);
597
598   TH1* hpadding = GetRawsData(AliMUONQAIndices::kTrackerBusPatchPaddingErrors);
599   
600   TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus);
601     
602   TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen);
603   
604   Int_t nevents = TMath::Nint(hnevents->GetBinContent(1));
605   
606   if ( !nevents ) 
607   {
608     TPaveText* text = new TPaveText(0,0,0.99,0.99,"NDC");
609     text->AddText("FATAL : 0 event seen ? That's NOT normal...");
610     text->SetFillColor(2); // red = FATAL
611     hrostatus->GetListOfFunctions()->Add(text);
612     return;
613   }
614   
615   /////////////////////////////////////////////////////////////////
616   /// Start by counting the number of errors
617   /////////////////////////////////////////////////////////////////
618   
619   while ( log.Next(msg,occurence) )
620   {
621     AliDebug(1,Form("msg=%s occurence=%d",msg.Data(),occurence));
622              
623     if ( msg.Contains("token") )
624     {
625       Int_t dsp(-1),iddl(-1),ecode(-1);
626       
627       sscanf(msg.Data(),"Lost token error detected with address 0x%10X of DDL %10d and code %10d.",
628              &dsp,&iddl,&ecode);
629       Int_t localBP = ((dsp >> 16)- 4)*5 + 1;
630       Int_t buspatch = localBP + iddl*100;
631       
632       // Let's try to get all the suspected bus patches (i.e. one full FRT, as currently
633       // we don't have more precise information to locate the faulty bus patch(es)).
634       
635       AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatch,kFALSE);
636       if (bp)
637       {
638         Int_t frt = bp->GetFrtId();
639         AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(bp->GetDdlId());
640         Int_t* b = new Int_t[ddl->GetMaxDsp()];
641         ddl->GetBusPerDsp(b);
642         Int_t nbus(0);
643         for ( Int_t i = 0; i < ddl->GetNofFrts() && !nbus; ++i ) 
644         {
645           if ( ddl->GetFrtId(i) == frt ) 
646           {
647             nbus = b[i];
648           }
649         }
650         if (nbus<=0) 
651         {
652           AliError("GOT NBUS<=0 ! THAT IS BAD ! CHECK !");
653           nbus=1;
654         }
655         delete[] b;
656       
657         while (nbus) {
658           htoken->Fill(buspatch+nbus-1,occurence);
659           --nbus;
660         }
661       }
662       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors,occurence);
663     }
664     
665     if ( msg.Contains("Parity") )
666     {
667       Int_t buspatch;
668       sscanf(msg.Data(),"Parity error in buspatch %d (0x%X).",&buspatch,&buspatch);
669       hparity->Fill(buspatch,occurence);      
670       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors,occurence);
671     }
672     
673     if ( msg.Contains("Glitch") ) 
674     {
675       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors,occurence);      
676     }
677     
678     if ( msg.Contains("Padding") )
679     {
680       Int_t block, dsp, buspatch;      
681       sscanf(msg.Data(),"Padding word error for iBlock %d, iDsp %d, iBus %d.",&block,&dsp,&buspatch);
682       hpadding->Fill(buspatch,occurence);
683       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors,occurence);      
684     }
685   }
686   
687   /////////////////////////////////////////////////////////////////
688   ///
689   /// Then make the status about number of missing bus patches
690   ///
691   /////////////////////////////////////////////////////////////////
692
693   Int_t nofBusPatchesNotInConfig(0);
694     
695   for ( int i = 1; i <= fBusPatchConfig->GetNbinsX(); ++i )
696   {
697     Double_t buspatchId = fBusPatchConfig->GetBinCenter(i);
698     if ( TMath::Nint(buspatchId) != i ) 
699     {
700       AliError(Form("buspathId=%e i=%d",buspatchId,i));
701     }
702     Double_t content = fBusPatchConfig->GetBinContent(i);
703     
704     if ( content <= 0. /* no content */
705         && 
706         AliMpDDLStore::Instance()->GetBusPatch(i,kFALSE) /* but a valid bus patch */ )
707     {
708       ++nofBusPatchesNotInConfig;
709     }    
710   }
711   
712   Double_t nbuspatches = fBusPatchConfig->GetEntries();
713   
714   Int_t bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig);
715   hrostatus->SetBinContent(bin,nofBusPatchesNotInConfig*nevents/nbuspatches);
716   
717   Double_t nofBusPatchesNotInData(0);
718   
719   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
720   AliMpBusPatch* bp;
721   
722   while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
723   {
724     if ( !data->HasBusPatch(bp->GetId()) ) ++nofBusPatchesNotInData;
725   }
726   
727   bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream);
728   hrostatus->SetBinContent(bin,nofBusPatchesNotInData*nevents/nbuspatches);
729 }
730
731 //____________________________________________________________________________ 
732 void AliMUONTrackerQADataMakerRec::FillEventSize(AliRawReader* rawReader)
733 {
734   /// Fill event size histogram(s)
735   
736   TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen);
737
738   TH1* hddlevents = GetRawsData(AliMUONQAIndices::kTrackerDDLNofEventsSeen);
739   
740   TH1* hDDLEventSize = GetRawsData(AliMUONQAIndices::kTrackerDDLEventSize);
741   
742   hnevents->Fill(0.0);
743   
744   Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
745   
746   for ( int i = 0; i < AliDAQ::NumberOfDdls("MUONTRK"); ++i )
747   {
748     rawReader->Reset();
749     rawReader->Select("MUONTRK",i,i);
750     if (rawReader->ReadHeader() )
751     {
752       UInt_t ddlsize = rawReader->GetEquipmentSize();
753       hDDLEventSize->Fill(i+offset,ddlsize);
754       hddlevents->Fill(i+offset);
755     }      
756   }
757   rawReader->Reset();
758 }
759
760 //____________________________________________________________________________ 
761 void AliMUONTrackerQADataMakerRec::InitCommon()
762 {  
763   if (!fBusPatchConfig)
764   {
765     Int_t bpmin(999999);
766     Int_t bpmax(0);
767     
768     TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
769     AliMpBusPatch* bp(0x0);
770     while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
771     {
772       bpmin = TMath::Min(bpmin,bp->GetId());
773       bpmax = TMath::Max(bpmax,bp->GetId());
774     }
775     
776     fBPxmin = bpmin-0.5;
777     fBPxmax = bpmax+0.5;
778     fBPnbins = TMath::Nint(fBPxmax-fBPxmin);
779         
780     AliMUONVStore* config = fCalibrationData->Config();
781     
782     if (config)
783     {
784       fBusPatchConfig = new TH1F("hTrackerBusPatchConfig","Configuration of bus patches",fBPnbins,fBPxmin,fBPxmax);
785       fBusPatchConfig->SetDirectory(0);
786     }
787     else
788     {
789       AliWarning("Tracker configuration not found. Will not be able to cut on low occupancies");
790     }
791     
792     next.Reset();
793     while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
794     {
795       if ( config ) 
796       {
797         Int_t nofManusInConfig(0);
798       
799         for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
800         {
801           Int_t manuId = bp->GetManuId(imanu);
802           if ( config->FindObject(bp->GetDEId(),manuId)) ++nofManusInConfig;
803         }
804         
805         if ( nofManusInConfig > 0 )
806         {
807           fBusPatchConfig->Fill(bp->GetId(),1.0);
808         }
809         else
810         {
811           fBusPatchConfig->Fill(bp->GetId(),0.0);          
812         }
813       }      
814       else // no config, we assume all is there...
815       {
816         fBusPatchConfig->Fill(bp->GetId());
817       }
818     }
819   }
820 }
821
822 //____________________________________________________________________________ 
823 void AliMUONTrackerQADataMakerRec::BookHistograms(AliQAv1::TASKINDEX_t task)
824 {
825   AliCodeTimerAuto("",0);
826
827   InitCommon();
828   
829   const Bool_t expert   = kTRUE ; 
830   const Bool_t saveCorr = kTRUE ; 
831   const Bool_t image    = kTRUE ; 
832   
833   TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",fBPnbins,fBPxmin,fBPxmax);
834   
835   Master()->Add2List(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, task, expert, !image, !saveCorr);
836   
837   TH1* h = new TH1F("hTrackerBusPatchParityErrors","Number of parity errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
838   
839   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchParityErrors,task,expert,!image,!saveCorr);
840   
841   h = new TH1F("hTrackerBusPatchTokenLostErrors","Number of token lost errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
842   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchTokenLostErrors,task,expert,!image,!saveCorr);
843   
844   h = new TH1F("hTrackerBusPatchPaddingErrors","Number of padding errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
845   
846   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchPaddingErrors,task,expert,!image,!saveCorr);
847   
848   
849   TH1* hnevents(0x0);
850   
851   if ( task == AliQAv1::kRAWS )
852   {
853     // for raw data, we differentiate events seen from events used to be able to detect
854     // severe decoder errors that lead to no event decoded (i.e. zero event used) even if
855     // events are there (i.e non-zero event seen).
856     hnevents = new TH1F("hTrackerNofPhysicsEventsSeen","Number of physics events seen",1,-0.5,0.5);
857     // this one will count the number of physics event the rawdatamaker is *seeing*
858     TAxis* a = hnevents->GetXaxis();
859     a->SetBinLabel(1,"NPhysicsEvents");
860     hnevents->SetStats(kFALSE);
861     Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofPhysicsEventsSeen,task,expert,!image,!saveCorr);
862   }
863   
864   hnevents = new TH1F("hTrackerNofGoodPhysicsEventsUsed","Number of good physics events used",1,-0.5,0.5);
865   // this one will get its content from the TrackerData, i.e. it will count the number of *good* physics events *used*
866   // (i.e. not empty and with no fatal readout error)
867   TAxis* a = hnevents->GetXaxis();
868   a->SetBinLabel(1,"NGoodPhysicsEvents");
869   hnevents->SetStats(kFALSE);  
870
871   Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed,task,expert,!image,!saveCorr);
872
873   Master()->Add2List(static_cast<TH1*>(fBusPatchConfig->Clone()),AliMUONQAIndices::kTrackerBusPatchConfig, task,expert, !image, !saveCorr);
874
875   Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
876   const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
877   
878   Double_t xmin = offset - 0.5;
879   Double_t xmax  = offset + nbins - 0.5;
880   
881   TString what(AliQAv1::GetTaskName(task));
882   
883   h = new TH1F(Form("hTrackerDDL%sOccupancy",what.Data()),Form(";DDLId;DDL Occupancy in %% (from %s)",what.Data()),nbins,xmin,xmax);
884   
885   Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLOccupancy,task,expert,!image,!saveCorr);
886
887   if ( task == AliQAv1::kRAWS )
888   {
889     // see above the comment about why we have event seen vs used for raw data.
890     h = new TH1F("hTrackerDDLNofEventsSeen","Number of events seen by DDL;DDLId",nbins,xmin,xmax);
891     Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsSeen,task,expert,!image,!saveCorr);
892   }
893   
894   h = new TH1F("hTrackerDDLNofEventsUsed","Number of events used by DDL;DDLId",nbins,xmin,xmax);
895   Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsUsed,task,expert,!image,!saveCorr);
896   
897 }
898
899 //____________________________________________________________________________ 
900 void AliMUONTrackerQADataMakerRec::InitRaws()
901 {
902   /// create monitor objects for RAWS
903         
904   TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
905   
906   /// Book histograms that are common to Raws and Digits
907   BookHistograms(AliQAv1::kRAWS);
908   
909   /// Now the Raws specific parts
910   TH1* h = new TH1F("hTrackerReadoutStatus","Readout status (x events)",7,-0.5,6.5);
911   h->SetStats(kFALSE);
912   
913   TAxis* a = h->GetXaxis();
914   
915   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors),"Glitch errors");
916   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors),"Token lost errors");
917   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors),"Parity errors");
918   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors),"Padding errors");
919   
920   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents),"Empty events");
921   
922   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig),"Not readout bus patches");
923   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream),"Missing bus patches");
924
925   TH1* h1 = static_cast<TH1*>(h->Clone("hTrackerReadoutStatusPerEvent"));
926   h1->SetTitle("Readout status per event");
927   h1->GetYaxis()->SetTitle("Percentage");
928   
929   // The QA shifter will only see the summary plot below
930
931   Add2RawsList(h,AliMUONQAIndices::kTrackerReadoutStatus,kTRUE,kFALSE,kFALSE);    
932   Add2RawsList(h1,AliMUONQAIndices::kTrackerReadoutStatusPerEvent,kFALSE,kTRUE,kFALSE);  
933
934   // Lastly the event size histograms
935   
936   Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
937   const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
938   
939   Double_t xmin = offset - 0.5;
940   Double_t xmax  = offset + nbins - 0.5;
941   
942   h = new TH1F("hTrackerDDLEventSize","DDL event size (bytes);DDL Id;Data size (bytes)",nbins,xmin,xmax);  
943   h->SetStats(kFALSE);
944   Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSize,kTRUE,kFALSE,kFALSE);
945
946   h = new TH1F("hTrackerDDLMeanEventSize","DDL mean event size (KB) per event;DDL Id;Mean Event size (KB)",nbins,xmin,xmax);  
947   h->SetStats(kFALSE);
948   Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSizePerEvent,kFALSE,kTRUE,kFALSE);
949     
950   Add2RawsList(new TH1F("hTrackerIsThere","tracker is there",1,0,1),AliMUONQAIndices::kTrackerIsThere,kTRUE,kFALSE,kFALSE);
951 }
952
953 //__________________________________________________________________
954 void AliMUONTrackerQADataMakerRec::InitDigits() 
955 {
956   /// create monitor objects for DIGITS
957   
958   AliCodeTimerAuto("",0);
959
960   if ( GetRecoParam()->TryRecover() )
961   {
962     fDigitMaker->SetTryRecover(kTRUE);
963   }
964   else
965   {
966     fDigitMaker->SetTryRecover(kFALSE);    
967   }
968   
969   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
970   
971   /// Book histograms that are common to Raws and Digits
972   BookHistograms(AliQAv1::kDIGITSR);
973
974
975 //____________________________________________________________________________ 
976 void AliMUONTrackerQADataMakerRec::InitRecPoints()
977 {
978   /// create Reconstructed Points histograms in RecPoints subdir for the
979   /// MUON tracker subsystem.
980   const Bool_t expert   = kTRUE ; 
981   const Bool_t image    = kTRUE ; 
982   
983   AliCodeTimerAuto("",0);
984
985   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
986   
987   BookHistograms(AliQAv1::kRECPOINTS);
988   
989   TH1I *h1I;
990   TH1F *h1F;
991   TH2F *h2F;
992   
993   // histograms per chamber
994   Int_t nCh = AliMpConstants::NofTrackingChambers();
995   for ( Int_t i = 0; i < nCh; ++i ) 
996   {
997     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
998     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+i, expert, !image);
999     
1000     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC);Counts",i+1), 100,0,1000);
1001     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerChamber+i, expert, !image);
1002     
1003     Float_t rMax = AliMUONConstants::Rmax(i/2);
1004     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);
1005     Add2RecPointsList(h2F, AliMUONQAIndices::kTrackerClusterHitMapPerChamber+i, expert, !image);
1006   }
1007   
1008   // summary histograms per chamber
1009   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
1010   Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerNumberOfClustersPerChamber, !expert, image);
1011   
1012   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
1013   h1F->SetOption("P");
1014   h1F->SetMarkerStyle(kFullDotMedium);
1015   h1F->SetMarkerColor(kRed);
1016   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean, !expert, image);
1017   
1018   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
1019   h1F->SetOption("P");
1020   h1F->SetMarkerStyle(kFullDotMedium);
1021   h1F->SetMarkerColor(kRed);
1022   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma, !expert, image);
1023   
1024   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh,-0.5,nCh-0.5);
1025   h1F->SetOption("P");
1026   h1F->SetMarkerStyle(kFullDotMedium);
1027   h1F->SetMarkerColor(kRed);
1028   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChMean, !expert, image);
1029   
1030   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh,-0.5,nCh-0.5);
1031   h1F->SetOption("P");
1032   h1F->SetMarkerStyle(kFullDotMedium);
1033   h1F->SetMarkerColor(kRed);
1034   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChSigma, !expert, image);
1035   
1036   // histograms per DE
1037   Int_t ndes(0);
1038   AliMpDEIterator it;
1039   it.First();
1040   while ( !it.IsDone())
1041   {
1042     Int_t detElemId = it.CurrentDEId();
1043     
1044     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
1045     {
1046       ndes = TMath::Max(ndes,detElemId);
1047       
1048       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
1049       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
1050       
1051       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (fC)",detElemId), 100,0,1000);
1052       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId, expert, !image);
1053     }
1054     
1055     it.Next();
1056   }
1057   
1058   // summary histograms per DE
1059   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
1060   Add2RecPointsList(h1I, AliMUONQAIndices::kTrackerNumberOfClustersPerDE, !expert, image);
1061   
1062   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
1063   h1F->SetOption("P");
1064   h1F->SetMarkerStyle(kFullDotMedium);
1065   h1F->SetMarkerColor(kRed);
1066   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean, !expert, image);
1067   
1068   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", ndes+1,-0.5,ndes+0.5);
1069   h1F->SetOption("P");
1070   h1F->SetMarkerStyle(kFullDotMedium);
1071   h1F->SetMarkerColor(kRed);
1072   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerDEMean, !expert, image);
1073   
1074   MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
1075 }
1076
1077 //____________________________________________________________________________ 
1078 void AliMUONTrackerQADataMakerRec::InitESDs()
1079 {
1080   ///create ESDs histograms in ESDs subdir
1081   
1082   const Bool_t expert   = kTRUE ; 
1083   const Bool_t image    = kTRUE ; 
1084   
1085   Int_t nCh = AliMUONConstants::NTrackingCh();
1086   Int_t nDE = 1100;
1087   
1088   // track info
1089   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
1090   Add2ESDsList(hESDnTracks, AliMUONQAIndices::kESDnTracks, !expert, image);
1091
1092   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
1093   Add2ESDsList(hESDMatchTrig, AliMUONQAIndices::kESDMatchTrig, !expert, image);
1094   
1095   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
1096   Add2ESDsList(hESDMomentum, AliMUONQAIndices::kESDMomentum, !expert, image);
1097
1098   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
1099   Add2ESDsList(hESDPt, AliMUONQAIndices::kESDPt, !expert, image);
1100
1101   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
1102   Add2ESDsList(hESDRapidity, AliMUONQAIndices::kESDRapidity, !expert, image);
1103
1104   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
1105   Add2ESDsList(hESDChi2, AliMUONQAIndices::kESDChi2, !expert, image);
1106   
1107   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
1108   Add2ESDsList(hESDProbChi2, AliMUONQAIndices::kESDProbChi2, !expert, image);
1109   
1110   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
1111   Add2ESDsList(hESDThetaX, AliMUONQAIndices::kESDThetaX, !expert, image);
1112   
1113   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
1114   Add2ESDsList(hESDThetaY, AliMUONQAIndices::kESDThetaY, !expert, image);
1115   
1116   // cluster info
1117   for (Int_t i = 0; i < nCh; i++) {
1118     Float_t rMax = AliMUONConstants::Rmax(i/2);
1119     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
1120                                        100, -rMax, rMax, 100, -rMax, rMax);
1121     Add2ESDsList(hESDClusterHitMap, AliMUONQAIndices::kESDClusterHitMap+i, expert, !image);
1122   }
1123   
1124   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
1125   Add2ESDsList(hESDnClustersPerTrack, AliMUONQAIndices::kESDnClustersPerTrack, !expert, image);
1126   
1127   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
1128   hESDnClustersPerCh->SetFillColor(kRed);
1129   Add2ESDsList(hESDnClustersPerCh, AliMUONQAIndices::kESDnClustersPerCh, !expert, image);
1130   
1131   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
1132   hESDnClustersPerDE->SetFillColor(kRed);
1133   Add2ESDsList(hESDnClustersPerDE, AliMUONQAIndices::kESDnClustersPerDE, !expert, image);
1134   
1135   for (Int_t i = 0; i < nCh; i++) {
1136     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
1137     Add2ESDsList(hESDClusterChargeInCh, AliMUONQAIndices::kESDClusterChargeInCh+i, expert, !image);
1138   }
1139   
1140   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
1141   hESDClusterChargePerChMean->SetOption("P");
1142   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
1143   hESDClusterChargePerChMean->SetMarkerColor(kRed);
1144   Add2ESDsList(hESDClusterChargePerChMean, AliMUONQAIndices::kESDClusterChargePerChMean, !expert, image);
1145   
1146   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
1147   hESDClusterChargePerChSigma->SetOption("P");
1148   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
1149   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
1150   Add2ESDsList(hESDClusterChargePerChSigma, AliMUONQAIndices::kESDClusterChargePerChSigma, !expert, image);
1151   
1152   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
1153   hESDClusterChargePerDE->SetOption("P");
1154   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
1155   hESDClusterChargePerDE->SetMarkerColor(kRed);
1156   Add2ESDsList(hESDClusterChargePerDE, AliMUONQAIndices::kESDClusterChargePerDE, !expert, image);
1157   
1158   for (Int_t i = 0; i < nCh; i++) {
1159     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
1160     Add2ESDsList(hESDClusterSizeInCh, AliMUONQAIndices::kESDClusterSizeInCh+i, expert, !image);
1161   }
1162   
1163   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
1164   hESDClusterSizePerChMean->SetOption("P");
1165   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
1166   hESDClusterSizePerChMean->SetMarkerColor(kRed);
1167   Add2ESDsList(hESDClusterSizePerChMean, AliMUONQAIndices::kESDClusterSizePerChMean, !expert, image);
1168   
1169   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
1170   hESDClusterSizePerChSigma->SetOption("P");
1171   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
1172   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
1173   Add2ESDsList(hESDClusterSizePerChSigma, AliMUONQAIndices::kESDClusterSizePerChSigma, !expert, image);
1174   
1175   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
1176   hESDClusterSizePerDE->SetOption("P");
1177   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
1178   hESDClusterSizePerDE->SetMarkerColor(kRed);
1179   Add2ESDsList(hESDClusterSizePerDE, AliMUONQAIndices::kESDClusterSizePerDE, !expert, image);
1180   
1181   // cluster - track info
1182   for (Int_t i = 0; i < nCh; i++) {
1183     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.);
1184     Add2ESDsList(hESDResidualXInCh, AliMUONQAIndices::kESDResidualXInCh+i, expert, !image);
1185     
1186     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.);
1187     Add2ESDsList(hESDResidualYInCh, AliMUONQAIndices::kESDResidualYInCh+i, expert, !image);
1188     
1189     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);
1190     Add2ESDsList(hESDLocalChi2XInCh, AliMUONQAIndices::kESDLocalChi2XInCh+i, expert, !image);
1191     
1192     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);
1193     Add2ESDsList(hESDLocalChi2YInCh, AliMUONQAIndices::kESDLocalChi2YInCh+i, expert, !image);
1194     
1195     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);
1196     Add2ESDsList(hESDLocalChi2InCh, AliMUONQAIndices::kESDLocalChi2InCh+i, expert, !image);
1197   }
1198   
1199   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
1200   hESDResidualXPerChMean->SetOption("P");
1201   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
1202   hESDResidualXPerChMean->SetMarkerColor(kRed);
1203   Add2ESDsList(hESDResidualXPerChMean, AliMUONQAIndices::kESDResidualXPerChMean, !expert, image);
1204   
1205   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
1206   hESDResidualYPerChMean->SetOption("P");
1207   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
1208   hESDResidualYPerChMean->SetMarkerColor(kRed);
1209   Add2ESDsList(hESDResidualYPerChMean, AliMUONQAIndices::kESDResidualYPerChMean, !expert, image);
1210   
1211   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
1212   hESDResidualXPerChSigma->SetOption("P");
1213   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
1214   hESDResidualXPerChSigma->SetMarkerColor(kRed);
1215   Add2ESDsList(hESDResidualXPerChSigma, AliMUONQAIndices::kESDResidualXPerChSigma, !expert, image);
1216   
1217   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
1218   hESDResidualYPerChSigma->SetOption("P");
1219   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
1220   hESDResidualYPerChSigma->SetMarkerColor(kRed);
1221   Add2ESDsList(hESDResidualYPerChSigma, AliMUONQAIndices::kESDResidualYPerChSigma, !expert, image);
1222   
1223   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerCh", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
1224   hESDLocalChi2XPerChMean->SetOption("P");
1225   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
1226   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
1227   Add2ESDsList(hESDLocalChi2XPerChMean, AliMUONQAIndices::kESDLocalChi2XPerChMean, !expert, image);
1228   
1229   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerCh", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
1230   hESDLocalChi2YPerChMean->SetOption("P");
1231   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
1232   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
1233   Add2ESDsList(hESDLocalChi2YPerChMean, AliMUONQAIndices::kESDLocalChi2YPerChMean, !expert, image);
1234   
1235   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);
1236   hESDLocalChi2PerChMean->SetOption("P");
1237   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
1238   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
1239   Add2ESDsList(hESDLocalChi2PerChMean, AliMUONQAIndices::kESDLocalChi2PerChMean, !expert, image);
1240   
1241   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
1242   hESDResidualXPerDEMean->SetOption("P");
1243   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
1244   hESDResidualXPerDEMean->SetMarkerColor(kRed);
1245   Add2ESDsList(hESDResidualXPerDEMean, AliMUONQAIndices::kESDResidualXPerDEMean, !expert, image);
1246   
1247   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
1248   hESDResidualYPerDEMean->SetOption("P");
1249   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
1250   hESDResidualYPerDEMean->SetMarkerColor(kRed);
1251   Add2ESDsList(hESDResidualYPerDEMean, AliMUONQAIndices::kESDResidualYPerDEMean, !expert, image);
1252   
1253   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
1254   hESDResidualXPerDESigma->SetOption("P");
1255   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
1256   hESDResidualXPerDESigma->SetMarkerColor(kRed);
1257   Add2ESDsList(hESDResidualXPerDESigma, AliMUONQAIndices::kESDResidualXPerDESigma, !expert, image);
1258   
1259   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
1260   hESDResidualYPerDESigma->SetOption("P");
1261   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
1262   hESDResidualYPerDESigma->SetMarkerColor(kRed);
1263   Add2ESDsList(hESDResidualYPerDESigma, AliMUONQAIndices::kESDResidualYPerDESigma, !expert, image);
1264   
1265   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDE", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
1266   hESDLocalChi2XPerDEMean->SetOption("P");
1267   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
1268   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
1269   Add2ESDsList(hESDLocalChi2XPerDEMean, AliMUONQAIndices::kESDLocalChi2XPerDEMean, !expert, image);
1270   
1271   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDE", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
1272   hESDLocalChi2YPerDEMean->SetOption("P");
1273   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
1274   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
1275   Add2ESDsList(hESDLocalChi2YPerDEMean, AliMUONQAIndices::kESDLocalChi2YPerDEMean, !expert, image);
1276   
1277   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);
1278   hESDLocalChi2PerDEMean->SetOption("P");
1279   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
1280   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
1281   Add2ESDsList(hESDLocalChi2PerDEMean, AliMUONQAIndices::kESDLocalChi2PerDEMean, !expert, image);
1282   
1283   // intermediate histograms
1284   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
1285   Add2ESDsList(hESDnTotClustersPerCh, AliMUONQAIndices::kESDnTotClustersPerCh, expert, !image);
1286   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
1287   Add2ESDsList(hESDnTotClustersPerDE, AliMUONQAIndices::kESDnTotClustersPerDE, expert, !image);
1288   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);
1289   Add2ESDsList(hESDnTotFullClustersPerDE, AliMUONQAIndices::kESDnTotFullClustersPerDE, expert, !image);
1290   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (fC)", nDE+1, -0.5, nDE+0.5);
1291   Add2ESDsList(hESDSumClusterChargePerDE, AliMUONQAIndices::kESDSumClusterChargePerDE, expert, !image);
1292   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
1293   Add2ESDsList(hESDSumClusterSizePerDE, AliMUONQAIndices::kESDSumClusterSizePerDE, expert, !image);
1294   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);
1295   Add2ESDsList(hESDSumResidualXPerDE, AliMUONQAIndices::kESDSumResidualXPerDE, expert, !image);
1296   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);
1297   Add2ESDsList(hESDSumResidualYPerDE, AliMUONQAIndices::kESDSumResidualYPerDE, expert, !image);
1298   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);
1299   Add2ESDsList(hESDSumResidualX2PerDE, AliMUONQAIndices::kESDSumResidualX2PerDE, expert, !image);
1300   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);
1301   Add2ESDsList(hESDSumResidualY2PerDE, AliMUONQAIndices::kESDSumResidualY2PerDE, expert, !image);
1302   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);
1303   Add2ESDsList(hESDSumLocalChi2XPerDE, AliMUONQAIndices::kESDSumLocalChi2XPerDE, expert, !image);
1304   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);
1305   Add2ESDsList(hESDSumLocalChi2YPerDE, AliMUONQAIndices::kESDSumLocalChi2YPerDE, expert, !image);
1306   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);
1307   Add2ESDsList(hESDSumLocalChi2PerDE, AliMUONQAIndices::kESDSumLocalChi2PerDE, expert, !image);
1308 }
1309
1310 //____________________________________________________________________________
1311 void AliMUONTrackerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
1312 {
1313         /// make QA for rawdata tracker
1314         
1315   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1316
1317   /// forces init
1318   GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1319   
1320   AliMUONTrackerDataMaker* dm = static_cast<AliMUONTrackerDataMaker*>(TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie())));
1321
1322         dm->SetRawReader(rawReader);
1323         
1324   Int_t eventType = rawReader->GetType();
1325   
1326   if (eventType == AliRawEventHeaderBase::kPhysicsEvent ) 
1327   {
1328     dm->ProcessEvent();
1329     
1330     FillEventSize(rawReader);
1331         
1332     if ( dm->LastEventWasEmpty() )
1333     {
1334       TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus);
1335
1336       if (hrostatus) hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents);
1337     }    
1338   }
1339 }
1340
1341 //__________________________________________________________________
1342 void AliMUONTrackerQADataMakerRec::MakeDigits(TTree* digitsTree)         
1343 {
1344   /// makes data from Digits
1345   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1346   
1347   /// forces init
1348
1349   GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1350
1351   if (!fDigitStore)
1352     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1353   fDigitStore->Connect(*digitsTree, false);
1354   digitsTree->GetEvent(0);
1355   
1356   TIter next(fDigitStore->CreateIterator());
1357   
1358   AliMUONVDigit* dig = 0x0;
1359   
1360   AliMUON2DMap oneEventData(true);
1361   
1362   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1363   {
1364     if ( dig->IsTracker() )
1365     {
1366       if ( dig->Charge() > 0.0 )
1367       {
1368         
1369         Int_t detElemId = dig->DetElemId();
1370         Int_t manuId = dig->ManuId();
1371         
1372         AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1373         if (!param)
1374         {
1375           param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,
1376                                           AliMUONVCalibParam::InvalidFloatValue());
1377           oneEventData.Add(param);
1378         }
1379         param->SetValueAsDouble(dig->ManuChannel(),0,dig->Charge());
1380       }
1381     }
1382   }
1383   
1384   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);
1385 }
1386
1387 //____________________________________________________________________________
1388 void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1389 {
1390         /// Fill histograms related to tracker clusters 
1391         
1392         // First things first : do we have clusters in the TreeR ?
1393         // In "normal" production mode, it should be perfectly normal
1394         // *not* to have them.
1395         // But if for some reason we de-activated the combined tracking,
1396         // then we have clusters in TreeR, so let's take that opportunity
1397         // to QA them...
1398         
1399   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1400   // Forces init by requesting an histogram
1401   GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy); 
1402
1403         if (!fClusterStore)
1404         {
1405           AliCodeTimerAuto("ClusterStore creation",1);
1406                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1407                 if (!fClusterStore) 
1408                 {
1409                         return;
1410                 }
1411         }
1412         
1413         fClusterStore->Connect(*clustersTree,kFALSE);
1414         clustersTree->GetEvent(0);
1415
1416         TIter next(fClusterStore->CreateIterator());
1417         AliMUONVCluster* cluster;
1418         
1419   AliMUONQAMappingCheck* mcr = MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()));
1420   
1421   if ( mcr ) mcr->NewEvent();
1422   
1423   AliMUON2DMap oneEventData(true);
1424   
1425         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1426         {
1427                 Int_t detElemId = cluster->GetDetElemId();
1428                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1429                 
1430                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1431                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1432                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1433
1434                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1435                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1436                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1437     GetRecPointsData(AliMUONQAIndices::kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1438                 
1439     if ( mcr ) mcr->Store(*cluster);
1440     
1441     for ( int i = 0; i < cluster->GetNDigits(); ++i ) 
1442     {
1443       UInt_t digitId = cluster->GetDigitId(i);
1444       
1445       Int_t manuId = AliMUONVDigit::ManuId(digitId);
1446       Int_t manuChannel = AliMUONVDigit::ManuChannel(digitId);
1447       
1448       AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1449       if (!param)
1450       {
1451         param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
1452         oneEventData.Add(param);
1453       }
1454       param->SetValueAsDouble(manuChannel,0,1.0);
1455     }
1456         }
1457         
1458   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);    
1459
1460         fClusterStore->Clear();
1461 }
1462
1463 //____________________________________________________________________________
1464 void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
1465 {
1466   /// make QA data from ESDs
1467
1468   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1469    
1470   // load ESD event in the interface
1471   AliMUONESDInterface esdInterface;
1472   if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
1473   else AliError("Unable to get recoParam: use default ones for residual calculation");
1474   esdInterface.LoadEvent(*esd);
1475   
1476   GetESDsData(AliMUONQAIndices::kESDnTracks)->Fill(esdInterface.GetNTracks());
1477   
1478   Int_t nTrackMatchTrig = 0;
1479   
1480   // loop over tracks
1481   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1482   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1483     
1484     // get the ESD track and skip "ghosts"
1485     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1486     if (!esdTrack->ContainTrackerData()) continue;
1487     
1488     // get corresponding MUON track
1489     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1490     
1491     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1492     
1493     GetESDsData(AliMUONQAIndices::kESDMomentum)->Fill(esdTrack->P());
1494     GetESDsData(AliMUONQAIndices::kESDPt)->Fill(esdTrack->Pt());
1495     GetESDsData(AliMUONQAIndices::kESDRapidity)->Fill(esdTrack->Y());
1496     GetESDsData(AliMUONQAIndices::kESDChi2)->Fill(track->GetNormalizedChi2());
1497     GetESDsData(AliMUONQAIndices::kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1498     GetESDsData(AliMUONQAIndices::kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1499     GetESDsData(AliMUONQAIndices::kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1500     GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->Fill(track->GetNClusters());
1501     
1502     // loop over clusters
1503     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1504     while (trackParam) {
1505       
1506       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1507       Int_t chId = cluster->GetChamberId();
1508       Int_t deID = cluster->GetDetElemId();
1509       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1510       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1511       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1512       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1513       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1514       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1515       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1516       
1517       GetESDsData(AliMUONQAIndices::kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1518       
1519       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh)->Fill(chId);
1520       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE)->Fill(deID);
1521       
1522       GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1523       GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1524       
1525       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1526         GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE)->Fill(deID);
1527         GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1528         GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1529       }
1530       
1531       GetESDsData(AliMUONQAIndices::kESDResidualXInCh+chId)->Fill(residualX);
1532       GetESDsData(AliMUONQAIndices::kESDResidualYInCh+chId)->Fill(residualY);
1533       GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE)->Fill(deID, residualX);
1534       GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE)->Fill(deID, residualY);
1535       GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1536       GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1537       
1538       GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1539       GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1540       GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+chId)->Fill(localChi2);
1541       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1542       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1543       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1544       
1545       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1546       
1547     }
1548     
1549   }
1550
1551   GetESDsData(AliMUONQAIndices::kESDMatchTrig)->Fill(nTrackMatchTrig);
1552   
1553 }
1554
1555 //____________________________________________________________________________ 
1556 AliMUONVTrackerData* AliMUONTrackerQADataMakerRec::GetTrackerData() const
1557
1558   /// Return tracker data
1559   
1560   return TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Data(); 
1561 }
1562
1563 //____________________________________________________________________________ 
1564 void
1565 AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
1566 {
1567   /// Reset those histograms that must be reset (and only those), plus
1568   /// the trackerdata itself.
1569   
1570   TIter next(list);
1571   TObject* o;
1572   while ( ( o = next() ) )
1573   {
1574     TH1* h = dynamic_cast<TH1*>(o);
1575     if (h)
1576     {
1577       TString hn(h->GetName());
1578       
1579       if ( !hn.Contains("TrackerBusPatchConfig") )
1580       {
1581         AliDebug(1,Form("Resetting %s",hn.Data()));
1582
1583         h->Reset();
1584       }
1585       else
1586       {
1587         AliDebug(1,Form("Will not reset histogram %s",hn.Data()));          
1588       }
1589     }
1590     else
1591     {
1592       AliMUONVTrackerData* d = dynamic_cast<AliMUONVTrackerData*>(o);
1593       if (d)
1594       {
1595         AliDebug(1,Form("Resetting %s",d->GetName()));
1596         d->Clear();
1597       }
1598       else
1599       {
1600         AliError(Form("Found an object of class %s. Do not know how to reset.",o->ClassName()));
1601       }
1602     }
1603   }
1604   
1605   fLogger->Clear();
1606 }
1607
1608 //____________________________________________________________________________ 
1609 TObjArray* AliMUONTrackerQADataMakerRec::GetArray(TObjArray*& array, Bool_t create)
1610 {
1611   /// Get (or create) the array
1612
1613   if ( ! array ) 
1614   {
1615     if ( create ) 
1616     {
1617       array = new TObjArray(AliRecoParam::kNSpecies);
1618     }
1619   }
1620   
1621   return array;
1622 }
1623
1624 //____________________________________________________________________________ 
1625 AliMUONVTrackerDataMaker* 
1626 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex)  const
1627 {
1628   /// const version of the getter
1629   if ( fTrackerDataMakerArray )
1630   {
1631     return static_cast<AliMUONVTrackerDataMaker*>(fTrackerDataMakerArray->At(specieIndex));
1632   }
1633   return 0x0;
1634 }
1635
1636 //____________________________________________________________________________ 
1637 AliMUONVTrackerDataMaker* 
1638 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex, Bool_t create)
1639 {
1640   /// Get (or create) TrackerDataMaker object for a given specie
1641   
1642   TObjArray* array = GetArray(fTrackerDataMakerArray,create);
1643   TObject* o(0x0);
1644   
1645   if ( array ) 
1646   {
1647     array->SetOwner(kTRUE);
1648     o = array->At(specieIndex);
1649     if (!o && create)
1650     {
1651       
1652       AliMUONTrackerDataMaker* dm = new AliMUONTrackerDataMaker(0x0,
1653                                                                 AliCDBManager::Instance()->GetRun(),
1654                                                                 0x0,
1655                                                                 "",
1656                                                                 "",
1657                                                                 kFALSE,
1658                                                                 0.0,0.0);
1659       
1660       if (!fLogger) fLogger = new AliMUONLogger(-1); // note that we share the logger between species... should not be a big deal though
1661       dm->EnableErrorLogger(fLogger);
1662       dm->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level    
1663       dm->Data()->SetName("RawCharges");
1664       dm->SetRunning(kTRUE);
1665
1666       o = dm;
1667       array->AddAt(o,specieIndex);      
1668     }
1669   }
1670   return static_cast<AliMUONVTrackerDataMaker*>(o);
1671 }
1672
1673 //____________________________________________________________________________ 
1674 AliMUONVTrackerData* 
1675 AliMUONTrackerQADataMakerRec::TrackerCalData(Int_t specieIndex, Bool_t create)
1676 {
1677   TObjArray* array = GetArray(fTrackerCalDataArray,create);
1678   TObject* o(0x0);
1679   
1680   if (array)
1681   {
1682     o = array->At(specieIndex);
1683     if (!o && create)
1684     {
1685       AliMUONTrackerData* data = new AliMUONTrackerData("CalCharges",Form("Calibrated charges (fC) %s",GetRecoParam()->GetCalibrationMode()),1);
1686       data->SetDimensionName(0,"charge");
1687       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1688       o=data;
1689       array->AddAt(o,specieIndex);
1690     }
1691   }
1692   return static_cast<AliMUONVTrackerData*>(o);
1693 }
1694
1695 //____________________________________________________________________________ 
1696 AliMUONVTrackerData* 
1697 AliMUONTrackerQADataMakerRec::TrackerRecData(Int_t specieIndex, Bool_t create)
1698 {
1699   TObjArray* array = GetArray(fTrackerRecDataArray,create);
1700   TObject* o(0x0);
1701   
1702   if (array)
1703   {
1704     o = array->At(specieIndex);
1705     if (!o && create)
1706     {
1707       AliMUONTrackerData* data = new AliMUONTrackerData("RecCharges",Form("Calibrated charges (fC) %s for digits belonging to a reconstructed cluster",GetRecoParam()->GetCalibrationMode()),1);
1708       data->SetDimensionName(0,"one");
1709       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1710       o=data;
1711       array->AddAt(o,specieIndex);
1712     }
1713   }
1714   return static_cast<AliMUONVTrackerData*>(o);
1715 }
1716
1717 //____________________________________________________________________________ 
1718 AliMUONQAMappingCheck* 
1719 AliMUONTrackerQADataMakerRec::MappingCheckRecPoints(Int_t specieIndex, Bool_t create)
1720 {
1721   TObjArray* array = GetArray(fMappingCheckRecPointsArray,create);
1722   TObject* o(0x0);
1723   
1724   if (array)
1725   {
1726     o = array->At(specieIndex);
1727     array->SetOwner(kTRUE);
1728     if (!o && create)
1729     {
1730       AliMUONQAMappingCheck* mcheck = new AliMUONQAMappingCheck(RunNumber()); 
1731       o=mcheck;
1732       array->AddAt(o,specieIndex);
1733     }
1734   }
1735   return static_cast<AliMUONQAMappingCheck*>(o);
1736 }