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