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