ROOT logo
//  **************************************************************************
//  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
//  *                                                                        *
//  * Author: The ALICE Off-line Project.                                    *
//  * Contributors are mentioned in the code where appropriate.              *
//  *                                                                        *
//  * Permission to use, copy, modify and distribute this software and its   *
//  * documentation strictly for non-commercial purposes is hereby granted   *
//  * without fee, provided that the above copyright notice appears in all   *
//  * copies and that both the copyright notice and this permission notice   *
//  * appear in the supporting documentation. The authors make no claims     *
//  * about the suitability of this software for any purpose. It is          *
//  * provided "as is" without express or implied warranty.                  *
//  **************************************************************************

#include <TTree.h>
#include "AliHMPID.h"
#include "AliHMPIDHit.h"   //OccupancyPrint(), HitQa()
#include "AliHMPIDDigit.h" //
#include <TParticle.h>  //SummaryOfEvent(), HitQa()
#include <TBenchmark.h>  //HitQA()
#include <TPDGCode.h>    //HitQA()
#include <AliStack.h>   //SummaryOfEvent(), HitQa()
#include <AliRun.h>     //HitQa() 
#include <AliMC.h>       //ctor
#include <AliHeader.h>
#include <TH1F.h>        //HitQA()
#include <AliLog.h>      //in many methods to print AliInfo 
#include "AliLoader.h"

