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