]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackerQADataMakerRec.cxx
Coverity fix
[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     if ( fLogger->NumberOfEntries() > 0 )
583     {
584       // readout errors      
585       FillReadoutStatus(*fLogger,TrackerDataMaker(specie)->Data());      
586       fLogger->Clear();
587     }
588   }    
589 }
590
591 //____________________________________________________________________________ 
592 void AliMUONTrackerQADataMakerRec::FillReadoutStatus(AliMUONLogger& log, AliMUONVTrackerData* data)
593 {
594   log.ResetItr();
595
596   TString msg;
597   Int_t occurence;
598   
599   TH1* hparity = GetRawsData(AliMUONQAIndices::kTrackerBusPatchParityErrors);
600
601   TH1* htoken = GetRawsData(AliMUONQAIndices::kTrackerBusPatchTokenLostErrors);
602
603   TH1* hpadding = GetRawsData(AliMUONQAIndices::kTrackerBusPatchPaddingErrors);
604   
605   TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus);
606     
607   TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen);
608   
609   Int_t nevents = TMath::Nint(hnevents->GetBinContent(1));
610   
611   if ( !nevents ) 
612   {
613     TPaveText* text = new TPaveText(0,0,0.99,0.99,"NDC");
614     text->AddText("FATAL : 0 event seen ? That's NOT normal...");
615     text->SetFillColor(2); // red = FATAL
616     hrostatus->GetListOfFunctions()->Add(text);
617     return;
618   }
619   
620   /////////////////////////////////////////////////////////////////
621   /// Start by counting the number of errors
622   /////////////////////////////////////////////////////////////////
623   
624   while ( log.Next(msg,occurence) )
625   {
626     AliDebug(1,Form("msg=%s occurence=%d",msg.Data(),occurence));
627              
628     if ( msg.Contains("token") )
629     {
630       Int_t dsp(-1),iddl(-1),ecode(-1);
631       
632       sscanf(msg.Data(),"Lost token error detected with address 0x%X of DDL %d and code %d.",
633              &dsp,&iddl,&ecode);
634       Int_t localBP = ((dsp >> 16)- 4)*5 + 1;
635       Int_t buspatch = localBP + iddl*100;
636       
637       // Let's try to get all the suspected bus patches (i.e. one full FRT, as currently
638       // we don't have more precise information to locate the faulty bus patch(es)).
639       
640       AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatch,kFALSE);
641       if (bp)
642       {
643         Int_t frt = bp->GetFrtId();
644         AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(bp->GetDdlId());
645         Int_t* b = new Int_t[ddl->GetMaxDsp()];
646         ddl->GetBusPerDsp(b);
647         Int_t nbus(0);
648         for ( Int_t i = 0; i < ddl->GetNofFrts() && !nbus; ++i ) 
649         {
650           if ( ddl->GetFrtId(i) == frt ) 
651           {
652             nbus = b[i];
653           }
654         }
655         if (nbus<=0) 
656         {
657           AliError("GOT NBUS<=0 ! THAT IS BAD ! CHECK !");
658           nbus=1;
659         }
660         delete[] b;
661       
662         while (nbus) {
663           htoken->Fill(buspatch+nbus-1,occurence);
664           --nbus;
665         }
666       }
667       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors,occurence);
668     }
669     
670     if ( msg.Contains("Parity") )
671     {
672       Int_t buspatch;
673       sscanf(msg.Data(),"Parity error in buspatch %d (0x%X).",&buspatch,&buspatch);
674       hparity->Fill(buspatch,occurence);      
675       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors,occurence);
676     }
677     
678     if ( msg.Contains("Glitch") ) 
679     {
680       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors,occurence);      
681     }
682     
683     if ( msg.Contains("Padding") )
684     {
685       Int_t block, dsp, buspatch;      
686       sscanf(msg.Data(),"Padding word error for iBlock %d, iDsp %d, iBus %d.",&block,&dsp,&buspatch);
687       hpadding->Fill(buspatch,occurence);
688       hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors,occurence);      
689     }
690   }
691   
692   /////////////////////////////////////////////////////////////////
693   ///
694   /// Then make the status about number of missing bus patches
695   ///
696   /////////////////////////////////////////////////////////////////
697
698   Int_t nofBusPatchesNotInConfig(0);
699     
700   for ( int i = 1; i <= fBusPatchConfig->GetNbinsX(); ++i )
701   {
702     Double_t buspatchId = fBusPatchConfig->GetBinCenter(i);
703     if ( TMath::Nint(buspatchId) != i ) 
704     {
705       AliError(Form("buspathId=%e i=%d",buspatchId,i));
706     }
707     Double_t content = fBusPatchConfig->GetBinContent(i);
708     
709     if ( content <= 0. /* no content */
710         && 
711         AliMpDDLStore::Instance()->GetBusPatch(i,kFALSE) /* but a valid bus patch */ )
712     {
713       ++nofBusPatchesNotInConfig;
714     }    
715   }
716   
717   Double_t nbuspatches = fBusPatchConfig->GetEntries();
718   
719   Int_t bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig);
720   hrostatus->SetBinContent(bin,nofBusPatchesNotInConfig*nevents/nbuspatches);
721   
722   Double_t nofBusPatchesNotInData(0);
723   
724   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
725   AliMpBusPatch* bp;
726   
727   while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
728   {
729     if ( !data->HasBusPatch(bp->GetId()) ) ++nofBusPatchesNotInData;
730   }
731   
732   bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream);
733   hrostatus->SetBinContent(bin,nofBusPatchesNotInData*nevents/nbuspatches);
734 }
735
736 //____________________________________________________________________________ 
737 void AliMUONTrackerQADataMakerRec::FillEventSize(AliRawReader* rawReader)
738 {
739   /// Fill event size histogram(s)
740   
741   TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen);
742
743   TH1* hddlevents = GetRawsData(AliMUONQAIndices::kTrackerDDLNofEventsSeen);
744   
745   TH1* hDDLEventSize = GetRawsData(AliMUONQAIndices::kTrackerDDLEventSize);
746   
747   hnevents->Fill(0.0);
748   
749   Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
750   
751   for ( int i = 0; i < AliDAQ::NumberOfDdls("MUONTRK"); ++i )
752   {
753     rawReader->Reset();
754     rawReader->Select("MUONTRK",i,i);
755     if (rawReader->ReadHeader() )
756     {
757       UInt_t ddlsize = rawReader->GetEquipmentSize();
758       hDDLEventSize->Fill(i+offset,ddlsize);
759       hddlevents->Fill(i+offset);
760     }      
761   }
762   rawReader->Reset();
763 }
764
765 //____________________________________________________________________________ 
766 void AliMUONTrackerQADataMakerRec::InitCommon()
767 {  
768   if (!fBusPatchConfig)
769   {
770     Int_t bpmin(999999);
771     Int_t bpmax(0);
772     
773     TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
774     AliMpBusPatch* bp(0x0);
775     while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
776     {
777       bpmin = TMath::Min(bpmin,bp->GetId());
778       bpmax = TMath::Max(bpmax,bp->GetId());
779     }
780     
781     fBPxmin = bpmin-0.5;
782     fBPxmax = bpmax+0.5;
783     fBPnbins = TMath::Nint(fBPxmax-fBPxmin);
784         
785     AliMUONVStore* config = fCalibrationData->Config();
786     
787     if (config)
788     {
789       fBusPatchConfig = new TH1F("hTrackerBusPatchConfig","Configuration of bus patches",fBPnbins,fBPxmin,fBPxmax);
790       fBusPatchConfig->SetDirectory(0);
791     }
792     else
793     {
794       AliWarning("Tracker configuration not found. Will not be able to cut on low occupancies");
795     }
796     
797     next.Reset();
798     while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
799     {
800       if ( config ) 
801       {
802         Int_t nofManusInConfig(0);
803       
804         for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
805         {
806           Int_t manuId = bp->GetManuId(imanu);
807           if ( config->FindObject(bp->GetDEId(),manuId)) ++nofManusInConfig;
808         }
809         
810         if ( nofManusInConfig > 0 )
811         {
812           fBusPatchConfig->Fill(bp->GetId(),1.0);
813         }
814         else
815         {
816           fBusPatchConfig->Fill(bp->GetId(),0.0);          
817         }
818       }      
819       else // no config, we assume all is there...
820       {
821         fBusPatchConfig->Fill(bp->GetId());
822       }
823     }
824   }
825 }
826
827 //____________________________________________________________________________ 
828 void AliMUONTrackerQADataMakerRec::BookHistograms(AliQAv1::TASKINDEX_t task)
829 {
830   AliCodeTimerAuto("",0);
831
832   InitCommon();
833   
834   const Bool_t expert   = kTRUE ; 
835   const Bool_t saveCorr = kTRUE ; 
836   const Bool_t image    = kTRUE ; 
837   
838   TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",fBPnbins,fBPxmin,fBPxmax);
839   
840   Master()->Add2List(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, task, expert, !image, !saveCorr);
841   
842   TH1* h = new TH1F("hTrackerBusPatchParityErrors","Number of parity errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
843   
844   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchParityErrors,task,expert,!image,!saveCorr);
845   
846   h = new TH1F("hTrackerBusPatchTokenLostErrors","Number of token lost errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
847   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchTokenLostErrors,task,expert,!image,!saveCorr);
848   
849   h = new TH1F("hTrackerBusPatchPaddingErrors","Number of padding errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
850   
851   Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchPaddingErrors,task,expert,!image,!saveCorr);
852   
853   
854   TH1* hnevents(0x0);
855   
856   if ( task == AliQAv1::kRAWS )
857   {
858     // for raw data, we differentiate events seen from events used to be able to detect
859     // severe decoder errors that lead to no event decoded (i.e. zero event used) even if
860     // events are there (i.e non-zero event seen).
861     hnevents = new TH1F("hTrackerNofPhysicsEventsSeen","Number of physics events seen",1,-0.5,0.5);
862     // this one will count the number of physics event the rawdatamaker is *seeing*
863     TAxis* a = hnevents->GetXaxis();
864     a->SetBinLabel(1,"NPhysicsEvents");
865     hnevents->SetStats(kFALSE);
866     Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofPhysicsEventsSeen,task,expert,!image,!saveCorr);
867   }
868   
869   hnevents = new TH1F("hTrackerNofGoodPhysicsEventsUsed","Number of good physics events used",1,-0.5,0.5);
870   // this one will get its content from the TrackerData, i.e. it will count the number of *good* physics events *used*
871   // (i.e. not empty and with no fatal readout error)
872   TAxis* a = hnevents->GetXaxis();
873   a->SetBinLabel(1,"NGoodPhysicsEvents");
874   hnevents->SetStats(kFALSE);  
875
876   Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed,task,expert,!image,!saveCorr);
877
878   Master()->Add2List(static_cast<TH1*>(fBusPatchConfig->Clone()),AliMUONQAIndices::kTrackerBusPatchConfig, task,expert, !image, !saveCorr);
879
880   Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
881   const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
882   
883   Double_t xmin = offset - 0.5;
884   Double_t xmax  = offset + nbins - 0.5;
885   
886   TString what(AliQAv1::GetTaskName(task));
887   
888   h = new TH1F(Form("hTrackerDDL%sOccupancy",what.Data()),Form(";DDLId;DDL Occupancy in %% (from %s)",what.Data()),nbins,xmin,xmax);
889   
890   Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLOccupancy,task,expert,!image,!saveCorr);
891
892   if ( task == AliQAv1::kRAWS )
893   {
894     // see above the comment about why we have event seen vs used for raw data.
895     h = new TH1F("hTrackerDDLNofEventsSeen","Number of events seen by DDL;DDLId",nbins,xmin,xmax);
896     Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsSeen,task,expert,!image,!saveCorr);
897   }
898   
899   h = new TH1F("hTrackerDDLNofEventsUsed","Number of events used by DDL;DDLId",nbins,xmin,xmax);
900   Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsUsed,task,expert,!image,!saveCorr);
901   
902 }
903
904 //____________________________________________________________________________ 
905 void AliMUONTrackerQADataMakerRec::InitRaws()
906 {
907   /// create monitor objects for RAWS
908         
909   TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
910   
911   /// Book histograms that are common to Raws and Digits
912   BookHistograms(AliQAv1::kRAWS);
913   
914   /// Now the Raws specific parts
915   TH1* h = new TH1F("hTrackerReadoutStatus","Readout status (x events)",7,-0.5,6.5);
916   h->SetStats(kFALSE);
917   
918   TAxis* a = h->GetXaxis();
919   
920   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors),"Glitch errors");
921   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors),"Token lost errors");
922   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors),"Parity errors");
923   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors),"Padding errors");
924   
925   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents),"Empty events");
926   
927   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig),"Not readout bus patches");
928   a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream),"Missing bus patches");
929
930   TH1* h1 = static_cast<TH1*>(h->Clone("hTrackerReadoutStatusPerEvent"));
931   h1->SetTitle("Readout status per event");
932   h1->GetYaxis()->SetTitle("Percentage");
933   
934   // The QA shifter will only see the summary plot below
935
936   Add2RawsList(h,AliMUONQAIndices::kTrackerReadoutStatus,kTRUE,kFALSE,kFALSE);    
937   Add2RawsList(h1,AliMUONQAIndices::kTrackerReadoutStatusPerEvent,kFALSE,kTRUE,kFALSE);  
938
939   // Lastly the event size histograms
940   
941   Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
942   const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
943   
944   Double_t xmin = offset - 0.5;
945   Double_t xmax  = offset + nbins - 0.5;
946   
947   h = new TH1F("hTrackerDDLEventSize","DDL event size (bytes);DDL Id;Data size (bytes)",nbins,xmin,xmax);  
948   h->SetStats(kFALSE);
949   Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSize,kTRUE,kFALSE,kFALSE);
950
951   h = new TH1F("hTrackerDDLMeanEventSize","DDL mean event size (KB) per event;DDL Id;Mean Event size (KB)",nbins,xmin,xmax);  
952   h->SetStats(kFALSE);
953   Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSizePerEvent,kFALSE,kTRUE,kFALSE);
954     
955   Add2RawsList(new TH1F("hTrackerIsThere","tracker is there",1,0,1),AliMUONQAIndices::kTrackerIsThere,kTRUE,kFALSE,kFALSE);
956 }
957
958 //__________________________________________________________________
959 void AliMUONTrackerQADataMakerRec::InitDigits() 
960 {
961   /// create monitor objects for DIGITS
962   
963   AliCodeTimerAuto("",0);
964
965   if ( GetRecoParam()->TryRecover() )
966   {
967     fDigitMaker->SetTryRecover(kTRUE);
968   }
969   else
970   {
971     fDigitMaker->SetTryRecover(kFALSE);    
972   }
973   
974   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
975   
976   /// Book histograms that are common to Raws and Digits
977   BookHistograms(AliQAv1::kDIGITSR);
978
979
980 //____________________________________________________________________________ 
981 void AliMUONTrackerQADataMakerRec::InitRecPoints()
982 {
983   /// create Reconstructed Points histograms in RecPoints subdir for the
984   /// MUON tracker subsystem.
985   const Bool_t expert   = kTRUE ; 
986   const Bool_t image    = kTRUE ; 
987   
988   AliCodeTimerAuto("",0);
989
990   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
991   
992   BookHistograms(AliQAv1::kRECPOINTS);
993   
994   TH1I *h1I;
995   TH1F *h1F;
996   TH2F *h2F;
997   
998   // histograms per chamber
999   Int_t nCh = AliMpConstants::NofTrackingChambers();
1000   for ( Int_t i = 0; i < nCh; ++i ) 
1001   {
1002     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
1003     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+i, expert, !image);
1004     
1005     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC);Counts",i+1), 100,0,1000);
1006     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerChamber+i, expert, !image);
1007     
1008     Float_t rMax = AliMUONConstants::Rmax(i/2);
1009     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);
1010     Add2RecPointsList(h2F, AliMUONQAIndices::kTrackerClusterHitMapPerChamber+i, expert, !image);
1011   }
1012   
1013   // summary histograms per chamber
1014   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
1015   Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerNumberOfClustersPerChamber, !expert, image);
1016   
1017   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
1018   h1F->SetOption("P");
1019   h1F->SetMarkerStyle(kFullDotMedium);
1020   h1F->SetMarkerColor(kRed);
1021   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean, !expert, image);
1022   
1023   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
1024   h1F->SetOption("P");
1025   h1F->SetMarkerStyle(kFullDotMedium);
1026   h1F->SetMarkerColor(kRed);
1027   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma, !expert, image);
1028   
1029   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh,-0.5,nCh-0.5);
1030   h1F->SetOption("P");
1031   h1F->SetMarkerStyle(kFullDotMedium);
1032   h1F->SetMarkerColor(kRed);
1033   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChMean, !expert, image);
1034   
1035   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh,-0.5,nCh-0.5);
1036   h1F->SetOption("P");
1037   h1F->SetMarkerStyle(kFullDotMedium);
1038   h1F->SetMarkerColor(kRed);
1039   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChSigma, !expert, image);
1040   
1041   // histograms per DE
1042   Int_t ndes(0);
1043   AliMpDEIterator it;
1044   it.First();
1045   while ( !it.IsDone())
1046   {
1047     Int_t detElemId = it.CurrentDEId();
1048     
1049     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
1050     {
1051       ndes = TMath::Max(ndes,detElemId);
1052       
1053       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
1054       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
1055       
1056       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (fC)",detElemId), 100,0,1000);
1057       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId, expert, !image);
1058     }
1059     
1060     it.Next();
1061   }
1062   
1063   // summary histograms per DE
1064   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
1065   Add2RecPointsList(h1I, AliMUONQAIndices::kTrackerNumberOfClustersPerDE, !expert, image);
1066   
1067   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
1068   h1F->SetOption("P");
1069   h1F->SetMarkerStyle(kFullDotMedium);
1070   h1F->SetMarkerColor(kRed);
1071   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean, !expert, image);
1072   
1073   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", ndes+1,-0.5,ndes+0.5);
1074   h1F->SetOption("P");
1075   h1F->SetMarkerStyle(kFullDotMedium);
1076   h1F->SetMarkerColor(kRed);
1077   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerDEMean, !expert, image);
1078   
1079   MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
1080 }
1081
1082 //____________________________________________________________________________ 
1083 void AliMUONTrackerQADataMakerRec::InitESDs()
1084 {
1085   ///create ESDs histograms in ESDs subdir
1086   
1087   const Bool_t expert   = kTRUE ; 
1088   const Bool_t image    = kTRUE ; 
1089   
1090   Int_t nCh = AliMUONConstants::NTrackingCh();
1091   Int_t nDE = 1100;
1092   
1093   // track info
1094   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
1095   Add2ESDsList(hESDnTracks, AliMUONQAIndices::kESDnTracks, !expert, image);
1096
1097   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
1098   Add2ESDsList(hESDMatchTrig, AliMUONQAIndices::kESDMatchTrig, !expert, image);
1099   
1100   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
1101   Add2ESDsList(hESDMomentum, AliMUONQAIndices::kESDMomentum, !expert, image);
1102
1103   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
1104   Add2ESDsList(hESDPt, AliMUONQAIndices::kESDPt, !expert, image);
1105
1106   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
1107   Add2ESDsList(hESDRapidity, AliMUONQAIndices::kESDRapidity, !expert, image);
1108
1109   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
1110   Add2ESDsList(hESDChi2, AliMUONQAIndices::kESDChi2, !expert, image);
1111   
1112   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
1113   Add2ESDsList(hESDProbChi2, AliMUONQAIndices::kESDProbChi2, !expert, image);
1114   
1115   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
1116   Add2ESDsList(hESDThetaX, AliMUONQAIndices::kESDThetaX, !expert, image);
1117   
1118   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
1119   Add2ESDsList(hESDThetaY, AliMUONQAIndices::kESDThetaY, !expert, image);
1120   
1121   // cluster info
1122   for (Int_t i = 0; i < nCh; i++) {
1123     Float_t rMax = AliMUONConstants::Rmax(i/2);
1124     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
1125                                        100, -rMax, rMax, 100, -rMax, rMax);
1126     Add2ESDsList(hESDClusterHitMap, AliMUONQAIndices::kESDClusterHitMap+i, expert, !image);
1127   }
1128   
1129   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
1130   Add2ESDsList(hESDnClustersPerTrack, AliMUONQAIndices::kESDnClustersPerTrack, !expert, image);
1131   
1132   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
1133   hESDnClustersPerCh->SetFillColor(kRed);
1134   Add2ESDsList(hESDnClustersPerCh, AliMUONQAIndices::kESDnClustersPerCh, !expert, image);
1135   
1136   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
1137   hESDnClustersPerDE->SetFillColor(kRed);
1138   Add2ESDsList(hESDnClustersPerDE, AliMUONQAIndices::kESDnClustersPerDE, !expert, image);
1139   
1140   for (Int_t i = 0; i < nCh; i++) {
1141     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
1142     Add2ESDsList(hESDClusterChargeInCh, AliMUONQAIndices::kESDClusterChargeInCh+i, expert, !image);
1143   }
1144   
1145   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
1146   hESDClusterChargePerChMean->SetOption("P");
1147   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
1148   hESDClusterChargePerChMean->SetMarkerColor(kRed);
1149   Add2ESDsList(hESDClusterChargePerChMean, AliMUONQAIndices::kESDClusterChargePerChMean, !expert, image);
1150   
1151   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
1152   hESDClusterChargePerChSigma->SetOption("P");
1153   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
1154   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
1155   Add2ESDsList(hESDClusterChargePerChSigma, AliMUONQAIndices::kESDClusterChargePerChSigma, !expert, image);
1156   
1157   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
1158   hESDClusterChargePerDE->SetOption("P");
1159   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
1160   hESDClusterChargePerDE->SetMarkerColor(kRed);
1161   Add2ESDsList(hESDClusterChargePerDE, AliMUONQAIndices::kESDClusterChargePerDE, !expert, image);
1162   
1163   for (Int_t i = 0; i < nCh; i++) {
1164     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
1165     Add2ESDsList(hESDClusterSizeInCh, AliMUONQAIndices::kESDClusterSizeInCh+i, expert, !image);
1166   }
1167   
1168   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
1169   hESDClusterSizePerChMean->SetOption("P");
1170   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
1171   hESDClusterSizePerChMean->SetMarkerColor(kRed);
1172   Add2ESDsList(hESDClusterSizePerChMean, AliMUONQAIndices::kESDClusterSizePerChMean, !expert, image);
1173   
1174   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
1175   hESDClusterSizePerChSigma->SetOption("P");
1176   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
1177   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
1178   Add2ESDsList(hESDClusterSizePerChSigma, AliMUONQAIndices::kESDClusterSizePerChSigma, !expert, image);
1179   
1180   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
1181   hESDClusterSizePerDE->SetOption("P");
1182   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
1183   hESDClusterSizePerDE->SetMarkerColor(kRed);
1184   Add2ESDsList(hESDClusterSizePerDE, AliMUONQAIndices::kESDClusterSizePerDE, !expert, image);
1185   
1186   // cluster - track info
1187   for (Int_t i = 0; i < nCh; i++) {
1188     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.);
1189     Add2ESDsList(hESDResidualXInCh, AliMUONQAIndices::kESDResidualXInCh+i, expert, !image);
1190     
1191     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.);
1192     Add2ESDsList(hESDResidualYInCh, AliMUONQAIndices::kESDResidualYInCh+i, expert, !image);
1193     
1194     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);
1195     Add2ESDsList(hESDLocalChi2XInCh, AliMUONQAIndices::kESDLocalChi2XInCh+i, expert, !image);
1196     
1197     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);
1198     Add2ESDsList(hESDLocalChi2YInCh, AliMUONQAIndices::kESDLocalChi2YInCh+i, expert, !image);
1199     
1200     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);
1201     Add2ESDsList(hESDLocalChi2InCh, AliMUONQAIndices::kESDLocalChi2InCh+i, expert, !image);
1202   }
1203   
1204   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
1205   hESDResidualXPerChMean->SetOption("P");
1206   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
1207   hESDResidualXPerChMean->SetMarkerColor(kRed);
1208   Add2ESDsList(hESDResidualXPerChMean, AliMUONQAIndices::kESDResidualXPerChMean, !expert, image);
1209   
1210   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
1211   hESDResidualYPerChMean->SetOption("P");
1212   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
1213   hESDResidualYPerChMean->SetMarkerColor(kRed);
1214   Add2ESDsList(hESDResidualYPerChMean, AliMUONQAIndices::kESDResidualYPerChMean, !expert, image);
1215   
1216   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
1217   hESDResidualXPerChSigma->SetOption("P");
1218   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
1219   hESDResidualXPerChSigma->SetMarkerColor(kRed);
1220   Add2ESDsList(hESDResidualXPerChSigma, AliMUONQAIndices::kESDResidualXPerChSigma, !expert, image);
1221   
1222   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
1223   hESDResidualYPerChSigma->SetOption("P");
1224   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
1225   hESDResidualYPerChSigma->SetMarkerColor(kRed);
1226   Add2ESDsList(hESDResidualYPerChSigma, AliMUONQAIndices::kESDResidualYPerChSigma, !expert, image);
1227   
1228   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerCh", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
1229   hESDLocalChi2XPerChMean->SetOption("P");
1230   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
1231   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
1232   Add2ESDsList(hESDLocalChi2XPerChMean, AliMUONQAIndices::kESDLocalChi2XPerChMean, !expert, image);
1233   
1234   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerCh", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
1235   hESDLocalChi2YPerChMean->SetOption("P");
1236   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
1237   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
1238   Add2ESDsList(hESDLocalChi2YPerChMean, AliMUONQAIndices::kESDLocalChi2YPerChMean, !expert, image);
1239   
1240   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);
1241   hESDLocalChi2PerChMean->SetOption("P");
1242   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
1243   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
1244   Add2ESDsList(hESDLocalChi2PerChMean, AliMUONQAIndices::kESDLocalChi2PerChMean, !expert, image);
1245   
1246   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
1247   hESDResidualXPerDEMean->SetOption("P");
1248   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
1249   hESDResidualXPerDEMean->SetMarkerColor(kRed);
1250   Add2ESDsList(hESDResidualXPerDEMean, AliMUONQAIndices::kESDResidualXPerDEMean, !expert, image);
1251   
1252   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
1253   hESDResidualYPerDEMean->SetOption("P");
1254   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
1255   hESDResidualYPerDEMean->SetMarkerColor(kRed);
1256   Add2ESDsList(hESDResidualYPerDEMean, AliMUONQAIndices::kESDResidualYPerDEMean, !expert, image);
1257   
1258   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
1259   hESDResidualXPerDESigma->SetOption("P");
1260   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
1261   hESDResidualXPerDESigma->SetMarkerColor(kRed);
1262   Add2ESDsList(hESDResidualXPerDESigma, AliMUONQAIndices::kESDResidualXPerDESigma, !expert, image);
1263   
1264   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
1265   hESDResidualYPerDESigma->SetOption("P");
1266   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
1267   hESDResidualYPerDESigma->SetMarkerColor(kRed);
1268   Add2ESDsList(hESDResidualYPerDESigma, AliMUONQAIndices::kESDResidualYPerDESigma, !expert, image);
1269   
1270   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDE", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
1271   hESDLocalChi2XPerDEMean->SetOption("P");
1272   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
1273   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
1274   Add2ESDsList(hESDLocalChi2XPerDEMean, AliMUONQAIndices::kESDLocalChi2XPerDEMean, !expert, image);
1275   
1276   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDE", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
1277   hESDLocalChi2YPerDEMean->SetOption("P");
1278   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
1279   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
1280   Add2ESDsList(hESDLocalChi2YPerDEMean, AliMUONQAIndices::kESDLocalChi2YPerDEMean, !expert, image);
1281   
1282   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);
1283   hESDLocalChi2PerDEMean->SetOption("P");
1284   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
1285   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
1286   Add2ESDsList(hESDLocalChi2PerDEMean, AliMUONQAIndices::kESDLocalChi2PerDEMean, !expert, image);
1287   
1288   // intermediate histograms
1289   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
1290   Add2ESDsList(hESDnTotClustersPerCh, AliMUONQAIndices::kESDnTotClustersPerCh, expert, !image);
1291   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
1292   Add2ESDsList(hESDnTotClustersPerDE, AliMUONQAIndices::kESDnTotClustersPerDE, expert, !image);
1293   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);
1294   Add2ESDsList(hESDnTotFullClustersPerDE, AliMUONQAIndices::kESDnTotFullClustersPerDE, expert, !image);
1295   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (fC)", nDE+1, -0.5, nDE+0.5);
1296   Add2ESDsList(hESDSumClusterChargePerDE, AliMUONQAIndices::kESDSumClusterChargePerDE, expert, !image);
1297   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
1298   Add2ESDsList(hESDSumClusterSizePerDE, AliMUONQAIndices::kESDSumClusterSizePerDE, expert, !image);
1299   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);
1300   Add2ESDsList(hESDSumResidualXPerDE, AliMUONQAIndices::kESDSumResidualXPerDE, expert, !image);
1301   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);
1302   Add2ESDsList(hESDSumResidualYPerDE, AliMUONQAIndices::kESDSumResidualYPerDE, expert, !image);
1303   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);
1304   Add2ESDsList(hESDSumResidualX2PerDE, AliMUONQAIndices::kESDSumResidualX2PerDE, expert, !image);
1305   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);
1306   Add2ESDsList(hESDSumResidualY2PerDE, AliMUONQAIndices::kESDSumResidualY2PerDE, expert, !image);
1307   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);
1308   Add2ESDsList(hESDSumLocalChi2XPerDE, AliMUONQAIndices::kESDSumLocalChi2XPerDE, expert, !image);
1309   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);
1310   Add2ESDsList(hESDSumLocalChi2YPerDE, AliMUONQAIndices::kESDSumLocalChi2YPerDE, expert, !image);
1311   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);
1312   Add2ESDsList(hESDSumLocalChi2PerDE, AliMUONQAIndices::kESDSumLocalChi2PerDE, expert, !image);
1313 }
1314
1315 //____________________________________________________________________________
1316 void AliMUONTrackerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
1317 {
1318         /// make QA for rawdata tracker
1319         
1320   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1321
1322   /// forces init
1323   GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1324   
1325   AliMUONTrackerDataMaker* dm = static_cast<AliMUONTrackerDataMaker*>(TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie())));
1326
1327         dm->SetRawReader(rawReader);
1328         
1329   Int_t eventType = rawReader->GetType();
1330   
1331   if (eventType == AliRawEventHeaderBase::kPhysicsEvent ) 
1332   {
1333     dm->ProcessEvent();
1334     
1335     FillEventSize(rawReader);
1336         
1337     if ( dm->LastEventWasEmpty() )
1338     {
1339       TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus);
1340
1341       if (hrostatus) hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents);
1342     }
1343   }
1344 }
1345
1346 //__________________________________________________________________
1347 void AliMUONTrackerQADataMakerRec::MakeDigits(TTree* digitsTree)         
1348 {
1349   /// makes data from Digits
1350   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1351   
1352   /// forces init
1353
1354   GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1355
1356   if (!fDigitStore)
1357     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1358   fDigitStore->Connect(*digitsTree, false);
1359   digitsTree->GetEvent(0);
1360   
1361   TIter next(fDigitStore->CreateIterator());
1362   
1363   AliMUONVDigit* dig = 0x0;
1364   
1365   AliMUON2DMap oneEventData(true);
1366   
1367   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1368   {
1369     if ( dig->IsTracker() )
1370     {
1371       if ( dig->Charge() > 0.0 )
1372       {
1373         
1374         Int_t detElemId = dig->DetElemId();
1375         Int_t manuId = dig->ManuId();
1376         
1377         AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1378         if (!param)
1379         {
1380           param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,
1381                                           AliMUONVCalibParam::InvalidFloatValue());
1382           oneEventData.Add(param);
1383         }
1384         param->SetValueAsDouble(dig->ManuChannel(),0,dig->Charge());
1385       }
1386     }
1387   }
1388   
1389   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);
1390 }
1391
1392 //____________________________________________________________________________
1393 void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1394 {
1395         /// Fill histograms related to tracker clusters 
1396         
1397         // First things first : do we have clusters in the TreeR ?
1398         // In "normal" production mode, it should be perfectly normal
1399         // *not* to have them.
1400         // But if for some reason we de-activated the combined tracking,
1401         // then we have clusters in TreeR, so let's take that opportunity
1402         // to QA them...
1403         
1404   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1405   // Forces init by requesting an histogram
1406   GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy); 
1407
1408         if (!fClusterStore)
1409         {
1410           AliCodeTimerAuto("ClusterStore creation",1);
1411                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1412                 if (!fClusterStore) 
1413                 {
1414                         return;
1415                 }
1416         }
1417         
1418         fClusterStore->Connect(*clustersTree,kFALSE);
1419         clustersTree->GetEvent(0);
1420
1421         TIter next(fClusterStore->CreateIterator());
1422         AliMUONVCluster* cluster;
1423         
1424   AliMUONQAMappingCheck* mcr = MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()));
1425   
1426   if ( mcr ) mcr->NewEvent();
1427   
1428   AliMUON2DMap oneEventData(true);
1429   
1430         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1431         {
1432                 Int_t detElemId = cluster->GetDetElemId();
1433                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1434                 
1435                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1436                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1437                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1438
1439                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1440                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1441                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1442     GetRecPointsData(AliMUONQAIndices::kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1443                 
1444     if ( mcr ) mcr->Store(*cluster);
1445     
1446     for ( int i = 0; i < cluster->GetNDigits(); ++i ) 
1447     {
1448       UInt_t digitId = cluster->GetDigitId(i);
1449       
1450       Int_t manuId = AliMUONVDigit::ManuId(digitId);
1451       Int_t manuChannel = AliMUONVDigit::ManuChannel(digitId);
1452       
1453       AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1454       if (!param)
1455       {
1456         param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
1457         oneEventData.Add(param);
1458       }
1459       param->SetValueAsDouble(manuChannel,0,1.0);
1460     }
1461         }
1462         
1463   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);    
1464
1465         fClusterStore->Clear();
1466 }
1467
1468 //____________________________________________________________________________
1469 void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
1470 {
1471   /// make QA data from ESDs
1472
1473   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1474    
1475   // load ESD event in the interface
1476   AliMUONESDInterface esdInterface;
1477   if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
1478   else AliError("Unable to get recoParam: use default ones for residual calculation");
1479   esdInterface.LoadEvent(*esd);
1480   
1481   GetESDsData(AliMUONQAIndices::kESDnTracks)->Fill(esdInterface.GetNTracks());
1482   
1483   Int_t nTrackMatchTrig = 0;
1484   
1485   // loop over tracks
1486   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1487   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1488     
1489     // get the ESD track and skip "ghosts"
1490     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1491     if (!esdTrack->ContainTrackerData()) continue;
1492     
1493     // get corresponding MUON track
1494     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1495     
1496     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1497     
1498     GetESDsData(AliMUONQAIndices::kESDMomentum)->Fill(esdTrack->P());
1499     GetESDsData(AliMUONQAIndices::kESDPt)->Fill(esdTrack->Pt());
1500     GetESDsData(AliMUONQAIndices::kESDRapidity)->Fill(esdTrack->Y());
1501     GetESDsData(AliMUONQAIndices::kESDChi2)->Fill(track->GetNormalizedChi2());
1502     GetESDsData(AliMUONQAIndices::kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1503     GetESDsData(AliMUONQAIndices::kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1504     GetESDsData(AliMUONQAIndices::kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1505     GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->Fill(track->GetNClusters());
1506     
1507     // loop over clusters
1508     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1509     while (trackParam) {
1510       
1511       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1512       Int_t chId = cluster->GetChamberId();
1513       Int_t deID = cluster->GetDetElemId();
1514       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1515       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1516       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1517       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1518       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1519       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1520       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1521       
1522       GetESDsData(AliMUONQAIndices::kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1523       
1524       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh)->Fill(chId);
1525       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE)->Fill(deID);
1526       
1527       GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1528       GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1529       
1530       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1531         GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE)->Fill(deID);
1532         GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1533         GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1534       }
1535       
1536       GetESDsData(AliMUONQAIndices::kESDResidualXInCh+chId)->Fill(residualX);
1537       GetESDsData(AliMUONQAIndices::kESDResidualYInCh+chId)->Fill(residualY);
1538       GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE)->Fill(deID, residualX);
1539       GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE)->Fill(deID, residualY);
1540       GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1541       GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1542       
1543       GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1544       GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1545       GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+chId)->Fill(localChi2);
1546       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1547       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1548       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1549       
1550       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1551       
1552     }
1553     
1554   }
1555
1556   GetESDsData(AliMUONQAIndices::kESDMatchTrig)->Fill(nTrackMatchTrig);
1557   
1558 }
1559
1560 //____________________________________________________________________________ 
1561 AliMUONVTrackerData* AliMUONTrackerQADataMakerRec::GetTrackerData() const
1562
1563   /// Return tracker data
1564   
1565   return TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Data(); 
1566 }
1567
1568 //____________________________________________________________________________ 
1569 void
1570 AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
1571 {
1572   /// Reset those histograms that must be reset (and only those), plus
1573   /// the trackerdata itself.
1574   
1575   TIter next(list);
1576   TObject* o;
1577   while ( ( o = next() ) )
1578   {
1579     TH1* h = dynamic_cast<TH1*>(o);
1580     if (h)
1581     {
1582       TString hn(h->GetName());
1583       
1584       if ( !hn.Contains("TrackerBusPatchConfig") )
1585       {
1586         AliDebug(1,Form("Resetting %s",hn.Data()));
1587
1588         h->Reset();
1589       }
1590       else
1591       {
1592         AliDebug(1,Form("Will not reset histogram %s",hn.Data()));          
1593       }
1594     }
1595     else
1596     {
1597       AliMUONVTrackerData* d = dynamic_cast<AliMUONVTrackerData*>(o);
1598       if (d)
1599       {
1600         AliDebug(1,Form("Resetting %s",d->GetName()));
1601         d->Clear();
1602       }
1603       else
1604       {
1605         AliError(Form("Found an object of class %s. Do not know how to reset.",o->ClassName()));
1606       }
1607     }
1608   }
1609 }
1610
1611 //____________________________________________________________________________ 
1612 TObjArray* AliMUONTrackerQADataMakerRec::GetArray(TObjArray*& array, Bool_t create)
1613 {
1614   /// Get (or create) the array
1615
1616   if ( ! array ) 
1617   {
1618     if ( create ) 
1619     {
1620       array = new TObjArray(AliRecoParam::kNSpecies);
1621     }
1622   }
1623   
1624   return array;
1625 }
1626
1627 //____________________________________________________________________________ 
1628 AliMUONVTrackerDataMaker* 
1629 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex)  const
1630 {
1631   /// const version of the getter
1632   if ( fTrackerDataMakerArray )
1633   {
1634     return static_cast<AliMUONVTrackerDataMaker*>(fTrackerDataMakerArray->At(specieIndex));
1635   }
1636   return 0x0;
1637 }
1638
1639 //____________________________________________________________________________ 
1640 AliMUONVTrackerDataMaker* 
1641 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex, Bool_t create)
1642 {
1643   /// Get (or create) TrackerDataMaker object for a given specie
1644   
1645   TObjArray* array = GetArray(fTrackerDataMakerArray,create);
1646   TObject* o(0x0);
1647   
1648   if ( array ) 
1649   {
1650     array->SetOwner(kTRUE);
1651     o = array->At(specieIndex);
1652     if (!o && create)
1653     {
1654       
1655       AliMUONTrackerDataMaker* dm = new AliMUONTrackerDataMaker(0x0,
1656                                                                 AliCDBManager::Instance()->GetRun(),
1657                                                                 0x0,
1658                                                                 "",
1659                                                                 "",
1660                                                                 kFALSE,
1661                                                                 0.0,0.0);
1662       
1663       if (!fLogger) fLogger = new AliMUONLogger(-1); // note that we share the logger between species... should not be a big deal though
1664       dm->EnableErrorLogger(fLogger);
1665       dm->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level    
1666       dm->Data()->SetName("RawCharges");
1667       dm->SetRunning(kTRUE);
1668
1669       o = dm;
1670       array->AddAt(o,specieIndex);      
1671     }
1672   }
1673   return static_cast<AliMUONVTrackerDataMaker*>(o);
1674 }
1675
1676 //____________________________________________________________________________ 
1677 AliMUONVTrackerData* 
1678 AliMUONTrackerQADataMakerRec::TrackerCalData(Int_t specieIndex, Bool_t create)
1679 {
1680   TObjArray* array = GetArray(fTrackerCalDataArray,create);
1681   TObject* o(0x0);
1682   
1683   if (array)
1684   {
1685     o = array->At(specieIndex);
1686     if (!o && create)
1687     {
1688       AliMUONTrackerData* data = new AliMUONTrackerData("CalCharges",Form("Calibrated charges (fC) %s",GetRecoParam()->GetCalibrationMode()),1);
1689       data->SetDimensionName(0,"charge");
1690       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1691       o=data;
1692       array->AddAt(o,specieIndex);
1693     }
1694   }
1695   return static_cast<AliMUONVTrackerData*>(o);
1696 }
1697
1698 //____________________________________________________________________________ 
1699 AliMUONVTrackerData* 
1700 AliMUONTrackerQADataMakerRec::TrackerRecData(Int_t specieIndex, Bool_t create)
1701 {
1702   TObjArray* array = GetArray(fTrackerRecDataArray,create);
1703   TObject* o(0x0);
1704   
1705   if (array)
1706   {
1707     o = array->At(specieIndex);
1708     if (!o && create)
1709     {
1710       AliMUONTrackerData* data = new AliMUONTrackerData("RecCharges",Form("Calibrated charges (fC) %s for digits belonging to a reconstructed cluster",GetRecoParam()->GetCalibrationMode()),1);
1711       data->SetDimensionName(0,"one");
1712       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1713       o=data;
1714       array->AddAt(o,specieIndex);
1715     }
1716   }
1717   return static_cast<AliMUONVTrackerData*>(o);
1718 }
1719
1720 //____________________________________________________________________________ 
1721 AliMUONQAMappingCheck* 
1722 AliMUONTrackerQADataMakerRec::MappingCheckRecPoints(Int_t specieIndex, Bool_t create)
1723 {
1724   TObjArray* array = GetArray(fMappingCheckRecPointsArray,create);
1725   TObject* o(0x0);
1726   
1727   if (array)
1728   {
1729     o = array->At(specieIndex);
1730     array->SetOwner(kTRUE);
1731     if (!o && create)
1732     {
1733       AliMUONQAMappingCheck* mcheck = new AliMUONQAMappingCheck(RunNumber()); 
1734       o=mcheck;
1735       array->AddAt(o,specieIndex);
1736     }
1737   }
1738   return static_cast<AliMUONQAMappingCheck*>(o);
1739 }