]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPID.cxx
Minor protection
[u/mrichter/AliRoot.git] / HMPID / AliHMPID.cxx
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" //
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 
28 ClassImp(AliHMPID)    
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fSdi(0),fDig(0),fClu(0)
31 {
32 //Named ctor
33   AliDebug(1,"Start.");
34 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
35   HitCreate();          gAlice->GetMCApp()->AddHitList(fHits);
36   AliDebug(1,"Stop.");
37 }//AliHMPID::AliHMPID(const char *name, const char *title)
38 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39 AliHMPID::~AliHMPID()
40 {
41 //dtor
42   AliDebug(1,"Start.");
43
44   
45   if(fHits)      delete fHits;
46   if(fDigits)    delete fDigits;
47   if(fSdi)       delete fSdi;
48   if(fDig)      {fDig->Delete();   delete fDig;}
49   if(fClu)      {fClu->Delete();   delete fClu;}
50   AliDebug(1,"Stop.");    
51 }//AliHMPID::~AliHMPID()
52 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 void AliHMPID::MakeBranch(Option_t* option)
54 {
55 //Create Tree branches for the HMPID.
56   AliDebug(1,Form("Start with option= %s.",option));
57     
58   const Int_t kBufSize = 4000;
59       
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");
64
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);}   
69   
70   AliDebug(1,"Stop.");   
71 }//void AliHMPID::MakeBranch(Option_t* option)
72 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
73 void AliHMPID::SetTreeAddress()
74 {
75 //Set branch address for the Hits and Digits Tree.
76   AliDebug(1,"Start.");
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]));}
81   AliDebug(1,"Stop.");
82 }//void AliHMPID::SetTreeAddress()
83 //__________________________________________________________________________________________________
84 // AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
85 // {
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;}
93 //     }//hits
94 //   }//prims loop
95 //   GetLoader()->UnloadHits();
96 //   return 0;
97 // }
98 //__________________________________________________________________________________________________
99 void AliHMPID::HitPrint(Int_t iEvtN)const
100 {
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;
105   
106   Int_t iTotalHits=0;
107   for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
108     GetLoader()->TreeH()->GetEntry(iPrimN);      
109     Hits()->Print();
110     iTotalHits+=Hits()->GetEntries();
111   }
112   GetLoader()->UnloadHits();
113   AliInfo(Form("totally %i hits",iTotalHits));
114 }
115 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
116 void AliHMPID::SdiPrint(Int_t iEvt)const
117 {
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;
122   
123   GetLoader()->TreeS()->GetEntry(0);
124   SdiLst()->Print();
125   GetLoader()->UnloadSDigits();
126   Printf("totally %i sdigits",SdiLst()->GetEntries());
127 }
128 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
129 void AliHMPID::DigPrint(Int_t iEvt)const
130 {
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;
135   
136   GetLoader()->TreeD()->GetEntry(0);
137   DigLst()->Print();
138   Int_t totDigs=0;
139   for(Int_t i=0;i<7;i++) {totDigs+=DigLst(i)->GetEntries();}
140   Printf("totally %i Digits",totDigs);
141   GetLoader()->UnloadDigits();
142 }
143 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144 void AliHMPID::CluPrint(Int_t iEvtN)const
145 {
146 //prints a list of HMPID clusters  for a given event
147   Printf("List of HMPID clusters for event %i",iEvtN);
148   if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;    
149   if(GetLoader()->LoadRecPoints()) return;
150   
151   Int_t iCluCnt=0;
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();
155   }
156   GetLoader()->UnloadRecPoints();
157   Printf("totally %i clusters for event %i",iCluCnt,iEvtN);
158 }
159 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++