]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDParam.cxx
Geometry V2 updated with the final frames. Now completed.
[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 <TGeoPhysicalNode.h> //ctor
26 #include <TGeoBBox.h>
27 ClassImp(AliHMPIDParam)
28
29
30 Float_t AliHMPIDParam::fgkMinPcX[]={0.,0.,0.,0.,0.,0.};
31 Float_t AliHMPIDParam::fgkMaxPcX[]={0.,0.,0.,0.,0.,0.};
32 Float_t AliHMPIDParam::fgkMinPcY[]={0.,0.,0.,0.,0.,0.};
33 Float_t AliHMPIDParam::fgkMaxPcY[]={0.,0.,0.,0.,0.,0.};
34
35 Float_t AliHMPIDParam::fgCellX=0.;
36 Float_t AliHMPIDParam::fgCellY=0.;
37
38 Float_t AliHMPIDParam::fgPcX=0;
39 Float_t AliHMPIDParam::fgPcY=0;
40
41 Float_t AliHMPIDParam::fgAllX=0;
42 Float_t AliHMPIDParam::fgAllY=0;
43
44 Int_t AliHMPIDParam::fgSigmas=4;
45
46 AliHMPIDParam* AliHMPIDParam::fgInstance=0x0;        //singleton pointer               
47 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 AliHMPIDParam::AliHMPIDParam():TNamed("HmpidParam","default version") 
49 {
50 // Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
51 // In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.    
52 // Note that TGeoManager should be already initialized from geometry.root file  
53
54 if(!gGeoManager) 
55 {
56 TGeoManager::Import("misaligned_geometry.root");
57 if(!gGeoManager) AliFatal("!!!!!!No geometry loaded!!!!!!!");
58 }
59
60
61     Float_t Dead=2.6;// cm of the dead zones between PCs-> See 2CRC2099P1
62     TGeoBBox *bcell = (TGeoBBox *)gGeoManager->GetVolume("Hcel")->GetShape();
63     fgCellX=2.*bcell->GetDX(); fgCellY = 2.*bcell->GetDY();
64     fgPcX=80.*fgCellX; fgPcY = 48.*fgCellY;
65     fgAllX=2.*fgPcX+Dead;
66     fgAllY=3.*fgPcY+2.*Dead;
67
68      fgkMinPcX[1]=fgPcX+Dead; fgkMinPcX[3]=fgkMinPcX[1];  fgkMinPcX[5]=fgkMinPcX[3];
69      fgkMaxPcX[0]=fgPcX; fgkMaxPcX[2]=fgkMaxPcX[0];  fgkMaxPcX[4]=fgkMaxPcX[2];
70      fgkMaxPcX[1]=fgAllX; fgkMaxPcX[3]=fgkMaxPcX[1];  fgkMaxPcX[5]=fgkMaxPcX[3];
71    
72      fgkMinPcY[2]=fgPcY+Dead; fgkMinPcY[3]=fgkMinPcY[2];  
73      fgkMinPcY[4]=2.*fgPcY+2.*Dead; fgkMinPcY[5]=fgkMinPcY[4];
74      fgkMaxPcY[0]=fgPcY; fgkMaxPcY[1]=fgkMaxPcY[0];  
75      fgkMaxPcY[2]=2.*fgPcY+Dead; fgkMaxPcY[3]=fgkMaxPcY[2]; 
76      fgkMaxPcY[4]=fgAllY; fgkMaxPcY[5]=fgkMaxPcY[4];   
77     
78   fX=0.5*SizeAllX();
79   fY=0.5*SizeAllY();
80   for(Int_t i=kMinCh;i<=kMaxCh;i++) 
81     if(gGeoManager && gGeoManager->IsClosed()) {
82 //      fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix(); // previous style
83       TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("/HMPID/Chamber%i",i));
84       if (!pne) {
85         AliErrorClass(Form("The symbolic volume %s does not correspond to any physical entry!",Form("HMPID_%i",i)));
86         fM[i]=new TGeoHMatrix;
87         IdealPosition(i,fM[i]);
88       } else {
89         TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
90         if(pnode) fM[i]=pnode->GetMatrix();
91         else {
92           fM[i]=new TGeoHMatrix;
93           IdealPosition(i,fM[i]);
94         }
95       }
96     } else{
97       fM[i]=new TGeoHMatrix;
98       IdealPosition(i,fM[i]);
99     } 
100   fgInstance=this; 
101 }//ctor
102 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103 void AliHMPIDParam::Print(Option_t* opt) const
104 {
105 // print some usefull (hopefully) info on some internal guts of HMPID parametrisation 
106   
107   for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
108 }//Print()
109 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 void AliHMPIDParam::IdealPosition(Int_t iCh, TGeoHMatrix *pMatrix)
111 {
112 // Construct ideal position matrix for a given chamber
113 // Arguments: iCh- chamber ID; pMatrix- pointer to precreated unity matrix where to store the results
114 //   Returns: none
115   const Double_t kAngHor=19.5;        //  horizontal angle between chambers  19.5 grad
116   const Double_t kAngVer=20;          //  vertical angle between chambers    20   grad     
117   const Double_t kAngCom=30;          //  common HMPID rotation with respect to x axis  30   grad     
118   const Double_t kTrans[3]={490,0,0}; //  center of the chamber is on window-gap surface
119   pMatrix->RotateY(90);               //  rotate around y since initial position is in XY plane -> now in YZ plane
120   pMatrix->SetTranslation(kTrans);    //  now plane in YZ is shifted along x 
121   switch(iCh){
122     case 0:                pMatrix->RotateY(kAngHor);  pMatrix->RotateZ(-kAngVer);  break; //right and down 
123     case 1:                                            pMatrix->RotateZ(-kAngVer);  break; //down              
124     case 2:                pMatrix->RotateY(kAngHor);                               break; //right 
125     case 3:                                                                         break; //no rotation
126     case 4:                pMatrix->RotateY(-kAngHor);                              break; //left   
127     case 5:                                            pMatrix->RotateZ(kAngVer);   break; //up
128     case 6:                pMatrix->RotateY(-kAngHor); pMatrix->RotateZ(kAngVer);   break; //left and up 
129   }
130   pMatrix->RotateZ(kAngCom);     //apply common rotation  in XY plane    
131    
132 }
133 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
134 Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
135 {
136 // Prints some useful info from stack
137 // Arguments: evt - event number. if not -1 print info only for that event
138 //            tid - track id. if not -1 then print it and all it's mothers if any   
139 //   Returns: mother tid of the given tid if any
140   AliRunLoader *pAL=AliRunLoader::Open(); 
141   if(pAL->LoadHeader()) return -1;
142   if(pAL->LoadKinematics()) return -1;
143   
144   Int_t mtid=-1;
145   Int_t iNevt=pAL->GetNumberOfEvents();
146   
147   for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
148     if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
149     pAL->GetEvent(iEvt);    
150     AliStack *pStack=pAL->Stack();  
151     if(tid==-1){                        //print all tids for this event
152       for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
153       Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
154     }else{                              //print only this tid and it;s mothers
155       if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
156       TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
157       TString str=pTrack->GetName();
158       while((tid=pTrack->GetFirstMother()) >= 0){
159         pTrack=pStack->Particle(tid);
160         str+=" from ";str+=pTrack->GetName();
161       } 
162     }//if(tid==-1)      
163   }//events loop
164   pAL->UnloadHeader();  pAL->UnloadKinematics();
165   return mtid;
166 }
167 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
169 {
170 // Counts total number of particles of given sort (including secondary) for a given event
171   AliRunLoader *pAL=AliRunLoader::Open(); 
172   pAL->GetEvent(evt);    
173   if(pAL->LoadHeader()) return 0;
174   if(pAL->LoadKinematics()) return 0;
175   AliStack *pStack=pAL->Stack();
176   
177   Int_t iCnt=0;
178   for(Int_t i=0;i<pStack->GetNtrack();i++) if(pStack->Particle(i)->GetPdgCode()==pid) iCnt++;
179   
180   pAL->UnloadHeader();  pAL->UnloadKinematics();
181   return iCnt;
182 }
183 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++