]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDParam.cxx
Add TPC preprocessor (Haavard, Marian)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.cxx
index c264b6805a196086555ed32247ae7946f01f0d1e..5ae43cbbb16eb60e592a160a5d37b0a1a569d29a 100644 (file)
 #include <AliRunLoader.h>  //Stack()
 #include <AliStack.h>      //Stack()
 #include <TParticle.h>     //Stack()    
-#include "AliHMPIDHelix.h"  //TestTrans()
+#include <TGeoPhysicalNode.h> //ctor
 
 ClassImp(AliHMPIDParam)
 
 AliHMPIDParam* AliHMPIDParam::fgInstance=0x0;        //singleton pointer               
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-AliHMPIDParam::AliHMPIDParam():TNamed("RichParam","default version") 
+AliHMPIDParam::AliHMPIDParam():TNamed("HmpidParam","default version") 
 {
 // Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
 // In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.    
 // Note that TGeoManager should be already initialized from geometry.root file  
   fX=0.5*AliHMPIDDigit::SizeAllX();
   fY=0.5*AliHMPIDDigit::SizeAllY();
-  for(Int_t i=0;i<7;i++) fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix();
+  for(Int_t i=AliHMPIDDigit::kMinCh;i<=AliHMPIDDigit::kMaxCh;i++) 
+    if(gGeoManager && gGeoManager->IsClosed()) {
+//      fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix(); // previous style
+      TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("/HMPID/Chamber%i",i));
+      if (!pne) {
+        AliErrorClass(Form("The symbolic volume %s does not correspond to any physical entry!",Form("HMPID_%i",i)));
+        fM[i]=new TGeoHMatrix;
+        IdealPosition(i,fM[i]);
+      } else {
+        TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
+        if(pnode) fM[i]=pnode->GetMatrix();
+        else {
+          fM[i]=new TGeoHMatrix;
+          IdealPosition(i,fM[i]);
+        }
+      }
+    } else{
+      fM[i]=new TGeoHMatrix;
+      IdealPosition(i,fM[i]);
+    } 
   fgInstance=this; 
 }//ctor
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -46,9 +65,33 @@ void AliHMPIDParam::Print(Option_t* opt) const
   for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
 }//Print()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDParam::IdealPosition(Int_t iCh, TGeoHMatrix *pMatrix)
+{
+// Construct ideal position matrix for a given chamber
+// Arguments: iCh- chamber ID; pMatrix- pointer to precreated unity matrix where to store the results
+//   Returns: none
+  const Double_t kAngHor=19.5; //  horizontal angle between chambers  19.5 grad
+  const Double_t kAngVer=20;   //  vertical angle between chambers    20   grad     
+  const Double_t kAngCom=30;   //  common HMPID rotation with respect to x axis  30   grad     
+  const Double_t trans[3]={490,0,0}; //center of the chamber is on window-gap surface
+  pMatrix->RotateY(90);           //rotate around y since initial position is in XY plane -> now in YZ plane
+  pMatrix->SetTranslation(trans); //now plane in YZ is shifted along x 
+  switch(iCh){
+    case 0:                pMatrix->RotateY(kAngHor);  pMatrix->RotateZ(-kAngVer);  break; //right and down 
+    case 1:                                            pMatrix->RotateZ(-kAngVer);  break; //down              
+    case 2:                pMatrix->RotateY(kAngHor);                               break; //right 
+    case 3:                                                                         break; //no rotation
+    case 4:                pMatrix->RotateY(-kAngHor);                              break; //left   
+    case 5:                                            pMatrix->RotateZ(kAngVer);   break; //up
+    case 6:                pMatrix->RotateY(-kAngHor); pMatrix->RotateZ(kAngVer);   break; //left and up 
+  }
+  pMatrix->RotateZ(kAngCom);     //apply common rotation  in XY plane    
+   
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
 {
-// Prints some usefull info from stack
+// Prints some useful info from stack
 // Arguments: evt - event number. if not -1 print info only for that event
 //            tid - track id. if not -1 then print it and all it's mothers if any   
 //   Returns: mother tid of the given tid if any
@@ -57,7 +100,7 @@ Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
   if(pAL->LoadKinematics()) return -1;
   
   Int_t mtid=-1;
-  Int_t iNevt=pAL->GetNumberOfEvents();     Printf("This session contains %i event(s)",iNevt);
+  Int_t iNevt=pAL->GetNumberOfEvents();
   
   for(Int_t iEvt=0;iEvt<iNevt;iEvt++){//events loop
     if(evt!=-1 && evt!=iEvt) continue; //in case one needs to print the requested event, ignore all others
@@ -74,7 +117,6 @@ Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
         pTrack=pStack->Particle(tid);
         str+=" from ";str+=pTrack->GetName();
       } 
-      Printf("%s",str.Data());       
     }//if(tid==-1)      
   }//events loop
   pAL->UnloadHeader();  pAL->UnloadKinematics();