470273f058284b60309ba52e303d953580cfb920
[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 "AliMpDetElement.h"
51 #include "AliMpLocalBoard.h"
52 #include "AliMpStationType.h"
53 #include "AliMpTriggerCrate.h"
54 #include "AliMpDCSNamer.h"
55 #include "AliRawEventHeaderBase.h"
56
57 // --- AliRoot header files ---
58 #include "AliCDBManager.h"
59 #include "AliCDBStorage.h"
60 #include "AliESDEvent.h"
61 #include "AliESDMuonTrack.h"
62 #include "AliESDMuonCluster.h"
63 #include "AliLog.h"
64 #include "AliRawReader.h"
65 #include "AliQAChecker.h"
66 #include "AliCodeTimer.h"
67 #include "AliDCSValue.h"
68 #include "AliMUONVDigit.h"
69
70 // --- ROOT system ---
71 #include <TClonesArray.h>
72 #include <TFile.h> 
73 #include <TH1F.h> 
74 #include <TH1I.h> 
75 #include <TH2F.h>
76 #include <TLine.h>
77 #include <TPaveText.h>
78 #include <Riostream.h>
79 #include <TMath.h>
80
81 //-----------------------------------------------------------------------------
82 /// \class AliMUONQADataMakerRec
83 ///
84 /// MUON base class for quality assurance data (histo) maker
85 ///
86 /// \author C. Finck, D. Stocco, L. Aphecetche
87
88 /// \cond CLASSIMP
89 ClassImp(AliMUONQADataMakerRec)
90 /// \endcond
91            
92
93 namespace {
94   
95   int trim(Int_t n, 
96            Double_t* x,
97            Double_t alpha,
98            Double_t& tmean,
99            Double_t& tvar,
100            Double_t& min,
101            Double_t& max)
102   {
103     //
104     // Calculates the trimmed (tmean) mean
105     // of a sample (x) and estimates the variance (tvar)
106     // of that mean.
107     //
108     
109     // First check input parameters
110     
111     // number of observations
112     if ( n < 2 )
113     {
114       return -1;
115     }
116     
117     if ( alpha < 0 || alpha >= 0.5 )
118       // proportion of observations
119       // to be trimmed at each end of the sorted sample
120     {
121       return -2;
122     }
123     
124     // Input parameters are good. Let's move on.
125     
126     // Insure we use a sample sorted into ascending order.
127     
128     Int_t* indices = new Int_t[n];
129     
130     TMath::Sort(n,x,indices,kFALSE);
131     
132     Double_t* sx = new Double_t[n];
133     
134     for ( Int_t i = 0; i < n; ++i )
135     {
136       sx[i] = x[indices[i]];
137     }
138     delete[] indices;
139     
140   
141     // Number of observations trimmed at each end.
142     
143     Int_t k = static_cast<Int_t>(floorf(alpha * n));
144     
145     double sum = 0.0;
146     
147     for ( Int_t i = k; i < n - k ; ++i )
148     {
149       sum += sx[i];
150     }
151     
152     tmean = sum / ( n - 2 * k );
153   
154     double t2 = 0.0;
155     
156     for ( Int_t i = k; i < n - k; ++i )
157     {
158       t2 += (sx[i] - tmean) * (sx[i] - tmean);
159     }
160     
161     tvar = (
162             t2 +
163             k * (sx[k] - tmean) * (sx[k] - tmean) +
164             k * (sx[n - k - 1] - tmean) * (sx[n - k - 1] - tmean)
165             ) / (n * n);
166     
167     // get the min and max for the non-rejected values
168     min = DBL_MAX;
169     max = 0.0;
170     
171     for ( Int_t i = k; i < n-k; ++i ) 
172     {
173       min = TMath::Min(min,sx[i]);
174       max = TMath::Max(max,sx[i]);
175     }
176     
177     delete[] sx;
178     
179     return 0;
180   }
181 }
182
183 //____________________________________________________________________________ 
184 AliMUONQADataMakerRec::AliMUONQADataMakerRec() : 
185 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kMUON), "MUON Quality Assurance Data Maker"),
186 fDigitStore(0x0),
187 fTriggerStore(0x0),
188 fDigitMaker(0x0),
189 fClusterStore(0x0),
190 fTrackerDataMaker(0x0)
191 {
192     /// ctor
193         
194   AliDebug(AliQAv1::GetQADebugLevel(),"");
195
196         Ctor();
197 }
198
199 //____________________________________________________________________________ 
200 void
201 AliMUONQADataMakerRec::Ctor()
202 {
203         /// Init some members
204         fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
205         fDigitMaker = new AliMUONDigitMaker(kTRUE);
206 }
207
208 //____________________________________________________________________________ 
209 AliMUONQADataMakerRec::AliMUONQADataMakerRec(const AliMUONQADataMakerRec& qadm) :
210 AliQADataMakerRec(qadm),
211 fDigitStore(0x0),
212 fTriggerStore(0x0),
213 fDigitMaker(0x0),
214 fClusterStore(0x0),
215 fTrackerDataMaker(0x0)
216 {
217     ///copy ctor 
218
219   AliDebug(AliQAv1::GetQADebugLevel(),"");
220
221
222     SetName((const char*)qadm.GetName()) ; 
223     SetTitle((const char*)qadm.GetTitle()); 
224
225         // Do not copy the digit store and digit maker, but create its own ones
226         
227         Ctor();
228         
229 }
230
231 //__________________________________________________________________
232 AliMUONQADataMakerRec& AliMUONQADataMakerRec::operator = (const AliMUONQADataMakerRec& qadm )
233 {
234   /// Assignment operator
235
236   AliDebug(AliQAv1::GetQADebugLevel(),"");
237
238   // check assignment to self
239   if (this == &qadm) return *this;
240
241   this->~AliMUONQADataMakerRec();
242   new(this) AliMUONQADataMakerRec(qadm);
243   return *this;
244 }
245
246 //__________________________________________________________________
247 AliMUONQADataMakerRec::~AliMUONQADataMakerRec()
248 {
249     /// dtor
250   
251   AliDebug(AliQAv1::GetQADebugLevel(),"");
252
253   AliCodeTimerAuto("");
254   
255   delete fDigitStore;
256   delete fTriggerStore;
257   delete fDigitMaker;
258   delete fClusterStore;
259   delete fTrackerDataMaker;
260 }
261
262 //____________________________________________________________________________ 
263 void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
264 {
265   ///Detector specific actions at end of cycle
266   
267   AliCodeTimerAuto("");
268   
269   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
270   {
271     if (! IsValidEventSpecie(specie, list)  ) 
272       continue ;      
273     SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
274     if ( task == AliQAv1::kRAWS && fTrackerDataMaker ) 
275       {
276         if ( !GetRawsData(kTrackerBusPatchOccupancy) ) continue;
277         
278         TIter next(list[specie]);
279         TObject* o;
280         Bool_t alreadyThere(kFALSE);
281         while ( ( o = next() ) && !alreadyThere )
282           {
283             TString classname(o->ClassName());
284             if ( classname.Contains("TrackerData") ) alreadyThere = kTRUE;
285           }
286         if (!alreadyThere && fTrackerDataMaker) 
287           {
288           AliDebug(AliQAv1::GetQADebugLevel(), "Adding fTrackerData to the list of qa objects");
289             list[specie]->AddAt(fTrackerDataMaker->Data(),(Int_t)kTrackerData);
290           }
291           if ( fTrackerDataMaker ) 
292             {
293               TH1* hbp = GetRawsData(kTrackerBusPatchOccupancy);
294               hbp->Reset();
295               TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
296               AliMpBusPatch* bp(0x0);
297               AliMUONVTrackerData* data = fTrackerDataMaker->Data();
298               Int_t occDim = 2;
299       
300               while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
301                 {
302                   Int_t busPatchId = bp->GetId();
303                   Int_t bin = hbp->FindBin(busPatchId);
304                   hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
305                 }
306               
307               BeautifyTrackerBusPatchOccupancy(*hbp);
308             }
309       }
310     
311     // Normalize RecPoints histos
312     if ( task == AliQAv1::kRECPOINTS ) {
313       
314       if (!GetRecPointsData(kTrackerClusterChargePerChMean)) continue;
315
316       TH1* hTrackerClusterChargePerChMean = GetRecPointsData(kTrackerClusterChargePerChMean);
317       TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(kTrackerClusterChargePerChSigma);
318       TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(kTrackerClusterMultiplicityPerChMean);
319       TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(kTrackerClusterMultiplicityPerChSigma);
320       TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(kTrackerClusterChargePerDEMean);
321       TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(kTrackerClusterMultiplicityPerDEMean);
322       
323       // loop over chambers
324       for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
325         
326         TH1* hTrackerClusterChargePerChamber = GetRecPointsData(kTrackerClusterChargePerChamber+iCh);
327         Double_t sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
328         hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
329         hTrackerClusterChargePerChMean->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetMeanError());
330         hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
331         hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
332         
333         TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(kTrackerClusterMultiplicityPerChamber+iCh);
334         Double_t sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
335         hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
336         hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
337         hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
338         hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
339         
340         // loop over DE into chamber iCh
341         AliMpDEIterator it;
342         it.First(iCh);
343         while ( !it.IsDone()) {
344           
345           Int_t iDE = it.CurrentDEId();
346           
347           TH1* hTrackerClusterChargePerDE = GetRecPointsData(kTrackerClusterChargePerDE+iDE);
348           hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
349           Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
350           if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
351           else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber->GetXaxis()->GetXmax());
352           
353           TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(kTrackerClusterMultiplicityPerDE+iDE);
354           hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
355           nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
356           if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
357           else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax());
358           
359           it.Next();
360         }
361         
362       }
363       
364     }
365     
366     // Normalize ESD histos
367     if ( task == AliQAv1::kESDS ) {
368       
369       if (!GetESDsData(kESDnClustersPerTrack)) continue;
370       
371       Double_t nTracks = GetESDsData(kESDnClustersPerTrack)->GetEntries();
372       if (nTracks <= 0) continue;
373       
374       TH1* hESDnClustersPerCh = GetESDsData(kESDnClustersPerCh);
375       TH1* hESDnClustersPerDE = GetESDsData(kESDnClustersPerDE);
376       TH1* hESDClusterChargePerChMean = GetESDsData(kESDClusterChargePerChMean);
377       TH1* hESDClusterChargePerChSigma = GetESDsData(kESDClusterChargePerChSigma);
378       TH1* hESDClusterSizePerChMean = GetESDsData(kESDClusterSizePerChMean);
379       TH1* hESDClusterSizePerChSigma = GetESDsData(kESDClusterSizePerChSigma);
380       TH1* hESDResidualXPerChMean = GetESDsData(kESDResidualXPerChMean);
381       TH1* hESDResidualXPerChSigma = GetESDsData(kESDResidualXPerChSigma);
382       TH1* hESDResidualYPerChMean = GetESDsData(kESDResidualYPerChMean);
383       TH1* hESDResidualYPerChSigma = GetESDsData(kESDResidualYPerChSigma);
384       TH1* hESDLocalChi2XPerChMean = GetESDsData(kESDLocalChi2XPerChMean);
385       TH1* hESDLocalChi2YPerChMean = GetESDsData(kESDLocalChi2YPerChMean);
386       TH1* hESDLocalChi2PerChMean = GetESDsData(kESDLocalChi2PerChMean);
387       TH1* hESDClusterChargePerDE = GetESDsData(kESDClusterChargePerDE);
388       TH1* hESDClusterSizePerDE = GetESDsData(kESDClusterSizePerDE);
389       TH1* hESDResidualXPerDEMean = GetESDsData(kESDResidualXPerDEMean);
390       TH1* hESDResidualXPerDESigma = GetESDsData(kESDResidualXPerDESigma);
391       TH1* hESDResidualYPerDEMean = GetESDsData(kESDResidualYPerDEMean);
392       TH1* hESDResidualYPerDESigma = GetESDsData(kESDResidualYPerDESigma);
393       TH1* hESDLocalChi2XPerDEMean = GetESDsData(kESDLocalChi2XPerDEMean);
394       TH1* hESDLocalChi2YPerDEMean = GetESDsData(kESDLocalChi2YPerDEMean);
395       TH1* hESDLocalChi2PerDEMean = GetESDsData(kESDLocalChi2PerDEMean);
396       TH1* hESDnTotClustersPerCh = GetESDsData(kESDnTotClustersPerCh);
397       TH1* hESDnTotClustersPerDE = GetESDsData(kESDnTotClustersPerDE);
398       TH1* hESDnTotFullClustersPerDE = GetESDsData(kESDnTotFullClustersPerDE);
399       TH1* hESDSumClusterChargePerDE = GetESDsData(kESDSumClusterChargePerDE);
400       TH1* hESDSumClusterSizePerDE = GetESDsData(kESDSumClusterSizePerDE);
401       TH1* hESDSumResidualXPerDE = GetESDsData(kESDSumResidualXPerDE);
402       TH1* hESDSumResidualYPerDE = GetESDsData(kESDSumResidualYPerDE);
403       TH1* hESDSumResidualX2PerDE = GetESDsData(kESDSumResidualX2PerDE);
404       TH1* hESDSumResidualY2PerDE = GetESDsData(kESDSumResidualY2PerDE);
405       TH1* hESDSumLocalChi2XPerDE = GetESDsData(kESDSumLocalChi2XPerDE);
406       TH1* hESDSumLocalChi2YPerDE = GetESDsData(kESDSumLocalChi2YPerDE);
407       TH1* hESDSumLocalChi2PerDE = GetESDsData(kESDSumLocalChi2PerDE);
408       
409       hESDnClustersPerCh->Reset();
410       hESDnClustersPerDE->Reset();
411       hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
412       hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
413       
414       // loop over chambers
415       for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
416         
417         TH1* hESDClusterChargeInCh = GetESDsData(kESDClusterChargeInCh+iCh);
418         Double_t sigmaCharge = hESDClusterChargeInCh->GetRMS();
419         hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
420         hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
421         hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
422         hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
423         
424         TH1* hESDClusterSizeInCh = GetESDsData(kESDClusterSizeInCh+iCh);
425         Double_t sigmaSize = hESDClusterSizeInCh->GetRMS();
426         hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
427         hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
428         hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
429         hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
430         
431         TH1* hESDResidualXInCh = GetESDsData(kESDResidualXInCh+iCh);
432         Double_t sigmaResidualX = hESDResidualXInCh->GetRMS();
433         hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
434         hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
435         hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
436         hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
437         
438         TH1* hESDResidualYInCh = GetESDsData(kESDResidualYInCh+iCh);
439         Double_t sigmaResidualY = hESDResidualYInCh->GetRMS();
440         hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
441         hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
442         hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
443         hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
444         
445         TH1* hESDLocalChi2XInCh = GetESDsData(kESDLocalChi2XInCh+iCh);
446         Double_t sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
447         hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
448         hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
449         
450         TH1* hESDLocalChi2YInCh = GetESDsData(kESDLocalChi2YInCh+iCh);
451         Double_t sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
452         hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
453         hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
454         
455         TH1* hESDLocalChi2InCh = GetESDsData(kESDLocalChi2InCh+iCh);
456         Double_t sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
457         hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
458         hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
459         
460         // loop over DE into chamber iCh
461         AliMpDEIterator it;
462         it.First(iCh);
463         while ( !it.IsDone()) {
464           
465           Int_t iDE = it.CurrentDEId();
466           
467           Double_t nClusters = hESDnTotClustersPerDE->GetBinContent(iDE+1);
468           if (nClusters > 1) {
469             
470             hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
471             hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
472             
473             Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
474             hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
475             hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
476             hESDResidualXPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
477             hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
478             
479             Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
480             hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
481             hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
482             hESDResidualYPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
483             hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
484             
485             hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
486             hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
487             
488             hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
489             hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
490             
491             hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
492             hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
493             
494           } else {
495             
496             hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
497             hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
498             
499             hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
500             hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
501             hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
502             hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
503             
504             hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
505             hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
506             hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
507             hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
508             
509             hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
510             hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
511             
512             hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
513             hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
514             
515             hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
516             hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
517             
518           }
519           
520           Double_t nFullClusters = hESDnTotFullClustersPerDE->GetBinContent(iDE+1);
521           if (nFullClusters > 1) {
522             
523             hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
524             hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
525             
526           } else {
527             
528             hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
529             hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
530             
531           }
532           
533           it.Next();
534         }
535         
536       }
537       
538     }
539     
540     // Display trigger histos in a more user friendly way
541     DisplayTriggerInfo(task);
542   } // loop on specie
543     
544   // do the QA checking
545   AliQAChecker::Instance()->Run(AliQAv1::kMUON, task, list) ;
546 }
547
548 //____________________________________________________________________________ 
549 void AliMUONQADataMakerRec::InitRaws()
550 {
551     /// create Raws histograms in Raws subdir
552         
553   AliCodeTimerAuto("");
554   
555   const Bool_t expert   = kTRUE ; 
556   const Bool_t saveCorr = kTRUE ; 
557   const Bool_t image    = kTRUE ; 
558  
559   TString boardName = "Local board Id";
560   
561   TString histoName, histoTitle;
562   for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
563     TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
564     for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
565       histoName = Form("hTriggerScalers%sChamber%i", cathName.Data(), 11+iChamber);
566       histoTitle = Form("Chamber %i - %s: trigger scaler counts", 11+iChamber, cathName.Data());
567       TH2F* h3 = new TH2F(histoName.Data(), histoTitle.Data(),
568                           234, 0.5, 234.5,
569                           16, -0.5, 15.5);
570       h3->GetXaxis()->SetTitle(boardName.Data());
571       h3->GetYaxis()->SetTitle("Strip");        
572       Add2RawsList(h3, kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
573     }
574   }
575         
576         AliMUONTriggerDisplay triggerDisplay;
577         for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
578                 TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
579                 for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
580                         histoName = Form("hScalersDisplay%sChamber%i", cathName.Data(), 11+iChamber);
581                         histoTitle = Form("Chamber %i - %s: Hit rate from scalers (Hz/cm^{2})", 11+iChamber, cathName.Data());
582                         TH2F* h5 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
583                                                                               iCath, iChamber, histoTitle);
584                         Add2RawsList(h5, kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image, !saveCorr);
585                 }
586         }
587
588         FillTriggerDCSHistos();
589
590         TH1F* h10 = new TH1F("hTriggerScalersTime", "Acquisition time from trigger scalers", 1, 0.5, 1.5);
591         h10->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
592         h10->GetYaxis()->SetTitle("Cumulated scaler time (s)");
593         Add2RawsList(h10, kTriggerScalersTime, !expert, !image, !saveCorr);
594         
595   Int_t bpmin(999999);
596   Int_t bpmax(0);
597   
598   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
599   AliMpBusPatch* bp(0x0);
600   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
601   {
602     bpmin = TMath::Min(bpmin,bp->GetId());
603     bpmax = TMath::Max(bpmax,bp->GetId());
604   }
605   
606   Double_t xmin = bpmin-0.5;
607   Double_t xmax = bpmax+0.5;
608   Int_t nbins = bpmax-bpmin+1;
609   
610   TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",nbins,xmin,xmax);
611
612   TH1* hbpnpads = new TH1F("hTrackerBusPatchNofPads","Number of pads per bus patch",nbins,xmin,xmax);
613
614   TH1* hbpnmanus = new TH1F("hTrackerBusPatchNofManus","Number of manus per bus patch",nbins,xmin,xmax);
615
616   Add2RawsList(hbp,kTrackerBusPatchOccupancy, !expert, image, !saveCorr);
617   Add2RawsList(hbpnpads,kTrackerBusPatchNofPads, expert, !image, !saveCorr);
618   Add2RawsList(hbpnmanus,kTrackerBusPatchNofManus, expert, !image, !saveCorr);
619
620   const Bool_t histogram(kFALSE);
621
622   if(!fTrackerDataMaker) fTrackerDataMaker = new AliMUONTrackerDataMaker(GetMUONRecoParam(),
623                                                   AliCDBManager::Instance()->GetRun(),
624                                                   0x0,
625                                                   "",
626                                                   "NOGAIN",
627                                                   histogram,
628                                                   0.0,0.0);
629                 
630   fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
631         
632   fTrackerDataMaker->SetRunning(kTRUE);
633 }
634
635 //__________________________________________________________________
636 void AliMUONQADataMakerRec::InitDigits() 
637 {
638   /// Initialized Digits spectra 
639   const Bool_t expert   = kTRUE ; 
640   const Bool_t image    = kTRUE ; 
641   
642   TH1I* h0 = new TH1I("hDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  1400, 100, 1500); 
643   Add2DigitsList(h0, 0, !expert, image);
644   
645   TH1I* h1 = new TH1I("hDigitsADC", "ADC distribution in Digits;ACD value;Counts", 4096, 0, 4095); 
646   Add2DigitsList(h1, 1, !expert, image);    
647
648
649 //____________________________________________________________________________ 
650 void AliMUONQADataMakerRec::InitRecPoints()
651 {
652         /// create Reconstructed Points histograms in RecPoints subdir
653   
654   AliCodeTimerAuto("");
655   
656         InitRecPointsTrigger();
657         InitRecPointsTracker();
658 }
659
660 //____________________________________________________________________________ 
661 void AliMUONQADataMakerRec::InitRecPointsTracker()
662 {
663   /// create Reconstructed Points histograms in RecPoints subdir for the
664   /// MUON tracker subsystem.
665   const Bool_t expert   = kTRUE ; 
666   const Bool_t image    = kTRUE ; 
667   
668   AliCodeTimerAuto("");
669   
670   TH1I *h1I;
671   TH1F *h1F;
672   TH2F *h2F;
673   
674   // histograms per chamber
675   Int_t nCh = AliMpConstants::NofTrackingChambers();
676   for ( Int_t i = 0; i < nCh; ++i ) 
677   {
678     h1I = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads};Counts)",i+1), 100,0,100);
679     Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerChamber+i, expert, !image);
680     
681     h1I = new TH1I(Form("hTrackerClusterChargeForChamber%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC);Counts",i+1), 100,0,1000);
682     Add2RecPointsList(h1I,kTrackerClusterChargePerChamber+i, expert, !image);
683     
684     Float_t rMax = AliMUONConstants::Rmax(i/2);
685     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);
686     Add2RecPointsList(h2F, kTrackerClusterHitMapPerChamber+i, expert, !image);
687   }
688   
689   // summary histograms per chamber
690   h1I = new TH1I("hTrackerNumberOfClustersPerChamber", "Number of clusters per chamber;chamber ID;n_{clusters}", nCh,-0.5,nCh-0.5);
691   Add2RecPointsList(h1I,kTrackerNumberOfClustersPerChamber, !expert, image);
692   
693   h1F = new TH1F("hTrackerClusterMultiplicityPerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh,-0.5,nCh-0.5);
694   h1F->SetOption("P");
695   h1F->SetMarkerStyle(kFullDotMedium);
696   h1F->SetMarkerColor(kRed);
697   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChMean, !expert, image);
698   
699   h1F = new TH1F("hTrackerClusterMultiplicityPerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh,-0.5,nCh-0.5);
700   h1F->SetOption("P");
701   h1F->SetMarkerStyle(kFullDotMedium);
702   h1F->SetMarkerColor(kRed);
703   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerChSigma, !expert, image);
704   
705   h1F = new TH1F("hTrackerClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh,-0.5,nCh-0.5);
706   h1F->SetOption("P");
707   h1F->SetMarkerStyle(kFullDotMedium);
708   h1F->SetMarkerColor(kRed);
709   Add2RecPointsList(h1F, kTrackerClusterChargePerChMean, !expert, image);
710   
711   h1F = new TH1F("hTrackerClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh,-0.5,nCh-0.5);
712   h1F->SetOption("P");
713   h1F->SetMarkerStyle(kFullDotMedium);
714   h1F->SetMarkerColor(kRed);
715   Add2RecPointsList(h1F, kTrackerClusterChargePerChSigma, !expert, image);
716   
717   // histograms per DE
718   Int_t ndes(0);
719   AliMpDEIterator it;
720   it.First();
721   while ( !it.IsDone())
722   {
723     Int_t detElemId = it.CurrentDEId();
724     
725     if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
726     {
727       ndes = TMath::Max(ndes,detElemId);
728       
729       h1I = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId), Form("cluster size distribution in detection element %d;size (n_{pads})",detElemId), 100,0,100);
730       Add2RecPointsList(h1I,kTrackerClusterMultiplicityPerDE+detElemId, expert, !image);
731       
732       h1I = new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId), Form("cluster charge distribution in detection element %d;charge (fC)",detElemId), 100,0,1000);
733       Add2RecPointsList(h1I,kTrackerClusterChargePerDE+detElemId, expert, !image);
734     }
735     
736     it.Next();
737   }
738   
739   // summary histograms per DE
740   h1I = new TH1I("hTrackerNumberOfClustersPerDE", "Number of clusters per detection element;DetElem ID;n_{clusters}", ndes+1,-0.5,ndes+0.5);
741   Add2RecPointsList(h1I, kTrackerNumberOfClustersPerDE, !expert, image);
742   
743   h1F = new TH1F("hTrackerClusterMultiplicityPerDEMean", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", ndes+1,-0.5,ndes+0.5);
744   h1F->SetOption("P");
745   h1F->SetMarkerStyle(kFullDotMedium);
746   h1F->SetMarkerColor(kRed);
747   Add2RecPointsList(h1F, kTrackerClusterMultiplicityPerDEMean, !expert, image);
748   
749   h1F = new TH1F("hTrackerClusterChargePerDEMean", "cluster mean charge per DE;DetElem ID;<charge> (fC)", ndes+1,-0.5,ndes+0.5);
750   h1F->SetOption("P");
751   h1F->SetMarkerStyle(kFullDotMedium);
752   h1F->SetMarkerColor(kRed);
753   Add2RecPointsList(h1F, kTrackerClusterChargePerDEMean, !expert, image);
754 }
755
756 //____________________________________________________________________________ 
757 void AliMUONQADataMakerRec::InitRecPointsTrigger()
758 {
759         /// create Reconstructed Points histograms in RecPoints subdir for the
760         /// MUON Trigger subsystem.
761         
762   const Bool_t expert   = kTRUE ; 
763   const Bool_t image    = kTRUE ; 
764
765   TString boardName = "Local board Id";
766
767   TString histoName, histoTitle;
768   for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
769     TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
770     for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
771       histoName = Form("hTriggerDigits%sChamber%i", cathName.Data(), 11+iChamber);
772       histoTitle = Form("Chamber %i - %s: counts per strip", 11+iChamber, cathName.Data());
773       TH2F* h0 = new TH2F(histoName.Data(), histoTitle.Data(),
774                           234, 0.5, 234.5,
775                           16, -0.5, 15.5);
776       h0->GetXaxis()->SetTitle(boardName.Data());
777       h0->GetYaxis()->SetTitle("Strip");
778       Add2RecPointsList(h0, kTriggerDigits + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image);
779     }
780   }
781
782     TH1F* h2 = new TH1F("hTriggeredBoards", "Triggered boards", 234, 0.5, 234.5);
783     Add2RecPointsList(h2, kTriggeredBoards, expert, !image);
784
785     AliMUONTriggerDisplay triggerDisplay;
786     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
787       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
788       for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
789         histoName = Form("hTriggerDigitsDisplay%sChamber%i", cathName.Data(), 11+iChamber);
790         histoTitle = Form("Chamber %i - %s: Occupancy per strip (counts/event)", 11+iChamber, cathName.Data());
791         TH2F* h3 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
792                                                               iCath, iChamber, histoTitle);
793         Add2RecPointsList(h3, kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, !expert, image);
794       }
795     }
796
797     TH2F* h4 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto("hFiredBoardsDisplay", AliMUONTriggerDisplay::kDisplayBoards,
798                                                           0, 0, "Local board triggers / event");
799     Add2RecPointsList(h4, kTriggerBoardsDisplay, !expert, image);
800
801     TH1F* h5 = new TH1F("hNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
802     Int_t esindex = AliRecoParam::AConvert(fEventSpecie);
803     h5->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
804     h5->GetYaxis()->SetTitle("Number of analyzed events");
805     Add2RecPointsList(h5, kNAnalyzedEvents, !expert, image);
806 }
807
808
809 //____________________________________________________________________________ 
810 void AliMUONQADataMakerRec::InitESDs()
811 {
812   ///create ESDs histograms in ESDs subdir
813   
814   const Bool_t expert   = kTRUE ; 
815   const Bool_t image    = kTRUE ; 
816   
817   Int_t nCh = AliMUONConstants::NTrackingCh();
818   Int_t nDE = 1100;
819   
820   // track info
821   TH1F* hESDnTracks = new TH1F("hESDnTracks", "number of tracks;n_{tracks}", 20, 0., 20.);
822   Add2ESDsList(hESDnTracks, kESDnTracks, !expert, image);
823
824   TH1F* hESDMatchTrig = new TH1F("hESDMatchTrig", "number of tracks matched with trigger;n_{tracks}", 20, 0., 20.);
825   Add2ESDsList(hESDMatchTrig, kESDMatchTrig, !expert, image);
826   
827   TH1F* hESDMomentum = new TH1F("hESDMomentum", "momentum distribution;p (GeV/c)", 300, 0., 300);
828   Add2ESDsList(hESDMomentum, kESDMomentum, !expert, image);
829
830   TH1F* hESDPt = new TH1F("hESDPt", "transverse momentum distribution;p_{t} (GeV/c)", 200, 0., 50);
831   Add2ESDsList(hESDPt, kESDPt, !expert, image);
832
833   TH1F* hESDRapidity = new TH1F("hESDRapidity", "rapidity distribution;rapidity", 200, -4.5, -2.);
834   Add2ESDsList(hESDRapidity, kESDRapidity, !expert, image);
835
836   TH1F* hESDChi2 = new TH1F("hESDChi2", "normalized #chi^{2} distribution;#chi^{2} / ndf", 500, 0., 50.);
837   Add2ESDsList(hESDChi2, kESDChi2, !expert, image);
838   
839   TH1F* hESDProbChi2 = new TH1F("hESDProbChi2", "distribution of probability of #chi^{2};prob(#chi^{2})", 100, 0., 1.);
840   Add2ESDsList(hESDProbChi2, kESDProbChi2, !expert, image);
841   
842   TH1F* hESDThetaX = new TH1F("hESDThetaX", "#theta_{X} distribution;#theta_{X} (degree)", 360, -180., 180);
843   Add2ESDsList(hESDThetaX, kESDThetaX, !expert, image);
844   
845   TH1F* hESDThetaY = new TH1F("hESDThetaY", "#theta_{Y} distribution;#theta_{Y} (degree)", 360, -180., 180);
846   Add2ESDsList(hESDThetaY, kESDThetaY, !expert, image);
847   
848   // cluster info
849   for (Int_t i = 0; i < nCh; i++) {
850     Float_t rMax = AliMUONConstants::Rmax(i/2);
851     TH2F* hESDClusterHitMap = new TH2F(Form("hESDClusterHitMap%d",i+1), Form("cluster position distribution in chamber %d;X (cm);Y (cm)",i+1),
852                                        100, -rMax, rMax, 100, -rMax, rMax);
853     Add2ESDsList(hESDClusterHitMap, kESDClusterHitMap+i, expert, !image);
854   }
855   
856   TH1F* hESDnClustersPerTrack = new TH1F("hESDnClustersPerTrack", "number of associated clusters per track;n_{clusters}", 20, 0., 20.);
857   Add2ESDsList(hESDnClustersPerTrack, kESDnClustersPerTrack, !expert, image);
858   
859   TH1F* hESDnClustersPerCh = new TH1F("hESDnClustersPerCh", "averaged number of clusters per chamber per track;chamber ID;<n_{clusters}>", nCh, -0.5, nCh-0.5);
860   hESDnClustersPerCh->SetFillColor(kRed);
861   Add2ESDsList(hESDnClustersPerCh, kESDnClustersPerCh, !expert, image);
862   
863   TH1F* hESDnClustersPerDE = new TH1F("hESDnClustersPerDE", "averaged number of clusters per DE per track;DetElem ID;<n_{clusters}>", nDE+1, -0.5, nDE+0.5);
864   hESDnClustersPerDE->SetFillColor(kRed);
865   Add2ESDsList(hESDnClustersPerDE, kESDnClustersPerDE, !expert, image);
866   
867   for (Int_t i = 0; i < nCh; i++) {
868     TH1F* hESDClusterChargeInCh = new TH1F(Form("hESDClusterChargeInCh%d",i+1), Form("cluster charge distribution in chamber %d;charge (fC)",i+1), 100, 0., 1000.);
869     Add2ESDsList(hESDClusterChargeInCh, kESDClusterChargeInCh+i, expert, !image);
870   }
871   
872   TH1F* hESDClusterChargePerChMean = new TH1F("hESDClusterChargePerChMean", "cluster mean charge per chamber;chamber ID;<charge> (fC)", nCh, -0.5, nCh-0.5);
873   hESDClusterChargePerChMean->SetOption("P");
874   hESDClusterChargePerChMean->SetMarkerStyle(kFullDotMedium);
875   hESDClusterChargePerChMean->SetMarkerColor(kRed);
876   Add2ESDsList(hESDClusterChargePerChMean, kESDClusterChargePerChMean, !expert, image);
877   
878   TH1F* hESDClusterChargePerChSigma = new TH1F("hESDClusterChargePerChSigma", "cluster charge dispersion per chamber;chamber ID;#sigma_{charge} (fC)", nCh, -0.5, nCh-0.5);
879   hESDClusterChargePerChSigma->SetOption("P");
880   hESDClusterChargePerChSigma->SetMarkerStyle(kFullDotMedium);
881   hESDClusterChargePerChSigma->SetMarkerColor(kRed);
882   Add2ESDsList(hESDClusterChargePerChSigma, kESDClusterChargePerChSigma, !expert, image);
883   
884   TH1F* hESDClusterChargePerDE = new TH1F("hESDClusterChargePerDE", "cluster mean charge per DE;DetElem ID;<charge> (fC)", nDE+1, -0.5, nDE+0.5);
885   hESDClusterChargePerDE->SetOption("P");
886   hESDClusterChargePerDE->SetMarkerStyle(kFullDotMedium);
887   hESDClusterChargePerDE->SetMarkerColor(kRed);
888   Add2ESDsList(hESDClusterChargePerDE, kESDClusterChargePerDE, !expert, image);
889   
890   for (Int_t i = 0; i < nCh; i++) {
891     TH1F* hESDClusterSizeInCh = new TH1F(Form("hESDClusterSizeInCh%d",i+1), Form("cluster size distribution in chamber %d;size (n_{pads})",i+1), 200, 0., 200.);
892     Add2ESDsList(hESDClusterSizeInCh, kESDClusterSizeInCh+i, expert, !image);
893   }
894   
895   TH1F* hESDClusterSizePerChMean = new TH1F("hESDClusterSizePerChMean", "cluster mean size per chamber;chamber ID;<size> (n_{pads})", nCh, -0.5, nCh-0.5);
896   hESDClusterSizePerChMean->SetOption("P");
897   hESDClusterSizePerChMean->SetMarkerStyle(kFullDotMedium);
898   hESDClusterSizePerChMean->SetMarkerColor(kRed);
899   Add2ESDsList(hESDClusterSizePerChMean, kESDClusterSizePerChMean, !expert, image);
900   
901   TH1F* hESDClusterSizePerChSigma = new TH1F("hESDClusterSizePerChSigma", "cluster size dispersion per chamber;chamber ID;#sigma_{size} (n_{pads})", nCh, -0.5, nCh-0.5);
902   hESDClusterSizePerChSigma->SetOption("P");
903   hESDClusterSizePerChSigma->SetMarkerStyle(kFullDotMedium);
904   hESDClusterSizePerChSigma->SetMarkerColor(kRed);
905   Add2ESDsList(hESDClusterSizePerChSigma, kESDClusterSizePerChSigma, !expert, image);
906   
907   TH1F* hESDClusterSizePerDE = new TH1F("hESDClusterSizePerDE", "cluster mean size per DE;DetElem ID;<size> (n_{pads})", nDE+1, -0.5, nDE+0.5);
908   hESDClusterSizePerDE->SetOption("P");
909   hESDClusterSizePerDE->SetMarkerStyle(kFullDotMedium);
910   hESDClusterSizePerDE->SetMarkerColor(kRed);
911   Add2ESDsList(hESDClusterSizePerDE, kESDClusterSizePerDE, !expert, image);
912   
913   // cluster - track info
914   for (Int_t i = 0; i < nCh; i++) {
915     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.);
916     Add2ESDsList(hESDResidualXInCh, kESDResidualXInCh+i, expert, !image);
917     
918     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.);
919     Add2ESDsList(hESDResidualYInCh, kESDResidualYInCh+i, expert, !image);
920     
921     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);
922     Add2ESDsList(hESDLocalChi2XInCh, kESDLocalChi2XInCh+i, expert, !image);
923     
924     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);
925     Add2ESDsList(hESDLocalChi2YInCh, kESDLocalChi2YInCh+i, expert, !image);
926     
927     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);
928     Add2ESDsList(hESDLocalChi2InCh, kESDLocalChi2InCh+i, expert, !image);
929   }
930   
931   TH1F* hESDResidualXPerChMean = new TH1F("hESDResidualXPerChMean", "cluster-track residual-X per Ch: mean;chamber ID;<#Delta_{X}> (cm)", nCh, -0.5, nCh-0.5);
932   hESDResidualXPerChMean->SetOption("P");
933   hESDResidualXPerChMean->SetMarkerStyle(kFullDotMedium);
934   hESDResidualXPerChMean->SetMarkerColor(kRed);
935   Add2ESDsList(hESDResidualXPerChMean, kESDResidualXPerChMean, !expert, image);
936   
937   TH1F* hESDResidualYPerChMean = new TH1F("hESDResidualYPerChMean", "cluster-track residual-Y per Ch: mean;chamber ID;<#Delta_{Y}> (cm)", nCh, -0.5, nCh-0.5);
938   hESDResidualYPerChMean->SetOption("P");
939   hESDResidualYPerChMean->SetMarkerStyle(kFullDotMedium);
940   hESDResidualYPerChMean->SetMarkerColor(kRed);
941   Add2ESDsList(hESDResidualYPerChMean, kESDResidualYPerChMean, !expert, image);
942   
943   TH1F* hESDResidualXPerChSigma = new TH1F("hESDResidualXPerChSigma", "cluster-track residual-X per Ch: sigma;chamber ID;#sigma_{X} (cm)", nCh, -0.5, nCh-0.5);
944   hESDResidualXPerChSigma->SetOption("P");
945   hESDResidualXPerChSigma->SetMarkerStyle(kFullDotMedium);
946   hESDResidualXPerChSigma->SetMarkerColor(kRed);
947   Add2ESDsList(hESDResidualXPerChSigma, kESDResidualXPerChSigma, !expert, image);
948   
949   TH1F* hESDResidualYPerChSigma = new TH1F("hESDResidualYPerChSigma", "cluster-track residual-Y per Ch: sigma;chamber ID;#sigma_{Y} (cm)", nCh, -0.5, nCh-0.5);
950   hESDResidualYPerChSigma->SetOption("P");
951   hESDResidualYPerChSigma->SetMarkerStyle(kFullDotMedium);
952   hESDResidualYPerChSigma->SetMarkerColor(kRed);
953   Add2ESDsList(hESDResidualYPerChSigma, kESDResidualYPerChSigma, !expert, image);
954   
955   TH1F* hESDLocalChi2XPerChMean = new TH1F("hESDLocalChi2XPerCh", "local chi2-X per Ch: mean;chamber ID;<local #chi^{2}_{X}>", nCh, -0.5, nCh-0.5);
956   hESDLocalChi2XPerChMean->SetOption("P");
957   hESDLocalChi2XPerChMean->SetMarkerStyle(kFullDotMedium);
958   hESDLocalChi2XPerChMean->SetMarkerColor(kRed);
959   Add2ESDsList(hESDLocalChi2XPerChMean, kESDLocalChi2XPerChMean, !expert, image);
960   
961   TH1F* hESDLocalChi2YPerChMean = new TH1F("hESDLocalChi2YPerCh", "local chi2-Y per Ch: mean;chamber ID;<local #chi^{2}_{Y}>", nCh, -0.5, nCh-0.5);
962   hESDLocalChi2YPerChMean->SetOption("P");
963   hESDLocalChi2YPerChMean->SetMarkerStyle(kFullDotMedium);
964   hESDLocalChi2YPerChMean->SetMarkerColor(kRed);
965   Add2ESDsList(hESDLocalChi2YPerChMean, kESDLocalChi2YPerChMean, !expert, image);
966   
967   TH1F* hESDLocalChi2PerChMean = new TH1F("hESDLocalChi2PerCh", "local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per Ch: mean;chamber ID;<local #chi^{2}>", nCh, -0.5, nCh-0.5);
968   hESDLocalChi2PerChMean->SetOption("P");
969   hESDLocalChi2PerChMean->SetMarkerStyle(kFullDotMedium);
970   hESDLocalChi2PerChMean->SetMarkerColor(kRed);
971   Add2ESDsList(hESDLocalChi2PerChMean, kESDLocalChi2PerChMean, !expert, image);
972   
973   TH1F* hESDResidualXPerDEMean = new TH1F("hESDResidualXPerDEMean", "cluster-track residual-X per DE: mean;DetElem ID;<#Delta_{X}> (cm)", nDE+1, -0.5, nDE+0.5);
974   hESDResidualXPerDEMean->SetOption("P");
975   hESDResidualXPerDEMean->SetMarkerStyle(kFullDotMedium);
976   hESDResidualXPerDEMean->SetMarkerColor(kRed);
977   Add2ESDsList(hESDResidualXPerDEMean, kESDResidualXPerDEMean, !expert, image);
978   
979   TH1F* hESDResidualYPerDEMean = new TH1F("hESDResidualYPerDEMean", "cluster-track residual-Y per DE: mean;DetElem ID;<#Delta_{Y}> (cm)", nDE+1, -0.5, nDE+0.5);
980   hESDResidualYPerDEMean->SetOption("P");
981   hESDResidualYPerDEMean->SetMarkerStyle(kFullDotMedium);
982   hESDResidualYPerDEMean->SetMarkerColor(kRed);
983   Add2ESDsList(hESDResidualYPerDEMean, kESDResidualYPerDEMean, !expert, image);
984   
985   TH1F* hESDResidualXPerDESigma = new TH1F("hESDResidualXPerDESigma", "cluster-track residual-X per DE: sigma;DetElem ID;#sigma_{X} (cm)", nDE+1, -0.5, nDE+0.5);
986   hESDResidualXPerDESigma->SetOption("P");
987   hESDResidualXPerDESigma->SetMarkerStyle(kFullDotMedium);
988   hESDResidualXPerDESigma->SetMarkerColor(kRed);
989   Add2ESDsList(hESDResidualXPerDESigma, kESDResidualXPerDESigma, !expert, image);
990   
991   TH1F* hESDResidualYPerDESigma = new TH1F("hESDResidualYPerDESigma", "cluster-track residual-Y per DE: sigma;DetElem ID;#sigma_{Y} (cm)", nDE+1, -0.5, nDE+0.5);
992   hESDResidualYPerDESigma->SetOption("P");
993   hESDResidualYPerDESigma->SetMarkerStyle(kFullDotMedium);
994   hESDResidualYPerDESigma->SetMarkerColor(kRed);
995   Add2ESDsList(hESDResidualYPerDESigma, kESDResidualYPerDESigma, !expert, image);
996   
997   TH1F* hESDLocalChi2XPerDEMean = new TH1F("hESDLocalChi2XPerDE", "local chi2-X per DE: mean;DetElem ID;<local #chi^{2}_{X}>", nDE+1, -0.5, nDE+0.5);
998   hESDLocalChi2XPerDEMean->SetOption("P");
999   hESDLocalChi2XPerDEMean->SetMarkerStyle(kFullDotMedium);
1000   hESDLocalChi2XPerDEMean->SetMarkerColor(kRed);
1001   Add2ESDsList(hESDLocalChi2XPerDEMean, kESDLocalChi2XPerDEMean, !expert, image);
1002   
1003   TH1F* hESDLocalChi2YPerDEMean = new TH1F("hESDLocalChi2YPerDE", "local chi2-Y per DE: mean;DetElem ID;<local #chi^{2}_{Y}>", nDE+1, -0.5, nDE+0.5);
1004   hESDLocalChi2YPerDEMean->SetOption("P");
1005   hESDLocalChi2YPerDEMean->SetMarkerStyle(kFullDotMedium);
1006   hESDLocalChi2YPerDEMean->SetMarkerColor(kRed);
1007   Add2ESDsList(hESDLocalChi2YPerDEMean, kESDLocalChi2YPerDEMean, !expert, image);
1008   
1009   TH1F* hESDLocalChi2PerDEMean = new TH1F("hESDLocalChi2PerDE", "local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per DE: mean;DetElem ID;<local #chi^{2}>", nDE+1, -0.5, nDE+0.5);
1010   hESDLocalChi2PerDEMean->SetOption("P");
1011   hESDLocalChi2PerDEMean->SetMarkerStyle(kFullDotMedium);
1012   hESDLocalChi2PerDEMean->SetMarkerColor(kRed);
1013   Add2ESDsList(hESDLocalChi2PerDEMean, kESDLocalChi2PerDEMean, !expert, image);
1014   
1015   // intermediate histograms
1016   TH1F* hESDnTotClustersPerCh = new TH1F("hESDnTotClustersPerCh", "total number of associated clusters per chamber;chamber ID;#Sigma(n_{clusters})", nCh, -0.5, nCh-0.5);
1017   Add2ESDsList(hESDnTotClustersPerCh, kESDnTotClustersPerCh, expert, !image);
1018   TH1F* hESDnTotClustersPerDE = new TH1F("hESDnTotClustersPerDE", "total number of associated clusters per DE;DetElem ID;#Sigma(n_{clusters})", nDE+1, -0.5, nDE+0.5);
1019   Add2ESDsList(hESDnTotClustersPerDE, kESDnTotClustersPerDE, expert, !image);
1020   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);
1021   Add2ESDsList(hESDnTotFullClustersPerDE, kESDnTotFullClustersPerDE, expert, !image);
1022   TH1F* hESDSumClusterChargePerDE = new TH1F("hESDSumClusterChargePerDE", "sum of cluster charge per DE;DetElem ID;#Sigma(charge) (fC)", nDE+1, -0.5, nDE+0.5);
1023   Add2ESDsList(hESDSumClusterChargePerDE, kESDSumClusterChargePerDE, expert, !image);
1024   TH1F* hESDSumClusterSizePerDE = new TH1F("hESDSumClusterSizePerDE", "sum of cluster size per DE;DetElem ID;#Sigma(size) (n_{pads})", nDE+1, -0.5, nDE+0.5);
1025   Add2ESDsList(hESDSumClusterSizePerDE, kESDSumClusterSizePerDE, expert, !image);
1026   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);
1027   Add2ESDsList(hESDSumResidualXPerDE, kESDSumResidualXPerDE, expert, !image);
1028   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);
1029   Add2ESDsList(hESDSumResidualYPerDE, kESDSumResidualYPerDE, expert, !image);
1030   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);
1031   Add2ESDsList(hESDSumResidualX2PerDE, kESDSumResidualX2PerDE, expert, !image);
1032   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);
1033   Add2ESDsList(hESDSumResidualY2PerDE, kESDSumResidualY2PerDE, expert, !image);
1034   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);
1035   Add2ESDsList(hESDSumLocalChi2XPerDE, kESDSumLocalChi2XPerDE, expert, !image);
1036   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);
1037   Add2ESDsList(hESDSumLocalChi2YPerDE, kESDSumLocalChi2YPerDE, expert, !image);
1038   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);
1039   Add2ESDsList(hESDSumLocalChi2PerDE, kESDSumLocalChi2PerDE, expert, !image);
1040 }
1041
1042 //____________________________________________________________________________
1043 void AliMUONQADataMakerRec::MakeRaws(AliRawReader* rawReader)
1044 {
1045     /// make QA for rawdata
1046
1047     // Check id histograms already created for this Event Specie
1048
1049   AliDebug(AliQAv1::GetQADebugLevel(),
1050            Form("RAW event type %s", AliRawEventHeaderBase::GetTypeName(rawReader->GetType())));
1051   
1052   if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ) 
1053   {
1054     rawReader->Reset();
1055     MakeRawsTracker(rawReader);
1056   }
1057   
1058   if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ||
1059        rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent ) 
1060   {
1061     rawReader->Reset();    
1062     MakeRawsTrigger(rawReader);
1063   }
1064 }
1065
1066 //____________________________________________________________________________
1067 void AliMUONQADataMakerRec::MakeRawsTracker(AliRawReader* rawReader)
1068 {
1069         /// make QA for rawdata tracker
1070         
1071   /// forces init
1072   GetRawsData(kTrackerBusPatchOccupancy);
1073   
1074         ((AliMUONTrackerDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader);
1075         
1076         fTrackerDataMaker->ProcessEvent();
1077 }
1078
1079 //____________________________________________________________________________
1080 void AliMUONQADataMakerRec::MakeRawsTrigger(AliRawReader* rawReader)
1081 {
1082         /// make QA for rawdata trigger
1083         
1084     // Get trigger scalers
1085
1086     Int_t loCircuit=0;
1087     AliMpCDB::LoadDDLStore();
1088
1089     AliMUONRawStreamTrigger rawStreamTrig(rawReader);
1090     while (rawStreamTrig.NextDDL()) 
1091     {
1092       // If not a scaler event, do nothing
1093       Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
1094       if ( !scalerEvent ) continue;
1095
1096       AliDebug(AliQAv1::GetQADebugLevel(),"Filling trigger scalers");
1097
1098       AliMUONDDLTrigger* ddlTrigger = rawStreamTrig.GetDDLTrigger();
1099       AliMUONDarcHeader* darcHeader = ddlTrigger->GetDarcHeader();
1100
1101       if (darcHeader->GetGlobalFlag()){
1102         UInt_t nOfClocks = darcHeader->GetGlobalClock();
1103         Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
1104         ((TH1F*)GetRawsData(kTriggerScalersTime))->Fill(1., nOfSeconds);
1105       }
1106
1107       Int_t nReg = darcHeader->GetRegHeaderEntries();
1108     
1109       for(Int_t iReg = 0; iReg < nReg ;iReg++)
1110       {   //reg loop
1111
1112         // crate info  
1113         AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
1114           GetTriggerCrate(rawStreamTrig.GetDDL(), iReg);
1115
1116         AliMUONRegHeader* regHeader =  darcHeader->GetRegHeaderEntry(iReg);
1117
1118         // loop over local structures
1119         Int_t nLocal = regHeader->GetLocalEntries();
1120         for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
1121         {
1122           AliMUONLocalStruct* localStruct = regHeader->GetLocalEntry(iLocal);
1123         
1124           // if card exist
1125           if (!localStruct) continue;
1126           
1127           loCircuit = crate->GetLocalBoardId(localStruct->GetId());
1128
1129           if ( !loCircuit ) continue; // empty slot
1130
1131           AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
1132
1133           // skip copy cards
1134           if( !localBoard->IsNotified()) 
1135             continue;
1136
1137           Int_t cathode = localStruct->GetComptXY()%2;
1138
1139           // loop over strips
1140           for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
1141             if(localStruct->GetXY1(ibitxy) > 0)
1142               ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 0))
1143                 ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY1(ibitxy));
1144             if(localStruct->GetXY2(ibitxy) > 0)
1145               ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 1))
1146                 ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY2(ibitxy));
1147             if(localStruct->GetXY3(ibitxy) > 0)
1148               ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 2))
1149                 ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY3(ibitxy));
1150             if(localStruct->GetXY4(ibitxy) > 0)
1151               ((TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + 3))
1152                 ->Fill(loCircuit, ibitxy, 2*localStruct->GetXY4(ibitxy));
1153           } // loop on strips
1154         } // iLocal
1155       } // iReg
1156     } // NextDDL
1157 }
1158
1159 //__________________________________________________________________
1160 void AliMUONQADataMakerRec::MakeDigits(TTree* digitsTree)         
1161 {
1162   /// makes data from Digits
1163
1164   // Do nothing in case of calibration event
1165   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1166
1167   if (!fDigitStore)
1168     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
1169   fDigitStore->Connect(*digitsTree, false);
1170   digitsTree->GetEvent(0);
1171   
1172   TIter next(fDigitStore->CreateIterator());
1173   
1174   AliMUONVDigit* dig = 0x0;
1175   
1176   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
1177     {
1178     GetDigitsData(0)->Fill(dig->DetElemId());
1179     GetDigitsData(1)->Fill(dig->ADC());
1180     }
1181 }
1182
1183 //____________________________________________________________________________
1184 void AliMUONQADataMakerRec::MakeRecPoints(TTree* clustersTree)
1185 {
1186         /// Fill histograms from treeR
1187
1188   // Do nothing in case of calibration event
1189   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1190         
1191   GetRecPointsData(kNAnalyzedEvents)->Fill(1.);
1192
1193   MakeRecPointsTracker(clustersTree);
1194         MakeRecPointsTrigger(clustersTree);
1195 }
1196
1197 //____________________________________________________________________________
1198 void AliMUONQADataMakerRec::MakeRecPointsTracker(TTree* clustersTree)
1199 {
1200         /// Fill histograms related to tracker clusters 
1201         
1202         // First things first : do we have clusters in the TreeR ?
1203         // In "normal" production mode, it should be perfectly normal
1204         // *not* to have them.
1205         // But if for some reason we de-activated the combined tracking,
1206         // then we have clusters in TreeR, so let's take that opportunity
1207         // to QA them...
1208         
1209         if (!fClusterStore)
1210         {
1211                 AliCodeTimerAuto("ClusterStore creation");
1212                 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
1213                 if (!fClusterStore) 
1214                 {
1215                         return;
1216                 }
1217         }
1218         
1219         AliCodeTimerAuto("");
1220         
1221         fClusterStore->Connect(*clustersTree,kFALSE);
1222         clustersTree->GetEvent(0);
1223
1224         TIter next(fClusterStore->CreateIterator());
1225         AliMUONVCluster* cluster;
1226         
1227         while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
1228         {
1229                 Int_t detElemId = cluster->GetDetElemId();
1230                 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1231                 
1232                 GetRecPointsData(kTrackerNumberOfClustersPerDE)->Fill(detElemId);
1233                 GetRecPointsData(kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
1234                 GetRecPointsData(kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
1235
1236                 GetRecPointsData(kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
1237                 GetRecPointsData(kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
1238                 GetRecPointsData(kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
1239                 GetRecPointsData(kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
1240                 
1241         }
1242         
1243         fClusterStore->Clear();
1244 }
1245
1246 //____________________________________________________________________________
1247 void AliMUONQADataMakerRec::MakeRecPointsTrigger(TTree* clustersTree)
1248 {
1249         /// makes data from trigger response
1250       
1251     // Fired pads info
1252     fDigitStore->Clear();
1253
1254     if (!fTriggerStore) fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
1255     fTriggerStore->Clear();
1256     fTriggerStore->Connect(*clustersTree, false);
1257     clustersTree->GetEvent(0);
1258
1259     AliMUONLocalTrigger* locTrg;
1260     TIter nextLoc(fTriggerStore->CreateLocalIterator());
1261
1262     while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(nextLoc()) ) ) 
1263     {
1264       if (locTrg->IsNull()) continue;
1265    
1266       TArrayS xyPattern[2];
1267       locTrg->GetXPattern(xyPattern[0]);
1268       locTrg->GetYPattern(xyPattern[1]);
1269
1270       Int_t nBoard = locTrg->LoCircuit();
1271
1272       Bool_t xTrig=locTrg->IsTrigX();
1273       Bool_t yTrig=locTrg->IsTrigY();
1274     
1275       if (xTrig && yTrig)
1276         ((TH1F*)GetRecPointsData(kTriggeredBoards))->Fill(nBoard);
1277
1278       fDigitMaker->TriggerDigits(nBoard, xyPattern, *fDigitStore);
1279     }
1280
1281     TIter nextDigit(fDigitStore->CreateIterator());
1282     AliMUONVDigit* mDigit;
1283     while ( ( mDigit = static_cast<AliMUONVDigit*>(nextDigit()) ) )
1284     {
1285       Int_t detElemId = mDigit->DetElemId();
1286       Int_t ch = detElemId/100;
1287       Int_t localBoard = mDigit->ManuId();
1288       Int_t channel = mDigit->ManuChannel();
1289       Int_t cathode = mDigit->Cathode();
1290       Int_t iChamber = ch - 11;
1291       
1292       ((TH2F*)GetRecPointsData(kTriggerDigits + AliMpConstants::NofTriggerChambers()*cathode + iChamber))
1293         ->Fill(localBoard, channel);
1294     }
1295 }
1296
1297 //____________________________________________________________________________
1298 void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
1299 {
1300   /// make QA data from ESDs
1301
1302   // Do nothing in case of calibration event
1303   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
1304   
1305   // load ESD event in the interface
1306   AliMUONESDInterface esdInterface;
1307   if (GetMUONRecoParam()) AliMUONESDInterface::ResetTracker(GetMUONRecoParam());
1308   else AliError("Unable to get recoParam: use default ones for residual calculation");
1309   esdInterface.LoadEvent(*esd);
1310   
1311   GetESDsData(kESDnTracks)->Fill(esdInterface.GetNTracks());
1312   
1313   Int_t nTrackMatchTrig = 0;
1314   
1315   // loop over tracks
1316   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
1317   for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
1318     
1319     // get the ESD track and skip "ghosts"
1320     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
1321     if (!esdTrack->ContainTrackerData()) continue;
1322     
1323     // get corresponding MUON track
1324     AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
1325     
1326     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
1327     
1328     GetESDsData(kESDMomentum)->Fill(esdTrack->P());
1329     GetESDsData(kESDPt)->Fill(esdTrack->Pt());
1330     GetESDsData(kESDRapidity)->Fill(esdTrack->Y());
1331     GetESDsData(kESDChi2)->Fill(track->GetNormalizedChi2());
1332     GetESDsData(kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
1333     GetESDsData(kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
1334     GetESDsData(kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
1335     GetESDsData(kESDnClustersPerTrack)->Fill(track->GetNClusters());
1336     
1337     // loop over clusters
1338     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
1339     while (trackParam) {
1340       
1341       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
1342       Int_t chId = cluster->GetChamberId();
1343       Int_t deID = cluster->GetDetElemId();
1344       Double_t residualX = cluster->GetX() - trackParam->GetNonBendingCoor();
1345       Double_t residualY = cluster->GetY() - trackParam->GetBendingCoor();
1346       Double_t sigmaResidualX2 = cluster->GetErrX2() - trackParam->GetCovariances()(0,0);
1347       Double_t sigmaResidualY2 = cluster->GetErrY2() - trackParam->GetCovariances()(2,2);
1348       Double_t localChi2X = (sigmaResidualX2 > 0.) ? residualX*residualX/sigmaResidualX2 : 0.;
1349       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
1350       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
1351       
1352       GetESDsData(kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
1353       
1354       GetESDsData(kESDnTotClustersPerCh)->Fill(chId);
1355       GetESDsData(kESDnTotClustersPerDE)->Fill(deID);
1356       
1357       GetESDsData(kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
1358       GetESDsData(kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
1359       
1360       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
1361         GetESDsData(kESDnTotFullClustersPerDE)->Fill(deID);
1362         GetESDsData(kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
1363         GetESDsData(kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
1364       }
1365       
1366       GetESDsData(kESDResidualXInCh+chId)->Fill(residualX);
1367       GetESDsData(kESDResidualYInCh+chId)->Fill(residualY);
1368       GetESDsData(kESDSumResidualXPerDE)->Fill(deID, residualX);
1369       GetESDsData(kESDSumResidualYPerDE)->Fill(deID, residualY);
1370       GetESDsData(kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
1371       GetESDsData(kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
1372       
1373       GetESDsData(kESDLocalChi2XInCh+chId)->Fill(localChi2X);
1374       GetESDsData(kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
1375       GetESDsData(kESDLocalChi2InCh+chId)->Fill(localChi2);
1376       GetESDsData(kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
1377       GetESDsData(kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
1378       GetESDsData(kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
1379       
1380       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
1381     }
1382     
1383   }
1384   
1385   GetESDsData(kESDMatchTrig)->Fill(nTrackMatchTrig);
1386   
1387 }
1388
1389 //____________________________________________________________________________ 
1390 void AliMUONQADataMakerRec::StartOfDetectorCycle()
1391 {
1392     /// Detector specific actions at start of cycle
1393   
1394 }
1395
1396 //____________________________________________________________________________ 
1397 void AliMUONQADataMakerRec::DisplayTriggerInfo(AliQAv1::TASKINDEX_t task)
1398 {
1399   //
1400   /// Display trigger information in a user-friendly way:
1401   /// from local board and strip numbers to their position on chambers
1402   //
1403   
1404
1405   if(task!=AliQAv1::kRECPOINTS && task!=AliQAv1::kRAWS) return;
1406
1407   // check we get histograms, otherwise return right now
1408   if ( task == AliQAv1::kRECPOINTS )
1409   {
1410     if ( !GetRecPointsData(kTriggerDigits) ) return;
1411   }
1412   
1413   if ( task == AliQAv1::kRAWS ) 
1414   {
1415     if ( !GetRawsData(kTriggerScalers) ) return;
1416   }
1417   
1418   AliMUONTriggerDisplay triggerDisplay;
1419   
1420   TH2F* histoStrips=0x0;
1421   TH2F* histoDisplayStrips=0x0;
1422   AliMUONTriggerDisplay::EDisplayOption displayOption = AliMUONTriggerDisplay::kDefaultDisplay;
1423   if(task == AliQAv1::kRAWS) displayOption = AliMUONTriggerDisplay::kNormalizeToArea;
1424
1425   for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
1426   {    
1427     for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
1428     {
1429       if(task==AliQAv1::kRECPOINTS){
1430         histoStrips = (TH2F*)GetRecPointsData(kTriggerDigits + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1431       }
1432       else if(task==AliQAv1::kRAWS){
1433         histoStrips = (TH2F*)GetRawsData(kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1434       }
1435
1436       if(histoStrips->GetEntries()==0) continue; // No events found => No need to display
1437
1438       if(task==AliQAv1::kRECPOINTS){
1439         histoDisplayStrips = (TH2F*)GetRecPointsData(kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1440       }
1441       else if(task==AliQAv1::kRAWS){
1442         histoDisplayStrips = (TH2F*)GetRawsData(kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
1443       }
1444
1445       triggerDisplay.FillDisplayHistogram(histoStrips, histoDisplayStrips,
1446                                           AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber, displayOption);
1447
1448       Float_t scaleValue = 0.;
1449       if(task==AliQAv1::kRAWS) {
1450         scaleValue = ((TH1F*)GetRawsData(kTriggerScalersTime))->GetBinContent(1);
1451       }
1452       else if ( task == AliQAv1::kRECPOINTS ) {
1453         scaleValue = GetRecPointsData(kNAnalyzedEvents)->GetBinContent(1);
1454       }
1455       if(scaleValue>0.) histoDisplayStrips->Scale(1./scaleValue);
1456     } // iChamber
1457   } // iCath
1458
1459   if(task==AliQAv1::kRECPOINTS){
1460     TH1F* histoBoards = (TH1F*)GetRecPointsData(kTriggeredBoards);
1461     TH2F* histoDisplayBoards = (TH2F*)GetRecPointsData(kTriggerBoardsDisplay);
1462     triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
1463     Float_t scaleValue = GetRecPointsData(kNAnalyzedEvents)->GetBinContent(1);
1464     if(scaleValue>0.) histoDisplayBoards->Scale(1./scaleValue);
1465   }
1466 }
1467
1468
1469 //_____________________________________________________________________________
1470 Bool_t 
1471 AliMUONQADataMakerRec::FillTriggerDCSHistos()
1472 {
1473   /// Get HV and currents values for one trigger chamber
1474   
1475   AliCodeTimerAuto("");
1476
1477   AliMUONCalibrationData calibrationData(AliCDBManager::Instance()->GetRun());
1478
1479   TMap* triggerDcsMap = calibrationData.TriggerDCS();
1480
1481   if ( !triggerDcsMap ) 
1482   {
1483     AliError("Cannot fill DCS histos, as triggerDcsMap is NULL");
1484     return kFALSE;
1485   }
1486
1487   AliMpDEIterator deIt;
1488   
1489   deIt.First();
1490     
1491   AliMpDCSNamer triggerDcsNamer("TRIGGER");
1492
1493   TH2* currHisto = 0x0;
1494   Int_t histoIndex = 0;
1495   TString histoName, histoTitle;
1496
1497   Bool_t error = kFALSE;
1498   Bool_t expert   = kTRUE;
1499   Bool_t saveCorr = kTRUE;
1500   Bool_t image    = kTRUE;
1501   
1502   while ( !deIt.IsDone() )
1503   {
1504     Int_t detElemId = deIt.CurrentDEId();
1505     
1506     if ( AliMpDEManager::GetStationType(detElemId) == AliMp::kStationTrigger) {
1507
1508       Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
1509       Int_t slat = detElemId%100;
1510
1511       for(Int_t iMeas=0; iMeas<AliMpDCSNamer::kNDCSMeas; iMeas++){
1512         TString currAlias = triggerDcsNamer.DCSChannelName(detElemId, 0, iMeas);
1513
1514         AliDebug(AliQAv1::GetQADebugLevel(), Form("\nDetElemId %i   dcsAlias %s", detElemId, currAlias.Data()));
1515
1516         TPair* triggerDcsPair = static_cast<TPair*>(triggerDcsMap->FindObject(currAlias.Data()));
1517
1518         if (!triggerDcsPair)
1519         {
1520           AliError(Form("Did not find expected alias (%s) for DE %d",
1521                         currAlias.Data(),detElemId));  
1522           error = kTRUE;
1523         }
1524         else
1525         {
1526           TObjArray* values = static_cast<TObjArray*>(triggerDcsPair->Value());
1527           if (!values)
1528           {
1529             AliError(Form("Could not get values for alias %s",currAlias.Data()));
1530             error = kTRUE;
1531           }
1532           else
1533           {
1534             TIter next(values);
1535             AliDCSValue* val = 0x0;
1536
1537             Int_t ich = iChamber - AliMpConstants::NofTrackingChambers();
1538
1539             switch(iMeas){
1540             case AliMpDCSNamer::kDCSI:
1541               histoIndex = kTriggerRPCi + ich;
1542               histoName = Form("hRPCIChamber%i", 11+ich);
1543               histoTitle = Form("Chamber %i: RPC Currents (#muA)", 11+ich);
1544               break;
1545             case AliMpDCSNamer::kDCSHV:
1546               histoIndex = kTriggerRPChv + ich;
1547               histoName = Form("hRPCHVChamber%i", 11+ich);
1548               histoTitle = Form("Chamber %i: RPC HV (V)", 11+ich);
1549               break;
1550             }
1551
1552             currHisto = (TH2F*) GetRawsData(histoIndex);
1553
1554             if(!currHisto){
1555               Int_t npoints = values->GetEntries();
1556               TArrayF axisSlat(18+1), axisTime(npoints+1);
1557               for(Int_t islat=0; islat<=18; islat++){
1558                 axisSlat[islat] = -0.5 + (Float_t)islat;
1559               }
1560               for(Int_t ientry=0; ientry<npoints; ientry++){
1561                 val = static_cast<AliDCSValue*>(values->At(ientry));
1562                 axisTime[ientry] = val->GetTimeStamp();
1563               }
1564               axisTime[npoints] = val->GetTimeStamp() + 100;
1565
1566               currHisto  = new TH2F(histoName.Data(), histoTitle.Data(),
1567                                     npoints, axisTime.GetArray(),
1568                                     18, axisSlat.GetArray());
1569               currHisto->GetXaxis()->SetTitle("Time");
1570               currHisto->GetXaxis()->SetTimeDisplay(1);
1571               //currHisto->GetXaxis()->SetTimeFormat("%d%b%y %H:%M:%S");
1572               currHisto->GetYaxis()->SetTitle("RPC");
1573               Add2RawsList(currHisto, histoIndex, !expert, image, !saveCorr);
1574             }
1575
1576             while ( ( val = static_cast<AliDCSValue*>(next()) ) )
1577             {
1578               Float_t hvi = val->GetFloat();
1579
1580               AliDebug(AliQAv1::GetQADebugLevel(), Form("Value %f", hvi));
1581  
1582               currHisto->Fill(1.0001 * val->GetTimeStamp(), slat, hvi);
1583             } // loop on values
1584           } // if (!values)
1585         } // if (!triggerDcsPair)
1586       } // loop on measured types (HV and currents)
1587     } // if (stationType == kStationTrigger)
1588
1589     deIt.Next();
1590   }
1591   return error;
1592 }
1593
1594 //____________________________________________________________________________ 
1595 AliMUONVTrackerData* AliMUONQADataMakerRec::GetTrackerData() const
1596
1597 /// Return tracker data
1598   
1599   return fTrackerDataMaker->Data(); 
1600   
1601 }
1602
1603 //____________________________________________________________________________ 
1604 void
1605 AliMUONQADataMakerRec::BeautifyTrackerBusPatchOccupancy(TH1& hbp)
1606 {
1607   /// Put labels, limits and so on on the TrackerBusPatchOccupancy histogram
1608   
1609   hbp.SetXTitle("Absolute Bus Patch Id");
1610   hbp.SetYTitle("Occupancy (percent)");
1611   hbp.SetStats(kFALSE);
1612   
1613   Double_t xmin = hbp.GetXaxis()->GetXmin();
1614   Double_t xmax = hbp.GetXaxis()->GetXmax();
1615   
1616   Double_t occMax(0.1); // 0.1% y-limit for the plot
1617   Double_t occError(1.0); // 1.0% y-limit to count the "errors"
1618   
1619   TLine* line = new TLine(xmin,occError,xmax,occError);
1620   line->SetLineColor(2);
1621   line->SetLineWidth(3);
1622   
1623   hbp.GetListOfFunctions()->Add(line);
1624   
1625   TH1* hnpads = GetRawsData(kTrackerBusPatchNofPads);
1626   hnpads->SetStats(kFALSE);
1627   TH1* hnmanus = GetRawsData(kTrackerBusPatchNofManus);
1628   hnmanus->SetStats(kFALSE);
1629   
1630   TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1631   AliMpBusPatch* bp(0x0);
1632   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
1633   {
1634     Int_t n(0);
1635     for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
1636     {
1637       Int_t manuId = bp->GetManuId(imanu);
1638       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(bp->GetDEId());      
1639       n += de->NofChannelsInManu(manuId);
1640     }
1641     hnpads->Fill(bp->GetId(),n*1.0);
1642     hnmanus->Fill(bp->GetId(),bp->GetNofManus()*1.0);
1643   }
1644   
1645   next.Reset();
1646   
1647   Int_t nMissingPads(0);
1648   Int_t nPads(0);
1649   Int_t nBusPatches(0);
1650   Int_t nMissingBusPatches(0);
1651
1652   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
1653   {
1654     Int_t bin = hbp.FindBin(bp->GetId());
1655     Int_t n = hnpads->GetBinContent(bin);
1656     
1657     ++nBusPatches;
1658
1659     nPads += n;
1660     
1661     if ( hbp.GetBinContent(bin) <= 0 ) 
1662     {
1663       nMissingPads += n;
1664       ++nMissingBusPatches;
1665     }
1666   }
1667
1668   next.Reset();
1669   
1670   Double_t* x = new Double_t[nBusPatches];
1671   Int_t n(0);
1672   Int_t nBusPatchesAboveLimit(0);
1673   
1674   while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
1675   {
1676     Int_t bin = hbp.FindBin(bp->GetId());
1677     if ( hbp.GetBinContent(bin) > 0 )
1678     {
1679       x[n] = hbp.GetBinContent(bin);
1680       ++n;
1681     }
1682     if ( hbp.GetBinContent(bin) > occError )
1683     {
1684       ++nBusPatchesAboveLimit;
1685     }
1686   }
1687   
1688   Double_t alpha(0.1); // trim 10% of data
1689   Double_t tmean,tvar;
1690   Double_t ymin,ymax;
1691   
1692   // computed the truncated mean of the occupancy values, in order to get a 
1693   // reasonable y-range for the histogram (without giant peaks to the roof 
1694   // for misbehaving buspatches).
1695   Int_t ok = trim(nBusPatches,x,alpha,tmean,tvar,ymin,ymax);
1696   
1697   if ( ok < 0 ) 
1698   {
1699     ymax = occMax;
1700   }
1701   else
1702   {
1703     ymax = TMath::Max(ymax,occMax);
1704   }
1705   
1706   hbp.SetMaximum(ymax*1.4);
1707   
1708   TPaveText* text = new TPaveText(0.55,0.85,0.99,0.99,"NDC");
1709   
1710   if (ok < 0 ) 
1711   {
1712     text->AddText("Could not compute truncated mean. Not enough events ?");
1713     text->SetFillColor(2);
1714   }
1715   else if (!nPads || !nBusPatches)
1716   {
1717     text->AddText("Could not get the total number of pads. ERROR !!!");
1718     text->SetFillColor(2);
1719   }
1720   else
1721   {
1722     Float_t missingPadFraction = nMissingPads*100.0/nPads;
1723     Float_t missingBusPatchFraction = nMissingBusPatches*100.0/nBusPatches;
1724     Float_t aboveLimitFraction = nBusPatchesAboveLimit*100.0/nBusPatches;
1725     
1726     text->AddText(Form("%5.2f %% of missing buspatches (%d out of %d)",missingBusPatchFraction,nMissingBusPatches,nBusPatches));
1727     text->AddText(Form("%5.2f %% of missing pads (%d out of %d)",missingPadFraction,nMissingPads,nPads));
1728     text->AddText(Form("%5.2f %% bus patches above the %5.2f %% limit",aboveLimitFraction,occError));
1729     text->AddText(Form("Truncated mean at %2d %% is %7.2f %%",(Int_t)(alpha*100),tmean));
1730     
1731     if ( missingPadFraction > 10.0 || aboveLimitFraction > 5.0 ) 
1732     {
1733       text->SetFillColor(2);
1734     }
1735     else
1736     {
1737       text->SetFillColor(3);
1738     }
1739   }
1740   
1741   hbp.GetListOfFunctions()->Add(text);
1742 }
1743