Fix by Ruben
[u/mrichter/AliRoot.git] / ZDC / AliZDCQADataMakerSim.cxx
CommitLineData
3d2cda92 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
fdc38bb2 15\r
3d2cda92 16// --- Standard library ---\r
17#include <Riostream.h>\r
18// --- ROOT system ---\r
19#include <TClonesArray.h>\r
7d297381 20#include <TFile.h> \r
3d2cda92 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
3d2cda92 31\r
32ClassImp(AliZDCQADataMakerSim)\r
33 \r
34//____________________________________________________________________________ \r
35 AliZDCQADataMakerSim::AliZDCQADataMakerSim() : \r
796c8b58 36 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kZDC), "ZDC Quality Assurance Data Maker")\r
3d2cda92 37{\r
38 // ctor\r
39}\r
40\r
41//____________________________________________________________________________ \r
42AliZDCQADataMakerSim::AliZDCQADataMakerSim(const AliZDCQADataMakerSim& qadm) :\r
796c8b58 43 AliQADataMakerSim()\r
3d2cda92 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
51AliZDCQADataMakerSim& 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
60void AliZDCQADataMakerSim::InitHits()\r
61{\r
62 // create Hits histograms in Hits subdir\r
63 //\r
7d297381 64 const Bool_t expert = kTRUE ; \r
65 const Bool_t image = kTRUE ; \r
213a7d34 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
7d297381 93 \r
92664bc8 94 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line\r
3d2cda92 95}\r
96\r
97\r
98//____________________________________________________________________________ \r
99void AliZDCQADataMakerSim::InitDigits()\r
100{\r
101 // create Digits histograms in Digits subdir\r
102 //\r
7d297381 103 const Bool_t expert = kTRUE ; \r
104 const Bool_t image = kTRUE ; \r
105 \r
fdc38bb2 106 // ------------------- HIGH GAIN CHAIN ---------------------------\r
db72ff3b 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
7d297381 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
3d2cda92 115 //\r
db72ff3b 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
7d297381 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
3d2cda92 124 //\r
db72ff3b 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
7d297381 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
3d2cda92 133 // \r
3d2cda92 134 //\r
92664bc8 135 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line\r
3d2cda92 136}\r
137\r
138//____________________________________________________________________________\r
6252ceeb 139void AliZDCQADataMakerSim::MakeHits()\r
3d2cda92 140{\r
141 //filling QA histos for Hits\r
eca4fa66 142\r
143 // Check id histograms already created for this Event Specie\r
796c8b58 144 if( !GetHitsData(0) ) InitHits();\r
eca4fa66 145 \r
6252ceeb 146 TIter next(fHitsArray); \r
213a7d34 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
92664bc8 155 FillHitsData(8,hit->GetLightPMC());\r
213a7d34 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
92664bc8 161 FillHitsData(9,hit->GetLightPMC());\r
3d2cda92 162 }\r
213a7d34 163 else if(hit->GetVolume(0)==2){\r
164 adcSumQ_ZNC += hit->GetLightPMQ();\r
165 adcSum_ZNC += hit->GetLightPMC() + hit->GetLightPMQ();\r
166 //\r
92664bc8 167 FillHitsData(10,hit->GetLightPMC());\r
213a7d34 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
92664bc8 173 FillHitsData(11,hit->GetLightPMC());\r
213a7d34 174 }\r
175 //\r
92664bc8 176 FillHitsData(0,adcSum_ZNC);\r
177 FillHitsData(1,adcSum_ZNA);\r
178 FillHitsData(2,adcSum_ZPC);\r
179 FillHitsData(3,adcSum_ZPA);\r
213a7d34 180 //\r
92664bc8 181 FillHitsData(4,adcSumQ_ZNC);\r
182 FillHitsData(5,adcSumQ_ZNA);\r
183 FillHitsData(6,adcSumQ_ZPC);\r
184 FillHitsData(7,adcSumQ_ZPA);\r
213a7d34 185 }\r
3d2cda92 186}\r
187\r
188//___________________________________________________________________________\r
189void AliZDCQADataMakerSim::MakeHits(TTree * hitTree)\r
190{\r
191 // make QA data from Hit Tree\r
b143652b 192 if(!hitTree){\r
193 AliError("Can't get ZDC hit tree!!");\r
194 return; \r
195 } \r
3d2cda92 196\r
197 TBranch * branch = hitTree->GetBranch("ZDC") ;\r
3d2cda92 198\r
199 if(!branch){\r
200 AliError("ZDC branch in Hit Tree not found!"); \r
201 return;\r
fdc38bb2 202 } \r
b143652b 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
92664bc8 213 //\r
214 IncEvCountCycleHits();\r
215 IncEvCountTotalHits();\r
216 //\r
3d2cda92 217}\r
218\r
66317fbe 219//___________________________________________________________________________\r
2537e870 220void AliZDCQADataMakerSim::MakeDigits(TTree *digitTree)\r
66317fbe 221{\r
2537e870 222 // makes data from Digit Tree\r
796c8b58 223 if( !GetDigitsData(0) ) InitDigits();\r
2537e870 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
796c8b58 238 \r
fdc38bb2 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
92664bc8 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
796c8b58 243 \r
2537e870 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
796c8b58 249 adcSum_ZNC += digit->GetADCValue(0);\r
92664bc8 250 //adcSum_ZNC_lg += digit->GetADCValue(1);\r
66317fbe 251 //\r
796c8b58 252 if(digit->GetSector(1)!=0){\r
253 adcSumQ_ZNC += digit->GetADCValue(0);\r
92664bc8 254 //adcSumQ_ZNC_lg+= digit->GetADCValue(1);\r
66317fbe 255 }\r
256 else{\r
92664bc8 257 FillDigitsData(8,digit->GetADCValue(0));\r
258 //FillDigitsData(20,digit->GetADCValue(1));\r
66317fbe 259 }\r
3d2cda92 260 }\r
796c8b58 261 else if(digit->GetSector(0)==2){\r
262 adcSum_ZPC += digit->GetADCValue(0);\r
92664bc8 263 //adcSum_ZPC_lg += digit->GetADCValue(1);\r
66317fbe 264 //\r
796c8b58 265 if(digit->GetSector(1)!=0){\r
266 adcSumQ_ZPC += digit->GetADCValue(0);\r
92664bc8 267 //adcSumQ_ZPC_lg+= digit->GetADCValue(1);\r
66317fbe 268 }\r
269 else{\r
92664bc8 270 FillDigitsData(10,digit->GetADCValue(0));\r
271 //FillDigitsData(22,digit->GetADCValue(1));\r
66317fbe 272 }\r
3d2cda92 273 }\r
2537e870 274 else if(digit->GetSector(0)==4 && digit->GetSector(1)!=5){\r
796c8b58 275 adcSum_ZNA += digit->GetADCValue(0);\r
92664bc8 276 //adcSum_ZNA_lg += digit->GetADCValue(1);\r
66317fbe 277 //\r
796c8b58 278 if(digit->GetSector(1)!=0){\r
279 adcSumQ_ZNA += digit->GetADCValue(0);\r
92664bc8 280 //adcSumQ_ZNA_lg+= digit->GetADCValue(1);\r
66317fbe 281 }\r
282 else{\r
92664bc8 283 FillDigitsData(9,digit->GetADCValue(0));\r
284 //FillDigitsData(21,digit->GetADCValue(1));\r
66317fbe 285 }\r
3d2cda92 286 }\r
796c8b58 287 else if(digit->GetSector(0)==5){\r
288 adcSum_ZPA += digit->GetADCValue(0);\r
92664bc8 289 //adcSum_ZPA_lg += digit->GetADCValue(1);\r
66317fbe 290 //\r
796c8b58 291 if(digit->GetSector(1)!=0){\r
292 adcSumQ_ZPA += digit->GetADCValue(0);\r
92664bc8 293 //adcSumQ_ZPA_lg+= digit->GetADCValue(1);\r
66317fbe 294 }\r
295 else{\r
92664bc8 296 FillDigitsData(11,digit->GetADCValue(0));\r
297 //FillDigitsData(23,digit->GetADCValue(1));\r
66317fbe 298 }\r
3d2cda92 299 }\r
3d2cda92 300 }\r
301 //\r
92664bc8 302 FillDigitsData(0,adcSum_ZNC);\r
303 FillDigitsData(1,adcSum_ZNA);\r
304 FillDigitsData(2,adcSum_ZPC);\r
305 FillDigitsData(3,adcSum_ZPA);\r
3d2cda92 306 //\r
92664bc8 307 FillDigitsData(4,adcSumQ_ZNC);\r
308 FillDigitsData(5,adcSumQ_ZNA);\r
309 FillDigitsData(6,adcSumQ_ZPC);\r
310 FillDigitsData(7,adcSumQ_ZPA);\r
3d2cda92 311 //\r
92664bc8 312 IncEvCountCycleDigits();\r
313 IncEvCountTotalDigits();\r
3d2cda92 314 //\r
796c8b58 315}\r
316\r
3d2cda92 317//____________________________________________________________________________\r
318void AliZDCQADataMakerSim::StartOfDetectorCycle()\r
319{\r
320 //Detector specific actions at start of cycle\r
321 \r
322}\r
323\r
324//____________________________________________________________________________ \r
4e25ac79 325void AliZDCQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)\r
3d2cda92 326{\r
fdc38bb2 327 // Detector specific actions at end of cycle\r
3d2cda92 328 // do the QA checking\r
92664bc8 329 ResetEventTrigClasses();\r
4e25ac79 330 AliQAChecker::Instance()->Run(AliQAv1::kZDC, task, list); \r
3d2cda92 331}\r