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" //
19 #include <TParticle.h> //SummaryOfEvent(), HitQa()
20 #include <TBenchmark.h> //HitQA()
21 #include <TPDGCode.h> //HitQA()
22 #include <AliStack.h> //SummaryOfEvent(), HitQa()
23 #include <AliRun.h> //HitQa()
24 #include <AliMC.h> //ctor
25 #include <AliHeader.h>
26 #include <TH1F.h> //HitQA()
27 #include <AliLog.h> //in many methods to print AliInfo
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fSdi(0),fDig(0),fClu(0)
34 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
35 HitCreate(); gAlice->GetMCApp()->AddHitList(fHits);
37 }//AliHMPID::AliHMPID(const char *name, const char *title)
38 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 if(fHits) delete fHits;
46 if(fDigits) delete fDigits;
48 if(fDig) {fDig->Delete(); delete fDig;}
49 if(fClu) {fClu->Delete(); delete fClu;}
51 }//AliHMPID::~AliHMPID()
52 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 void AliHMPID::MakeBranch(Option_t* option)
55 //Create Tree branches for the HMPID.
56 AliDebug(1,Form("Start with option= %s.",option));
58 const Int_t kBufSize = 4000;
60 const char *cH = strstr(option,"H");
61 const char *cD = strstr(option,"D");
62 const char *cR = strstr(option,"R");
63 const char *cS = strstr(option,"S");
65 if(cH&& TreeH()){HitCreate(); MakeBranchInTree( TreeH(), "HMPID" ,&fHits ,kBufSize,0);}
66 if(cS&&fLoader->TreeS()){SdiCreate(); MakeBranchInTree(fLoader->TreeS(), "HMPID" ,&fSdi ,kBufSize,0);}
67 if(cD&&fLoader->TreeD()){DigCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeD(),Form("HMPID%d",i),&((*fDig)[i]),kBufSize,0);}
68 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 }//void AliHMPID::MakeBranch(Option_t* option)
72 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
73 void AliHMPID::SetTreeAddress()
75 //Set branch address for the Hits and Digits Tree.
77 if(fLoader->TreeH() && fLoader->TreeH()->GetBranch("HMPID" )){HitCreate(); fLoader->TreeH()->SetBranchAddress( "HMPID" ,&fHits );}
78 if(fLoader->TreeS() && fLoader->TreeS()->GetBranch("HMPID" )){SdiCreate(); fLoader->TreeS()->SetBranchAddress( "HMPID" ,&fSdi );}
79 if(fLoader->TreeD() && fLoader->TreeD()->GetBranch("HMPID0")){DigCreate(); for(int i=0;i<7;i++) fLoader->TreeD()->SetBranchAddress(Form("HMPID%d",i),&((*fDig)[i]));}
80 if(fLoader->TreeR() && fLoader->TreeR()->GetBranch("HMPID0")){CluCreate(); for(int i=0;i<7;i++) fLoader->TreeR()->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));}
82 }//void AliHMPID::SetTreeAddress()
83 //__________________________________________________________________________________________________
84 // AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
86 // // Search for the first HMPID hit belonging to the given tid
87 // GetLoader()->LoadHits();
88 // for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
89 // GetLoader()->TreeH()->GetEntry(iPrimN);
90 // for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
91 // AliHMPIDHit *pHit=(AliHMPIDHit*)Hits()->At(iHitN);
92 // if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
95 // GetLoader()->UnloadHits();
98 //__________________________________________________________________________________________________
99 void AliHMPID::HitPrint(Int_t iEvtN)const
101 //Prints a list of HMPID hits for a given event. Default is event number 0.
102 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
103 AliInfo(Form("List of HMPID hits for event %i",iEvtN));
104 if(GetLoader()->LoadHits()) return;
107 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
108 GetLoader()->TreeH()->GetEntry(iPrimN);
110 iTotalHits+=Hits()->GetEntries();
112 GetLoader()->UnloadHits();
113 AliInfo(Form("totally %i hits",iTotalHits));
115 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
116 void AliHMPID::SdiPrint(Int_t iEvt)const
118 //prints a list of HMPID sdigits for a given event
119 if(GetLoader()->GetRunLoader()->GetEvent(iEvt)) return;
120 Info("PrintSDigits","List of HMPID sdigits for event %i",iEvt);
121 if(GetLoader()->LoadSDigits()) return;
123 GetLoader()->TreeS()->GetEntry(0);
125 GetLoader()->UnloadSDigits();
126 Printf("totally %i sdigits",SdiLst()->GetEntries());
128 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
129 void AliHMPID::DigPrint(Int_t iEvt)const
131 //prints a list of HMPID digits for a given event
132 if(GetLoader()->GetRunLoader()->GetEvent(iEvt)) return;
133 Printf("List of HMPID digits for event %i",iEvt);
134 if(GetLoader()->LoadDigits()) return;
136 GetLoader()->TreeD()->GetEntry(0);
139 for(Int_t i=0;i<7;i++) {totDigs+=DigLst(i)->GetEntries();}
140 Printf("totally %i Digits",totDigs);
141 GetLoader()->UnloadDigits();
143 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144 void AliHMPID::CluPrint(Int_t iEvtN)const
146 //prints a list of HMPID clusters for a given event
147 Printf("List of HMPID clusters for event %i",iEvtN);
148 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
149 if(GetLoader()->LoadRecPoints()) return;
152 GetLoader()->TreeR()->GetEntry(0);
153 for(Int_t iCh=0;iCh<7;iCh++){
154 TClonesArray *pCluLst=(TClonesArray*)fClu->At(iCh); iCluCnt+=pCluLst->GetEntries(); pCluLst->Print();
156 GetLoader()->UnloadRecPoints();
157 Printf("totally %i clusters for event %i",iCluCnt,iEvtN);
159 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++