]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDQADataMaker.cxx
SetLabel added and Printf commented
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDQADataMaker.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 "AliHMPIDQADataMaker.h"
37 #include "AliHMPIDParam.h"
38 #include "AliHMPIDRawStream.h"
39 #include "AliLog.h"
40 ClassImp(AliHMPIDQADataMaker)
41            
42 //____________________________________________________________________________ 
43   AliHMPIDQADataMaker::AliHMPIDQADataMaker() : 
44   AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kHMPID), "HMPID Quality Assurance Data Maker")
45 {
46   // ctor
47 }
48
49 //____________________________________________________________________________ 
50 AliHMPIDQADataMaker::AliHMPIDQADataMaker(const AliHMPIDQADataMaker& qadm) :
51   AliQADataMaker() 
52 {
53   //copy ctor 
54   SetName((const char*)qadm.GetName()) ; 
55   SetTitle((const char*)qadm.GetTitle()); 
56 }
57
58 //__________________________________________________________________
59 AliHMPIDQADataMaker& AliHMPIDQADataMaker::operator = (const AliHMPIDQADataMaker& qadm )
60 {
61   // Equal operator.
62   this->~AliHMPIDQADataMaker();
63   new(this) AliHMPIDQADataMaker(qadm);
64   return *this;
65 }
66  
67 //____________________________________________________________________________ 
68 void AliHMPIDQADataMaker::InitHits()
69 {
70   // create Hits histograms in Hits subdir
71      TH1F *hHitQdc=new TH1F("HitQdc","HMPID Hit Qdc all chamber;QDC",500,0,4000);
72      Add2HitsList(hHitQdc,0);
73      TH2F *hHitMap[7];
74      for(Int_t iCh=0;iCh<7;iCh++) {
75      hHitMap[iCh]=new TH2F(Form("HMPID HitMap%i",iCh),Form("Ch%i;x_{Hit};y_{Hit}",iCh),162,-1,161,146,-1,145);   
76     Add2HitsList(hHitMap[iCh],iCh+1);
77     }
78
79 }
80
81 //____________________________________________________________________________ 
82 void AliHMPIDQADataMaker::InitDigits()
83 {
84   // create Digits histograms in Digits subdir
85       TH1F *hDigPcEvt = new TH1F("hDigPcEvt","PC occupancy",156,-1,77);
86       TH1F *hDigQ     = new TH1F("Q        ","Charge of digits (ADC)     ",3000,0,3000);
87       TH1F *hDigChEvt = new TH1F("hDigChEvt","Chamber occupancy per event",AliHMPIDParam::kMaxCh+1,AliHMPIDParam::kMinCh,AliHMPIDParam::kMaxCh+1);
88
89       TProfile *tDigHighQ = new TProfile("tDigHighQ","Highest charge in chamber  ",AliHMPIDParam::kMaxCh+1,AliHMPIDParam::kMinCh,AliHMPIDParam::kMaxCh+1);
90       TProfile *tDigChEvt = new TProfile("tDigChEvt","Chamber occupancy per event (profile)",AliHMPIDParam::kMaxCh+1,AliHMPIDParam::kMinCh,AliHMPIDParam::kMaxCh+1);
91
92 Add2DigitsList(hDigPcEvt,0);
93 Add2DigitsList(hDigQ    ,1);
94 Add2DigitsList(hDigChEvt,2);
95 Add2DigitsList(tDigHighQ,3);
96 Add2DigitsList(tDigChEvt,4);
97 }
98
99 //____________________________________________________________________________ 
100 void AliHMPIDQADataMaker::InitSDigits()
101 {
102   // create SDigits histograms in SDigits subdir
103    TH1F   *hSDigits     = new TH1F("hHmpidSDigits",    "SDigits Q  distribution in HMPID",  500, 0., 5000.) ; 
104
105 Add2SDigitsList(hSDigits,0);
106 }
107
108 //____________________________________________________________________________ 
109
110 void AliHMPIDQADataMaker::InitRecPoints()
111 {
112   // create cluster histograms in RecPoint subdir
113
114   TH1F *hCluEvt=new TH1F("CluPerEvt","Cluster multiplicity"   ,100,0,100);
115   TH1F *hCluChi2  =new TH1F("CluChi2"  ,"Chi2 "               ,1000,0,100);
116   TH1F *hCluFlg   =new TH1F("CluFlg"   ,"Cluster flag"        ,14,-1.5,12.5); hCluFlg->SetFillColor(5);
117   TH1F *hCluSize  =new TH1F("CluSize"  ,"Cluster size        ",100,0,100);
118   TH1F *hCluQ     =new TH1F("CluQ"     ,"Cluster charge (ADC)",1000,0,5000);
119
120   Add2RecPointsList(hCluEvt , 0);
121   Add2RecPointsList(hCluChi2, 1);
122   Add2RecPointsList(hCluFlg , 2);
123   Add2RecPointsList(hCluSize, 3);
124   Add2RecPointsList(hCluQ   , 4);
125 }
126 //____________________________________________________________________________
127
128 void AliHMPIDQADataMaker::InitRaws()
129 {
130 //
131 // Booking QA histo for Raw data
132 //
133   TH1F *hqPad[14];
134   for(Int_t iddl =0; iddl<14; iddl++) {
135   hqPad[iddl] = new TH1F(Form("hqPadDDL%i",iddl), Form("Pad Q Entries at DDL %i",iddl), 500,0,5000);
136   Add2RawsList(hqPad[iddl],iddl);
137   }
138
139   const Int_t nerr = (Int_t)AliHMPIDRawStream::kSumErr+1;
140   const char *hnames[nerr]={"RawDataSize","RawMarkerSize","WrongRow","WrongDilogic","WrongPad","EoEFlag",
141                              "EoESize","EoEDILOGIC","EoERow","BadSegWord","WrongSeg","RowMarkerSize","NoErrors","Invalid"};
142
143   TH1F *hSumErr = new TH1F("SumErr","Summary of the returned errors",2*nerr,0,nerr);
144
145   for(Int_t ilabel=0; ilabel< nerr; ilabel++) {
146   hSumErr->GetXaxis()->CenterLabels(kTRUE);
147   hSumErr->GetXaxis()->SetBinLabel((2*ilabel+1),Form("%i  %s",ilabel+1,hnames[ilabel]));
148
149   }
150 Add2RawsList(hSumErr,14);
151 }
152
153 //____________________________________________________________________________
154 void AliHMPIDQADataMaker::InitESDs()
155 {
156   //
157   //Booking ESDs histograms
158    TH2F*  hCkovP  = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]"   , 150,      0,  7  ,100, 0, 1)   ;
159    TH2F*  hSigP   = new TH2F("SigP"  ,"#sigma_{#theta_c} [mrad];[GeV]", 150,      0,  7  ,100, 0, 1)   ;
160    TH2F*  hMipXY  = new TH2F("MipXY" ,"mip position"                  , 260,      0,130  ,252, 0,126)  ;
161    TH2F*  hDifXY  = new TH2F("DifXY" ,"diff"                          , 200,    -10, 10  ,200,-10,10)  ;
162    TH1F*  hPid[5];
163    hPid[0] = new TH1F("PidE" ,"electron response"              , 101, -0.005,1.005)             ;
164    hPid[1] = new TH1F("PidMu","#mu response"                   , 101, -0.005,1.005)             ;
165    hPid[2] = new TH1F("PidPi","#pi response"                   , 101, -0.005,1.005)             ;
166    hPid[3] = new TH1F("PidK" ,"K response"                     , 101, -0.005,1.005)             ;
167    hPid[4] = new TH1F("PidP" ,"p response"                         ,101, -0.005,1.005)             ;
168
169 Add2ESDsList(hCkovP,0);
170 Add2ESDsList(hSigP ,1);
171 Add2ESDsList(hMipXY,2);
172 Add2ESDsList(hDifXY,3);
173 for(Int_t i=0; i< 5; i++) Add2ESDsList(hPid[i],i+4);
174 }
175 //____________________________________________________________________________
176
177 void AliHMPIDQADataMaker::MakeHits(TClonesArray * data)
178 {
179  //
180  //filling QA histos for Hits
181  //
182   TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
183   if (!hits){
184     AliError("Wrong type of hits container") ; 
185   } else {
186     TIter next(hits); 
187     AliHMPIDHit * hit ; 
188     while ( (hit = dynamic_cast<AliHMPIDHit *>(next())) ) {
189       if(hit->Pid()<500000) GetHitsData(0)->Fill(hit->Q()) ;
190       if(hit->Pid()<500000) GetHitsData(hit->Ch()+1)->Fill(hit->LorsX(),hit->LorsY());
191     }
192   } 
193
194 }
195 //___________________________________________________________________________
196 void AliHMPIDQADataMaker::MakeHits(TTree * data)
197 {
198 //
199 //Opening of the Hit TTree 
200 //
201  TClonesArray *pHits=new TClonesArray("AliHMPIDHit");  data->SetBranchAddress("HMPID",&pHits);
202   for(Int_t iEnt=0;iEnt<data->GetEntriesFast();iEnt++){//entries loop
203     data->GetEntry(iEnt);
204     MakeHits(pHits);
205   }//entries loop
206 }
207 //____________________________________________________________________________
208 void AliHMPIDQADataMaker::MakeDigits(TClonesArray * data)
209 {
210  //
211  //filling QA histos for Digits
212  //
213   TObjArray *chamber = dynamic_cast<TObjArray*>(data);
214   if ( !chamber) {
215     AliError("Wrong type of digits container") ; 
216   } else {
217     for(Int_t i =0; i< chamber->GetEntries(); i++)
218       {
219         TClonesArray * digits = dynamic_cast<TClonesArray*>(chamber->At(i)); 
220         GetDigitsData(2)->Fill(i,digits->GetEntriesFast()/(48.*80.*6.));
221         GetDigitsData(4)->Fill(i,digits->GetEntriesFast()/(48.*80.*6.));
222         Double_t highQ=0;
223         TIter next(digits); 
224         AliHMPIDDigit * digit; 
225         while ( (digit = dynamic_cast<AliHMPIDDigit *>(next())) ) {
226           GetDigitsData(0)->Fill(10.*i+digit->Pc(),1./(48.*80.));
227           GetDigitsData(1)->Fill(digit->Q());
228           if(digit->Q()>highQ) highQ = digit->Q();
229         }  
230       GetDigitsData(3)->Fill(i,highQ);
231  
232       }
233   }
234 }
235 //___________________________________________________________________________
236 void AliHMPIDQADataMaker::MakeDigits(TTree * data)
237 {
238 //
239 //Opening the Digit Tree
240 //
241  TObjArray *pObjDig=new TObjArray(AliHMPIDParam::kMaxCh+1);
242   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
243     TClonesArray *pCA=new TClonesArray("AliHMPIDDigit");
244     pObjDig->AddAt(pCA,iCh);
245   }
246
247   pObjDig->SetOwner(kTRUE);
248
249   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
250     data->SetBranchAddress(Form("HMPID%i",iCh),&(*pObjDig)[iCh]);
251   }
252   data->GetEntry(0);
253
254    MakeDigits((TClonesArray *)pObjDig);
255 }
256 //____________________________________________________________________________
257
258 void AliHMPIDQADataMaker::MakeRaws(AliRawReader *rawReader)
259 {
260 //
261 // Filling Raws QA histos
262 //
263   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
264     AliHMPIDRawStream stream(rawReader);
265     while(stream.Next())
266     {
267
268       UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
269       if((UInt_t)(2*iCh)==ddl || (UInt_t)(2*iCh+1)==ddl) {
270        for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){
271         for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
272           for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
273             if(stream.GetCharge(ddl,row,dil,pad) < 1) continue;
274               GetRawsData(ddl)->Fill(stream.GetCharge(ddl,row,dil,pad));
275 //              Printf("charge %i",stream.GetCharge(ddl,row,dil,pad));
276             }//pad
277           }//dil
278         }//row
279       }//while
280     }
281     for(Int_t iErr =1; iErr<(Int_t)AliHMPIDRawStream::kSumErr; iErr++){
282       Int_t errflag = stream.GetErrors(iErr);
283
284        if(errflag < 0) GetRawsData(14)->Fill((Int_t)AliHMPIDRawStream::kSumErr+0.5);
285        else if(errflag == 0) GetRawsData(14)->Fill((Int_t)AliHMPIDRawStream::kSumErr-0.5);
286        else GetRawsData(14)->Fill(iErr-0.5);
287      }
288     stream.Delete();
289   }//chamber loop
290 }
291
292 //___________________________________________________________________________
293
294 void AliHMPIDQADataMaker::MakeSDigits(TClonesArray * data)
295 {
296  //
297  //filling QA histos for SDigits
298  //
299   TClonesArray * sdigits = dynamic_cast<TClonesArray *>(data) ; 
300   if (!sdigits) {
301     AliError("Wrong type of sdigits container") ; 
302   } else {
303     TIter next(sdigits) ; 
304     AliHMPIDDigit * sdigit ; 
305     while ( (sdigit = dynamic_cast<AliHMPIDDigit *>(next())) ) {
306             GetSDigitsData(0)->Fill(sdigit->Q());
307     } 
308   }
309 }
310 //___________________________________________________________________________
311 void AliHMPIDQADataMaker::MakeSDigits(TTree * data)
312 {
313  //
314  // Opening the SDigit Tree
315  //
316  TClonesArray * sdigits = new TClonesArray("AliHMPIDDigit", 1000) ;
317
318   TBranch * branch = data->GetBranch("HMPID") ;
319   if ( ! branch ) {
320     AliError("HMPID SDigit Tree not found") ;
321     return;
322   }
323   branch->SetAddress(&sdigits) ;
324   branch->GetEntry(0) ;
325   MakeSDigits(sdigits) ;
326 }
327 //____________________________________________________________________________
328 void AliHMPIDQADataMaker::MakeRecPoints(TTree * clustersTree)
329 {
330   //
331   //filling QA histos for clusters
332   //
333   TClonesArray *clusters = new TClonesArray("AliHMPIDCluster");
334   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){
335     TBranch *branch = clustersTree->GetBranch(Form("HMPID%d",i));
336     branch->SetAddress(&clusters);
337     branch->GetEntry(0);
338
339     GetRecPointsData(0)->Fill(i,clusters->GetEntries());
340     TIter next(clusters);
341     AliHMPIDCluster *clu;
342     while ( (clu = dynamic_cast<AliHMPIDCluster *>(next())) ) {
343       GetRecPointsData(1)->Fill(clu->Chi2());
344       GetRecPointsData(2)->Fill(clu->Status());
345       GetRecPointsData(3)->Fill(clu->Size());
346       GetRecPointsData(4)->Fill(clu->Q()); 
347     }
348   }
349
350   clusters->Delete();
351   delete clusters;
352 }
353
354 //____________________________________________________________________________
355 void AliHMPIDQADataMaker::MakeESDs(AliESDEvent * esd)
356 {
357   //
358   //fills QA histos for ESD
359   //
360   for(Int_t iTrk = 0 ; iTrk < esd->GetNumberOfTracks() ; iTrk++){
361     AliESDtrack *pTrk = esd->GetTrack(iTrk) ;
362     GetESDsData(0)->Fill(pTrk->GetP(),pTrk->GetHMPIDsignal());
363     GetESDsData(1)->Fill( pTrk->GetP(),TMath::Sqrt(pTrk->GetHMPIDchi2()));
364     Float_t xm,ym; Int_t q,np;  
365     pTrk->GetHMPIDmip(xm,ym,q,np);                       //mip info
366     GetESDsData(2)->Fill(xm,ym);
367     Float_t xRad,yRad,th,ph;        
368     pTrk->GetHMPIDtrk(xRad,yRad,th,ph);              //track info at the middle of the radiator
369     Float_t xPc = xRad+9.25*TMath::Tan(th)*TMath::Cos(ph); // temporar: linear extrapol (B=0!)
370     Float_t yPc = yRad+9.25*TMath::Tan(th)*TMath::Sin(ph); // temporar:          "
371     GetESDsData(3)->Fill(xm-xPc,ym-yPc); //track info
372     Double_t pid[5] ;      pTrk->GetHMPIDpid(pid) ;
373     for(Int_t i = 0 ; i < 5 ; i++) GetESDsData(4+i)->Fill(pid[i]) ;
374   }
375 }
376 //____________________________________________________________________________
377 void AliHMPIDQADataMaker::StartOfDetectorCycle()
378 {
379   //Detector specific actions at start of cycle
380   
381 }
382
383 void AliHMPIDQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * obj)
384 {
385   //Detector specific actions at end of cycle
386   // do the QA checking
387 //  AliQAChecker::Instance()->Run(AliQAv1::kHMPID, task, obj) ;  
388 }
389