Updated macro
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQADataMakerRec.cxx
CommitLineData
020d7a22 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15/*\r
16Based on the QA code for PHOS written by Yves Schutz July 2007\r
17\r
18Authors: J.Klay (Cal Poly) May 2008\r
19 S. Salur LBL April 2008\r
20 \r
21Created one histogram for QA shifter;\r
22The idea:average counts for all the towers should be flat \r
23Change all existing histograms as experts\r
24 --By Yaxian Mao \r
25\r
26*/\r
27\r
28// --- ROOT system ---\r
29#include <TClonesArray.h>\r
30#include <TFile.h> \r
31#include <TH1F.h> \r
32#include <TH1I.h> \r
33#include <TH2F.h> \r
34#include <TProfile.h> \r
35\r
36// --- Standard library ---\r
37\r
38\r
39// --- AliRoot header files ---\r
40#include "AliESDCaloCluster.h"\r
41#include "AliESDCaloCells.h"\r
42#include "AliESDEvent.h"\r
43#include "AliLog.h"\r
44#include "AliEMCALQADataMakerRec.h"\r
45#include "AliQAChecker.h"\r
46#include "AliEMCALDigit.h" \r
47#include "AliEMCALRecPoint.h" \r
48#include "AliEMCALRawUtils.h"\r
49#include "AliEMCALReconstructor.h"\r
50#include "AliEMCALRecParam.h"\r
51#include "AliRawReader.h"\r
52#include "AliCaloRawStreamV3.h"\r
53#include "AliEMCALGeoParams.h"\r
54\r
55ClassImp(AliEMCALQADataMakerRec)\r
56 \r
57//____________________________________________________________________________ \r
58 AliEMCALQADataMakerRec::AliEMCALQADataMakerRec() : \r
59 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"),\r
60 fSuperModules(4), // FIXME!!! number of SuperModules; 4 for 2009; update default to 12 for later runs..\r
61 fFirstPedestalSample(0),\r
62 fLastPedestalSample(15),\r
63 fMinSignalHG(0),\r
64 fMaxSignalHG(AliEMCALGeoParams::fgkSampleMax)\r
65 {\r
66 // ctor\r
67}\r
68\r
69//____________________________________________________________________________ \r
70AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qadm) :\r
71 AliQADataMakerRec(), \r
72 fSuperModules(qadm.GetSuperModules()), \r
73 fFirstPedestalSample(qadm.GetFirstPedestalSample()), \r
74 fLastPedestalSample(qadm.GetLastPedestalSample()), \r
75 fMinSignalHG(qadm.GetMinSignalHG()),\r
76 fMaxSignalHG(qadm.GetMaxSignalHG())\r
77{\r
78 //copy ctor \r
79 SetName((const char*)qadm.GetName()) ; \r
80 SetTitle((const char*)qadm.GetTitle()); \r
81}\r
82\r
83//__________________________________________________________________\r
84AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQADataMakerRec& qadm )\r
85{\r
86 // Equal operator.\r
87 this->~AliEMCALQADataMakerRec();\r
88 new(this) AliEMCALQADataMakerRec(qadm);\r
89 return *this;\r
90}\r
91 \r
92//____________________________________________________________________________ \r
93void AliEMCALQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)\r
94{\r
95 //Detector specific actions at end of cycle\r
96 \r
97 if(fCycleCounter)\r
98 GetRawsData(kNEventsPerTower)->Scale(1./fCycleCounter);\r
99 \r
100 // do the QA checking\r
101 AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ; \r
102}\r
103\r
104//____________________________________________________________________________ \r
105void AliEMCALQADataMakerRec::InitESDs()\r
106{\r
107 //Create histograms to controll ESD\r
108 const Bool_t expert = kTRUE ; \r
109 const Bool_t image = kTRUE ; \r
110 \r
111 TH1F * h1 = new TH1F("hESDCaloClusterE", "ESDs CaloCluster energy in EMCAL;Energy [MeV];Counts", 200, 0., 20.) ; \r
112 h1->Sumw2() ;\r
113 Add2ESDsList(h1, kESDCaloClusE, !expert, image) ; \r
114\r
115 TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL;# of Clusters;Entries", 100, 0, 100) ; \r
116 h2->Sumw2() ;\r
117 Add2ESDsList(h2, kESDCaloClusM, !expert, image) ;\r
118\r
119 TH1F * h3 = new TH1F("hESDCaloCellA", "ESDs CaloCell amplitude in EMCAL;Energy [MeV];Counts", 500, 0., 250.) ; \r
120 h3->Sumw2() ;\r
121 Add2ESDsList(h3, kESDCaloCellA, !expert, image) ; \r
122 \r
123 TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL;# of Clusters;Entries", 200, 0, 1000) ; \r
124 h4->Sumw2() ;\r
125 Add2ESDsList(h4, kESDCaloCellM, !expert, image) ;\r
126 \r
127}\r
128\r
129//____________________________________________________________________________ \r
130void AliEMCALQADataMakerRec::InitDigits()\r
131{\r
132 // create Digits histograms in Digits subdir\r
133 const Bool_t expert = kTRUE ; \r
134 const Bool_t image = kTRUE ; \r
135 \r
136 TH1I * h0 = new TH1I("hEmcalDigits", "Digits amplitude distribution in EMCAL;Amplitude [ADC counts];Counts", 500, 0, 500) ; \r
137 h0->Sumw2() ;\r
138 Add2DigitsList(h0, 0, !expert, image) ;\r
139 TH1I * h1 = new TH1I("hEmcalDigitsMul", "Digits multiplicity distribution in EMCAL;# of Digits;Entries", 200, 0, 2000) ; \r
140 h1->Sumw2() ;\r
141 Add2DigitsList(h1, 1, !expert, image) ;\r
142}\r
143\r
144//____________________________________________________________________________ \r
145void AliEMCALQADataMakerRec::InitRecPoints()\r
146{\r
147 // create Reconstructed Points histograms in RecPoints subdir\r
148 const Bool_t expert = kTRUE ; \r
149 const Bool_t image = kTRUE ; \r
150 \r
151 TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies;Energy [MeV];Counts",200, 0.,20.); //GeV\r
152 h0->Sumw2();\r
153 Add2RecPointsList(h0,kRecPE, !expert, image);\r
154\r
155 TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities;# of Clusters;Entries",100,0,100);\r
156 h1->Sumw2();\r
157 Add2RecPointsList(h1,kRecPM, !expert, image);\r
158\r
159 TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities;# of Digits;Entries",20,0,20);\r
160 h2->Sumw2();\r
161 Add2RecPointsList(h2,kRecPDigM, !expert, image);\r
162\r
163}\r
164\r
165//____________________________________________________________________________ \r
166void AliEMCALQADataMakerRec::InitRaws()\r
167{\r
168 // create Raws histograms in Raws subdir\r
169 const Bool_t expert = kTRUE ; \r
170 const Bool_t saveCorr = kTRUE ; \r
171 const Bool_t image = kTRUE ; \r
172\r
173 int nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48\r
174 int nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules\r
175\r
176 // counter info: number of channels per event (bins are SM index)\r
177 TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod;SM Id;# of towers",\r
178 fSuperModules, -0.5, fSuperModules-0.5) ;\r
179 Add2RawsList(h0, kNsmodLG, expert, image, !saveCorr) ;\r
180 TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod;SM Id;# of towers", \r
181 fSuperModules, -0.5, fSuperModules-0.5) ; \r
182 Add2RawsList(h1, kNsmodHG, expert, image, !saveCorr) ;\r
183\r
184 // where did max sample occur? (bins are towers)\r
185 TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", \r
186 nTot, -0.5, nTot-0.5) ;\r
187 Add2RawsList(h2, kTimeLG, expert, image, !saveCorr) ;\r
188 TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", \r
189 nTot, -0.5, nTot-0.5) ;\r
190 Add2RawsList(h3, kTimeHG, expert, image, !saveCorr) ;\r
191\r
192 // how much above pedestal was the max sample? (bins are towers)\r
193 TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]", \r
194 nTot, -0.5, nTot-0.5) ;\r
195 Add2RawsList(h4, kSigLG, expert, image, !saveCorr) ;\r
196 TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]",\r
197 nTot, -0.5, nTot-0.5) ;\r
198 Add2RawsList(h5, kSigHG, expert, image, !saveCorr) ;\r
199\r
200 // total counter: channels per event\r
201 TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers;# of Towers;Counts", 200, 0, nTot) ;\r
202 h6->Sumw2() ;\r
203 Add2RawsList(h6, kNtotLG, expert, image, !saveCorr) ;\r
204 TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers;# of Towers;Counts", 200,0, nTot) ;\r
205 h7->Sumw2() ;\r
206 Add2RawsList(h7, kNtotHG, expert, image, !saveCorr) ;\r
207\r
208 // pedestal (bins are towers)\r
209 TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]", \r
210 nTot, -0.5, nTot-0.5) ;\r
211 Add2RawsList(h8, kPedLG, expert, image, !saveCorr) ;\r
212 TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]",\r
213 nTot, -0.5, nTot-0.5) ;\r
214 Add2RawsList(h9, kPedHG, expert, image, !saveCorr) ;\r
215\r
216 // pedestal rms (standard dev = sqrt of variance estimator for pedestal) (bins are towers)\r
217 TProfile * h10 = new TProfile("hLowEmcalRawPedRMS", "Low Gain EMC: Pedestal RMS vs towerId;Tower Id;Width [ADC counts]", \r
218 nTot, -0.5, nTot-0.5) ;\r
219 Add2RawsList(h10, kPedRMSLG, expert, image, !saveCorr) ;\r
220 TProfile * h11 = new TProfile("hHighEmcalRawPedRMS", "High Gain EMC: Pedestal RMS vs towerId;Tower Id;Width [ADC counts]",\r
221 nTot, -0.5, nTot-0.5) ;\r
222 Add2RawsList(h11, kPedRMSHG, expert, image, !saveCorr) ;\r
223 \r
224 //number of events per tower, for shifter fast check \r
225 TH1I * h12 = new TH1I("hNEventsPerTower", "Number of events per tower;Tower", 200,0, nTot) ;\r
226 h12->Sumw2() ;\r
227 Add2RawsList(h12, kNEventsPerTower, !expert, image, !saveCorr) ;\r
228 \r
229 \r
230\r
231 // now repeat the same for TRU and LEDMon data\r
232 int nTot2x2 = fSuperModules * AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // max number of TRU channels for all SuperModules\r
233\r
234 // counter info: number of channels per event (bins are SM index)\r
235 TProfile * hT0 = new TProfile("hTRUEmcalSupermodules", "TRU EMC: # of TRU channels vs SuperMod;SM Id;# of TRU channels",\r
236 fSuperModules, -0.5, fSuperModules-0.5) ;\r
237 Add2RawsList(hT0, kNsmodTRU, expert, image, !saveCorr) ;\r
238\r
239 // where did max sample occur? (bins are TRU channels)\r
240 TProfile * hT1 = new TProfile("hTRUEmcalRawtime", "TRU EMC: Time at Max vs 2x2Id;2x2 Id;Time [ticks]", \r
241 nTot2x2, -0.5, nTot2x2-0.5) ;\r
242 Add2RawsList(hT1, kTimeTRU, expert, image, !saveCorr) ;\r
243\r
244 // how much above pedestal was the max sample? (bins are TRU channels)\r
245 TProfile * hT2 = new TProfile("hTRUEmcalRawMaxMinusMin", "TRU EMC: Max - Min vs 2x2Id;2x2 Id;Max-Min [ADC counts]", \r
246 nTot2x2, -0.5, nTot2x2-0.5) ;\r
247 Add2RawsList(hT2, kSigTRU, expert, image, !saveCorr) ;\r
248\r
249 // total counter: channels per event\r
250 TH1I * hT3 = new TH1I("hTRUNtot", "TRU EMC: Total Number of found TRU channels;# of TRU Channels;Counts", 200, 0, nTot2x2) ;\r
251 hT3->Sumw2() ;\r
252 Add2RawsList(hT3, kNtotTRU, expert, image, !saveCorr) ;\r
253\r
254 // pedestal (bins are TRU channels)\r
255 TProfile * hT4 = new TProfile("hTRUEmcalRawPed", "TRU EMC: Pedestal vs 2x2Id;2x2 Id;Pedestal [ADC counts]", \r
256 nTot2x2, -0.5, nTot2x2-0.5) ;\r
257 Add2RawsList(hT4, kPedTRU, expert, image, !saveCorr) ;\r
258\r
259 // pedestal rms (standard dev = sqrt of variance estimator for pedestal) (bins are TRU channels)\r
260 TProfile * hT5 = new TProfile("hTRUEmcalRawPedRMS", "TRU EMC: Pedestal RMS vs 2x2Id;2x2 Id;Width [ADC counts]", \r
261 nTot2x2, -0.5, nTot2x2-0.5) ;\r
262 Add2RawsList(hT5, kPedRMSTRU, expert, image, !saveCorr) ;\r
263\r
264 // and also LED Mon..\r
265 // LEDMon has both high and low gain channels, just as regular FEE/towers\r
266 int nTotLEDMon = fSuperModules * AliEMCALGeoParams::fgkEMCALLEDRefs; // max number of LEDMon channels for all SuperModules\r
267\r
268 // counter info: number of channels per event (bins are SM index)\r
269 TProfile * hL0 = new TProfile("hLowLEDMonEmcalSupermodules", "LowLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips",\r
270 fSuperModules, -0.5, fSuperModules-0.5) ;\r
271 Add2RawsList(hL0, kNsmodLGLEDMon, expert, image, !saveCorr) ;\r
272 TProfile * hL1 = new TProfile("hHighLEDMonEmcalSupermodules", "HighLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips", \r
273 fSuperModules, -0.5, fSuperModules-0.5) ; \r
274 Add2RawsList(hL1, kNsmodHGLEDMon, expert, image, !saveCorr) ;\r
275\r
276 // where did max sample occur? (bins are strips)\r
277 TProfile * hL2 = new TProfile("hLowLEDMonEmcalRawtime", "LowLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", \r
278 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
279 Add2RawsList(hL2, kTimeLGLEDMon, expert, image, !saveCorr) ;\r
280 TProfile * hL3 = new TProfile("hHighLEDMonEmcalRawtime", "HighLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", \r
281 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
282 Add2RawsList(hL3, kTimeHGLEDMon, expert, image, !saveCorr) ;\r
283\r
284 // how much above pedestal was the max sample? (bins are strips)\r
285 TProfile * hL4 = new TProfile("hLowLEDMonEmcalRawMaxMinusMin", "LowLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]", \r
286 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
287 Add2RawsList(hL4, kSigLGLEDMon, expert, image, !saveCorr) ;\r
288 TProfile * hL5 = new TProfile("hHighLEDMonEmcalRawMaxMinusMin", "HighLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]",\r
289 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
290 Add2RawsList(hL5, kSigHGLEDMon, expert, image, !saveCorr) ;\r
291\r
292 // total counter: channels per event\r
293 TH1I * hL6 = new TH1I("hLowLEDMonNtot", "LowLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200, 0, nTotLEDMon) ;\r
294 hL6->Sumw2() ;\r
295 Add2RawsList(hL6, kNtotLGLEDMon, expert, image, !saveCorr) ;\r
296 TH1I * hL7 = new TH1I("hHighLEDMonNtot", "HighLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200,0, nTotLEDMon) ;\r
297 hL7->Sumw2() ;\r
298 Add2RawsList(hL7, kNtotHGLEDMon, expert, image, !saveCorr) ;\r
299\r
300 // pedestal (bins are strips)\r
301 TProfile * hL8 = new TProfile("hLowLEDMonEmcalRawPed", "LowLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]", \r
302 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
303 Add2RawsList(hL8, kPedLGLEDMon, expert, image, !saveCorr) ;\r
304 TProfile * hL9 = new TProfile("hHighLEDMonEmcalRawPed", "HighLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]",\r
305 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
306 Add2RawsList(hL9, kPedHGLEDMon, expert, image, !saveCorr) ;\r
307\r
308 // pedestal rms (standard dev = sqrt of variance estimator for pedestal) (bins are strips)\r
309 TProfile * hL10 = new TProfile("hLowLEDMonEmcalRawPedRMS", "LowLEDMon Gain EMC: Pedestal RMS vs stripId;Strip Id;Width [ADC counts]", \r
310 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
311 Add2RawsList(hL10, kPedRMSLGLEDMon, expert, image, !saveCorr) ;\r
312 TProfile * hL11 = new TProfile("hHighLEDMonEmcalRawPedRMS", "HighLEDMon Gain EMC: Pedestal RMS vs stripId;Strip Id;Width [ADC counts]",\r
313 nTotLEDMon, -0.5, nTotLEDMon-0.5) ;\r
314 Add2RawsList(hL11, kPedRMSHGLEDMon, expert, image, !saveCorr) ;\r
315 \r
316}\r
317\r
318//____________________________________________________________________________\r
319void AliEMCALQADataMakerRec::MakeESDs(AliESDEvent * esd)\r
320{\r
321 // make QA data from ESDs\r
322\r
323 Int_t nTot = 0 ; \r
324 for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {\r
325 AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;\r
326 if( clu->IsEMCAL() ) {\r
327 GetESDsData(kESDCaloClusE)->Fill(clu->E()) ;\r
328 nTot++ ;\r
329 } \r
330 }\r
331 GetESDsData(kESDCaloClusM)->Fill(nTot) ;\r
332\r
333 //fill calo cells\r
334 AliESDCaloCells* cells = esd->GetEMCALCells();\r
335 GetESDsData(kESDCaloCellM)->Fill(cells->GetNumberOfCells()) ;\r
336\r
337 for ( Int_t index = 0; index < cells->GetNumberOfCells() ; index++ ) {\r
338 GetESDsData(kESDCaloCellA)->Fill(cells->GetAmplitude(index)) ;\r
339 }\r
340\r
341}\r
342\r
343//____________________________________________________________________________\r
344void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)\r
345{\r
346 //Fill prepared histograms with Raw digit properties\r
347\r
348 //Raw histogram filling not yet implemented\r
349 //\r
350 //Need to figure out how to get the info we want without having to\r
351 //actually run Raw2Digits twice.\r
352 //I suspect what we actually want is a raw digits method, not a true\r
353 //emcal raw data method, but this doesn't seem to be allowed in\r
354 //AliQADataMakerRec.h\r
355\r
356 // For now, to avoid redoing the expensive signal fits we just\r
357 // look at max vs min of the signal spextra, a la online usage in\r
358 // AliCaloCalibPedestal\r
359\r
360 rawReader->Reset() ;\r
361 AliCaloRawStreamV3 in(rawReader,"EMCAL"); \r
362\r
363 // setup\r
364 int nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48\r
365 int nRows = AliEMCALGeoParams::fgkEMCALRows; // number of rows per SuperModule\r
366 int nStripsPerSM = AliEMCALGeoParams::fgkEMCALLEDRefs; // number of strips per SuperModule\r
367 int n2x2PerSM = AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // number of TRU 2x2's per SuperModule\r
368\r
369 int sampleMin = 0; \r
370 int sampleMax = AliEMCALGeoParams::fgkSampleMax; // 0x3ff = 1023 = 10-bit range\r
371\r
372 // for the pedestal calculation\r
373 Bool_t selectPedestalSamples = kTRUE;\r
374\r
375 // SM counters; decl. should be safe, assuming we don't get more than expected SuperModules..\r
376 int nTotalSMLG[AliEMCALGeoParams::fgkEMCALModules] = {0};\r
377 int nTotalSMHG[AliEMCALGeoParams::fgkEMCALModules] = {0};\r
378 int nTotalSMTRU[AliEMCALGeoParams::fgkEMCALModules] = {0};\r
379 int nTotalSMLGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};\r
380 int nTotalSMHGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0};\r
381\r
382 // indices for the reading\r
383 int iSM = 0;\r
384 int sample = 0;\r
385 int time = 0;\r
386 // counters, on sample level\r
387 int i = 0; // the sample number in current event.\r
388 int maxTime = 0;\r
389 int startBin = 0;\r
390\r
391 // calc. quantities\r
392 double meanPed = 0, squaredMean = 0, rmsPed = 0;\r
393\r
394 // start loop over input stream \r
395 while (in.NextDDL()) {\r
396 int iRCU = in.GetDDLNumber() % 2; // RCU0 or RCU1, within SuperModule\r
397 while (in.NextChannel()) {\r
398\r
399 // counters\r
400 int max = sampleMin, min = sampleMax; // min and max sample values\r
401 int nsamples = 0;\r
402\r
403 // for the pedestal calculation\r
404 int sampleSum = 0; // sum of samples\r
405 int squaredSampleSum = 0; // sum of samples squared\r
406 int nSum = 0; // number of samples in sum\r
407 \r
408 while (in.NextBunch()) {\r
409 const UShort_t *sig = in.GetSignals();\r
410 startBin = in.GetStartTimeBin();\r
411 nsamples += in.GetBunchLength();\r
412 for (i = 0; i < in.GetBunchLength(); i++) {\r
413 sample = sig[i];\r
414 time = startBin--;\r
415\r
416 // check if it's a min or max value\r
417 if (sample < min) min = sample;\r
418 if (sample > max) {\r
419 max = sample;\r
420 maxTime = time;\r
421 }\r
422\r
423 // should we add it for the pedestal calculation?\r
424 if ( (fFirstPedestalSample<=time && time<=fLastPedestalSample) || // sample time in range\r
425 !selectPedestalSamples ) { // or we don't restrict the sample range.. - then we'll take all \r
426 sampleSum += sample;\r
427 squaredSampleSum += sample*sample;\r
428 nSum++;\r
429 }\r
430 \r
431 } // loop over samples in bunch\r
432 } // loop over bunches\r
433 \r
434 if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout\r
435\r
436 // calculate pedesstal estimate: mean of possibly selected samples\r
437 if (nSum > 0) {\r
438 meanPed = sampleSum / (1.0 * nSum);\r
439 squaredMean = squaredSampleSum / (1.0 * nSum);\r
440 // The variance (rms squared) is equal to the mean of the squares minus the square of the mean..\r
441 rmsPed = sqrt(squaredMean - meanPed*meanPed); \r
442 }\r
443 else {\r
444 meanPed = 0;\r
445 squaredMean = 0;\r
446 rmsPed = 0;\r
447 }\r
448\r
449 // it should be enough to check the SuperModule info for each DDL really, but let's keep it here for now\r
450 iSM = in.GetModule(); //The modules are numbered starting from 0\r
451\r
452 if (iSM>=0 && iSM<fSuperModules) { // valid module reading, can go on with filling\r
453\r
454 if ( in.IsLowGain() || in.IsHighGain() ) { // regular towers\r
455 int towerId = iSM*nTowersPerSM + in.GetColumn()*nRows + in.GetRow();\r
456 \r
457 GetRawsData(kNEventsPerTower)->Fill(towerId);\r
458 \r
459\r
460 if ( in.IsLowGain() ) { \r
461 //fill the low gain histograms, and counters\r
462 nTotalSMLG[iSM]++; // one more channel found\r
463 GetRawsData(kSigLG)->Fill(towerId, max - min);\r
464 GetRawsData(kTimeLG)->Fill(towerId, maxTime);\r
465 if (nSum>0) { // only fill pedestal info in case it could be calculated\r
466 GetRawsData(kPedLG)->Fill(towerId, meanPed);\r
467 GetRawsData(kPedRMSLG)->Fill(towerId, rmsPed);\r
468 }\r
469 } // gain==0\r
470 else if ( in.IsHighGain() ) { \r
471 //fill the high gain ones\r
472 nTotalSMHG[iSM]++; // one more channel found\r
473 int signal = max - min;\r
474 // only fill the max-min signal info and maxTime, if the\r
475 // signal was in the selected range \r
476 if ( (signal > fMinSignalHG) && (signal < fMaxSignalHG) ) { \r
477 GetRawsData(kSigHG)->Fill(towerId, signal);\r
478 GetRawsData(kTimeHG)->Fill(towerId, maxTime);\r
479 } // signal\r
480 if (nSum>0) { // only fill pedestal info in case it could be calculated\r
481 GetRawsData(kPedHG)->Fill(towerId, meanPed);\r
482 GetRawsData(kPedRMSHG)->Fill(towerId, rmsPed);\r
483 }\r
484 }\r
485 } // low or high gain\r
486 // TRU\r
487 else if ( in.IsTRUData() ) {\r
488 // for TRU data, the mapping class holds the TRU internal 2x2 number (0..95) in the Column var..\r
489 int iTRU = iRCU; //TRU0 is from RCU0, TRU1 from RCU1\r
490 if (iRCU>0 && in.GetBranch()>0) iTRU=2; // TRU2 is from branch B on RCU1\r
491 int TRU2x2Id = iSM*n2x2PerSM + iTRU*AliEMCALGeoParams::fgkEMCAL2x2PerTRU \r
492 + in.GetColumn();\r
493\r
494 //fill the low gain histograms, and counters\r
495 nTotalSMTRU[iSM]++; // one more channel found\r
496 GetRawsData(kSigTRU)->Fill(TRU2x2Id, max - min);\r
497 GetRawsData(kTimeTRU)->Fill(TRU2x2Id, maxTime);\r
498 if (nSum>0) { // only fill pedestal info in case it could be calculated\r
499 GetRawsData(kPedTRU)->Fill(TRU2x2Id, meanPed);\r
500 GetRawsData(kPedRMSTRU)->Fill(TRU2x2Id, rmsPed);\r
501 }\r
502 }\r
503 // LED Mon\r
504 else if ( in.IsLEDMonData() ) {\r
505 // for LED Mon data, the mapping class holds the gain info in the Row variable\r
506 // and the Strip number in the Column..\r
507 int gain = in.GetRow(); \r
508 int stripId = iSM*nStripsPerSM + in.GetColumn();\r
509 \r
510 if ( gain == 0 ) { \r
511 //fill the low gain histograms, and counters\r
512 nTotalSMLGLEDMon[iSM]++; // one more channel found\r
513 GetRawsData(kSigLGLEDMon)->Fill(stripId, max - min);\r
514 GetRawsData(kTimeLGLEDMon)->Fill(stripId, maxTime);\r
515 if (nSum>0) { // only fill pedestal info in case it could be calculated\r
516 GetRawsData(kPedLGLEDMon)->Fill(stripId, meanPed);\r
517 GetRawsData(kPedRMSLGLEDMon)->Fill(stripId, rmsPed);\r
518 }\r
519 } // gain==0\r
520 else if ( gain == 1 ) { \r
521 //fill the high gain ones\r
522 nTotalSMHGLEDMon[iSM]++; // one more channel found\r
523 GetRawsData(kSigHGLEDMon)->Fill(stripId, max - min);\r
524 GetRawsData(kTimeHGLEDMon)->Fill(stripId, maxTime);\r
525 if (nSum>0) { // only fill pedestal info in case it could be calculated\r
526 GetRawsData(kPedHGLEDMon)->Fill(stripId, meanPed);\r
527 GetRawsData(kPedRMSHGLEDMon)->Fill(stripId, rmsPed);\r
528 }\r
529 } // low or high gain\r
530 } // LEDMon\r
531\r
532 } // SM index OK\r
533\r
534 } // nsamples>0 check, some data found for this channel; not only trailer/header\r
535 }// end while over channel \r
536 \r
537 }//end while over DDL's, of input stream \r
538\r
539 // let's also fill the SM and event counter histograms\r
540 int nTotalHG = 0;\r
541 int nTotalLG = 0;\r
542 int nTotalTRU = 0;\r
543 int nTotalHGLEDMon = 0;\r
544 int nTotalLGLEDMon = 0;\r
545 for (iSM=0; iSM<fSuperModules; iSM++) { \r
546 nTotalLG += nTotalSMLG[iSM]; \r
547 nTotalHG += nTotalSMHG[iSM]; \r
548 nTotalTRU += nTotalSMTRU[iSM]; \r
549 nTotalLG += nTotalSMLGLEDMon[iSM]; \r
550 nTotalHG += nTotalSMHGLEDMon[iSM]; \r
551 GetRawsData(kNsmodLG)->Fill(iSM, nTotalSMLG[iSM]); \r
552 GetRawsData(kNsmodHG)->Fill(iSM, nTotalSMHG[iSM]); \r
553 GetRawsData(kNsmodTRU)->Fill(iSM, nTotalSMTRU[iSM]); \r
554 GetRawsData(kNsmodLGLEDMon)->Fill(iSM, nTotalSMLGLEDMon[iSM]); \r
555 GetRawsData(kNsmodHGLEDMon)->Fill(iSM, nTotalSMHGLEDMon[iSM]); \r
556 }\r
557 GetRawsData(kNtotLG)->Fill(nTotalLG);\r
558 GetRawsData(kNtotHG)->Fill(nTotalHG);\r
559 GetRawsData(kNtotTRU)->Fill(nTotalTRU);\r
560 GetRawsData(kNtotLGLEDMon)->Fill(nTotalLGLEDMon);\r
561 GetRawsData(kNtotHGLEDMon)->Fill(nTotalHGLEDMon);\r
562\r
563 // just in case the next rawreader consumer forgets to reset; let's do it here again..\r
564 rawReader->Reset() ;\r
565\r
566 return;\r
567}\r
568\r
569//____________________________________________________________________________\r
570void AliEMCALQADataMakerRec::MakeDigits()\r
571{\r
572 // makes data from Digits\r
573\r
574 GetDigitsData(1)->Fill(fDigitsArray->GetEntriesFast()) ; \r
575 TIter next(fDigitsArray) ; \r
576 AliEMCALDigit * digit ; \r
577 while ( (digit = dynamic_cast<AliEMCALDigit *>(next())) ) {\r
578 GetDigitsData(0)->Fill( digit->GetAmp()) ;\r
579 } \r
580 \r
581}\r
582\r
583//____________________________________________________________________________\r
584void AliEMCALQADataMakerRec::MakeDigits(TTree * digitTree)\r
585{\r
586 // makes data from Digit Tree\r
587 if (fDigitsArray) \r
588 fDigitsArray->Clear() ; \r
589 else\r
590 fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; \r
591 \r
592 TBranch * branch = digitTree->GetBranch("EMCAL") ;\r
593 if ( ! branch ) {\r
594 AliWarning("EMCAL branch in Digit Tree not found") ; \r
595 } else {\r
596 branch->SetAddress(&fDigitsArray) ;\r
597 branch->GetEntry(0) ; \r
598 MakeDigits() ; \r
599 }\r
600 \r
601}\r
602\r
603//____________________________________________________________________________\r
604void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree)\r
605{\r
606 // makes data from RecPoints\r
607 TBranch *emcbranch = clustersTree->GetBranch("EMCALECARP");\r
608 if (!emcbranch) { \r
609 AliError("can't get the branch with the EMCAL clusters !");\r
610 return;\r
611 }\r
612 \r
613 TObjArray * emcrecpoints = new TObjArray(100) ;\r
614 emcbranch->SetAddress(&emcrecpoints);\r
615 emcbranch->GetEntry(0);\r
616 \r
617 GetRecPointsData(kRecPM)->Fill(emcrecpoints->GetEntriesFast()) ; \r
618 TIter next(emcrecpoints) ; \r
619 AliEMCALRecPoint * rp ; \r
620 while ( (rp = dynamic_cast<AliEMCALRecPoint *>(next())) ) {\r
621 GetRecPointsData(kRecPE)->Fill( rp->GetEnergy()) ;\r
622 GetRecPointsData(kRecPDigM)->Fill(rp->GetMultiplicity());\r
623 }\r
624 emcrecpoints->Delete();\r
625 delete emcrecpoints;\r
626 \r
627}\r
628\r
629//____________________________________________________________________________ \r
630void AliEMCALQADataMakerRec::StartOfDetectorCycle()\r
631{\r
632 //Detector specific actions at start of cycle\r
633 \r
634}\r
635\r