Fix for the problem during PbPb run of Nov 2010 (Indra)
[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()
3c6274c1 18#include "AliHMPIDDigit.h" //
d3da6dc4 19#include <TParticle.h> //SummaryOfEvent(), HitQa()
20#include <TBenchmark.h> //HitQA()
21#include <TPDGCode.h> //HitQA()
3c6274c1 22#include <AliStack.h> //SummaryOfEvent(), HitQa()
d3da6dc4 23#include <AliRun.h> //HitQa()
24#include <AliMC.h> //ctor
25#include <AliHeader.h>
d3da6dc4 26#include <TH1F.h> //HitQA()
27#include <AliLog.h> //in many methods to print AliInfo
27311693 28
d3da6dc4 29ClassImp(AliHMPID)
30//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59d9d4b3 31AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fDoFeed(kTRUE),fSdi(0),fDig(0),fClu(0)
d3da6dc4 32{
33//Named ctor
34 AliDebug(1,"Start.");
35//AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
36 HitCreate(); gAlice->GetMCApp()->AddHitList(fHits);
59d9d4b3 37
38 TString ttl=title;
39 fDoFeed=!ttl.Contains("NoFeedBack");
d3da6dc4 40 AliDebug(1,"Stop.");
41}//AliHMPID::AliHMPID(const char *name, const char *title)
42//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43AliHMPID::~AliHMPID()
44{
45//dtor
46 AliDebug(1,"Start.");
47
48
49 if(fHits) delete fHits;
50 if(fDigits) delete fDigits;
51 if(fSdi) delete fSdi;
52 if(fDig) {fDig->Delete(); delete fDig;}
53 if(fClu) {fClu->Delete(); delete fClu;}
54 AliDebug(1,"Stop.");
55}//AliHMPID::~AliHMPID()
56//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57void AliHMPID::MakeBranch(Option_t* option)
58{
59//Create Tree branches for the HMPID.
60 AliDebug(1,Form("Start with option= %s.",option));
61
62 const Int_t kBufSize = 4000;
63
64 const char *cH = strstr(option,"H");
65 const char *cD = strstr(option,"D");
66 const char *cR = strstr(option,"R");
67 const char *cS = strstr(option,"S");
68
cb5b8b21 69 if(cH&&fLoader->TreeH()){HitCreate(); MakeBranchInTree(fLoader->TreeH(), "HMPID" ,&fHits ,kBufSize,0);}
d3da6dc4 70 if(cS&&fLoader->TreeS()){SdiCreate(); MakeBranchInTree(fLoader->TreeS(), "HMPID" ,&fSdi ,kBufSize,0);}
71 if(cD&&fLoader->TreeD()){DigCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeD(),Form("HMPID%d",i),&((*fDig)[i]),kBufSize,0);}
72 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
74 AliDebug(1,"Stop.");
75}//void AliHMPID::MakeBranch(Option_t* option)
76//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77void AliHMPID::SetTreeAddress()
78{
79//Set branch address for the Hits and Digits Tree.
80 AliDebug(1,"Start.");
81 if(fLoader->TreeH() && fLoader->TreeH()->GetBranch("HMPID" )){HitCreate(); fLoader->TreeH()->SetBranchAddress( "HMPID" ,&fHits );}
82 if(fLoader->TreeS() && fLoader->TreeS()->GetBranch("HMPID" )){SdiCreate(); fLoader->TreeS()->SetBranchAddress( "HMPID" ,&fSdi );}
83 if(fLoader->TreeD() && fLoader->TreeD()->GetBranch("HMPID0")){DigCreate(); for(int i=0;i<7;i++) fLoader->TreeD()->SetBranchAddress(Form("HMPID%d",i),&((*fDig)[i]));}
84 if(fLoader->TreeR() && fLoader->TreeR()->GetBranch("HMPID0")){CluCreate(); for(int i=0;i<7;i++) fLoader->TreeR()->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));}
85 AliDebug(1,"Stop.");
86}//void AliHMPID::SetTreeAddress()
87//__________________________________________________________________________________________________
88// AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
89// {
90// // Search for the first HMPID hit belonging to the given tid
91// GetLoader()->LoadHits();
92// for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
93// GetLoader()->TreeH()->GetEntry(iPrimN);
94// for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
95// AliHMPIDHit *pHit=(AliHMPIDHit*)Hits()->At(iHitN);
96// if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
97// }//hits
98// }//prims loop
99// GetLoader()->UnloadHits();
100// return 0;
101// }