]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALQADataMakerRec.cxx
Updated checking and display for AMORE (Yves)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQADataMakerRec.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 Based on the QA code for PHOS written by Yves Schutz July 2007
17
18 Authors:  J.Klay (Cal Poly) May 2008
19           S. Salur LBL April 2008
20  
21 Created one histogram for QA shifter;-- Yaxian Mao: 11/2009
22 The idea:average counts for all the towers should be flat 
23 Change all existing histograms as experts
24
25 Change histograms for DQM shifter: --  Yaxian Mao 04/2010
26 Calcuate the amplitude ratio from current run and the LED reference, for QAChecker use
27 Also calculate the ratio of amplitude from LED Monitor system (current/Reference), to check LED system  
28  
29 */
30
31 // --- ROOT system ---
32 #include <TClonesArray.h>
33 #include <TFile.h> 
34 #include <TH1F.h> 
35 #include <TH1I.h> 
36 #include <TH2F.h> 
37 #include <TLine.h>
38 #include <TText.h>
39 #include <TProfile.h> 
40 #include <TStyle.h>
41 // --- Standard library ---
42
43
44 // --- AliRoot header files ---
45 #include "AliDAQ.h"
46 #include "AliESDCaloCluster.h"
47 #include "AliESDCaloCells.h"
48 #include "AliESDEvent.h"
49 #include "AliLog.h"
50 #include "AliEMCALQADataMakerRec.h"
51 #include "AliQAChecker.h"
52 #include "AliEMCALDigit.h" 
53 #include "AliEMCALRecPoint.h" 
54 #include "AliEMCALRawUtils.h"
55 #include "AliEMCALReconstructor.h"
56 #include "AliEMCALRecParam.h"
57 #include "AliRawReader.h"
58 #include "AliCaloRawStreamV3.h"
59 #include "AliEMCALGeoParams.h"
60 #include "AliRawEventHeaderBase.h"
61 #include "AliQAManager.h"
62 #include "AliCDBEntry.h"
63
64 #include "AliCaloBunchInfo.h"
65 #include "AliCaloFitResults.h"
66 #include "AliCaloRawAnalyzerFastFit.h"
67 #include "AliCaloRawAnalyzerNN.h"
68 #include "AliCaloRawAnalyzerLMS.h"
69 #include "AliCaloRawAnalyzerPeakFinder.h"
70 #include "AliCaloRawAnalyzerCrude.h"
71
72 using namespace std;
73
74 ClassImp(AliEMCALQADataMakerRec)
75            
76 //____________________________________________________________________________ 
77 AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(fitAlgorithm fitAlgo) : 
78   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"),
79   fFittingAlgorithm(0),
80   fRawAnalyzer(0),
81   fRawAnalyzerTRU(0),
82   fSuperModules(4), // FIXME!!! number of SuperModules; 4 for 2009; update default to 12 for later runs..
83   fFirstPedestalSample(0),
84   fLastPedestalSample(3),
85   fFirstPedestalSampleTRU(0),
86   fLastPedestalSampleTRU(3),
87   fMinSignalLG(0),
88   fMaxSignalLG(AliEMCALGeoParams::fgkSampleMax),
89   fMinSignalHG(0),
90   fMaxSignalHG(AliEMCALGeoParams::fgkSampleMax),
91   fMinSignalTRU(0),
92   fMaxSignalTRU(AliEMCALGeoParams::fgkSampleMax),
93   fMinSignalLGLEDMon(0),
94   fMaxSignalLGLEDMon(AliEMCALGeoParams::fgkSampleMax),
95   fMinSignalHGLEDMon(0),
96   fMaxSignalHGLEDMon(AliEMCALGeoParams::fgkSampleMax),
97   fCalibRefHistoPro(NULL),
98   fCalibRefHistoH2F(NULL),
99   fLEDMonRefHistoPro(NULL),
100   fHighEmcHistoH2F(NULL)
101 //  fTextSM(new TText*[fSuperModules]) ,
102 //  fLineCol(NULL),
103 //  fLineRow(NULL)
104
105 {
106   // ctor
107   SetFittingAlgorithm(fitAlgo);
108   fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS();
109   fRawAnalyzerTRU->SetFixTau(kTRUE); 
110   fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper
111 //  for (Int_t sm = 0 ; sm < fSuperModules ; sm++){
112 //    fTextSM[sm] = NULL ;
113 //  }
114 }
115
116 //____________________________________________________________________________ 
117 AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qadm) :
118   AliQADataMakerRec(), 
119   fFittingAlgorithm(0),
120   fRawAnalyzer(0),
121   fRawAnalyzerTRU(0),
122   fSuperModules(qadm.GetSuperModules()), 
123   fFirstPedestalSample(qadm.GetFirstPedestalSample()), 
124   fLastPedestalSample(qadm.GetLastPedestalSample()),  
125   fFirstPedestalSampleTRU(qadm.GetFirstPedestalSampleTRU()), 
126   fLastPedestalSampleTRU(qadm.GetLastPedestalSampleTRU()),  
127   fMinSignalLG(qadm.GetMinSignalLG()),
128   fMaxSignalLG(qadm.GetMaxSignalLG()),
129   fMinSignalHG(qadm.GetMinSignalHG()),
130   fMaxSignalHG(qadm.GetMaxSignalHG()),
131   fMinSignalTRU(qadm.GetMinSignalTRU()),
132   fMaxSignalTRU(qadm.GetMaxSignalTRU()),
133   fMinSignalLGLEDMon(qadm.GetMinSignalLGLEDMon()),
134   fMaxSignalLGLEDMon(qadm.GetMaxSignalLGLEDMon()),
135   fMinSignalHGLEDMon(qadm.GetMinSignalHGLEDMon()),
136   fMaxSignalHGLEDMon(qadm.GetMaxSignalHGLEDMon()),
137   fCalibRefHistoPro(NULL),
138   fCalibRefHistoH2F(NULL),
139   fLEDMonRefHistoPro(NULL),
140   fHighEmcHistoH2F(NULL)
141 //  fTextSM(new TText*[fSuperModules]) ,
142 //  fLineCol(NULL),
143 //  fLineRow(NULL)
144 {
145   //copy ctor 
146   SetName((const char*)qadm.GetName()) ; 
147   SetTitle((const char*)qadm.GetTitle()); 
148   SetFittingAlgorithm(qadm.GetFittingAlgorithm());
149   fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS();
150   fRawAnalyzerTRU->SetFixTau(kTRUE); 
151   fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper
152 //  for (Int_t sm = 0 ; sm < fSuperModules ; sm++){
153 //    fTextSM[sm] = qadm.fTextSM[sm] ;
154 //  }  
155 }
156
157 //__________________________________________________________________
158 AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQADataMakerRec& qadm )
159 {
160   // Equal operator.
161   this->~AliEMCALQADataMakerRec();
162   new(this) AliEMCALQADataMakerRec(qadm);
163 //  fLineCol = NULL;
164 //  fLineRow = NULL;
165 //  for (Int_t sm = 0 ; sm < fSuperModules ; sm++){
166 //    fTextSM[sm] = qadm.fTextSM[sm] ;
167 //  }    
168   return *this;
169 }
170  
171 //____________________________________________________________________________ 
172 void AliEMCALQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
173 {
174   //Detector specific actions at end of cycle
175         
176 //  if(fCycleCounter)
177 //        GetRawsData(kNEventsPerTower)->Scale(1./fCycleCounter);
178
179   // do the QA checking
180   AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ;  
181 }
182
183 //____________________________________________________________________________ 
184 void AliEMCALQADataMakerRec::GetCalibRefFromOCDB()
185 {
186   //Get the reference histogram from OCDB
187   TString sName1("hHighEmcalRawMaxMinusMin") ;
188   TString sName2("hLowLEDMonEmcalRawMaxMinusMin") ;
189   sName1.Prepend(Form("%s_", AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib))) ; 
190   sName2.Prepend(Form("%s_", AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib))) ; 
191   
192   TString refStorage(AliQAv1::GetQARefStorage()) ;
193   if (!refStorage.Contains(AliQAv1::GetLabLocalOCDB()) && !refStorage.Contains(AliQAv1::GetLabAliEnOCDB())) {
194     AliFatal(Form("%s is not a valid location for reference data", refStorage.Data())) ; 
195   } else {
196     AliQAManager* manQA = AliQAManager::QAManager(AliQAv1::kRAWS) ;    
197     AliQAv1::SetQARefDataDirName(AliRecoParam::kCalib) ;
198     if ( ! manQA->GetLock() ) { 
199       manQA->SetDefaultStorage(AliQAv1::GetQARefStorage()) ; 
200       manQA->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
201       manQA->SetRun(AliCDBManager::Instance()->GetRun()) ; 
202       manQA->SetLock() ; 
203     }
204     char * detOCDBDir = Form("%s/%s/%s", GetName(), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ; 
205     AliCDBEntry * entry = manQA->Get(detOCDBDir, manQA->GetRun()) ;
206     if (entry) {
207       TList * listDetQAD =static_cast<TList *>(entry->GetObject()) ;
208       if ( strcmp(listDetQAD->ClassName(), "TList") != 0 ) {
209         AliError(Form("Expected a Tlist and found a %s for detector %s", listDetQAD->ClassName(), GetName())) ; 
210         listDetQAD = NULL ; 
211       }
212       TObjArray * dirOCDB= NULL ; 
213       if ( listDetQAD )
214         dirOCDB = static_cast<TObjArray *>(listDetQAD->FindObject(Form("%s/%s", AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib)))) ;       
215       if (dirOCDB){
216         fCalibRefHistoPro = dynamic_cast<TProfile *>(dirOCDB->FindObject(sName1.Data())) ; 
217         fLEDMonRefHistoPro = dynamic_cast<TProfile *>(dirOCDB->FindObject(sName2.Data())) ; 
218       }
219     }
220   }
221  
222   if(fCalibRefHistoPro && fLEDMonRefHistoPro){
223     
224     //Defining histograms binning, each 2D histogram covers all SMs
225     Int_t nSMSectors = fSuperModules / 2; // 2 SMs per sector
226     Int_t nbinsZ = 2*AliEMCALGeoParams::fgkEMCALCols;
227     Int_t nbinsPhi = nSMSectors * AliEMCALGeoParams::fgkEMCALRows;
228     
229     if(!fCalibRefHistoH2F)
230       fCalibRefHistoH2F =  new TH2F("hCalibRefHisto", "hCalibRefHisto", nbinsZ, -0.5, nbinsZ - 0.5, nbinsPhi, -0.5, nbinsPhi -0.5);
231     ConvertProfile2H(fCalibRefHistoPro,fCalibRefHistoH2F) ; 
232   } else {
233     AliFatal(Form("No reference object with name %s or %s found", sName1.Data(), sName2.Data())) ; 
234   }
235 }
236 //____________________________________________________________________________ 
237 void AliEMCALQADataMakerRec::InitESDs()
238 {
239   //Create histograms to controll ESD
240   const Bool_t expert   = kTRUE ; 
241   const Bool_t image    = kTRUE ; 
242   
243   TH1F * h1 = new TH1F("hESDCaloClusterE",  "ESDs CaloCluster energy in EMCAL;Energy [GeV];Counts",    200, 0., 100.) ; 
244   h1->Sumw2() ;
245   Add2ESDsList(h1, kESDCaloClusE, !expert, image)  ;                                                     
246
247   TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL;# of Clusters;Entries", 100, 0,  100) ; 
248   h2->Sumw2() ;
249   Add2ESDsList(h2, kESDCaloClusM, !expert, image)  ;
250
251   TH1F * h3 = new TH1F("hESDCaloCellA",  "ESDs CaloCell amplitude in EMCAL;Energy [GeV];Counts",    500, 0., 50.) ; 
252   h3->Sumw2() ;
253   Add2ESDsList(h3, kESDCaloCellA, !expert, image)  ;  
254  
255   TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL;# of Clusters;Entries", 200, 0,  1000) ; 
256   h4->Sumw2() ;
257   Add2ESDsList(h4, kESDCaloCellM, !expert, image) ;
258         
259 }
260
261 //____________________________________________________________________________ 
262 void AliEMCALQADataMakerRec::InitDigits()
263 {
264   // create Digits histograms in Digits subdir
265   const Bool_t expert   = kTRUE ; 
266   const Bool_t image    = kTRUE ; 
267   
268   TH1I * h0 = new TH1I("hEmcalDigits",    "Digits amplitude distribution in EMCAL;Amplitude [ADC counts];Counts",    500, 0, 500) ; 
269   h0->Sumw2() ;
270   Add2DigitsList(h0, 0, !expert, image) ;
271   TH1I * h1 = new TH1I("hEmcalDigitsMul", "Digits multiplicity distribution in EMCAL;# of Digits;Entries", 200, 0, 2000) ; 
272   h1->Sumw2() ;
273   Add2DigitsList(h1, 1, !expert, image) ;
274 }
275
276 //____________________________________________________________________________ 
277 void AliEMCALQADataMakerRec::InitRecPoints()
278 {
279   // create Reconstructed PoInt_ts histograms in RecPoints subdir
280   const Bool_t expert   = kTRUE ; 
281   const Bool_t image    = kTRUE ; 
282   
283   TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies;Energy [GeV];Counts",200, 0.,20.); //GeV
284   h0->Sumw2();
285   Add2RecPointsList(h0,kRecPE, !expert, image);
286
287   TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities;# of Clusters;Entries",100,0,100);
288   h1->Sumw2();
289   Add2RecPointsList(h1,kRecPM, !expert, image);
290
291   TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities;# of Digits;Entries",20,0,20);
292   h2->Sumw2();
293   Add2RecPointsList(h2,kRecPDigM, !expert, image);
294
295 }
296
297 //____________________________________________________________________________ 
298 void AliEMCALQADataMakerRec::InitRaws()
299 {
300   // create Raws histograms in Raws subdir
301    const Bool_t expert   = kTRUE ; 
302    const Bool_t saveCorr = kTRUE ; 
303    const Bool_t image    = kTRUE ; 
304
305   Int_t nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48
306   Int_t nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules
307   
308   
309         //Defining histograms binning, each 2D histogram covers all SMs
310         Int_t nSMSectors = fSuperModules / 2; // 2 SMs per sector
311         Int_t nbinsZ = 2*AliEMCALGeoParams::fgkEMCALCols;
312         Int_t nbinsPhi = nSMSectors * AliEMCALGeoParams::fgkEMCALRows;
313    
314    // counter info: number of channels per event (bins are SM index)
315   TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod;SM Id;# of towers",
316                                fSuperModules, -0.5, fSuperModules-0.5) ;
317   Add2RawsList(h0, kNsmodLG, expert, image, !saveCorr) ;
318   TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod;SM Id;# of towers",  
319                                fSuperModules, -0.5, fSuperModules-0.5) ; 
320   Add2RawsList(h1, kNsmodHG, expert, image, !saveCorr) ;
321
322   // where did max sample occur? (bins are towers)
323   TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", 
324                                nTot, -0.5, nTot-0.5) ;
325   Add2RawsList(h2, kTimeLG, expert, image, !saveCorr) ;
326   TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", 
327                                nTot, -0.5, nTot-0.5) ;
328   Add2RawsList(h3, kTimeHG, expert, image, !saveCorr) ;
329
330   // how much above pedestal was the max sample?  (bins are towers)
331   TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]", 
332                                nTot, -0.5, nTot-0.5) ;
333   Add2RawsList(h4, kSigLG, expert, image, !saveCorr) ;
334   TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]",
335                                nTot, -0.5, nTot-0.5) ;
336   Add2RawsList(h5, kSigHG, expert, image, !saveCorr) ;
337
338   // total counter: channels per event
339   TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers;# of Towers;Counts", 200, 0, nTot) ;
340   h6->Sumw2() ;
341   Add2RawsList(h6, kNtotLG, expert, image, !saveCorr) ;
342   TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers;# of Towers;Counts", 200,0, nTot) ;
343   h7->Sumw2() ;
344   Add2RawsList(h7, kNtotHG, expert, image, !saveCorr) ;
345
346   // pedestal (bins are towers)
347   TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]", 
348                                nTot, -0.5, nTot-0.5) ;
349   Add2RawsList(h8, kPedLG, expert, image, !saveCorr) ;
350   TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]",
351                                nTot, -0.5, nTot-0.5) ;
352   Add2RawsList(h9, kPedHG, expert, image, !saveCorr) ;
353         
354  //number of events per tower, for shifter fast check   
355   TH1I * h12 = new TH1I("hTowerHG", "High Gains on the Tower;Tower", nTot,0, nTot) ;
356   h12->Sumw2() ;
357   Add2RawsList(h12, kTowerHG, !expert, image, !saveCorr) ;
358   TH1I * h13 = new TH1I("hTowerLG", "Low Gains on the Tower;Tower", nTot,0, nTot) ;
359   h13->Sumw2() ;
360   Add2RawsList(h13, kTowerLG, !expert, image, !saveCorr) ;              
361  
362   //temp 2D amplitude histogram for the current run
363   fHighEmcHistoH2F = new TH2F("h2DHighEC2", "High Gain EMC:Max - Min [ADC counts]", nbinsZ, -0.5 , nbinsZ-0.5, nbinsPhi, -0.5, nbinsPhi-0.5);
364
365   //add ratio histograms: to comapre the current run with the reference data 
366   TH2F * h15 = new TH2F("h2DRatioAmp", "High Gain Ratio to Reference:Amplitude_{current run}/Amplitude_{reference run}", nbinsZ, -0.5 , nbinsZ-0.5, 
367                         nbinsPhi, -0.5, nbinsPhi-0.5);
368   //settings for display in amore
369   h15->SetTitle("Amplitude_{current run}/Amplitude_{reference run}"); 
370     h15->SetMaximum(1.6);
371     h15->SetMinimum(0.4);
372     h15->SetOption("COLZ");
373     gStyle->SetOptStat(0);
374     Int_t color[] = {4,3,2} ;
375     gStyle->SetPalette(3,color);
376     h15->GetZaxis()->SetNdivisions(3);
377     h15->UseCurrentStyle();
378   Add2RawsList(h15, k2DRatioAmp, !expert, image, !saveCorr) ;
379
380         TH1F * h16 = new TH1F("hRatioDist", "Amplitude_{current run}/Amplitude_{reference run} ratio distribution", nTot, 0., 2.);
381   h16->SetMinimum(1.);
382   Add2RawsList(h16, kRatioDist, !expert, image, !saveCorr) ;
383  
384   // now repeat the same for TRU and LEDMon data
385   Int_t nTot2x2 = fSuperModules * AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // max number of TRU channels for all SuperModules
386
387   // counter info: number of channels per event (bins are SM index)
388   TProfile * hT0 = new TProfile("hTRUEmcalSupermodules", "TRU EMC: # of TRU channels vs SuperMod;SM Id;# of TRU channels",
389                                 fSuperModules, -0.5, fSuperModules-0.5) ;
390   Add2RawsList(hT0, kNsmodTRU, expert, image, !saveCorr) ;
391
392   // where did max sample occur? (bins are TRU channels)
393   TProfile * hT1 = new TProfile("hTRUEmcalRawtime", "TRU EMC: Time at Max vs 2x2Id;2x2 Id;Time [ticks]", 
394                                 nTot2x2, -0.5, nTot2x2-0.5) ;
395   Add2RawsList(hT1, kTimeTRU, expert, image, !saveCorr) ;
396
397   // how much above pedestal was the max sample?  (bins are TRU channels)
398   TProfile * hT2 = new TProfile("hTRUEmcalRawMaxMinusMin", "TRU EMC: Max - Min vs 2x2Id;2x2 Id;Max-Min [ADC counts]", 
399                                 nTot2x2, -0.5, nTot2x2-0.5) ;
400   Add2RawsList(hT2, kSigTRU, expert, image, !saveCorr) ;
401
402   // total counter: channels per event
403   TH1I * hT3 = new TH1I("hTRUNtot", "TRU EMC: Total Number of found TRU channels;# of TRU Channels;Counts", 200, 0, nTot2x2) ;
404   hT3->Sumw2() ;
405   Add2RawsList(hT3, kNtotTRU, expert, image, !saveCorr) ;
406
407   // pedestal (bins are TRU channels)
408   TProfile * hT4 = new TProfile("hTRUEmcalRawPed", "TRU EMC: Pedestal vs 2x2Id;2x2 Id;Pedestal [ADC counts]", 
409                                 nTot2x2, -0.5, nTot2x2-0.5) ;
410   Add2RawsList(hT4, kPedTRU, expert, image, !saveCorr) ;
411
412   // L0 trigger hits: # of hits (bins are TRU channels)
413   TH1I * hT5 = new TH1I("hTRUEmcalL0hits", "L0 trigger hits: Total number of 2x2 L0 generated", nTot2x2, -0.5, nTot2x2);
414   hT5->Sumw2();
415   Add2RawsList(hT5, kNL0TRU, expert, image, !saveCorr);
416
417   // L0 trigger hits: average time (bins are TRU channels)
418   TProfile * hT6 = new TProfile("hTRUEmcalL0hitsAvgTime", "L0 trigger hits: average time bin", nTot2x2, -0.5, nTot2x2); 
419   Add2RawsList(hT6, kTimeL0TRU, expert, image, !saveCorr);
420
421   // and also LED Mon..
422   // LEDMon has both high and low gain channels, just as regular FEE/towers
423   Int_t nTotLEDMon = fSuperModules * AliEMCALGeoParams::fgkEMCALLEDRefs; // max number of LEDMon channels for all SuperModules
424
425   // counter info: number of channels per event (bins are SM index)
426   TProfile * hL0 = new TProfile("hLowLEDMonEmcalSupermodules", "LowLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips",
427                                fSuperModules, -0.5, fSuperModules-0.5) ;
428   Add2RawsList(hL0, kNsmodLGLEDMon, expert, image, !saveCorr) ;
429   TProfile * hL1 = new TProfile("hHighLEDMonEmcalSupermodules", "HighLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips",  
430                                fSuperModules, -0.5, fSuperModules-0.5) ; 
431   Add2RawsList(hL1, kNsmodHGLEDMon, expert, image, !saveCorr) ;
432
433   // where did max sample occur? (bins are strips)
434   TProfile * hL2 = new TProfile("hLowLEDMonEmcalRawtime", "LowLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", 
435                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
436   Add2RawsList(hL2, kTimeLGLEDMon, expert, image, !saveCorr) ;
437   TProfile * hL3 = new TProfile("hHighLEDMonEmcalRawtime", "HighLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", 
438                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
439   Add2RawsList(hL3, kTimeHGLEDMon, expert, image, !saveCorr) ;
440
441   // how much above pedestal was the max sample?  (bins are strips)
442   TProfile * hL4 = new TProfile("hLowLEDMonEmcalRawMaxMinusMin", "LowLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]", 
443                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
444   Add2RawsList(hL4, kSigLGLEDMon, expert, image, !saveCorr) ;
445   TProfile * hL5 = new TProfile("hHighLEDMonEmcalRawMaxMinusMin", "HighLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]",
446                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
447   Add2RawsList(hL5, kSigHGLEDMon, expert, image, !saveCorr) ;
448   
449     // total counter: channels per event
450   TH1I * hL6 = new TH1I("hLowLEDMonNtot", "LowLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200, 0, nTotLEDMon) ;
451   hL6->Sumw2() ;
452   Add2RawsList(hL6, kNtotLGLEDMon, expert, image, !saveCorr) ;
453   TH1I * hL7 = new TH1I("hHighLEDMonNtot", "HighLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200,0, nTotLEDMon) ;
454   hL7->Sumw2() ;
455   Add2RawsList(hL7, kNtotHGLEDMon, expert, image, !saveCorr) ;
456
457   // pedestal (bins are strips)
458   TProfile * hL8 = new TProfile("hLowLEDMonEmcalRawPed", "LowLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]", 
459                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
460   Add2RawsList(hL8, kPedLGLEDMon, expert, image, !saveCorr) ;
461   TProfile * hL9 = new TProfile("hHighLEDMonEmcalRawPed", "HighLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]",
462                                nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
463   Add2RawsList(hL9, kPedHGLEDMon, expert, image, !saveCorr) ;
464   
465   //add two histograms for shifter from the LED monitor system: comapre LED monitor with the reference run
466   //to be used for decision whether we need to change reference data
467   TH1F * hL10 = new TH1F("hMaxMinusMinLEDMonRatio", "LEDMon amplitude, Ratio to reference run", nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
468   Add2RawsList(hL10, kLEDMonRatio, !expert, image, !saveCorr) ;
469   //settings for display in amore
470   hL10->SetTitle("Amplitude_{LEDMon current}/Amplitude_{LEDMon reference}"); 
471   hL10->SetMaximum(1.6);
472   hL10->SetMinimum(0.4);
473 //  hL10->SetOption("E");
474   TH1F * hL11 = new TH1F("hMaxMinusMinLEDMonRatioDist", "LEDMon amplitude, Ratio distribution", nTot, 0, 2);
475   hL11->SetMinimum(1.) ;
476   Add2RawsList(hL11, kLEDMonRatioDist, !expert, image, !saveCorr) ;
477   
478   GetCalibRefFromOCDB() ;   
479   GetCalibRefFromOCDB() ;   
480 }
481
482 //____________________________________________________________________________
483 void AliEMCALQADataMakerRec::MakeESDs(AliESDEvent * esd)
484 {
485   // make QA data from ESDs
486
487   Int_t nTot = 0 ; 
488   for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {
489     AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
490     if( clu->IsEMCAL() ) {
491       GetESDsData(kESDCaloClusE)->Fill(clu->E()) ;
492       nTot++ ;
493     } 
494   }
495   GetESDsData(kESDCaloClusM)->Fill(nTot) ;
496
497   //fill calo cells
498   AliESDCaloCells* cells = esd->GetEMCALCells();
499   GetESDsData(kESDCaloCellM)->Fill(cells->GetNumberOfCells()) ;
500
501   for ( Int_t index = 0; index < cells->GetNumberOfCells() ; index++ ) {
502     GetESDsData(kESDCaloCellA)->Fill(cells->GetAmplitude(index)) ;
503   }
504
505 }
506
507 //____________________________________________________________________________
508 void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
509 {
510   //Fill prepared histograms with Raw digit properties
511
512   // make sure EMCal was readout during the event
513   Int_t emcID = AliDAQ::DetectorID("EMCAL"); // bit 18..
514   const UInt_t *detPattern = rawReader->GetDetectorPattern(); 
515   UInt_t emcInReadout = ( ((1 << emcID) & detPattern[0]) >> emcID);
516   if (! emcInReadout) return; // no poInt_t in looking at this event, if no EMCal data
517
518   // setup
519   rawReader->Reset() ;
520   AliCaloRawStreamV3 in(rawReader,"EMCAL"); 
521   rawReader->Select("EMCAL", 0, AliEMCALGeoParams::fgkLastAltroDDL) ; //select EMCAL DDL's 
522
523   AliRecoParam::EventSpecie_t saveSpecie = fEventSpecie ;
524
525   if (rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent) { 
526     SetEventSpecie(AliRecoParam::kCalib) ;
527   }
528  
529   fRawAnalyzer->SetIsZeroSuppressed(true); // TMP - should use stream->IsZeroSuppressed(), or altro cfg registers later
530
531   const Int_t nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48
532   const Int_t nRows        = AliEMCALGeoParams::fgkEMCALRows; // number of rows per SuperModule
533   const Int_t nStripsPerSM = AliEMCALGeoParams::fgkEMCALLEDRefs; // number of strips per SuperModule
534   const Int_t n2x2PerSM    = AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // number of TRU 2x2's per SuperModule
535   const Int_t n2x2PerTRU   = AliEMCALGeoParams::fgkEMCAL2x2PerTRU;
536
537   // SM counters; decl. should be safe, assuming we don't get more than expected SuperModules..
538   Int_t nTotalSMLG[AliEMCALGeoParams::fgkEMCALModules]       = {0};
539   Int_t nTotalSMHG[AliEMCALGeoParams::fgkEMCALModules]       = {0};
540   Int_t nTotalSMTRU[AliEMCALGeoParams::fgkEMCALModules]      = {0};
541   Int_t nTotalSMLGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};
542   Int_t nTotalSMHGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};
543
544   const Int_t nTRUL0ChannelBits = 10; // used for L0 trigger bits checks
545   Int_t iSM = 0; // SuperModule index 
546   // start loop over input stream  
547   while (in.NextDDL()) {
548     Int_t iRCU = in.GetDDLNumber() % 2; // RCU0 or RCU1, within SuperModule
549
550     while (in.NextChannel()) {
551       iSM = in.GetModule(); // SuperModule
552       //prInt_tf("iSM %d DDL %d", iSM, in.GetDDLNumber()); 
553       if (iSM>=0 && iSM<fSuperModules) { // valid module reading
554
555         Int_t nsamples = 0;
556         vector<AliCaloBunchInfo> bunchlist; 
557         while (in.NextBunch()) {
558           nsamples += in.GetBunchLength();
559           bunchlist.push_back( AliCaloBunchInfo(in.GetStartTimeBin(), in.GetBunchLength(), in.GetSignals() ) );
560         } 
561         
562         if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
563           Float_t time = 0.; 
564           Float_t amp  = 0.; 
565           // indices for pedestal calc.
566           Int_t firstPedSample = 0;
567           Int_t lastPedSample  = 0;
568           bool isTRUL0IdData   = false;
569
570           if (! in.IsTRUData() ) { // high gain, low gain, LED Mon data - all have the same shaper/sampling 
571             AliCaloFitResults fitResults = fRawAnalyzer->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2()); 
572             amp  = fitResults.GetAmp();
573             time = fitResults.GetTof(); 
574             firstPedSample = fFirstPedestalSample;
575             lastPedSample  = fLastPedestalSample;
576           }
577           else { // TRU data is special, needs its own analyzer
578             AliCaloFitResults fitResults = fRawAnalyzerTRU->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2()); 
579             amp  = fitResults.GetAmp();
580             time = fitResults.GetTof(); 
581             firstPedSample = fFirstPedestalSampleTRU;
582             lastPedSample  = fLastPedestalSampleTRU;
583             if (in.GetColumn() > n2x2PerTRU) {
584               isTRUL0IdData = true;
585             }
586           }
587   
588           // pedestal samples
589           Int_t nPed = 0;
590           vector<Int_t> pedSamples; 
591         
592           // select earliest bunch 
593           unsigned int bunchIndex = 0;
594           unsigned int startBin = bunchlist.at(0).GetStartBin();
595           if (bunchlist.size() > 0) {
596             for(unsigned int ui=1; ui < bunchlist.size(); ui++ ) {
597               if (startBin > bunchlist.at(ui).GetStartBin() ) {
598                 startBin = bunchlist.at(ui).GetStartBin();
599                 bunchIndex = ui;
600               }
601             }
602           }
603
604           // check bunch for entries in the pedestal sample range
605           Int_t bunchLength = bunchlist.at(bunchIndex).GetLength(); 
606           const UShort_t *sig = bunchlist.at(bunchIndex).GetData();
607           Int_t timebin = 0;
608
609           if (! isTRUL0IdData) { // regular data, can look at pedestals
610             for (Int_t i = 0; i<bunchLength; i++) {
611               timebin = startBin--;
612               if ( firstPedSample<=timebin && timebin<=lastPedSample ) {
613                 pedSamples.push_back( sig[i] );
614                 nPed++;
615               }     
616             } // i
617           }
618           else { // TRU L0 Id Data
619             // which TRU the channel belongs to?
620             Int_t iTRUId = in.GetModule()*3 + (iRCU*in.GetBranch() + iRCU);
621
622             for (Int_t i = 0; i< bunchLength; i++) {
623               for( Int_t j = 0; j < nTRUL0ChannelBits; j++ ){
624                 // check if the bit j is 1
625                 if( (sig[i] & ( 1 << j )) > 0 ){
626                   Int_t iTRUIdInSM = (in.GetColumn() - n2x2PerTRU)*nTRUL0ChannelBits+j;
627                   if(iTRUIdInSM < n2x2PerTRU) {
628                     Int_t iTRUAbsId = iTRUIdInSM + n2x2PerTRU * iTRUId;
629                     // Fill the histograms
630                     GetRawsData(kNL0TRU)->Fill(iTRUAbsId);
631                     GetRawsData(kTimeL0TRU)->Fill(iTRUAbsId, startBin);
632                   }
633                 }
634               }
635               startBin--;
636             } // i      
637           } // TRU L0 Id data                   
638
639           // fill histograms
640           if ( in.IsLowGain() || in.IsHighGain() ) { // regular towers
641             Int_t towerId = iSM*nTowersPerSM + in.GetColumn()*nRows + in.GetRow();
642             if ( in.IsLowGain() ) { 
643               nTotalSMLG[iSM]++; 
644               GetRawsData(kTowerLG)->Fill(towerId);
645               if ( (amp > fMinSignalLG) && (amp < fMaxSignalLG) ) { 
646                 GetRawsData(kSigLG)->Fill(towerId, amp);
647                 GetRawsData(kTimeLG)->Fill(towerId, time);
648               }
649               if (nPed > 0) {
650                 for (Int_t i=0; i<nPed; i++) {
651                   GetRawsData(kPedLG)->Fill(towerId, pedSamples[i]);
652                 }
653               }
654             } // gain==0
655             else if ( in.IsHighGain() ) {               
656               nTotalSMHG[iSM]++; 
657               GetRawsData(kTowerHG)->Fill(towerId);
658               if ( (amp > fMinSignalHG) && (amp < fMaxSignalHG) ) { 
659                 GetRawsData(kSigHG)->Fill(towerId, amp);
660                 GetRawsData(kTimeHG)->Fill(towerId, time);
661               } 
662               if (nPed > 0) {
663                 for (Int_t i=0; i<nPed; i++) {
664                   GetRawsData(kPedHG)->Fill(towerId, pedSamples[i]);
665                 }
666               }
667             } // gain==1
668           } // low or high gain
669           // TRU
670           else if ( in.IsTRUData() && in.GetColumn()<AliEMCALGeoParams::fgkEMCAL2x2PerTRU) {
671             // for TRU data, the mapping class holds the TRU Int_ternal 2x2 number (0..95) in the Column var..
672             Int_t iTRU = (iRCU*in.GetBranch() + iRCU); //TRU0 is from RCU0, TRU1 from RCU1, TRU2 is from branch B on RCU1
673             Int_t iTRU2x2Id = iSM*n2x2PerSM + iTRU*AliEMCALGeoParams::fgkEMCAL2x2PerTRU 
674               + in.GetColumn();
675             nTotalSMTRU[iSM]++; 
676             if ( (amp > fMinSignalTRU) && (amp < fMaxSignalTRU) ) { 
677               GetRawsData(kSigTRU)->Fill(iTRU2x2Id, amp);
678               GetRawsData(kTimeTRU)->Fill(iTRU2x2Id, time);
679             }
680             if (nPed > 0) {
681               for (Int_t i=0; i<nPed; i++) {
682                 GetRawsData(kPedTRU)->Fill(iTRU2x2Id, pedSamples[i]);
683               }
684             }
685           }
686           // LED Mon
687           else if ( in.IsLEDMonData() ) {
688             // for LED Mon data, the mapping class holds the gain info in the Row variable
689             // and the Strip number in the Column..
690             Int_t gain = in.GetRow(); 
691             Int_t stripId = iSM*nStripsPerSM + in.GetColumn();
692           
693             if ( gain == 0 ) { 
694               nTotalSMLGLEDMon[iSM]++; 
695               if ( (amp > fMinSignalLGLEDMon) && (amp < fMaxSignalLGLEDMon) ) { 
696                 GetRawsData(kSigLGLEDMon)->Fill(stripId, amp);
697                 GetRawsData(kTimeLGLEDMon)->Fill(stripId, time);
698               }
699               if (nPed > 0) {
700                 for (Int_t i=0; i<nPed; i++) {
701                   GetRawsData(kPedLGLEDMon)->Fill(stripId, pedSamples[i]);
702                 }
703               }
704             } // gain==0
705             else if ( gain == 1 ) {             
706               nTotalSMHGLEDMon[iSM]++; 
707               if ( (amp > fMinSignalHGLEDMon) && (amp < fMaxSignalHGLEDMon) ) { 
708                 GetRawsData(kSigHGLEDMon)->Fill(stripId, amp);
709                 GetRawsData(kTimeHGLEDMon)->Fill(stripId, time);
710               }
711               if (nPed > 0) {
712                 for (Int_t i=0; i<nPed; i++) {
713                   GetRawsData(kPedHGLEDMon)->Fill(stripId, pedSamples[i]);
714                 }
715               }
716             } // low or high gain
717           } // LEDMon
718
719         } // SM index OK
720
721       } // nsamples>0 check, some data found for this channel; not only trailer/header
722     }// end while over channel 
723    
724   }//end while over DDL's, of input stream 
725
726  // TProfile * p = dynamic_cast<TProfile *>(GetRawsData(kSigHG)) ;
727   ConvertProfile2H(dynamic_cast<TProfile *>(GetRawsData(kSigHG)), fHighEmcHistoH2F) ;  
728   Double_t binContent = 0. ;
729   //calculate the ratio of the amplitude and fill the histograms, only if the events type is Calib
730  if (rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent) { 
731   GetRawsData(k2DRatioAmp)->Reset(); 
732   GetRawsData(kRatioDist)->Reset(); 
733   for(Int_t ix = 1; ix <= fHighEmcHistoH2F->GetNbinsX(); ix++) {
734     for(Int_t iy = 1; iy <= fHighEmcHistoH2F->GetNbinsY(); iy++) {
735       if(fCalibRefHistoH2F->GetBinContent(ix, iy))binContent = fHighEmcHistoH2F->GetBinContent(ix, iy)/fCalibRefHistoH2F->GetBinContent(ix, iy) ;
736       GetRawsData(k2DRatioAmp)->SetBinContent(ix, iy, binContent);
737       GetRawsData(kRatioDist)->Fill(GetRawsData(k2DRatioAmp)->GetBinContent(ix, iy));
738     }
739   } 
740  }
741   //Now for LED monitor system, to calculate the ratio as well
742   if(fLEDMonRefHistoPro){
743   GetRawsData(kLEDMonRatio)->Reset();   
744   GetRawsData(kLEDMonRatioDist)->Reset();
745   
746   Double_t binContent, binError;
747   
748   for(int ib = 1; ib <= fLEDMonRefHistoPro->GetNbinsX(); ib++) {
749     
750     if(fLEDMonRefHistoPro->GetBinContent(ib) != 0) binContent = GetRawsData(kSigLGLEDMon)->GetBinContent(ib) / fLEDMonRefHistoPro->GetBinContent(ib);
751     else binContent = 0;
752     GetRawsData(kLEDMonRatio)->SetBinContent(ib, binContent);
753     
754     binError = GetRawsData(kSigLGLEDMon)->GetBinError(ib)/fLEDMonRefHistoPro->GetBinContent(ib) +
755     GetRawsData(kSigLGLEDMon)->GetBinContent(ib)/TMath::Power(fLEDMonRefHistoPro->GetBinContent(ib), 2)*fLEDMonRefHistoPro->GetBinError(ib);
756     GetRawsData(kLEDMonRatio)->SetBinError(ib, binError);
757     GetRawsData(kLEDMonRatioDist)->Fill(GetRawsData(kLEDMonRatio)->GetBinContent(ib));
758     }
759   }
760   
761   
762   
763   // let's also fill the SM and event counter histograms
764   Int_t nTotalHG = 0;
765   Int_t nTotalLG = 0;
766   Int_t nTotalTRU = 0;
767   Int_t nTotalHGLEDMon = 0;
768   Int_t nTotalLGLEDMon = 0;
769   for (Int_t iSM=0; iSM<fSuperModules; iSM++) {  
770     nTotalLG += nTotalSMLG[iSM]; 
771     nTotalHG += nTotalSMHG[iSM]; 
772     nTotalTRU += nTotalSMTRU[iSM]; 
773     nTotalLGLEDMon += nTotalSMLGLEDMon[iSM]; 
774     nTotalHGLEDMon += nTotalSMHGLEDMon[iSM]; 
775     GetRawsData(kNsmodLG)->Fill(iSM, nTotalSMLG[iSM]); 
776     GetRawsData(kNsmodHG)->Fill(iSM, nTotalSMHG[iSM]); 
777     GetRawsData(kNsmodTRU)->Fill(iSM, nTotalSMTRU[iSM]); 
778     GetRawsData(kNsmodLGLEDMon)->Fill(iSM, nTotalSMLGLEDMon[iSM]); 
779     GetRawsData(kNsmodHGLEDMon)->Fill(iSM, nTotalSMHGLEDMon[iSM]); 
780   }
781   
782   GetRawsData(kNtotLG)->Fill(nTotalLG);
783   GetRawsData(kNtotHG)->Fill(nTotalHG);
784   GetRawsData(kNtotTRU)->Fill(nTotalTRU);
785   GetRawsData(kNtotLGLEDMon)->Fill(nTotalLGLEDMon);
786   GetRawsData(kNtotHGLEDMon)->Fill(nTotalHGLEDMon);
787  
788
789   SetEventSpecie(saveSpecie) ; 
790   // just in case the next rawreader consumer forgets to reset; let's do it here again..
791   rawReader->Reset() ;
792
793   return;
794 }
795
796 //____________________________________________________________________________
797 void AliEMCALQADataMakerRec::MakeDigits()
798 {
799   // makes data from Digits
800
801   GetDigitsData(1)->Fill(fDigitsArray->GetEntriesFast()) ; 
802   TIter next(fDigitsArray) ; 
803   AliEMCALDigit * digit ; 
804   while ( (digit = dynamic_cast<AliEMCALDigit *>(next())) ) {
805     GetDigitsData(0)->Fill( digit->GetAmplitude()) ;
806   }  
807   
808 }
809
810 //____________________________________________________________________________
811 void AliEMCALQADataMakerRec::MakeDigits(TTree * digitTree)
812 {
813   // makes data from Digit Tree
814   if (fDigitsArray) 
815     fDigitsArray->Clear() ; 
816   else
817     fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; 
818   
819   TBranch * branch = digitTree->GetBranch("EMCAL") ;
820   if ( ! branch ) {
821     AliWarning("EMCAL branch in Digit Tree not found") ; 
822   } else {
823     branch->SetAddress(&fDigitsArray) ;
824     branch->GetEntry(0) ; 
825     MakeDigits() ; 
826   }
827   
828 }
829
830 //____________________________________________________________________________
831 void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree)
832 {
833   // makes data from RecPoints
834   TBranch *emcbranch = clustersTree->GetBranch("EMCALECARP");
835   if (!emcbranch) { 
836     AliError("can't get the branch with the EMCAL clusters !");
837     return;
838   }
839   
840   TObjArray * emcRecPoints = new TObjArray(100) ;
841   emcbranch->SetAddress(&emcRecPoints);
842   emcbranch->GetEntry(0);
843   
844   GetRecPointsData(kRecPM)->Fill(emcRecPoints->GetEntriesFast()) ; 
845   TIter next(emcRecPoints) ; 
846   AliEMCALRecPoint * rp ; 
847   while ( (rp = dynamic_cast<AliEMCALRecPoint *>(next())) ) {
848     GetRecPointsData(kRecPE)->Fill(rp->GetEnergy()) ;
849     GetRecPointsData(kRecPDigM)->Fill(rp->GetMultiplicity());
850   }
851   emcRecPoints->Delete();
852   delete emcRecPoints;
853   
854 }
855
856 //____________________________________________________________________________ 
857 void AliEMCALQADataMakerRec::StartOfDetectorCycle()
858 {
859   //Detector specific actions at start of cycle
860   
861 }
862
863 //____________________________________________________________________________ 
864 void AliEMCALQADataMakerRec::SetFittingAlgorithm(Int_t fitAlgo)              
865 {
866   //Set fitting algorithm and initialize it if this same algorithm was not set before.
867   //printf("**** Set Algorithm , number %d ****\n",fitAlgo);
868   
869   if(fitAlgo == fFittingAlgorithm && fRawAnalyzer) {
870     //Do nothing, this same algorithm already set before.
871     //printf("**** Algorithm already set before, number %d, %s ****\n",fitAlgo, fRawAnalyzer->GetName());
872     return;
873   }
874   //Initialize the requested algorithm
875   if(fitAlgo != fFittingAlgorithm || !fRawAnalyzer) {
876     //printf("**** Init Algorithm , number %d ****\n",fitAlgo);
877                 
878     fFittingAlgorithm = fitAlgo; 
879     if (fRawAnalyzer) delete fRawAnalyzer;  // delete prev. analyzer if existed.
880                 
881     if (fitAlgo == kFastFit) {
882       fRawAnalyzer = new AliCaloRawAnalyzerFastFit();
883     }
884     else if (fitAlgo == kNeuralNet) {
885       fRawAnalyzer = new AliCaloRawAnalyzerNN();
886     }
887     else if (fitAlgo == kLMS) {
888       fRawAnalyzer = new AliCaloRawAnalyzerLMS();
889     }
890     else if (fitAlgo == kPeakFinder) {
891       fRawAnalyzer = new AliCaloRawAnalyzerPeakFinder();
892     }
893     else if (fitAlgo == kCrude) {
894       fRawAnalyzer = new AliCaloRawAnalyzerCrude();
895     }
896     else {
897       AliWarning("EMCAL QA invalid fit algorithm choice") ; 
898     }
899
900   }
901   return;
902 }
903
904 //_____________________________________________________________________________________
905 void AliEMCALQADataMakerRec::ConvertProfile2H(TProfile * p, TH2 * histo) 
906 {  
907   // set some histogram defaults
908   //histo->Reset() ; 
909   //histo->SetStats(kFALSE); // no statistics box shown
910   Int_t nbinsProf = p->GetNbinsX();
911   
912   // loop through the TProfile p and fill the TH2F histo 
913   Int_t row = 0;
914   Int_t col = 0;
915   Double_t binContent = 0;
916   Int_t towerNum = 0; // global tower Id
917   //  i = 0; // tower Id within SuperModule
918   Int_t iSM = 0; // SuperModule index 
919   Int_t iSMSide = 0; // 0=A, 1=C side
920   Int_t iSMSector = 0; // 2 SM's per sector
921   
922   // indices for 2D plots
923   Int_t col2d = 0;
924   Int_t row2d = 0;
925   
926   for (Int_t ibin = 1; ibin <= nbinsProf; ibin++) {
927     towerNum = (Int_t) p->GetBinCenter(ibin);
928     binContent = p->GetBinContent(ibin);
929     
930     // figure out what the tower indices are: col, row within a SuperModule
931     iSM = towerNum/(AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols);
932     col = (towerNum/AliEMCALGeoParams::fgkEMCALRows) % (AliEMCALGeoParams::fgkEMCALCols);
933     row = towerNum % (AliEMCALGeoParams::fgkEMCALRows);
934     
935     //DecodeTowerNum(towerNum, &SM, &col, &row);
936     // then we calculate what the global 2D coord are, based on which SM 
937     // we are in
938     iSMSector = iSM / 2;
939     iSMSide = iSM % 2;
940     
941     if (iSMSide == 1) { // C side, shown to the right
942       col2d = col + AliEMCALGeoParams::fgkEMCALCols;
943     }
944     else { // A side, shown to the left 
945       col2d = col; 
946     }
947     
948     row2d = row + iSMSector * AliEMCALGeoParams::fgkEMCALRows;
949     
950     histo->SetBinContent(col2d+1, row2d+1, binContent);
951   }
952