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