Record changes.
[u/mrichter/AliRoot.git] / HMPID / Hqa.C
CommitLineData
96390f65 1#include <TSystem.h>
2#include <TFile.h>
3#include <TTree.h>
4#include <TClonesArray.h>
5#include <TObjArray.h>
6#include <TH2F.h>
7#include <TCanvas.h>
8
9#include <AliHMPIDHit.h>
10#include <AliHMPIDCluster.h>
9234c352 11#include <AliHMPIDDigit.h>
96390f65 12//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13TObjArray *CreateContainer(const char *classname,TTree *pTree)
14{
15 TObjArray *pOA=new TObjArray(7); pOA->SetOwner();
ae5a42aa 16 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
96390f65 17 TClonesArray *pCA=new TClonesArray(classname);
18 pOA->AddAt(pCA,iCh);
19 pTree->SetBranchAddress(Form("HMPID%i",iCh),&pCA);
20 }
96390f65 21 return pOA;
22}
23//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59d9d4b3 24TH1F *hHitQdc; TH2F *hHitMap[7];
25void Hits(Int_t mode,TTree *pTree=0x0)
26{
27 switch(mode){
28 case 1:
29 hHitQdc=new TH1F("HitQdc","Hit Qdc all chamber;QDC",500,0,4000);
30 for(Int_t iCh=0;iCh<7;iCh++) hHitMap[iCh]=new TH2F(Form("HitMap%i",iCh),Form("Ch%i;x_{Hit};y_{Hit}",iCh),160,0,160,160,0,160);
31 return;
32 case 2:
33 if(pTree==0) return;
34 TClonesArray *pHits=new TClonesArray("AliHMPIDHit"); pTree->SetBranchAddress("HMPID",&pHits);
35 for(Int_t iEnt=0;iEnt<pTree->GetEntriesFast();iEnt++){//entries loop
36 pTree->GetEntry(iEnt);
37 for(Int_t iHit=0;iHit<pHits->GetEntriesFast();iHit++){//hits loop
38 AliHMPIDHit *pHit = (AliHMPIDHit*)pHits->UncheckedAt(iHit);
39 hHitMap[pHit->Ch()]->Fill(pHit->LorsX(),pHit->LorsY());
40 hHitQdc->Fill(pHit->Q());
41 }//hits loop
42 }//entries loop
43 delete pHits;
44 return;
45 case 3:
46 TCanvas *c1=new TCanvas("HitCan","Hits",1280,800); c1->Divide(3,3);
47
48 for(Int_t iCh=0;iCh<7;iCh++){
49 if(iCh==6) c1->cd(1); if(iCh==5) c1->cd(2);
50 if(iCh==4) c1->cd(4); if(iCh==3) c1->cd(5); if(iCh==2) c1->cd(6);
51 if(iCh==1) c1->cd(8); if(iCh==0) c1->cd(9);
52 hHitMap[iCh]->Draw();
53 }
54 c1->cd(3); gPad->SetLogy(); hHitQdc->Draw();
55 return;
56 }
57}//Hits()
58//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96390f65 59TH1F *hCluEvt,*hCluChi2,*hCluFlg,*hCluSize;
96390f65 60void Clus(Int_t mode, TTree *pTree=0x0)
61{
62 switch(mode){
63 case 1:
64 hCluEvt=new TH1F("CluPerEvt","# clusters per event",11,-0.5,10.5);
65 hCluChi2 =new TH1F("CluChi2" ,"Chi2 " ,1000,0,100);
66 hCluFlg =new TH1F("CluFlg" ,"Cluster flag" ,14,-1.5,12.5); hCluFlg->SetFillColor(5);
67 hCluSize =new TH1F("CluSize" ,"Raw cluster size ",100,0,100);
68 return;
69 case 2:
70 if(pTree==0) return;
59d9d4b3 71 TObjArray *pLst=CreateContainer("AliHMPIDCluster",pTree); pTree->GetEntry(0);
ae5a42aa 72 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
96390f65 73 TClonesArray *pClus=(TClonesArray *)pLst->UncheckedAt(iCh);
96390f65 74 hCluEvt->Fill(pClus->GetEntriesFast());
75 for(Int_t iClu=0;iClu<pClus->GetEntriesFast();iClu++){//clusters loop
76 AliHMPIDCluster *pClu=(AliHMPIDCluster*)pClus->UncheckedAt(iClu);
59d9d4b3 77 hCluFlg->Fill(pClu->Status()); hCluChi2->Fill(pClu->Chi2()); hCluSize->Fill(pClu->Size());
96390f65 78 }
79 }
80 delete pLst;
81 return;
82 case 3:
83 TCanvas *c1=new TCanvas("CluComCan","Clusters in common",1280,800); c1->Divide(3,3);
59d9d4b3 84 c1->cd(1); hCluEvt->Draw(); c1->cd(2); hCluChi2->Draw();
85 c1->cd(3); hCluFlg->Draw(); c1->cd(4); hCluSize->Draw();
96390f65 86 return;
87 }//switch
88}//Clus()
9234c352 89//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90TH1F *hDigPcEvt,*hDigQ, *hDigChEvt;
91void Digs(Int_t mode, TTree *pTree=0x0)
92{
93 switch(mode){
94 case 1:
95 hDigPcEvt=new TH1F("OccPerEvt","PC occupancy per event",156,-1,77);
96 hDigChEvt=new TH1F("OccPerEvt","Chamber occupancy per event",32,-1,7);
97 hDigQ =new TH1F("Q ","Q ",3000,0,3000);
98 return;
99 case 2:
100 if(pTree==0) return;
101 TObjArray *pLst=CreateContainer("AliHMPIDDigit",pTree); pTree->GetEntry(0);
102 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
103 TClonesArray *pDigs=(TClonesArray *)pLst->UncheckedAt(iCh);
104 hDigChEvt->Fill(iCh,pDigs->GetEntriesFast()/(48.*80.*6.));
105 for(Int_t iDig=0;iDig<pDigs->GetEntriesFast();iDig++){//digits loop
106 AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigs->UncheckedAt(iDig);
107 hDigPcEvt->Fill(10.*iCh+pDig->Pc(),1./(48.*80.));
108 hDigQ->Fill(pDig->Q());
109 }
110 }
111 delete pLst;
112 return;
113 case 3:
114 TCanvas *c1=new TCanvas("DigQa","Digit Check",1280,800); c1->Divide(2,2);
115 c1->cd(1); hDigPcEvt->Draw(); c1->cd(2); hDigQ->Draw(); c1->cd(3); hDigChEvt->Draw();
116 return;
117 }//switch
118}//Dig()
119
96390f65 120//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00f49991 121void Hqa()
122{
96390f65 123
124 TFile *fh=0; if(gSystem->IsFileInIncludePath("HMPID.Hits.root")) fh=TFile::Open("HMPID.Hits.root" ,"read");if(fh->IsZombie()) fh=0;
125 TFile *fd=0; if(gSystem->IsFileInIncludePath("HMPID.Digits.root")) fd=TFile::Open("HMPID.Digits.root" ,"read");if(fd->IsZombie()) fd=0;
126 TFile *fc=0; if(gSystem->IsFileInIncludePath("HMPID.RecPoints.root")) fc=TFile::Open("HMPID.RecPoints.root","read");if(fc->IsZombie()) fc=0;
96390f65 127 if(fh==0 && fd==0 && fc==0){Printf("Nothing to do!"); return;}
9234c352 128 if(fh) Hits(1); if(fc) Clus(1); if(fd) Digs(1);//book
96390f65 129 Int_t iEvt=0;
130 while(1){
131 TTree *th=0; if(fh) th=(TTree*)fh->Get(Form("Event%i/TreeH",iEvt));
132 TTree *td=0; if(fd) td=(TTree*)fd->Get(Form("Event%i/TreeD",iEvt));
133 TTree *tc=0; if(fc) tc=(TTree*)fc->Get(Form("Event%i/TreeR",iEvt));
9234c352 134 Hits(2,th); Clus(2,tc); Digs(2,td);//fill
96390f65 135 if(th==0 && td==0 && tc==0) break;
136 iEvt++;
137 Printf("Event %i processed",iEvt);
138 }
9234c352 139 // if(fh) Hits(3); if(fc) Clus(3);
140
141if(fd) Digs(3);//plot
96390f65 142}
143
144/*
145
146void BlahQA()
00f49991 147{
27311693 148 TFile *pFile = new TFile("Hqa.root","recreate");
149 AliHMPIDCluster::DoCorrSin(kFALSE);
150 AliHMPIDDigit::fSigmas=4;
151 Int_t nEvts=10000;
00f49991 152 TLegend *lQ=new TLegend(0.5,0.5,0.9,0.9);
153
154 TH1F *hQ7eV =new TH1F("hQ7eV" ,"" ,300,-50,2000); hQ7eV ->SetLineColor(kRed); lQ->AddEntry(hQ7eV ,"Ckov 7 eV"); hQ7eV->SetStats(0);
155 TH1F *hQ200eV=new TH1F("hQ200eV","" ,300,-50,2000); hQ200eV->SetLineColor(kBlack); lQ->AddEntry(hQ200eV,"mip 200 eV");
156 TH1F *hQ500eV=new TH1F("hQ500eV","" ,300,-50,2000); hQ500eV->SetLineColor(kCyan); lQ->AddEntry(hQ500eV,"mip 500 eV");
157 TH1F *hQ900eV=new TH1F("hQ900eV","" ,300,-50,2000); hQ900eV->SetLineColor(kGreen); lQ->AddEntry(hQ900eV,"mip 900 eV");
158
00f49991 159
160 gStyle->SetOptStat(10);
161 TH2F *pCluMapSi1 =new TH2F("cluMapSi1","Size 1 map" ,1700,-10,160,1700,-10,160);
162 TH2F *pCluMapLo0 =new TH2F("cluMNoLo0","Loc Max 0 map" ,1700,-10,160,1700,-10,160);
163 TH2F *pCluMapLo1 =new TH2F("cluMapLo1","Loc Max 1 map" ,1700,-10,160,1700,-10,160);
164 TH2F *pCluMapUnf =new TH2F("cluMapUnf","Unfolded map" ,1700,-10,160,1700,-10,160);
165 TH2F *pCluMapEdg =new TH2F("cluMapEdg","On edge map" ,1700,-10,160,1700,-10,160);
166 TH2F *pCluMapCoG =new TH2F("cluMapCoG","CoG map" ,1700,-10,160,1700,-10,160);
167 TH2F *pCluMapEmp =new TH2F("cluMapEmp","undefined-empty" ,1700,-10,160,1700,-10,160);
168 TH2F *pCluMapNoLoc=new TH2F("cluMapNoLoc","no loc maxima" ,1700,-10,160,1700,-10,160);
169 TH2F *pCluMapAbn =new TH2F("cluMapAbn","abnormal fit" ,1700,-10,160,1700,-10,160);
170 TH2F *pCluMapNot =new TH2F("cluMapNot","Raw Clusters" ,1700,-10,160,1700,-10,160);
171 TH2F *pCluMapMax =new TH2F("cluMapMax","N. locs excceds" ,1700,-10,160,1700,-10,160);
172
27311693 173 TH1F *hHitCluDifX = new TH1F("hHitCluDifX" ,";entries;x_{Hit}-x_{Clu} [cm]" ,1000,-1,1); hHitCluDifX->Sumw2(); hHitCluDifX->SetFillColor(kYellow);
174// TH2F *hHitCluDifXv= new TH2F("hHitCluDifXv",";x_{Hit};x_{Hit}-x_{Clu} [cm]" ,500,-0.5,0.5,1000,-0.2,0.2);hHitCluDifXv->Sumw2();
175 TProfile *hHitCluDifXv= new TProfile("hHitCluDifXv",";x_{Hit};x_{Hit}-x_{Clu} [cm]" ,500,-0.5,0.5);
176 TH1F *hHitCluDifY = new TH1F("hHitCluDifY" ,";entries;y_{Hit}-y_{Clu} [cm]" ,1000,-1,1); hHitCluDifY->Sumw2(); hHitCluDifY->SetFillColor(kYellow);
177 TH2F *hHitCluDifXY= new TH2F("hHitCluDifXY",";x_{Hit}-x_{Clu};y_{Hit}-y_{Clu}",1000,-1,1,1000,-1,1);hHitCluDifXY->Sumw2();
00f49991 178 TH1F *hHitCluDifQ = new TH1F("hHitCluDifQ" ,";entries;(Q_{Clu}-Q_{Hit})/Q_{Hit}" ,200 ,-200,200); hHitCluDifQ->Sumw2(); hHitCluDifQ->SetFillColor(kYellow);
179
00f49991 180
181 Float_t e200=200e-9,e500=500e-9,e900=900e-9,e7=7e-9;//predefined Eloss
182
183 AliHMPIDHit hit(0,0,kProton,0,0,0);
184 for(int i=0;i<5000;i++){
185 hQ200eV->Fill(hit.QdcTot(e200)); hQ500eV->Fill(hit.QdcTot(e500)); hQ900eV->Fill(hit.QdcTot(e900)); hQ7eV->Fill(hit.QdcTot(e7));
186 }
187 TClonesArray hits("AliHMPIDHit"); TClonesArray sdigs("AliHMPIDDigit");
188 TObjArray digs(7); for(Int_t i=0;i<7;i++) digs.AddAt(new TClonesArray("AliHMPIDDigit"),i);
189 TObjArray clus(7); for(Int_t i=0;i<7;i++) clus.AddAt(new TClonesArray("AliHMPIDCluster"),i);
190
191
192 for(Int_t iEvt=0;iEvt<nEvts;iEvt++){//events loop
27311693 193 if(iEvt%50==0)Printf("============> iEvt = %d ",iEvt);
00f49991 194
195 Int_t ch,pid; Float_t e,hitx,hity,hitq;
196// Int_t nHits=(type==999)?1:40;
197 Int_t nHits=1;
198 for(Int_t iHit=0;iHit<nHits;iHit++){//hits loop for the current event
199 switch(iHit){
27311693 200 case 0: ch=0;pid=kProton;e=e200;
ae5a42aa 201 hitx=AliHMPIDParam::SizePadX()*(6+gRandom->Rndm());
202 hity=AliHMPIDParam::SizePadY()*(6+gRandom->Rndm());break; //mip ramdomly distributed in one pad
00f49991 203 case 1: ch=0;pid=kProton;e=e200;hitx=0.4;hity=0.42;break; //mip in left-hand bottom coner of chamber 0
204 case 2: ch=0;pid=kProton;e=e200;hitx=0.4;hity=30 ;break; //mip on left edge of chamber 0
205 case 3: ch=0;pid=kProton;e=e200;hitx=40; hity=0.42;break; //mip on bottom edge of chamber 0
206 default: ch=gRandom->Rndm()*6; pid=(gRandom->Rndm()>0.9)? kProton:50000050;
207 if(pid==kProton)
208 e=gRandom->Rndm()*900e-9;
209 else
210 e=5.5e-9+3e-9*gRandom->Rndm();
ae5a42aa 211 hitx=gRandom->Rndm()*AliHMPIDParam::SizeAllX(); hity=gRandom->Rndm()*AliHMPIDParam::SizeAllY();break; //random hit
00f49991 212 }
213 new(hits[iHit]) AliHMPIDHit(ch,e,pid,iHit,hitx,hity);
214 hitq=e;
215 }//hits loop
216
9234c352 217 case AliHMPIDCluster::kNoLoc: pCluMapNoLoc->Fill(clux,cluy);break;
27311693 218 case AliHMPIDCluster::kNoLoc: pCluMapNoLoc->Fill(clux,cluy);break;
219 case AliHMPIDCluster::kAbn: pCluMapAbn->Fill(clux,cluy); break;
220 case AliHMPIDCluster::kNot: pCluMapNot->Fill(clux,cluy); break;
00f49991 221 default: pCluMapEmp->Fill(clux,cluy); break;
222 }
223
224 hHitCluDifX->Fill(hitx-clux); hHitCluDifY->Fill(hity-cluy); hHitCluDifXY->Fill(hitx-clux,hity-cluy); hHitCluDifQ->Fill(100*(cluq-hitq)/hitq);
27311693 225 // distorsion due to feedback photons
226 Int_t pc,px,py;
ae5a42aa 227 AliHMPIDParam::Lors2Pad(hitx,hity,pc,px,py);
228 Float_t padCenterX = AliHMPIDParam::LorsX(pc,px);
27311693 229 if(pClu->Size()>1)hHitCluDifXv->Fill(hitx-padCenterX,(hitx-clux));
230 //
00f49991 231 }//clusters loop
232 }//chambers loop
233
234 hits.Delete(); sdigs.Delete(); for(int i = 0;i<7;i++){((TClonesArray*)digs.At(i))->Delete();((TClonesArray*)clus.At(i))->Delete();}
235 }//events loop
96390f65 236}
237
238
239
240*/