]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/AliHMPID.cxx
Removing the old and adding new CDB and alignment data files with the correct detecto...
[u/mrichter/AliRoot.git] / HMPID / AliHMPID.cxx
CommitLineData
d3da6dc4 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#include "AliHMPID.h"
17#include "AliHMPIDHit.h" //OccupancyPrint(), HitQa()
18#include "AliHMPIDDigit.h" //OccupancyPrint()
19#include <TParticle.h> //SummaryOfEvent(), HitQa()
20#include <TBenchmark.h> //HitQA()
21#include <TPDGCode.h> //HitQA()
22#include <AliStack.h> //OccupancyPrint(), SummaryOfEvent(), HitQa()
23#include <AliRun.h> //HitQa()
24#include <AliMC.h> //ctor
25#include <AliHeader.h>
26#include <AliGenEventHeader.h>
27#include <AliGenHijingEventHeader.h>
28#include <TH1F.h> //HitQA()
29#include <AliLog.h> //in many methods to print AliInfo
30ClassImp(AliHMPID)
31//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fSdi(0),fDig(0),fClu(0)
33{
34//Named ctor
35 AliDebug(1,"Start.");
36//AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
37 HitCreate(); gAlice->GetMCApp()->AddHitList(fHits);
38 AliDebug(1,"Stop.");
39}//AliHMPID::AliHMPID(const char *name, const char *title)
40//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41AliHMPID::~AliHMPID()
42{
43//dtor
44 AliDebug(1,"Start.");
45
46
47 if(fHits) delete fHits;
48 if(fDigits) delete fDigits;
49 if(fSdi) delete fSdi;
50 if(fDig) {fDig->Delete(); delete fDig;}
51 if(fClu) {fClu->Delete(); delete fClu;}
52 AliDebug(1,"Stop.");
53}//AliHMPID::~AliHMPID()
54//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55void AliHMPID::MakeBranch(Option_t* option)
56{
57//Create Tree branches for the HMPID.
58 AliDebug(1,Form("Start with option= %s.",option));
59
60 const Int_t kBufSize = 4000;
61
62 const char *cH = strstr(option,"H");
63 const char *cD = strstr(option,"D");
64 const char *cR = strstr(option,"R");
65 const char *cS = strstr(option,"S");
66
67 if(cH&& TreeH()){HitCreate(); MakeBranchInTree( TreeH(), "HMPID" ,&fHits ,kBufSize,0);}
68 if(cS&&fLoader->TreeS()){SdiCreate(); MakeBranchInTree(fLoader->TreeS(), "HMPID" ,&fSdi ,kBufSize,0);}
69 if(cD&&fLoader->TreeD()){DigCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeD(),Form("HMPID%d",i),&((*fDig)[i]),kBufSize,0);}
70 if(cR&&fLoader->TreeR()){CluCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeR(),Form("HMPID%d",i),&((*fClu)[i]),kBufSize,0);}
71
72 AliDebug(1,"Stop.");
73}//void AliHMPID::MakeBranch(Option_t* option)
74//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75void AliHMPID::SetTreeAddress()
76{
77//Set branch address for the Hits and Digits Tree.
78 AliDebug(1,"Start.");
79 if(fLoader->TreeH() && fLoader->TreeH()->GetBranch("HMPID" )){HitCreate(); fLoader->TreeH()->SetBranchAddress( "HMPID" ,&fHits );}
80 if(fLoader->TreeS() && fLoader->TreeS()->GetBranch("HMPID" )){SdiCreate(); fLoader->TreeS()->SetBranchAddress( "HMPID" ,&fSdi );}
81 if(fLoader->TreeD() && fLoader->TreeD()->GetBranch("HMPID0")){DigCreate(); for(int i=0;i<7;i++) fLoader->TreeD()->SetBranchAddress(Form("HMPID%d",i),&((*fDig)[i]));}
82 if(fLoader->TreeR() && fLoader->TreeR()->GetBranch("HMPID0")){CluCreate(); for(int i=0;i<7;i++) fLoader->TreeR()->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));}
83 AliDebug(1,"Stop.");
84}//void AliHMPID::SetTreeAddress()
85//__________________________________________________________________________________________________
86// AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
87// {
88// // Search for the first HMPID hit belonging to the given tid
89// GetLoader()->LoadHits();
90// for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
91// GetLoader()->TreeH()->GetEntry(iPrimN);
92// for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
93// AliHMPIDHit *pHit=(AliHMPIDHit*)Hits()->At(iHitN);
94// if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
95// }//hits
96// }//prims loop
97// GetLoader()->UnloadHits();
98// return 0;
99// }
100//__________________________________________________________________________________________________
101void AliHMPID::HitPrint(Int_t iEvtN)const
102{
103//Prints a list of HMPID hits for a given event. Default is event number 0.
104 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
105 AliInfo(Form("List of HMPID hits for event %i",iEvtN));
106 if(GetLoader()->LoadHits()) return;
107
108 Int_t iTotalHits=0;
109 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
110 GetLoader()->TreeH()->GetEntry(iPrimN);
111 Hits()->Print();
112 iTotalHits+=Hits()->GetEntries();
113 }
114 GetLoader()->UnloadHits();
115 AliInfo(Form("totally %i hits",iTotalHits));
116}
117//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118void AliHMPID::SdiPrint(Int_t iEvt)const
119{
120//prints a list of HMPID sdigits for a given event
121 if(GetLoader()->GetRunLoader()->GetEvent(iEvt)) return;
122 Info("PrintSDigits","List of HMPID sdigits for event %i",iEvt);
123 if(GetLoader()->LoadSDigits()) return;
124
125 GetLoader()->TreeS()->GetEntry(0);
126 SdiLst()->Print();
127 GetLoader()->UnloadSDigits();
128 Printf("totally %i sdigits",SdiLst()->GetEntries());
129}
130//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
131void AliHMPID::DigPrint(Int_t iEvt)const
132{
133//prints a list of HMPID digits for a given event
134 if(GetLoader()->GetRunLoader()->GetEvent(iEvt)) return;
135 Printf("List of HMPID digits for event %i",iEvt);
136 if(GetLoader()->LoadDigits()) return;
137
138 GetLoader()->TreeD()->GetEntry(0);
139 DigLst()->Print();
140 GetLoader()->UnloadDigits();
141 Printf("totally %i Digits",DigLst()->GetEntries());
142}
143//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144void AliHMPID::OccupancyPrint(Int_t iEvtNreq)
145{
146//prints occupancy for each chamber in a given event
147 Int_t iEvtNmin,iEvtNmax;
148 if(iEvtNreq==-1){
149 iEvtNmin=0;
150 iEvtNmax=gAlice->GetEventsPerRun();
151 } else {
152 iEvtNmin=iEvtNreq;iEvtNmax=iEvtNreq+1;
153 }
154
155 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
156 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
157
158// Info("Occupancy","for event %i",iEvtN);
159 if(GetLoader()->LoadHits()) return;
160 if(GetLoader()->LoadDigits()) return;
161
162
163 for(Int_t iEvtN=iEvtNmin;iEvtN<iEvtNmax;iEvtN++){
164 Int_t nDigCh[7]={0,0,0,0,0,0,0};
165 Int_t iChHits[7]={0,0,0,0,0,0,0};
166 Int_t nPrim[7]={0,0,0,0,0,0,0};
167 Int_t nSec[7]={0,0,0,0,0,0,0};
168 AliInfo(Form("events processed %i",iEvtN));
169 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
170 AliStack *pStack = GetLoader()->GetRunLoader()->Stack();
171 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
172 GetLoader()->TreeH()->GetEntry(iPrimN);
173 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
174 AliHMPIDHit *pHit = (AliHMPIDHit*)Hits()->At(iHitN);
175 if(pHit->E()>0){
176 iChHits[pHit->Ch()]++;
177 if(pStack->Particle(pHit->GetTrack())->Rho()<0.01) nPrim[pHit->Ch()]++;else nSec[pHit->Ch()]++;
178 }
179 }
180 }
181
182 GetLoader()->TreeD()->GetEntry(0);
183 for(Int_t iCh=0;iCh<7;iCh++){
184 for(Int_t iDig=0;iDig<DigLst(iCh)->GetEntries();iDig++){
185 AliHMPIDDigit *pDig=(AliHMPIDDigit*)DigLst(iCh)->At(iDig);
186 nDigCh[pDig->Ch()]++;
187 }
188 Printf("Occupancy for chamber %i = %4.2f %% and charged prim tracks %i and sec. tracks %i with total %i",
189 iCh,Float_t(nDigCh[iCh])*100/AliHMPIDDigit::kPadAll,nPrim[iCh],nSec[iCh],iChHits[iCh]);
190 }
191
192
193 }//events loop
194 GetLoader()->UnloadHits();
195 GetLoader()->UnloadDigits();
196 GetLoader()->GetRunLoader()->UnloadHeader();
197 GetLoader()->GetRunLoader()->UnloadKinematics();
198}
199//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200void AliHMPID::CluPrint(Int_t iEvtN)const
201{
202//prints a list of HMPID clusters for a given event
203 Printf("List of HMPID clusters for event %i",iEvtN);
204 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
205 if(GetLoader()->LoadRecPoints()) return;
206
207 Int_t iCluCnt=0;
208 GetLoader()->TreeR()->GetEntry(0);
209 for(Int_t iCh=0;iCh<7;iCh++){
210 TClonesArray *pCluLst=(TClonesArray*)fClu->At(iCh); iCluCnt+=pCluLst->GetEntries(); pCluLst->Print();
211 }
212 GetLoader()->UnloadRecPoints();
213 Printf("totally %i clusters for event %i",iCluCnt,iEvtN);
214}
215//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
216void AliHMPID::SummaryOfEvent(Int_t iEvtN) const
217{
218//prints a summary for a given event
219 AliInfo(Form("Summary of event %i",iEvtN));
220 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
221 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
222 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
223 AliStack *pStack=GetLoader()->GetRunLoader()->Stack();
224
225 AliGenEventHeader* pGenHeader = gAlice->GetHeader()->GenEventHeader();
226 if(pGenHeader->InheritsFrom("AliGenHijingEventHeader")) {
227 AliInfo(Form(" Hijing event with impact parameter b = %.2f (fm)",((AliGenHijingEventHeader*) pGenHeader)->ImpactParameter()));
228 }
229 Int_t nChargedPrimaries=0;
230 for(Int_t i=0;i<pStack->GetNtrack();i++) {
231 TParticle *pParticle = pStack->Particle(i);
232 if(pParticle->IsPrimary()&&pParticle->GetPDG()->Charge()!=0) nChargedPrimaries++;
233 }
234 AliInfo(Form("Total number of primaries %i",pStack->GetNprimary()));
235 AliInfo(Form("Total number of charged primaries %i",nChargedPrimaries));
236 AliInfo(Form("Total n. of tracks in stack(+sec) %i",pStack->GetNtrack()));
237 GetLoader()->GetRunLoader()->UnloadHeader();
238 GetLoader()->GetRunLoader()->UnloadKinematics();
239}
240//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++