1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 Based on the QA code for PHOS written by Yves Schutz July 2007
18 Authors: J.Klay (Cal Poly) May 2008
19 S. Salur LBL April 2008
23 // --- ROOT system ---
24 #include <TClonesArray.h>
31 // --- Standard library ---
34 // --- AliRoot header files ---
35 #include "AliESDCaloCluster.h"
36 #include "AliESDCaloCells.h"
37 #include "AliESDEvent.h"
39 #include "AliEMCALQADataMakerRec.h"
40 #include "AliQAChecker.h"
41 #include "AliEMCALRecPoint.h"
42 #include "AliEMCALRawUtils.h"
43 #include "AliEMCALReconstructor.h"
44 #include "AliEMCALRecParam.h"
45 #include "AliRawReader.h"
46 #include "AliCaloRawStream.h"
48 ClassImp(AliEMCALQADataMakerRec)
50 //____________________________________________________________________________
51 AliEMCALQADataMakerRec::AliEMCALQADataMakerRec() :
52 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"),
53 fSuperModules(4) // FIXME!!! number of SuperModules; 4 for 2009; update default to 12 for later runs..
58 //____________________________________________________________________________
59 AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qadm) :
63 SetName((const char*)qadm.GetName()) ;
64 SetTitle((const char*)qadm.GetTitle());
65 fSuperModules = qadm.GetSuperModules();
68 //__________________________________________________________________
69 AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQADataMakerRec& qadm )
72 this->~AliEMCALQADataMakerRec();
73 new(this) AliEMCALQADataMakerRec(qadm);
77 //____________________________________________________________________________
78 void AliEMCALQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
80 //Detector specific actions at end of cycle
82 AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ;
85 //____________________________________________________________________________
86 void AliEMCALQADataMakerRec::InitESDs()
88 //Create histograms to controll ESD
89 const Bool_t expert = kTRUE ;
90 const Bool_t image = kTRUE ;
92 TH1F * h1 = new TH1F("hESDCaloClusterE", "ESDs CaloCluster energy in EMCAL", 200, 0., 20.) ;
94 Add2ESDsList(h1, kESDCaloClusE, !expert, image) ;
96 TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL", 100, 0, 100) ;
98 Add2ESDsList(h2, kESDCaloClusM, !expert, image) ;
100 TH1F * h3 = new TH1F("hESDCaloCellA", "ESDs CaloCell amplitude in EMCAL", 500, 0., 250.) ;
102 Add2ESDsList(h3, kESDCaloCellA, !expert, image) ;
104 TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL", 200, 0, 1000) ;
106 Add2ESDsList(h4, kESDCaloCellM, !expert, image) ;
110 //____________________________________________________________________________
111 void AliEMCALQADataMakerRec::InitRecPoints()
113 // create Reconstructed Points histograms in RecPoints subdir
114 const Bool_t expert = kTRUE ;
115 const Bool_t image = kTRUE ;
117 TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies",200, 0.,20.); //GeV
119 Add2RecPointsList(h0,kRecPE, !expert, image);
121 TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities",100,0,100);
123 Add2RecPointsList(h1,kRecPM, !expert, image);
125 TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities",20,0,20);
127 Add2RecPointsList(h2,kRecPDigM, !expert, image);
131 //____________________________________________________________________________
132 void AliEMCALQADataMakerRec::InitRaws()
134 // create Raws histograms in Raws subdir
135 const Bool_t expert = kTRUE ;
136 const Bool_t saveCorr = kTRUE ;
137 const Bool_t image = kTRUE ;
139 int nTowersPerSM = 1152; // number of towers in a SuperModule; 24x48
140 int nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules
142 // counter info: number of channels per event (bins are SM index)
143 TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod",
144 fSuperModules, -0.5, fSuperModules-0.5) ;
145 Add2RawsList(h0, kNsmodLG, !expert, image, !saveCorr) ;
146 TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod",
147 fSuperModules, -0.5, fSuperModules-0.5) ;
148 Add2RawsList(h1, kNsmodHG, !expert, image, !saveCorr) ;
150 // where did max sample occur? (bins are towers)
151 TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId",
152 nTot, -0.5, nTot-0.5) ;
153 Add2RawsList(h2, kTimeLG, !expert, image, !saveCorr) ;
154 TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId",
155 nTot, -0.5, nTot-0.5) ;
156 Add2RawsList(h3, kTimeHG, !expert, image, !saveCorr) ;
158 // how much above pedestal was the max sample? (bins are towers)
159 TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId",
160 nTot, -0.5, nTot-0.5) ;
161 Add2RawsList(h4, kSigLG, !expert, image, !saveCorr) ;
162 TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId",
163 nTot, -0.5, nTot-0.5) ;
164 Add2RawsList(h5, kSigHG, !expert, image, !saveCorr) ;
166 // total counter: channels per event
167 TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers", 200, 0, nTot) ;
169 Add2RawsList(h6, kNtotLG, !expert, image, !saveCorr) ;
170 TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers", 200,0, nTot) ;
172 Add2RawsList(h7, kNtotHG, !expert, image, !saveCorr) ;
174 // pedestal (bins are towers)
175 TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId",
176 nTot, -0.5, nTot-0.5) ;
177 Add2RawsList(h8, kPedLG, !expert, image, !saveCorr) ;
178 TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId",
179 nTot, -0.5, nTot-0.5) ;
180 Add2RawsList(h9, kPedHG, !expert, image, !saveCorr) ;
182 // pedestal rms (standard dev = sqrt of variance estimator for pedestal) (bins are towers)
183 TProfile * h10 = new TProfile("hLowEmcalRawPedRMS", "Low Gain EMC: Pedestal RMS vs towerId",
184 nTot, -0.5, nTot-0.5) ;
185 Add2RawsList(h10, kPedRMSLG, !expert, image, !saveCorr) ;
186 TProfile * h11 = new TProfile("hHighEmcalRawPedRMS", "High Gain EMC: Pedestal RMS vs towerId",
187 nTot, -0.5, nTot-0.5) ;
188 Add2RawsList(h11, kPedRMSHG, !expert, image, !saveCorr) ;
192 //____________________________________________________________________________
193 void AliEMCALQADataMakerRec::MakeESDs(AliESDEvent * esd)
195 // make QA data from ESDs
198 for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {
199 AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
200 if( clu->IsEMCAL() ) {
201 GetESDsData(kESDCaloClusE)->Fill(clu->E()) ;
205 GetESDsData(kESDCaloClusM)->Fill(nTot) ;
208 AliESDCaloCells* cells = esd->GetEMCALCells();
209 GetESDsData(kESDCaloCellM)->Fill(cells->GetNumberOfCells()) ;
211 for ( Int_t index = 0; index < cells->GetNumberOfCells() ; index++ ) {
212 GetESDsData(kESDCaloCellA)->Fill(cells->GetAmplitude(index)) ;
217 //____________________________________________________________________________
218 void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
220 //Fill prepared histograms with Raw digit properties
222 //Raw histogram filling not yet implemented
224 //Need to figure out how to get the info we want without having to
225 //actually run Raw2Digits twice.
226 //I suspect what we actually want is a raw digits method, not a true
227 //emcal raw data method, but this doesn't seem to be allowed in
228 //AliQADataMakerRec.h
230 // For now, to avoid redoing the expensive signal fits we just
231 // look at max vs min of the signal spextra, a la online usage in
232 // AliCaloCalibPedestal
235 AliCaloRawStream in(rawReader,"EMCAL");
238 int nTowersPerSM = 1152; // number of towers in a SuperModule; 24x48
239 int nRows = 24; // number of rows per SuperModule
241 int sampleMax = 0x3ff; // 1023 = 10-bit range
243 // for the pedestal calculation
244 Bool_t selectPedestalSamples = kTRUE;
245 int firstPedestalSample = 0;
246 int lastPedestalSample = 15;
248 // SM counters; decl. should be safe, assuming we don't get more than 12 SuperModules..
249 int nTotalSMLG[12] = {0};
250 int nTotalSMHG[12] = {0};
252 // indices for the reading
257 // counters, on sample level
258 int i = 0; // the sample number in current event.
259 int max = sampleMin, min = sampleMax;//Use these for picking the pedestal
262 // for the pedestal calculation
263 int sampleSum = 0; // sum of samples
264 int squaredSampleSum = 0; // sum of samples squared
265 int nSum = 0; // number of samples in sum
267 double meanPed = 0, squaredMean = 0, rmsPed = 0;
269 while (in.Next()) { // loop over input stream
270 sample = in.GetSignal(); //Get the adc signal
272 if (sample < min) { min = sample; }
279 // should we add it for the pedestal calculation?
280 if ( (firstPedestalSample<=time && time<=lastPedestalSample) || // sample time in range
281 !selectPedestalSamples ) { // or we don't restrict the sample range.. - then we'll take all
283 squaredSampleSum += sample*sample;
287 if ( i >= in.GetTimeLength()) {
288 // calculate pedesstal estimate: mean of possibly selected samples
290 meanPed = sampleSum / (1.0 * nSum);
291 squaredMean = squaredSampleSum / (1.0 * nSum);
292 // The variance (rms squared) is equal to the mean of the squares minus the square of the mean..
293 rmsPed = sqrt(squaredMean - meanPed*meanPed);
301 //If we're here then we're done with this tower
302 gain = -1; // init to not valid value
303 if ( in.IsLowGain() ) {
306 else if ( in.IsHighGain() ) {
310 iSM = in.GetModule(); //The modules are numbered starting from 0
312 if (iSM>=0 && iSM<fSuperModules) { // valid module reading, can go on with filling
314 int towerId = iSM*nTowersPerSM + in.GetColumn()*nRows + in.GetRow();
317 //fill the low gain histograms, and counters
318 nTotalSMLG[iSM]++; // one more channel found
319 GetRawsData(kSigLG)->Fill(towerId, max - min);
320 GetRawsData(kTimeLG)->Fill(towerId, maxTime);
321 if (nSum>0) { // only fill pedestal info in case it could be calculated
322 GetRawsData(kPedLG)->Fill(towerId, meanPed);
323 GetRawsData(kPedRMSLG)->Fill(towerId, rmsPed);
326 else if (gain == 1) {
327 //fill the high gain ones
328 nTotalSMHG[iSM]++; // one more channel found
329 GetRawsData(kSigHG)->Fill(towerId, max - min);
330 GetRawsData(kTimeHG)->Fill(towerId, maxTime);
331 if (nSum>0) { // only fill pedestal info in case it could be calculated
332 GetRawsData(kPedHG)->Fill(towerId, meanPed);
333 GetRawsData(kPedRMSHG)->Fill(towerId, rmsPed);
339 max = sampleMin; min = sampleMax;
342 // also pedestal calc counters
343 sampleSum = 0; // sum of samples
344 squaredSampleSum = 0; // sum of samples squared
345 nSum = 0; // number of samples in sum
347 }//End if, of channel
349 }//end while, of stream
351 // let's also fill the SM and event counter histograms
354 for (iSM=0; iSM<fSuperModules; iSM++) {
355 nTotalLG += nTotalSMLG[iSM];
356 nTotalHG += nTotalSMHG[iSM];
357 GetRawsData(kNsmodLG)->Fill(iSM, nTotalSMLG[iSM]);
358 GetRawsData(kNsmodHG)->Fill(iSM, nTotalSMHG[iSM]);
360 GetRawsData(kNtotLG)->Fill(nTotalLG);
361 GetRawsData(kNtotHG)->Fill(nTotalHG);
363 // just in case the next rawreader consumer forgets to reset; let's do it here again..
369 //____________________________________________________________________________
370 void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree)
372 // makes data from RecPoints
373 TBranch *emcbranch = clustersTree->GetBranch("EMCALECARP");
375 AliError("can't get the branch with the EMCAL clusters !");
378 TObjArray * emcrecpoints = new TObjArray(100) ;
379 emcbranch->SetAddress(&emcrecpoints);
380 emcbranch->GetEntry(0);
382 GetRecPointsData(kRecPM)->Fill(emcrecpoints->GetEntriesFast()) ;
383 TIter next(emcrecpoints) ;
384 AliEMCALRecPoint * rp ;
385 while ( (rp = dynamic_cast<AliEMCALRecPoint *>(next())) ) {
386 GetRecPointsData(kRecPE)->Fill( rp->GetEnergy()) ;
387 GetRecPointsData(kRecPDigM)->Fill(rp->GetMultiplicity());
389 emcrecpoints->Delete();
394 //____________________________________________________________________________
395 void AliEMCALQADataMakerRec::StartOfDetectorCycle()
397 //Detector specific actions at start of cycle