Updated QA
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDQADataMakerRec.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 /* $Id$ */
18
19 // --- ROOT system ---
20 #include <TClonesArray.h>
21 #include <TFile.h> 
22 #include <TH1F.h> 
23 #include <TH2F.h>
24 #include <TProfile.h>
25 #include <Riostream.h>
26 // --- Standard library ---
27
28 // --- AliRoot header files ---
29 #include "AliESDCaloCluster.h"
30 #include "AliESDEvent.h"
31 #include "AliQAChecker.h"
32 #include "AliLog.h"
33 #include "AliHMPIDDigit.h"
34 #include "AliHMPIDHit.h"
35 #include "AliHMPIDCluster.h"
36 #include "AliHMPIDQADataMakerRec.h"
37 #include "AliHMPIDParam.h"
38 #include "AliHMPIDRawStream.h"
39 #include "AliLog.h"
40 ClassImp(AliHMPIDQADataMakerRec)
41            
42 //____________________________________________________________________________ 
43   AliHMPIDQADataMakerRec::AliHMPIDQADataMakerRec() : 
44   AliQADataMakerRec(AliQA::GetDetName(AliQA::kHMPID), "HMPID Quality Assurance Data Maker")
45 {
46   // ctor
47 }
48
49 //____________________________________________________________________________ 
50 AliHMPIDQADataMakerRec::AliHMPIDQADataMakerRec(const AliHMPIDQADataMakerRec& qadm) :
51   AliQADataMakerRec() 
52 {
53   //copy ctor 
54   SetName((const char*)qadm.GetName()) ; 
55   SetTitle((const char*)qadm.GetTitle()); 
56 }
57
58 //__________________________________________________________________
59 AliHMPIDQADataMakerRec& AliHMPIDQADataMakerRec::operator = (const AliHMPIDQADataMakerRec& qadm )
60 {
61   // Equal operator.
62   this->~AliHMPIDQADataMakerRec();
63   new(this) AliHMPIDQADataMakerRec(qadm);
64   return *this;
65 }
66  
67 //____________________________________________________________________________ 
68
69 void AliHMPIDQADataMakerRec::InitRecPoints()
70 {
71   // create cluster histograms in RecPoint subdir
72
73   TH1F *hCluEvt=new TH1F("CluPerEvt","Cluster multiplicity"   ,100,0,100);
74   TH1F *hCluChi2  =new TH1F("CluChi2"  ,"Chi2 "               ,1000,0,100);
75   TH1F *hCluFlg   =new TH1F("CluFlg"   ,"Cluster flag"        ,14,-1.5,12.5); hCluFlg->SetFillColor(5);
76   TH1F *hCluSize  =new TH1F("CluSize"  ,"Cluster size        ",100,0,100);
77   TH1F *hCluQ     =new TH1F("CluQ"     ,"Cluster charge (ADC)",1000,0,5000);
78
79   Add2RecPointsList(hCluEvt , 0);
80   Add2RecPointsList(hCluChi2, 1);
81   Add2RecPointsList(hCluFlg , 2);
82   Add2RecPointsList(hCluSize, 3);
83   Add2RecPointsList(hCluQ   , 4);
84 }
85 //____________________________________________________________________________
86
87 void AliHMPIDQADataMakerRec::InitRaws()
88 {
89 //
90 // Booking QA histo for Raw data
91 //
92   const Int_t nerr = (Int_t)AliHMPIDRawStream::kSumErr+1;
93   const char *hnames[nerr]={"RawDataSize","RawMarkerSize","WrongRow","WrongDilogic","WrongPad","EoEFlag",
94                              "EoESize","EoEDILOGIC","EoERow","BadSegWord","WrongSeg","RowMarkerSize","NoErrors","Invalid"};
95   TH1F *hqPad[14], *hSumErr[14];
96
97   for(Int_t iddl =0; iddl<14; iddl++) {
98
99   hqPad[iddl] = new TH1F(Form("hqPadDDL%i",iddl), Form("Pad Q Entries at DDL %i",iddl), 500,0,5000);
100   Add2RawsList(hqPad[iddl],iddl);
101   hSumErr[iddl] = new TH1F(Form("SumErrDDL%i",iddl), Form("Error summary for ddl %i",iddl), 2*nerr,0,2*nerr);
102   hSumErr[iddl]->SetYTitle("%");
103   for(Int_t ilabel=0; ilabel< nerr; ilabel++) {
104   hSumErr[iddl]->GetXaxis()->CenterLabels(kTRUE);
105   hSumErr[iddl]->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i  %s",ilabel+1,hnames[ilabel]));
106   }
107   Add2RawsList(hSumErr[iddl],iddl+14);
108  }
109   TH1F *hNevRaws = new TH1F("NevRaws","Events per DDL",15,0,15);
110   Add2RawsList(hNevRaws,28);
111 }
112 //____________________________________________________________________________
113 void AliHMPIDQADataMakerRec::InitESDs()
114 {
115   //
116   //Booking ESDs histograms
117    TH2F*  hCkovP  = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]"   , 150,      0,  7  ,100, 0, 1)   ;
118    TH2F*  hSigP   = new TH2F("SigP"  ,"#sigma_{#theta_c} [mrad];[GeV]", 150,      0,  7  ,100, 0, 1)   ;
119    TH2F*  hMipXY  = new TH2F("MipXY" ,"mip position"                  , 260,      0,130  ,252, 0,126)  ;
120    TH2F*  hDifXY  = new TH2F("DifXY" ,"diff"                          , 200,    -10, 10  ,200,-10,10)  ;
121    TH1F*  hPid[5];
122    hPid[0] = new TH1F("PidE" ,"electron response"              , 101, -0.005,1.005)             ;
123    hPid[1] = new TH1F("PidMu","#mu response"                   , 101, -0.005,1.005)             ;
124    hPid[2] = new TH1F("PidPi","#pi response"                   , 101, -0.005,1.005)             ;
125    hPid[3] = new TH1F("PidK" ,"K response"                     , 101, -0.005,1.005)             ;
126    hPid[4] = new TH1F("PidP" ,"p response"                         ,101, -0.005,1.005)             ;
127
128 Add2ESDsList(hCkovP,0);
129 Add2ESDsList(hSigP ,1);
130 Add2ESDsList(hMipXY,2);
131 Add2ESDsList(hDifXY,3);
132 for(Int_t i=0; i< 5; i++) Add2ESDsList(hPid[i],i+4);
133 }
134 //____________________________________________________________________________
135 void AliHMPIDQADataMakerRec::MakeRaws(AliRawReader *rawReader)
136 {
137 //
138 // Filling Raws QA histos
139 //
140     AliHMPIDRawStream stream(rawReader);
141
142     while(stream.Next())
143      {
144        UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
145
146        for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
147        GetRawsData(ddl)->Fill(stream.GetChargeArray()[iPad]);}
148                                                            
149        GetRawsData(28)->Fill(ddl);
150
151        for(Int_t iErr =1; iErr<(Int_t)AliHMPIDRawStream::kSumErr; iErr++){
152  
153          Int_t NumOfErr = stream.GetErrors(ddl,iErr);
154
155          GetRawsData(ddl+14)->Fill(iErr,NumOfErr);
156        }
157      }
158    stream.Delete();
159 }
160 //___________________________________________________________________________
161 void AliHMPIDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
162 {
163   //
164   //filling QA histos for clusters
165   //
166   TClonesArray *clusters = new TClonesArray("AliHMPIDCluster");
167   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){
168     TBranch *branch = clustersTree->GetBranch(Form("HMPID%d",i));
169     branch->SetAddress(&clusters);
170     branch->GetEntry(0);
171
172     GetRecPointsData(0)->Fill(i,clusters->GetEntries());
173     TIter next(clusters);
174     AliHMPIDCluster *clu;
175     while ( (clu = dynamic_cast<AliHMPIDCluster *>(next())) ) {
176       GetRecPointsData(1)->Fill(clu->Chi2());
177       GetRecPointsData(2)->Fill(clu->Status());
178       GetRecPointsData(3)->Fill(clu->Size());
179       GetRecPointsData(4)->Fill(clu->Q()); 
180     }
181   }
182
183   clusters->Delete();
184   delete clusters;
185 }
186
187 //____________________________________________________________________________
188 void AliHMPIDQADataMakerRec::MakeESDs(AliESDEvent * esd)
189 {
190   //
191   //fills QA histos for ESD
192   //
193   for(Int_t iTrk = 0 ; iTrk < esd->GetNumberOfTracks() ; iTrk++){
194     AliESDtrack *pTrk = esd->GetTrack(iTrk) ;
195     GetESDsData(0)->Fill(pTrk->GetP(),pTrk->GetHMPIDsignal());
196     GetESDsData(1)->Fill( pTrk->GetP(),TMath::Sqrt(pTrk->GetHMPIDchi2()));
197     Float_t xm,ym; Int_t q,np;  
198     pTrk->GetHMPIDmip(xm,ym,q,np);                       //mip info
199     GetESDsData(2)->Fill(xm,ym);
200     Float_t xRad,yRad,th,ph;        
201     pTrk->GetHMPIDtrk(xRad,yRad,th,ph);              //track info at the middle of the radiator
202     Float_t xPc = xRad+9.25*TMath::Tan(th)*TMath::Cos(ph); // temporar: linear extrapol (B=0!)
203     Float_t yPc = yRad+9.25*TMath::Tan(th)*TMath::Sin(ph); // temporar:          "
204     GetESDsData(3)->Fill(xm-xPc,ym-yPc); //track info
205     Double_t pid[5] ;      pTrk->GetHMPIDpid(pid) ;
206     for(Int_t i = 0 ; i < 5 ; i++) GetESDsData(4+i)->Fill(pid[i]) ;
207   }
208 }
209 //____________________________________________________________________________
210 void AliHMPIDQADataMakerRec::StartOfDetectorCycle()
211 {
212   //Detector specific actions at start of cycle
213   
214 }
215
216 void AliHMPIDQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX, TObjArray *)
217 {
218   //Detector specific actions at end of cycle
219   // do the QA checking
220   //AliQAChecker::Instance()->Run(AliQA::kHMPID, task, obj);
221   //if(task==AliQA::kRAWS){  
222
223    for(Int_t iddl=0; iddl<14; iddl++)
224   {
225   if(GetRawsData(28)->GetBinContent(iddl)!=0) GetRawsData(iddl+14)->Scale(100./GetRawsData(28)->GetBinContent(iddl));
226   }
227 }
228