Get selected digit via method, not direct member access (changed in root trunk).
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQADataMakerRec.cxx
CommitLineData
9e47432c 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/*
16Based on the QA code for PHOS written by Yves Schutz July 2007
17
18Authors: J.Klay (Cal Poly) May 2008
19 S. Salur LBL April 2008
20
21Created one histogram for QA shifter;
22The idea:average counts for all the towers should be flat
23Change all existing histograms as experts
24 --By Yaxian Mao
25
26*/
27
28// --- ROOT system ---
29#include <TClonesArray.h>
30#include <TFile.h>
31#include <TH1F.h>
32#include <TH1I.h>
33#include <TH2F.h>
34#include <TProfile.h>
35
36// --- Standard library ---
37
38
39// --- AliRoot header files ---
40#include "AliESDCaloCluster.h"
41#include "AliESDCaloCells.h"
42#include "AliESDEvent.h"
43#include "AliLog.h"
44#include "AliEMCALQADataMakerRec.h"
45#include "AliQAChecker.h"
46#include "AliEMCALDigit.h"
47#include "AliEMCALRecPoint.h"
48#include "AliEMCALRawUtils.h"
49#include "AliEMCALReconstructor.h"
50#include "AliEMCALRecParam.h"
51#include "AliRawReader.h"
52#include "AliCaloRawStreamV3.h"
53#include "AliEMCALGeoParams.h"
def665cb 54#include "AliRawEventHeaderBase.h"
55
56#include "AliCaloBunchInfo.h"
57#include "AliCaloFitResults.h"
58#include "AliCaloRawAnalyzerFastFit.h"
59#include "AliCaloRawAnalyzerNN.h"
60#include "AliCaloRawAnalyzerLMS.h"
61#include "AliCaloRawAnalyzerPeakFinder.h"
62#include "AliCaloRawAnalyzerCrude.h"
9e47432c 63
64ClassImp(AliEMCALQADataMakerRec)
65
66//____________________________________________________________________________
def665cb 67AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(fitAlgorithm fitAlgo) :
68 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"),
69 fFittingAlgorithm(0),
70 fRawAnalyzer(0),
71 fRawAnalyzerTRU(0),
72 fSuperModules(4), // FIXME!!! number of SuperModules; 4 for 2009; update default to 12 for later runs..
73 fFirstPedestalSample(0),
74 fLastPedestalSample(3),
75 fFirstPedestalSampleTRU(0),
76 fLastPedestalSampleTRU(3),
77 fMinSignalLG(0),
78 fMaxSignalLG(AliEMCALGeoParams::fgkSampleMax),
79 fMinSignalHG(0),
80 fMaxSignalHG(AliEMCALGeoParams::fgkSampleMax),
81 fMinSignalTRU(0),
82 fMaxSignalTRU(AliEMCALGeoParams::fgkSampleMax),
83 fMinSignalLGLEDMon(0),
84 fMaxSignalLGLEDMon(AliEMCALGeoParams::fgkSampleMax),
85 fMinSignalHGLEDMon(0),
86 fMaxSignalHGLEDMon(AliEMCALGeoParams::fgkSampleMax)
87{
9e47432c 88 // ctor
def665cb 89 SetFittingAlgorithm(fitAlgo);
90 fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS();
91 fRawAnalyzerTRU->SetFixTau(kTRUE);
92 fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper
9e47432c 93}
94
95//____________________________________________________________________________
96AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qadm) :
97 AliQADataMakerRec(),
def665cb 98 fFittingAlgorithm(0),
99 fRawAnalyzer(0),
100 fRawAnalyzerTRU(0),
9e47432c 101 fSuperModules(qadm.GetSuperModules()),
102 fFirstPedestalSample(qadm.GetFirstPedestalSample()),
103 fLastPedestalSample(qadm.GetLastPedestalSample()),
def665cb 104 fFirstPedestalSampleTRU(qadm.GetFirstPedestalSampleTRU()),
105 fLastPedestalSampleTRU(qadm.GetLastPedestalSampleTRU()),
106 fMinSignalLG(qadm.GetMinSignalLG()),
107 fMaxSignalLG(qadm.GetMaxSignalLG()),
9e47432c 108 fMinSignalHG(qadm.GetMinSignalHG()),
def665cb 109 fMaxSignalHG(qadm.GetMaxSignalHG()),
110 fMinSignalTRU(qadm.GetMinSignalTRU()),
111 fMaxSignalTRU(qadm.GetMaxSignalTRU()),
112 fMinSignalLGLEDMon(qadm.GetMinSignalLGLEDMon()),
113 fMaxSignalLGLEDMon(qadm.GetMaxSignalLGLEDMon()),
114 fMinSignalHGLEDMon(qadm.GetMinSignalHGLEDMon()),
115 fMaxSignalHGLEDMon(qadm.GetMaxSignalHGLEDMon())
9e47432c 116{
117 //copy ctor
118 SetName((const char*)qadm.GetName()) ;
119 SetTitle((const char*)qadm.GetTitle());
def665cb 120 SetFittingAlgorithm(qadm.GetFittingAlgorithm());
121 fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS();
122 fRawAnalyzerTRU->SetFixTau(kTRUE);
123 fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper
9e47432c 124}
125
126//__________________________________________________________________
127AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQADataMakerRec& qadm )
128{
129 // Equal operator.
130 this->~AliEMCALQADataMakerRec();
131 new(this) AliEMCALQADataMakerRec(qadm);
132 return *this;
133}
134
135//____________________________________________________________________________
136void AliEMCALQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
137{
138 //Detector specific actions at end of cycle
139
140// if(fCycleCounter)
141// GetRawsData(kNEventsPerTower)->Scale(1./fCycleCounter);
142
143 // do the QA checking
144 AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ;
145}
146
147//____________________________________________________________________________
148void AliEMCALQADataMakerRec::InitESDs()
149{
150 //Create histograms to controll ESD
151 const Bool_t expert = kTRUE ;
152 const Bool_t image = kTRUE ;
153
154 TH1F * h1 = new TH1F("hESDCaloClusterE", "ESDs CaloCluster energy in EMCAL;Energy [GeV];Counts", 200, 0., 100.) ;
155 h1->Sumw2() ;
156 Add2ESDsList(h1, kESDCaloClusE, !expert, image) ;
157
158 TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL;# of Clusters;Entries", 100, 0, 100) ;
159 h2->Sumw2() ;
160 Add2ESDsList(h2, kESDCaloClusM, !expert, image) ;
161
162 TH1F * h3 = new TH1F("hESDCaloCellA", "ESDs CaloCell amplitude in EMCAL;Energy [GeV];Counts", 500, 0., 50.) ;
163 h3->Sumw2() ;
164 Add2ESDsList(h3, kESDCaloCellA, !expert, image) ;
165
166 TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL;# of Clusters;Entries", 200, 0, 1000) ;
167 h4->Sumw2() ;
168 Add2ESDsList(h4, kESDCaloCellM, !expert, image) ;
169
170}
171
172//____________________________________________________________________________
173void AliEMCALQADataMakerRec::InitDigits()
174{
175 // create Digits histograms in Digits subdir
176 const Bool_t expert = kTRUE ;
177 const Bool_t image = kTRUE ;
178
179 TH1I * h0 = new TH1I("hEmcalDigits", "Digits amplitude distribution in EMCAL;Amplitude [ADC counts];Counts", 500, 0, 500) ;
180 h0->Sumw2() ;
181 Add2DigitsList(h0, 0, !expert, image) ;
182 TH1I * h1 = new TH1I("hEmcalDigitsMul", "Digits multiplicity distribution in EMCAL;# of Digits;Entries", 200, 0, 2000) ;
183 h1->Sumw2() ;
184 Add2DigitsList(h1, 1, !expert, image) ;
185}
186
187//____________________________________________________________________________
188void AliEMCALQADataMakerRec::InitRecPoints()
189{
190 // create Reconstructed Points histograms in RecPoints subdir
191 const Bool_t expert = kTRUE ;
192 const Bool_t image = kTRUE ;
193
194 TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies;Energy [GeV];Counts",200, 0.,20.); //GeV
195 h0->Sumw2();
196 Add2RecPointsList(h0,kRecPE, !expert, image);
197
198 TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities;# of Clusters;Entries",100,0,100);
199 h1->Sumw2();
200 Add2RecPointsList(h1,kRecPM, !expert, image);
201
202 TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities;# of Digits;Entries",20,0,20);
203 h2->Sumw2();
204 Add2RecPointsList(h2,kRecPDigM, !expert, image);
205
206}
207
208//____________________________________________________________________________
209void AliEMCALQADataMakerRec::InitRaws()
210{
211 // create Raws histograms in Raws subdir
212 const Bool_t expert = kTRUE ;
213 const Bool_t saveCorr = kTRUE ;
214 const Bool_t image = kTRUE ;
215
216 int nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48
217 int nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules
218
219 // counter info: number of channels per event (bins are SM index)
220 TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod;SM Id;# of towers",
221 fSuperModules, -0.5, fSuperModules-0.5) ;
222 Add2RawsList(h0, kNsmodLG, expert, image, !saveCorr) ;
223 TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod;SM Id;# of towers",
224 fSuperModules, -0.5, fSuperModules-0.5) ;
225 Add2RawsList(h1, kNsmodHG, expert, image, !saveCorr) ;
226
227 // where did max sample occur? (bins are towers)
228 TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]",
229 nTot, -0.5, nTot-0.5) ;
230 Add2RawsList(h2, kTimeLG, expert, image, !saveCorr) ;
231 TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]",
232 nTot, -0.5, nTot-0.5) ;
233 Add2RawsList(h3, kTimeHG, expert, image, !saveCorr) ;
234
235 // how much above pedestal was the max sample? (bins are towers)
236 TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]",
237 nTot, -0.5, nTot-0.5) ;
238 Add2RawsList(h4, kSigLG, expert, image, !saveCorr) ;
239 TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]",
240 nTot, -0.5, nTot-0.5) ;
241 Add2RawsList(h5, kSigHG, expert, image, !saveCorr) ;
242
243 // total counter: channels per event
244 TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers;# of Towers;Counts", 200, 0, nTot) ;
245 h6->Sumw2() ;
246 Add2RawsList(h6, kNtotLG, expert, image, !saveCorr) ;
247 TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers;# of Towers;Counts", 200,0, nTot) ;
248 h7->Sumw2() ;
249 Add2RawsList(h7, kNtotHG, expert, image, !saveCorr) ;
250
251 // pedestal (bins are towers)
252 TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]",
253 nTot, -0.5, nTot-0.5) ;
254 Add2RawsList(h8, kPedLG, expert, image, !saveCorr) ;
255 TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]",
256 nTot, -0.5, nTot-0.5) ;
257 Add2RawsList(h9, kPedHG, expert, image, !saveCorr) ;
9e47432c 258
259 //number of events per tower, for shifter fast check
260 TH1I * h12 = new TH1I("hTowerHG", "High Gains on the Tower;Tower", nTot,0, nTot) ;
261 h12->Sumw2() ;
262 Add2RawsList(h12, kTowerHG, !expert, image, !saveCorr) ;
263 TH1I * h13 = new TH1I("hTowerLG", "Low Gains on the Tower;Tower", nTot,0, nTot) ;
264 h13->Sumw2() ;
265 Add2RawsList(h13, kTowerLG, !expert, image, !saveCorr) ;
266
267 // now repeat the same for TRU and LEDMon data
268 int nTot2x2 = fSuperModules * AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // max number of TRU channels for all SuperModules
269
270 // counter info: number of channels per event (bins are SM index)
271 TProfile * hT0 = new TProfile("hTRUEmcalSupermodules", "TRU EMC: # of TRU channels vs SuperMod;SM Id;# of TRU channels",
272 fSuperModules, -0.5, fSuperModules-0.5) ;
273 Add2RawsList(hT0, kNsmodTRU, expert, image, !saveCorr) ;
274
275 // where did max sample occur? (bins are TRU channels)
276 TProfile * hT1 = new TProfile("hTRUEmcalRawtime", "TRU EMC: Time at Max vs 2x2Id;2x2 Id;Time [ticks]",
277 nTot2x2, -0.5, nTot2x2-0.5) ;
278 Add2RawsList(hT1, kTimeTRU, expert, image, !saveCorr) ;
279
280 // how much above pedestal was the max sample? (bins are TRU channels)
281 TProfile * hT2 = new TProfile("hTRUEmcalRawMaxMinusMin", "TRU EMC: Max - Min vs 2x2Id;2x2 Id;Max-Min [ADC counts]",
282 nTot2x2, -0.5, nTot2x2-0.5) ;
283 Add2RawsList(hT2, kSigTRU, expert, image, !saveCorr) ;
284
285 // total counter: channels per event
286 TH1I * hT3 = new TH1I("hTRUNtot", "TRU EMC: Total Number of found TRU channels;# of TRU Channels;Counts", 200, 0, nTot2x2) ;
287 hT3->Sumw2() ;
288 Add2RawsList(hT3, kNtotTRU, expert, image, !saveCorr) ;
289
290 // pedestal (bins are TRU channels)
291 TProfile * hT4 = new TProfile("hTRUEmcalRawPed", "TRU EMC: Pedestal vs 2x2Id;2x2 Id;Pedestal [ADC counts]",
292 nTot2x2, -0.5, nTot2x2-0.5) ;
293 Add2RawsList(hT4, kPedTRU, expert, image, !saveCorr) ;
294
5c6517c3 295 // L0 trigger hits: # of hits (bins are TRU channels)
296 TH1I * hT5 = new TH1I("hTRUEmcalL0hits", "L0 trigger hits: Total number of 2x2 L0 generated", nTot2x2, -0.5, nTot2x2);
297 hT5->Sumw2();
298 Add2RawsList(hT5, kNL0TRU, expert, image, !saveCorr);
299
300 // L0 trigger hits: average time (bins are TRU channels)
301 TProfile * hT6 = new TProfile("hTRUEmcalL0hitsAvgTime", "L0 trigger hits: average time bin", nTot2x2, -0.5, nTot2x2);
302 Add2RawsList(hT6, kTimeL0TRU, expert, image, !saveCorr);
303
9e47432c 304 // and also LED Mon..
305 // LEDMon has both high and low gain channels, just as regular FEE/towers
306 int nTotLEDMon = fSuperModules * AliEMCALGeoParams::fgkEMCALLEDRefs; // max number of LEDMon channels for all SuperModules
307
308 // counter info: number of channels per event (bins are SM index)
309 TProfile * hL0 = new TProfile("hLowLEDMonEmcalSupermodules", "LowLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips",
310 fSuperModules, -0.5, fSuperModules-0.5) ;
311 Add2RawsList(hL0, kNsmodLGLEDMon, expert, image, !saveCorr) ;
312 TProfile * hL1 = new TProfile("hHighLEDMonEmcalSupermodules", "HighLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips",
313 fSuperModules, -0.5, fSuperModules-0.5) ;
314 Add2RawsList(hL1, kNsmodHGLEDMon, expert, image, !saveCorr) ;
315
316 // where did max sample occur? (bins are strips)
317 TProfile * hL2 = new TProfile("hLowLEDMonEmcalRawtime", "LowLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]",
318 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
319 Add2RawsList(hL2, kTimeLGLEDMon, expert, image, !saveCorr) ;
320 TProfile * hL3 = new TProfile("hHighLEDMonEmcalRawtime", "HighLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]",
321 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
322 Add2RawsList(hL3, kTimeHGLEDMon, expert, image, !saveCorr) ;
323
324 // how much above pedestal was the max sample? (bins are strips)
325 TProfile * hL4 = new TProfile("hLowLEDMonEmcalRawMaxMinusMin", "LowLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]",
326 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
327 Add2RawsList(hL4, kSigLGLEDMon, expert, image, !saveCorr) ;
328 TProfile * hL5 = new TProfile("hHighLEDMonEmcalRawMaxMinusMin", "HighLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]",
329 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
330 Add2RawsList(hL5, kSigHGLEDMon, expert, image, !saveCorr) ;
331
332 // total counter: channels per event
333 TH1I * hL6 = new TH1I("hLowLEDMonNtot", "LowLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200, 0, nTotLEDMon) ;
334 hL6->Sumw2() ;
335 Add2RawsList(hL6, kNtotLGLEDMon, expert, image, !saveCorr) ;
336 TH1I * hL7 = new TH1I("hHighLEDMonNtot", "HighLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200,0, nTotLEDMon) ;
337 hL7->Sumw2() ;
338 Add2RawsList(hL7, kNtotHGLEDMon, expert, image, !saveCorr) ;
339
340 // pedestal (bins are strips)
341 TProfile * hL8 = new TProfile("hLowLEDMonEmcalRawPed", "LowLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]",
342 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
343 Add2RawsList(hL8, kPedLGLEDMon, expert, image, !saveCorr) ;
344 TProfile * hL9 = new TProfile("hHighLEDMonEmcalRawPed", "HighLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]",
345 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;
346 Add2RawsList(hL9, kPedHGLEDMon, expert, image, !saveCorr) ;
347
9e47432c 348}
349
350//____________________________________________________________________________
351void AliEMCALQADataMakerRec::MakeESDs(AliESDEvent * esd)
352{
353 // make QA data from ESDs
354
355 Int_t nTot = 0 ;
356 for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {
357 AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
358 if( clu->IsEMCAL() ) {
359 GetESDsData(kESDCaloClusE)->Fill(clu->E()) ;
360 nTot++ ;
361 }
362 }
363 GetESDsData(kESDCaloClusM)->Fill(nTot) ;
364
365 //fill calo cells
366 AliESDCaloCells* cells = esd->GetEMCALCells();
367 GetESDsData(kESDCaloCellM)->Fill(cells->GetNumberOfCells()) ;
368
369 for ( Int_t index = 0; index < cells->GetNumberOfCells() ; index++ ) {
370 GetESDsData(kESDCaloCellA)->Fill(cells->GetAmplitude(index)) ;
371 }
372
373}
374
375//____________________________________________________________________________
376void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
377{
378 //Fill prepared histograms with Raw digit properties
def665cb 379 // setup
9e47432c 380 rawReader->Reset() ;
381 AliCaloRawStreamV3 in(rawReader,"EMCAL");
30aa89b0 382 rawReader->Select("EMCAL", 0, AliEMCALGeoParams::fgkLastAltroDDL) ; //select EMCAL DDL's
9e47432c 383
5c6517c3 384 AliRecoParam::EventSpecie_t saveSpecie = fEventSpecie ;
385
def665cb 386 if (rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent) {
387 SetEventSpecie(AliRecoParam::kCalib) ;
388 }
389
390 fRawAnalyzer->SetIsZeroSuppressed(true); // TMP - should use stream->IsZeroSuppressed(), or altro cfg registers later
391
9e47432c 392 int nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48
393 int nRows = AliEMCALGeoParams::fgkEMCALRows; // number of rows per SuperModule
394 int nStripsPerSM = AliEMCALGeoParams::fgkEMCALLEDRefs; // number of strips per SuperModule
395 int n2x2PerSM = AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // number of TRU 2x2's per SuperModule
5c6517c3 396 int n2x2PerTRU = AliEMCALGeoParams::fgkEMCAL2x2PerTRU;
9e47432c 397
9e47432c 398 // SM counters; decl. should be safe, assuming we don't get more than expected SuperModules..
399 int nTotalSMLG[AliEMCALGeoParams::fgkEMCALModules] = {0};
400 int nTotalSMHG[AliEMCALGeoParams::fgkEMCALModules] = {0};
401 int nTotalSMTRU[AliEMCALGeoParams::fgkEMCALModules] = {0};
402 int nTotalSMLGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};
403 int nTotalSMHGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};
404
5c6517c3 405 int nTRUL0ChannelBits = 10; // used for L0 trigger bits checks
406
def665cb 407 // start loop over input stream
9e47432c 408 int iSM = 0;
def665cb 409 while (in.NextDDL()) {
98d6fe2e 410 int iRCU = in.GetDDLNumber() % 2; // RCU0 or RCU1, within SuperModule
9e47432c 411
98d6fe2e 412 while (in.NextChannel()) {
413 iSM = in.GetModule(); // SuperModule
414 //printf("iSM %d DDL %d", iSM, in.GetDDLNumber());
415 if (iSM>=0 && iSM<fSuperModules) { // valid module reading
9e47432c 416
def665cb 417 int nsamples = 0;
418 vector<AliCaloBunchInfo> bunchlist;
419 while (in.NextBunch()) {
420 nsamples += in.GetBunchLength();
421 bunchlist.push_back( AliCaloBunchInfo(in.GetStartTimeBin(), in.GetBunchLength(), in.GetSignals() ) );
422 }
423
424 if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
425 Float_t time = 0;
426 Float_t amp = 0;
427 // indices for pedestal calc.
428 int firstPedSample = 0;
429 int lastPedSample = 0;
5c6517c3 430 bool isTRUL0IdData = false;
def665cb 431
432 if (! in.IsTRUData() ) { // high gain, low gain, LED Mon data - all have the same shaper/sampling
433 AliCaloFitResults fitResults = fRawAnalyzer->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2());
434 amp = fitResults.GetAmp();
435 time = fitResults.GetTof();
436 firstPedSample = fFirstPedestalSample;
437 lastPedSample = fLastPedestalSample;
9e47432c 438 }
def665cb 439 else { // TRU data is special, needs its own analyzer
440 AliCaloFitResults fitResults = fRawAnalyzerTRU->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2());
441 amp = fitResults.GetAmp();
442 time = fitResults.GetTof();
443 firstPedSample = fFirstPedestalSampleTRU;
444 lastPedSample = fLastPedestalSampleTRU;
5c6517c3 445 if (in.GetColumn() > n2x2PerTRU) {
446 isTRUL0IdData = true;
447 }
def665cb 448 }
449
450 // pedestal samples
451 int nPed = 0;
98d6fe2e 452 vector<int> pedSamples;
9e47432c 453
def665cb 454 // select earliest bunch
455 unsigned int bunchIndex = 0;
456 unsigned int startBin = bunchlist.at(0).GetStartBin();
457 if (bunchlist.size() > 0) {
458 for(unsigned int ui=1; ui < bunchlist.size(); ui++ ) {
459 if (startBin > bunchlist.at(ui).GetStartBin() ) {
460 startBin = bunchlist.at(ui).GetStartBin();
461 bunchIndex = ui;
462 }
9e47432c 463 }
464 }
def665cb 465
466 // check bunch for entries in the pedestal sample range
467 int bunchLength = bunchlist.at(bunchIndex).GetLength();
468 const UShort_t *sig = bunchlist.at(bunchIndex).GetData();
469 int timebin = 0;
5c6517c3 470
471 if (! isTRUL0IdData) { // regular data, can look at pedestals
472 for (int i = 0; i<bunchLength; i++) {
473 timebin = startBin--;
474 if ( firstPedSample<=timebin && timebin<=lastPedSample ) {
475 pedSamples.push_back( sig[i] );
476 nPed++;
477 }
478 } // i
98d6fe2e 479 // printf("nPed %d\n", nPed);
5c6517c3 480 }
481 else { // TRU L0 Id Data
482 // which TRU the channel belongs to?
483 int TRUId = in.GetModule()*3 + (iRCU*in.GetBranch() + iRCU);
484
485 for (int i = 0; i< bunchLength; i++) {
486 for( int j = 0; j < nTRUL0ChannelBits; j++ ){
487 // check if the bit j is 1
488 if( (sig[i] & ( 1 << j )) > 0 ){
489 int TRUIdInSM = (in.GetColumn() - n2x2PerTRU)*nTRUL0ChannelBits+j;
490 if(TRUIdInSM < n2x2PerTRU) {
491 int TRUAbsId = TRUIdInSM + n2x2PerTRU * TRUId;
492 // Fill the histograms
493 GetRawsData(kNL0TRU)->Fill(TRUAbsId);
494 GetRawsData(kTimeL0TRU)->Fill(TRUAbsId, startBin);
495 }
496 }
497 }
498 startBin--;
499 } // i
500 } // TRU L0 Id data
def665cb 501
502 // fill histograms
503 if ( in.IsLowGain() || in.IsHighGain() ) { // regular towers
504 int towerId = iSM*nTowersPerSM + in.GetColumn()*nRows + in.GetRow();
def665cb 505 if ( in.IsLowGain() ) {
506 nTotalSMLG[iSM]++;
507 GetRawsData(kTowerLG)->Fill(towerId);
508 if ( (amp > fMinSignalLG) && (amp < fMaxSignalLG) ) {
509 GetRawsData(kSigLG)->Fill(towerId, amp);
510 GetRawsData(kTimeLG)->Fill(towerId, time);
511 }
512 if (nPed > 0) {
513 for (int i=0; i<nPed; i++) {
514 GetRawsData(kPedLG)->Fill(towerId, pedSamples[i]);
515 }
516 }
517 } // gain==0
518 else if ( in.IsHighGain() ) {
519 nTotalSMHG[iSM]++;
520 GetRawsData(kTowerHG)->Fill(towerId);
521 if ( (amp > fMinSignalHG) && (amp < fMaxSignalHG) ) {
522 GetRawsData(kSigHG)->Fill(towerId, amp);
523 GetRawsData(kTimeHG)->Fill(towerId, time);
524 }
525 if (nPed > 0) {
526 for (int i=0; i<nPed; i++) {
527 GetRawsData(kPedHG)->Fill(towerId, pedSamples[i]);
528 }
529 }
530 } // gain==1
531 } // low or high gain
532 // TRU
533 else if ( in.IsTRUData() && in.GetColumn()<AliEMCALGeoParams::fgkEMCAL2x2PerTRU) {
534 // for TRU data, the mapping class holds the TRU internal 2x2 number (0..95) in the Column var..
5c6517c3 535 int iTRU = (iRCU*in.GetBranch() + iRCU); //TRU0 is from RCU0, TRU1 from RCU1, TRU2 is from branch B on RCU1
def665cb 536 int iTRU2x2Id = iSM*n2x2PerSM + iTRU*AliEMCALGeoParams::fgkEMCAL2x2PerTRU
537 + in.GetColumn();
def665cb 538 nTotalSMTRU[iSM]++;
539 if ( (amp > fMinSignalTRU) && (amp < fMaxSignalTRU) ) {
540 GetRawsData(kSigTRU)->Fill(iTRU2x2Id, amp);
541 GetRawsData(kTimeTRU)->Fill(iTRU2x2Id, time);
9e47432c 542 }
def665cb 543 if (nPed > 0) {
544 for (int i=0; i<nPed; i++) {
545 GetRawsData(kPedTRU)->Fill(iTRU2x2Id, pedSamples[i]);
546 }
9e47432c 547 }
def665cb 548 }
549 // LED Mon
550 else if ( in.IsLEDMonData() ) {
551 // for LED Mon data, the mapping class holds the gain info in the Row variable
552 // and the Strip number in the Column..
553 int gain = in.GetRow();
554 int stripId = iSM*nStripsPerSM + in.GetColumn();
555
556 if ( gain == 0 ) {
557 nTotalSMLGLEDMon[iSM]++;
558 if ( (amp > fMinSignalLGLEDMon) && (amp < fMaxSignalLGLEDMon) ) {
559 GetRawsData(kSigLGLEDMon)->Fill(stripId, amp);
560 GetRawsData(kTimeLGLEDMon)->Fill(stripId, time);
561 }
562 if (nPed > 0) {
563 for (int i=0; i<nPed; i++) {
564 GetRawsData(kPedLGLEDMon)->Fill(stripId, pedSamples[i]);
565 }
566 }
567 } // gain==0
568 else if ( gain == 1 ) {
569 nTotalSMHGLEDMon[iSM]++;
570 if ( (amp > fMinSignalHGLEDMon) && (amp < fMaxSignalHGLEDMon) ) {
571 GetRawsData(kSigHGLEDMon)->Fill(stripId, amp);
572 GetRawsData(kTimeHGLEDMon)->Fill(stripId, time);
573 }
574 if (nPed > 0) {
575 for (int i=0; i<nPed; i++) {
576 GetRawsData(kPedHGLEDMon)->Fill(stripId, pedSamples[i]);
577 }
578 }
579 } // low or high gain
580 } // LEDMon
581
582 } // SM index OK
9e47432c 583
584 } // nsamples>0 check, some data found for this channel; not only trailer/header
585 }// end while over channel
586
587 }//end while over DDL's, of input stream
588
589 // let's also fill the SM and event counter histograms
590 int nTotalHG = 0;
591 int nTotalLG = 0;
592 int nTotalTRU = 0;
593 int nTotalHGLEDMon = 0;
594 int nTotalLGLEDMon = 0;
595 for (iSM=0; iSM<fSuperModules; iSM++) {
596 nTotalLG += nTotalSMLG[iSM];
597 nTotalHG += nTotalSMHG[iSM];
598 nTotalTRU += nTotalSMTRU[iSM];
98d6fe2e 599 nTotalLGLEDMon += nTotalSMLGLEDMon[iSM];
600 nTotalHGLEDMon += nTotalSMHGLEDMon[iSM];
9e47432c 601 GetRawsData(kNsmodLG)->Fill(iSM, nTotalSMLG[iSM]);
602 GetRawsData(kNsmodHG)->Fill(iSM, nTotalSMHG[iSM]);
603 GetRawsData(kNsmodTRU)->Fill(iSM, nTotalSMTRU[iSM]);
604 GetRawsData(kNsmodLGLEDMon)->Fill(iSM, nTotalSMLGLEDMon[iSM]);
605 GetRawsData(kNsmodHGLEDMon)->Fill(iSM, nTotalSMHGLEDMon[iSM]);
606 }
def665cb 607
9e47432c 608 GetRawsData(kNtotLG)->Fill(nTotalLG);
609 GetRawsData(kNtotHG)->Fill(nTotalHG);
610 GetRawsData(kNtotTRU)->Fill(nTotalTRU);
611 GetRawsData(kNtotLGLEDMon)->Fill(nTotalLGLEDMon);
612 GetRawsData(kNtotHGLEDMon)->Fill(nTotalHGLEDMon);
5c6517c3 613
614
def665cb 615 SetEventSpecie(saveSpecie) ;
9e47432c 616 // just in case the next rawreader consumer forgets to reset; let's do it here again..
617 rawReader->Reset() ;
618
619 return;
620}
621
622//____________________________________________________________________________
623void AliEMCALQADataMakerRec::MakeDigits()
624{
625 // makes data from Digits
626
627 GetDigitsData(1)->Fill(fDigitsArray->GetEntriesFast()) ;
628 TIter next(fDigitsArray) ;
629 AliEMCALDigit * digit ;
630 while ( (digit = dynamic_cast<AliEMCALDigit *>(next())) ) {
631 GetDigitsData(0)->Fill( digit->GetAmp()) ;
632 }
633
634}
635
636//____________________________________________________________________________
637void AliEMCALQADataMakerRec::MakeDigits(TTree * digitTree)
638{
639 // makes data from Digit Tree
640 if (fDigitsArray)
641 fDigitsArray->Clear() ;
642 else
643 fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ;
644
645 TBranch * branch = digitTree->GetBranch("EMCAL") ;
646 if ( ! branch ) {
647 AliWarning("EMCAL branch in Digit Tree not found") ;
648 } else {
649 branch->SetAddress(&fDigitsArray) ;
650 branch->GetEntry(0) ;
651 MakeDigits() ;
652 }
653
654}
655
656//____________________________________________________________________________
657void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree)
658{
659 // makes data from RecPoints
660 TBranch *emcbranch = clustersTree->GetBranch("EMCALECARP");
661 if (!emcbranch) {
662 AliError("can't get the branch with the EMCAL clusters !");
663 return;
664 }
665
666 TObjArray * emcrecpoints = new TObjArray(100) ;
667 emcbranch->SetAddress(&emcrecpoints);
668 emcbranch->GetEntry(0);
669
670 GetRecPointsData(kRecPM)->Fill(emcrecpoints->GetEntriesFast()) ;
671 TIter next(emcrecpoints) ;
672 AliEMCALRecPoint * rp ;
673 while ( (rp = dynamic_cast<AliEMCALRecPoint *>(next())) ) {
674 GetRecPointsData(kRecPE)->Fill( rp->GetEnergy()) ;
675 GetRecPointsData(kRecPDigM)->Fill(rp->GetMultiplicity());
676 }
677 emcrecpoints->Delete();
678 delete emcrecpoints;
679
680}
681
682//____________________________________________________________________________
683void AliEMCALQADataMakerRec::StartOfDetectorCycle()
684{
685 //Detector specific actions at start of cycle
686
687}
688
def665cb 689//____________________________________________________________________________
690void AliEMCALQADataMakerRec::SetFittingAlgorithm(Int_t fitAlgo)
691{
692 //Set fitting algorithm and initialize it if this same algorithm was not set before.
693 //printf("**** Set Algorithm , number %d ****\n",fitAlgo);
694
695 if(fitAlgo == fFittingAlgorithm && fRawAnalyzer) {
696 //Do nothing, this same algorithm already set before.
697 //printf("**** Algorithm already set before, number %d, %s ****\n",fitAlgo, fRawAnalyzer->GetName());
698 return;
699 }
700 //Initialize the requested algorithm
701 if(fitAlgo != fFittingAlgorithm || !fRawAnalyzer) {
702 //printf("**** Init Algorithm , number %d ****\n",fitAlgo);
703
704 fFittingAlgorithm = fitAlgo;
705 if (fRawAnalyzer) delete fRawAnalyzer; // delete prev. analyzer if existed.
706
707 if (fitAlgo == kFastFit) {
708 fRawAnalyzer = new AliCaloRawAnalyzerFastFit();
709 }
710 else if (fitAlgo == kNeuralNet) {
711 fRawAnalyzer = new AliCaloRawAnalyzerNN();
712 }
713 else if (fitAlgo == kLMS) {
714 fRawAnalyzer = new AliCaloRawAnalyzerLMS();
715 }
716 else if (fitAlgo == kPeakFinder) {
717 fRawAnalyzer = new AliCaloRawAnalyzerPeakFinder();
718 }
719 else if (fitAlgo == kCrude) {
720 fRawAnalyzer = new AliCaloRawAnalyzerCrude();
721 }
722 else {
723 AliWarning("EMCAL QA invalid fit algorithm choice") ;
724 }
725
726 }
727 return;
728}
729