]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCQADataMakerSim.cxx
Typo corrected.
[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 // --- Standard library ---
16 #include <Riostream.h>
17 // --- ROOT system ---
18 #include <TClonesArray.h>
19 #include <TFile.h> 
20 #include <TH1F.h> 
21 #include <TH2F.h>
22 #include <TBranch.h>
23 #include <TTree.h>
24 // --- AliRoot header files ---
25 #include "AliLog.h"
26 #include "AliQAChecker.h"
27 #include "AliZDCQADataMakerSim.h"
28 #include "AliZDCHit.h"
29 #include "AliZDCDigit.h"
30 #include "AliZDCRawStream.h"
31
32 ClassImp(AliZDCQADataMakerSim)
33            
34 //____________________________________________________________________________ 
35   AliZDCQADataMakerSim::AliZDCQADataMakerSim() : 
36   AliQADataMakerSim(AliQA::GetDetName(AliQA::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   TH2F * hZNCh  = new TH2F("hZNCh", "Hits centroid in ZNC", 100, -5.,5.,100,-5.,5.);
65   TH2F * hZNAh  = new TH2F("hZNAh", "Hits centroid in ZNA", 100, -5.,5.,100,-5.,5.);
66   TH2F * hZPCh  = new TH2F("hZPCh", "Hits centroid in ZPC", 100,-12.,12.,100,-12.,12.); 
67   TH2F * hZPAh  = new TH2F("hZPAh", "Hits centroid in ZPA", 100,-12.,12.,100,-12.,12.); 
68   Add2HitsList(hZNCh, 0);
69   Add2HitsList(hZPCh, 1);
70   Add2HitsList(hZNAh, 2);
71   Add2HitsList(hZPAh, 3);
72 }
73
74
75 //____________________________________________________________________________ 
76 void AliZDCQADataMakerSim::InitDigits()
77 {
78   // create Digits histograms in Digits subdir
79   //
80   TH1F * hDigZNCTot = new TH1F("hDigZNCTot", "Digit signal in ZNC", 100, 0., 6000.);
81   TH1F * hDigZNATot = new TH1F("hDigZNATot", "Digit signal in ZNA", 100, 0., 6000.);
82   TH1F * hDigZPCTot = new TH1F("hDigZPCTot", "Digit signal in ZPC", 100, 0., 10000.);
83   TH1F * hDigZPATot = new TH1F("hDigZPATot", "Digit signal in ZPA", 100, 0., 10000.);
84   Add2DigitsList(hDigZNCTot, 0);
85   Add2DigitsList(hDigZPCTot, 1);
86   Add2DigitsList(hDigZNATot, 2);
87   Add2DigitsList(hDigZPATot, 3);
88   //
89   TH1F * hDigSumQZNC = new TH1F("hDigSumQZNC", "Signal in 4 ZNC PMQ[i]",100, 0., 4000.);
90   TH1F * hDigSumQZPC = new TH1F("hDigSumQZPC", "Signal in 4 ZPC PMQ[i]",100, 0., 4000.);
91   TH1F * hDigSumQZNA = new TH1F("hDigSumQZNA", "Signal in 4 ZNA PMQ[i]",100, 0., 4000.);
92   TH1F * hDigSumQZPA = new TH1F("hDigSumQZPA", "Signal in 4 ZPA PMQ[i]",100, 0., 4000.);
93   Add2DigitsList(hDigSumQZNC, 4);
94   Add2DigitsList(hDigSumQZPC, 5);
95   Add2DigitsList(hDigSumQZNA, 6);
96   Add2DigitsList(hDigSumQZPA, 7);
97   //
98   TH1F * hDigPMCZNC = new TH1F("hDigPMCZNC", "Signal in 4 ZNC PMQ[i]",100, 0., 4000.);
99   TH1F * hDigPMCZPC = new TH1F("hDigPMCZPC", "Signal in 4 ZPC PMQ[i]",100, 0., 4000.);
100   TH1F * hDigPMCZNA = new TH1F("hDigPMCZNA", "Signal in 4 ZNA PMQ[i]",100, 0., 4000.);
101   TH1F * hDigPMCZPA = new TH1F("hDigPMCZPA", "Signal in 4 ZPA PMQ[i]",100, 0., 4000.);
102   Add2DigitsList(hDigPMCZNC, 8);
103   Add2DigitsList(hDigPMCZPC, 9);
104   Add2DigitsList(hDigPMCZNA, 10);
105   Add2DigitsList(hDigPMCZPA, 11);
106   // 
107   // ------------------- LOW GAIN CHAIN ---------------------------
108   TH1F * hDigZNCTotlg = new TH1F("hDigZNCTotlg", "Digit lg signal in ZNC", 100, 0., 6000.);
109   TH1F * hDigZNATotlg = new TH1F("hDigZNATotlg", "Digit lg signal in ZNA", 100, 0., 6000.);
110   TH1F * hDigZPCTotlg = new TH1F("hDigZPCTotlg", "Digit lg signal in ZPC", 100, 0., 10000.);
111   TH1F * hDigZPATotlg = new TH1F("hDigZPATotlg", "Digit lg signal in ZPA", 100, 0., 10000.);
112   Add2DigitsList(hDigZNCTotlg, 12);
113   Add2DigitsList(hDigZPCTotlg, 13);
114   Add2DigitsList(hDigZNATotlg, 14);
115   Add2DigitsList(hDigZPATotlg, 15);
116   //
117   TH1F * hDigSumQZNClg = new TH1F("hDigSumQZNClg", "Signal in 4 ZNC PMQlg[i]",100, 0., 4000.);
118   TH1F * hDigSumQZPClg = new TH1F("hDigSumQZPClg", "Signal in 4 ZPC PMQlg[i]",100, 0., 4000.);
119   TH1F * hDigSumQZNAlg = new TH1F("hDigSumQZNAlg", "Signal in 4 ZNA PMQlg[i]",100, 0., 4000.);
120   TH1F * hDigSumQZPAlg = new TH1F("hDigSumQZPAlg", "Signal in 4 ZPA PMQlg[i]",100, 0., 4000.);
121   Add2DigitsList(hDigSumQZNClg, 16);
122   Add2DigitsList(hDigSumQZPClg, 17);
123   Add2DigitsList(hDigSumQZNAlg, 18);
124   Add2DigitsList(hDigSumQZPAlg, 19);
125   //
126   TH1F * hDigPMCZNClg = new TH1F("hDigPMCZNClg", "Signal in 4 ZNC PMQlg[i]",100, 0., 4000.);
127   TH1F * hDigPMCZPClg = new TH1F("hDigPMCZPClg", "Signal in 4 ZPC PMQlg[i]",100, 0., 4000.);
128   TH1F * hDigPMCZNAlg = new TH1F("hDigPMCZNAlg", "Signal in 4 ZNA PMQlg[i]",100, 0., 4000.);
129   TH1F * hDigPMCZPAlg = new TH1F("hDigPMCZPAlg", "Signal in 4 ZPA PMQlg[i]",100, 0., 4000.);
130   Add2DigitsList(hDigPMCZNClg, 20);
131   Add2DigitsList(hDigPMCZPClg, 21);
132   Add2DigitsList(hDigPMCZNAlg, 22);
133   Add2DigitsList(hDigPMCZPAlg, 23);
134 }
135
136 //____________________________________________________________________________
137 void AliZDCQADataMakerSim::MakeHits(TClonesArray * data)
138 {
139   //filling QA histos for Hits
140   //
141   fHits = dynamic_cast<TClonesArray *>(data); 
142   if(!fHits){
143     AliError("Wrong type of hits container"); 
144   } 
145   else {
146     TIter next(fHits); 
147     AliZDCHit * hit; 
148     while((hit = dynamic_cast<AliZDCHit *>(next()))){
149       if(hit->GetVolume(0)==1) GetHitsData(0)->Fill(hit->GetXImpact(),hit->GetYImpact());
150       else if(hit->GetVolume(0)==2) GetHitsData(1)->Fill(hit->GetXImpact(), hit->GetYImpact());
151       else if(hit->GetVolume(0)==4) GetHitsData(2)->Fill(hit->GetXImpact(), hit->GetYImpact());
152       else if(hit->GetVolume(0)==5) GetHitsData(3)->Fill(hit->GetXImpact(), hit->GetYImpact());
153     }
154   } 
155
156 }
157
158 //___________________________________________________________________________
159 void AliZDCQADataMakerSim::MakeHits(TTree * hitTree)
160 {
161   // make QA data from Hit Tree
162   //
163   if(!hitTree){
164     AliError("Hit Tree not found!"); 
165     return;
166   }
167   //
168   TBranch * branch = hitTree->GetBranch("ZDC") ;
169   if(!branch){
170     AliError("ZDC branch in Hit Tree not found!"); 
171     return;
172   }
173   else{
174     Int_t ntracks = (Int_t) hitTree->GetEntries();
175     //printf("\n\t *** no.track %d\n",ntracks);
176     if (ntracks<=0) return;
177     //
178     for(Int_t itrack=0; itrack<ntracks; itrack++){
179       fHits = new TClonesArray("AliZDCHit", 1000);
180       //
181       branch->SetAddress(&fHits) ;
182       branch->GetEntry(itrack);
183       //
184       //printf("\t *** track %d",itrack);
185       //hits->Print("");
186       //printf("\n");
187       //
188       MakeHits(fHits); 
189       fHits->Clear();
190     }     
191   }
192 }
193
194 //____________________________________________________________________________
195 void AliZDCQADataMakerSim::MakeDigits(TClonesArray * digits)
196 {
197   // makes data from Digits
198   //
199   TIter next(digits) ; 
200   AliZDCDigit * digit ; 
201   //
202   Float_t ADCSum_ZNC=0., ADCSum_ZNA=0., ADCSum_ZPC=0., ADCSum_ZPA=0.;
203   Float_t ADCSumQ_ZNC=0., ADCSumQ_ZNA=0., ADCSumQ_ZPC=0., ADCSumQ_ZPA=0.;
204   Float_t ADCSum_ZNC_lg=0., ADCSum_ZNA_lg=0., ADCSum_ZPC_lg=0., ADCSum_ZPA_lg=0.;
205   Float_t ADCSumQ_ZNC_lg=0., ADCSumQ_ZNA_lg=0., ADCSumQ_ZPC_lg=0., ADCSumQ_ZPA_lg=0.;
206   //
207   while((digit = dynamic_cast<AliZDCDigit *>(next()))){
208     if(digit->GetSector(0)==1){
209       ADCSum_ZNC += digit->GetADCValue(0);
210       ADCSum_ZNC_lg += digit->GetADCValue(1);
211       //
212       if(digit->GetSector(1)!=0){
213         ADCSumQ_ZNC += digit->GetADCValue(0);
214         ADCSumQ_ZNC_lg+= digit->GetADCValue(1);
215       }
216       else{
217         GetDigitsData(8)->Fill(digit->GetADCValue(0));
218         GetDigitsData(20)->Fill(digit->GetADCValue(1));
219       }
220     }
221     else if(digit->GetSector(0)==2){
222       ADCSum_ZPC += digit->GetADCValue(0);
223       ADCSum_ZPC_lg += digit->GetADCValue(1);
224       //
225       if(digit->GetSector(1)!=0){
226         ADCSumQ_ZPC += digit->GetADCValue(0);
227         ADCSumQ_ZPC_lg+= digit->GetADCValue(1);
228       }
229       else{
230         GetDigitsData(9)->Fill(digit->GetADCValue(0));
231         GetDigitsData(21)->Fill(digit->GetADCValue(1));
232       }
233     }
234     else if(digit->GetSector(0)==4){
235       ADCSum_ZNA += digit->GetADCValue(0);
236       ADCSum_ZNA_lg += digit->GetADCValue(1);
237       //
238       if(digit->GetSector(1)!=0){
239         ADCSumQ_ZNA += digit->GetADCValue(0);
240         ADCSumQ_ZNA_lg+= digit->GetADCValue(1);
241       }
242       else{
243         GetDigitsData(10)->Fill(digit->GetADCValue(0));
244         GetDigitsData(22)->Fill(digit->GetADCValue(1));
245       }
246     }
247     else if(digit->GetSector(0)==5){
248       ADCSum_ZPA += digit->GetADCValue(0);
249       ADCSum_ZPA_lg += digit->GetADCValue(1);
250       //
251       if(digit->GetSector(1)!=0){
252         ADCSumQ_ZPA += digit->GetADCValue(0);
253         ADCSumQ_ZPA_lg+= digit->GetADCValue(1);
254       }
255       else{
256         GetDigitsData(11)->Fill(digit->GetADCValue(0));
257         GetDigitsData(23)->Fill(digit->GetADCValue(1));
258       }
259     }
260   }
261   //
262   GetDigitsData(0)->Fill(ADCSum_ZNC);
263   GetDigitsData(1)->Fill(ADCSum_ZPC);
264   GetDigitsData(2)->Fill(ADCSum_ZNA);
265   GetDigitsData(3)->Fill(ADCSum_ZPA);
266   //
267   GetDigitsData(4)->Fill(ADCSumQ_ZNC);
268   GetDigitsData(5)->Fill(ADCSumQ_ZPC);
269   GetDigitsData(6)->Fill(ADCSumQ_ZNA);
270   GetDigitsData(7)->Fill(ADCSumQ_ZPA);
271   //
272   GetDigitsData(12)->Fill(ADCSum_ZNC_lg);
273   GetDigitsData(13)->Fill(ADCSum_ZPC_lg);
274   GetDigitsData(14)->Fill(ADCSum_ZNA_lg);
275   GetDigitsData(15)->Fill(ADCSum_ZPA_lg);
276   //
277   GetDigitsData(16)->Fill(ADCSumQ_ZNC_lg);
278   GetDigitsData(17)->Fill(ADCSumQ_ZPC_lg);
279   GetDigitsData(18)->Fill(ADCSumQ_ZNA_lg);
280   GetDigitsData(19)->Fill(ADCSumQ_ZPA_lg);
281    
282 }
283 //___________________________________________________________________________
284 void AliZDCQADataMakerSim::MakeDigits(TTree *digitTree )
285 {
286    // makes data from Digit Tree
287    fDigits = new TClonesArray("AliZDCDigit", 1000); 
288    //
289    TBranch * branch = digitTree->GetBranch("ZDC");
290    if(!branch){
291       AliError("ZDC branch in Digit Tree not found"); 
292       return;
293    } 
294    branch->SetAddress(&fDigits);
295    branch->GetEntry(0); 
296    MakeDigits(fDigits); 
297    fDigits->Clear();
298 }
299
300 //____________________________________________________________________________
301 void AliZDCQADataMakerSim::StartOfDetectorCycle()
302 {
303   //Detector specific actions at start of cycle
304   
305 }
306
307 //____________________________________________________________________________ 
308 void AliZDCQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
309 {
310   //Detector specific actions at end of cycle
311   // do the QA checking
312   AliQAChecker::Instance()->Run(AliQA::kZDC, task, list);  
313 }