Better selection between menus
[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()
d3da6dc4 25
26ClassImp(AliHMPIDParam)
27
28AliHMPIDParam* AliHMPIDParam::fgInstance=0x0; //singleton pointer
29//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30AliHMPIDParam::AliHMPIDParam():TNamed("RichParam","default version")
31{
32// Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
33// In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.
34// Note that TGeoManager should be already initialized from geometry.root file
35 fX=0.5*AliHMPIDDigit::SizeAllX();
36 fY=0.5*AliHMPIDDigit::SizeAllY();
1d4857c5 37 for(Int_t i=0;i<7;i++)
38 if(gGeoManager)
39 fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix();
40 else{
41 fM[i]=new TGeoHMatrix;
42 IdealPosition(i,fM[i]);
43 }
d3da6dc4 44 fgInstance=this;
45}//ctor
46//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47void AliHMPIDParam::Print(Option_t* opt) const
48{
49// print some usefull (hopefully) info on some internal guts of HMPID parametrisation
50
51 for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
52}//Print()
53//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1d4857c5 54void AliHMPIDParam::IdealPosition(Int_t iCh, TGeoHMatrix *pMatrix)
55{
56// Construct ideal position matrix for a given chamber
57// Arguments: iCh- chamber ID; pMatrix- pointer to precreated unity matrix where to store the results
58// Returns: none
59 const Double_t kAngHor=19.5; // horizontal angle between chambers 19.5 grad
60 const Double_t kAngVer=20; // vertical angle between chambers 20 grad
61 const Double_t kAngCom=30; // common HMPID rotation with respect to x axis 30 grad
62 const Double_t trans[3]={490,0,0}; //center of the chamber is on window-gap surface
63 pMatrix->RotateY(90); //rotate around y since initial position is in XY plane -> now in YZ plane
64 pMatrix->SetTranslation(trans); //now plane in YZ is shifted along x
65 switch(iCh){
66 case 0: pMatrix->RotateY(kAngHor); pMatrix->RotateZ(-kAngVer); break; //right and down
67 case 1: pMatrix->RotateZ(-kAngVer); break; //down
68 case 2: pMatrix->RotateY(kAngHor); break; //right
69 case 3: break; //no rotation
70 case 4: pMatrix->RotateY(-kAngHor); break; //left
71 case 5: pMatrix->RotateZ(kAngVer); break; //up
72 case 6: pMatrix->RotateY(-kAngHor); pMatrix->RotateZ(kAngVer); break; //left and up
73 }
74 pMatrix->RotateZ(kAngCom); //apply common rotation in XY plane
75
76}
77//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d3da6dc4 78Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
79{
d1bf51e1 80// Prints some useful info from stack
d3da6dc4 81// Arguments: evt - event number. if not -1 print info only for that event
82// tid - track id. if not -1 then print it and all it's mothers if any
83// Returns: mother tid of the given tid if any
84 AliRunLoader *pAL=AliRunLoader::Open();
85 if(pAL->LoadHeader()) return -1;
86 if(pAL->LoadKinematics()) return -1;
87
88 Int_t mtid=-1;
cf7e313e 89 Int_t iNevt=pAL->GetNumberOfEvents();
d3da6dc4 90
91 for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
92 if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
93 pAL->GetEvent(iEvt);
94 AliStack *pStack=pAL->Stack();
95 if(tid==-1){ //print all tids for this event
96 for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
97 Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
98 }else{ //print only this tid and it;s mothers
99 if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
100 TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
101 TString str=pTrack->GetName();
102 while((tid=pTrack->GetFirstMother()) >= 0){
103 pTrack=pStack->Particle(tid);
104 str+=" from ";str+=pTrack->GetName();
105 }
d3da6dc4 106 }//if(tid==-1)
107 }//events loop
108 pAL->UnloadHeader(); pAL->UnloadKinematics();
109 return mtid;
110}
111//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
113{
114// Counts total number of particles of given sort (including secondary) for a given event
115 AliRunLoader *pAL=AliRunLoader::Open();
116 pAL->GetEvent(evt);
117 if(pAL->LoadHeader()) return 0;
118 if(pAL->LoadKinematics()) return 0;
119 AliStack *pStack=pAL->Stack();
120
121 Int_t iCnt=0;
122 for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
123
124 pAL->UnloadHeader(); pAL->UnloadKinematics();
125 return iCnt;
126}
127//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++