Make and print an image of QA user flagged histograms (Yves)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDQADataMakerRec.cxx
CommitLineData
04236e67 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
04236e67 19// --- ROOT system ---
20#include <TClonesArray.h>
21#include <TFile.h>
22#include <TH1F.h>
23#include <TH2F.h>
aa21372e 24#include <TProfile.h>
04236e67 25#include <Riostream.h>
26// --- Standard library ---
27
28// --- AliRoot header files ---
29#include "AliESDCaloCluster.h"
30#include "AliESDEvent.h"
cc1abc7f 31#include "AliQAChecker.h"
04236e67 32#include "AliLog.h"
33#include "AliHMPIDDigit.h"
34#include "AliHMPIDHit.h"
35#include "AliHMPIDCluster.h"
36#include "AliHMPIDQADataMakerRec.h"
7656d8ac 37#include "AliHMPIDQAChecker.h"
cc1abc7f 38#include "AliHMPIDParam.h"
39#include "AliHMPIDRawStream.h"
40#include "AliLog.h"
b38ac33a 41
606697a8 42//.
b38ac33a 43// HMPID AliHMPIDQADataMakerRec base class
44// for QA of reconstruction
45// here also errors are calculated
46//.
47
04236e67 48ClassImp(AliHMPIDQADataMakerRec)
49
ec575c20 50//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 51 AliHMPIDQADataMakerRec::AliHMPIDQADataMakerRec() :
4e25ac79 52 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kHMPID), "HMPID Quality Assurance Data Maker"),fEvtRaw(0)
04236e67 53{
54 // ctor
04236e67 55}
56
ec575c20 57//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 58AliHMPIDQADataMakerRec::AliHMPIDQADataMakerRec(const AliHMPIDQADataMakerRec& qadm) :
2bd0e033 59 AliQADataMakerRec(),fEvtRaw(qadm.fEvtRaw)
04236e67 60{
61 //copy ctor
04236e67 62 SetName((const char*)qadm.GetName()) ;
63 SetTitle((const char*)qadm.GetTitle());
64}
65
ec575c20 66//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 67AliHMPIDQADataMakerRec& AliHMPIDQADataMakerRec::operator = (const AliHMPIDQADataMakerRec& qadm )
68{
69 // Equal operator.
70 this->~AliHMPIDQADataMakerRec();
71 new(this) AliHMPIDQADataMakerRec(qadm);
72 return *this;
73}
74
ec575c20 75//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 76void AliHMPIDQADataMakerRec::InitRecPoints()
77{
78 // create cluster histograms in RecPoint subdir
7d297381 79 const Bool_t expert = kTRUE ;
80 const Bool_t image = kTRUE ;
41391bd4 81
aa21372e 82 TProfile *hCluMult = new TProfile("CluMult" ,"Cluster multiplicity per chamber" , 16, -1 , 7 , 0, 500);
7d297381 83 Add2RecPointsList(hCluMult , 0,expert, !image);
aa21372e 84
85 TH2F *hCluFlg = new TH2F("CluFlg" ,"Cluster flag " , 56 ,-1.5, 12.5, 70, -0.5, 6.5);
7d297381 86 Add2RecPointsList(hCluFlg , 1,expert, !image);
aa21372e 87
88 TH1F *hCluSizeMip[7], *hCluSizePho[7];
89
90 TH1F *hCluQSect[42], *hCluQSectZoom[42];
91
7656d8ac 92 for(Int_t iCh =0; iCh <7; iCh++){
7d297381 93 hCluSizeMip[iCh] = new TH1F(Form("CluSizeMipCh%i",iCh),Form("Cluster size MIP (cluster Q > 100 ADC) in Chamber %i",iCh), 50 , 0 , 50 );
94 Add2RecPointsList(hCluSizeMip[iCh], iCh+2,expert,!image);
aa21372e 95
7d297381 96 hCluSizePho[iCh] = new TH1F(Form("CluSizePho%i",iCh ),Form("Cluster size Phots(cluster Q < 100 ADC) in Chamber %i",iCh), 50 , 0 , 50 );
97 Add2RecPointsList(hCluSizePho[iCh], iCh+7+2,expert,!image);
98
aa21372e 99 for(Int_t iSect =0; iSect < 6; iSect++){
100 hCluQSectZoom[iCh*6+iSect] = new TH1F(Form("QClusCh%iSect%iZoom",iCh,iSect) ,Form("Zoom on Cluster charge (ADC) in Chamber %i and sector %i",iCh,iSect),100,0,100);
7d297381 101 Add2RecPointsList(hCluQSectZoom[iCh*6+iSect],2+14+iCh*6+iSect,expert,!image);
102
aa21372e 103 hCluQSect[iCh*6+iSect] = new TH1F(Form("QClusCh%iSect%i",iCh,iSect) ,Form("Cluster charge (ADC) in Chamber %i and sector %i",iCh,iSect),250,0,5000);
7d297381 104 Add2RecPointsList(hCluQSect[iCh*6+iSect],2+14+42+iCh*6+iSect, !expert, image);
aa21372e 105 }
106 }
cc1abc7f 107}
ec575c20 108//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cc1abc7f 109void AliHMPIDQADataMakerRec::InitRaws()
110{
111//
112// Booking QA histo for Raw data
113//
64f2781e 114// All histograms implemented in InitRaws are used in AMORE. Any change here should be propagated to the amoreHMP-QA as well!!! (clm)
115//
116
7d297381 117 const Bool_t expert = kTRUE ;
118 const Bool_t saveCorr = kTRUE ;
119 const Bool_t image = kTRUE ;
120
b38ac33a 121 const Int_t kNerr = (Int_t)AliHMPIDRawStream::kSumErr+1;
aa21372e 122 TH1F *hSumErr[14];
123 TH2F *hDilo[14];
64f2781e 124 TH2I *hPadMap[42]; //AMORE monitoring
125 TH1I *hPadQ[42]; //AMORE monitoring
3c8e86a0 126 for(Int_t iddl =0; iddl<AliHMPIDRawStream::kNDDL; iddl++) {
3c8e86a0 127
64f2781e 128 hSumErr[iddl] = new TH1F(Form("hSumErrDDL%i",iddl), Form("Error summary for DDL %i",iddl), 2*kNerr,0,2*kNerr);
b38ac33a 129 for(Int_t ilabel=0; ilabel< kNerr; ilabel++) {
3c8e86a0 130 hSumErr[iddl]->GetXaxis()->CenterLabels(kTRUE);
3c8e86a0 131 hSumErr[iddl]->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i %s",ilabel+1,AliHMPIDRawStream::GetErrName(ilabel)));
7d297381 132 }
133
134 Add2RawsList(hSumErr[iddl],iddl,expert,!image, !saveCorr);
aa21372e 135
64f2781e 136 hDilo[iddl] = new TH2F(Form("hDiloDDL%i",iddl),Form("Dilogic response at DDL;Row # ;Dilogic #",iddl),24,1,25,10,1,11);
7d297381 137 Add2RawsList(hDilo[iddl],14+iddl,expert,!image, !saveCorr);
64f2781e 138 }//DDL loop
7d297381 139 for(Int_t iCh = AliHMPIDParam::kMinCh; iCh <=AliHMPIDParam::kMaxCh ;iCh++) {
140 for(Int_t iPc = AliHMPIDParam::kMinPc; iPc <= AliHMPIDParam::kMaxPc ;iPc++) {
64f2781e 141 hPadMap[iPc+6*iCh] = new TH2I(Form("hPadMap_Ch_%i_Pc%i",iCh,iPc),Form("Pad Map of Ch: %i Pc: %i;Pad X;Pad Y;",iCh,iPc),80,0,80,48,0,48);
7d297381 142 Add2RawsList(hPadMap[iPc+6*iCh],28+iPc+6*iCh,expert,!image, !saveCorr);
64f2781e 143 hPadQ[iPc+6*iCh] = new TH1I(Form("hPadQ_Ch_%i_Pc%i",iCh,iPc),Form("Pad Charge of Ch: %i Pc: %i;Pad Q;Entries;",iCh,iPc),4100,0,4100);
7d297381 144 Add2RawsList(hPadQ[iPc+6*iCh],70+iPc+6*iCh,expert,!image, !saveCorr);
64f2781e 145 }//PC loop
146 }//Ch loop
147
7d297381 148 TH2I *hGeneralErrorSummary = new TH2I("GeneralErrorSummary"," DDL index vs Error type plot", 2*kNerr, 0, 2*kNerr, 2*AliHMPIDRawStream::kNDDL,0,2*AliHMPIDRawStream::kNDDL);
149 for(Int_t igenlabel =0 ; igenlabel< kNerr; igenlabel++) hGeneralErrorSummary->GetXaxis()->SetBinLabel((2*igenlabel+1),Form("%i %s",igenlabel+1,AliHMPIDRawStream::GetErrName(igenlabel)));
150 Add2RawsList(hGeneralErrorSummary,14+14+42+42, !expert, image, !saveCorr);
04236e67 151}
ec575c20 152//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 153void AliHMPIDQADataMakerRec::InitESDs()
154{
cc1abc7f 155 //
156 //Booking ESDs histograms
7d297381 157 const Bool_t expert = kTRUE ;
158 const Bool_t image = kTRUE ;
159
160 TH2F* hCkovP = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]" , 150, 0, 7 ,100, 0, 1) ;
161 TH2F* hSigP = new TH2F("SigP" ,"#sigma_{#theta_c} [mrad];[GeV]", 150, 0, 7 ,100, 0, 1) ;
162 TH2F* hDifXY = new TH2F("DifXY" ,"diff" , 200, -10, 10 ,200,-10,10) ;
163 TH2F* hMvsP = new TH2F("MvsP","Reconstructed Mass vs P",60,0,6,1000,0,1) ;
164 TH1F* hPid[5];
165 hPid[0] = new TH1F("PidE" ,"electron response" , 101, -0.005,1.005) ;
166 hPid[1] = new TH1F("PidMu","#mu response" , 101, -0.005,1.005) ;
167 hPid[2] = new TH1F("PidPi","#pi response" , 101, -0.005,1.005) ;
168 hPid[3] = new TH1F("PidK" ,"K response" , 101, -0.005,1.005) ;
169 hPid[4] = new TH1F("PidP" ,"p response" , 101, -0.005,1.005) ;
170
171 Add2ESDsList(hCkovP,0, !expert, image);
172 Add2ESDsList(hSigP ,1, expert, !image);
173 Add2ESDsList(hDifXY,2, !expert, image);
174 Add2ESDsList(hMvsP,3, expert, !image);
175 for(Int_t i=0; i< 5; i++) Add2ESDsList(hPid[i],i+4, expert, !image);
04236e67 176}
ec575c20 177//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cc1abc7f 178void AliHMPIDQADataMakerRec::MakeRaws(AliRawReader *rawReader)
04236e67 179{
cc1abc7f 180//
181// Filling Raws QA histos
182//
78328afd 183 rawReader->Reset() ;
184 AliHMPIDRawStream stream(rawReader);
cc1abc7f 185
aa21372e 186 fEvtRaw++;
187
cc1abc7f 188 while(stream.Next())
189 {
190 UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
64f2781e 191 if(ddl > 13) continue;
cc1abc7f 192 for(Int_t iErr =1; iErr<(Int_t)AliHMPIDRawStream::kSumErr; iErr++){
b38ac33a 193 Int_t numOfErr = stream.GetErrors(ddl,iErr);
aa21372e 194 GetRawsData(ddl)->Fill(iErr,numOfErr);
41391bd4 195 //Printf("err type %i ddl number %i Num of errors %i",iErr,ddl,numOfErr);
196 ((TH2I*)GetRawsData(14+14+42+42))->Fill(iErr,ddl,iErr); //
cc1abc7f 197 }
64f2781e 198 UInt_t word; Int_t Nddl, r, d, a;//pc,pcX,pcY;
aa21372e 199 for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
64f2781e 200 AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);dig.Raw(word,Nddl,r,d,a);
aa21372e 201 GetRawsData(ddl+14)->Fill(r,d);
64f2781e 202 GetRawsData(28+stream.Pc(Nddl,r,d,a)+6*AliHMPIDParam::DDL2C(ddl))->Fill(stream.PadPcX(Nddl,r,d,a),stream.PadPcY(Nddl,r,d,a));
203 GetRawsData(70+stream.Pc(Nddl,r,d,a)+6*AliHMPIDParam::DDL2C(ddl))->Fill(stream.GetChargeArray()[iPad]);
204 }
cc1abc7f 205 }
41391bd4 206
cc1abc7f 207 stream.Delete();
aa21372e 208
cc1abc7f 209}
ec575c20 210//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cc1abc7f 211void AliHMPIDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
212{
213 //
214 //filling QA histos for clusters
215 //
7656d8ac 216 AliHMPIDParam *pPar =AliHMPIDParam::Instance();
c2df1ef0 217
218 static TClonesArray *clusters;
219 if(!clusters) clusters = new TClonesArray("AliHMPIDCluster");
220
aa21372e 221 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
222 TBranch *branch = clustersTree->GetBranch(Form("HMPID%d",iCh));
04236e67 223 branch->SetAddress(&clusters);
224 branch->GetEntry(0);
aa21372e 225 GetRecPointsData(0)->Fill(iCh,clusters->GetEntries());
04236e67 226 TIter next(clusters);
227 AliHMPIDCluster *clu;
cc1abc7f 228 while ( (clu = dynamic_cast<AliHMPIDCluster *>(next())) ) {
aa21372e 229 GetRecPointsData(1)->Fill(clu->Status(),iCh);
230 Int_t sect = pPar->InHVSector(clu->Y());
231 if(clu->Q()>100) GetRecPointsData(2+iCh)->Fill(clu->Size());
232 else {
233 GetRecPointsData(2+7+iCh)->Fill(clu->Size());
234 GetRecPointsData(2+14+iCh*6+sect)->Fill(clu->Q());
235 }
236 GetRecPointsData(2+14+42+iCh*6+sect)->Fill(clu->Q());
04236e67 237 }
238 }
239
c2df1ef0 240 clusters->Clear();
241
04236e67 242}
ec575c20 243//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
04236e67 244void AliHMPIDQADataMakerRec::MakeESDs(AliESDEvent * esd)
245{
cc1abc7f 246 //
04236e67 247 //fills QA histos for ESD
cc1abc7f 248 //
7656d8ac 249
04236e67 250 for(Int_t iTrk = 0 ; iTrk < esd->GetNumberOfTracks() ; iTrk++){
251 AliESDtrack *pTrk = esd->GetTrack(iTrk) ;
cc1abc7f 252 GetESDsData(0)->Fill(pTrk->GetP(),pTrk->GetHMPIDsignal());
253 GetESDsData(1)->Fill( pTrk->GetP(),TMath::Sqrt(pTrk->GetHMPIDchi2()));
04236e67 254 Float_t xm,ym; Int_t q,np;
255 pTrk->GetHMPIDmip(xm,ym,q,np); //mip info
04236e67 256 Float_t xRad,yRad,th,ph;
257 pTrk->GetHMPIDtrk(xRad,yRad,th,ph); //track info at the middle of the radiator
258 Float_t xPc = xRad+9.25*TMath::Tan(th)*TMath::Cos(ph); // temporar: linear extrapol (B=0!)
259 Float_t yPc = yRad+9.25*TMath::Tan(th)*TMath::Sin(ph); // temporar: "
7656d8ac 260 GetESDsData(2)->Fill(xm-xPc,ym-yPc); //track info
261 if(pTrk->GetHMPIDsignal()>0) {
262 Double_t a = 1.292*1.292*TMath::Cos(pTrk->GetHMPIDsignal())*TMath::Cos(pTrk->GetHMPIDsignal())-1.;
263 if(a > 0) {
264 Double_t mass = pTrk->P()*TMath::Sqrt(1.292*1.292*TMath::Cos(pTrk->GetHMPIDsignal())*TMath::Cos(pTrk->GetHMPIDsignal())-1.);
265 GetESDsData(3)->Fill( pTrk->GetP(),mass);
266 }
267 }
268 Double_t pid[5] ; pTrk->GetHMPIDpid(pid) ;
cc1abc7f 269 for(Int_t i = 0 ; i < 5 ; i++) GetESDsData(4+i)->Fill(pid[i]) ;
270 }
271}
ec575c20 272//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cc1abc7f 273void AliHMPIDQADataMakerRec::StartOfDetectorCycle()
274{
275 //Detector specific actions at start of cycle
276
277}
ec575c20 278//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cc1abc7f 279
4e25ac79 280void AliHMPIDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray **histos)
cc1abc7f 281{
282 //Detector specific actions at end of cycle
283 // do the QA checking
fdd7f404 284
4e25ac79 285 if(task==AliQAv1::kRAWS) {
57acd2d2 286 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
287 for(Int_t iddl=0;iddl<14;iddl++) {
288 TH1F *h = (TH1F*)histos[specie]->At(14+iddl); //ddl histos scaled by the number of events
289 h->Scale(1./(Float_t)fEvtRaw);
290 }
aa21372e 291 }
292 }
fdd7f404 293
4e25ac79 294 AliQAChecker::Instance()->Run(AliQAv1::kHMPID, task, histos);
fdd7f404 295
04236e67 296}
297