ClassImp(AliHMPID)    
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AliHMPID::AliHMPID(const char *name, const char *title):AliDetector(name,title),fDoFeed(kTRUE),fSdi(0),fDig(0),fClu(0)
{
//Named ctor
  AliDebug(1,"Start.");
//AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
  HitCreate();          gAlice->GetMCApp()->AddHitList(fHits);
  
  TString ttl=title;
  fDoFeed=!ttl.Contains("NoFeedBack");
  AliDebug(1,"Stop.");
}//AliHMPID::AliHMPID(const char *name, const char *title)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AliHMPID::~AliHMPID()
{
//dtor
  AliDebug(1,"Start.");

  
  if(fHits)      delete fHits;
  if(fDigits)    delete fDigits;
  if(fSdi)       delete fSdi;
  if(fDig)      {fDig->Delete();   delete fDig;}
  if(fClu)      {fClu->Delete();   delete fClu;}
  AliDebug(1,"Stop.");    
}//AliHMPID::~AliHMPID()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void AliHMPID::MakeBranch(Option_t* option)
{
//Create Tree branches for the HMPID.
  AliDebug(1,Form("Start with option= %s.",option));
    
  const Int_t kBufSize = 4000;
      
  const char *cH = strstr(option,"H");
  const char *cD = strstr(option,"D");
  const char *cR = strstr(option,"R");
  const char *cS = strstr(option,"S");

  if(cH&&fLoader->TreeH()){HitCreate();                       MakeBranchInTree(fLoader->TreeH(),     "HMPID"     ,&fHits       ,kBufSize,0);}
  if(cS&&fLoader->TreeS()){SdiCreate();                       MakeBranchInTree(fLoader->TreeS(),     "HMPID"     ,&fSdi        ,kBufSize,0);}
  if(cD&&fLoader->TreeD()){DigCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeD(),Form("HMPID%d",i),&((*fDig)[i]),kBufSize,0);}
  if(cR&&fLoader->TreeR()){CluCreate();for(Int_t i=0;i<7;i++) MakeBranchInTree(fLoader->TreeR(),Form("HMPID%d",i),&((*fClu)[i]),kBufSize,0);}   
  
  AliDebug(1,"Stop.");   
}//void AliHMPID::MakeBranch(Option_t* option)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void AliHMPID::SetTreeAddress()
{
//Set branch address for the Hits and Digits Tree.
  AliDebug(1,"Start.");
  if(fLoader->TreeH() && fLoader->TreeH()->GetBranch("HMPID" )){HitCreate();                      fLoader->TreeH()->SetBranchAddress(     "HMPID"     ,&fHits       );}
  if(fLoader->TreeS() && fLoader->TreeS()->GetBranch("HMPID" )){SdiCreate();                      fLoader->TreeS()->SetBranchAddress(     "HMPID"     ,&fSdi        );}
  if(fLoader->TreeD() && fLoader->TreeD()->GetBranch("HMPID0")){DigCreate(); for(int i=0;i<7;i++) fLoader->TreeD()->SetBranchAddress(Form("HMPID%d",i),&((*fDig)[i]));}
  if(fLoader->TreeR() && fLoader->TreeR()->GetBranch("HMPID0")){CluCreate(); for(int i=0;i<7;i++) fLoader->TreeR()->SetBranchAddress(Form("HMPID%d",i),&((*fClu)[i]));}
  AliDebug(1,"Stop.");
}//void AliHMPID::SetTreeAddress()
//__________________________________________________________________________________________________
// AliHMPIDHit* AliHMPID::Hit(Int_t tid)const
// {
// // Search for the first HMPID hit belonging to the given tid
//   GetLoader()->LoadHits();
//   for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop      
//     GetLoader()->TreeH()->GetEntry(iPrimN);
//     for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
//       AliHMPIDHit *pHit=(AliHMPIDHit*)Hits()->At(iHitN);
//       if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
//     }//hits
//   }//prims loop
//   GetLoader()->UnloadHits();
//   return 0;
// }
 AliHMPID.cxx:1
 AliHMPID.cxx:2
 AliHMPID.cxx:3
 AliHMPID.cxx:4
 AliHMPID.cxx:5
 AliHMPID.cxx:6
 AliHMPID.cxx:7
 AliHMPID.cxx:8
 AliHMPID.cxx:9
 AliHMPID.cxx:10
 AliHMPID.cxx:11
 AliHMPID.cxx:12
 AliHMPID.cxx:13
 AliHMPID.cxx:14
 AliHMPID.cxx:15
 AliHMPID.cxx:16
 AliHMPID.cxx:17
 AliHMPID.cxx:18
 AliHMPID.cxx:19
 AliHMPID.cxx:20
 AliHMPID.cxx:21
 AliHMPID.cxx:22
 AliHMPID.cxx:23
 AliHMPID.cxx:24
 AliHMPID.cxx:25
 AliHMPID.cxx:26
 AliHMPID.cxx:27
 AliHMPID.cxx:28
 AliHMPID.cxx:29
 AliHMPID.cxx:30
 AliHMPID.cxx:31
 AliHMPID.cxx:32
 AliHMPID.cxx:33
 AliHMPID.cxx:34
 AliHMPID.cxx:35
 AliHMPID.cxx:36
 AliHMPID.cxx:37
 AliHMPID.cxx:38
 AliHMPID.cxx:39
 AliHMPID.cxx:40
 AliHMPID.cxx:41
 AliHMPID.cxx:42
 AliHMPID.cxx:43
 AliHMPID.cxx:44
 AliHMPID.cxx:45
 AliHMPID.cxx:46
 AliHMPID.cxx:47
 AliHMPID.cxx:48
 AliHMPID.cxx:49
 AliHMPID.cxx:50
 AliHMPID.cxx:51
 AliHMPID.cxx:52
 AliHMPID.cxx:53
 AliHMPID.cxx:54
 AliHMPID.cxx:55
 AliHMPID.cxx:56
 AliHMPID.cxx:57
 AliHMPID.cxx:58
 AliHMPID.cxx:59
 AliHMPID.cxx:60
 AliHMPID.cxx:61
 AliHMPID.cxx:62
 AliHMPID.cxx:63
 AliHMPID.cxx:64
 AliHMPID.cxx:65
 AliHMPID.cxx:66
 AliHMPID.cxx:67
 AliHMPID.cxx:68
 AliHMPID.cxx:69
 AliHMPID.cxx:70
 AliHMPID.cxx:71
 AliHMPID.cxx:72
 AliHMPID.cxx:73
 AliHMPID.cxx:74
 AliHMPID.cxx:75
 AliHMPID.cxx:76
 AliHMPID.cxx:77
 AliHMPID.cxx:78
 AliHMPID.cxx:79
 AliHMPID.cxx:80
 AliHMPID.cxx:81
 AliHMPID.cxx:82
 AliHMPID.cxx:83
 AliHMPID.cxx:84
 AliHMPID.cxx:85
 AliHMPID.cxx:86
 AliHMPID.cxx:87
 AliHMPID.cxx:88
 AliHMPID.cxx:89
 AliHMPID.cxx:90
 AliHMPID.cxx:91
 AliHMPID.cxx:92
 AliHMPID.cxx:93
 AliHMPID.cxx:94
 AliHMPID.cxx:95
 AliHMPID.cxx:96
 AliHMPID.cxx:97
 AliHMPID.cxx:98
 AliHMPID.cxx:99
 AliHMPID.cxx:100
 AliHMPID.cxx:101
 AliHMPID.cxx:102
 AliHMPID.cxx:103