]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCQADataMakerSim.cxx
end-of-line normalization
[u/mrichter/AliRoot.git] / ZDC / AliZDCQADataMakerSim.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 // --- Standard library ---
17 #include <Riostream.h>
18 // --- ROOT system ---
19 #include <TClonesArray.h>
20 #include <TFile.h>     
21 #include <TH1F.h> 
22 #include <TH2F.h>
23 #include <TBranch.h>
24 #include <TTree.h>
25 // --- AliRoot header files ---
26 #include "AliLog.h"
27 #include "AliQAChecker.h"
28 #include "AliZDCQADataMakerSim.h"
29 #include "AliZDCHit.h"
30 #include "AliZDCDigit.h"
31
32 ClassImp(AliZDCQADataMakerSim)
33            
34 //____________________________________________________________________________ 
35   AliZDCQADataMakerSim::AliZDCQADataMakerSim() : 
36       AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kZDC), "ZDC Quality Assurance Data Maker")
37 {
38   // ctor
39 }
40
41 //____________________________________________________________________________ 
42 AliZDCQADataMakerSim::AliZDCQADataMakerSim(const AliZDCQADataMakerSim& qadm) :
43     AliQADataMakerSim()
44 {
45   //copy ctor 
46   SetName((const char*)qadm.GetName()); 
47   SetTitle((const char*)qadm.GetTitle()); 
48 }
49
50 //__________________________________________________________________
51 AliZDCQADataMakerSim& AliZDCQADataMakerSim::operator = (const AliZDCQADataMakerSim& qadm )
52 {
53   // Equal operator.
54   this->~AliZDCQADataMakerSim();
55   new(this) AliZDCQADataMakerSim(qadm);
56   return *this;
57 }
58  
59 //____________________________________________________________________________ 
60 void AliZDCQADataMakerSim::InitHits()
61 {
62   // create Hits histograms in Hits subdir
63   //
64   const Bool_t expert   = kTRUE ; 
65   const Bool_t image    = kTRUE ; 
66
67   TH1F * hHitsZNCTot = new TH1F("hHitsZNCTot", "Signal in ZNC; N_{phe}", 100, 0., 6000.);
68   TH1F * hHitsZNATot = new TH1F("hHitsZNATot", "Signal in ZNA; N_{phe}", 100, 0., 6000.);
69   TH1F * hHitsZPCTot = new TH1F("hHitsZPCTot", "Signal in ZPC; N_{phe}", 100, 0., 6000.);
70   TH1F * hHitsZPATot = new TH1F("hHitsZPATot", "Signal in ZPA; N_{phe}", 100, 0., 6000.);
71   Add2HitsList(hHitsZNCTot, 0, !expert, image);
72   Add2HitsList(hHitsZNATot, 1, !expert, image);
73   Add2HitsList(hHitsZPCTot, 2, !expert, image);
74   Add2HitsList(hHitsZPATot, 3, !expert, image);
75   //
76   TH1F * hHitsSumQZNC = new TH1F("hHitsSumQZNC", "Signal in 4 ZNC PMQ; N_{phe}",100, 0., 4000.);
77   TH1F * hHitsSumQZNA = new TH1F("hHitsSumQZNA", "Signal in 4 ZNA PMQ; N_{phe}",100, 0., 4000.);
78   TH1F * hHitsSumQZPC = new TH1F("hHitsSumQZPC", "Signal in 4 ZPC PMQ; N_{phe}",100, 0., 4000.);
79   TH1F * hHitsSumQZPA = new TH1F("hHitsSumQZPA", "Signal in 4 ZPA PMQ; N_{phe}",100, 0., 4000.);
80   Add2HitsList(hHitsSumQZNC, 4, expert, !image);
81   Add2HitsList(hHitsSumQZNA, 5, expert, !image);
82   Add2HitsList(hHitsSumQZPC, 6, expert, !image);
83   Add2HitsList(hHitsSumQZPA, 7, expert, !image);
84   //
85   TH1F * hHitsPMCZNC = new TH1F("hHitsPMCZNC", "Signal in ZNC PMC; N_{phe}",100, 0., 4000.);
86   TH1F * hHitsPMCZNA = new TH1F("hHitsPMCZNA", "Signal in ZNA PMC; N_{phe}",100, 0., 4000.);
87   TH1F * hHitsPMCZPC = new TH1F("hHitsPMCZPC", "Signal in ZPC PMC; N_{phe}",100, 0., 4000.);
88   TH1F * hHitsPMCZPA = new TH1F("hHitsPMCZPA", "Signal in ZPA PMC; N_{phe}",100, 0., 4000.);
89   Add2HitsList(hHitsPMCZNC, 8, expert, !image);
90   Add2HitsList(hHitsPMCZNA, 9, expert, !image);
91   Add2HitsList(hHitsPMCZPC, 10, expert, !image);
92   Add2HitsList(hHitsPMCZPA, 11, expert, !image);
93   
94   ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
95 }
96
97
98 //____________________________________________________________________________ 
99 void AliZDCQADataMakerSim::InitDigits()
100 {
101   // create Digits histograms in Digits subdir
102   //
103   const Bool_t expert   = kTRUE ; 
104   const Bool_t image    = kTRUE ; 
105   
106   // ------------------- HIGH GAIN CHAIN ---------------------------
107   TH1F * hDigZNCTot = new TH1F("hDigZNCTot", "Signal in ZNC;Amplitude [ADC counts];Counts", 100, 0., 6000.);
108   TH1F * hDigZNATot = new TH1F("hDigZNATot", "Signal in ZNA;Amplitude [ADC counts];Counts", 100, 0., 6000.);
109   TH1F * hDigZPCTot = new TH1F("hDigZPCTot", "Signal in ZPC;Amplitude [ADC counts];Counts", 100, 0., 6000.);
110   TH1F * hDigZPATot = new TH1F("hDigZPATot", "Signal in ZPA;Amplitude [ADC counts];Counts", 100, 0., 6000.);
111   Add2DigitsList(hDigZNCTot, 0, !expert, image);
112   Add2DigitsList(hDigZNATot, 1, !expert, image);
113   Add2DigitsList(hDigZPCTot, 2, !expert, image);
114   Add2DigitsList(hDigZPATot, 3, !expert, image);
115   //
116   TH1F * hDigSumQZNC = new TH1F("hDigSumQZNC", "Signal in 4 ZNC PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
117   TH1F * hDigSumQZNA = new TH1F("hDigSumQZNA", "Signal in 4 ZNA PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
118   TH1F * hDigSumQZPC = new TH1F("hDigSumQZPC", "Signal in 4 ZPC PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
119   TH1F * hDigSumQZPA = new TH1F("hDigSumQZPA", "Signal in 4 ZPA PMQ;Amplitude [ADC counts];Counts",100, 0., 4000.);
120   Add2DigitsList(hDigSumQZNC, 4, expert, !image);
121   Add2DigitsList(hDigSumQZNA, 5, expert, !image);
122   Add2DigitsList(hDigSumQZPC, 6, expert, !image);
123   Add2DigitsList(hDigSumQZPA, 7, expert, !image);
124   //
125   TH1F * hDigPMCZNC = new TH1F("hDigPMCZNC", "Signal in ZNC PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
126   TH1F * hDigPMCZNA = new TH1F("hDigPMCZNA", "Signal in ZNA PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
127   TH1F * hDigPMCZPC = new TH1F("hDigPMCZPC", "Signal in ZPC PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
128   TH1F * hDigPMCZPA = new TH1F("hDigPMCZPA", "Signal in ZPA PMC;Amplitude [ADC counts];Counts",100, 0., 4000.);
129   Add2DigitsList(hDigPMCZNC, 8, expert, !image);
130   Add2DigitsList(hDigPMCZNA, 9, expert, !image);
131   Add2DigitsList(hDigPMCZPC, 10, expert, !image);
132   Add2DigitsList(hDigPMCZPA, 11, expert, !image);
133   // 
134   //
135   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
136 }
137
138 //____________________________________________________________________________
139 void AliZDCQADataMakerSim::MakeHits()
140 {
141   //filling QA histos for Hits
142
143   // Check id histograms already created for this Event Specie
144   if( !GetHitsData(0) ) InitHits();
145   
146   TIter next(fHitsArray); 
147   AliZDCHit * hit; 
148   Float_t adcSum_ZNC=0., adcSum_ZNA=0., adcSum_ZPC=0., adcSum_ZPA=0.;
149   Float_t adcSumQ_ZNC=0., adcSumQ_ZNA=0., adcSumQ_ZPC=0., adcSumQ_ZPA=0.;
150   while((hit = dynamic_cast<AliZDCHit *>(next()))){
151     if(hit->GetVolume(0)==1){
152        adcSumQ_ZNC += hit->GetLightPMQ();
153        adcSum_ZNC  += hit->GetLightPMC() + hit->GetLightPMQ();
154        //
155        FillHitsData(8,hit->GetLightPMC());
156     }
157     else if(hit->GetVolume(0)==4){
158        adcSumQ_ZNA += hit->GetLightPMQ();
159        adcSum_ZNA  += hit->GetLightPMC() + hit->GetLightPMQ();
160        //
161        FillHitsData(9,hit->GetLightPMC());
162     }
163     else if(hit->GetVolume(0)==2){
164        adcSumQ_ZNC += hit->GetLightPMQ();
165        adcSum_ZNC  += hit->GetLightPMC() + hit->GetLightPMQ();
166        //
167        FillHitsData(10,hit->GetLightPMC());
168     }
169     else if(hit->GetVolume(0)==5){
170        adcSumQ_ZNC += hit->GetLightPMQ();
171        adcSum_ZNC  += hit->GetLightPMC() + hit->GetLightPMQ();
172        //
173        FillHitsData(11,hit->GetLightPMC());
174     }
175     //
176     FillHitsData(0,adcSum_ZNC);
177     FillHitsData(1,adcSum_ZNA);
178     FillHitsData(2,adcSum_ZPC);
179     FillHitsData(3,adcSum_ZPA);
180     //
181     FillHitsData(4,adcSumQ_ZNC);
182     FillHitsData(5,adcSumQ_ZNA);
183     FillHitsData(6,adcSumQ_ZPC);
184     FillHitsData(7,adcSumQ_ZPA);
185   }
186 }
187
188 //___________________________________________________________________________
189 void AliZDCQADataMakerSim::MakeHits(TTree * hitTree)
190 {
191   // make QA data from Hit Tree
192   if(!hitTree){
193     AliError("Can't get ZDC hit tree!!");
194     return; 
195   }     
196
197   TBranch * branch = hitTree->GetBranch("ZDC") ;
198
199   if(!branch){
200     AliError("ZDC branch in Hit Tree not found!"); 
201     return;
202   } 
203   
204   if(fHitsArray) fHitsArray->Clear() ; 
205   else fHitsArray = new TClonesArray("AliZDCHit", 1000);
206  
207   branch->SetAddress(&fHitsArray) ;
208   for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
209     branch->GetEntry(ientry) ;
210     MakeHits() ; 
211     fHitsArray->Clear() ; 
212   }   
213   //
214   IncEvCountCycleHits();
215   IncEvCountTotalHits();
216   //
217 }
218
219 //___________________________________________________________________________
220 void AliZDCQADataMakerSim::MakeDigits(TTree *digitTree)
221 {
222   // makes data from Digit Tree
223   if( !GetDigitsData(0) ) InitDigits();
224
225   if(!digitTree){
226     AliError("Can't get ZDC digit tree!!");
227     return; 
228   }     
229    
230   TBranch * branch = digitTree->GetBranch("ZDC");
231   if(!branch){
232     AliError("ZDC branch in digit tree not found"); 
233     return;
234   } 
235     
236   AliZDCDigit *digit = 0x0;
237   branch->SetAddress(&digit);
238      
239   Float_t adcSum_ZNC=0., adcSum_ZNA=0., adcSum_ZPC=0., adcSum_ZPA=0.;
240   Float_t adcSumQ_ZNC=0., adcSumQ_ZNA=0., adcSumQ_ZPC=0., adcSumQ_ZPA=0.;
241   //  Float_t adcSum_ZNC_lg=0., adcSum_ZNA_lg=0., adcSum_ZPC_lg=0., adcSum_ZPA_lg=0.;
242   //  Float_t adcSumQ_ZNC_lg=0., adcSumQ_ZNA_lg=0., adcSumQ_ZPC_lg=0., adcSumQ_ZPA_lg=0.;
243   
244   Int_t ndig = digitTree->GetEntries();
245   for(Int_t i=0; i<ndig; i++){
246       branch->GetEntry(i);
247       
248       if(digit->GetSector(0)==1 && digit->GetSector(1)!=5){
249           adcSum_ZNC += digit->GetADCValue(0);
250           //adcSum_ZNC_lg += digit->GetADCValue(1);
251           //
252           if(digit->GetSector(1)!=0){
253               adcSumQ_ZNC += digit->GetADCValue(0);
254               //adcSumQ_ZNC_lg+= digit->GetADCValue(1);
255           }
256           else{
257               FillDigitsData(8,digit->GetADCValue(0));
258               //FillDigitsData(20,digit->GetADCValue(1));
259           }
260       }
261       else if(digit->GetSector(0)==2){
262           adcSum_ZPC += digit->GetADCValue(0);
263           //adcSum_ZPC_lg += digit->GetADCValue(1);
264           //
265           if(digit->GetSector(1)!=0){
266               adcSumQ_ZPC += digit->GetADCValue(0);
267               //adcSumQ_ZPC_lg+= digit->GetADCValue(1);
268           }
269           else{
270               FillDigitsData(10,digit->GetADCValue(0));
271               //FillDigitsData(22,digit->GetADCValue(1));
272           }
273       }
274       else if(digit->GetSector(0)==4 && digit->GetSector(1)!=5){
275           adcSum_ZNA += digit->GetADCValue(0);
276           //adcSum_ZNA_lg += digit->GetADCValue(1);
277           //
278           if(digit->GetSector(1)!=0){
279               adcSumQ_ZNA += digit->GetADCValue(0);
280               //adcSumQ_ZNA_lg+= digit->GetADCValue(1);
281           }
282           else{
283               FillDigitsData(9,digit->GetADCValue(0));
284               //FillDigitsData(21,digit->GetADCValue(1));
285           }
286       }
287       else if(digit->GetSector(0)==5){
288           adcSum_ZPA += digit->GetADCValue(0);
289           //adcSum_ZPA_lg += digit->GetADCValue(1);
290           //
291           if(digit->GetSector(1)!=0){
292               adcSumQ_ZPA += digit->GetADCValue(0);
293               //adcSumQ_ZPA_lg+= digit->GetADCValue(1);
294           }
295           else{
296               FillDigitsData(11,digit->GetADCValue(0));
297               //FillDigitsData(23,digit->GetADCValue(1));
298           }
299       }
300   }
301   //
302   FillDigitsData(0,adcSum_ZNC);
303   FillDigitsData(1,adcSum_ZNA);
304   FillDigitsData(2,adcSum_ZPC);
305   FillDigitsData(3,adcSum_ZPA);
306   //
307   FillDigitsData(4,adcSumQ_ZNC);
308   FillDigitsData(5,adcSumQ_ZNA);
309   FillDigitsData(6,adcSumQ_ZPC);
310   FillDigitsData(7,adcSumQ_ZPA);
311   //
312   IncEvCountCycleDigits();
313   IncEvCountTotalDigits();
314   //
315 }
316
317 //____________________________________________________________________________
318 void AliZDCQADataMakerSim::StartOfDetectorCycle()
319 {
320   //Detector specific actions at start of cycle
321   
322 }
323
324 //____________________________________________________________________________ 
325 void AliZDCQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
326 {
327   // Detector specific actions at end of cycle
328   // do the QA checking
329   ResetEventTrigClasses();
330   AliQAChecker::Instance()->Run(AliQAv1::kZDC, task, list);  
331 }