Changes for Root6 (Mikolaj)
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQADataMaker.cxx
CommitLineData
51504028 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//---
19// Produces the data needed to calculate the quality assurance.
20// ACORDE QA for Hits, Digits, RAW and ESD's
21//
22// Authors:
23//
24// Luciano Diaz Gonzalez <luciano.diaz@nucleares.unam.mx> (ICN-UNAM)
25// Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch> (FCFM-BUAP)
26// Arturo Fernandez Tellez <afernan@mail.cern.ch (FCFM-BUAP)
27//
28// Created: June 13th 2008
29//---
30
31// --- ROOT system ---
32#include <TClonesArray.h>
33#include <TFile.h>
34#include <TH1F.h>
35#include <TH2F.h>
36#include <TDirectory.h>
37#include <TObject.h>
38// --- Standard library ---
39
40// --- AliRoot header files ---
41#include "AliESDEvent.h"
42#include "AliLog.h"
43#include "AliACORDEdigit.h"
44#include "AliACORDEhit.h"
45#include "AliACORDERecPoint.h"
46#include "AliACORDEQADataMaker.h"
47#include "AliQAChecker.h"
48#include "AliACORDERawReader.h"
49#include "AliACORDERawStream.h"
50
51ClassImp(AliACORDEQADataMaker)
52
53//____________________________________________________________________________
4e25ac79 54AliACORDEQADataMaker::AliACORDEQADataMaker():AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")
51504028 55{
56 // Acorde QA Data Maker
57}
58
59//____________________________________________________________________________
60AliACORDEQADataMaker::AliACORDEQADataMaker(const AliACORDEQADataMaker& qadm):AliQADataMaker()
61{
62 SetName((const char*)qadm.GetName()) ;
63 SetTitle((const char*)qadm.GetTitle());
64}
65//__________________________________________________________________
66AliACORDEQADataMaker& AliACORDEQADataMaker::operator = (const AliACORDEQADataMaker& qadm )
67{
68 // Equal operator.
69 this->~AliACORDEQADataMaker();
70 new(this) AliACORDEQADataMaker(qadm);
71 return *this;
72}
73//____________________________________________________________________________
74void AliACORDEQADataMaker::StartOfDetectorCycle()
75{
76 //Detector specific actions at start of cycle
77
78}
79
80//____________________________________________________________________________
81void AliACORDEQADataMaker::InitHits()
82{
83
84// create Hits histograms in Hits subdir
85 TH1F *fAHitsACORDE[8];
86
87 fAHitsACORDE[0] = new TH1F("hACORDEloss" ,"Energy Loss ",1000,0.,1500.);
88 fAHitsACORDE[1] = new TH1F("hACORDEPolar" ," Polar Angle ",90,0.,90.);
89 fAHitsACORDE[2] = new TH1F("hACORDEAzimuth" ,"Azimuth Angle ",360,-180.,180.);
90 fAHitsACORDE[3] = new TH1F("hACORDEPx" ,"Px Distribution ",60,-30.,30.);
91 fAHitsACORDE[4] = new TH1F("hACORDEPy" ,"Py Distribution ",60,-30.,30.);
92 fAHitsACORDE[5] = new TH1F("hACORDEPz" ,"Pz Distribution ",60,-30.,30.);
93 fAHitsACORDE[6] = new TH1F("hACORDEPt" ,"Pt Distribution ",60,0.,50.);
94 fAHitsACORDE[7] = new TH1F("hACORDEpxpz" ,"Pt Distribution ",100,-50.,50.);
95
96 TH2F *hACORDExy = new TH2F("hACORDExy" ,"Dist. xy",2800,-2400.,1400.,200,-4805.,4825.);
97 TH2F *hACORDExz = new TH2F("hACORDExz" ,"Dist.xz ",900,-1500.,2850.,1200,-1000.,4000.);
98 TH2F *hACORDEyz = new TH2F("hACORDEyz" ,"Dist.yz ",5,817.,819.,1200,-600.,600.);
99 TH2F *hACORDEAzimPol = new TH2F("hACORDEAzimPol" ,"Azimuth vs Polar ",360,-180.,180.,180,0.,180.);
100
101 for(Int_t i=0; i<8; i++)
102 Add2HitsList(fAHitsACORDE[i],i);
103
104 Add2HitsList(hACORDExy,8);
105 Add2HitsList(hACORDExz,9);
106 Add2HitsList(hACORDEyz,10);
107 Add2HitsList(hACORDEAzimPol,11);
92664bc8 108 //
109 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
51504028 110}
92664bc8 111
51504028 112//____________________________________________________________________________
113void AliACORDEQADataMaker::InitDigits()
114{
115// create Digits histograms in Digits subdir
116
117 TH1F * fhDigitsModule;
118 TString modulename;
119 modulename = "hDigitsModule";
120 fhDigitsModule = new TH1F(modulename.Data(),"hDigitsModuleSingle",60,0,60);
121 Add2DigitsList( fhDigitsModule,0);
92664bc8 122 //
123 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
51504028 124}
125
126//____________________________________________________________________________
127void AliACORDEQADataMaker::InitRaws()
128{
129 // create Raw histograms in Raw subdir
92664bc8 130 TH1F *fhACORDEBitPattern[4];
131 fhACORDEBitPattern[0] = new TH1F("ACORDERawDataSM","ACORDE-SingleMuon",60,1,60);//AcordeSingleMuon BitPattern
132 fhACORDEBitPattern[1] = new TH1F("ACORDERawDataMM","ACORDE-MultiMuon",60,1,60);//AcordeMultiMuon BitPattern
133 fhACORDEBitPattern[2] = new TH1F("ACORDERawDataSMM","ACORDE-SingleMuonMultiplicity",60,1,60);//AcordeSingleMuon Multiplicity
134 fhACORDEBitPattern[3] = new TH1F("ACORDERawDataMMM","ACORDE-MultiMuonMultiplicity",60,1,60);//AcordeMultiMuon Multiplicity
135 for(Int_t i=0;i<4;i++) {
136 Add2RawsList(fhACORDEBitPattern[i],i);
137 }
138 //
139 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
51504028 140}
141
142//____________________________________________________________________________
143
144void AliACORDEQADataMaker::InitRecPoints()
145{
146 // create cluster histograms in RecPoint subdir
92664bc8 147 // Not needed for ACORDE by now !!
148 //
149 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
51504028 150}
92664bc8 151
51504028 152//____________________________________________________________________________
153void AliACORDEQADataMaker::InitESDs()
154{
155 //create ESDs histograms in ESDs subdir
156
157 TH1F * fhESDsSingle;
158 TH1F * fhESDsMulti;
159
160 TString name;
161
162 name = "hESDsSingle";
163 fhESDsSingle = new TH1F(name.Data(),"hESDsSingle",60,0,60);
164 Add2ESDsList( fhESDsSingle,0);
165
166 name = "hESDsMulti";
167 fhESDsMulti = new TH1F(name.Data(),"hESDsMulti",60,0,60);
168 Add2ESDsList( fhESDsMulti,1);
92664bc8 169 //
170 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
51504028 171
172}
173//____________________________________________________________________________
174
175void AliACORDEQADataMaker::MakeHits(TTree *hitTree)
176{
177
178 // Here we fill the QA histos for Hits declared above
92664bc8 179 IncEvCountCycleHits();
180 IncEvCountTotalHits();
181
51504028 182 printf("Estamos en make Hits");
183 TClonesArray * hits = new TClonesArray("AliACORDEhit",1000);
184 TBranch * branch = hitTree->GetBranch("ACORDE");
185 if (!branch)
186 {
187 AliWarning("ACORDE branch in Hit Tree not found");
188 }else
189 {
190 if (branch)
191 {
192 branch->SetAddress(&hits);
193 }else
194 {
195 AliError("Branch ACORDE hit not found");
196 exit(111);
197 }
198 Int_t ntracks = (Int_t)hitTree->GetEntries();
199 if (ntracks<=0) return;
200 for(Int_t track=0;track<ntracks;track++)
201 {
202 branch->GetEntry(track);
203 Int_t nhits = hits->GetEntriesFast();
204 for(Int_t ihit=0;ihit<nhits;ihit++)
205 {
206 AliACORDEhit *AcoHit = (AliACORDEhit*) hits->UncheckedAt(ihit);
207 if (!AcoHit)
208 {
209 AliError("The unchecked hit doesn't exist");
210 break;
211 }
92664bc8 212 FillHitsData(0,AcoHit->Eloss());
213 FillHitsData(1,AcoHit->PolarAngle());
214 FillHitsData(2,AcoHit->AzimuthAngle());
215 FillHitsData(3,AcoHit->Px());
216 FillHitsData(4,AcoHit->Py());
217 FillHitsData(5,AcoHit->Pz());
218 FillHitsData(6,TMath::Sqrt( (AcoHit->Px())*(AcoHit->Px())+
51504028 219 (AcoHit->Py())*(AcoHit->Py())));
92664bc8 220 if((AcoHit->Py()) != 0.0 ) FillHitsData(7,TMath::ATan(AcoHit->Px()/AcoHit->Py()));
221 FillHitsData(8, (Float_t)(AcoHit->X()),(Float_t)(AcoHit->Y()) );
222 FillHitsData(9, (Float_t)(AcoHit->X()),(Float_t)(AcoHit->Z()) );
223 FillHitsData(10, (Float_t)(AcoHit->Y()),(Float_t)(AcoHit->Z()) );
224 FillHitsData(11, (Float_t)(AcoHit->AzimuthAngle()),
225 (Float_t)(AcoHit->PolarAngle()));
51504028 226 }
227 }
228 }
229
230
231
232}
233
234//____________________________________________________________________________
235void AliACORDEQADataMaker::MakeDigits( TTree *digitsTree)
236{
237 //fills QA histos for Digits
92664bc8 238 IncEvCountCycleDigits();
239 IncEvCountTotalDigits();
51504028 240
241
242 TClonesArray * digits = new TClonesArray("AliACORDEdigit",1000);
243 TBranch * branch = digitsTree->GetBranch("ACORDEdigit");
244 if (!branch)
245 {
246 AliWarning("ACORDE branch in Digits Tree not found");
247 }else
248 {
249 if (branch)
250 {
251 branch->SetAddress(&digits);
252 }else
253 {
254 AliError("Branch ACORDE digit not found");
255 exit(111);
256 }
257 Int_t ntracks = (Int_t)digitsTree->GetEntries();
258 if (ntracks<=0) return;
259 printf("Entries in DigitsTree:%d\n",ntracks);
260 for(Int_t track=0;track<ntracks;track++)
261 {
262 branch->GetEntry(track);
263 Int_t ndigits = digits->GetEntriesFast();
264 for(Int_t idigit=0;idigit<ndigits;idigit++)
265 {
266 AliACORDEdigit *AcoDigit = (AliACORDEdigit*) digits->UncheckedAt(idigit);
267 if (!AcoDigit)
268 {
269 AliError("The unchecked digit doesn't exist");
270 break;
271 }
92664bc8 272 FillDigitsData(0,AcoDigit->GetModule()-1);
51504028 273 }
274 }
275
276
277 }
278
279
280}
281
282
283//____________________________________________________________________________
284void AliACORDEQADataMaker::MakeRaws( AliRawReader* rawReader)
285{
286
287 //fills QA histos for RAW
92664bc8 288 IncEvCountCycleRaws();
289 IncEvCountTotalRaws();
290
51504028 291 rawReader->Reset();
292 AliACORDERawStream rawStream(rawReader);
293 size_t contSingle=0;
294 size_t contMulti=0;
295 UInt_t dy[4];
296
297 bool kroSingle[60],kroMulti[60];
298 UInt_t tmpDy;
299
300 for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}
301
302if(rawStream.Next())
303{
304 rawReader->NextEvent();
305 rawStream.Reset();
306 dy[0]=rawStream.GetWord(0);
307 dy[1]=rawStream.GetWord(1);
308 dy[2]=rawStream.GetWord(2);
309 dy[3]=rawStream.GetWord(3);
310 tmpDy=dy[0];
311 for(Int_t r=0;r<30;++r)
312 {
313 kroSingle[r] = tmpDy & 1;
314 tmpDy>>=1;
315 }
316 tmpDy=dy[1];
317 for(Int_t r=30;r<60;++r)
318 {
319 kroSingle[r] = tmpDy & 1;
320 tmpDy>>=1;
321 }
322 tmpDy=dy[2];
323 for(Int_t r=0;r<30;++r)
324 {
325 kroMulti[r] = tmpDy & 1;
326 tmpDy>>=1;
327 }
328 tmpDy=dy[3];
329 for(Int_t r=30;r<60;++r)
330 {
331 kroMulti[r] = tmpDy & 1;
332 tmpDy>>=1;
333 }
334 contSingle=0;
335 contMulti=0;
336 for(Int_t r=0;r<60;++r)
337 {
338 if(kroSingle[r]==1)
339 {
92664bc8 340 FillRawsData(0,r+1);
341 contSingle=contSingle+1;
51504028 342 }
343 if(kroMulti[r]==1)
344 {
92664bc8 345 FillRawsData(1,r+1);
346 contMulti++;
51504028 347 }
348
92664bc8 349 } FillRawsData(2,contSingle); FillRawsData(3,contMulti);
51504028 350}
351
352
353
354}
355//____________________________________________________________________________
356void AliACORDEQADataMaker::MakeRecPoints(TTree * clustersTree)
357{
358 //fills QA histos for clusters
92664bc8 359 IncEvCountCycleRecPoints();
360 IncEvCountTotalRecPoints();
361
51504028 362 // Not needed for ACORDE by now!!!
363}
364
365//____________________________________________________________________________
366void AliACORDEQADataMaker::MakeESDs(AliESDEvent * esd)
367{
368 //fills QA histos for ESD
92664bc8 369 IncEvCountCycleESDs();
370 IncEvCountTotalESDs();
371
51504028 372
373 AliESDACORDE * fESDACORDE= esd->GetACORDEData();
374 Int_t *fACORDEMultiMuon =fESDACORDE->GetACORDEMultiMuon();
375 Int_t *fACORDESingleMuon=fESDACORDE->GetACORDESingleMuon();
376
92664bc8 377 for(int i=0;i<60;i++){
378 if(fACORDESingleMuon[i]==1)
379 FillESDsData(0,i);
380 if(fACORDEMultiMuon[i]==1)
381 FillESDsData(1,i);
51504028 382 }
92664bc8 383
384
51504028 385
386}
387