]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDParam.cxx
Cluster finding improved.
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.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 #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
27 ClassImp(AliHMPIDParam)
28
29 AliHMPIDParam* AliHMPIDParam::fgInstance=0x0;        //singleton pointer               
30 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 AliHMPIDParam::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 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42 void 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 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
50 {
51 // Prints some useful 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();
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     }//if(tid==-1)      
78   }//events loop
79   pAL->UnloadHeader();  pAL->UnloadKinematics();
80   return mtid;
81 }
82 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83 Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
84 {
85 // Counts total number of particles of given sort (including secondary) for a given event
86   AliRunLoader *pAL=AliRunLoader::Open(); 
87   pAL->GetEvent(evt);    
88   if(pAL->LoadHeader()) return 0;
89   if(pAL->LoadKinematics()) return 0;
90   AliStack *pStack=pAL->Stack();
91   
92   Int_t iCnt=0;
93   for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
94   
95   pAL->UnloadHeader();  pAL->UnloadKinematics();
96   return iCnt;
97 }
98 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++