]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCQADataMakerRec.cxx
Add drawer of empirical
[u/mrichter/AliRoot.git] / ZDC / AliZDCQADataMakerRec.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 //                                                                   //
18 //  Produces the data needed to calculate the ZDC quality assurance. //
19 //  QA objects are 1 & 2 Dimensional histograms.                     //
20 //  author: C. Oppedisano                                            //
21 //                                                                   //
22 ///////////////////////////////////////////////////////////////////////
23
24 // --- ROOT system ---
25 #include <TClonesArray.h>
26 #include <TFile.h> 
27 #include <TH1F.h> 
28 #include <TH2F.h>
29 #include <TLine.h>
30 #include <TProfile.h>
31 #include <Riostream.h>
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliLog.h"
36 #include "AliQAChecker.h"
37 #include "AliZDCReco.h"
38 #include "AliRawReader.h"
39 #include "AliZDCQADataMakerRec.h"
40 #include "AliZDCPedestals.h"
41 #include "AliZDCRawStream.h"
42 #include "AliZDCDigit.h"
43 #include "AliESDZDC.h"
44 #include "AliESDEvent.h"
45
46 ClassImp(AliZDCQADataMakerRec)
47            
48 //____________________________________________________________________________ 
49   AliZDCQADataMakerRec::AliZDCQADataMakerRec() : 
50   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kZDC), "ZDC Quality Assurance Data Maker"), 
51   fPedCalibData(0x0)
52 {
53   // ctor
54 }
55
56 //____________________________________________________________________________ 
57 AliZDCQADataMakerRec::AliZDCQADataMakerRec(const AliZDCQADataMakerRec& qadm) :
58   AliQADataMakerRec(),      
59   fPedCalibData(qadm.fPedCalibData)
60
61 {
62   //copy ctor 
63   SetName((const char*)qadm.GetName()); 
64   SetTitle((const char*)qadm.GetTitle()); 
65 }
66
67 //__________________________________________________________________
68 AliZDCQADataMakerRec& AliZDCQADataMakerRec::operator = (const AliZDCQADataMakerRec& qadm )
69 {
70   // Equal operator.
71   this->~AliZDCQADataMakerRec();
72   new(this) AliZDCQADataMakerRec(qadm);
73   return *this;
74 }
75
76 //____________________________________________________________________________ 
77 AliZDCQADataMakerRec::~AliZDCQADataMakerRec()
78 {
79   if(fPedCalibData && !(AliCDBManager::Instance()->GetCacheFlag())){
80     delete fPedCalibData;
81     fPedCalibData=0;
82   } 
83 }
84
85 //____________________________________________________________________________ 
86 AliZDCPedestals* AliZDCQADataMakerRec::GetPedCalibData() const
87 {
88
89   // Retrieving pedestal calibration object from OCDB
90   AliZDCPedestals *calibdata = 0x0;
91   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Pedestals");
92   if(!entry) AliWarning("No calibration data loaded!");  
93   else{
94     calibdata = (AliZDCPedestals*)  (entry->GetObject());
95     if(!calibdata) AliFatal("Wrong calibration object in calibration  file!");
96   }
97   return calibdata;
98
99 }
100
101 //____________________________________________________________________________ 
102 void AliZDCQADataMakerRec::InitDigits()
103 {
104   // create Digits histograms in Digits subdir
105   //
106   const Bool_t expert   = kTRUE ; 
107   const Bool_t image    = kTRUE ; 
108   
109   // ------------------- HIGH GAIN CHAIN ---------------------------
110   TH1F * hDigZNCTot = new TH1F("hDigZNCTot", "Signal in ZNC;Amplitude [ADC counts];Counts", 100, 0., 6000.);
111   TH1F * hDigZNATot = new TH1F("hDigZNATot", "Signal in ZNA;Amplitude [ADC counts];Counts", 100, 0., 6000.);
112   TH1F * hDigZPCTot = new TH1F("hDigZPCTot", "Signal in ZPC;Amplitude [ADC counts];Counts", 100, 0., 6000.);
113   TH1F * hDigZPATot = new TH1F("hDigZPATot", "Signal in ZPA;Amplitude [ADC counts];Counts", 100, 0., 6000.);
114   Add2DigitsList(hDigZNCTot, 0, !expert, image);
115   Add2DigitsList(hDigZNATot, 1, !expert, image);
116   Add2DigitsList(hDigZPCTot, 2, !expert, image);
117   Add2DigitsList(hDigZPATot, 3, !expert, image);
118   //
119   TH1F * hDigSumQZNC = new TH1F("hDigSumQZNC", "Signal in 4 ZNC PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
120   TH1F * hDigSumQZNA = new TH1F("hDigSumQZNA", "Signal in 4 ZNA PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
121   TH1F * hDigSumQZPC = new TH1F("hDigSumQZPC", "Signal in 4 ZPC PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
122   TH1F * hDigSumQZPA = new TH1F("hDigSumQZPA", "Signal in 4 ZPA PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
123   Add2DigitsList(hDigSumQZNC, 4, expert, !image);
124   Add2DigitsList(hDigSumQZNA, 5, expert, !image);
125   Add2DigitsList(hDigSumQZPC, 6, expert, !image);
126   Add2DigitsList(hDigSumQZPA, 7, expert, !image);
127   //
128   TH1F * hDigPMCZNC = new TH1F("hDigPMCZNC", "Signal in ZNC PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
129   TH1F * hDigPMCZNA = new TH1F("hDigPMCZNA", "Signal in ZNA PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
130   TH1F * hDigPMCZPC = new TH1F("hDigPMCZPC", "Signal in ZPC PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
131   TH1F * hDigPMCZPA = new TH1F("hDigPMCZPA", "Signal in ZPA PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
132   Add2DigitsList(hDigPMCZNC, 8, expert, !image);
133   Add2DigitsList(hDigPMCZNA, 9, expert, !image);
134   Add2DigitsList(hDigPMCZPC, 10, expert, !image);
135   Add2DigitsList(hDigPMCZPA, 11, expert, !image);
136   // 
137   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
138 }
139
140 //____________________________________________________________________________
141 void AliZDCQADataMakerRec::InitRaws()
142 {
143   // create Digits histograms in Digits subdir
144   const Bool_t expert   = kTRUE ; 
145   const Bool_t image    = kTRUE ; 
146
147   TH1F * hZNCSpectrum = new TH1F("hZNCSpectrum","ZNC spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
148   TH1F * hZPCSpectrum = new TH1F("hZPCSpectrum","ZPC spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
149   TH1F * hZNASpectrum = new TH1F("hZNASpectrum","ZNA spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
150   TH1F * hZPASpectrum = new TH1F("hZPASpectrum","ZPA spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
151   // Booking from ch. 8 for checked signals to avoid running QA on pedestals!
152   TH1F * hZEM1Spectrum = new TH1F("hZEM1Spectrum","ZEM1 spectrum;Amplitude [ADC counts];Counts",100,8., 1208.);
153   TH1F * hZEM2Spectrum = new TH1F("hZEM2Spectrum","ZEM2 spectrum;Amplitude [ADC counts];Counts",100,8., 1208.);
154   Add2RawsList(hZNCSpectrum, 0, expert, !image);
155   Add2RawsList(hZNASpectrum, 1, expert, !image);
156   Add2RawsList(hZPCSpectrum, 2, expert, !image);
157   Add2RawsList(hZPASpectrum, 3, expert, !image);
158   Add2RawsList(hZEM1Spectrum, 4, expert, !image);
159   Add2RawsList(hZEM2Spectrum, 5, expert, !image);
160     
161   TH1F * hRawPMCZNC = new TH1F("hRawPMCZNC", "Raw ZNC PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
162   TH1F * hRawPMCZNA = new TH1F("hRawPMCZNA", "Raw ZNA PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
163   TH1F * hRawPMCZPC = new TH1F("hRawPMCZPC", "Raw ZPC PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
164   TH1F * hRawPMCZPA = new TH1F("hRawPMCZPA", "Raw ZPA PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
165   Add2RawsList(hRawPMCZNC, 6, expert, !image);
166   Add2RawsList(hRawPMCZNA, 7, expert, !image);
167   Add2RawsList(hRawPMCZPC, 8, expert, !image);
168   Add2RawsList(hRawPMCZPA, 9, expert, !image);
169   TH1F * hRawSumQZNC = new TH1F("hRawSumQZNC", "Raw sumQ ZNC;Amplitude [ADC counts];Counts",100, 0., 1200.);
170   TH1F * hRawSumQZNA = new TH1F("hRawSumQZNA", "Raw sumQ ZNA;Amplitude [ADC counts];Counts",100, 0., 1200.);
171   TH1F * hRawSumQZPC = new TH1F("hRawSumQZPC", "Raw sumQ ZPC;Amplitude [ADC counts];Counts",100, 0., 1200.);
172   TH1F * hRawSumQZPA = new TH1F("hRawSumQZPA", "Raw sumQ ZPA;Amplitude [ADC counts];Counts",100, 0., 1200.);
173   Add2RawsList(hRawSumQZNC, 10, expert, !image);
174   Add2RawsList(hRawSumQZNA, 11, expert, !image);
175   Add2RawsList(hRawSumQZPC, 12, expert, !image);
176   Add2RawsList(hRawSumQZPA, 13, expert, !image);
177   
178   TH1F * hRawTDCZNC = new TH1F("hRawTDCZNC", "TDC ZNC;TDC [ns]",160, -320., -260.);
179   Add2RawsList(hRawTDCZNC, 14, expert, !image);
180   TH1F * hRawTDCZPC = new TH1F("hRawTDCZPC", "TDC ZPC;TDC [ns]",160, -340., -280.);
181   Add2RawsList(hRawTDCZPC, 15, expert, !image);
182   TH1F * hRawTDCZNA = new TH1F("hRawTDCZNA", "TDC ZNA;TDC [ns]",160, -340., -280.);
183   Add2RawsList(hRawTDCZNA, 16, expert, !image);
184   TH1F * hRawTDCZPA = new TH1F("hRawTDCZPA", "TDC ZPA;TDC [ns]",160, -340., -280.);
185   Add2RawsList(hRawTDCZPA, 17, expert, !image);
186   TH1F * hRawTDCZEM1 = new TH1F("hRawTDCZEM1", "TDC ZEM1;TDC [ns]",160, -320., -280.);
187   Add2RawsList(hRawTDCZEM1, 18, expert, !image);
188   TH1F * hRawTDCZEM2 = new TH1F("hRawTDCZEM2", "TDC ZEM2;TDC [ns]",160, -320., -280.);
189   Add2RawsList(hRawTDCZEM2, 19, expert, !image);
190   
191   TProfile * hRawADCProfs = new TProfile("hRawADCProfs", "ADC profiles;ADC id;Mean ADC values",22,-0.5,21.5,10.,1210.,"");
192   Add2RawsList(hRawADCProfs, 20, expert, !image);
193   TProfile * hRawTDCProfs = new TProfile("hRawTDCProfs", "TDC profiles;TDC id;Mean TDC values",6,0.5,6.5,-340.,-290.,"S");
194   Add2RawsList(hRawTDCProfs, 21, expert, !image);
195   
196   TH1F * hRawADCs = new TH1F("hRawADCs", "ADCs;ADC id;Mean ADC values",22,-0.5,21.5);
197   Add2RawsList(hRawADCs, 22, !expert, image);
198  
199   TH1F * hRawTDCs = new TH1F("hRawTDCs", "TDCs;TDC id;Mean TDC values",6,0.5,6.5);
200 //  hRawTDCs->SetMaximum(-300); hRawTDCs->SetMinimum(-340);
201   Add2RawsList(hRawTDCs, 23, !expert, image);
202   
203   TH2F *hTimeZDC = new TH2F("hTimeZDC", "ZDC timing;(ZNC-ZNA) (ns);(ZNC+ZNA) (ns)", 120,-30.,30.,120,-100.,-40.);
204   Add2RawsList(hTimeZDC, 24, !expert, image);
205   
206   TH2F *hZNCrawCentr  = new TH2F("hZNCrawCentr", "ZNC centroid;X (cm);Y(cm)", 100,-3.5,3.5,100,-3.5,3.5);
207   Add2RawsList(hZNCrawCentr, 25, expert, image);
208   TH2F *hZNArawCentr  = new TH2F("hZNArawCentr", "ZNA centroid;X (cm);Y(cm)", 100,-3.5,3.5,100,-3.5,3.5);
209   Add2RawsList(hZNArawCentr, 26, expert, image);
210   
211   //
212   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
213 }
214
215 //____________________________________________________________________________
216 void AliZDCQADataMakerRec::InitRecPoints()
217 {
218   // create Digits histograms in Digits subdir
219   const Bool_t expert = kTRUE ; 
220   const Bool_t image  = kTRUE ; 
221   //
222   // ------------------- HIGH GAIN CHAIN ---------------------------
223   TH1F * hRecZNCTot = new TH1F("hRecZNCTot", "Rec signal in ZNC;Amplitude [ADC counts];Counts", 100, 0., 2000.);
224   TH1F * hRecZNATot = new TH1F("hRecZNATot", "Rec signal in ZNA;Amplitude [ADC counts];Counts", 100, 0., 2000.);
225   TH1F * hRecZPCTot = new TH1F("hRecZPCTot", "Rec signal in ZPC;Amplitude [ADC counts];Counts", 100, 0., 8000.);
226   TH1F * hRecZPATot = new TH1F("hRecZPATot", "Rec signal in ZPA;Amplitude [ADC counts];Counts", 100, 0., 8000.);
227   Add2RecPointsList(hRecZNCTot, 0, !expert, image);
228   Add2RecPointsList(hRecZNATot, 1, !expert, image);
229   Add2RecPointsList(hRecZPCTot, 2, !expert, image);
230   Add2RecPointsList(hRecZPATot, 3, !expert, image);
231   //
232   TH1F * hRecSumQZNC = new TH1F("hRecSumQZNC", "Rec summed 4 ZNC quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
233   TH1F * hRecSumQZNA = new TH1F("hRecSumQZNA", "Rec summed 4 ZNA quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
234   TH1F * hRecSumQZPC = new TH1F("hRecSumQZPC", "Rec summed 4 ZPC quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
235   TH1F * hRecSumQZPA = new TH1F("hRecSumQZPA", "Rec summed 4 ZPA quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
236   Add2RecPointsList(hRecSumQZNC, 4, expert, !image);
237   Add2RecPointsList(hRecSumQZNA, 5, expert, !image);
238   Add2RecPointsList(hRecSumQZPC, 6, expert, !image);
239   Add2RecPointsList(hRecSumQZPA, 7, expert, !image);
240   //
241   TH1F * hRecPMCZNC = new TH1F("hRecPMCZNC", "Rec common ZNC PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
242   TH1F * hRecPMCZNA = new TH1F("hRecPMCZNA", "Rec common ZNA PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
243   TH1F * hRecPMCZPC = new TH1F("hRecPMCZPC", "Rec common ZPC PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
244   TH1F * hRecPMCZPA = new TH1F("hRecPMCZPA", "Rec common ZPA PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
245   Add2RecPointsList(hRecPMCZNC, 8 , expert, !image);
246   Add2RecPointsList(hRecPMCZNA, 9 , expert, !image);
247   Add2RecPointsList(hRecPMCZPC, 10, expert, !image);
248   Add2RecPointsList(hRecPMCZPA, 11, expert, !image); 
249   //
250   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
251 }
252
253 //____________________________________________________________________________
254 void AliZDCQADataMakerRec::InitESDs()
255 {
256   //Booking ESDs histograms
257   //
258   const Bool_t expert = kTRUE ; 
259   const Bool_t image  = kTRUE ; 
260   
261   // ------------------- HIGH GAIN CHAIN ---------------------------
262   TH1F * hESDZNCTot = new TH1F("hESDZNCTot", "Energy in ZNC", 100, 0., 4000.);
263   TH1F * hESDZNATot = new TH1F("hESDZNATot", "Energy in ZNA", 100, 0., 4000.);
264   TH1F * hESDZPCTot = new TH1F("hESDZPCTot", "Energy in ZPC", 100, 0., 4000.);
265   TH1F * hESDZPATot = new TH1F("hESDZPATot", "Energy in ZPA", 100, 0., 4000.);
266   Add2ESDsList(hESDZNCTot, 0, !expert, image);
267   Add2ESDsList(hESDZNATot, 1, !expert, image);
268   Add2ESDsList(hESDZPCTot, 2, !expert, image);
269   Add2ESDsList(hESDZPATot, 3, !expert, image);
270   //
271   TH1F * hESDZEM1 = new TH1F("hESDZEM1", "Energy in ZEM1", 100, 0., 2000.);
272   TH1F * hESDZEM2 = new TH1F("hESDZEM2", "Energy in ZEM2", 100, 0., 2000.);
273   Add2ESDsList(hESDZEM1,4, !expert, image);
274   Add2ESDsList(hESDZEM2,5, !expert, image);
275   //
276   TH1F * hESDSumQZNC = new TH1F("hESDSumQZNC", "Sum of 4 ZNC energy",100, 0., 2000.);
277   TH1F * hESDSumQZNA = new TH1F("hESDSumQZNA", "Sum of 4 ZNA energy",100, 0., 2000.);
278   TH1F * hESDSumQZPC = new TH1F("hESDSumQZPC", "Sum of 4 ZPC energy",100, 0., 2000.);
279   TH1F * hESDSumQZPA = new TH1F("hESDSumQZPA", "Sum of 4 ZPA energy",100, 0., 2000.);
280   Add2ESDsList(hESDSumQZNC, 6, expert, !image);
281   Add2ESDsList(hESDSumQZNA, 7, expert, !image);
282   Add2ESDsList(hESDSumQZPC, 8, expert, !image);
283   Add2ESDsList(hESDSumQZPA, 9, expert, !image);
284   //
285   TH1F * hESDPMCZNC = new TH1F("hESDPMCZNC", "Energy in ZNC PMC",100, 0., 2000.);
286   TH1F * hESDPMCZNA = new TH1F("hESDPMCZNA", "Energy in ZNA PMC",100, 0., 2000.);
287   TH1F * hESDPMCZPC = new TH1F("hESDPMCZPC", "Energy in ZPC PMC",100, 0., 2000.);
288   TH1F * hESDPMCZPA = new TH1F("hESDPMCZPA", "Energy in ZPA PMC",100, 0., 2000.);
289   Add2ESDsList(hESDPMCZNC, 10, expert, !image);
290   Add2ESDsList(hESDPMCZNA, 11, expert, !image);
291   Add2ESDsList(hESDPMCZPC, 12, expert, !image);
292   Add2ESDsList(hESDPMCZPA, 13, expert, !image);
293   // 
294   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
295 }
296
297 //___________________________________________________________________________
298 void AliZDCQADataMakerRec::MakeDigits(TTree *digitTree)
299 {
300   // makes data from Digit Tree
301   if(!GetDigitsData(0)) InitDigits();
302
303   if(!digitTree){
304     AliError("Can't get ZDC digit tree!!");
305     return; 
306   }     
307    
308   TBranch * branch = digitTree->GetBranch("ZDC");
309   if(!branch){
310     AliError("ZDC branch in digit tree not found"); 
311     return;
312   } 
313     
314   AliZDCDigit *digit = 0x0;
315   branch->SetAddress(&digit);
316      
317   Float_t adcSum_ZNC=0., adcSum_ZNA=0., adcSum_ZPC=0., adcSum_ZPA=0.;
318   Float_t adcSumQ_ZNC=0., adcSumQ_ZNA=0., adcSumQ_ZPC=0., adcSumQ_ZPA=0.;
319   //Float_t adcSum_ZNC_lg=0., adcSum_ZNA_lg=0., adcSum_ZPC_lg=0., adcSum_ZPA_lg=0.;
320   //Float_t adcSumQ_ZNC_lg=0., adcSumQ_ZNA_lg=0., adcSumQ_ZPC_lg=0., adcSumQ_ZPA_lg=0.;
321   
322   Int_t ndig = digitTree->GetEntries();
323   for(Int_t i=0; i<ndig; i++){
324       branch->GetEntry(i);
325       
326       if(digit->GetSector(0)==1 && digit->GetSector(1)!=5){
327           adcSum_ZNC += digit->GetADCValue(0);
328           //adcSum_ZNC_lg += digit->GetADCValue(1);
329           //
330           if(digit->GetSector(1)!=0){
331               adcSumQ_ZNC += digit->GetADCValue(0);
332               //adcSumQ_ZNC_lg+= digit->GetADCValue(1);
333           }
334           else{
335               FillDigitsData(8,digit->GetADCValue(0));
336               //FillDigitsData(20,digit->GetADCValue(1));
337           }
338       }
339       else if(digit->GetSector(0)==2){
340           adcSum_ZPC += digit->GetADCValue(0);
341           //adcSum_ZPC_lg += digit->GetADCValue(1);
342           //
343           if(digit->GetSector(1)!=0){
344               adcSumQ_ZPC += digit->GetADCValue(0);
345               //adcSumQ_ZPC_lg+= digit->GetADCValue(1);
346           }
347           else{
348               FillDigitsData(10,digit->GetADCValue(0));
349               //FillDigitsData(22,digit->GetADCValue(1));
350           }
351       }
352       else if(digit->GetSector(0)==4 && digit->GetSector(1)!=5){
353           adcSum_ZNA += digit->GetADCValue(0);
354           //adcSum_ZNA_lg += digit->GetADCValue(1);
355           //
356           if(digit->GetSector(1)!=0){
357               adcSumQ_ZNA += digit->GetADCValue(0);
358               //adcSumQ_ZNA_lg+= digit->GetADCValue(1);
359           }
360           else{
361               FillDigitsData(9,digit->GetADCValue(0));
362               //FillDigitsData(21,digit->GetADCValue(1));
363           }
364       }
365       else if(digit->GetSector(0)==5){
366           adcSum_ZPA += digit->GetADCValue(0);
367           //adcSum_ZPA_lg += digit->GetADCValue(1);
368           //
369           if(digit->GetSector(1)!=0){
370               adcSumQ_ZPA += digit->GetADCValue(0);
371               //adcSumQ_ZPA_lg+= digit->GetADCValue(1);
372           }
373           else{
374               FillDigitsData(11,digit->GetADCValue(0));
375               //FillDigitsData(23,digit->GetADCValue(1));
376           }
377       }
378   }
379   //
380   FillDigitsData(0,adcSum_ZNC);
381   FillDigitsData(1,adcSum_ZNA);
382   FillDigitsData(2,adcSum_ZPC);
383   FillDigitsData(3,adcSum_ZPA);
384   //
385   FillDigitsData(4,adcSumQ_ZNC);
386   FillDigitsData(5,adcSumQ_ZNA);
387   FillDigitsData(6,adcSumQ_ZPC);
388   FillDigitsData(7,adcSumQ_ZPA);
389   
390   delete digit;
391   digit=0;
392   //
393   IncEvCountCycleDigits();
394   IncEvCountTotalDigits();
395   //
396 }
397
398
399 //____________________________________________________________________________
400 void AliZDCQADataMakerRec::MakeRaws(AliRawReader *rawReader)
401 {
402   // Filling Raws QA histos
403   //
404   // Checking the event type 
405 //  if (rawReader->GetType()!=7){
406   
407     // Check if histograms already created for this Event Specie
408     if(!GetRawsData(0)) InitRaws();
409     // Parameters for mean value pedestal subtraction
410     int const kNch = 24;
411     Float_t meanPed[2*kNch];    
412     for(Int_t jj=0; jj<2*kNch; jj++){
413       if(fPedCalibData) meanPed[jj] = fPedCalibData->GetMeanPed(jj);
414       else{
415         meanPed[jj] = 0.;
416         printf("  AliZDCQADataMakerRec::MakeRaws -> No valid pedestal object loaded!\n\n");
417       }
418     }
419     
420     Float_t zncSignal=0., znaSignal=0., zpcSignal=0., zpaSignal=0.;
421     Float_t zncSumQ=0., znaSumQ=0., zpcSumQ=0., zpaSumQ=0.;
422     Float_t zncpmC=0., znapmC=0., zpcpmC=0., zpapmC=0.;
423     Bool_t isZNCFired=kFALSE, isZPCFired=kFALSE, isZNAFired=kFALSE, isZPAFired=kFALSE;
424     Int_t  indZNC=0, indZNA=0, indZPC=0, indZPA=0;
425     Double_t zncTDC=0., zpcTDC=0., zem1TDC=0., zem2TDC=0., znaTDC=0., zpaTDC=0.;
426     Double_t zncSumTDC=0., znaSumTDC=0., tdcGate=0., l0=0.;
427     
428     const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
429     const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
430     const Float_t alpha=0.5;
431     Float_t numXZNC=0., numYZNC=0., denZNC=0., wZNC=0.; 
432     Float_t numXZNA=0., numYZNA=0., denZNA=0., wZNA=0.; 
433     
434     rawReader->Reset();
435     AliZDCRawStream stream(rawReader);
436     while(stream.Next()){
437
438       if(stream.IsADCDataWord() && 
439          (stream.GetADCModule()==0 || stream.GetADCModule()==1)){
440        
441          Int_t det = stream.GetSector(0);
442          Int_t quad = stream.GetSector(1);
443          Int_t gain = stream.GetADCGain();
444          Int_t pedindex=0;
445          
446          // Stuff for pedestal subtraction
447          if(quad != 5){ // ZDCs (not reference PTMs)
448           Float_t rawVal=-99., pedSubVal=-99.;
449           if(det == 1){    
450             pedindex = quad;
451             if(gain == 0){
452               rawVal = (Float_t) (stream.GetADCValue());
453               pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
454               zncSignal  += pedSubVal; 
455               isZNCFired = kTRUE;
456               if(quad!=0){
457                 zncSumQ += pedSubVal;
458                 if(pedSubVal>0.&& zncpmC>7.){
459                   wZNC = TMath::Power(pedSubVal, alpha);
460                   numXZNC += x[quad-1]*wZNC;
461                   numYZNC += y[quad-1]*wZNC;
462                   denZNC += wZNC;
463                 }
464               }
465               else{
466                 zncpmC = pedSubVal;
467                 FillRawsData(6,zncpmC);
468               }
469               indZNC++;
470               
471               FillRawsData(20, pedindex, pedSubVal);
472             }
473           }
474           else if(det == 2){ 
475             pedindex = quad+5;
476             if(gain == 0){
477               rawVal = (Float_t) (stream.GetADCValue());
478               pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
479               zpcSignal += pedSubVal; 
480               isZPCFired = kTRUE;
481               if(quad!=0) zpcSumQ += pedSubVal;
482               else{
483                 zpcpmC = pedSubVal;
484                 FillRawsData(8,zpcpmC);
485               }
486               indZPC++;
487               
488               FillRawsData(20, pedindex, pedSubVal);
489             }
490           }
491           else if(det == 3){ 
492             pedindex = quad+9;
493             if(quad==1){     
494               if(gain == 0){
495                 rawVal = (Float_t) (stream.GetADCValue());
496                 pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
497                 FillRawsData(4,pedSubVal);
498                 FillRawsData(20,pedindex, pedSubVal);
499               }
500             }
501             else if(quad==2){ 
502               if(gain == 0){
503                 rawVal = (Float_t) (stream.GetADCValue());
504                 pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
505                 FillRawsData(5,pedSubVal); 
506                 FillRawsData(20,pedindex, pedSubVal);
507               }
508             }
509           }
510           else if(det == 4){       
511             pedindex = quad+12;
512             if(gain == 0){
513               rawVal = (Float_t) (stream.GetADCValue());
514               pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
515               znaSignal  += pedSubVal; 
516               isZNAFired = kTRUE;
517               if(quad!=0){
518                 znaSumQ += pedSubVal;
519                 if(pedSubVal>0.&& znapmC>7.) {
520                   wZNA = TMath::Power(pedSubVal, alpha);
521                   numXZNA += x[quad-1]*wZNA;
522                   numYZNA += y[quad-1]*wZNA;
523                   denZNA += wZNA;
524                 }
525               }
526               else{
527                 znapmC = pedSubVal;
528                 FillRawsData(7,znapmC);
529               }
530               indZNA++;
531               
532               FillRawsData(20,pedindex, pedSubVal);
533             }
534           }
535           else if(det == 5){
536             pedindex = quad+17;
537             if(gain == 0){
538               rawVal = (Float_t) (stream.GetADCValue());
539               pedSubVal = (Float_t) (rawVal-meanPed[pedindex]); 
540               zpaSignal  += pedSubVal; 
541               isZPAFired = kTRUE;
542               if(quad!=0) zpaSumQ += pedSubVal;
543               else{
544                 zpapmC = pedSubVal;
545                 FillRawsData(9,zpapmC);
546               }
547               indZPA++;
548               
549               FillRawsData(20,pedindex, pedSubVal);
550             }
551           }
552                          
553          }
554
555          if(isZNCFired && indZNC==5){
556            FillRawsData(0,zncSignal);
557            FillRawsData(10,zncSumQ); 
558            //
559            Float_t xZNC, yZNC;           
560            if(denZNC!=0){
561              xZNC = numXZNC/denZNC;
562              yZNC = numYZNC/denZNC;
563            } 
564            else xZNC = yZNC = 999.;
565            FillRawsData(25, xZNC, yZNC, zncpmC);
566          }
567          if(isZPCFired && indZPC==5){
568            FillRawsData(2,zpcSignal);
569            FillRawsData(12,zpcSumQ); 
570          }
571          if(isZNAFired && indZNA==5){ 
572            FillRawsData(1,znaSignal);
573            FillRawsData(11,znaSumQ); 
574            //
575            Float_t xZNA, yZNA;
576            if(denZNA!=0){
577              xZNA = numXZNA/denZNA;
578              yZNA = numYZNA/denZNA;
579            } 
580            else xZNA = yZNA = 999.;
581            FillRawsData(26, xZNA, yZNA, znapmC);
582          }
583          if(isZPAFired && indZPA==5){ 
584            FillRawsData(3,zpaSignal);
585            FillRawsData(13,zpaSumQ); 
586          }
587          
588          if(indZNC==5){
589            zncSignal = zncSumQ = zncpmC = 0;
590            isZNCFired=kFALSE; indZNC=0;
591          }
592          if(indZPC==5){
593            zpcSignal = zpcSumQ = zpcpmC = 0;
594            isZPCFired=kFALSE; indZPC=0;
595          }
596          if(indZNA==5){
597            znaSignal = znaSumQ = znapmC = 0;
598            isZNAFired=kFALSE; indZNA=0;
599          }
600          if(indZPA==5){
601            zpaSignal = zpaSumQ = zpapmC = 0;
602            isZPAFired=kFALSE; indZPA=0;
603          }
604          
605       } //IsADCDataWord && signal ADCs
606       else if(stream.IsZDCTDCDatum()){
607          Float_t tdcValue = 0.025*stream.GetZDCTDCDatum();
608          if(stream.GetChannel()==1 && tdcValue!=0.){
609             zncTDC = tdcValue;
610          }
611          else if(stream.GetChannel()==3 && tdcValue!=0.){
612             zpcTDC = tdcValue;
613          }
614          else if(stream.GetChannel()==5 && tdcValue!=0.){
615             znaTDC = tdcValue;
616          }
617          else if(stream.GetChannel()==7 && tdcValue!=0.){
618             zpaTDC = tdcValue;
619          }
620          else if(stream.GetChannel()==8 && tdcValue!=0.){
621             zem1TDC = tdcValue;
622          }
623          else if(stream.GetChannel()==9 && tdcValue!=0.){
624             zem2TDC = tdcValue;
625          }
626          else if(stream.GetChannel()==10 && tdcValue!=0.){
627             zncSumTDC = tdcValue;
628          }
629          else if(stream.GetChannel()==12 && tdcValue!=0.){
630             znaSumTDC = tdcValue;
631          }
632          else if(stream.GetChannel()==14 && tdcValue!=0.) tdcGate = tdcValue;
633          else if(stream.GetChannel()==15 && tdcValue!=0.) l0 = tdcValue;
634          
635          if(stream.GetChannel()==16 && tdcGate!=0. && l0!=0.){
636               if(zncTDC!=0.){
637                 Float_t znc = zncTDC-tdcGate;
638                 FillRawsData(14,znc);
639                 if(znc>-340. && znc<-290.) FillRawsData(21,1, znc);
640               }
641               if(zpcTDC!=0.){
642                 Float_t zpc = zpcTDC-tdcGate;
643                 FillRawsData(15,zpc);
644                 if(zpc>-340. && zpc<-290.) FillRawsData(21,2, zpc);
645               }
646               if(znaTDC!=0.){
647                 Float_t zna = znaTDC-tdcGate;
648                 FillRawsData(16,zna);
649                 if(zna>-340. && zna<-290.) FillRawsData(21,3, zna);
650               }
651               if(zpaTDC!=0.){
652                 Float_t zpa = zpaTDC-tdcGate;
653                 FillRawsData(17,zpa);
654                 if(zpa>-340. && zpa<-290.) FillRawsData(21,4, zpa);
655               }
656               if(zem1TDC!=0.){
657                 Float_t zem1 = zem1TDC-tdcGate;
658                 FillRawsData(18,zem1);
659                 if(zem1>-340. && zem1<-290.) FillRawsData(21,5, zem1);
660               }
661               if(zem2TDC!=0.){
662                 Float_t zem2 = zem2TDC-tdcGate;
663                 FillRawsData(19,zem2);
664                 if(zem2TDC>-340. && zem2<-290.) FillRawsData(21,6, zem2);
665               }
666               if(znaSumTDC!=0. && zncSumTDC!=0.){
667                  Float_t tdcC = zncSumTDC-l0;
668                  Float_t tdcA = znaSumTDC-l0;
669                  FillRawsData(24, tdcC-tdcA, tdcC+tdcA);
670               }
671            //
672            tdcGate = zncTDC = zpcTDC = zem1TDC = zem2TDC = znaTDC = zpaTDC = 0.;
673            zncSumTDC = znaSumTDC = 0.;
674          }
675       }
676     
677     } //stream.Next()
678 //  } // check on event type
679 //  else{
680 //    AliDebug(1,Form("Skipping non-physics event for QA -> event type %d \n", rawReader->GetType())); 
681 //  }
682 //
683     IncEvCountCycleRaws();
684     IncEvCountTotalRaws();
685     //
686 }
687
688 //____________________________________________________________________________
689 void AliZDCQADataMakerRec::MakeRecPoints(TTree * clustersTree)
690 {
691   // Filling QA histos from RecPoints
692
693   TBranch *branch = clustersTree->GetBranch("ZDC");
694   if(!branch){ 
695     AliError("Can't get the ZDC branch for rec points!");
696     return;
697   }
698   
699   if(!GetRecPointsData(0)) InitRecPoints() ;
700
701   Float_t sum_ZNC=0., sum_ZNA=0., sum_ZPC=0., sum_ZPA=0.;
702   Float_t sumQ_ZNC=0., sumQ_ZNA=0., sumQ_ZPC=0., sumQ_ZPA=0.;
703
704   AliZDCReco reco;
705   AliZDCReco* preco = &reco;
706   clustersTree->SetBranchAddress("ZDC", &preco);
707
708   clustersTree->GetEntry(0);
709   for(Int_t i=0; i<5; i++){
710     sum_ZNC += reco.GetZN1HREnTow(i);
711     sum_ZPC += reco.GetZN2HREnTow(i);
712     sum_ZNA += reco.GetZP1HREnTow(i);
713     sum_ZPA += reco.GetZP2HREnTow(i);
714     if(i==0){
715       FillRecPointsData(8,reco.GetZN1HREnTow(i));
716       FillRecPointsData(9,reco.GetZN2HREnTow(i));
717       FillRecPointsData(10,reco.GetZP1HREnTow(i));
718       FillRecPointsData(11,reco.GetZP2HREnTow(i));
719     }
720     else{
721       sumQ_ZNC += reco.GetZN1HREnTow(i);
722       sumQ_ZPC += reco.GetZN2HREnTow(i);
723       sumQ_ZNA += reco.GetZP1HREnTow(i);
724       sumQ_ZPA += reco.GetZP2HREnTow(i);
725     }
726   }
727   
728   FillRecPointsData(0,sum_ZNC);
729   FillRecPointsData(1,sum_ZNA);
730   FillRecPointsData(2,sum_ZPC);
731   FillRecPointsData(3,sum_ZPA);
732   //
733   FillRecPointsData(4,sumQ_ZNC);
734   FillRecPointsData(5,sumQ_ZNA);
735   FillRecPointsData(6,sumQ_ZPC);
736   FillRecPointsData(7,sumQ_ZPA);
737   //
738   IncEvCountCycleRecPoints();
739   IncEvCountTotalRecPoints();
740   //  
741 }  
742
743 //____________________________________________________________________________
744 void AliZDCQADataMakerRec::MakeESDs(AliESDEvent * esd)
745 {
746   // make QA data from ESDs
747   //
748   
749   // Check id histograms already created for this Event Specie
750   if(!GetESDsData(0)) InitESDs() ;
751
752   AliESDZDC * zdcESD =  esd->GetESDZDC();
753   //
754   /*TString beamType = esd->GetBeamType();
755   Double_t centr_ZNC[2]={999.,999}, centr_ZNA[2]={999.,999};
756   if(((beamType.CompareTo("pp"))==0) || ((beamType.CompareTo("p-p"))==0)
757      ||((beamType.CompareTo("PP"))==0) || ((beamType.CompareTo("P-P"))==0)){
758     zdcESD->GetZNCentroidInpp(centr_ZNC, centr_ZNA);
759   }
760   else if((beamType.CompareTo("A-A")) == 0 || (beamType.CompareTo("Pb-Pb")) == 0){
761     Float_t beamEne = esd->GetBeamEnergy();
762     zdcESD->GetZNCentroidInPbPb(beamEne, centr_ZNC, centr_ZNA);
763   }
764   else printf("\n WARNING!!! AliZDCQADataMakerRec::MakeESDs: can't calculate centroids for beam type: %s\n\n",beamType.Data());
765   FillESDsData(0,centr_ZNC[0], centr_ZNC[1]);
766   FillESDsData(1,centr_ZNA[0], centr_ZNA[1]);*/
767
768   FillESDsData(0,esd->GetZDCN1Energy());
769   FillESDsData(1,esd->GetZDCN2Energy());
770   FillESDsData(2,esd->GetZDCP1Energy());
771   FillESDsData(3,esd->GetZDCP2Energy());
772   FillESDsData(4,esd->GetZDCEMEnergy(0));
773   FillESDsData(5,esd->GetZDCEMEnergy(1));
774   //
775   Double_t sumQZNC=0., sumQZPC=0., sumQZNA=0., sumQZPA=0.;
776   //Double_t sumQZNC_lg=0., sumQZPC_lg=0., sumQZNA_lg=0., sumQZPA_lg=0.;
777   //
778   const Double_t *towZNC, *towZPC, *towZNA, *towZPA;
779   //const Double_t *towZNC_lg, *towZPC_lg, *towZNA_lg, *towZPA_lg;
780   //
781   towZNC = zdcESD->GetZN1TowerEnergy();
782   towZPC = zdcESD->GetZP1TowerEnergy();
783   towZNA = zdcESD->GetZN2TowerEnergy();
784   towZPA = zdcESD->GetZP2TowerEnergy();
785   //
786   /*towZNC_lg = zdcESD->GetZN1TowerEnergyLR();
787   towZPC_lg = zdcESD->GetZP1TowerEnergyLR();
788   towZNA_lg = zdcESD->GetZN2TowerEnergyLR();
789   towZPA_lg = zdcESD->GetZP2TowerEnergyLR();*/
790   //
791   for(Int_t i=0; i<5; i++){
792      if(i==0){
793        FillESDsData(10,towZNC[i]);
794        FillESDsData(11,towZNA[i]);
795        FillESDsData(12,towZPC[i]);
796        FillESDsData(13,towZPA[i]);
797      }
798      else{
799        sumQZNC += towZNC[i];
800        sumQZPC += towZPC[i];
801        sumQZNA += towZNA[i];
802        sumQZPA += towZPA[i];
803      }
804   }
805   FillESDsData(6,sumQZNC);
806   FillESDsData(7,sumQZNA);
807   FillESDsData(8,sumQZPC);
808   FillESDsData(9,sumQZPA);
809   //
810   IncEvCountCycleESDs();
811   IncEvCountTotalESDs();
812   //
813 }
814
815 //____________________________________________________________________________
816 void AliZDCQADataMakerRec::StartOfDetectorCycle()
817 {
818   //Detector specific actions at start of cycle
819
820   fPedCalibData = GetPedCalibData();
821   
822 }
823
824 //____________________________________________________________________________ 
825 void AliZDCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
826 {
827   //Detector specific actions at end of cycle
828   // do the QA checking
829   //
830   ResetEventTrigClasses();
831   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {  // RS: loop over event types
832     //
833     if (!IsValidEventSpecie(specie, list)) continue;
834     SetEventSpecie(AliRecoParam::ConvertIndex(specie));
835     //
836     for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
837       //
838       if(task == AliQAv1::kRAWS) {
839         TH1F* h14 =  dynamic_cast<TH1F*> (GetRawsData(14, itc));
840         TH1F* h15 =  dynamic_cast<TH1F*> (GetRawsData(15, itc));
841         TH1F* h16 =  dynamic_cast<TH1F*> (GetRawsData(16, itc));
842         TH1F* h17 =  dynamic_cast<TH1F*> (GetRawsData(17, itc));
843         TH1F* h18 =  dynamic_cast<TH1F*> (GetRawsData(18, itc));
844         TH1F* h19 =  dynamic_cast<TH1F*> (GetRawsData(19, itc));
845         TProfile* h20 = dynamic_cast<TProfile*> (GetRawsData(20, itc));
846         //TProfile* h21 =  dynamic_cast<TProfile*> (GetRawsData(21, itc));
847         TH1F* h22 =  dynamic_cast<TH1F*> (GetRawsData(22, itc));
848         TH1F* h23 =  dynamic_cast<TH1F*> (GetRawsData(23, itc));
849         TH2F* h24 =  dynamic_cast<TH2F*> (GetRawsData(24, itc));
850         TH2F* h25 =  dynamic_cast<TH2F*> (GetRawsData(25, itc));
851         TH2F* h26 =  dynamic_cast<TH2F*> (GetRawsData(26, itc));
852         if(!h20){
853          AliWarning("AliZDCQADataMakerRec -> RAW ADC histo not found!"); 
854          AliWarning(Form("for specie %s and trigger class %s",
855                          AliRecoParam::GetEventSpecieName(specie), AliQADataMaker::GetTrigClassName(itc)));
856         }
857         else{
858           if(h22){
859
860             for(Int_t ibin=1; ibin<=h20->GetNbinsX(); ibin++){
861               h22->SetBinContent(ibin, h20->GetBinContent(ibin)); 
862               h22->SetBinError(ibin, h20->GetBinError(ibin));
863             }
864             h22->SetLineColor(kBlue+1); h22->SetLineWidth(2);
865           }
866           else printf("Warning: Raw ADC QA histo not found \n\n");
867         }
868         if(!h14 || !h15 || !h16 || !h17 || !h18 || !h19){
869         AliWarning("AliZDCQADataMakerRec -> RAW TDC histos not found!"); 
870          AliWarning(Form("for specie %s and trigger class %s",
871                          AliRecoParam::GetEventSpecieName(specie), AliQADataMaker::GetTrigClassName(itc)));
872         }
873         else{
874           /*for(Int_t ibin=1; ibin<=h21->GetNbinsX(); ibin++){
875             printf("  bin %d  TDC %f\n",ibin,  h21->GetBinContent(ibin));
876             h23->SetBinContent(ibin, h21->GetBinContent(ibin)); 
877             h23->SetBinError(ibin, h21->GetBinError(ibin));
878           }*/
879           if(h23){
880             h23->SetBinContent(1, h14->GetMean());
881             h23->SetBinError(1, h14->GetRMS());
882             h23->SetBinContent(2, h15->GetMean());
883             h23->SetBinError(2, h15->GetRMS());
884             h23->SetBinContent(3, h16->GetMean());
885             h23->SetBinError(3, h16->GetRMS());
886             h23->SetBinContent(4, h17->GetMean());
887             h23->SetBinError(4, h17->GetRMS());
888             h23->SetBinContent(5, h18->GetMean());
889             h23->SetBinError(5, h18->GetRMS());
890             h23->SetBinContent(6, h19->GetMean());
891             h23->SetBinError(6, h19->GetRMS());
892             //
893             h23->SetLineColor(kAzure+6); 
894             h23->SetLineWidth(2);
895           }
896           else printf(" Warning: Raw TDC QA histo not found\n\n");
897         }
898         if(!h25 || !h26){
899          AliWarning("AliZDCQADataMakerRec -> RAW centroid histos not found!"); 
900          AliWarning(Form("for specie %s and trigger class %s",
901                          AliRecoParam::GetEventSpecieName(specie), AliQADataMaker::GetTrigClassName(itc)));
902         }
903         else{
904          h25->SetMarkerColor(kPink-2); 
905          h26->SetMarkerColor(kAzure-2);
906         }
907         if(!h24) {
908          AliWarning("AliZDCQADataMakerRec -> RAW debunching histo not found!"); 
909          AliWarning(Form("for specie %s and trigger class %s",
910                          AliRecoParam::GetEventSpecieName(specie), AliQADataMaker::GetTrigClassName(itc)));
911         }
912         else h24->SetMarkerColor(kAzure);
913       }
914     } // loop over t
915   } //  loop over species
916         
917   AliQAChecker::Instance()->Run(AliQAv1::kZDC, task, list) ;  
918 }