This commit was generated by cvs2svn to compensate for changes in r15977,
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.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#include "AliHMPIDParam.h" //class header
16#include "AliHMPIDDigit.h" //ctor
17#include <TCanvas.h> //TestXXX()
18#include <TLatex.h> //TestTrans()
19#include <TView.h> //TestTrans()
20#include <TPolyMarker3D.h> //TestTrans()
21#include <TRotation.h>
22#include <AliRunLoader.h> //Stack()
23#include <AliStack.h> //Stack()
24#include <TParticle.h> //Stack()
25#include "AliHMPIDHelix.h" //TestTrans()
26
27ClassImp(AliHMPIDParam)
28
29AliHMPIDParam* AliHMPIDParam::fgInstance=0x0; //singleton pointer
30//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31AliHMPIDParam::AliHMPIDParam():TNamed("RichParam","default version")
32{
33// Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
34// In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.
35// Note that TGeoManager should be already initialized from geometry.root file
36 fX=0.5*AliHMPIDDigit::SizeAllX();
37 fY=0.5*AliHMPIDDigit::SizeAllY();
38 for(Int_t i=0;i<7;i++) fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix();
39 fgInstance=this;
40}//ctor
41//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42void AliHMPIDParam::Print(Option_t* opt) const
43{
44// print some usefull (hopefully) info on some internal guts of HMPID parametrisation
45
46 for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
47}//Print()
48//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
50{
51// Prints some usefull info from stack
52// Arguments: evt - event number. if not -1 print info only for that event
53// tid - track id. if not -1 then print it and all it's mothers if any
54// Returns: mother tid of the given tid if any
55 AliRunLoader *pAL=AliRunLoader::Open();
56 if(pAL->LoadHeader()) return -1;
57 if(pAL->LoadKinematics()) return -1;
58
59 Int_t mtid=-1;
60 Int_t iNevt=pAL->GetNumberOfEvents(); Printf("This session contains %i event(s)",iNevt);
61
62 for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
63 if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
64 pAL->GetEvent(iEvt);
65 AliStack *pStack=pAL->Stack();
66 if(tid==-1){ //print all tids for this event
67 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
68 Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
69 }else{ //print only this tid and it;s mothers
70 if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
71 TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
72 TString str=pTrack->GetName();
73 while((tid=pTrack->GetFirstMother()) >= 0){
74 pTrack=pStack->Particle(tid);
75 str+=" from ";str+=pTrack->GetName();
76 }
77 Printf("%s",str.Data());
78 }//if(tid==-1)
79 }//events loop
80 pAL->UnloadHeader(); pAL->UnloadKinematics();
81 return mtid;
82}
83//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
85{
86// Counts total number of particles of given sort (including secondary) for a given event
87 AliRunLoader *pAL=AliRunLoader::Open();
88 pAL->GetEvent(evt);
89 if(pAL->LoadHeader()) return 0;
90 if(pAL->LoadKinematics()) return 0;
91 AliStack *pStack=pAL->Stack();
92
93 Int_t iCnt=0;
94 for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
95
96 pAL->UnloadHeader(); pAL->UnloadKinematics();
97 return iCnt;
98}
99//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++