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