]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackerQADataMakerRec.cxx
Cuts updated.
[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("kTrackerNofPhysicsEventsSeen","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("kTrackerNofGoodPhysicsEventsUsed","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 }
956
957 //__________________________________________________________________
958 void AliMUONTrackerQADataMakerRec::InitDigits() 
959 {
960   /// create monitor objects for DIGITS
961   
962   AliCodeTimerAuto("",0);
963
964   if ( GetRecoParam()->TryRecover() )
965   {
966     fDigitMaker->SetTryRecover(kTRUE);
967   }
968   else
969   {
970     fDigitMaker->SetTryRecover(kFALSE);    
971   }
972   
973   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
974   
975   /// Book histograms that are common to Raws and Digits
976   BookHistograms(AliQAv1::kDIGITSR);
977
978
979 //____________________________________________________________________________ 
980 void AliMUONTrackerQADataMakerRec::InitRecPoints()
981 {
982   /// create Reconstructed Points histograms in RecPoints subdir for the
983   /// MUON tracker subsystem.
984   const Bool_t expert   = kTRUE ; 
985   const Bool_t image    = kTRUE ; 
986   
987   AliCodeTimerAuto("",0);
988
989   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
990   
991   BookHistograms(AliQAv1::kRECPOINTS);
992   
993   TH1I *h1I;
994   TH1F *h1F;
995   TH2F *h2F;
996   
997   // histograms per chamber
998   Int_t nCh = AliMpConstants::NofTrackingChambers();
999   for ( Int_t i = 0; i < nCh; ++i ) 
1000   {
1001     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
1002     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+i, expert, !image);
1003     
1004     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC);Counts",i+1), 100,0,1000);
1005     Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerChamber+i, expert, !image);
1006     
1007     Float_t rMax = AliMUONConstants::Rmax(i/2);
1008     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);
1009     Add2RecPointsList(h2F, AliMUONQAIndices::kTrackerClusterHitMapPerChamber+i, expert, !image);
1010   }
1011   
1012   // summary histograms per chamber
1013   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
1014   Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerNumberOfClustersPerChamber, !expert, image);
1015   
1016   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
1017   h1F->SetOption("P");
1018   h1F->SetMarkerStyle(kFullDotMedium);
1019   h1F->SetMarkerColor(kRed);
1020   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean, !expert, image);
1021   
1022   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
1023   h1F->SetOption("P");
1024   h1F->SetMarkerStyle(kFullDotMedium);
1025   h1F->SetMarkerColor(kRed);
1026   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma, !expert, image);
1027   
1028   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh,-0.5,nCh-0.5);
1029   h1F->SetOption("P");
1030   h1F->SetMarkerStyle(kFullDotMedium);
1031   h1F->SetMarkerColor(kRed);
1032   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChMean, !expert, image);
1033   
1034   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh,-0.5,nCh-0.5);
1035   h1F->SetOption("P");
1036   h1F->SetMarkerStyle(kFullDotMedium);
1037   h1F->SetMarkerColor(kRed);
1038   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerChSigma, !expert, image);
1039   
1040   // histograms per DE
1041   Int_t ndes(0);
1042   AliMpDEIterator it;
1043   it.First();
1044   while ( !it.IsDone())
1045   {
1046     Int_t detElemId = it.CurrentDEId();
1047     
1048     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
1049     {
1050       ndes = TMath::Max(ndes,detElemId);
1051       
1052       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
1053       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
1054       
1055       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (fC)",detElemId), 100,0,1000);
1056       Add2RecPointsList(h1I,AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId, expert, !image);
1057     }
1058     
1059     it.Next();
1060   }
1061   
1062   // summary histograms per DE
1063   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
1064   Add2RecPointsList(h1I, AliMUONQAIndices::kTrackerNumberOfClustersPerDE, !expert, image);
1065   
1066   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
1067   h1F->SetOption("P");
1068   h1F->SetMarkerStyle(kFullDotMedium);
1069   h1F->SetMarkerColor(kRed);
1070   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean, !expert, image);
1071   
1072   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", ndes+1,-0.5,ndes+0.5);
1073   h1F->SetOption("P");
1074   h1F->SetMarkerStyle(kFullDotMedium);
1075   h1F->SetMarkerColor(kRed);
1076   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerDEMean, !expert, image);
1077   
1078   MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
1079 }
1080
1081 //____________________________________________________________________________ 
1082 void AliMUONTrackerQADataMakerRec::InitESDs()
1083 {
1084   ///create ESDs histograms in ESDs subdir
1085   
1086   const Bool_t expert   = kTRUE ; 
1087   const Bool_t image    = kTRUE ; 
1088   
1089   Int_t nCh = AliMUONConstants::NTrackingCh();
1090   Int_t nDE = 1100;
1091   
1092   // track info
1093   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
1094   Add2ESDsList(hESDnTracks, AliMUONQAIndices::kESDnTracks, !expert, image);
1095
1096   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
1097   Add2ESDsList(hESDMatchTrig, AliMUONQAIndices::kESDMatchTrig, !expert, image);
1098   
1099   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
1100   Add2ESDsList(hESDMomentum, AliMUONQAIndices::kESDMomentum, !expert, image);
1101
1102   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
1103   Add2ESDsList(hESDPt, AliMUONQAIndices::kESDPt, !expert, image);
1104
1105   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
1106   Add2ESDsList(hESDRapidity, AliMUONQAIndices::kESDRapidity, !expert, image);
1107
1108   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
1109   Add2ESDsList(hESDChi2, AliMUONQAIndices::kESDChi2, !expert, image);
1110   
1111   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
1112   Add2ESDsList(hESDProbChi2, AliMUONQAIndices::kESDProbChi2, !expert, image);
1113   
1114   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
1115   Add2ESDsList(hESDThetaX, AliMUONQAIndices::kESDThetaX, !expert, image);
1116   
1117   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
1118   Add2ESDsList(hESDThetaY, AliMUONQAIndices::kESDThetaY, !expert, image);
1119   
1120   // cluster info
1121   for (Int_t i = 0; i < nCh; i++) {
1122     Float_t rMax = AliMUONConstants::Rmax(i/2);
1123     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
1124                                        100, -rMax, rMax, 100, -rMax, rMax);
1125     Add2ESDsList(hESDClusterHitMap, AliMUONQAIndices::kESDClusterHitMap+i, expert, !image);
1126   }
1127   
1128   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
1129   Add2ESDsList(hESDnClustersPerTrack, AliMUONQAIndices::kESDnClustersPerTrack, !expert, image);
1130   
1131   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
1132   hESDnClustersPerCh->SetFillColor(kRed);
1133   Add2ESDsList(hESDnClustersPerCh, AliMUONQAIndices::kESDnClustersPerCh, !expert, image);
1134   
1135   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
1136   hESDnClustersPerDE->SetFillColor(kRed);
1137   Add2ESDsList(hESDnClustersPerDE, AliMUONQAIndices::kESDnClustersPerDE, !expert, image);
1138   
1139   for (Int_t i = 0; i < nCh; i++) {
1140     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
1141     Add2ESDsList(hESDClusterChargeInCh, AliMUONQAIndices::kESDClusterChargeInCh+i, expert, !image);
1142   }
1143   
1144   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
1145   hESDClusterChargePerChMean->SetOption("P");
1146   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
1147   hESDClusterChargePerChMean->SetMarkerColor(kRed);
1148   Add2ESDsList(hESDClusterChargePerChMean, AliMUONQAIndices::kESDClusterChargePerChMean, !expert, image);
1149   
1150   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
1151   hESDClusterChargePerChSigma->SetOption("P");
1152   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
1153   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
1154   Add2ESDsList(hESDClusterChargePerChSigma, AliMUONQAIndices::kESDClusterChargePerChSigma, !expert, image);
1155   
1156   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
1157   hESDClusterChargePerDE->SetOption("P");
1158   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
1159   hESDClusterChargePerDE->SetMarkerColor(kRed);
1160   Add2ESDsList(hESDClusterChargePerDE, AliMUONQAIndices::kESDClusterChargePerDE, !expert, image);
1161   
1162   for (Int_t i = 0; i < nCh; i++) {
1163     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
1164     Add2ESDsList(hESDClusterSizeInCh, AliMUONQAIndices::kESDClusterSizeInCh+i, expert, !image);
1165   }
1166   
1167   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
1168   hESDClusterSizePerChMean->SetOption("P");
1169   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
1170   hESDClusterSizePerChMean->SetMarkerColor(kRed);
1171   Add2ESDsList(hESDClusterSizePerChMean, AliMUONQAIndices::kESDClusterSizePerChMean, !expert, image);
1172   
1173   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
1174   hESDClusterSizePerChSigma->SetOption("P");
1175   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
1176   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
1177   Add2ESDsList(hESDClusterSizePerChSigma, AliMUONQAIndices::kESDClusterSizePerChSigma, !expert, image);
1178   
1179   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
1180   hESDClusterSizePerDE->SetOption("P");
1181   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
1182   hESDClusterSizePerDE->SetMarkerColor(kRed);
1183   Add2ESDsList(hESDClusterSizePerDE, AliMUONQAIndices::kESDClusterSizePerDE, !expert, image);
1184   
1185   // cluster - track info
1186   for (Int_t i = 0; i < nCh; i++) {
1187     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.);
1188     Add2ESDsList(hESDResidualXInCh, AliMUONQAIndices::kESDResidualXInCh+i, expert, !image);
1189     
1190     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.);
1191     Add2ESDsList(hESDResidualYInCh, AliMUONQAIndices::kESDResidualYInCh+i, expert, !image);
1192     
1193     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);
1194     Add2ESDsList(hESDLocalChi2XInCh, AliMUONQAIndices::kESDLocalChi2XInCh+i, expert, !image);
1195     
1196     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);
1197     Add2ESDsList(hESDLocalChi2YInCh, AliMUONQAIndices::kESDLocalChi2YInCh+i, expert, !image);
1198     
1199     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);
1200     Add2ESDsList(hESDLocalChi2InCh, AliMUONQAIndices::kESDLocalChi2InCh+i, expert, !image);
1201   }
1202   
1203   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
1204   hESDResidualXPerChMean->SetOption("P");
1205   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
1206   hESDResidualXPerChMean->SetMarkerColor(kRed);
1207   Add2ESDsList(hESDResidualXPerChMean, AliMUONQAIndices::kESDResidualXPerChMean, !expert, image);
1208   
1209   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
1210   hESDResidualYPerChMean->SetOption("P");
1211   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
1212   hESDResidualYPerChMean->SetMarkerColor(kRed);
1213   Add2ESDsList(hESDResidualYPerChMean, AliMUONQAIndices::kESDResidualYPerChMean, !expert, image);
1214   
1215   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
1216   hESDResidualXPerChSigma->SetOption("P");
1217   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
1218   hESDResidualXPerChSigma->SetMarkerColor(kRed);
1219   Add2ESDsList(hESDResidualXPerChSigma, AliMUONQAIndices::kESDResidualXPerChSigma, !expert, image);
1220   
1221   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
1222   hESDResidualYPerChSigma->SetOption("P");
1223   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
1224   hESDResidualYPerChSigma->SetMarkerColor(kRed);
1225   Add2ESDsList(hESDResidualYPerChSigma, AliMUONQAIndices::kESDResidualYPerChSigma, !expert, image);
1226   
1227   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerCh", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
1228   hESDLocalChi2XPerChMean->SetOption("P");
1229   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
1230   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
1231   Add2ESDsList(hESDLocalChi2XPerChMean, AliMUONQAIndices::kESDLocalChi2XPerChMean, !expert, image);
1232   
1233   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerCh", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
1234   hESDLocalChi2YPerChMean->SetOption("P");
1235   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
1236   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
1237   Add2ESDsList(hESDLocalChi2YPerChMean, AliMUONQAIndices::kESDLocalChi2YPerChMean, !expert, image);
1238   
1239   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);
1240   hESDLocalChi2PerChMean->SetOption("P");
1241   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
1242   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
1243   Add2ESDsList(hESDLocalChi2PerChMean, AliMUONQAIndices::kESDLocalChi2PerChMean, !expert, image);
1244   
1245   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
1246   hESDResidualXPerDEMean->SetOption("P");
1247   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
1248   hESDResidualXPerDEMean->SetMarkerColor(kRed);
1249   Add2ESDsList(hESDResidualXPerDEMean, AliMUONQAIndices::kESDResidualXPerDEMean, !expert, image);
1250   
1251   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
1252   hESDResidualYPerDEMean->SetOption("P");
1253   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
1254   hESDResidualYPerDEMean->SetMarkerColor(kRed);
1255   Add2ESDsList(hESDResidualYPerDEMean, AliMUONQAIndices::kESDResidualYPerDEMean, !expert, image);
1256   
1257   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
1258   hESDResidualXPerDESigma->SetOption("P");
1259   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
1260   hESDResidualXPerDESigma->SetMarkerColor(kRed);
1261   Add2ESDsList(hESDResidualXPerDESigma, AliMUONQAIndices::kESDResidualXPerDESigma, !expert, image);
1262   
1263   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
1264   hESDResidualYPerDESigma->SetOption("P");
1265   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
1266   hESDResidualYPerDESigma->SetMarkerColor(kRed);
1267   Add2ESDsList(hESDResidualYPerDESigma, AliMUONQAIndices::kESDResidualYPerDESigma, !expert, image);
1268   
1269   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDE", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
1270   hESDLocalChi2XPerDEMean->SetOption("P");
1271   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
1272   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
1273   Add2ESDsList(hESDLocalChi2XPerDEMean, AliMUONQAIndices::kESDLocalChi2XPerDEMean, !expert, image);
1274   
1275   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDE", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
1276   hESDLocalChi2YPerDEMean->SetOption("P");
1277   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
1278   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
1279   Add2ESDsList(hESDLocalChi2YPerDEMean, AliMUONQAIndices::kESDLocalChi2YPerDEMean, !expert, image);
1280   
1281   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);
1282   hESDLocalChi2PerDEMean->SetOption("P");
1283   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
1284   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
1285   Add2ESDsList(hESDLocalChi2PerDEMean, AliMUONQAIndices::kESDLocalChi2PerDEMean, !expert, image);
1286   
1287   // intermediate histograms
1288   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
1289   Add2ESDsList(hESDnTotClustersPerCh, AliMUONQAIndices::kESDnTotClustersPerCh, expert, !image);
1290   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
1291   Add2ESDsList(hESDnTotClustersPerDE, AliMUONQAIndices::kESDnTotClustersPerDE, expert, !image);
1292   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);
1293   Add2ESDsList(hESDnTotFullClustersPerDE, AliMUONQAIndices::kESDnTotFullClustersPerDE, expert, !image);
1294   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (fC)", nDE+1, -0.5, nDE+0.5);
1295   Add2ESDsList(hESDSumClusterChargePerDE, AliMUONQAIndices::kESDSumClusterChargePerDE, expert, !image);
1296   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
1297   Add2ESDsList(hESDSumClusterSizePerDE, AliMUONQAIndices::kESDSumClusterSizePerDE, expert, !image);
1298   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);
1299   Add2ESDsList(hESDSumResidualXPerDE, AliMUONQAIndices::kESDSumResidualXPerDE, expert, !image);
1300   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);
1301   Add2ESDsList(hESDSumResidualYPerDE, AliMUONQAIndices::kESDSumResidualYPerDE, expert, !image);
1302   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);
1303   Add2ESDsList(hESDSumResidualX2PerDE, AliMUONQAIndices::kESDSumResidualX2PerDE, expert, !image);
1304   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);
1305   Add2ESDsList(hESDSumResidualY2PerDE, AliMUONQAIndices::kESDSumResidualY2PerDE, expert, !image);
1306   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);
1307   Add2ESDsList(hESDSumLocalChi2XPerDE, AliMUONQAIndices::kESDSumLocalChi2XPerDE, expert, !image);
1308   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);
1309   Add2ESDsList(hESDSumLocalChi2YPerDE, AliMUONQAIndices::kESDSumLocalChi2YPerDE, expert, !image);
1310   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);
1311   Add2ESDsList(hESDSumLocalChi2PerDE, AliMUONQAIndices::kESDSumLocalChi2PerDE, expert, !image);
1312 }
1313
1314 //____________________________________________________________________________
1315 void AliMUONTrackerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
1316 {
1317         /// make QA for rawdata tracker
1318         
1319   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1320
1321   AliInfo(Form("rawReader class=%s",rawReader->ClassName()));
1322   
1323   /// forces init
1324   GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1325   
1326   AliMUONTrackerDataMaker* dm = static_cast<AliMUONTrackerDataMaker*>(TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie())));
1327
1328         dm->SetRawReader(rawReader);
1329         
1330   Int_t eventType = rawReader->GetType();
1331   
1332   if (eventType == AliRawEventHeaderBase::kPhysicsEvent ) 
1333   {
1334     dm->ProcessEvent();
1335     
1336     FillEventSize(rawReader);
1337         
1338     if ( dm->LastEventWasEmpty() )
1339     {
1340       TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus);
1341
1342       if (hrostatus) hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents);
1343     }
1344   }
1345 }
1346
1347 //__________________________________________________________________
1348 void AliMUONTrackerQADataMakerRec::MakeDigits(TTree* digitsTree)         
1349 {
1350   /// makes data from Digits
1351   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1352   
1353   /// forces init
1354
1355   GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
1356
1357   if (!fDigitStore)
1358     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1359   fDigitStore->Connect(*digitsTree, false);
1360   digitsTree->GetEvent(0);
1361   
1362   TIter next(fDigitStore->CreateIterator());
1363   
1364   AliMUONVDigit* dig = 0x0;
1365   
1366   AliMUON2DMap oneEventData(true);
1367   
1368   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1369   {
1370     if ( dig->IsTracker() )
1371     {
1372       if ( dig->Charge() > 0.0 )
1373       {
1374         
1375         Int_t detElemId = dig->DetElemId();
1376         Int_t manuId = dig->ManuId();
1377         
1378         AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1379         if (!param)
1380         {
1381           param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,
1382                                           AliMUONVCalibParam::InvalidFloatValue());
1383           oneEventData.Add(param);
1384         }
1385         param->SetValueAsDouble(dig->ManuChannel(),0,dig->Charge());
1386       }
1387     }
1388   }
1389   
1390   TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);
1391 }
1392
1393 //____________________________________________________________________________
1394 void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1395 {
1396         /// Fill histograms related to tracker clusters 
1397         
1398         // First things first : do we have clusters in the TreeR ?
1399         // In "normal" production mode, it should be perfectly normal
1400         // *not* to have them.
1401         // But if for some reason we de-activated the combined tracking,
1402         // then we have clusters in TreeR, so let's take that opportunity
1403         // to QA them...
1404         
1405   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1406   // Forces init by requesting an histogram
1407   GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy); 
1408
1409         if (!fClusterStore)
1410         {
1411           AliCodeTimerAuto("ClusterStore creation",1);
1412                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1413                 if (!fClusterStore) 
1414                 {
1415                         return;
1416                 }
1417         }
1418         
1419         fClusterStore->Connect(*clustersTree,kFALSE);
1420         clustersTree->GetEvent(0);
1421
1422         TIter next(fClusterStore->CreateIterator());
1423         AliMUONVCluster* cluster;
1424         
1425   AliMUONQAMappingCheck* mcr = MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()));
1426   
1427   if ( mcr ) mcr->NewEvent();
1428   
1429   AliMUON2DMap oneEventData(true);
1430   
1431         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1432         {
1433                 Int_t detElemId = cluster->GetDetElemId();
1434                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1435                 
1436                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1437                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1438                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1439
1440                 GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1441                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1442                 GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1443     GetRecPointsData(AliMUONQAIndices::kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1444                 
1445     if ( mcr ) mcr->Store(*cluster);
1446     
1447     for ( int i = 0; i < cluster->GetNDigits(); ++i ) 
1448     {
1449       UInt_t digitId = cluster->GetDigitId(i);
1450       
1451       Int_t manuId = AliMUONVDigit::ManuId(digitId);
1452       Int_t manuChannel = AliMUONVDigit::ManuChannel(digitId);
1453       
1454       AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
1455       if (!param)
1456       {
1457         param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
1458         oneEventData.Add(param);
1459       }
1460       param->SetValueAsDouble(manuChannel,0,1.0);
1461     }
1462         }
1463         
1464   TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);    
1465
1466         fClusterStore->Clear();
1467 }
1468
1469 //____________________________________________________________________________
1470 void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
1471 {
1472   /// make QA data from ESDs
1473
1474   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
1475    
1476   // load ESD event in the interface
1477   AliMUONESDInterface esdInterface;
1478   if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
1479   else AliError("Unable to get recoParam: use default ones for residual calculation");
1480   esdInterface.LoadEvent(*esd);
1481   
1482   GetESDsData(AliMUONQAIndices::kESDnTracks)->Fill(esdInterface.GetNTracks());
1483   
1484   Int_t nTrackMatchTrig = 0;
1485   
1486   // loop over tracks
1487   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1488   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1489     
1490     // get the ESD track and skip "ghosts"
1491     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1492     if (!esdTrack->ContainTrackerData()) continue;
1493     
1494     // get corresponding MUON track
1495     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1496     
1497     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1498     
1499     GetESDsData(AliMUONQAIndices::kESDMomentum)->Fill(esdTrack->P());
1500     GetESDsData(AliMUONQAIndices::kESDPt)->Fill(esdTrack->Pt());
1501     GetESDsData(AliMUONQAIndices::kESDRapidity)->Fill(esdTrack->Y());
1502     GetESDsData(AliMUONQAIndices::kESDChi2)->Fill(track->GetNormalizedChi2());
1503     GetESDsData(AliMUONQAIndices::kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1504     GetESDsData(AliMUONQAIndices::kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1505     GetESDsData(AliMUONQAIndices::kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1506     GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->Fill(track->GetNClusters());
1507     
1508     // loop over clusters
1509     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1510     while (trackParam) {
1511       
1512       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1513       Int_t chId = cluster->GetChamberId();
1514       Int_t deID = cluster->GetDetElemId();
1515       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1516       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1517       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1518       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1519       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1520       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1521       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1522       
1523       GetESDsData(AliMUONQAIndices::kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1524       
1525       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh)->Fill(chId);
1526       GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE)->Fill(deID);
1527       
1528       GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1529       GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1530       
1531       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1532         GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE)->Fill(deID);
1533         GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1534         GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1535       }
1536       
1537       GetESDsData(AliMUONQAIndices::kESDResidualXInCh+chId)->Fill(residualX);
1538       GetESDsData(AliMUONQAIndices::kESDResidualYInCh+chId)->Fill(residualY);
1539       GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE)->Fill(deID, residualX);
1540       GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE)->Fill(deID, residualY);
1541       GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1542       GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1543       
1544       GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1545       GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1546       GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+chId)->Fill(localChi2);
1547       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1548       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1549       GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1550       
1551       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1552       
1553     }
1554     
1555   }
1556
1557   GetESDsData(AliMUONQAIndices::kESDMatchTrig)->Fill(nTrackMatchTrig);
1558   
1559 }
1560
1561 //____________________________________________________________________________ 
1562 AliMUONVTrackerData* AliMUONTrackerQADataMakerRec::GetTrackerData() const
1563
1564   /// Return tracker data
1565   
1566   return TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Data(); 
1567 }
1568
1569 //____________________________________________________________________________ 
1570 void
1571 AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
1572 {
1573   /// Reset those histograms that must be reset (and only those), plus
1574   /// the trackerdata itself.
1575   
1576   AliInfo("");
1577   
1578   TIter next(list);
1579   TObject* o;
1580   while ( ( o = next() ) )
1581   {
1582     TH1* h = dynamic_cast<TH1*>(o);
1583     if (h)
1584     {
1585       TString hn(h->GetName());
1586       
1587       if ( !hn.Contains("TrackerBusPatchConfig") )
1588       {
1589         AliInfo(Form("Resetting %s",hn.Data()));
1590
1591         if ( hn.Contains("DDLMeanEventSize") )
1592         {
1593           h->Print();
1594           h->GetListOfFunctions()->ls();
1595           cout << ">>>>>" << endl;
1596         }          
1597
1598         h->Reset();
1599         
1600         if ( hn.Contains("DDLMeanEventSize") )
1601         {
1602           h->Print();
1603           h->GetListOfFunctions()->ls();
1604           cout << "<<<<<<" << endl;
1605         }          
1606       }
1607       else
1608       {
1609         //        AliDebug(1,Form("Will not reset histogram %s",hn.Data()));
1610         AliInfo(Form("Will not reset histogram %s",hn.Data()));          
1611       }
1612     }
1613     else
1614     {
1615       AliMUONVTrackerData* d = dynamic_cast<AliMUONVTrackerData*>(o);
1616       if (d)
1617       {
1618         AliDebug(1,Form("Resetting %s",d->GetName()));
1619         d->Clear();
1620       }
1621       else
1622       {
1623         AliError(Form("Found an object of class %s. Do not know how to reset.",o->ClassName()));
1624       }
1625     }
1626   }
1627 }
1628
1629 //____________________________________________________________________________ 
1630 TObjArray* AliMUONTrackerQADataMakerRec::GetArray(TObjArray*& array, Bool_t create)
1631 {
1632   /// Get (or create) the array
1633
1634   if ( ! array ) 
1635   {
1636     if ( create ) 
1637     {
1638       array = new TObjArray(AliRecoParam::kNSpecies);
1639     }
1640   }
1641   
1642   return array;
1643 }
1644
1645 //____________________________________________________________________________ 
1646 AliMUONVTrackerDataMaker* 
1647 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex)  const
1648 {
1649   /// const version of the getter
1650   if ( fTrackerDataMakerArray )
1651   {
1652     return static_cast<AliMUONVTrackerDataMaker*>(fTrackerDataMakerArray->At(specieIndex));
1653   }
1654   return 0x0;
1655 }
1656
1657 //____________________________________________________________________________ 
1658 AliMUONVTrackerDataMaker* 
1659 AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex, Bool_t create)
1660 {
1661   /// Get (or create) TrackerDataMaker object for a given specie
1662   
1663   TObjArray* array = GetArray(fTrackerDataMakerArray,create);
1664   TObject* o(0x0);
1665   
1666   if ( array ) 
1667   {
1668     array->SetOwner(kTRUE);
1669     o = array->At(specieIndex);
1670     if (!o && create)
1671     {
1672       
1673       AliMUONTrackerDataMaker* dm = new AliMUONTrackerDataMaker(0x0,
1674                                                                 AliCDBManager::Instance()->GetRun(),
1675                                                                 0x0,
1676                                                                 "",
1677                                                                 "",
1678                                                                 kFALSE,
1679                                                                 0.0,0.0);
1680       
1681       if (!fLogger) fLogger = new AliMUONLogger(-1); // note that we share the logger between species... should not be a big deal though
1682       dm->EnableErrorLogger(fLogger);
1683       dm->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level    
1684       dm->Data()->SetName("RawCharges");
1685       dm->SetRunning(kTRUE);
1686
1687       o = dm;
1688       array->AddAt(o,specieIndex);      
1689     }
1690   }
1691   return static_cast<AliMUONVTrackerDataMaker*>(o);
1692 }
1693
1694 //____________________________________________________________________________ 
1695 AliMUONVTrackerData* 
1696 AliMUONTrackerQADataMakerRec::TrackerCalData(Int_t specieIndex, Bool_t create)
1697 {
1698   TObjArray* array = GetArray(fTrackerCalDataArray,create);
1699   TObject* o(0x0);
1700   
1701   if (array)
1702   {
1703     o = array->At(specieIndex);
1704     if (!o && create)
1705     {
1706       AliMUONTrackerData* data = new AliMUONTrackerData("CalCharges",Form("Calibrated charges (fC) %s",GetRecoParam()->GetCalibrationMode()),1);
1707       data->SetDimensionName(0,"charge");
1708       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1709       o=data;
1710       array->AddAt(o,specieIndex);
1711     }
1712   }
1713   return static_cast<AliMUONVTrackerData*>(o);
1714 }
1715
1716 //____________________________________________________________________________ 
1717 AliMUONVTrackerData* 
1718 AliMUONTrackerQADataMakerRec::TrackerRecData(Int_t specieIndex, Bool_t create)
1719 {
1720   TObjArray* array = GetArray(fTrackerRecDataArray,create);
1721   TObject* o(0x0);
1722   
1723   if (array)
1724   {
1725     o = array->At(specieIndex);
1726     if (!o && create)
1727     {
1728       AliMUONTrackerData* data = new AliMUONTrackerData("RecCharges",Form("Calibrated charges (fC) %s for digits belonging to a reconstructed cluster",GetRecoParam()->GetCalibrationMode()),1);
1729       data->SetDimensionName(0,"one");
1730       data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
1731       o=data;
1732       array->AddAt(o,specieIndex);
1733     }
1734   }
1735   return static_cast<AliMUONVTrackerData*>(o);
1736 }
1737
1738 //____________________________________________________________________________ 
1739 AliMUONQAMappingCheck* 
1740 AliMUONTrackerQADataMakerRec::MappingCheckRecPoints(Int_t specieIndex, Bool_t create)
1741 {
1742   TObjArray* array = GetArray(fMappingCheckRecPointsArray,create);
1743   TObject* o(0x0);
1744   
1745   if (array)
1746   {
1747     o = array->At(specieIndex);
1748     if (!o && create)
1749     {
1750       AliMUONQAMappingCheck* mcheck = new AliMUONQAMappingCheck(RunNumber()); 
1751       o=mcheck;
1752       array->AddAt(o,specieIndex);
1753     }
1754   }
1755   return static_cast<AliMUONQAMappingCheck*>(o);
1756 }