]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEQADataMaker.cxx
Added some more scripts
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQADataMaker.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
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
51 ClassImp(AliACORDEQADataMaker)
52            
53 //____________________________________________________________________________ 
54 AliACORDEQADataMaker::AliACORDEQADataMaker():AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")
55 {
56         // Acorde QA Data Maker
57 }
58
59 //____________________________________________________________________________ 
60 AliACORDEQADataMaker::AliACORDEQADataMaker(const AliACORDEQADataMaker& qadm):AliQADataMaker() 
61 {
62   SetName((const char*)qadm.GetName()) ; 
63   SetTitle((const char*)qadm.GetTitle()); 
64 }
65 //__________________________________________________________________
66 AliACORDEQADataMaker& AliACORDEQADataMaker::operator = (const AliACORDEQADataMaker& qadm )
67 {
68   // Equal operator.
69   this->~AliACORDEQADataMaker();
70   new(this) AliACORDEQADataMaker(qadm);
71   return *this;
72 }
73 //____________________________________________________________________________
74 void AliACORDEQADataMaker::StartOfDetectorCycle()
75 {
76   //Detector specific actions at start of cycle
77
78 }
79  
80 //____________________________________________________________________________ 
81 void 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);
108
109 }
110 //____________________________________________________________________________ 
111 void AliACORDEQADataMaker::InitDigits()
112 {
113 // create Digits histograms in Digits subdir
114
115    TH1F *    fhDigitsModule;
116    TString   modulename;
117    modulename = "hDigitsModule";
118    fhDigitsModule = new TH1F(modulename.Data(),"hDigitsModuleSingle",60,0,60);
119    Add2DigitsList( fhDigitsModule,0);
120
121
122 }
123
124 //____________________________________________________________________________ 
125 void AliACORDEQADataMaker::InitRaws()
126 {
127   // create Raw histograms in Raw subdir
128 TH1D *fhACORDEBitPattern[4];
129 fhACORDEBitPattern[0] = new TH1D("ACORDERawDataSM","ACORDE-SingleMuon",60,1,60);//AcordeSingleMuon BitPattern
130 fhACORDEBitPattern[1] = new TH1D("ACORDERawDataMM","ACORDE-MultiMuon",60,1,60);//AcordeMultiMuon BitPattern
131 fhACORDEBitPattern[2] = new TH1D("ACORDERawDataSMM","ACORDE-SingleMuonMultiplicity",60,1,60);//AcordeSingleMuon Multiplicity
132 fhACORDEBitPattern[3] = new TH1D("ACORDERawDataMMM","ACORDE-MultiMuonMultiplicity",60,1,60);//AcordeMultiMuon Multiplicity
133 for(Int_t i=0;i<4;i++)
134 {
135         Add2RawsList(fhACORDEBitPattern[i],i);
136 }
137 }
138
139 //____________________________________________________________________________ 
140
141 void AliACORDEQADataMaker::InitRecPoints()
142 {
143   // create cluster histograms in RecPoint subdir
144   // Not needed for ACORDE by now !!!
145 }
146 //____________________________________________________________________________
147 void AliACORDEQADataMaker::InitESDs()
148 {
149   //create ESDs histograms in ESDs subdir
150
151    TH1F *    fhESDsSingle;
152    TH1F *    fhESDsMulti;
153
154    TString   name;
155
156    name = "hESDsSingle";
157    fhESDsSingle = new TH1F(name.Data(),"hESDsSingle",60,0,60);
158    Add2ESDsList( fhESDsSingle,0);
159
160    name = "hESDsMulti";
161    fhESDsMulti = new TH1F(name.Data(),"hESDsMulti",60,0,60);
162    Add2ESDsList( fhESDsMulti,1);
163
164
165
166 }
167 //____________________________________________________________________________
168
169 void AliACORDEQADataMaker::MakeHits(TTree *hitTree)
170 {
171
172  // Here we fill the QA histos for Hits declared above
173
174         printf("Estamos en make Hits");
175         TClonesArray * hits = new TClonesArray("AliACORDEhit",1000);
176         TBranch * branch = hitTree->GetBranch("ACORDE");
177         if (!branch)
178         {
179                 AliWarning("ACORDE branch in Hit Tree not found");
180         }else
181         {
182                 if (branch)
183                 {
184                         branch->SetAddress(&hits);
185                 }else
186                 {
187                         AliError("Branch ACORDE hit not found");
188                         exit(111);
189                 }
190                 Int_t ntracks = (Int_t)hitTree->GetEntries();
191                 if (ntracks<=0) return;
192                 for(Int_t track=0;track<ntracks;track++)
193                 {
194                         branch->GetEntry(track);
195                         Int_t nhits = hits->GetEntriesFast();
196                         for(Int_t ihit=0;ihit<nhits;ihit++)
197                         {
198                                 AliACORDEhit *AcoHit = (AliACORDEhit*) hits->UncheckedAt(ihit);
199                                 if (!AcoHit)
200                                 {
201                                         AliError("The unchecked hit doesn't exist");
202                                         break;
203                                 }
204                                 GetHitsData(0)->Fill(AcoHit->Eloss());
205                                 GetHitsData(1)->Fill(AcoHit->PolarAngle());
206                                 GetHitsData(2)->Fill(AcoHit->AzimuthAngle());
207                                 GetHitsData(3)->Fill(AcoHit->Px());
208                                 GetHitsData(4)->Fill(AcoHit->Py());
209                                 GetHitsData(5)->Fill(AcoHit->Pz());
210                                 GetHitsData(6)->Fill(TMath::Sqrt( (AcoHit->Px())*(AcoHit->Px())+
211                                              (AcoHit->Py())*(AcoHit->Py())));
212                                 if((AcoHit->Py()) != 0.0 ) GetHitsData(7)->Fill(TMath::ATan(AcoHit->Px()/AcoHit->Py()));
213                                 GetHitsData(8)->Fill( (Float_t)(AcoHit->X()),(Float_t)(AcoHit->Y()) );
214                                 GetHitsData(9)->Fill( (Float_t)(AcoHit->X()),(Float_t)(AcoHit->Z()) );
215                                 GetHitsData(10)->Fill( (Float_t)(AcoHit->Y()),(Float_t)(AcoHit->Z()) );
216                                 GetHitsData(11)->Fill( (Float_t)(AcoHit->AzimuthAngle()),
217                                 (Float_t)(AcoHit->PolarAngle()));
218                         }
219                 }
220         }
221
222
223
224 }
225
226 //____________________________________________________________________________
227 void AliACORDEQADataMaker::MakeDigits( TTree *digitsTree)
228 {
229   //fills QA histos for Digits
230
231
232         TClonesArray * digits = new TClonesArray("AliACORDEdigit",1000);
233         TBranch * branch = digitsTree->GetBranch("ACORDEdigit");
234         if (!branch)
235         {
236                 AliWarning("ACORDE branch in Digits Tree not found");
237         }else
238         {
239                 if (branch)
240                 {
241                         branch->SetAddress(&digits);
242                 }else
243                 {
244                         AliError("Branch ACORDE digit not found");
245                         exit(111);
246                 }
247                 Int_t ntracks = (Int_t)digitsTree->GetEntries();
248                 if (ntracks<=0) return;
249                 printf("Entries in DigitsTree:%d\n",ntracks);
250                 for(Int_t track=0;track<ntracks;track++)
251                 {
252                         branch->GetEntry(track);
253                         Int_t ndigits = digits->GetEntriesFast();
254                         for(Int_t idigit=0;idigit<ndigits;idigit++)
255                         {
256                                 AliACORDEdigit *AcoDigit = (AliACORDEdigit*) digits->UncheckedAt(idigit);
257                                 if (!AcoDigit)
258                                 {
259                                         AliError("The unchecked digit doesn't exist");
260                                         break;
261                                 }
262                                 GetDigitsData(0)->Fill(AcoDigit->GetModule()-1);
263                         }
264                 }
265
266
267         }
268
269
270 }
271
272
273 //____________________________________________________________________________
274 void AliACORDEQADataMaker::MakeRaws( AliRawReader* rawReader)
275 {
276
277  //fills QA histos for RAW
278   rawReader->Reset();
279   AliACORDERawStream rawStream(rawReader);
280   size_t contSingle=0;
281   size_t contMulti=0;
282   UInt_t dy[4];
283
284   bool kroSingle[60],kroMulti[60];
285   UInt_t tmpDy;
286
287   for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}
288
289 if(rawStream.Next())
290 {
291         rawReader->NextEvent();
292         rawStream.Reset();
293         dy[0]=rawStream.GetWord(0);
294         dy[1]=rawStream.GetWord(1);
295         dy[2]=rawStream.GetWord(2);
296         dy[3]=rawStream.GetWord(3);
297         tmpDy=dy[0];
298         for(Int_t r=0;r<30;++r)
299         {
300                 kroSingle[r] = tmpDy & 1;
301                 tmpDy>>=1;
302         }
303         tmpDy=dy[1];
304         for(Int_t r=30;r<60;++r)
305         {
306                 kroSingle[r] = tmpDy & 1;
307                 tmpDy>>=1;
308         }
309         tmpDy=dy[2];
310         for(Int_t r=0;r<30;++r)
311         {
312                 kroMulti[r] = tmpDy & 1;
313                 tmpDy>>=1;
314         }
315         tmpDy=dy[3];
316         for(Int_t r=30;r<60;++r)
317         {
318                 kroMulti[r] = tmpDy & 1;
319                 tmpDy>>=1;
320         }
321         contSingle=0;
322         contMulti=0;
323         for(Int_t r=0;r<60;++r)
324         {
325                 if(kroSingle[r]==1)
326                 {
327                         GetRawsData(0)->Fill(r+1);
328                         contSingle=contSingle+1;
329                 }
330                 if(kroMulti[r]==1)
331                 {
332                         GetRawsData(1)->Fill(r+1);
333                         contMulti++;
334                 }
335
336         }GetRawsData(2)->Fill(contSingle);GetRawsData(3)->Fill(contMulti);
337 }
338
339
340
341 }
342 //____________________________________________________________________________
343 void AliACORDEQADataMaker::MakeRecPoints(TTree * clustersTree)
344 {
345   //fills QA histos for clusters
346   // Not needed for ACORDE by now!!!
347 }
348
349 //____________________________________________________________________________
350 void AliACORDEQADataMaker::MakeESDs(AliESDEvent * esd)
351 {
352   //fills QA histos for ESD
353
354         AliESDACORDE * fESDACORDE= esd->GetACORDEData();
355         Int_t *fACORDEMultiMuon =fESDACORDE->GetACORDEMultiMuon();
356         Int_t *fACORDESingleMuon=fESDACORDE->GetACORDESingleMuon();
357
358        for(int i=0;i<60;i++){
359             if(fACORDESingleMuon[i]==1)
360                GetESDsData(0) -> Fill(i);
361             if(fACORDEMultiMuon[i]==1)
362                GetESDsData(1) -> Fill(i);
363         }
364
365
366
367 }
368