]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQADataMakerRec.cxx
Get in sync with the base class
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQADataMakerRec.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 quality assurance. 
19   All data must be mergeable objects.
20 */
21
22 // --- ROOT system ---
23 #include <TClonesArray.h>
24 #include <TFile.h> 
25 #include <TH1F.h> 
26 #include <TH1I.h> 
27 #include <TH2I.h> 
28 #include <TParameter.h>
29
30 // --- Standard library ---
31
32 // --- AliRoot header files ---
33 #include "AliESDEvent.h"
34 #include "AliLog.h"
35 #include "AliCDBManager.h"
36 #include "AliCDBStorage.h"
37 #include "AliCDBEntry.h"
38 #include "AliVZEROQADataMakerRec.h"
39 #include "AliQAChecker.h"
40 #include "AliRawReader.h"
41 #include "AliVZERORawStream.h"
42 #include "AliVZEROReconstructor.h"
43
44
45 ClassImp(AliVZEROQADataMakerRec)
46            
47 //____________________________________________________________________________ 
48   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec() : 
49     AliQADataMakerRec(AliQA::GetDetName(AliQA::kVZERO), "VZERO Quality Assurance Data Maker"),
50     fCalibData(GetCalibData()),
51     fEvent(0)
52     
53 {
54   // constructor
55   
56    for(Int_t i=0; i<64; i++){  
57        fEven[i] = 0;   
58        fOdd[i]  = 0;  }
59   
60    for(Int_t i=0; i<128; i++){  
61        fADC_Mean[i] = 0.0;   }  
62 }
63
64 //____________________________________________________________________________ 
65   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec(const AliVZEROQADataMakerRec& qadm) :
66   AliQADataMakerRec(),
67     fCalibData(GetCalibData()),
68     fEvent(0)
69   
70 {
71   //copy constructor 
72    SetName((const char*)qadm.GetName()) ; 
73    SetTitle((const char*)qadm.GetTitle()); 
74 }
75
76 //__________________________________________________________________
77 AliVZEROQADataMakerRec& AliVZEROQADataMakerRec::operator = (const AliVZEROQADataMakerRec& qadm )
78 {
79   // Equal operator
80   this->~AliVZEROQADataMakerRec();
81   new(this) AliVZEROQADataMakerRec(qadm);
82   return *this;
83 }
84
85 //____________________________________________________________________________
86 AliVZEROCalibData* AliVZEROQADataMakerRec::GetCalibData() const
87
88 {
89   AliCDBManager *man = AliCDBManager::Instance();
90
91   AliCDBEntry *entry=0;
92
93   entry = man->Get("VZERO/Calib/Data");
94
95   // Retrieval of data in directory VZERO/Calib/Data:
96
97   AliVZEROCalibData *calibdata = 0;
98
99   if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
100   if (!calibdata)  AliFatal("No calibration data from calibration database !");
101
102   return calibdata;
103 }
104  
105 //____________________________________________________________________________ 
106 void AliVZEROQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
107 {
108   //Detector specific actions at end of cycle
109   // do the QA checking
110   AliQAChecker::Instance()->Run(AliQA::kVZERO, task, list) ;
111 }
112
113 //____________________________________________________________________________ 
114 void AliVZEROQADataMakerRec::InitESDs()
115 {
116   //Create histograms to control ESD
117  
118   TH1I * h1 = new TH1I("hVZERONbPMA", "Number of PMs fired in V0A", 80, 0, 80); 
119   h1->Sumw2() ;
120   Add2ESDsList(h1, 0)  ;  
121                                                                                                         
122   TH1I * h2 = new TH1I("hVZERONbPMC", "Number of PMs fired in V0C", 80, 0, 80); 
123   h2->Sumw2() ;
124   Add2ESDsList(h2, 1) ;
125  
126   TH1I * h3 = new TH1I("hVZEROMultA", "Multiplicity in V0A", 50, 0, 50) ; 
127   h3->Sumw2() ;
128   Add2ESDsList(h3, 2) ;
129  
130   TH1I * h4 = new TH1I("hVZEROMultC", "Multiplicity in V0C", 50, 0, 50) ; 
131   h4->Sumw2() ;
132   Add2ESDsList(h4, 3) ;
133
134   TH2F * h5 = new TH2F("fVzeroMult", "Vzero multiplicity",
135                          64, -0.5, 63.5,1000, -0.5, 99.5);
136   h5->GetXaxis()->SetTitle("Vzero PMT");
137   h5->GetYaxis()->SetTitle("Multiplicity");
138   h5->Sumw2() ;
139   Add2ESDsList(h5, 4) ;
140   TH1F * h6 = new TH1F("fBBA","BB Vzero A", 32, -0.5,31.5);
141   h6->Sumw2();
142   Add2ESDsList(h6, 5) ;
143   TH1F * h7 = new TH1F("fBGA","BG Vzero A", 32, -0.5,31.5);
144   h7->Sumw2();
145   Add2ESDsList(h7, 6) ;
146   TH1F * h8 = new TH1F("fBBC","BB Vzero C", 32, -0.5,31.5);
147   h8->Sumw2();
148   Add2ESDsList(h8, 7) ;
149   TH1F * h9 = new TH1F("fBGC","BG Vzero C", 32, -0.5,31.5);
150   h9->Sumw2();
151   Add2ESDsList(h9, 8) ;
152
153   TH2F *h10 = new TH2F("fVzeroAdc", "Vzero Adc",
154                          64, -0.5, 63.5,1024, -0.5, 1023.5);
155   h10->GetXaxis()->SetTitle("Vzero PMT");
156   h10->GetYaxis()->SetTitle("Adc counts");
157   h10->Sumw2() ;
158   Add2ESDsList(h10, 9);
159
160   TH2F *h11 = new TH2F("fVzeroTime", "Vzero Time",
161                          64, -0.5, 63.5,300, -0.5, 149.5);
162   h11->GetXaxis()->SetTitle("Vzero PMT");
163   h11->GetYaxis()->SetTitle("Time [100 ps]");
164   h11->Sumw2() ;
165   Add2ESDsList(h11,10);
166
167 }
168
169 //____________________________________________________________________________ 
170  void AliVZEROQADataMakerRec::InitRaws()
171  {
172    // create Raws histograms in Raws subdir
173
174   char ADCname[12]; 
175   char texte[40]; 
176   TH1I *hRawADC0[64]; 
177   TH1I *hRawADC1[64];
178   
179   Bool_t expert   = kTRUE ; 
180   Bool_t saveCorr = kTRUE ; 
181     
182   TH2I *h0 = new TH2I("hCellADCMap0","ADC vs Cell for EVEN Integrator", 70, 0, 70, 512, 0, 1024);
183   h0->Sumw2(); 
184   Add2RawsList(h0,0, !expert, !saveCorr) ;
185   TH2I *h1 = new TH2I("hCellADCMap1","ADC vs Cell for ODD Integrator", 70, 0, 70, 512, 0, 1024);
186   h1->Sumw2();
187   Add2RawsList(h1,1, !expert, !saveCorr) ;
188
189   TH2F *hMeanADC0 = new TH2F("hCellMeanADCMap0","Mean ADC vs cell for EVEN integrator",70,-0.5,69.5,512,-0.5,511.5);       
190   Add2RawsList(hMeanADC0,2, !expert, !saveCorr); 
191   TH2F *hMeanADC1 = new TH2F("hCellMeanADCMap1","Mean ADC vs cell for ODD integrator",70,-0.5,69.5,512,-0.5,511.5);       
192   Add2RawsList(hMeanADC1,3, !expert, !saveCorr);  
193     
194   TH1I *hMulV0A = new TH1I("hMulV0A", "Multiplicity in V0A", 40, 0, 40) ;  
195   Add2RawsList(hMulV0A,4, !expert, saveCorr);  
196   TH1I *hMulV0C = new TH1I("hMulV0C", "Multiplicity in V0C", 40, 0, 40) ;  
197   Add2RawsList(hMulV0C,5, !expert, saveCorr);  
198                           
199   for (Int_t i=0; i<64; i++)
200     {
201        sprintf(ADCname,"hRaw0ADC%d",i);
202        sprintf(texte,"Raw ADC in cell %d for even integrator",i);
203        hRawADC0[i]= new TH1I(ADCname,texte,1024,0,1024);       
204        Add2RawsList(hRawADC0[i],i+6, expert, !saveCorr);
205                     
206        sprintf(ADCname,"hRaw1ADC%d",i);
207        sprintf(texte,"Raw ADC in cell %d for odd integrator",i);
208        hRawADC1[i]= new TH1I(ADCname,texte,1024,0,1024);       
209        Add2RawsList(hRawADC1[i],i+6+64, expert, !saveCorr);                     
210      }  
211  }
212
213 //____________________________________________________________________________
214 void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
215 {
216   // make QA data from ESDs
217
218   AliESDVZERO *esdVZERO=esd->GetVZEROData();
219    
220   if (esdVZERO) { 
221       GetESDsData(0)->Fill(esdVZERO->GetNbPMV0A());
222       GetESDsData(1)->Fill(esdVZERO->GetNbPMV0C());  
223       GetESDsData(2)->Fill(esdVZERO->GetMTotV0A());
224       GetESDsData(3)->Fill(esdVZERO->GetMTotV0C());  
225       for(Int_t i=0;i<64;i++) {
226          GetESDsData(4)->Fill((Float_t) i,(Float_t) esdVZERO->GetMultiplicity(i));
227          GetESDsData(9)->Fill((Float_t) i,(Float_t) esdVZERO->GetAdc(i));
228          GetESDsData(10)->Fill((Float_t) i,(Float_t) esdVZERO->GetTime(i));
229       }
230       for(Int_t i=0;i<32;i++) { 
231         if(esdVZERO->BBTriggerV0A(i)) 
232            GetESDsData(5)->Fill((Float_t) i);
233         if(esdVZERO->BGTriggerV0A(i)) 
234            GetESDsData(6)->Fill((Float_t) i);
235         if(esdVZERO->BBTriggerV0C(i)) 
236            GetESDsData(7)->Fill((Float_t) i);
237         if(esdVZERO->BGTriggerV0C(i)) 
238            GetESDsData(8)->Fill((Float_t) i);
239       }
240   }
241   
242 }
243
244 //____________________________________________________________________________
245  void AliVZEROQADataMakerRec::MakeRaws(AliRawReader* rawReader)
246  {
247   //Fill histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
248                   
249   rawReader->Reset() ; 
250   AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
251   rawStream->Next();
252   
253   Float_t ChargeEoI, Threshold;  // for pedestal subtraction 
254                               
255 //  for(Int_t i=0; i<128; i++) { printf(" i = %d pedestal = %f sigma = %f \n\n", 
256 //                                        i,  fCalibData->GetPedestal(i),fCalibData->GetSigma(i) );} 
257              
258   GetRawsData(2)->Reset();      // to keep only the last value of the ADC average
259   GetRawsData(3)->Reset();
260
261   Int_t mulV0A = 0 ; 
262   Int_t mulV0C = 0 ; 
263    
264   Int_t thresholV0A = 50 ; 
265   Int_t thresholV0C = 50 ; 
266    
267   for(Int_t j=0; j<64; j++) {
268       Int_t i =  rawStream->GetOfflineChannel(j);  // Convert Online to Offline channel number 
269       if(!rawStream->GetIntegratorFlag(i,10)) 
270            { 
271             // even integrator - fills index6 to 69 
272             GetRawsData(0)->Fill(i,rawStream->GetADC(i)) ; 
273       GetRawsData(i+6)->Fill(rawStream->GetADC(i)) ; 
274             ChargeEoI  = (float)rawStream->GetADC(i) - fCalibData->GetPedestal(i); 
275             Threshold  = 3.0 * fCalibData->GetSigma(i);   
276             if(rawStream->GetADC(i)<1023 && ChargeEoI > Threshold) {
277                fADC_Mean[i] = ((fADC_Mean[i]*fEven[i]) + rawStream->GetADC(i)) / (fEven[i]+1); 
278                GetRawsData(2)->Fill((Float_t) i, fADC_Mean[i]);
279                fEven[i]+=1; }
280            }
281       else if(rawStream->GetIntegratorFlag(i,10)) 
282            { 
283             // odd integrator  - fills index 70 to 133  
284       GetRawsData(1)->Fill(i,rawStream->GetADC(i)) ; 
285       GetRawsData(i+6+64)->Fill(rawStream->GetADC(i)) ;
286             ChargeEoI  = (float)rawStream->GetADC(i) - fCalibData->GetPedestal(i+64) ; 
287             Threshold  = 3.0 * fCalibData->GetSigma(i+64);  
288             if(rawStream->GetADC(i)<1023 && ChargeEoI > Threshold) { 
289                fADC_Mean[i+64] = ((fADC_Mean[i+64]*fOdd[i]) + rawStream->GetADC(i)) / (fOdd[i]+1);
290                GetRawsData(3)->Fill((Float_t) i, fADC_Mean[i+64]);
291                fOdd[i]+=1; }
292            }    
293      if( i < 32 ){
294        if (rawStream->GetADC(i) > thresholV0C) 
295            mulV0C++ ;     
296      }else{
297        if (rawStream->GetADC(i) > thresholV0A) 
298            mulV0A++ ; 
299      }
300   }   
301    
302   fEvent++; 
303   GetRawsData(4)->Fill(mulV0A) ; 
304   TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(4)->GetName()))) ; 
305   p->SetVal(mulV0A) ; 
306   GetRawsData(5)->Fill(mulV0C) ; 
307   p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(5)->GetName()))) ; 
308   p->SetVal(mulV0C) ;                     
309  }
310
311 //____________________________________________________________________________ 
312 void AliVZEROQADataMakerRec::StartOfDetectorCycle()
313 {
314   // Detector specific actions at start of cycle
315   
316 }