1 // **************************************************************************
2 // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 // * Author: The ALICE Off-line Project. *
5 // * Contributors are mentioned in the code where appropriate. *
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 // **************************************************************************
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
31 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fSdi(0),fDig(0),fClu(0)
36 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
37 HitCreate(); gAlice->GetMCApp()->AddHitList(fHits);
39 }//AliHMPID::AliHMPID(const char *name, const char *title)
40 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 if(fHits) delete fHits;
48 if(fDigits) delete fDigits;
50 if(fDig) {fDig->Delete(); delete fDig;}
51 if(fClu) {fClu->Delete(); delete fClu;}
53 }//AliHMPID::~AliHMPID()
54 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 void AliHMPID::MakeBranch(Option_t* option)
57 //Create Tree branches for the HMPID.
58 AliDebug(1,Form("Start with option= %s.",option));
60 const Int_t kBufSize = 4000;
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");
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);}
73 }//void AliHMPID::MakeBranch(Option_t* option)
74 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75 void AliHMPID::SetTreeAddress()
77 //Set branch address for the Hits and Digits Tree.
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]));}
84 }//void AliHMPID::SetTreeAddress()
85 //__________________________________________________________________________________________________
86 // AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
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;}
97 // GetLoader()->UnloadHits();
100 //__________________________________________________________________________________________________
101 void AliHMPID::HitPrint(Int_t iEvtN)const
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;
109 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
110 GetLoader()->TreeH()->GetEntry(iPrimN);
112 iTotalHits+=Hits()->GetEntries();
114 GetLoader()->UnloadHits();
115 AliInfo(Form("totally %i hits",iTotalHits));
117 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118 void AliHMPID::SdiPrint(Int_t iEvt)const
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;
125 GetLoader()->TreeS()->GetEntry(0);
127 GetLoader()->UnloadSDigits();
128 Printf("totally %i sdigits",SdiLst()->GetEntries());
130 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
131 void AliHMPID::DigPrint(Int_t iEvt)const
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;
138 GetLoader()->TreeD()->GetEntry(0);
140 GetLoader()->UnloadDigits();
141 Printf("totally %i Digits",DigLst()->GetEntries());
143 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144 void AliHMPID::OccupancyPrint(Int_t iEvtNreq)
146 //prints occupancy for each chamber in a given event
147 Int_t iEvtNmin,iEvtNmax;
150 iEvtNmax=gAlice->GetEventsPerRun();
152 iEvtNmin=iEvtNreq;iEvtNmax=iEvtNreq+1;
155 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
156 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
158 // Info("Occupancy","for event %i",iEvtN);
159 if(GetLoader()->LoadHits()) return;
160 if(GetLoader()->LoadDigits()) return;
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);
176 iChHits[pHit->Ch()]++;
177 if(pStack->Particle(pHit->GetTrack())->Rho()<0.01) nPrim[pHit->Ch()]++;else nSec[pHit->Ch()]++;
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()]++;
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]);
194 GetLoader()->UnloadHits();
195 GetLoader()->UnloadDigits();
196 GetLoader()->GetRunLoader()->UnloadHeader();
197 GetLoader()->GetRunLoader()->UnloadKinematics();
199 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
200 void AliHMPID::CluPrint(Int_t iEvtN)const
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;
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();
212 GetLoader()->UnloadRecPoints();
213 Printf("totally %i clusters for event %i",iCluCnt,iEvtN);
215 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
216 void AliHMPID::SummaryOfEvent(Int_t iEvtN) const
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();
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()));
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++;
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();
240 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++