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