1.The QA data created on demand according to the event species at filling time. 2...
[u/mrichter/AliRoot.git] / MUON / AliMUONQADataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17
18 // --- MUON header files ---
19 #include "AliMUONQADataMakerRec.h"
20
21 #include "AliMUON2DMap.h"
22 #include "AliMUONCluster.h"  
23 #include "AliMUONConstants.h"  
24 #include "AliMUONDDLTrigger.h"
25 #include "AliMUONDarcHeader.h"
26 #include "AliMUONDigitMaker.h"
27 #include "AliMUONLocalStruct.h"
28 #include "AliMUONLocalTrigger.h"
29 #include "AliMUONRawStreamTracker.h"
30 #include "AliMUONRawStreamTrigger.h"
31 #include "AliMUONRegHeader.h"
32 #include "AliMUONTrackerDataMaker.h"
33 #include "AliMUONTriggerDisplay.h"
34 #include "AliMUONVCluster.h"
35 #include "AliMUONVClusterStore.h"
36 #include "AliMUONVDigit.h"
37 #include "AliMUONVDigitStore.h"
38 #include "AliMUONVTrackerData.h"
39 #include "AliMUONVTriggerStore.h"
40 #include "AliMUONTrack.h"
41 #include "AliMUONTrackParam.h"
42 #include "AliMUONESDInterface.h"
43 #include "AliMUONCalibrationData.h"
44 #include "AliMpBusPatch.h"
45 #include "AliMpCDB.h"
46 #include "AliMpConstants.h"
47 #include "AliMpDDLStore.h"
48 #include "AliMpDEIterator.h"
49 #include "AliMpDEManager.h"
50 #include "AliMpLocalBoard.h"
51 #include "AliMpStationType.h"
52 #include "AliMpTriggerCrate.h"
53 #include "AliMpDCSNamer.h"
54 #include "AliRawEventHeaderBase.h"
55
56 // --- AliRoot header files ---
57 #include "AliCDBManager.h"
58 #include "AliCDBStorage.h"
59 #include "AliESDEvent.h"
60 #include "AliESDMuonTrack.h"
61 #include "AliESDMuonCluster.h"
62 #include "AliLog.h"
63 #include "AliRawReader.h"
64 #include "AliQAChecker.h"
65 #include "AliCodeTimer.h"
66 #include "AliDCSValue.h"
67 #include "AliMUONVDigit.h"
68
69 // --- ROOT system ---
70 #include <TClonesArray.h>
71 #include <TFile.h> 
72 #include <TH1F.h> 
73 #include <TH1I.h> 
74 #include <TH2F.h>
75 #include <TH3F.h> 
76 #include <Riostream.h>
77
78 //-----------------------------------------------------------------------------
79 /// \class AliMUONQADataMakerRec
80 ///
81 /// MUON base class for quality assurance data (histo) maker
82 ///
83 /// \author C. Finck, D. Stocco, L. Aphecetche
84
85 /// \cond CLASSIMP
86 ClassImp(AliMUONQADataMakerRec)
87 /// \endcond
88            
89 //____________________________________________________________________________ 
90 AliMUONQADataMakerRec::AliMUONQADataMakerRec() : 
91 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kMUON), "MUON Quality Assurance Data Maker"),
92 fIsInitRaws(kFALSE),
93 fIsInitRecPointsTracker(kFALSE),
94 fIsInitRecPointsTrigger(kFALSE),
95 fIsInitESDs(kFALSE),
96 fDigitStore(0x0),
97 fTriggerStore(0x0),
98 fDigitMaker(0x0),
99 fClusterStore(0x0),
100 fTrackerDataMaker(0x0)
101 {
102     /// ctor
103         
104   AliDebug(AliQAv1::GetQADebugLevel(),"");
105
106         Ctor();
107 }
108
109 //____________________________________________________________________________ 
110 void
111 AliMUONQADataMakerRec::Ctor()
112 {
113         /// Init some members
114         fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
115         fDigitMaker = new AliMUONDigitMaker(kTRUE);
116 }
117
118 //____________________________________________________________________________ 
119 AliMUONQADataMakerRec::AliMUONQADataMakerRec(const AliMUONQADataMakerRec& qadm) :
120 AliQADataMakerRec(qadm),
121 fIsInitRaws(kFALSE),
122 fIsInitRecPointsTracker(kFALSE),
123 fIsInitRecPointsTrigger(kFALSE),
124 fIsInitESDs(kFALSE),
125 fDigitStore(0x0),
126 fTriggerStore(0x0),
127 fDigitMaker(0x0),
128 fClusterStore(0x0),
129 fTrackerDataMaker(0x0)
130 {
131     ///copy ctor 
132
133   AliDebug(AliQAv1::GetQADebugLevel(),"");
134
135
136     SetName((const char*)qadm.GetName()) ; 
137     SetTitle((const char*)qadm.GetTitle()); 
138
139         // Do not copy the digit store and digit maker, but create its own ones
140         
141         Ctor();
142         
143 }
144
145 //__________________________________________________________________
146 AliMUONQADataMakerRec& AliMUONQADataMakerRec::operator = (const AliMUONQADataMakerRec& qadm )
147 {
148   /// Assignment operator
149
150   AliDebug(AliQAv1::GetQADebugLevel(),"");
151
152   // check assignment to self
153   if (this == &qadm) return *this;
154
155   this->~AliMUONQADataMakerRec();
156   new(this) AliMUONQADataMakerRec(qadm);
157   return *this;
158 }
159
160 //__________________________________________________________________
161 AliMUONQADataMakerRec::~AliMUONQADataMakerRec()
162 {
163     /// dtor
164   
165   AliDebug(AliQAv1::GetQADebugLevel(),"");
166
167   AliCodeTimerAuto("");
168   
169   delete fDigitStore;
170   delete fTriggerStore;
171   delete fDigitMaker;
172   delete fClusterStore;
173   delete fTrackerDataMaker;
174 }
175
176 //____________________________________________________________________________ 
177 void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
178 {
179   ///Detector specific actions at end of cycle
180   
181   AliCodeTimerAuto("");
182   
183   // Display trigger histos in a more user friendly way
184   DisplayTriggerInfo(task);
185   
186   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
187     if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) ) 
188       continue ;
189     SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
190     if ( task == AliQAv1::kRAWS && fTrackerDataMaker ) 
191       {
192         TIter next(list[specie]);
193         TObject* o;
194         Bool_t alreadyThere(kFALSE);
195         while ( ( o = next() ) && !alreadyThere )
196           {
197             TString classname(o->ClassName());
198             if ( classname.Contains("TrackerData") ) alreadyThere = kTRUE;
199           }
200         if (!alreadyThere && fTrackerDataMaker) 
201           {
202           AliDebug(AliQAv1::GetQADebugLevel(), "Adding fTrackerDataMaker to the list of qa objects");
203             list[specie]->AddAt(fTrackerDataMaker->Data(),(Int_t)kTrackerData);
204           }
205           if ( fTrackerDataMaker ) 
206             {
207               TH1* hbp = GetRawsData(kTrackerBusPatchOccupancy);
208               hbp->Reset();
209               TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
210               AliMpBusPatch* bp(0x0);
211               AliMUONVTrackerData* data = fTrackerDataMaker->Data();
212               Int_t occDim = 2;
213       
214               while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
215                 {
216                   Int_t busPatchId = bp->GetId();
217                   Int_t bin = hbp->FindBin(busPatchId);
218                   hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim));
219                 }
220             }
221       }
222     
223     // Normalize RecPoints histos
224     if ( task == AliQAv1::kRECPOINTS ) {
225       
226       TH1* hTrackerClusterChargePerChMean = GetRecPointsData(kTrackerClusterChargePerChMean);
227       TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(kTrackerClusterChargePerChSigma);
228       TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(kTrackerClusterMultiplicityPerChMean);
229       TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(kTrackerClusterMultiplicityPerChSigma);
230       TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(kTrackerClusterChargePerDEMean);
231       TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(kTrackerClusterMultiplicityPerDEMean);
232       
233       // loop over chambers
234       for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
235         
236         TH1* hTrackerClusterChargePerChamber = GetRecPointsData(kTrackerClusterChargePerChamber+iCh);
237         Double_t sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
238         hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
239         hTrackerClusterChargePerChMean->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetMeanError());
240         hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
241         hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
242         
243         TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(kTrackerClusterMultiplicityPerChamber+iCh);
244         Double_t sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
245         hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
246         hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
247         hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
248         hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
249         
250         // loop over DE into chamber iCh
251         AliMpDEIterator it;
252         it.First(iCh);
253         while ( !it.IsDone()) {
254           
255           Int_t iDE = it.CurrentDEId();
256           
257           TH1* hTrackerClusterChargePerDE = GetRecPointsData(kTrackerClusterChargePerDE+iDE);
258           hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
259           Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
260           if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
261           else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber->GetXaxis()->GetXmax());
262           
263           TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(kTrackerClusterMultiplicityPerDE+iDE);
264           hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
265           nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
266           if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
267           else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax());
268           
269           it.Next();
270         }
271         
272       }
273       
274     }
275     
276     // Normalize ESD histos
277     if ( task == AliQAv1::kESDS ) {
278       
279       Double_t nTracks = GetESDsData(kESDnClustersPerTrack)->GetEntries();
280       if (nTracks <= 0) continue;
281       
282       TH1* hESDnClustersPerCh = GetESDsData(kESDnClustersPerCh);
283       TH1* hESDnClustersPerDE = GetESDsData(kESDnClustersPerDE);
284       TH1* hESDClusterChargePerChMean = GetESDsData(kESDClusterChargePerChMean);
285       TH1* hESDClusterChargePerChSigma = GetESDsData(kESDClusterChargePerChSigma);
286       TH1* hESDClusterSizePerChMean = GetESDsData(kESDClusterSizePerChMean);
287       TH1* hESDClusterSizePerChSigma = GetESDsData(kESDClusterSizePerChSigma);
288       TH1* hESDResidualXPerChMean = GetESDsData(kESDResidualXPerChMean);
289       TH1* hESDResidualXPerChSigma = GetESDsData(kESDResidualXPerChSigma);
290       TH1* hESDResidualYPerChMean = GetESDsData(kESDResidualYPerChMean);
291       TH1* hESDResidualYPerChSigma = GetESDsData(kESDResidualYPerChSigma);
292       TH1* hESDLocalChi2XPerChMean = GetESDsData(kESDLocalChi2XPerChMean);
293       TH1* hESDLocalChi2YPerChMean = GetESDsData(kESDLocalChi2YPerChMean);
294       TH1* hESDLocalChi2PerChMean = GetESDsData(kESDLocalChi2PerChMean);
295       TH1* hESDClusterChargePerDE = GetESDsData(kESDClusterChargePerDE);
296       TH1* hESDClusterSizePerDE = GetESDsData(kESDClusterSizePerDE);
297       TH1* hESDResidualXPerDEMean = GetESDsData(kESDResidualXPerDEMean);
298       TH1* hESDResidualXPerDESigma = GetESDsData(kESDResidualXPerDESigma);
299       TH1* hESDResidualYPerDEMean = GetESDsData(kESDResidualYPerDEMean);
300       TH1* hESDResidualYPerDESigma = GetESDsData(kESDResidualYPerDESigma);
301       TH1* hESDLocalChi2XPerDEMean = GetESDsData(kESDLocalChi2XPerDEMean);
302       TH1* hESDLocalChi2YPerDEMean = GetESDsData(kESDLocalChi2YPerDEMean);
303       TH1* hESDLocalChi2PerDEMean = GetESDsData(kESDLocalChi2PerDEMean);
304       TH1* hESDnTotClustersPerCh = GetESDsData(kESDnTotClustersPerCh);
305       TH1* hESDnTotClustersPerDE = GetESDsData(kESDnTotClustersPerDE);
306       TH1* hESDnTotFullClustersPerDE = GetESDsData(kESDnTotFullClustersPerDE);
307       TH1* hESDSumClusterChargePerDE = GetESDsData(kESDSumClusterChargePerDE);
308       TH1* hESDSumClusterSizePerDE = GetESDsData(kESDSumClusterSizePerDE);
309       TH1* hESDSumResidualXPerDE = GetESDsData(kESDSumResidualXPerDE);
310       TH1* hESDSumResidualYPerDE = GetESDsData(kESDSumResidualYPerDE);
311       TH1* hESDSumResidualX2PerDE = GetESDsData(kESDSumResidualX2PerDE);
312       TH1* hESDSumResidualY2PerDE = GetESDsData(kESDSumResidualY2PerDE);
313       TH1* hESDSumLocalChi2XPerDE = GetESDsData(kESDSumLocalChi2XPerDE);
314       TH1* hESDSumLocalChi2YPerDE = GetESDsData(kESDSumLocalChi2YPerDE);
315       TH1* hESDSumLocalChi2PerDE = GetESDsData(kESDSumLocalChi2PerDE);
316       
317       hESDnClustersPerCh->Reset();
318       hESDnClustersPerDE->Reset();
319       hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
320       hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
321       
322       // loop over chambers
323       for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
324         
325         TH1* hESDClusterChargeInCh = GetESDsData(kESDClusterChargeInCh+iCh);
326         Double_t sigmaCharge = hESDClusterChargeInCh->GetRMS();
327         hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
328         hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
329         hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
330         hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
331         
332         TH1* hESDClusterSizeInCh = GetESDsData(kESDClusterSizeInCh+iCh);
333         Double_t sigmaSize = hESDClusterSizeInCh->GetRMS();
334         hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
335         hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
336         hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
337         hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
338         
339         TH1* hESDResidualXInCh = GetESDsData(kESDResidualXInCh+iCh);
340         Double_t sigmaResidualX = hESDResidualXInCh->GetRMS();
341         hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
342         hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
343         hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
344         hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
345         
346         TH1* hESDResidualYInCh = GetESDsData(kESDResidualYInCh+iCh);
347         Double_t sigmaResidualY = hESDResidualYInCh->GetRMS();
348         hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
349         hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
350         hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
351         hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
352         
353         TH1* hESDLocalChi2XInCh = GetESDsData(kESDLocalChi2XInCh+iCh);
354         Double_t sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
355         hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
356         hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
357         
358         TH1* hESDLocalChi2YInCh = GetESDsData(kESDLocalChi2YInCh+iCh);
359         Double_t sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
360         hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
361         hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
362         
363         TH1* hESDLocalChi2InCh = GetESDsData(kESDLocalChi2InCh+iCh);
364         Double_t sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
365         hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
366         hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
367         
368         // loop over DE into chamber iCh
369         AliMpDEIterator it;
370         it.First(iCh);
371         while ( !it.IsDone()) {
372           
373           Int_t iDE = it.CurrentDEId();
374           
375           Double_t nClusters = hESDnTotClustersPerDE->GetBinContent(iDE+1);
376           if (nClusters > 1) {
377             
378             hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
379             hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
380             
381             Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
382             hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
383             hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
384             hESDResidualXPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
385             hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
386             
387             Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
388             hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
389             hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
390             hESDResidualYPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
391             hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
392             
393             hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
394             hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
395             
396             hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
397             hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
398             
399             hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
400             hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
401             
402           } else {
403             
404             hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
405             hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
406             
407             hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
408             hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
409             hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
410             hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
411             
412             hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
413             hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
414             hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
415             hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
416             
417             hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
418             hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
419             
420             hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
421             hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
422             
423             hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
424             hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
425             
426           }
427           
428           Double_t nFullClusters = hESDnTotFullClustersPerDE->GetBinContent(iDE+1);
429           if (nFullClusters > 1) {
430             
431             hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
432             hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
433             
434           } else {
435             
436             hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
437             hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
438             
439           }
440           
441           it.Next();
442         }
443         
444       }
445       
446     }
447     
448   }
449   
450   // do the QA checking
451   AliQAChecker::Instance()->Run(AliQAv1::kMUON, task, list) ;
452 }
453
454 //____________________________________________________________________________ 
455 void AliMUONQADataMakerRec::InitRaws()
456 {
457     /// create Raws histograms in Raws subdir
458         
459   AliCodeTimerAuto("");
460   
461   const Bool_t expert   = kTRUE ; 
462   const Bool_t saveCorr = kTRUE ; 
463   const Bool_t image    = kTRUE ; 
464   
465         if ( ! AliCDBManager::Instance()->GetDefaultStorage() )
466         {
467                 AliError("CDB default storage not set. Cannot work.");
468                 fIsInitRaws=kFALSE;
469         }
470         
471         TH3F* h3 = new TH3F("hTriggerScalersBendPlane", "Trigger scalers in bending plane",
472                                                                                         4, 10.5, 14.5,
473                                                                                         234, 0.5, 234.5,
474                                                                                         16, -0.5, 15.5);
475         h3->GetXaxis()->SetTitle("Chamber");
476         h3->GetYaxis()->SetTitle("Board");
477         h3->GetZaxis()->SetTitle("Strip");
478         Add2RawsList(h3, kTriggerScalersBP, expert, !image, !saveCorr);
479         
480         TH3F* h4 = new TH3F("hTriggerScalersNonBendPlane", "Trigger scalers in non-bending plane",
481                                                                                         4, 10.5, 14.5,
482                                                                                         234, 0.5, 234.5,
483                                                                                         16, -0.5, 15.5);
484         h4->GetXaxis()->SetTitle("Chamber");
485         h4->GetYaxis()->SetTitle("Board");
486         h4->GetZaxis()->SetTitle("Strip");
487         Add2RawsList(h4, kTriggerScalersNBP, expert, !image, !saveCorr);
488         
489         AliMUONTriggerDisplay triggerDisplay;
490         TString histoName, histoTitle;
491         for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
492                 TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
493                 for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
494                         histoName = Form("hScalers%sChamber%i", cathName.Data(), 11+iChamber);
495                         histoTitle = Form("Chamber %i: Scalers %s", 11+iChamber, cathName.Data());
496                         TH2F* h5 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
497                                                                               iCath, iChamber, histoTitle);
498                         Add2RawsList(h5, kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image, !saveCorr);
499                 }
500         }
501
502         TH2F* h6 = new TH2F("hTriggerRPCI", "Trigger RPC currents",
503                             4, 10.5, 14.5,
504                             18, -0.5, 17.5);
505         h6->GetXaxis()->SetTitle("Chamber");
506         h6->GetYaxis()->SetTitle("RPC");
507         Add2RawsList(h6, kTriggerRPCi, expert, !image, !saveCorr);
508
509         TH2F* h7 = new TH2F("hTriggerRPCHV", "Trigger RPC HV",
510                             4, 10.5, 14.5,
511                             18, -0.5, 17.5);
512         h7->GetXaxis()->SetTitle("Chamber");
513         h7->GetYaxis()->SetTitle("RPC");
514         Add2RawsList(h7, kTriggerRPChv, expert, !image, !saveCorr);
515         
516         for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
517           histoName = Form("hRPCIChamber%i", 11+iChamber);
518           histoTitle = Form("Chamber %i: RPC Currents (#muA)", 11+iChamber);
519           TH2F* h8 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplaySlats, 
520                                                                 0, iChamber, histoTitle);
521           Add2RawsList(h8, kTriggerIDisplay + iChamber, !expert, image, !saveCorr);
522         }
523
524         for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
525           histoName = Form("hRPCHVChamber%i", 11+iChamber);
526           histoTitle = Form("Chamber %i: RPC HV (V)", 11+iChamber);
527           TH2F* h9 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplaySlats, 
528                                                                 0, iChamber, histoTitle);
529           Add2RawsList(h9, kTriggerHVDisplay + iChamber, !expert, image, !saveCorr);
530         }
531
532         TH1F* h10 = new TH1F("hTriggerScalersTime", "Trigger scalers acquisition time", 1, 0.5, 1.5);
533         h10->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
534         h10->GetYaxis()->SetTitle("Cumulated scaler time (s)");
535         Add2RawsList(h10, kTriggerScalersTime, !expert, image, !saveCorr);
536         
537   Int_t nbp(0);
538   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
539   while (next())
540   {
541     ++nbp;
542   }
543   
544   TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",
545                       nbp,-0.5,nbp-0.5);
546   
547   Add2RawsList(hbp,kTrackerBusPatchOccupancy, !expert, image, !saveCorr);
548
549   const Bool_t histogram(kFALSE);
550
551   fTrackerDataMaker = new AliMUONTrackerDataMaker(GetMUONRecoParam(),
552                                                   AliCDBManager::Instance()->GetRun(),
553                                                   0x0,
554                                                   AliCDBManager::Instance()->GetDefaultStorage()->GetURI(),
555                                                   "NOGAIN",
556                                                   histogram,
557                                                   0.0,0.0);
558                 
559   fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
560         
561   fTrackerDataMaker->SetRunning(kTRUE);
562   
563         fIsInitRaws = kTRUE;
564 }
565
566 //__________________________________________________________________
567 void AliMUONQADataMakerRec::InitDigits() 
568 {
569   /// Initialized Digits spectra 
570   const Bool_t expert   = kTRUE ; 
571   const Bool_t image    = kTRUE ; 
572   
573   TH1I* h0 = new TH1I("hDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  1400, 100, 1500); 
574   Add2DigitsList(h0, 0, !expert, image);
575   
576   TH1I* h1 = new TH1I("hDigitsADC", "ADC distribution in Digits;ACD value;Counts", 4096, 0, 4095); 
577   Add2DigitsList(h1, 1, !expert, image);    
578
579
580 //____________________________________________________________________________ 
581 void AliMUONQADataMakerRec::InitRecPoints()
582 {
583         /// create Reconstructed Points histograms in RecPoints subdir
584   
585   AliCodeTimerAuto("");
586   
587         InitRecPointsTrigger();
588         InitRecPointsTracker();
589 }
590
591 //____________________________________________________________________________ 
592 void AliMUONQADataMakerRec::InitRecPointsTracker()
593 {
594   /// create Reconstructed Points histograms in RecPoints subdir for the
595   /// MUON tracker subsystem.
596   const Bool_t expert   = kTRUE ; 
597   const Bool_t image    = kTRUE ; 
598   
599   AliCodeTimerAuto("");
600   
601   TH1I *h1I;
602   TH1F *h1F;
603   TH2F *h2F;
604   
605   // histograms per chamber
606   Int_t nCh = AliMpConstants::NofTrackingChambers();
607   for ( Int_t i = 0; i < nCh; ++i ) 
608   {
609     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
610     Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerChamber+i, expert, !image);
611     
612     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (ADC counts);Counts",i+1), 500,0,5000);
613     Add2RecPointsList(h1I,kTrackerClusterChargePerChamber+i, expert, !image);
614     
615     Float_t rMax = AliMUONConstants::Rmax(i/2);
616     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);
617     Add2RecPointsList(h2F, kTrackerClusterHitMapPerChamber+i, expert, !image);
618   }
619   
620   // summary histograms per chamber
621   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
622   Add2RecPointsList(h1I,kTrackerNumberOfClustersPerChamber, !expert, image);
623   
624   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
625   h1F->SetOption("P");
626   h1F->SetMarkerStyle(kFullDotMedium);
627   h1F->SetMarkerColor(kRed);
628   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChMean, !expert, image);
629   
630   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
631   h1F->SetOption("P");
632   h1F->SetMarkerStyle(kFullDotMedium);
633   h1F->SetMarkerColor(kRed);
634   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChSigma, !expert, image);
635   
636   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (ADC counts)", nCh,-0.5,nCh-0.5);
637   h1F->SetOption("P");
638   h1F->SetMarkerStyle(kFullDotMedium);
639   h1F->SetMarkerColor(kRed);
640   Add2RecPointsList(h1F, kTrackerClusterChargePerChMean, !expert, image);
641   
642   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (ADC counts)", nCh,-0.5,nCh-0.5);
643   h1F->SetOption("P");
644   h1F->SetMarkerStyle(kFullDotMedium);
645   h1F->SetMarkerColor(kRed);
646   Add2RecPointsList(h1F, kTrackerClusterChargePerChSigma, !expert, image);
647   
648   // histograms per DE
649   Int_t ndes(0);
650   AliMpDEIterator it;
651   it.First();
652   while ( !it.IsDone())
653   {
654     Int_t detElemId = it.CurrentDEId();
655     
656     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
657     {
658       ndes = TMath::Max(ndes,detElemId);
659       
660       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
661       Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
662       
663       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (ADC counts)",detElemId), 500,0,5000);
664       Add2RecPointsList(h1I,kTrackerClusterChargePerDE+detElemId, expert, !image);
665     }
666     
667     it.Next();
668   }
669   
670   // summary histograms per DE
671   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
672   Add2RecPointsList(h1I, kTrackerNumberOfClustersPerDE, !expert, image);
673   
674   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
675   h1F->SetOption("P");
676   h1F->SetMarkerStyle(kFullDotMedium);
677   h1F->SetMarkerColor(kRed);
678   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerDEMean, !expert, image);
679   
680   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (ADC counts)", ndes+1,-0.5,ndes+0.5);
681   h1F->SetOption("P");
682   h1F->SetMarkerStyle(kFullDotMedium);
683   h1F->SetMarkerColor(kRed);
684   Add2RecPointsList(h1F, kTrackerClusterChargePerDEMean, !expert, image);
685   
686   fIsInitRecPointsTracker=kTRUE;
687 }
688
689 //____________________________________________________________________________ 
690 void AliMUONQADataMakerRec::InitRecPointsTrigger()
691 {
692         /// create Reconstructed Points histograms in RecPoints subdir for the
693         /// MUON Trigger subsystem.
694         
695   const Bool_t expert   = kTRUE ; 
696   const Bool_t image    = kTRUE ; 
697   
698     TH3F* h0 = new TH3F("hTriggerDigitsBendPlane", "Trigger digits in bending plane",
699                         4, 10.5, 14.5,
700                         234, 0.5, 234.5,
701                         16, -0.5, 15.5);
702     h0->GetXaxis()->SetTitle("Chamber");
703     h0->GetYaxis()->SetTitle("Board");
704     h0->GetZaxis()->SetTitle("Strip");
705     Add2RecPointsList(h0, kTriggerDigitsBendPlane, expert, !image);
706
707     TH3F* h1 = new TH3F("hTriggerDigitsNonBendPlane", "Trigger digits in non-bending plane",
708                         4, 10.5, 14.5,
709                         234, 0.5, 234.5,
710                         16, -0.5, 15.5);
711     h1->GetXaxis()->SetTitle("Chamber");
712     h1->GetYaxis()->SetTitle("Board");
713     h1->GetZaxis()->SetTitle("Strip");
714     Add2RecPointsList(h1, kTriggerDigitsNonBendPlane, expert, !image);
715
716     TH1F* h2 = new TH1F("hTriggeredBoards", "Triggered boards", 234, 0.5, 234.5);
717     Add2RecPointsList(h2, kTriggeredBoards, expert, !image);
718
719     AliMUONTriggerDisplay triggerDisplay;
720     TString histoName, histoTitle;
721     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
722       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
723       for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
724         histoName = Form("hTriggerDigits%sChamber%i", cathName.Data(), 11+iChamber);
725         histoTitle = Form("Chamber %i: Fired pads %s", 11+iChamber, cathName.Data());
726         TH2F* h3 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
727                                                               iCath, iChamber, histoTitle);
728         Add2RecPointsList(h3, kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image);
729       }
730     }
731
732     TH2F* h4 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto("hFiredBoardsDisplay", AliMUONTriggerDisplay::kDisplayBoards,
733                                                           0, 0, "Fired boards");
734     Add2RecPointsList(h4, kTriggerBoardsDisplay, !expert, image);
735         
736         fIsInitRecPointsTrigger = kTRUE;
737 }
738
739
740 //____________________________________________________________________________ 
741 void AliMUONQADataMakerRec::InitESDs()
742 {
743   ///create ESDs histograms in ESDs subdir
744   
745   const Bool_t expert   = kTRUE ; 
746   const Bool_t image    = kTRUE ; 
747   
748   Int_t nCh = AliMUONConstants::NTrackingCh();
749   Int_t nDE = 1100;
750   
751   // track info
752   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
753   Add2ESDsList(hESDnTracks, kESDnTracks, !expert, image);
754
755   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
756   Add2ESDsList(hESDMatchTrig, kESDMatchTrig, !expert, image);
757   
758   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
759   Add2ESDsList(hESDMomentum, kESDMomentum, !expert, image);
760
761   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
762   Add2ESDsList(hESDPt, kESDPt, !expert, image);
763
764   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
765   Add2ESDsList(hESDRapidity, kESDRapidity, !expert, image);
766
767   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
768   Add2ESDsList(hESDChi2, kESDChi2, !expert, image);
769   
770   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
771   Add2ESDsList(hESDProbChi2, kESDProbChi2, !expert, image);
772   
773   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
774   Add2ESDsList(hESDThetaX, kESDThetaX, !expert, image);
775   
776   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
777   Add2ESDsList(hESDThetaY, kESDThetaY, !expert, image);
778   
779   // cluster info
780   for (Int_t i = 0; i < nCh; i++) {
781     Float_t rMax = AliMUONConstants::Rmax(i/2);
782     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
783                                        100, -rMax, rMax, 100, -rMax, rMax);
784     Add2ESDsList(hESDClusterHitMap, kESDClusterHitMap+i, expert, !image);
785   }
786   
787   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
788   Add2ESDsList(hESDnClustersPerTrack, kESDnClustersPerTrack, !expert, image);
789   
790   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
791   hESDnClustersPerCh->SetFillColor(kRed);
792   Add2ESDsList(hESDnClustersPerCh, kESDnClustersPerCh, !expert, image);
793   
794   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
795   hESDnClustersPerDE->SetFillColor(kRed);
796   Add2ESDsList(hESDnClustersPerDE, kESDnClustersPerDE, !expert, image);
797   
798   for (Int_t i = 0; i < nCh; i++) {
799     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (ADC counts)",i+1), 500, 0., 5000.);
800     Add2ESDsList(hESDClusterChargeInCh, kESDClusterChargeInCh+i, expert, !image);
801   }
802   
803   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (ADC counts)", nCh, -0.5, nCh-0.5);
804   hESDClusterChargePerChMean->SetOption("P");
805   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
806   hESDClusterChargePerChMean->SetMarkerColor(kRed);
807   Add2ESDsList(hESDClusterChargePerChMean, kESDClusterChargePerChMean, !expert, image);
808   
809   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (ADC counts)", nCh, -0.5, nCh-0.5);
810   hESDClusterChargePerChSigma->SetOption("P");
811   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
812   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
813   Add2ESDsList(hESDClusterChargePerChSigma, kESDClusterChargePerChSigma, !expert, image);
814   
815   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (ADC counts)", nDE+1, -0.5, nDE+0.5);
816   hESDClusterChargePerDE->SetOption("P");
817   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
818   hESDClusterChargePerDE->SetMarkerColor(kRed);
819   Add2ESDsList(hESDClusterChargePerDE, kESDClusterChargePerDE, !expert, image);
820   
821   for (Int_t i = 0; i < nCh; i++) {
822     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
823     Add2ESDsList(hESDClusterSizeInCh, kESDClusterSizeInCh+i, expert, !image);
824   }
825   
826   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
827   hESDClusterSizePerChMean->SetOption("P");
828   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
829   hESDClusterSizePerChMean->SetMarkerColor(kRed);
830   Add2ESDsList(hESDClusterSizePerChMean, kESDClusterSizePerChMean, !expert, image);
831   
832   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
833   hESDClusterSizePerChSigma->SetOption("P");
834   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
835   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
836   Add2ESDsList(hESDClusterSizePerChSigma, kESDClusterSizePerChSigma, !expert, image);
837   
838   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
839   hESDClusterSizePerDE->SetOption("P");
840   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
841   hESDClusterSizePerDE->SetMarkerColor(kRed);
842   Add2ESDsList(hESDClusterSizePerDE, kESDClusterSizePerDE, !expert, image);
843   
844   // cluster - track info
845   for (Int_t i = 0; i < nCh; i++) {
846     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.);
847     Add2ESDsList(hESDResidualXInCh, kESDResidualXInCh+i, expert, !image);
848     
849     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.);
850     Add2ESDsList(hESDResidualYInCh, kESDResidualYInCh+i, expert, !image);
851     
852     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);
853     Add2ESDsList(hESDLocalChi2XInCh, kESDLocalChi2XInCh+i, expert, !image);
854     
855     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);
856     Add2ESDsList(hESDLocalChi2YInCh, kESDLocalChi2YInCh+i, expert, !image);
857     
858     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);
859     Add2ESDsList(hESDLocalChi2InCh, kESDLocalChi2InCh+i, expert, !image);
860   }
861   
862   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
863   hESDResidualXPerChMean->SetOption("P");
864   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
865   hESDResidualXPerChMean->SetMarkerColor(kRed);
866   Add2ESDsList(hESDResidualXPerChMean, kESDResidualXPerChMean, !expert, image);
867   
868   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
869   hESDResidualYPerChMean->SetOption("P");
870   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
871   hESDResidualYPerChMean->SetMarkerColor(kRed);
872   Add2ESDsList(hESDResidualYPerChMean, kESDResidualYPerChMean, !expert, image);
873   
874   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
875   hESDResidualXPerChSigma->SetOption("P");
876   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
877   hESDResidualXPerChSigma->SetMarkerColor(kRed);
878   Add2ESDsList(hESDResidualXPerChSigma, kESDResidualXPerChSigma, !expert, image);
879   
880   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
881   hESDResidualYPerChSigma->SetOption("P");
882   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
883   hESDResidualYPerChSigma->SetMarkerColor(kRed);
884   Add2ESDsList(hESDResidualYPerChSigma, kESDResidualYPerChSigma, !expert, image);
885   
886   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerChMean", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
887   hESDLocalChi2XPerChMean->SetOption("P");
888   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
889   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
890   Add2ESDsList(hESDLocalChi2XPerChMean, kESDLocalChi2XPerChMean, !expert, image);
891   
892   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerChMean", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
893   hESDLocalChi2YPerChMean->SetOption("P");
894   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
895   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
896   Add2ESDsList(hESDLocalChi2YPerChMean, kESDLocalChi2YPerChMean, !expert, image);
897   
898   TH1F* hESDLocalChi2PerChMean = new TH1F("hESDLocalChi2PerChMean", "local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per Ch: mean;chamber ID;<local #chi^{2}>", nCh, -0.5, nCh-0.5);
899   hESDLocalChi2PerChMean->SetOption("P");
900   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
901   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
902   Add2ESDsList(hESDLocalChi2PerChMean, kESDLocalChi2PerChMean, !expert, image);
903   
904   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
905   hESDResidualXPerDEMean->SetOption("P");
906   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
907   hESDResidualXPerDEMean->SetMarkerColor(kRed);
908   Add2ESDsList(hESDResidualXPerDEMean, kESDResidualXPerDEMean, !expert, image);
909   
910   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
911   hESDResidualYPerDEMean->SetOption("P");
912   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
913   hESDResidualYPerDEMean->SetMarkerColor(kRed);
914   Add2ESDsList(hESDResidualYPerDEMean, kESDResidualYPerDEMean, !expert, image);
915   
916   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
917   hESDResidualXPerDESigma->SetOption("P");
918   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
919   hESDResidualXPerDESigma->SetMarkerColor(kRed);
920   Add2ESDsList(hESDResidualXPerDESigma, kESDResidualXPerDESigma, !expert, image);
921   
922   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
923   hESDResidualYPerDESigma->SetOption("P");
924   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
925   hESDResidualYPerDESigma->SetMarkerColor(kRed);
926   Add2ESDsList(hESDResidualYPerDESigma, kESDResidualYPerDESigma, !expert, image);
927   
928   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDEMean", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
929   hESDLocalChi2XPerDEMean->SetOption("P");
930   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
931   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
932   Add2ESDsList(hESDLocalChi2XPerDEMean, kESDLocalChi2XPerDEMean, !expert, image);
933   
934   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDEMean", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
935   hESDLocalChi2YPerDEMean->SetOption("P");
936   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
937   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
938   Add2ESDsList(hESDLocalChi2YPerDEMean, kESDLocalChi2YPerDEMean, !expert, image);
939   
940   TH1F* hESDLocalChi2PerDEMean = new TH1F("hESDLocalChi2PerDEMean", "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);
941   hESDLocalChi2PerDEMean->SetOption("P");
942   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
943   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
944   Add2ESDsList(hESDLocalChi2PerDEMean, kESDLocalChi2PerDEMean, !expert, image);
945   
946   // intermediate histograms
947   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
948   Add2ESDsList(hESDnTotClustersPerCh, kESDnTotClustersPerCh, expert, !image);
949   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
950   Add2ESDsList(hESDnTotClustersPerDE, kESDnTotClustersPerDE, expert, !image);
951   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);
952   Add2ESDsList(hESDnTotFullClustersPerDE, kESDnTotFullClustersPerDE, expert, !image);
953   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (ADC counts)", nDE+1, -0.5, nDE+0.5);
954   Add2ESDsList(hESDSumClusterChargePerDE, kESDSumClusterChargePerDE, expert, !image);
955   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
956   Add2ESDsList(hESDSumClusterSizePerDE, kESDSumClusterSizePerDE, expert, !image);
957   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);
958   Add2ESDsList(hESDSumResidualXPerDE, kESDSumResidualXPerDE, expert, !image);
959   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);
960   Add2ESDsList(hESDSumResidualYPerDE, kESDSumResidualYPerDE, expert, !image);
961   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);
962   Add2ESDsList(hESDSumResidualX2PerDE, kESDSumResidualX2PerDE, expert, !image);
963   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);
964   Add2ESDsList(hESDSumResidualY2PerDE, kESDSumResidualY2PerDE, expert, !image);
965   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);
966   Add2ESDsList(hESDSumLocalChi2XPerDE, kESDSumLocalChi2XPerDE, expert, !image);
967   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);
968   Add2ESDsList(hESDSumLocalChi2YPerDE, kESDSumLocalChi2YPerDE, expert, !image);
969   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);
970   Add2ESDsList(hESDSumLocalChi2PerDE, kESDSumLocalChi2PerDE, expert, !image);
971   
972   fIsInitESDs =  kTRUE;
973 }
974
975 //____________________________________________________________________________
976 void AliMUONQADataMakerRec::MakeRaws(AliRawReader* rawReader)
977 {
978     /// make QA for rawdata
979
980   if ( ! GetRawsData(0) )
981     InitRaws() ;
982
983   if ( ! fIsInitRaws ) {
984       AliWarningStream() 
985         << "Skipping function due to a failure in Init" << endl;
986       return;
987     }    
988
989     // Check id histograms already created for this Event Specie
990   
991   if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ) 
992   {
993     rawReader->Reset();
994     MakeRawsTracker(rawReader);
995   }
996   
997   rawReader->Reset();    
998   MakeRawsTrigger(rawReader);
999 }
1000
1001 //____________________________________________________________________________
1002 void AliMUONQADataMakerRec::MakeRawsTracker(AliRawReader* rawReader)
1003 {
1004         /// make QA for rawdata tracker
1005         
1006         ((AliMUONTrackerDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader);
1007         
1008         fTrackerDataMaker->ProcessEvent();
1009 }
1010
1011 //____________________________________________________________________________
1012 void AliMUONQADataMakerRec::MakeRawsTrigger(AliRawReader* rawReader)
1013 {
1014         /// make QA for rawdata trigger
1015         
1016     // Get trigger scalers
1017
1018     Int_t loCircuit=0;
1019     AliMpCDB::LoadDDLStore();
1020
1021     AliMUONRawStreamTrigger rawStreamTrig(rawReader);
1022     while (rawStreamTrig.NextDDL()) 
1023     {
1024       // If not a scaler event, do nothing
1025       Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
1026       if(!scalerEvent) break;
1027
1028       AliMUONDDLTrigger* ddlTrigger = rawStreamTrig.GetDDLTrigger();
1029       AliMUONDarcHeader* darcHeader = ddlTrigger->GetDarcHeader();
1030
1031       if (darcHeader->GetGlobalFlag()){
1032         UInt_t nOfClocks = darcHeader->GetGlobalClock();
1033         Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
1034         ((TH1F*)GetRawsData(kTriggerScalersTime))->Fill(1., nOfSeconds);
1035       }
1036
1037       Int_t nReg = darcHeader->GetRegHeaderEntries();
1038     
1039       for(Int_t iReg = 0; iReg < nReg ;iReg++)
1040       {   //reg loop
1041
1042         // crate info  
1043         AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
1044           GetTriggerCrate(rawStreamTrig.GetDDL(), iReg);
1045
1046         AliMUONRegHeader* regHeader =  darcHeader->GetRegHeaderEntry(iReg);
1047
1048         // loop over local structures
1049         Int_t nLocal = regHeader->GetLocalEntries();
1050         for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
1051         {
1052           AliMUONLocalStruct* localStruct = regHeader->GetLocalEntry(iLocal);
1053         
1054           // if card exist
1055           if (!localStruct) continue;
1056           
1057           loCircuit = crate->GetLocalBoardId(localStruct->GetId());
1058
1059           if ( !loCircuit ) continue; // empty slot
1060
1061           AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
1062
1063           // skip copy cards
1064           if( !localBoard->IsNotified()) 
1065             continue;
1066
1067           Int_t cathode = localStruct->GetComptXY()%2;
1068
1069           ERaw hindex = (cathode==0) ? kTriggerScalersBP : kTriggerScalersNBP;
1070
1071           // loop over strips
1072           for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
1073             if(localStruct->GetXY1(ibitxy) > 0)
1074               ((TH3F*)GetRawsData(hindex))->Fill(11+0, loCircuit, ibitxy, 2*localStruct->GetXY1(ibitxy));
1075             if(localStruct->GetXY2(ibitxy) > 0)
1076               ((TH3F*)GetRawsData(hindex))->Fill(11+1, loCircuit, ibitxy, 2*localStruct->GetXY2(ibitxy));
1077             if(localStruct->GetXY3(ibitxy) > 0)
1078               ((TH3F*)GetRawsData(hindex))->Fill(11+2, loCircuit, ibitxy, 2*localStruct->GetXY3(ibitxy));
1079             if(localStruct->GetXY4(ibitxy) > 0)
1080               ((TH3F*)GetRawsData(hindex))->Fill(11+3, loCircuit, ibitxy, 2*localStruct->GetXY4(ibitxy));
1081           } // loop on strips
1082         } // iLocal
1083       } // iReg
1084     } // NextDDL
1085 }
1086
1087 //__________________________________________________________________
1088 void AliMUONQADataMakerRec::MakeDigits(TTree* digitsTree)         
1089 {
1090   /// makes data from Digits
1091
1092   // Check id histograms already created for this Event Specie
1093   if ( ! GetDigitsData(0) )
1094     InitDigits() ;
1095  
1096   if (!fDigitStore)
1097     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1098   fDigitStore->Connect(*digitsTree, false);
1099   digitsTree->GetEvent(0);
1100   
1101   TIter next(fDigitStore->CreateIterator());
1102   
1103   AliMUONVDigit* dig = 0x0;
1104   
1105   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1106     {
1107     GetDigitsData(0)->Fill(dig->DetElemId());
1108     GetDigitsData(1)->Fill(dig->ADC());
1109     }
1110 }
1111
1112 //____________________________________________________________________________
1113 void AliMUONQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1114 {
1115         /// Fill histograms from treeR
1116         
1117   // Check id histograms already created for this Event Specie
1118   if ( ! GetRecPointsData(0) )
1119     InitRecPoints() ;
1120  
1121   if (fIsInitRecPointsTracker) MakeRecPointsTracker(clustersTree);
1122         if (fIsInitRecPointsTrigger) MakeRecPointsTrigger(clustersTree);
1123 }
1124
1125 //____________________________________________________________________________
1126 void AliMUONQADataMakerRec::MakeRecPointsTracker(TTree* clustersTree)
1127 {
1128         /// Fill histograms related to tracker clusters 
1129         
1130         // First things first : do we have clusters in the TreeR ?
1131         // In "normal" production mode, it should be perfectly normal
1132         // *not* to have them.
1133         // But if for some reason we de-activated the combined tracking,
1134         // then we have clusters in TreeR, so let's take that opportunity
1135         // to QA them...
1136         
1137         if (!fClusterStore)
1138         {
1139                 AliCodeTimerAuto("ClusterStore creation");
1140                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1141                 if (!fClusterStore) 
1142                 {
1143                         fIsInitRecPointsTracker = kFALSE;
1144                         return;
1145                 }
1146         }
1147         
1148         AliCodeTimerAuto("");
1149         
1150         fClusterStore->Connect(*clustersTree,kFALSE);
1151         clustersTree->GetEvent(0);
1152
1153         TIter next(fClusterStore->CreateIterator());
1154         AliMUONVCluster* cluster;
1155         
1156         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1157         {
1158                 Int_t detElemId = cluster->GetDetElemId();
1159                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1160                 
1161                 GetRecPointsData(kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1162                 GetRecPointsData(kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1163                 GetRecPointsData(kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1164
1165                 GetRecPointsData(kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1166                 GetRecPointsData(kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1167                 GetRecPointsData(kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1168                 GetRecPointsData(kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1169                 
1170         }
1171         
1172         fClusterStore->Clear();
1173 }
1174
1175 //____________________________________________________________________________
1176 void AliMUONQADataMakerRec::MakeRecPointsTrigger(TTree* clustersTree)
1177 {
1178         /// makes data from trigger response
1179       
1180     // Fired pads info
1181     fDigitStore->Clear();
1182
1183     if (!fTriggerStore) fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
1184     fTriggerStore->Clear();
1185     fTriggerStore->Connect(*clustersTree, false);
1186     clustersTree->GetEvent(0);
1187
1188     AliMUONLocalTrigger* locTrg;
1189     TIter nextLoc(fTriggerStore->CreateLocalIterator());
1190
1191     while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(nextLoc()) ) ) 
1192     {
1193       if (locTrg->IsNull()) continue;
1194    
1195       TArrayS xyPattern[2];
1196       locTrg->GetXPattern(xyPattern[0]);
1197       locTrg->GetYPattern(xyPattern[1]);
1198
1199       Int_t nBoard = locTrg->LoCircuit();
1200
1201       Bool_t xTrig=locTrg->IsTrigX();
1202       Bool_t yTrig=locTrg->IsTrigY();
1203     
1204       if (xTrig && yTrig)
1205         ((TH1F*)GetRecPointsData(kTriggeredBoards))->Fill(nBoard);
1206
1207       fDigitMaker->TriggerDigits(nBoard, xyPattern, *fDigitStore);
1208     }
1209
1210     TIter nextDigit(fDigitStore->CreateIterator());
1211     AliMUONVDigit* mDigit;
1212     while ( ( mDigit = static_cast<AliMUONVDigit*>(nextDigit()) ) )
1213     {
1214       Int_t detElemId = mDigit->DetElemId();
1215       Int_t ch = detElemId/100;
1216       Int_t localBoard = mDigit->ManuId();
1217       Int_t channel = mDigit->ManuChannel();
1218       Int_t cathode = mDigit->Cathode();
1219       ERecPoints hindex 
1220         = ( cathode == 0 ) ? kTriggerDigitsBendPlane : kTriggerDigitsNonBendPlane;
1221       
1222       ((TH3F*)GetRecPointsData(hindex))->Fill(ch, localBoard, channel);
1223     }
1224 }
1225
1226 //____________________________________________________________________________
1227 void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
1228 {
1229   /// make QA data from ESDs
1230   
1231   // Check id histograms already created for this Event Specie
1232   if ( ! GetESDsData(0) )
1233     InitESDs() ;
1234  
1235   if ( ! fIsInitESDs ) {
1236     AliWarningStream() 
1237     << "Skipping function due to a failure in Init" << endl;
1238     return;
1239   }  
1240   
1241   // load ESD event in the interface
1242   AliMUONESDInterface esdInterface;
1243   if (GetMUONRecoParam()) AliMUONESDInterface::ResetTracker(GetMUONRecoParam());
1244   else AliError("Unable to get recoParam: use default ones for residual calculation");
1245   esdInterface.LoadEvent(*esd);
1246   
1247   GetESDsData(kESDnTracks)->Fill(esdInterface.GetNTracks());
1248   
1249   Int_t nTrackMatchTrig = 0;
1250   
1251   // loop over tracks
1252   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1253   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1254     
1255     // get the ESD track and skip "ghosts"
1256     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1257     if (!esdTrack->ContainTrackerData()) continue;
1258     
1259     // get corresponding MUON track
1260     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1261     
1262     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1263     
1264     GetESDsData(kESDMomentum)->Fill(esdTrack->P());
1265     GetESDsData(kESDPt)->Fill(esdTrack->Pt());
1266     GetESDsData(kESDRapidity)->Fill(esdTrack->Y());
1267     GetESDsData(kESDChi2)->Fill(track->GetNormalizedChi2());
1268     GetESDsData(kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1269     GetESDsData(kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1270     GetESDsData(kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1271     GetESDsData(kESDnClustersPerTrack)->Fill(track->GetNClusters());
1272     
1273     // loop over clusters
1274     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1275     while (trackParam) {
1276       
1277       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1278       Int_t chId = cluster->GetChamberId();
1279       Int_t deID = cluster->GetDetElemId();
1280       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1281       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1282       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1283       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1284       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1285       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1286       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1287       
1288       GetESDsData(kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1289       
1290       GetESDsData(kESDnTotClustersPerCh)->Fill(chId);
1291       GetESDsData(kESDnTotClustersPerDE)->Fill(deID);
1292       
1293       GetESDsData(kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1294       GetESDsData(kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1295       
1296       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1297         GetESDsData(kESDnTotFullClustersPerDE)->Fill(deID);
1298         GetESDsData(kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1299         GetESDsData(kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1300       }
1301       
1302       GetESDsData(kESDResidualXInCh+chId)->Fill(residualX);
1303       GetESDsData(kESDResidualYInCh+chId)->Fill(residualY);
1304       GetESDsData(kESDSumResidualXPerDE)->Fill(deID, residualX);
1305       GetESDsData(kESDSumResidualYPerDE)->Fill(deID, residualY);
1306       GetESDsData(kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1307       GetESDsData(kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1308       
1309       GetESDsData(kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1310       GetESDsData(kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1311       GetESDsData(kESDLocalChi2InCh+chId)->Fill(localChi2);
1312       GetESDsData(kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1313       GetESDsData(kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1314       GetESDsData(kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1315       
1316       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1317     }
1318     
1319   }
1320   
1321   GetESDsData(kESDMatchTrig)->Fill(nTrackMatchTrig);
1322   
1323 }
1324
1325 //____________________________________________________________________________ 
1326 void AliMUONQADataMakerRec::StartOfDetectorCycle()
1327 {
1328     /// Detector specific actions at start of cycle
1329   
1330 }
1331
1332 //____________________________________________________________________________ 
1333 void AliMUONQADataMakerRec::DisplayTriggerInfo(AliQAv1::TASKINDEX_t task)
1334 {
1335   //
1336   /// Display trigger information in a user-friendly way:
1337   /// from local board and strip numbers to their position on chambers
1338   //
1339   
1340
1341   if(task!=AliQAv1::kRECPOINTS && task!=AliQAv1::kRAWS) return;
1342
1343   AliMUONTriggerDisplay triggerDisplay;
1344   
1345   TH3F* histoStrips=0x0;
1346   TH2F* histoDisplayStrips=0x0;
1347
1348   for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
1349   {
1350     if(task==AliQAv1::kRECPOINTS){
1351       ERecPoints hindex 
1352         = ( iCath == 0 ) ? kTriggerDigitsBendPlane : kTriggerDigitsNonBendPlane;
1353       histoStrips = (TH3F*)GetRecPointsData(hindex);
1354     }
1355     else if(task==AliQAv1::kRAWS){
1356       ERaw hindex 
1357         = ( iCath == 0 ) ? kTriggerScalersBP : kTriggerScalersNBP;
1358       histoStrips = (TH3F*)GetRawsData(hindex);
1359       if(histoStrips->GetEntries()==0) continue; // No scalers found
1360     }
1361     
1362     for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
1363     {
1364       if(task==AliQAv1::kRECPOINTS){
1365         histoDisplayStrips = (TH2F*)GetRecPointsData(kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1366       }
1367       else if(task==AliQAv1::kRAWS){
1368         histoDisplayStrips = (TH2F*)GetRawsData(kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1369       }
1370       Int_t bin = histoStrips->GetXaxis()->FindBin(11+iChamber);
1371       histoStrips->GetXaxis()->SetRange(bin,bin);
1372       TH2F* inputHisto = (TH2F*)histoStrips->Project3D("zy");
1373       triggerDisplay.FillDisplayHistogram(inputHisto, histoDisplayStrips, AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber);
1374       if(task==AliQAv1::kRAWS) {
1375         Float_t acquisitionTime = ((TH1F*)GetRawsData(kTriggerScalersTime))->GetBinContent(1);
1376         histoDisplayStrips->Scale(1./acquisitionTime);
1377       }
1378     } // iChamber
1379   } // iCath
1380
1381   if(task==AliQAv1::kRAWS){    
1382     TH2F* histoI  = (TH2F*) GetRawsData(kTriggerRPCi);
1383     TH2F* histoHV = (TH2F*) GetRawsData(kTriggerRPChv);
1384     FillTriggerDCSHistos();
1385     for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++) {
1386       Int_t bin = histoI->GetXaxis()->FindBin(11+iChamber);
1387       TH2F* histoDisplayI = (TH2F*)GetRawsData(kTriggerIDisplay + iChamber);
1388       triggerDisplay.FillDisplayHistogram(histoI->ProjectionY("_px", bin, bin), histoDisplayI, AliMUONTriggerDisplay::kDisplaySlats, 0, iChamber);
1389       TH2F* histoDisplayHV = (TH2F*)GetRawsData(kTriggerHVDisplay + iChamber);
1390       bin = histoHV->GetXaxis()->FindBin(11+iChamber);
1391       triggerDisplay.FillDisplayHistogram(histoHV->ProjectionY("_px", bin, bin), histoDisplayHV, AliMUONTriggerDisplay::kDisplaySlats, 0, iChamber);
1392     }
1393   }
1394
1395   if(task==AliQAv1::kRECPOINTS){
1396     TH1F* histoBoards = (TH1F*)GetRecPointsData(kTriggeredBoards);
1397     TH2F* histoDisplayBoards = (TH2F*)GetRecPointsData(kTriggerBoardsDisplay);
1398     triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
1399   }
1400 }
1401
1402
1403 //_____________________________________________________________________________
1404 Bool_t 
1405 AliMUONQADataMakerRec::FillTriggerDCSHistos()
1406 {
1407   /// Get HV and currents values for one trigger chamber
1408   
1409   AliCodeTimerAuto("");
1410
1411   AliMUONCalibrationData calibrationData(AliCDBManager::Instance()->GetRun());
1412
1413   TMap* triggerDcsMap = calibrationData.TriggerDCS();
1414
1415   if ( !triggerDcsMap ) 
1416   {
1417     AliError("Cannot fill DCS histos, as triggerDcsMap is NULL");
1418     return kFALSE;
1419   }
1420
1421   AliMpDEIterator deIt;
1422   
1423   deIt.First();
1424     
1425   AliMpDCSNamer triggerDcsNamer("TRIGGER");
1426
1427   TH2* currHisto = 0x0;
1428
1429   Bool_t error = kFALSE;
1430   
1431   while ( !deIt.IsDone() )
1432   {
1433     Int_t detElemId = deIt.CurrentDEId();
1434     
1435     if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStationTrigger) {
1436
1437       Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
1438       Int_t slat = detElemId%100;
1439
1440       for(Int_t iMeas=0; iMeas<AliMpDCSNamer::kNDCSMeas; iMeas++){
1441         TString currAlias = triggerDcsNamer.DCSChannelName(detElemId, 0, iMeas);
1442
1443         AliDebug(AliQAv1::GetQADebugLevel(), Form("\nDetElemId %i   dcsAlias %s", detElemId, currAlias.Data()));
1444
1445         TPair* triggerDcsPair = static_cast<TPair*>(triggerDcsMap->FindObject(currAlias.Data()));
1446
1447         if (!triggerDcsPair)
1448         {
1449           AliError(Form("Did not find expected alias (%s) for DE %d",
1450                         currAlias.Data(),detElemId));  
1451           error = kTRUE;
1452         }
1453         else
1454         {
1455           TObjArray* values = static_cast<TObjArray*>(triggerDcsPair->Value());
1456           if (!values)
1457           {
1458             AliError(Form("Could not get values for alias %s",currAlias.Data()));
1459             error = kTRUE;
1460           }
1461           else
1462           {
1463             TIter next(values);
1464             AliDCSValue* val;
1465
1466             while ( ( val = static_cast<AliDCSValue*>(next()) ) )
1467             {
1468               Float_t hvi = val->GetFloat();
1469
1470               AliDebug(AliQAv1::GetQADebugLevel(), Form("Value %f", hvi));
1471
1472               switch(iMeas){
1473               case AliMpDCSNamer::kDCSI:
1474                 currHisto = (TH2F*) GetRawsData(kTriggerRPCi);
1475                 break;
1476               case AliMpDCSNamer::kDCSHV:
1477                 currHisto = (TH2F*) GetRawsData(kTriggerRPChv);
1478                 break;
1479               } 
1480               Int_t binX = currHisto->GetXaxis()->FindBin(iChamber+1);
1481               Int_t binY = currHisto->GetYaxis()->FindBin(slat);
1482               currHisto->SetBinContent(binX, binY, hvi);
1483             } // loop on values
1484           } // if (!values)
1485         } // if (!triggerDcsPair)
1486       } // loop on measured types (HV and currents)
1487     } // if (stationType == kStationTrigger)
1488
1489     deIt.Next();
1490   }
1491   return error;
1492 }
1493
1494 //____________________________________________________________________________ 
1495 AliMUONVTrackerData* AliMUONQADataMakerRec::GetTrackerData() const
1496
1497 /// Return tracker data
1498   
1499   return fTrackerDataMaker->Data(); 
1500   
1501 }