CMake: actual fix for compat with CMake v2.8.11
[u/mrichter/AliRoot.git] / AD / ADrec / AliADQADataMakerRec.cxx
CommitLineData
a6f3cc02 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
16
17// Produces the data needed to calculate the quality assurance
18// All data must be mergeable objects
19// Handles ESDs and Raws
20// Histos defined will be used for Raw Data control and monitoring
21
22// --- ROOT system ---
23#include <TClonesArray.h>
24#include <TFile.h>
25#include <TF1.h>
26#include <TH1F.h>
27#include <TH1I.h>
28#include <TH2I.h>
29#include <TH2F.h>
30#include <TGraph.h>
31#include <TParameter.h>
32#include <TTimeStamp.h>
33
34// --- Standard library ---
35
36// --- AliRoot header files ---
37#include "AliESDEvent.h"
38#include "AliLog.h"
39#include "AliCDBManager.h"
40#include "AliCDBStorage.h"
41#include "AliCDBEntry.h"
42#include "AliADQADataMakerRec.h"
43#include "AliQAChecker.h"
44#include "AliRawReader.h"
45#include "AliADRawStream.h"
46#include "AliADdigit.h"
47#include "AliADConst.h"
48#include "AliADReconstructor.h"
4462d42f 49#include "AliADTrending.h"
a6f3cc02 50#include "AliADCalibData.h"
51#include "AliCTPTimeParams.h"
52#include "event.h"
53
54ClassImp(AliADQADataMakerRec)
55
56//____________________________________________________________________________
57AliADQADataMakerRec::AliADQADataMakerRec() :
58AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kAD), "AD Quality Assurance Data Maker"),
59 fCalibData(0x0),
60 fTrendingUpdateTime(0),
61 fCycleStartTime(0),
62 fCycleStopTime(0),
63 fTimeSlewing(0)
64
65{
66 // Constructor
67
68 AliDebug(AliQAv1::GetQADebugLevel(), "Construct AD QA Object");
69
70 for(Int_t i=0; i<16; i++){
71 fEven[i] = 0;
72 fOdd[i] = 0;
73 }
74
75 for(Int_t i=0; i<32; i++){
76 fADCmean[i] = 0.0; }
77}
78
79//____________________________________________________________________________
80AliADQADataMakerRec::AliADQADataMakerRec(const AliADQADataMakerRec& qadm) :
81 AliQADataMakerRec(),
82 fCalibData(0x0),
83 fTrendingUpdateTime(0),
84 fCycleStartTime(0),
85 fCycleStopTime(0),
86 fTimeSlewing(0)
87
88{
89 // Copy constructor
90
91 SetName((const char*)qadm.GetName()) ;
92 SetTitle((const char*)qadm.GetTitle());
93}
94
95//__________________________________________________________________
96AliADQADataMakerRec& AliADQADataMakerRec::operator = (const AliADQADataMakerRec& qadm )
97{
98 // Equal operator
99
100 this->~AliADQADataMakerRec();
101 new(this) AliADQADataMakerRec(qadm);
102 return *this;
103}
104
105//____________________________________________________________________________
106AliADCalibData* AliADQADataMakerRec::GetCalibData() const
107
108{
109 AliCDBManager *man = AliCDBManager::Instance();
110
111 AliCDBEntry *entry=0;
112
734ca89d 113 entry = man->Get("AD/Calib/Data",fRun);
114 if(!entry){
115 AliWarning("Load of calibration data from default storage failed!");
116 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
a6f3cc02 117
118 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
119 entry = man->Get("AD/Calib/Data",fRun);
734ca89d 120 }
a6f3cc02 121 // Retrieval of data in directory AD/Calib/Data:
122
123 AliADCalibData *calibdata = 0;
124
125 if (entry) calibdata = (AliADCalibData*) entry->GetObject();
126 if (!calibdata) AliFatal("No calibration data from calibration database !");
127
128 return calibdata;
129}
130//____________________________________________________________________________
131void AliADQADataMakerRec::StartOfDetectorCycle()
132{
133 // Detector specific actions at start of cycle
134
135 // Reset of the histogram used - to have the trend versus time -
136
137 fCalibData = GetCalibData();
138
139 AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
140 if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
141 AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
142 Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
143
144 AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
145 if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !");
146 AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject();
147 l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0);
69e96215 148 /*/
a6f3cc02 149 AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("AD/Calib/TimeDelays");
150 if (!entry2) AliFatal("AD time delays are not found in OCDB !");
151 TH1F *delays = (TH1F*)entry2->GetObject();
152
153 AliCDBEntry *entry3 = AliCDBManager::Instance()->Get("AD/Calib/TimeSlewing");
154 if (!entry3) AliFatal("AD time slewing function is not found in OCDB !");
155 fTimeSlewing = (TF1*)entry3->GetObject();
69e96215 156 /*/
a6f3cc02 157
158 for(Int_t i = 0 ; i < 16; ++i) {
159 //Int_t board = AliADCalibData::GetBoardNumber(i);
160 fTimeOffset[i] = (
161 // ((Float_t)fCalibData->GetTriggerCountOffset(board) -
162 // (Float_t)fCalibData->GetRollOver(board))*25.0 +
163 // fCalibData->GetTimeOffset(i) -
164 // l1Delay+
69e96215 165 //delays->GetBinContent(i+1)//+
734ca89d 166 // kADOffset
69e96215 167 0
a6f3cc02 168 );
734ca89d 169 // AliInfo(Form(" fTimeOffset[%d] = %f kADoffset %f",i,fTimeOffset[i],kADOffset));
a6f3cc02 170 }
171
172
173
174
175
176 TTimeStamp currentTime;
177 fCycleStartTime = currentTime.GetSec();
178
179 // fNTotEvents = 0;
180}
181//____________________________________________________________________________
182void AliADQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
183{
184 // Detector specific actions at end of cycle
185 // Does the QA checking
186 ResetEventTrigClasses();
187 //
188 AliQAChecker::Instance()->Run(AliQAv1::kAD, task, list) ;
189
190 if(task == AliQAv1::kRAWS){
191 TTimeStamp currentTime;
192 fCycleStopTime = currentTime.GetSec();
193 }
194
195 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
196 if (! IsValidEventSpecie(specie, list)) continue ;
197 SetEventSpecie(AliRecoParam::ConvertIndex(specie));
198 if(task == AliQAv1::kRAWS) {
199 } else if (task == AliQAv1::kESDS) {
200 }
201 }
202}
203
204//____________________________________________________________________________
205void AliADQADataMakerRec::InitESDs()
206{
734ca89d 207 const Bool_t expert = kTRUE ;
208 const Bool_t image = kTRUE ;
209
210 TH2F * h2d;
211 TH1I * h1i;
212 TH1F * h1d;
213
214 h1i = new TH1I("H1I_Cell_Multiplicity_ADA", "Cell Multiplicity in ADA;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;
215 Add2ESDsList(h1i, kCellMultiADA, !expert, image) ;
216
217 h1i = new TH1I("H1I_Cell_Multiplicity_ADC", "Cell Multiplicity in AD;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;
218 Add2ESDsList(h1i, kCellMultiADC, !expert, image) ;
219
220 h1d = new TH1F("H1D_BBFlag_Counters", "BB Flag Counters;Channel;Counts",64, 0, 64) ;
221 Add2ESDsList(h1d, kBBFlag, !expert, image) ;
222
223 h1d = new TH1F("H1D_BGFlag_Counters", "BG Flag Counters;Channel;Counts",64, 0, 64) ;
224 Add2ESDsList(h1d, kBGFlag, !expert, image) ;
225
226 h2d = new TH2F("H2D_Charge_Channel", "ADC Charge per channel;Channel;Charge (ADC counts)",64, 0, 64, 1024, 0, 1024) ;
227 Add2ESDsList(h2d, kChargeChannel, !expert, image) ;
228
229 h2d = new TH2F("H2D_Time_Channel", "Time per channel;Channel;Time (ns)",64, 0, 64, 400, -100, 100) ;
230 Add2ESDsList(h2d, kTimeChannel, !expert, image) ;
231
232 h1d = new TH1F("H1D_ADA_Time", "Mean ADA Time;Time (ns);Counts",1000, -100., 100.);
233 Add2ESDsList(h1d,kESDADATime, !expert, image);
234
235 h1d = new TH1F("H1D_ADC_Time", "Mean ADC Time;Time (ns);Counts",1000, -100., 100.);
236 Add2ESDsList(h1d,kESDADCTime, !expert, image);
237
238 h1d = new TH1F("H1D_Diff_Time", "Diff Time ADA - ADC;Diff Time ADA - ADC (ns);Counts",1000, -200., 200.);
239 Add2ESDsList(h1d,kESDDiffTime, !expert, image);
240 //
241 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
a6f3cc02 242}
243
244//____________________________________________________________________________
245void AliADQADataMakerRec::InitDigits()
246{
734ca89d 247// create Digits histograms in Digits subdir
248 const Bool_t expert = kTRUE ;
249 const Bool_t image = kTRUE ;
a6f3cc02 250
734ca89d 251 // create Digits histograms in Digits subdir
252 TH1I * h0 = new TH1I("hDigitMultiplicity", "Digits multiplicity distribution in AD;# of Digits;Entries", 17,-0.5,16.5) ;
253 h0->Sumw2() ;
254 Add2DigitsList(h0, 0, !expert, image) ;
255
256 TH2D * h1 = new TH2D("hDigitLeadingTimePerPM", "Leading time distribution per PM in AD;PM number;Leading Time [ns]",16,0,16, 1000, 200, 300);
257 h1->Sumw2() ;
258 Add2DigitsList(h1, 1, !expert, image) ;
259
260 TH2D * h2 = new TH2D("hDigitTimeWidthPerPM", "Time width distribution per PM in AD;PM number;Time width [ns]",16,0,16, 1000, 0, 100);
261 h2->Sumw2() ;
262 Add2DigitsList(h2, 2, !expert, image) ;
263
264 TH2I * h3 = new TH2I("hDigitChargePerClockPerPM", "Charge array per PM in AD;PM number; Clock",16,0,16,21, -10.5, 10.5);
265 h3->Sumw2();
266 Add2DigitsList(h3, 3, !expert, image) ;
267
268 TH1I * h4 = new TH1I("hDigitBBflagsAD","Number of BB flags in AD; # of BB flags; Entries",17,-0.5,16.5);
269 h4->Sumw2();
270 Add2DigitsList(h4, 4, !expert, image) ;
271
272 TH1I * h5 = new TH1I("hDigitBBflagsADA","Number of BB flags in ADA; # of BB flags; Entries",9,-0.5,8.5);
273 h5->Sumw2();
274 Add2DigitsList(h5, 5, !expert, image) ;
275
276 TH1I * h6 = new TH1I("hDigitBBflagsADC","Number of BB flags in ADC; # of BB flags; Entries",9,-0.5,8.5);
277 h6->Sumw2();
278 Add2DigitsList(h6, 6, !expert, image) ;
279
280 TH2D * h7 = new TH2D("hDigitTotalChargePerPM", "Total Charge per PM in AD;PM number; Charge [ADC counts]",16,0,16,10000,0,10000);
281 h7->Sumw2();
282 Add2DigitsList(h7, 7, !expert, image) ;
283
284 TH2I * h8 = new TH2I("hDigitMaxChargeClockPerPM", "Clock with maximum charge per PM in AD;PM number; Clock ",16,0,16,21, -10.5, 10.5);
285 h8->Sumw2();
286 Add2DigitsList(h8, 8, !expert, image) ;
287
288 //
289 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
a6f3cc02 290}
291
292//____________________________________________________________________________
293void AliADQADataMakerRec::MakeDigits()
294{
734ca89d 295 // makes data from Digits
a6f3cc02 296
734ca89d 297 FillDigitsData(0,fDigitsArray->GetEntriesFast()) ;
298 TIter next(fDigitsArray) ;
299 AliADdigit *ADDigit ;
300 Int_t nBBflagsADA = 0;
301 Int_t nBBflagsADC = 0;
302
303 while ( (ADDigit = dynamic_cast<AliADdigit *>(next())) ) {
304 Int_t totCharge = 0;
305 Int_t PMNumber = ADDigit->PMNumber();
306
307 if(PMNumber<8 && ADDigit->GetBBflag()) nBBflagsADA++;
308 if(PMNumber>7 && ADDigit->GetBBflag()) nBBflagsADC++;
309
310 Short_t adc[21];
311 for(Int_t iClock=0; iClock<21; iClock++) {
312 adc[iClock]= ADDigit->ChargeADC(iClock);
313 FillDigitsData(3, PMNumber,(float)iClock-10,(float)adc[iClock]);
314 totCharge += adc[iClock];
315 }
316
317 FillDigitsData(1,PMNumber,ADDigit->Time());
318 FillDigitsData(2,PMNumber,ADDigit->Width());
319 FillDigitsData(7,PMNumber,totCharge);
320 FillDigitsData(8,PMNumber,TMath::LocMax(21,adc)-10);
321
322 }
323 FillDigitsData(4,nBBflagsADA+nBBflagsADC);
324 FillDigitsData(5,nBBflagsADA);
325 FillDigitsData(6,nBBflagsADC);
a6f3cc02 326}
327
328//____________________________________________________________________________
734ca89d 329void AliADQADataMakerRec::MakeDigits(TTree* digitTree)
a6f3cc02 330{
734ca89d 331 // makes data from Digit Tree
332
333 if (fDigitsArray)
334 fDigitsArray->Clear() ;
335 else
336 fDigitsArray = new TClonesArray("AliADdigit", 1000) ;
337
338 TBranch * branch = digitTree->GetBranch("ADDigit") ;
339 if ( ! branch ) {
340 AliWarning("AD branch in Digit Tree not found") ;
341 } else {
342 branch->SetAddress(&fDigitsArray) ;
343 branch->GetEntry(0) ;
344 MakeDigits() ;
345 }
346 //
347 IncEvCountCycleDigits();
348 IncEvCountTotalDigits();
349 //
a6f3cc02 350}
351
352
353//____________________________________________________________________________
734ca89d 354void AliADQADataMakerRec::MakeESDs(AliESDEvent* esd)
a6f3cc02 355{
734ca89d 356// Creates QA data from ESDs
357
358 UInt_t eventType = esd->GetEventType();
359
360 switch (eventType){
361 case PHYSICS_EVENT:
362 AliESDAD *esdAD=esd->GetADData();
363
364 if (!esdAD) break;
365
366 FillESDsData(kCellMultiADA,esdAD->GetNbPMADA());
367 FillESDsData(kCellMultiADC,esdAD->GetNbPMADC());
368
369 for(Int_t i=0;i<16;i++) {
370 FillESDsData(kChargeChannel,(Float_t) i,(Float_t) esdAD->GetAdc(i));
371 if (i < 8) {
372 if(esdAD->BBTriggerADA(i)) FillESDsData(kBBFlag,(Float_t) i);
373 if(esdAD->BGTriggerADA(i)) FillESDsData(kBGFlag,(Float_t) i);
374 }
375 else {
376 if(esdAD->BBTriggerADC(i-8)) FillESDsData(kBBFlag,(Float_t) i);
377 if(esdAD->BGTriggerADC(i-8)) FillESDsData(kBGFlag,(Float_t) i);
378 }
379 Float_t time = (Float_t) esdAD->GetTime(i);
380 FillESDsData(kTimeChannel,(Float_t) i,time);
381 }
382
383 Float_t timeADA = esdAD->GetADATime();
384 Float_t timeADC = esdAD->GetADCTime();
385 Float_t diffTime;
386
387 if(timeADA<-1024.+1.e-6 || timeADC<-1024.+1.e-6) diffTime = -1024.;
388 else diffTime = timeADA - timeADC;
389
390 FillESDsData(kESDADATime,timeADA);
391 FillESDsData(kESDADCTime,timeADC);
392 FillESDsData(kESDDiffTime,diffTime);
393
394 break;
395 }
396 //
397 IncEvCountCycleESDs();
398 IncEvCountTotalESDs();
399 //
a6f3cc02 400}
401
402//____________________________________________________________________________
403void AliADQADataMakerRec::InitRaws()
404{
405 // Creates RAW histograms in Raws subdir
406
407 const Bool_t expert = kTRUE ;
408 const Bool_t saveCorr = kTRUE ;
409 const Bool_t image = kTRUE ;
410
411 const Int_t kNintegrator = 2;
412
413 const Int_t kNTdcTimeBins = 1280;
414 const Float_t kTdcTimeMin = 0.;
415 const Float_t kTdcTimeMax = 75.;
416 const Int_t kNTdcWidthBins = 256;
417 const Float_t kTdcWidthMin = 0;
418 const Float_t kTdcWidthMax = 200.;
419 const Int_t kNChargeBins = 1024;
420 const Float_t kChargeMin = 0;
421 const Float_t kChargeMax = 1024;
422 const Int_t kNChannelBins = 16;
423 const Float_t kChannelMin = 0;
424 const Float_t kChannelMax = 16;
425 const Int_t kNPedestalBins = 200;
426 const Float_t kPedestalMin = 0;
69e96215 427 const Float_t kPedestalMax = 200;
428 const Int_t kNPairBins = 8;
429 const Float_t kPairMin = 0;
430 const Float_t kPairMax = 8;
a6f3cc02 431
432 TH2I * h2i;
433 TH2F * h2d;
434 TH1I * h1i;
435 TH1F * h1d;
436
437 int iHisto =0;
438
439 // Creation of Cell Multiplicity Histograms
69e96215 440 h1i = new TH1I("H1I_Multiplicity_ADA", "Number of fired cells in ADA;# of Cells;Entries", 10, 0, 10) ;
a6f3cc02 441 Add2RawsList(h1i,kMultiADA, !expert, image, saveCorr); iHisto++;
69e96215 442 h1i = new TH1I("H1I_Multiplicity_ADC", "Number of fired cells in ADC;# of Cells;Entries", 10, 0, 10) ;
a6f3cc02 443 Add2RawsList(h1i,kMultiADC, !expert, image, saveCorr); iHisto++;
444
445 // Creation of Total Charge Histograms
446 h1d = new TH1F("H1D_Charge_ADA", "Total Charge in ADA;Charge [ADC counts];Counts", 4000, 0, 30000) ;
447 Add2RawsList(h1d,kChargeADA, !expert, image, saveCorr); iHisto++;
448 h1d = new TH1F("H1D_Charge_ADC", "Total Charge in ADC;Charge [ADC counts];Counts", 4000, 0, 50000) ;
449 Add2RawsList(h1d,kChargeADC, !expert, image, saveCorr); iHisto++;
450 h1d = new TH1F("H1D_Charge_AD", "Total Charge in AD;Charge [ADC counts];Counts", 4000, 0, 80000) ;
451 Add2RawsList(h1d,kChargeAD, !expert, image, saveCorr); iHisto++;
452
453
454 // Creation of Charge EoI histogram
455 h2d = new TH2F("H2D_ChargeEoI", "Charge Event of Interest;Channel Number;Charge [ADC counts]"
456 ,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, 2.*kChargeMax);
457 Add2RawsList(h2d,kChargeEoI, !expert, image, saveCorr); iHisto++;
458
459 for(Int_t iInt=0;iInt<kNintegrator;iInt++){
460 // Creation of Pedestal histograms
461 h2i = new TH2I(Form("H2I_Pedestal_Int%d",iInt), Form("Pedestal (Int%d);Channel;Pedestal [ADC counts]",iInt)
462 ,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
463 Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), !expert, image, saveCorr); iHisto++;
464
465
466 // Creation of Charge EoI histograms
467 h2i = new TH2I(Form("H2I_ChargeEoI_Int%d",iInt), Form("Charge EoI (Int%d);Channel;Charge [ADC counts]",iInt)
468 ,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
469 Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), !expert, image, saveCorr); iHisto++;
470
471 }
472
473 // Creation of Time histograms
474 h2i = new TH2I("H2I_Width", "HPTDC Width;Channel;Width [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
475 Add2RawsList(h2i,kWidth, !expert, image, saveCorr); iHisto++;
cf283524 476
477 h2i = new TH2I("H2I_Width_BB", "HPTDC Width w/ BB Flag condition;Channel;Width [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
478 Add2RawsList(h2i,kWidthBB, !expert, image, saveCorr); iHisto++;
479
480 h2i = new TH2I("H2I_Width_BG", "HPTDC Width w/ BG Flag condition;Channel;Width [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
481 Add2RawsList(h2i,kWidthBG, !expert, image, saveCorr); iHisto++;
a6f3cc02 482
483 h2i = new TH2I("H2I_HPTDCTime", "HPTDC Time;Channel;Leading Time [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
484 Add2RawsList(h2i,kHPTDCTime, !expert, image, saveCorr); iHisto++;
cf283524 485
486 h2i = new TH2I("H2I_HPTDCTime_BB", "HPTDC Time w/ BB Flag condition;Channel;Leading Time [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
487 Add2RawsList(h2i,kHPTDCTimeBB, !expert, image, !saveCorr); iHisto++;
488
489 h2i = new TH2I("H2I_HPTDCTime_BG", "HPTDC Time w/ BG Flag condition;Channel;Leading Time [ns]",kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
490 Add2RawsList(h2i,kHPTDCTimeBG, !expert, image, !saveCorr); iHisto++;
a6f3cc02 491
492 h1d = new TH1F("H1D_ADA_Time", "ADA Time;Time [ns];Counts",kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
493 Add2RawsList(h1d,kADATime, !expert, image, saveCorr); iHisto++;
494
495 h1d = new TH1F("H1D_ADC_Time", "ADC Time;Time [ns];Counts",kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
496 Add2RawsList(h1d,kADCTime, !expert, image, saveCorr); iHisto++;
497
498 h1d = new TH1F("H1D_Diff_Time","Diff ADA-ADC Time;Time [ns];Counts",kNTdcTimeBins, -50., 50.);
499 Add2RawsList(h1d,kDiffTime, !expert, image, saveCorr); iHisto++;
500
501 h2d = new TH2F("H2D_TimeADA_ADC", "Mean Time in ADC versus ADA;Time ADA [ns];Time ADC [ns]", kNTdcTimeBins/8, kTdcTimeMin,kTdcTimeMax,kNTdcTimeBins/8, kTdcTimeMin,kTdcTimeMax) ;
502 Add2RawsList(h2d,kTimeADAADC, !expert, image, saveCorr); iHisto++;
503
69e96215 504 //Creation of pair coincidence histograms
b8cf9c79 505 h1i = new TH1I("H1I_MultiCoincidence_ADA", "Number of coincidences in ADA;# of Coincidences;Entries", 5, 0, 5) ;
69e96215 506 Add2RawsList(h1i,kNCoincADA, !expert, image, saveCorr); iHisto++;
b8cf9c79 507 h1i = new TH1I("H1I_MultiCoincidence_ADC", "Number of coincidences in ADC;# of Coincidences;Entries", 5, 0, 5) ;
69e96215 508 Add2RawsList(h1i,kNCoincADC, !expert, image, saveCorr); iHisto++;
509
b8cf9c79 510 h2d = new TH2F("H2D_Pair_Diff_Time","Diff Pair Time;Pair number;Time [ns]",kNPairBins, kPairMin, kPairMax,kNTdcTimeBins, -50., 50.);
69e96215 511 Add2RawsList(h2d,kPairDiffTime, !expert, image, saveCorr); iHisto++;
b8cf9c79 512
513 h2d = new TH2F("H2D_Pair_Diff_Charge","Diff Pair Charge;Pair number;Charge [ADC counts]",kNPairBins, kPairMin, kPairMax, 2*kNChargeBins, -kChargeMax, kChargeMax);
514 Add2RawsList(h2d,kPairDiffCharge, !expert, image, saveCorr); iHisto++;
a6f3cc02 515
cf283524 516 //Creation of Clock histograms
517 h2d = new TH2F("H2D_BBFlagVsClock", "BB-Flags Versus LHC-Clock;Channel;LHC Clocks",kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
518 Add2RawsList(h2d,kBBFlagVsClock, !expert, image, saveCorr); iHisto++;
519
520 h2d = new TH2F("H2D_BGFlagVsClock", "BG-Flags Versus LHC-Clock;Channel;LHC Clocks",kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
521 Add2RawsList(h2d,kBGFlagVsClock, !expert, image, saveCorr); iHisto++;
522
523 for(Int_t iInt=0;iInt<kNintegrator;iInt++){
524 h2d = new TH2F(Form("H2D_ChargeVsClock_Int%d",iInt), Form("Charge Versus LHC-Clock (Int%d);Channel;LHCClock;Charge [ADC counts]",iInt),kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
4462d42f 525 Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), !expert, image, saveCorr); iHisto++;
cf283524 526 }
527
78c1b015 528 h2d = new TH2F("H2D_BBFlagPerChannel", "BB-Flags Versus Channel;Channel;BB Flags Count",kNChannelBins, kChannelMin, kChannelMax,22,-0.5,21.5);
95930403 529 Add2RawsList(h2d,kBBFlagsPerChannel, !expert, image, saveCorr); iHisto++;
530
531 h2d = new TH2F("H2D_BGFlagPerChannel", "BG-Flags Versus Channel;Channel;BG Flags Count",kNChannelBins, kChannelMin, kChannelMax,22,-0.5,21.5);
532 Add2RawsList(h2d,kBGFlagsPerChannel, !expert, image, saveCorr); iHisto++;
69e96215 533
a6f3cc02 534 AliDebug(AliQAv1::GetQADebugLevel(), Form("%d Histograms has been added to the Raws List",iHisto));
535 //
536 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
537}
538
539//____________________________________________________________________________
540void AliADQADataMakerRec::MakeRaws(AliRawReader* rawReader)
541{
542 // Fills histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
543
544
545 // Check id histograms already created for this Event Specie
546 if ( ! GetRawsData(kPedestalInt0) )
547 InitRaws() ;
548
549 rawReader->Reset() ;
550 AliADRawStream* rawStream = new AliADRawStream(rawReader);
551 if(!(rawStream->Next())) return;
552
553 eventTypeType eventType = rawReader->GetType();
554
555 Int_t mulADA = 0 ;
556 Int_t mulADC = 0 ;
557 Double_t timeADA =0., timeADC = 0.;
558 Double_t weightADA =0., weightADC = 0.;
559 UInt_t itimeADA=0, itimeADC=0;
560 Double_t chargeADA=0., chargeADC=0.;
561
562 Double_t diffTime=-100000.;
69e96215 563
564 Int_t pmulADA = 0;
565 Int_t pmulADC = 0;
566 Double_t pDiffTime =-100000.;
a6f3cc02 567
568
569 switch (eventType){
570 case PHYSICS_EVENT:
571
572 // fNTotEvents++; // Use framework counters instead
573
574 Int_t iFlag=0;
575 Int_t pedestal;
69e96215 576 Int_t integrator[16];
a6f3cc02 577 Bool_t flagBB[16];
578 Bool_t flagBG[16];
579 Float_t charge;
580 Int_t offlineCh;
581 Float_t adc[16], time[16], width[16], timeCorr[16];
69e96215 582 Int_t iPair=0;
a6f3cc02 583
584 for(Int_t iChannel=0; iChannel<16; iChannel++) { // BEGIN : Loop over channels
585
586 offlineCh = rawStream->GetOfflineChannel(iChannel);
587
588 // Fill Pedestal histograms
589
590 for(Int_t j=15; j<21; j++) {
591 if((rawStream->GetBGFlag(iChannel,j) || rawStream->GetBBFlag(iChannel,j))) iFlag++;
592 }
593
594 if(iFlag == 0){ //No Flag found
595 for(Int_t j=15; j<21; j++){
596 pedestal= (Int_t) rawStream->GetPedestal(iChannel, j);
69e96215 597 integrator[offlineCh] = rawStream->GetIntegratorFlag(iChannel, j);
a6f3cc02 598
69e96215 599 FillRawsData((integrator[offlineCh] == 0 ? kPedestalInt0 : kPedestalInt1),offlineCh,pedestal);
a6f3cc02 600 }
601 }
602
603 // Fill Charge EoI histograms
604
605 adc[offlineCh] = 0.0;
606
607 // Search for the maximum charge in the train of 21 LHC clocks
608 // regardless of the integrator which has been operated:
609 Float_t maxadc = 0;
610 Int_t imax = -1;
611 Float_t adcPedSub[21];
612 for(Int_t iClock=0; iClock<21; iClock++){
613 Bool_t iIntegrator = rawStream->GetIntegratorFlag(iChannel,iClock);
69e96215 614 Int_t k = offlineCh+16*iIntegrator;
a6f3cc02 615
a6f3cc02 616 adcPedSub[iClock] = rawStream->GetPedestal(iChannel,iClock) - fCalibData->GetPedestal(k);
617 // if(adcPedSub[iClock] <= GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k)) {
618 if(adcPedSub[iClock] <= 2.*fCalibData->GetSigma(k)) {
619 adcPedSub[iClock] = 0;
620 continue;
621 }
622 // if(iClock < GetRecoParam()->GetStartClock() || iClock > GetRecoParam()->GetEndClock()) continue;
623 if(iClock < 8 || iClock > 12) continue;
624 if(adcPedSub[iClock] > maxadc) {
625 maxadc = adcPedSub[iClock];
626 imax = iClock;
627 }
628 }
629 //printf(Form("Channel %d (online), %d (offline)\n",iChannel,j));
630 if (imax != -1) {
631 // Int_t start = imax - GetRecoParam()->GetNPreClocks();
632 Int_t start = imax - 2;
633 if (start < 0) start = 0;
634 // Int_t end = imax + GetRecoParam()->GetNPostClocks();
635 Int_t end = imax + 1;
636 if (end > 20) end = 20;
637 for(Int_t iClock = start; iClock <= end; iClock++) {
638 adc[offlineCh] += adcPedSub[iClock];
639 }
640 }
641
642
643 Int_t iClock = imax;
644 charge = rawStream->GetPedestal(iChannel,iClock); // Charge at the maximum
645
69e96215 646 integrator[offlineCh] = rawStream->GetIntegratorFlag(iChannel,iClock);
a6f3cc02 647 flagBB[offlineCh] = rawStream->GetBBFlag(iChannel, iClock);
648 flagBG[offlineCh] = rawStream->GetBGFlag(iChannel,iClock );
649 Int_t board = AliADCalibData::GetBoardNumber(offlineCh);
650 time[offlineCh] = rawStream->GetTime(iChannel)*fCalibData->GetTimeResolution(board);
651 width[offlineCh] = rawStream->GetWidth(iChannel)*fCalibData->GetWidthResolution(board);
652
653 if (time[offlineCh] >= 1e-6) FillRawsData(kChargeEoI,offlineCh,adc[offlineCh]);
654
69e96215 655 FillRawsData((integrator[offlineCh] == 0 ? kChargeEoIInt0 : kChargeEoIInt1),offlineCh,charge);
a6f3cc02 656
69e96215 657 Float_t sigma = fCalibData->GetSigma(offlineCh+16*integrator[offlineCh]);
a6f3cc02 658
659 if((adc[offlineCh] > 2.*sigma) && !(time[offlineCh] <1.e-6)){
660 if(offlineCh<8) {
661 mulADC++;
662 chargeADC += adc[offlineCh];
663
664 } else {
665 mulADA++;
666 chargeADA += adc[offlineCh];
667 }
668 }
669
670
671 // Fill HPTDC Time Histograms
2614dca2 672 //timeCorr[offlineCh] = CorrectLeadingTime(offlineCh,time[offlineCh],adc[offlineCh]);
673 timeCorr[offlineCh] = time[offlineCh];
a6f3cc02 674
fcb6ff8b 675 //const Float_t p1 = 2.50; // photostatistics term in the time resolution
676 //const Float_t p2 = 3.00; // sleewing related term in the time resolution
a6f3cc02 677 if(timeCorr[offlineCh]>-1024 + 1.e-6){
fcb6ff8b 678 //Float_t nphe = adc[offlineCh]*kChargePerADC/(fCalibData->GetGain(offlineCh)*TMath::Qe());
69e96215 679 Float_t timeErr = 1;
680 /*/
a6f3cc02 681 if (nphe>1.e-6) timeErr = TMath::Sqrt(kIntTimeRes*kIntTimeRes+
682 p1*p1/nphe+
683 p2*p2*(fTimeSlewing->GetParameter(0)*fTimeSlewing->GetParameter(1))*(fTimeSlewing->GetParameter(0)*fTimeSlewing->GetParameter(1))*
684 TMath::Power(adc[offlineCh]/fCalibData->GetCalibDiscriThr(offlineCh,kTRUE),2.*(fTimeSlewing->GetParameter(1)-1.))/
69e96215 685 (fCalibData->GetCalibDiscriThr(offlineCh,kTRUE)*fCalibData->GetCalibDiscriThr(offlineCh,kTRUE)));/*/
a6f3cc02 686
687 if (timeErr>1.e-6) {
688 if (offlineCh<8) {
689 itimeADC++;
690 timeADC += timeCorr[offlineCh]/(timeErr*timeErr);
691 weightADC += 1./(timeErr*timeErr);
692 }else{
693 itimeADA++;
694 timeADA += timeCorr[offlineCh]/(timeErr*timeErr);
695 weightADA += 1./(timeErr*timeErr);
696 }
697 }
698 }
cf283524 699
95930403 700 // Fill Flag and Charge Versus LHC-Clock histograms
78c1b015 701 Int_t nbbFlag = 0;
95930403 702 Int_t nbgFlag = 0;
78c1b015 703
cf283524 704 for(Int_t iEvent=0; iEvent<21; iEvent++){
705 charge = rawStream->GetPedestal(iChannel,iEvent);
706 Int_t intgr = rawStream->GetIntegratorFlag(iChannel,iEvent);
707 Bool_t bbFlag = rawStream->GetBBFlag(iChannel, iEvent);
708 Bool_t bgFlag = rawStream->GetBGFlag(iChannel,iEvent );
78c1b015 709 if(bbFlag) nbbFlag++;
95930403 710 if(bgFlag) nbgFlag++;
78c1b015 711
cf283524 712 FillRawsData((intgr == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), offlineCh,(float)iEvent-10,(float)charge);
713 FillRawsData(kBBFlagVsClock, offlineCh,(float)iEvent-10,(float)bbFlag);
714 FillRawsData(kBGFlagVsClock, offlineCh,(float)iEvent-10,(float)bgFlag);
78c1b015 715
cf283524 716 }
78c1b015 717 FillRawsData(kBBFlagsPerChannel, offlineCh,nbbFlag);
95930403 718 FillRawsData(kBGFlagsPerChannel, offlineCh,nbgFlag);
719
720 FillRawsData(kHPTDCTime,offlineCh,timeCorr[offlineCh]);
721 FillRawsData(kWidth,offlineCh,width[offlineCh]);
722 //if(flagBB[offlineCh]) {
723 if(nbbFlag > 0){
724 FillRawsData(kHPTDCTimeBB,offlineCh,timeCorr[offlineCh]);
725 FillRawsData(kWidthBB,offlineCh,width[offlineCh]);
726 }
727 //if(flagBG[offlineCh]) {
728 if(nbgFlag > 0){
729 FillRawsData(kHPTDCTimeBG,offlineCh,timeCorr[offlineCh]);
730 FillRawsData(kWidthBG,offlineCh,width[offlineCh]);
731 }
732
a6f3cc02 733
734 }// END of Loop over channels
69e96215 735
736 for(Int_t iChannel=0; iChannel<4; iChannel++) {//Loop over pairs ADC
737 offlineCh = rawStream->GetOfflineChannel(iChannel);
738 Float_t sigma = fCalibData->GetSigma(offlineCh+16*integrator[offlineCh]);
739 Float_t sigma4 = fCalibData->GetSigma(offlineCh+4+16*integrator[offlineCh]);
740 if( ((adc[offlineCh] > 2.*sigma) && !(time[offlineCh] <1.e-6)) && ((adc[offlineCh+4] > 2.*sigma4) && !(time[offlineCh+4] <1.e-6)) ){
741 pmulADC++;
742 if(timeCorr[offlineCh]<-1024.+1.e-6 || timeCorr[offlineCh+4]<-1024.+1.e-6) pDiffTime = -1024.;
743 else pDiffTime = timeCorr[offlineCh+4] - timeCorr[offlineCh];
744 FillRawsData(kPairDiffTime,iPair,pDiffTime);
69e96215 745 }
b8cf9c79 746 FillRawsData(kPairDiffCharge,iPair,TMath::Abs(adc[offlineCh]-adc[offlineCh+4]));
747 iPair++;
69e96215 748 }
749 for(Int_t iChannel=8; iChannel<12; iChannel++) {//Loop over pairs ADA
750 offlineCh = rawStream->GetOfflineChannel(iChannel);
751 Float_t sigma = fCalibData->GetSigma(offlineCh+16*integrator[offlineCh]);
752 Float_t sigma4 = fCalibData->GetSigma(offlineCh+4+16*integrator[offlineCh]);
b8cf9c79 753 if( ((adc[offlineCh] > 2.*sigma) && !(time[offlineCh] <1.e-6)) && ((adc[offlineCh+4] > 2.*sigma4) && !(time[offlineCh+4] <1.e-6)) ){
754 pmulADA++;
755 if(timeCorr[offlineCh]<-1024.+1.e-6 || timeCorr[offlineCh+4]<-1024.+1.e-6) pDiffTime = -1024.;
69e96215 756 else pDiffTime = timeCorr[offlineCh+4] - timeCorr[offlineCh];
757 FillRawsData(kPairDiffTime,iPair,pDiffTime);
b8cf9c79 758 }
759 FillRawsData(kPairDiffCharge,iPair,TMath::Abs(adc[offlineCh]-adc[offlineCh+4]));
760 iPair++;
69e96215 761 }
762 FillRawsData(kNCoincADA,pmulADA);
763 FillRawsData(kNCoincADC,pmulADC);
764
765
a6f3cc02 766 if(weightADA>1.e-6) timeADA /= weightADA;
767 else timeADA = -1024.;
768 if(weightADC>1.e-6) timeADC /= weightADC;
769 else timeADC = -1024.;
770 if(timeADA<-1024.+1.e-6 || timeADC<-1024.+1.e-6) diffTime = -1024.;
771 else diffTime = timeADA - timeADC;
772
773
774
775 FillRawsData(kADATime,timeADA);
776 FillRawsData(kADCTime,timeADC);
777 FillRawsData(kDiffTime,diffTime);
778 FillRawsData(kTimeADAADC,timeADA,timeADC);
779
780 FillRawsData(kMultiADA,mulADA);
781 FillRawsData(kMultiADC,mulADC);
782
783 FillRawsData(kChargeADA,chargeADA);
784 FillRawsData(kChargeADC,chargeADC);
785 FillRawsData(kChargeAD,chargeADA + chargeADC);
786
787 break;
788 } // END of SWITCH : EVENT TYPE
789
790 TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiADA)->GetName()))) ;
791 if (p) p->SetVal((double)mulADA) ;
792
793 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiADC)->GetName()))) ;
794 if (p) p->SetVal((double)mulADC) ;
795
796 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeADA)->GetName()))) ;
797 if (p) p->SetVal((double)chargeADA) ;
798
799 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeADC)->GetName()))) ;
800 if (p) p->SetVal((double)chargeADC) ;
801
802 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeAD)->GetName()))) ;
803 if (p) p->SetVal((double)(chargeADA + chargeADC)) ;
804
805 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kADATime)->GetName()))) ;
806 if (p) p->SetVal((double)timeADA) ;
807
808 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kADCTime)->GetName()))) ;
809 if (p) p->SetVal((double)timeADC) ;
810
811 p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ;
812 if (p) p->SetVal((double)diffTime) ;
813
814 delete rawStream; rawStream = 0x0;
815 //
816 IncEvCountCycleRaws();
817 IncEvCountTotalRaws();
818 //
819}
820
821//____________________________________________________________________________
fcb6ff8b 822Float_t AliADQADataMakerRec::CorrectLeadingTime(Int_t /*i*/, Float_t time, Float_t /*adc*/) const
a6f3cc02 823{
824 // Correct the leading time
825 // for slewing effect and
826 // misalignment of the channels
827 if (time < 1e-6) return -1024;
828
829 // Channel alignment and general offset subtraction
a6f3cc02 830 // time -= fTimeOffset[i];
831 //AliInfo(Form("time-offset %f", time));
832
833 // In case of pathological signals
69e96215 834 //if (adc < 1e-6) return time;
a6f3cc02 835
836 // Slewing correction
69e96215 837 //Float_t thr = fCalibData->GetCalibDiscriThr(i,kTRUE);
a6f3cc02 838 //AliInfo(Form("adc %f thr %f dtime %f ", adc,thr,fTimeSlewing->Eval(adc/thr)));
69e96215 839 //time -= fTimeSlewing->Eval(adc/thr);
a6f3cc02 840
841 return time;
842}
843